>>8,h[p*2+1]=g%256}return h},decompressFromUint8Array:function(d){if(d==null)return l.decompress(d);for(var a=new Array(d.length/2),h=0,p=a.length;h>1}else{for(m=1,p=0;p>1}S--,S==0&&(S=Math.pow(2,T),T++),delete v[b]}else for(m=g[b],p=0;p>1;S--,S==0&&(S=Math.pow(2,T),T++),g[w]=_++,b=String(y)}if(b!==""){if(Object.prototype.hasOwnProperty.call(v,b)){if(b.charCodeAt(0)<256){for(p=0;p>1}else{for(m=1,p=0;p>1}S--,S==0&&(S=Math.pow(2,T),T++),delete v[b]}else for(m=g[b],p=0;p>1;S--,S==0&&(S=Math.pow(2,T),T++)}for(m=2,p=0;p>1;for(;;)if(k=k<<1,C==a-1){A.push(h(k));break}else C++;return A.join("")},decompress:function(d){return d==null?"":d==""?null:l._decompress(d.length,32768,function(a){return d.charCodeAt(a)})},_decompress:function(d,a,h){var p=[],m,g=4,v=4,y=3,w="",b=[],S,_,T,A,k,C,E,R={val:h(0),position:a,index:1};for(S=0;S<3;S+=1)p[S]=S;for(T=0,k=Math.pow(2,2),C=1;C!=k;)A=R.val&R.position,R.position>>=1,R.position==0&&(R.position=a,R.val=h(R.index++)),T|=(A>0?1:0)*C,C<<=1;switch(m=T){case 0:for(T=0,k=Math.pow(2,8),C=1;C!=k;)A=R.val&R.position,R.position>>=1,R.position==0&&(R.position=a,R.val=h(R.index++)),T|=(A>0?1:0)*C,C<<=1;E=s(T);break;case 1:for(T=0,k=Math.pow(2,16),C=1;C!=k;)A=R.val&R.position,R.position>>=1,R.position==0&&(R.position=a,R.val=h(R.index++)),T|=(A>0?1:0)*C,C<<=1;E=s(T);break;case 2:return""}for(p[3]=E,_=E,b.push(E);;){if(R.index>d)return"";for(T=0,k=Math.pow(2,y),C=1;C!=k;)A=R.val&R.position,R.position>>=1,R.position==0&&(R.position=a,R.val=h(R.index++)),T|=(A>0?1:0)*C,C<<=1;switch(E=T){case 0:for(T=0,k=Math.pow(2,8),C=1;C!=k;)A=R.val&R.position,R.position>>=1,R.position==0&&(R.position=a,R.val=h(R.index++)),T|=(A>0?1:0)*C,C<<=1;p[v++]=s(T),E=v-1,g--;break;case 1:for(T=0,k=Math.pow(2,16),C=1;C!=k;)A=R.val&R.position,R.position>>=1,R.position==0&&(R.position=a,R.val=h(R.index++)),T|=(A>0?1:0)*C,C<<=1;p[v++]=s(T),E=v-1,g--;break;case 2:return b.join("")}if(g==0&&(g=Math.pow(2,y),y++),p[E])w=p[E];else if(E===v)w=_+_.charAt(0);else return null;b.push(w),p[v++]=_+w.charAt(0),g--,_=w,g==0&&(g=Math.pow(2,y),y++)}}};return l}();n!=null?n.exports=i:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return i})}(vn)),vn.exports}var Wi=nr();const ir="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2084%2062'%3e%3crect%20width='64'%20height='48'%20x='18'%20y='2'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3crect%20width='32'%20height='48'%20x='2'%20y='12'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%234169E1'%20d='M14%2052a4%204%200%201%201-8%200%204%204%200%200%201%208%200Zm64-42a4%204%200%201%201-8%200%204%204%200%200%201%208%200Z'/%3e%3c/svg%3e",sr="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2082%2062'%3e%3crect%20width='78'%20height='58'%20x='2'%20y='2'%20fill='%23999'%20fill-opacity='.3'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3crect%20width='18'%20height='46'%20x='8'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3crect%20width='18'%20height='46'%20x='32'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3crect%20width='18'%20height='46'%20x='56'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3c/svg%3e",or="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2084%2062'%3e%3crect%20width='64'%20height='48'%20x='18'%20y='2'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%23999'%20fill-opacity='.3'%20d='M19%203h62v10H19z'/%3e%3cpath%20stroke='%234169E1'%20stroke-width='2'%20d='M43%208a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3cpath%20stroke='%23999'%20stroke-width='2'%20d='M52%208a2%202%200%201%201-4%200%202%202%200%200%201%204%200Zm9%200a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3crect%20width='32'%20height='48'%20x='2'%20y='12'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%23999'%20fill-opacity='.3'%20d='M3%2049h30v10H3z'/%3e%3cpath%20stroke='%234169E1'%20stroke-width='2'%20d='M11%2054a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3cpath%20stroke='%23999'%20stroke-width='2'%20d='M20%2054a2%202%200%201%201-4%200%202%202%200%200%201%204%200Zm9%200a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3c/svg%3e",cr=200,ar=10;async function Mn(){const{masto:n}=re(),i=n.v1.followedTags.list({limit:cr}).values(),s=[];let o=0;do{const{value:c,done:r}=await i.next();if(r||(c==null?void 0:c.length)===0)break;s.push(...c),o++}while(oc.name.localeCompare(r.name)),s.length&&setTimeout(()=>{Ue.account.set("followedTags",{tags:s,updatedAt:Date.now()})},1),s}const rr=24*60*60*1e3;async function lr(){try{const{tags:n,updatedAt:i}=Ue.account.get("followedTags")||{};return n!=null&&n.length?(Date.now()-i>rr&&Mn(),n):await Mn()}catch{return[]}}const Zi=document.createElement("div"),dr=n=>{if(!n)return[];if(n.indexOf("#")===-1)return[];Zi.innerHTML=n;const i=Zi.querySelectorAll("a.hashtag");return i.length?Array.from(i).map(s=>s.innerText.trim().replace(/^[^#]*#+/,"")):[]};function wn({children:n}){if(typeof n=="string")return n;const[i,s]=M("");return Q(()=>{Promise.resolve(n).then(s)},[n]),i}const It=9,ur=["following","mentions","notifications","list","public","trending","search","hashtag","bookmarks","favourites"],Js={following:{id:"7ZJHdw"},notifications:{id:"iDNBZe"},list:{id:"h16FyT"},public:{id:"tXgQpk"},search:{id:"A1taO8"},"account-statuses":{id:"AeXO77"},bookmarks:{id:"7Ff7ia"},favourites:{id:"zZOZj7"},hashtag:{id:"GP8RLS"},trending:{id:"4/iCqx"},mentions:{id:"/bZzdR"}},kn={list:[{text:{id:"DUMt1y"},name:"id",notRequired:!0}],public:[{text:{id:"OgyJSr"},name:"local",type:"checkbox"},{text:{id:"kyAi7k"},name:"instance",type:"text",placeholder:{id:"7defFj"},notRequired:!0}],trending:[{text:{id:"kyAi7k"},name:"instance",type:"text",placeholder:{id:"7defFj"},notRequired:!0}],search:[{text:{id:"dmloPh"},name:"query",type:"text",placeholder:{id:"UHDQDE"},notRequired:!0}],"account-statuses":[{text:"@",name:"id",type:"text",placeholder:"cheeaun@mastodon.social"}],hashtag:[{text:"#",name:"hashtag",type:"text",placeholder:{id:"a6oTWs"},pattern:"[^#]+"},{text:{id:"eK4SL/"},name:"media",type:"checkbox"},{text:{id:"kyAi7k"},name:"instance",type:"text",placeholder:{id:"7defFj"},notRequired:!0}]},hr=bt(async({id:n})=>{const i=await re().masto.v1.accounts.$select(n).fetch();return i.username||i.acct||i.displayName}),$n={following:{id:"home",title:(n,i)=>i===0?pe._({id:"i0qMbr"}):pe._({id:"following.title"}),path:"/",icon:"home"},mentions:{id:"mentions",title:{id:"/bZzdR"},path:"/mentions",icon:"at"},notifications:{id:"notifications",title:{id:"iDNBZe"},path:"/notifications",icon:"notification"},list:{id:({id:n})=>n?"list":"lists",title:({id:n})=>n?la(n):pe._({id:"h16FyT"}),path:({id:n})=>n?`/l/${n}`:"/l",icon:"list",excludeViewMode:({id:n})=>n?[]:["multi-column"]},public:{id:"public",title:({local:n})=>n?pe._({id:"d5zxa4"}):pe._({id:"4ERYY7"}),subtitle:({instance:n})=>n||re().instance,path:({local:n,instance:i})=>`/${i}/p${n?"/l":""}`,icon:({local:n})=>n?"building":"earth"},trending:{id:"trending",title:{id:"4/iCqx"},subtitle:({instance:n})=>n||re().instance,path:({instance:n})=>`/${n}/trending`,icon:"chart"},search:{id:"search",title:({query:n})=>n?`“${n}”`:pe._({id:"A1taO8"}),path:({query:n})=>n?`/search?q=${encodeURIComponent(n)}&type=statuses`:"/search",icon:"search",excludeViewMode:({query:n})=>n?[]:["multi-column"]},"account-statuses":{id:"account-statuses",title:hr,path:({id:n})=>`/a/${n}`,icon:"user"},bookmarks:{id:"bookmarks",title:{id:"7Ff7ia"},path:"/b",icon:"bookmark"},favourites:{id:"favourites",title:{id:"zZOZj7"},path:"/f",icon:"heart"},hashtag:{id:"hashtag",title:({hashtag:n})=>n,subtitle:({instance:n})=>n||re().instance,path:({hashtag:n,instance:i,media:s})=>`${i?`/${i}`:""}/t/${n.split(/\s+/).join("+")}${s?"?media=1":""}`,icon:"hashtag"}};function fr({onClose:n}){const{_:i}=le(),s=We(x),{shortcuts:o}=s,[c,r]=M(!1),[u,l]=M(!1),[d]=ki();return e("div",{id:"shortcuts-settings-container",class:"sheet",tabindex:"-1",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(I,{icon:"x",alt:pe._({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:[e(I,{icon:"shortcut"})," ",e(f,{id:"CTqTgr"})," ",e("sup",{style:{fontSize:12,opacity:.5,textTransform:"uppercase"},children:e(f,{id:"A1As8l"})})]})}),e("main",{children:[e("p",{children:e(f,{id:"CIHAsy"})}),e("div",{class:"shortcuts-view-mode",children:[{value:"float-button",label:pe._({id:"qwdOim"}),imgURL:ir},{value:"tab-menu-bar",label:pe._({id:"UxBoCm"}),imgURL:or},{value:"multi-column",label:pe._({id:"uvDfdW"}),imgURL:sr}].map(({value:a,label:h,imgURL:p})=>{const m=s.settings.shortcutsViewMode===a||a==="float-button"&&!s.settings.shortcutsViewMode;return e("label",{class:m?"checked":"",children:[e("input",{type:"radio",name:"shortcuts-view-mode",value:a,checked:m,onChange:g=>{x.settings.shortcutsViewMode=g.target.value}})," ",e("img",{src:p,alt:"",width:"80",height:"58"})," ",e("span",{children:h})]},a)})}),o.length>0?e(U,{children:[e("ol",{class:"shortcuts-list",ref:d,children:o.filter(Boolean).map((a,h)=>{const p=Object.values(a).join("-"),{type:m}=a;if(!$n[m])return null;let{icon:g,title:v,subtitle:y,excludeViewMode:w}=$n[m];typeof v=="function"?v=v(a,h):v=i(v),typeof y=="function"?y=y(a,h):y=i(y),typeof g=="function"&&(g=g(a,h)),typeof w=="function"&&(w=w(a,h));const b=w==null?void 0:w.includes(s.settings.shortcutsViewMode);return e("li",{children:[e(I,{icon:g}),e("span",{class:"shortcut-text",children:[e(wn,{children:v}),y&&e(U,{children:[" ",e("small",{class:"ib insignificant",children:y})]}),b&&e("span",{class:"tag",children:e(f,{id:"5KJFnN"})})]}),e("span",{class:"shortcut-actions",children:[e("button",{type:"button",class:"plain small",disabled:h===0,onClick:()=>{const S=Array.from(x.shortcuts);if(h>0){const _=x.shortcuts[h-1];S[h-1]=a,S[h]=_,x.shortcuts=S}},children:e(I,{icon:"arrow-up",alt:pe._({id:"QyioBP"})})}),e("button",{type:"button",class:"plain small",disabled:h===o.length-1,onClick:()=>{const S=Array.from(x.shortcuts);if(h{r({shortcut:a,shortcutIndex:h})},children:e(I,{icon:"pencil",alt:pe._({id:"ePK91l"})})})]})]},p)})}),o.length===1&&s.settings.shortcutsViewMode!=="float-button"&&e("div",{class:"ui-state insignificant",children:[e(I,{icon:"info"})," ",e("small",{children:e(f,{id:"3Xq4Zi"})})]})]}):e("div",{class:"ui-state insignificant",children:[e("p",{children:s.settings.shortcutsViewMode==="multi-column"?pe._({id:"3xIN+E"}):pe._({id:"vLxvHT"})}),e("p",{children:e(f,{id:"Fq4zw3",components:{0:e("br",{}),1:e("a",{href:"#",onClick:a=>{a.preventDefault(),x.shortcuts=[{type:"following"},{type:"notifications"}]}})}})})]}),e("p",{class:"insignificant",children:o.length>=It&&(s.settings.shortcutsViewMode==="multi-column"?pe._({id:"RqXfsz",values:{SHORTCUTS_LIMIT:It}}):pe._({id:"EVRO/o",values:{SHORTCUTS_LIMIT:It}}))}),e("p",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e("button",{type:"button",class:"light",onClick:()=>l(!0),children:e(f,{id:"bgVLbt"})}),e("button",{type:"button",disabled:o.length>=It,onClick:()=>r(!0),children:[e(I,{icon:"plus"})," ",e("span",{children:s.settings.shortcutsViewMode==="multi-column"?pe._({id:"Vh3ADI"}):pe._({id:"9tmn6W"})})]})]})]}),c&&e(Ye,{onClick:a=>{a.target===a.currentTarget&&r(!1)},children:e(pr,{shortcut:c.shortcut,shortcutIndex:c.shortcutIndex,onSubmit:({result:a,mode:h})=>{h==="edit"?x.shortcuts[c.shortcutIndex]=a:x.shortcuts.push(a)},onClose:()=>r(!1)})}),u&&e(Ye,{onClick:a=>{a.target===a.currentTarget&&l(!1)},children:e(mr,{shortcuts:o,onClose:()=>l(!1)})})]})}const Xi={list:{id:"1qL+L+"},search:{id:"dmTmkQ"},hashtag:{id:"E8laYz"}};function pr({onSubmit:n,disabled:i,shortcut:s,shortcutIndex:o,onClose:c}){var w,b;const{_:r}=le(),u=!!s,[l,d]=M((s==null?void 0:s.type)||null),[a,h]=M("default"),[p,m]=M([]),[g,v]=M([]);Q(()=>{(async()=>{if(l==="list")try{h("loading");const S=await hn();m(S),h("default")}catch{h("error")}})(),(async()=>{if(l==="hashtag")try{const S=await Mn();v(S)}catch{}})()},[l]);const y=j();return Q(()=>{if(u&&l&&kn[l]){const S=y.current;kn[l].forEach(({name:_,type:T})=>{const A=S.querySelector(`[name="${_}"]`);A&&s[_]&&(T==="checkbox"?A.checked=s[_]==="on":A.value=s[_])})}},[u,l]),e("div",{id:"shortcut-settings-form",class:"sheet",children:[!!c&&e("button",{type:"button",class:"sheet-close",onClick:c,children:e(I,{icon:"x",alt:pe._({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:u?pe._({id:"pe1jog"}):pe._({id:"Lsxpe5"})})}),e("main",{tabindex:"-1",children:e("form",{ref:y,onSubmit:S=>{S.preventDefault();const _=new FormData(S.target),T={};_.forEach((A,k)=>{T[k]=A==null?void 0:A.trim(),k==="instance"&&(T[k]=T[k].replace(/^https?:\/\//,"").replace(/\/+$/,""),T[k]=T[k].replace(/^@?[^@]+@/,""))}),T.type&&(n({result:T,mode:u?"edit":"add"}),S.target.reset(),d(null),c==null||c())},children:[e("p",{children:e("label",{children:[e("span",{children:e(f,{id:"cklVjM"})}),e("select",{required:!0,disabled:i,onChange:S=>{d(S.target.value)},defaultValue:u?s.type:void 0,name:"type",dir:"auto",children:[e("option",{}),ur.map(S=>e("option",{value:S,children:r(Js[S])}))]})]})}),(b=(w=kn[l])==null?void 0:w.map)==null?void 0:b.call(w,({text:S,name:_,type:T,placeholder:A,pattern:k,notRequired:C})=>l==="list"?e("p",{children:e("label",{children:[e("span",{children:e(f,{id:"2BBAbc"})}),e("select",{name:"id",required:!C,disabled:i||a==="loading",defaultValue:u?s.id:void 0,dir:"auto",children:[e("option",{value:""}),p.map(E=>e("option",{value:E.id,children:E.title}))]})]})}):e("p",{children:e("label",{children:[e("span",{children:r(S)})," ",e("input",{type:T,switch:T==="checkbox"||void 0,name:_,placeholder:r(A),required:T==="text"&&!C,disabled:i,list:l==="hashtag"?"followed-hashtags-datalist":null,autocorrect:"off",autocapitalize:"off",spellCheck:!1,pattern:k,dir:"auto"}),l==="hashtag"&&g.length>0&&e("datalist",{id:"followed-hashtags-datalist",children:g.map(E=>e("option",{value:E.name}))})]})})),!!Xi[l]&&e("p",{class:"form-note insignificant",children:[e(I,{icon:"info"}),r(Xi[l])]}),e("footer",{children:[e("button",{type:"submit",class:"block",disabled:i||a==="loading",children:u?pe._({id:"tfDRzk"}):pe._({id:"m16xKo"})}),u&&e("button",{type:"button",class:"light danger",onClick:()=>{x.shortcuts.splice(o,1),c==null||c()},children:e(f,{id:"t/YqKh"})})]})]})})]})}function mr({shortcuts:n,onClose:i}){var m;const{_:s}=le(),{masto:o}=re(),c=Ae(()=>!n||!n.filter(Boolean).length?"":Wi.compressToEncodedURIComponent(JSON.stringify(n.filter(Boolean))),[n]),[r,u]=M(""),[l,d]=M("default"),a=Ae(()=>{if(!r)return d("default"),null;try{const g=JSON.parse(Wi.decompressFromEncodedURIComponent(r));if(!Array.isArray(g))throw new Error("Not an array");return d("default"),g}catch{try{const v=JSON.parse(r);if(!Array.isArray(v))throw new Error("Not an array");return d("default"),v}catch{return d("error"),null}}},[r]),h=x.shortcuts.length>0,p=j();return e("div",{id:"import-export-container",class:"sheet",children:[!!i&&e("button",{type:"button",class:"sheet-close",onClick:i,children:e(I,{icon:"x",alt:pe._({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:e(f,{id:"OOa7/5",components:{0:e("small",{class:"ib insignificant"})}})})}),e("main",{tabindex:"-1",children:[e("section",{children:[e("h3",{children:[e(I,{icon:"arrow-down-circle",size:"l",class:"insignificant"})," ",e("span",{children:e(f,{id:"l3s5ri"})})]}),e("p",{class:"field-button",children:[e("input",{ref:p,type:"text",name:"import",placeholder:pe._({id:"tBmklN"}),class:"block",onInput:g=>{u(g.target.value)},dir:"auto"}),x.settings.shortcutSettingsCloudImportExport&&e("button",{type:"button",class:"plain2 small",disabled:l==="cloud-downloading",onClick:async()=>{d("cloud-downloading");const g=kt();fe(pe._({id:"HLqLGx"}));try{const y=(await o.v1.accounts.relationships.fetch({id:[g]}))[0];if(y){const{note:w=""}=y;if(/(.*)<\/phanpy-shortcuts-settings>/.test(w)){const b=w.match(/(.*)<\/phanpy-shortcuts-settings>/)[1],{v:S,dt:_,data:T}=JSON.parse(b);p.current.value=T,p.current.dispatchEvent(new Event("input"))}}d("default")}catch{d("error"),fe(pe._({id:"gCDfX+"}))}},title:pe._({id:"B6cG3J"}),children:[e(I,{icon:"cloud"}),e(I,{icon:"arrow-down"})]})]}),!!a&&Array.isArray(a)&&e(U,{children:[e("p",{children:[e("b",{children:a.length})," shortcut",a.length>1?"s":""," ",e("small",{class:"insignificant",children:["(",r.length," characters)"]})]}),e("ol",{class:"import-settings-list",children:a.map(g=>{var v,y;return e("li",{children:[e("span",{style:{opacity:n.some(w=>Object.keys(w).every(b=>w[b]===g[b]))?1:0},children:"*"}),e("span",{children:[s(Js[g.type]),g.type==="list"&&" ⚠️"," ",(y=(v=kn[g.type])==null?void 0:v.map)==null?void 0:y.call(v,({text:w,name:b,type:S})=>g[b]?e(U,{children:[e("span",{class:"tag collapsed insignificant",children:[w,":"," ",S==="checkbox"?g[b]==="on"?"✅":"❌":g[b]]})," "]}):null)]})]})})}),e("p",{children:[e("small",{children:e(f,{id:"o6sElH"})}),e("br",{}),e("small",{children:["⚠️"," ",e(f,{id:"N4z4P/"})]})]})]}),l==="error"&&e("p",{class:"error",children:e("small",{children:["⚠️ ",e(f,{id:"ZhsPEb"})]})}),e("p",{children:[h&&e(U,{children:[e(pt,{confirmLabel:pe._({id:"6MzUUU"}),menuFooter:e("div",{class:"footer",children:e(f,{id:"nl8sCE"})}),onClick:()=>{const g=a.filter(w=>!x.shortcuts.some(b=>Object.keys(b).every(S=>b[S]===w[S])));if(!g.length){fe(pe._({id:"o6L30P"}));return}let v=[...x.shortcuts,...g];const y=v.length>It;y&&(v=v.slice(0,It)),x.shortcuts=v,fe(y?pe._({id:"SBmqmC",values:{SHORTCUTS_LIMIT:It}}):pe._({id:"QO9uTx"})),i==null||i()},children:e("button",{type:"button",class:"plain2",disabled:!a,children:e(f,{id:"c89gCv"})})})," "]}),e(pt,{confirmLabel:h?pe._({id:"6ZjzWP"}):pe._({id:"DWumLi"}),menuItemClassName:h?"danger":void 0,onClick:()=>{x.shortcuts=a,fe(pe._({id:"QO9uTx"})),i==null||i()},children:e("button",{type:"button",class:"plain2",disabled:!a,children:h?pe._({id:"uIp8WL"}):pe._({id:"Sjnlwj"})})})]})]}),e("section",{children:[e("h3",{children:[e(I,{icon:"arrow-up-circle",size:"l",class:"insignificant"})," ",e("span",{children:e(f,{id:"GS+Mus"})})]}),e("p",{children:e("input",{style:{width:"100%"},type:"text",value:c,readOnly:!0,onClick:g=>{if(g.target.value){g.target.select();try{navigator.clipboard.writeText(g.target.value),fe(pe._({id:"cWtH+v"}))}catch{fe(pe._({id:"yUWyHa"}))}}},dir:"auto"})}),e("p",{children:[e("button",{type:"button",class:"plain2",disabled:!c,onClick:()=>{try{navigator.clipboard.writeText(c),fe(pe._({id:"+Kq2vY"}))}catch{fe(pe._({id:"tFvxZF"}))}},children:[e(I,{icon:"clipboard"})," ",e("span",{children:e(f,{id:"he3ygx"})})]})," ",(navigator==null?void 0:navigator.share)&&((m=navigator==null?void 0:navigator.canShare)==null?void 0:m.call(navigator,{text:c}))&&e("button",{type:"button",class:"plain2",disabled:!c,onClick:()=>{try{navigator.share({text:c})}catch{alert(pe._({id:"TtG3Uh"}))}},children:[e(I,{icon:"share"})," ",e("span",{children:e(f,{id:"Z8lGw6"})})]})," ",x.settings.shortcutSettingsCloudImportExport&&e("button",{type:"button",class:"plain2",disabled:l==="cloud-uploading",onClick:async()=>{d("cloud-uploading");const g=kt();try{const y=(await o.v1.accounts.relationships.fetch({id:[g]}))[0];if(y){const{note:w=""}=y;let b="";const S=JSON.stringify({v:"1",dt:Date.now(),data:c});/(.*)<\/phanpy-shortcuts-settings>/.test(w)?b=w.replace(/(.*)<\/phanpy-shortcuts-settings>/,`${S}`):b=`${w}
+
+
+${S}`,fe(pe._({id:"9ZYiLz"})),await o.v1.accounts.$select(g).note.create({comment:b}),d("default"),fe(pe._({id:"5w02SH"}))}}catch{d("error"),fe(pe._({id:"aVsTYo"}))}},title:pe._({id:"gWd6Cu"}),children:[e(I,{icon:"cloud"}),e(I,{icon:"arrow-up"})]})," ",c.length>0&&e("small",{class:"insignificant ib",children:e(f,{id:"IPXOXm",values:{0:c.length}})})]}),!!c&&e("details",{children:[e("summary",{class:"insignificant",children:e("small",{children:e(f,{id:"e5E+WH"})})}),e("textarea",{style:{width:"100%"},rows:10,readOnly:!0,children:JSON.stringify(n.filter(Boolean),null,2)})]})]}),x.settings.shortcutSettingsCloudImportExport&&e("footer",{children:e("p",{children:[e(I,{icon:"cloud"})," ",e(f,{id:"C4T6O/"})]})})]})]})}ws(x,n=>{for(const[i,s,o,c]of n)/^show/i.test(s)&&!o&&ni()});function gr(){var c,r,u,l,d,a,h,p;const{_:n}=le(),i=We(x),s=ks(),o=Jt();return Q(()=>{setTimeout(xo,1e3)},[]),e(U,{children:[!!i.showCompose&&e(Ye,{class:`solid ${i.composerState.minimized?"min":""}`,minimized:!!i.composerState.minimized,children:e(Eo,{replyToStatus:typeof i.showCompose!="boolean"?i.showCompose.replyToStatus:((c=window.__COMPOSE__)==null?void 0:c.replyToStatus)||null,editStatus:((r=x.showCompose)==null?void 0:r.editStatus)||((u=window.__COMPOSE__)==null?void 0:u.editStatus)||null,draftStatus:((l=x.showCompose)==null?void 0:l.draftStatus)||((d=window.__COMPOSE__)==null?void 0:d.draftStatus)||null,onClose:m=>{const{newStatus:g,instance:v,type:y,scheduledAt:w}=m||{};x.showCompose=!1,window.__COMPOSE__=null,g&&(x.reloadStatusPage++,w&&x.reloadScheduledPosts++,fe({text:{post:n(w?{id:"IrX0sj"}:{id:"aTyHBW"}),reply:n(w?{id:"+38pse"}:{id:"lZdBKl"}),edit:n({id:"a5BN7l"})}[y||"post"],delay:1e3,duration:1e4,onClick:b=>{b.hideToast(),x.prevLocation=o,s(w?"/sp":v?`/${v}/s/${g.id}`:`/s/${g.id}`)}}))}})}),!!i.showSettings&&e(Ye,{onClose:()=>{x.showSettings=!1},children:e(oa,{onClose:()=>{x.showSettings=!1}})}),!!i.showAccounts&&e(Ye,{onClose:()=>{x.showAccounts=!1},children:e(jc,{onClose:()=>{x.showAccounts=!1}})}),!!i.showAccount&&e(Ye,{onClose:()=>{x.showAccount=!1},children:e(La,{account:((a=i.showAccount)==null?void 0:a.account)||i.showAccount,instance:(h=i.showAccount)==null?void 0:h.instance,onClose:({destination:m}={})=>{x.showAccount=!1}})}),!!i.showDrafts&&e(Ye,{onClose:()=>{x.showDrafts=!1},children:e(Ma,{onClose:()=>x.showDrafts=!1})}),!!i.showMediaModal&&e(Ye,{onClick:m=>{(m.target===m.currentTarget||m.target.classList.contains("media"))&&(x.showMediaModal=!1)},children:e(Xs,{mediaAttachments:i.showMediaModal.mediaAttachments,instance:i.showMediaModal.instance,index:i.showMediaModal.mediaIndex,statusID:i.showMediaModal.statusID,onClose:()=>{x.showMediaModal=!1}})}),!!i.showShortcutsSettings&&e(Ye,{onClose:()=>{x.showShortcutsSettings=!1},children:e(fr,{onClose:()=>x.showShortcutsSettings=!1})}),!!i.showGenericAccounts&&e(Ye,{onClose:()=>{x.showGenericAccounts=!1},children:e(Pa,{instance:i.showGenericAccounts.instance,excludeRelationshipAttrs:i.showGenericAccounts.excludeRelationshipAttrs,postID:i.showGenericAccounts.postID,onClose:()=>x.showGenericAccounts=!1,blankCopy:i.showGenericAccounts.blankCopy})}),!!i.showMediaAlt&&e(Ye,{onClose:m=>{x.showMediaAlt=!1},children:e(Oa,{alt:i.showMediaAlt.alt||i.showMediaAlt,lang:(p=i.showMediaAlt)==null?void 0:p.lang,onClose:()=>{x.showMediaAlt=!1}})}),!!i.showEmbedModal&&e(Ye,{class:"solid",onClose:()=>{x.showEmbedModal=!1},children:e(Na,{html:i.showEmbedModal.html,url:i.showEmbedModal.url,width:i.showEmbedModal.width,height:i.showEmbedModal.height,onClose:()=>{x.showEmbedModal=!1}})}),!!i.showReportModal&&e(Ye,{onClose:()=>{x.showReportModal=!1},children:e(tr,{account:i.showReportModal.account,post:i.showReportModal.post,onClose:()=>{x.showReportModal=!1}})})]})}function si({accountID:n,onChange:i}){const{_:s}=le(),{masto:o}=re(),[c,r]=M("default"),[u,l]=M(null),[d,a]=M(null),h=d!==null;return e("p",{class:"follow-request-buttons",children:[e("button",{type:"button",disabled:c==="loading"||h,onClick:()=>{r("loading"),l("accept"),(async()=>{try{const p=await o.v1.followRequests.$select(n).authorize();if(!(p!=null&&p.followedBy))throw new Error("Follow request not accepted");a(p),i()}catch{}r("default")})()},children:e(f,{id:"g3UF2V"})})," ",e("button",{type:"button",disabled:c==="loading"||h,class:"light danger",onClick:()=>{r("loading"),l("reject"),(async()=>{try{const p=await o.v1.followRequests.$select(n).reject();if(p!=null&&p.followedBy)throw new Error("Follow request not rejected");a(p),i()}catch{r("default")}})()},children:e(f,{id:"1t/NnN"})}),e("span",{class:"follow-request-states",children:h&&u?u==="accept"?e(I,{icon:"check-circle",alt:s({id:"bzMKg7"}),class:"follow-accepted"}):e(I,{icon:"x-circle",alt:s({id:"ekCRTP"}),class:"follow-rejected"}):e(Be,{hidden:c!=="loading"})})]})}const Ji={mention:"comment",status:"notification",reblog:"rocket",follow:"follow",follow_request:"follow-add",favourite:"heart",poll:"poll",update:"pencil","admin.signup":"account-edit","admin.report":"account-warning",severed_relationships:"heart-break",moderation_warning:"alert",emoji_reaction:"emoji2","pleroma:emoji_reaction":"emoji2",annual_report:"celebrate"};function Qi({account:n,emoji:i,emoji_url:s}){let o,c;typeof s=="string"?o=s:(o=s==null?void 0:s.url,c=s==null?void 0:s.staticUrl);const r=o?e(Xo,{url:o,staticUrl:c,alt:i}):i;return e(f,{id:"i5uN6K",values:{account:n,emojiObject:r}})}const Wn={status:({account:n})=>e(f,{id:"idiIxW",values:{account:n}}),reblog:({count:n,account:i,postsCount:s,postType:o,components:{Subject:c}})=>e(f,{id:"jkt9P5",values:{0:Qe(n),1:Qe(n),count:n,postsCount:s,postType:o,account:i},components:{0:e(c,{clickable:n>1}),1:e("span",{title:n}),2:e(c,{clickable:n>1}),3:e("span",{title:n})}}),follow:({account:n,count:i,components:{Subject:s}})=>e(f,{id:"+71G9C",values:{0:Qe(i),count:i,account:n},components:{0:e(s,{clickable:i>1}),1:e("span",{title:i})}}),follow_request:({account:n})=>e(f,{id:"eh6NHW",values:{account:n}}),favourite:({account:n,count:i,postsCount:s,postType:o,components:{Subject:c}})=>e(f,{id:"RqX1mR",values:{0:Qe(i),1:Qe(i),count:i,postsCount:s,postType:o,account:n},components:{0:e(c,{clickable:i>1}),1:e("span",{title:i}),2:e(c,{clickable:i>1}),3:e("span",{title:i})}}),poll:()=>pe._({id:"kIlJaS"}),"poll-self":()=>pe._({id:"kpjzdN"}),"poll-voted":()=>pe._({id:"moT7M8"}),update:()=>pe._({id:"uzt17m"}),"favourite+reblog":({count:n,account:i,postsCount:s,postType:o,components:{Subject:c}})=>e(f,{id:"NunZZQ",values:{0:Qe(n),1:Qe(n),count:n,postsCount:s,postType:o,account:i},components:{0:e(c,{clickable:n>1}),1:e("span",{title:n}),2:e(c,{clickable:n>1}),3:e("span",{title:n})}}),"admin.sign_up":({account:n})=>e(f,{id:"fJCCpx",values:{account:n}}),"admin.report":({account:n,targetAccount:i})=>e(f,{id:"eNfCmq",values:{account:n,targetAccount:i}}),severed_relationships:({name:n})=>e(f,{id:"Xl9v6+",values:{name:n},components:{0:e("i",{})}}),moderation_warning:()=>e("b",{children:e(f,{id:"YqffEv"})}),emoji_reaction:Qi,"pleroma:emoji_reaction":Qi,annual_report:({year:n})=>e(f,{id:"INLTzH",values:{year:n}})},yr={account_suspension:({from:n,targetName:i})=>e(f,{id:"uRkcgw",values:{from:n,targetName:i},components:{0:e("i",{}),1:e("i",{})}}),domain_block:({from:n,targetName:i,followersCount:s,followingCount:o})=>e(f,{id:"Q3yArs",values:{from:n,targetName:i,followersCount:s,followingCount:o},components:{0:e("i",{}),1:e("i",{})}}),user_domain_block:({targetName:n,followersCount:i,followingCount:s})=>e(f,{id:"RQKWUa",values:{targetName:n,followersCount:i,followingCount:s},components:{0:e("i",{})}})},br={none:{id:"ipnHrn"},disable:{id:"jw0eSZ"},mark_statuses_as_sensitive:{id:"v9jO+F"},delete_statuses:{id:"raUMBQ"},sensitive:{id:"w2OpMr"},silence:{id:"mlycBx"},suspend:{id:"Fz4lZ1"}},Zn=30;function vr({notification:n,instance:i,isStatic:s,disableContextMenu:o}){var te,J,ue,he,ne,we,Ce;const{_:c}=le(),{masto:r}=re(),{id:u,status:l,account:d,report:a,event:h,moderation_warning:p,annualReport:m,_ids:g,_accounts:v,_statuses:y,_groupKeys:w,sampleAccounts:b,notificationsCount:S,groupKey:_,_notificationsCount:T,_sampleAccountsCount:A}=n;let{type:k}=n;if(k==="mention"&&!l)return null;const C=(l==null?void 0:l.reblog)||l,E=C==null?void 0:C.id,R=kt(),F=R===(d==null?void 0:d.id),D=(te=l==null?void 0:l.poll)==null?void 0:te.voted,W=!!(l!=null&&l.inReplyToAccountId)&&(l==null?void 0:l.inReplyToAccountId)!==R&&((J=l==null?void 0:l.account)==null?void 0:J.id)===R;let G=0,X=0;if(k==="favourite+reblog"){if(v)for(const se of v)(ue=se._types)!=null&&ue.includes("favourite")&&G++,(he=se._types)!=null&&he.includes("reblog")&&X++;!X&&G&&(k="favourite"),!G&&X&&(k="reblog")}let q;k==="poll"?q=Wn[F?"poll-self":D?"poll-voted":"poll"]:Wn[k]?q=Wn[k]:q=pe._({id:"ODqZt1",values:{type:k}});const Z=({clickable:se,...Te})=>se?e("b",{tabIndex:"0",onClick:Y,...Te}):e("b",{...Te}),B=S>0&&S>(b==null?void 0:b.length),ee=B?"remote":"local";if(typeof q=="function"){const se=(k==="favourite"||k==="reblog")&&S?B?S:b==null?void 0:b.length:(v==null?void 0:v.length)||(b==null?void 0:b.length)||(d?1:0),Te=(y==null?void 0:y.length)||(l?1:0);if(k==="admin.report"){const Ie=a==null?void 0:a.targetAccount;Ie&&(q=q({account:e(yt,{account:d,showAvatar:!0}),targetAccount:e(yt,{account:Ie,showAvatar:!0})}))}else if(k==="severed_relationships"){const Ie=h==null?void 0:h.targetName;Ie&&(q=q({name:Ie}))}else if((k==="emoji_reaction"||k==="pleroma:emoji_reaction")&&n.emoji){const Ie=n.emoji_url||((we=(ne=l==null?void 0:l.emojis)==null?void 0:ne.find)==null?void 0:we.call(ne,Pe=>(Pe==null?void 0:Pe.shortcode)===n.emoji.replace(/^:/,"").replace(/:$/,"")));q=q({account:e(yt,{account:d,showAvatar:!0}),emoji:n.emoji,emojiURL:Ie})}else k==="annual_report"?q=q({...n.annualReport}):q=q({account:d?e(yt,{account:d,showAvatar:!0}):(b==null?void 0:b[0])&&e(yt,{account:b[0],showAvatar:!0}),count:se,postsCount:Te,postType:W?"reply":"post",components:{Subject:Z}})}const $=n.createdAt&&new Date(n.createdAt).toLocaleString(),K={"favourite+reblog":pe._({id:"+XOeb+"}),favourite:pe._({id:"LQFF6J"}),reblog:pe._({id:"phQpSa"}),follow:pe._({id:"Ih01jh"})}[k]||pe._({id:"bPwFdf"}),Y=()=>{x.showGenericAccounts={heading:K,accounts:v,showReactions:k==="favourite+reblog",excludeRelationshipAttrs:k==="follow"?["followedBy"]:[],postID:lt(E,i)}};if(l!=null&&l.filtered){const se=((Ce=l==null?void 0:l.account)==null?void 0:Ce.id)===R,Te=Vt(l.filtered,"notifications");if(!F&&!se&&(Te==null?void 0:Te.action)==="hide")return null}return e("div",{class:`notification notification-${k}`,"data-notification-id":g||u,"data-group-key":(w==null?void 0:w.join(" "))||_,tabIndex:"0",children:[e("div",{class:`notification-type notification-${k}`,title:$,children:k==="favourite+reblog"?e(U,{children:[e(I,{icon:"rocket",size:"xl",alt:k,class:"reblog-icon"}),e(I,{icon:"heart",size:"xl",alt:k,class:"favourite-icon"})]}):e(I,{icon:Ji[k]||"notification",size:"xl",alt:k})}),e("div",{class:"notification-content",children:[k!=="mention"&&e(U,{children:[e("p",{children:q}),k==="follow_request"&&e(si,{accountID:d.id}),k==="severed_relationships"&&e("div",{children:[yr[h.type]({from:i,...h}),e("br",{}),e("a",{href:`https://${i}/severed_relationships`,target:"_blank",rel:"noopener",children:e(f,{id:"YL6Y8P",components:{0:e(I,{icon:"external",size:"s"})}})}),"."]}),k==="moderation_warning"&&!!p&&e("div",{children:[c(br[p.action]()),e("br",{}),e("a",{href:`/disputes/strikes/${p.id}`,target:"_blank",rel:"noopener",children:e(f,{id:"YL6Y8P",components:{0:e(I,{icon:"external",size:"s"})}})})]}),k==="annual_report"&&e("div",{children:e(ge,{to:`/annual_report/${m==null?void 0:m.year}`,children:e(f,{id:"5PGPvG"})})})]}),(v==null?void 0:v.length)>1&&e("p",{class:"avatars-stack",children:[v.slice(0,Zn).map(se=>e(U,{children:[e("a",{href:se.url,rel:"noopener",class:"account-avatar-stack",onClick:Te=>{Te.preventDefault(),x.showAccount=se},children:[e(mt,{url:se.avatarStatic,size:v.length<=10?"xxl":v.length<20?"xl":"l",alt:`${se.displayName} @${se.acct}`,squircle:se==null?void 0:se.bot},se.id),k==="favourite+reblog"&&e("div",{class:"account-sub-icons",children:se._types.map(Te=>e(I,{icon:Ji[Te],size:"s",class:`${Te}-icon`}))})]},se.id)," "]},se.id)),(k==="favourite+reblog"||k==="favourite"||k==="reblog")&&ee==="remote"?e("button",{type:"button",class:"small plain","data-group-keys":w==null?void 0:w.join(" "),onClick:()=>{x.showGenericAccounts={heading:K,accounts:v,fetchAccounts:async()=>{const se=await Promise.allSettled(w.map(async Ie=>{const Pe=r.v2.notifications.$select(Ie).accounts.list().values();return[Ie,(await Pe.next()).value]})),Te=[];for(const Ie of se){const[Pe,$e]=Ie.value,Ee=/^favourite/.test(Pe)?"favourite":/^reblog/.test(Pe)?"reblog":null;if(Ee)for(const H of $e){const ke=Te.find(De=>De.id===H.id);ke?ke._types.push(Ee):(H._types=[Ee],Te.push(H))}}return{done:!0,value:Te}},showReactions:k==="favourite+reblog",postID:lt(E,i)}},children:["+",(k==="favourite"||k==="reblog")&&S-v.length,e(I,{icon:"chevron-down"})]}):e("button",{type:"button",class:"small plain",onClick:Y,children:[v.length>Zn&&`+${v.length-Zn}`,e(I,{icon:"chevron-down"})]})]}),!(v!=null&&v.length)&&(b==null?void 0:b.length)>1&&e("p",{class:"avatars-stack",children:[b.map(se=>e(U,{children:[e("a",{href:se.url,rel:"noopener",class:"account-avatar-stack",onClick:Te=>{Te.preventDefault(),x.showAccount=se},children:e(mt,{url:se.avatarStatic,size:"xxl",alt:`${se.displayName} @${se.acct}`,squircle:se==null?void 0:se.bot},se.id)},se.id)," "]},se.id)),S>b.length&&e(ge,{to:i?`/${i}/s/${l.id}`:`/s/${l.id}`,class:"button small plain centered",children:["+",S-b.length,e(I,{icon:"chevron-right"})]})]}),(y==null?void 0:y.length)>1&&e("ul",{class:"notification-group-statuses",children:y.map(se=>e("li",{children:e(es,{class:`status-link status-type-${k}`,to:i?`/${i}/s/${se.id}`:`/s/${se.id}`,children:e(Ge,{status:se,size:"s",previewMode:!0,allowContextMenu:!0,allowFilters:!0})})},se.id))}),l&&(!(y!=null&&y.length)||(y==null?void 0:y.length)<=1)&&e(es,{class:`status-link status-type-${k}`,to:i?`/${i}/s/${E}`:`/s/${E}`,onContextMenu:o?void 0:se=>{const Te=se.target.querySelector(".status");if(Te){if(se.metaKey)return;se.preventDefault(),Te.dispatchEvent(new MouseEvent("contextmenu",{clientX:se.clientX,clientY:se.clientY}))}},children:s?e(Ge,{status:C,size:"s",readOnly:!0,allowContextMenu:!0,allowFilters:!0}):e(Ge,{statusID:E,size:"s",readOnly:!0,allowContextMenu:!0,allowFilters:!0})})]})]})}function es(n){const i=Jo();return e(ge,{...n,"data-read-more":pe._({id:"8fZueG"}),ref:i})}const ln=ut(vr,(n,i)=>{var s,o;return((s=n.notification)==null?void 0:s.id)===((o=i.notification)==null?void 0:o.id)});"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",n=>{const{type:i,id:s,accessToken:o}=(n==null?void 0:n.data)||{};i==="notification"&&(x.routeNotification={id:s,accessToken:o})});const wr=ut(function(){const{_:i}=le();if(!("serviceWorker"in navigator))return null;const s=We(x),{routeNotification:o}=s,{id:c,accessToken:r}=o||{},[u,l]=M(!1);St(()=>{if(!c||!r)return;const{instance:a}=re(),{masto:h,instance:p}=re({accessToken:r}),m=a===p,g=r?Ro(r):di();(async()=>{const v=await h.v1.notifications.$select(c).fetch();if(v&&g){const y=g.instanceURL,{type:w,status:b,account:S}=v,_=!!document.querySelector("#modal-container > *"),T=w==="follow"&&!!(S!=null&&S.id),A=!!(S!=null&&S.id),k=!!(b!=null&&b.id);T&&m?x.showAccount={account:S,instance:y}:_||!m||A&&k?l({id:c,account:g,notification:v,sameInstance:m}):k?location.hash=`/${a}/s/${b.id}`:T?location.hash=`/${a}/a/${S.id}`:location.hash="/notifications"}})()},[c,r]),St(()=>{navigator!=null&&navigator.clearAppBadge&&navigator.clearAppBadge()},[]),Gt(a=>{a&&(navigator!=null&&navigator.clearAppBadge)&&navigator.clearAppBadge()});const d=()=>{l(!1),x.routeNotification=null,/\/notifications\?id=/i.test(location.hash)&&(location.hash="/notifications")};if(u){const{id:a,account:h,notification:p,sameInstance:m}=u;return e(Ye,{onClick:g=>{g.target===g.currentTarget&&d()},children:e("div",{class:"sheet",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:d,children:e(I,{icon:"x",alt:i({id:"yz7wBu"})})}),e("header",{children:e("b",{children:e(f,{id:"5+87Pq"})})}),e("main",{children:[!m&&e("p",{children:e(f,{id:"k9N0Xk"})}),e("div",{class:"notification-peek",onClick:g=>{const{target:v}=g;(g.target.tagName==="BUTTON"||g.target.tagName==="A")&&d()},children:e(ln,{instance:h.instanceURL,notification:p,isStatic:!0})}),e("div",{style:{textAlign:"end"},children:e(ge,{to:"/notifications",class:"button light",onClick:d,children:[e("span",{children:e(f,{id:"/WA/tl"})})," ",e(I,{icon:"arrow-right"})]})})]})]})})}return null}),Qs=Lo((n,i)=>{const{_:s}=le(),{instance:o}=re(),[c,r]=vt(),[u,l]=M(!1),[d,a]=M(c.get("q")||""),h=c.get("type"),p=j(null),m=j(null);return Mo(i,()=>({setValue:g=>{a(g)},focus:()=>{m.current.focus()},select:()=>{m.current.select()},blur:()=>{m.current.blur()}})),e("form",{ref:p,class:"search-popover-container",onSubmit:g=>{var y;if(g.preventDefault(),/\/search/.test(location.hash))if(d){const w={q:d};h&&(w.type=h),r(w)}else r({});else d?location.hash=`/search?q=${encodeURIComponent(d)}${h?`&type=${h}`:""}`:location.hash="/search";(y=n==null?void 0:n.onSubmit)==null||y.call(n,g)},children:[e("input",{ref:m,value:d,name:"q",type:"search",placeholder:s({id:"A1taO8"}),dir:"auto",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",onSearch:g=>{g.target.value||r({})},onInput:g=>{a(g.target.value),l(!0)},onFocus:()=>{var g,v;l(!0),(v=(g=p.current)==null?void 0:g.querySelector(".search-popover-item"))==null||v.classList.add("focus")},onBlur:()=>{var g,v;setTimeout(()=>{l(!1)},100),(v=(g=p.current)==null?void 0:g.querySelector(".search-popover-item.focus"))==null||v.classList.remove("focus")},onKeyDown:g=>{var y;const{key:v}=g;switch(v){case"Escape":l(!1);break;case"Down":case"ArrowDown":if(g.preventDefault(),u){const w=p.current.querySelector(".search-popover-item.focus");if(w){let b=w.nextElementSibling;for(;b&&b.hidden;)b=b.nextElementSibling;b&&(b.classList.add("focus"),Array.from(b.parentElement.children).filter(_=>_!==b).forEach(_=>{_.classList.remove("focus")}))}else{const b=p.current.querySelector(".search-popover-item");b&&b.classList.add("focus")}}break;case"Up":case"ArrowUp":if(g.preventDefault(),u){const w=document.querySelector(".search-popover-item.focus");if(w){let b=w.previousElementSibling;for(;b&&b.hidden;)b=b.previousElementSibling;b&&(b.classList.add("focus"),Array.from(b.parentElement.children).filter(_=>_!==b).forEach(_=>{_.classList.remove("focus")}))}else{const b=document.querySelector(".search-popover-item:last-child");b&&b.classList.add("focus")}}break;case"Enter":if(u){const w=document.querySelector(".search-popover-item.focus");w&&(g.preventDefault(),w.click()),l(!1),(y=n==null?void 0:n.onSubmit)==null||y.call(n,g)}break}}}),e("div",{class:"search-popover",hidden:!u||!d,children:!!d&&[{label:e(f,{id:"48oDit",values:{query:d},components:{0:e("small",{class:"insignificant"})}}),to:`/search?q=${encodeURIComponent(d)}`,top:!h&&!/\s/.test(d),hidden:!!h},{label:e(f,{id:"o1mMWT",values:{query:d},components:{0:e("q",{})}}),to:`/search?q=${encodeURIComponent(d)}&type=statuses`,hidden:/^https?:/.test(d),top:/\s/.test(d),icon:"document",queryType:"statuses"},{label:e(f,{id:"YAZw8D",values:{0:d.replace(/^#/,"")},components:{0:e("mark",{})}}),to:`/${o}/t/${d.replace(/^#/,"")}`,hidden:/^@/.test(d)||/^https?:/.test(d)||/\s/.test(d),top:/^#/.test(d),type:"link",icon:"hashtag",queryType:"hashtags"},{label:e(f,{id:"gEoOUj",values:{query:d},components:{0:e("mark",{})}}),to:`/${d}`,hidden:!/^https?:/.test(d),top:/^https?:/.test(d),type:"link"},{label:e(f,{id:"cDoNQr",values:{query:d},components:{0:e("q",{})}}),to:`/search?q=${encodeURIComponent(d)}&type=accounts`,icon:"group",queryType:"accounts"}].sort((g,v)=>{if(h){if(g.queryType===h)return-1;if(v.queryType===h)return 1}return g.top&&!v.top?-1:!g.top&&v.top?1:0}).filter(({hidden:g})=>!g).map(({label:g,to:v,icon:y,type:w},b)=>e(ge,{to:v,class:`search-popover-item ${b===0?"focus":""}`,onClick:S=>{var _;(_=n==null?void 0:n.onSubmit)==null||_.call(n,S)},children:[e(I,{icon:y||(w==="link"?"arrow-right":"search"),class:"more-insignificant"}),e("span",{children:g})," "]}))})]})}),kr=ut(function({onClose:i=()=>{}}){const[s,o]=M(!1),c=j(null);qe(["Slash","/"],u=>{o(!0),setTimeout(()=>{var l,d,a,h;(d=(l=c.current)==null?void 0:l.focus)==null||d.call(l),(h=(a=c.current)==null?void 0:a.select)==null||h.call(a)},0)},{useKey:!0,preventDefault:!0,ignoreEventWhen:u=>{const l=/\/search/.test(location.hash),d=!!document.querySelector("#modal-container > *");return l||d||u.metaKey||u.ctrlKey||u.altKey||u.shiftKey}});const r=()=>{o(!1),i()};return qe("esc",u=>{var l,d;(d=(l=c.current)==null?void 0:l.blur)==null||d.call(l),r()},{enabled:s,enableOnFormTags:!0,preventDefault:!0,useKey:!0,ignoreEventWhen:u=>u.metaKey||u.ctrlKey||u.altKey||u.shiftKey}),e("div",{id:"search-command-container",hidden:!s,onClick:u=>{u.target===u.currentTarget&&r()},children:e(Qs,{ref:c,onSubmit:()=>{r()}})})});function Sr(){const{_:n,_:i}=le(),{instance:s}=re(),o=We(x),{shortcuts:c,settings:r}=o;if(!c.length)return null;const u=r.shortcutsViewMode==="multi-column"||!r.shortcutsViewMode&&r.shortcutsColumnsMode,l=j(),d=j(!1),a=c.map((g,v)=>{const{type:y,...w}=g;if(!$n[y])return null;let{id:b,path:S,title:_,subtitle:T,icon:A}=$n[y];return typeof b=="function"&&(b=b(w,v)),typeof S=="function"&&(S=S({...w,instance:w.instance||s},v)),typeof _=="function"?_=_(w,v):_=i(_),typeof T=="function"?T=T(w,v):T=i(T),typeof A=="function"&&(A=A(w,v)),b==="lists"&&(d.current=!0),{id:b,path:S,title:_,subtitle:T,icon:A}}).filter(Boolean),h=ks();qe(["1","2","3","4","5","6","7","8","9"],g=>{var y,w;const v=parseInt(g.key,10)-1;if(vg.metaKey||g.ctrlKey||g.altKey||g.shiftKey});const[p,m]=M([]);return u?null:e("div",{id:"shortcuts",children:o.settings.shortcutsViewMode==="tab-menu-bar"?e("nav",{class:"tab-bar",onContextMenu:g=>{g.preventDefault(),x.showShortcutsSettings=!0},children:e("ul",{children:a.map(({id:g,path:v,title:y,subtitle:w,icon:b},S)=>e("li",{children:e(ge,{class:w?"has-subtitle":"",to:v,onClick:_=>{if(_.target.classList.contains("is-active")){_.preventDefault();const T=document.getElementById(`${g}-page`);if(T){T.scrollTop=0;const A=T.querySelector(".updates-button");A&&A.click()}}},children:[e(I,{icon:b,size:"xl",alt:y}),e("span",{children:[e(wn,{children:y}),w&&e(U,{children:[e("br",{}),e("small",{children:w})]})]})]})},`${S}-${g}-${y}-${w}-${v}`))})}):e(dt,{instanceRef:l,overflow:"auto",viewScroll:"close",menuClassName:"glass-menu shortcuts-menu",gap:8,position:"anchor",onMenuChange:g=>{g.open&&d.current&&hn().then(m)},menuButton:e("button",{type:"button",id:"shortcuts-button",class:"plain",onContextMenu:g=>{g.preventDefault(),x.showShortcutsSettings=!0},onTransitionStart:g=>{var v,y;try{const{target:w}=g;getComputedStyle(w).pointerEvents==="none"&&((y=(v=l.current)==null?void 0:v.closeMenu)==null||y.call(v))}catch{}},children:e(I,{icon:"shortcut",size:"xl",alt:n({id:"CTqTgr"})})}),children:a.map(({id:g,path:v,title:y,subtitle:w,icon:b},S)=>g==="lists"?e(dn,{menuClassName:"glass-menu",overflow:"auto",gap:-8,label:e(U,{children:[e(I,{icon:b,size:"l"}),e("span",{class:"menu-grow",children:e(wn,{children:y})}),e(I,{icon:"chevron-right"})]}),children:[e(je,{to:"/l",children:e("span",{children:e(f,{id:"BHWx+g"})})}),e(Ve,{}),p==null?void 0:p.map(_=>e(je,{to:`/l/${_.id}`,children:e("span",{children:[_.title,_.exclusive&&e(U,{children:[" ",e(Bt,{})]})]})},_.id))]}):e(je,{to:v,class:"glass-menu-item",children:[e(I,{icon:b,size:"l"})," ",e("span",{class:"menu-grow",children:[e("span",{children:e(wn,{children:y})}),w&&e(U,{children:[" ",e("small",{class:"more-insignificant",children:w})]})]}),e("span",{class:"menu-shortcut hide-until-focus-visible",children:S+1})]},`${S}-${g}-${y}-${w}-${v}`))})})}const _r=ut(Sr);function Cr(n){var c;let i=[],s=[],o=0;for(let r=0;r10&&(s.length>n.length/4||o>=3)){const r=s.map(u=>u.id);if(s.length>n.length*3/4)i=[...i,{id:r,items:s,type:"boosts"}];else{const u=Math.floor(i.length/2);i=[...i.slice(0,u),{id:r,items:s,type:"boosts"},...i.slice(u)]}return i}else return n}function ts(n,i){const s=Ue.account.get("boostedStatusIDs")||{},o=n.filter(r=>{if(!r.reblog)return!0;const u=`${i}-${r.reblog.id}`,l=s[u];return l&&l!==r.id?!1:(s[u]=r.id,!0)}),c=Object.keys(s);return c.length>50&&c.slice(0,c.length-50).forEach(r=>{delete s[r]}),Ue.account.set("boostedStatusIDs",s),o}function Ir(n,i){const s=[];let o=0;n.forEach(l=>{for(let a=0;ah.id===l.id))return;if(s[a].find(h=>h.id===l.inReplyToId)||s[a].find(h=>h.inReplyToId===l.id)){s[a].push(l);return}}const d=n.find(a=>a.id===l.inReplyToId);d&&(s[o++]=[l,d])});for(let l=0;ls[d].includes(h))&&(s[l]=[...s[l],...s[d]],s[l]=s[l].filter((h,p,m)=>m.findIndex(g=>g.id===h.id)===p),s.splice(d,1),d--);s.forEach(l=>{l.sort((d,a)=>!d.inReplyToId&&!a.inReplyToId?new Date(d.createdAt)-new Date(a.createdAt):d.inReplyToId===a.id?1:a.inReplyToId===d.id||!d.inReplyToId?-1:a.inReplyToId?new Date(d.createdAt)-new Date(a.createdAt):1)}),s.forEach(l=>{const d=l[0].account.id;l.forEach(a=>{a.account.id!==d&&(a._differentAuthor=!0)})}),s.length;const c=[],r=[],u=[];return n.forEach(l=>{if(l.reblog){c.push(l);return}for(let d=0;da.id===l.id)){if(r.includes(d))return;const a=s[d];a.sort((p,m)=>{const g=new Date(p.createdAt),v=new Date(m.createdAt);return g-v});const h=a[0].account.id;c.push({id:a.map(p=>p.id),items:a,type:a.every(p=>p.account.id===h)?"thread":"conversation"}),r.push(d);return}if(l.inReplyToId&&l.inReplyToAccountId!==l.account.id){const d=lt(l.id,i);x.statusReply[d]||u.push({sKey:d,inReplyToId:l.inReplyToId})}c.push(l)}),u!=null&&u.length&&queueMicrotask(()=>{const{masto:l}=re({instance:i});async function d(){for(let a=0;asetTimeout(g,1e3))}catch{}}}if(Je("@mastodon/fetch-multiple-statuses")){const a=u.map(({inReplyToId:h})=>h);(async()=>{var h;try{const p=await l.v1.statuses.list({id:a});if(p!=null&&p.length)for(const m of p){et(m,i,{skipThreading:!0});const g=(h=u.find(({inReplyToId:v})=>v===m.id))==null?void 0:h.sKey;g&&(x.statusReply[g]={id:m.id,instance:i})}else d()}catch{d()}})()}else d()}),c}const Tr=bt((n,i)=>i.v1.statuses.$select(n).fetch());async function eo(n,i){const s=await lr();if(!s.length)return;const{statusFollowedTags:o}=x,c=[];if(n.forEach(r=>{var m;if(r.reblog)return;const{id:u,content:l,tags:d=[]}=r,a=lt(u,i);if((m=o[a])!=null&&m.length)return;const h=dr(l);if(!h.length&&!d.length)return;const p=s.reduce((g,v)=>((h.some(y=>y.toLowerCase()===v.name.toLowerCase())||d.some(y=>y.name.toLowerCase()===v.name.toLowerCase()))&&g.push(v.name),g),[]);p.length&&c.push({item:r,sKey:a,followedTags:p})}),c.length){const r=c.map(l=>l.item.account),u=await Pn(r);if(!u)return;c.forEach(l=>{const{item:d,sKey:a,followedTags:h}=l,p=u[d.account.id];p&&!p.following&&(o[a]=h)})}}function Ar(){x.statusFollowedTags={}}function xr({scrollableRef:n,distanceFromStart:i=1,distanceFromEnd:s=1,scrollThresholdStart:o=10,scrollThresholdEnd:c=10,direction:r="vertical",distanceFromStartPx:u,distanceFromEndPx:l}={}){const[d,a]=M(null),[h,p]=M(!1),[m,g]=M(!1),[v,y]=M(!1),[w,b]=M(!1),S=r==="vertical";return St(()=>{const _=n.current;if(!_)return{};let T=S?_.scrollTop:_.scrollLeft;function A(){const{scrollTop:k,scrollLeft:C,scrollHeight:E,scrollWidth:R,clientHeight:F,clientWidth:D}=_,W=S?k:C,G=S?E:R,X=S?F:D,q=Math.abs(W-T),Z=u||Math.min(X*i,G,W),B=l||Math.min(X*s,G,G-W-X);q>=(T=G),y(W<=Z),b(W+X>=G-B)}return _.addEventListener("scroll",A,{passive:!0}),()=>_.removeEventListener("scroll",A)},[i,s,o,c]),{scrollDirection:d,reachStart:h,reachEnd:m,nearReachStart:v,nearReachEnd:w,init:()=>{n.current&&n.current.dispatchEvent(new Event("scroll"))}}}function Er({scrollableRef:n,distanceFromStart:i=1,distanceFromEnd:s=1,scrollThresholdStart:o=10,scrollThresholdEnd:c=10,direction:r="vertical",distanceFromStartPx:u,distanceFromEndPx:l,init:d}={},a,h){if(!a)return;const p=r==="vertical",m=j(null),g=j(null),v=Qo(()=>{let y=!1,w=!1,b=!1,S=!1;const _=n.current,{scrollTop:T,scrollLeft:A,scrollHeight:k,scrollWidth:C,clientHeight:E,clientWidth:R}=_,F=p?T:A,D=p?k:C,W=p?E:R,G=Math.abs(F-m.current),X=u||Math.min(W*i,D,F),q=l||Math.min(W*s,D,D-F-W);G>=(m.current=D,b=F<=X,S=F+W>=D-q,a({scrollDirection:g.current,reachStart:y,reachEnd:w,nearReachStart:b,nearReachEnd:S})},500);St(()=>{const y=n.current;return y?(m.current=y[p?"scrollTop":"scrollLeft"],y.addEventListener("scroll",v,{passive:!0}),()=>y.removeEventListener("scroll",v)):{}},[i,s,o,c,...h]),Q(()=>{d&&n.current&&queueMicrotask(()=>{n.current.dispatchEvent(new Event("scroll"))})},[d])}function Rr({class:n,statusID:i,status:s,instance:o,parent:c,onMediaClick:r}){var N;const{_:u}=le();let l=lt(i,o);const d=We(x);if(s||(s=d.statuses[l]||d.statuses[i],l=lt(s==null?void 0:s.id,o)),!s)return null;const{account:{acct:a,avatar:h,avatarStatic:p,id:m,url:g,displayName:v,username:y,emojis:w,bot:b,group:S},id:_,repliesCount:T,reblogged:A,reblogsCount:k,favourited:C,favouritesCount:E,bookmarked:R,poll:F,muted:D,sensitive:W,spoilerText:G,visibility:X,language:q,editedAt:Z,filtered:B,card:ee,createdAt:$,inReplyToId:K,inReplyToAccountId:Y,content:te,mentions:J,mediaAttachments:ue,reblog:he,uri:ne,url:we,emojis:Ce,_deleted:se,_pinned:Te}=s;if(!(ue!=null&&ue.length))return null;const Ie=O=>{O.shiftKey},Pe=Ae(()=>kt(),[]),$e=Ae(()=>Pe&&Pe===m,[m,Pe]),Ee=$o(Dn),H=!$e&&Vt(B,Ee);if((H==null?void 0:H.action)==="hide")return null;const ke=W,Me=(((N=li()["reading:expand:media"])==null?void 0:N.toLowerCase())||"default")==="show_all",me=c||"div";return ue.map((O,oe)=>{const Le=`${l}-${O.id}`,P=H==null?void 0:H.titlesStr;return e(me,{"data-state-post-id":l,onMouseEnter:Ie,"data-spoiler-text":G||(W?u({id:"FKojeB"}):void 0),"data-filtered-text":H?u(P?{id:"7FGvtQ",values:{filterTitleStr:P}}:{id:"03Qqf9"}):void 0,class:`
+ media-post
+ ${H?"filtered":""}
+ ${ke?"has-spoiler":""}
+ ${Me?"show-media":""}
+ `,children:e(Ms,{class:n,media:O,lang:q,to:`/${o}/s/${_}?media-only=${oe+1}`,onClick:r?ce=>r(ce,oe,O,s):void 0})},Le)})}const ns=ut(Rr);function Lr(n){var _,T,A,k,C;const{_:i}=le(),s=We(x),{masto:o,instance:c,authenticated:r}=re(),[u,l]=Ae(()=>{const E=ri();return[E.find(F=>F.info.id===kt())||E[0],E.length>1]},[]),d=(s.settings.shortcutsViewMode==="multi-column"||!s.settings.shortcutsViewMode&&s.settings.shortcutsColumnsMode)&&!s.shortcuts.find(E=>E.type==="following"),a=Is(()=>{x.showAccounts=!0},{threshold:600,detect:"touch",cancelOnMovement:!0}),h=j(),[p,m]=M(void 0),g=As([0,0,s.settings.shortcutsViewMode==="tab-menu-bar"?50:0,0]),v=j();async function y(E){return(E||!v.current)&&(v.current=o.v1.mutes.list({limit:80}).values()),await v.current.next()}const w=j();async function b(E){return(E||!w.current)&&(w.current=o.v1.blocks.list({limit:80}).values()),await w.current.next()}const S=j();return e(U,{children:[e("button",{ref:h,type:"button",class:`button plain nav-menu-button ${l?"with-avatar":""} ${p==="open"?"active":""}`,style:{position:"relative"},onClick:()=>{S.current=Date.now(),m(E=>E?void 0:"open")},onContextMenu:E=>{E.preventDefault(),x.showAccounts=!0},...a(),children:[l&&e(mt,{url:((_=u==null?void 0:u.info)==null?void 0:_.avatar)||((T=u==null?void 0:u.info)==null?void 0:T.avatarStatic),size:"l",squircle:(A=u==null?void 0:u.info)==null?void 0:A.bot}),e(I,{icon:"menu",size:l?"s":"l",alt:i({id:"zucql+"})})]}),e(pi,{menuClassName:"nav-menu",state:p,anchorRef:h,onClose:()=>{m(void 0)},containerProps:{style:{zIndex:10},onClick:()=>{Date.now()-S.current<300}},portal:{target:document.body},...n,overflow:"auto",viewScroll:"close",position:"anchor",align:"center",boundingBoxPadding:g,unmountOnClose:!0,children:[!!((k=s.appVersion)!=null&&k.commitHash)&&s.appVersion.commitHash!=="43d0d1e"&&e("div",{class:"top-menu",children:[e(ye,{onClick:()=>{confirm(i({id:"Djbaby"}))&&(async()=>{try{location.reload()}catch{}})()},children:[e(I,{icon:"sparkles",class:"sparkle-icon",size:"l"})," ",e("span",{children:e(f,{id:"95IFnD"})})]}),e(Ve,{})]}),e("section",{children:[e(je,{to:"/",children:[e(I,{icon:"home",size:"l"})," ",e("span",{children:e(f,{id:"i0qMbr"})})]}),r?e(U,{children:[d&&e(je,{to:"/following",children:[e(I,{icon:"following",size:"l"})," ",e("span",{children:e(f,{id:"following.title"})})]}),e(je,{to:"/catchup",children:[e(I,{icon:"history2",size:"l"}),e("span",{children:e(f,{id:"xrl8fj"})})]}),Je("@mastodon/mentions")&&e(je,{to:"/mentions",children:[e(I,{icon:"at",size:"l"})," ",e("span",{children:e(f,{id:"/bZzdR"})})]}),e(je,{to:"/notifications",children:[e(I,{icon:"notification",size:"l"})," ",e("span",{children:e(f,{id:"iDNBZe"})}),s.notificationsShowNew&&e("sup",{title:i({id:"isRobC"}),style:{opacity:.5},children:[" ","•"]})]}),e(Ve,{}),((C=u==null?void 0:u.info)==null?void 0:C.id)&&e(je,{to:`/${c}/a/${u.info.id}`,children:[e(I,{icon:"user",size:"l"})," ",e("span",{children:e(f,{id:"vERlcd"})})]}),e(Mr,{menuState:p}),e(je,{to:"/b",children:[e(I,{icon:"bookmark",size:"l"})," ",e("span",{children:e(f,{id:"7Ff7ia"})})]}),e(dn,{menuClassName:"nav-submenu",overflow:"auto",gap:-8,label:e(U,{children:[e(I,{icon:"more",size:"l"}),e("span",{class:"menu-grow",children:e(f,{id:"24misb"})}),e(I,{icon:"chevron-right"})]}),children:[e(je,{to:"/f",children:[e(I,{icon:"heart",size:"l"})," ",e("span",{children:e(f,{id:"zZOZj7"})})]}),e(je,{to:"/fh",children:[e(I,{icon:"hashtag",size:"l"})," ",e("span",{children:e(f,{id:"Xi1/bw"})})]}),e(je,{to:"/sp",children:[e(I,{icon:"schedule",size:"l"})," ",e("span",{children:e(f,{id:"+GkIdc"})})]}),e(Ve,{}),Je("@mastodon/filters")&&e(je,{to:"/ft",children:[e(I,{icon:"filters",size:"l"})," ",e("span",{children:e(f,{id:"cSev+j"})})]}),e(ye,{onClick:()=>{x.showGenericAccounts={id:"mute",heading:i({id:"sOKhEA"}),fetchAccounts:y,excludeRelationshipAttrs:["muting"]}},children:[e(I,{icon:"mute",size:"l"})," ",e("span",{children:e(f,{id:"n1sANU"})})]}),e(ye,{onClick:()=>{x.showGenericAccounts={id:"block",heading:i({id:"nL8nlr"}),fetchAccounts:b,excludeRelationshipAttrs:["blocking"]}},children:[e(I,{icon:"block",size:"l"})," ",e("span",{children:e(f,{id:"r3RRWo"})})]})," "]}),e(Ve,{}),e(ye,{onClick:()=>{x.showAccounts=!0},children:[e(I,{icon:"group",size:"l"})," ",e("span",{children:e(f,{id:"7e0O8Z"})})]})]}):e(U,{children:[e(Ve,{}),e(je,{to:"/login",children:[e(I,{icon:"user",size:"l"})," ",e("span",{children:e(f,{id:"sQia9P"})})]})]})]}),e("section",{children:[e(Ve,{}),e(je,{to:"/search",children:[e(I,{icon:"search",size:"l"})," ",e("span",{children:e(f,{id:"A1taO8"})})]}),e(je,{to:`/${c}/trending`,children:[e(I,{icon:"chart",size:"l"})," ",e("span",{children:e(f,{id:"4/iCqx"})})]}),e(je,{to:`/${c}/p/l`,children:[e(I,{icon:"building",size:"l"})," ",e("span",{children:e(f,{id:"d5zxa4"})})]}),e(je,{to:`/${c}/p`,children:[e(I,{icon:"earth",size:"l"})," ",e("span",{children:e(f,{id:"4ERYY7"})})]}),r?e(U,{children:[e(Ve,{className:"divider-grow"}),e(ye,{onClick:()=>{x.showKeyboardShortcutsHelp=!0},children:[e(I,{icon:"keyboard",size:"l"})," ",e("span",{children:e(f,{id:"77Emn0"})})]}),e(ye,{onClick:()=>{x.showShortcutsSettings=!0},children:[e(I,{icon:"shortcut",size:"l"})," ",e("span",{children:e(f,{id:"8Kudkr"})})]}),e(ye,{onClick:()=>{x.showSettings=!0},children:[e(I,{icon:"gear",size:"l"})," ",e("span",{children:e(f,{id:"uVbUP8"})})]})]}):e(U,{children:[e(Ve,{}),e(ye,{onClick:()=>{x.showSettings=!0},children:[e(I,{icon:"gear",size:"l"})," ",e("span",{children:e(f,{id:"uVbUP8"})})]})]})]})]})]})}function Mr({menuState:n}){const i=Je("@mastodon/lists"),[s,o]=M([]);return Q(()=>{i&&n==="open"&&hn().then(o)},[n,i]),s.length>0?e(dn,{menuClassName:"nav-submenu",overflow:"auto",gap:-8,label:e(U,{children:[e(I,{icon:"list",size:"l"}),e("span",{class:"menu-grow",children:e(f,{id:"h16FyT"})}),e(I,{icon:"chevron-right"})]}),children:[e(je,{to:"/l",children:e("span",{children:e(f,{id:"BHWx+g"})})}),(s==null?void 0:s.length)>0&&e(U,{children:[e(Ve,{}),s.map(c=>e(je,{to:`/l/${c.id}`,children:e("span",{children:[c.title,c.exclusive&&e(U,{children:[" ",e(Bt,{})]})]})},c.id))]})]}):i&&e(je,{to:"/l",children:[e(I,{icon:"list",size:"l"}),e("span",{children:e(f,{id:"h16FyT"})})]})}const $t=ut(Lr),fn={block:"start",inline:"center",behavior:"smooth"};function At({title:n,titleComponent:i,id:s,instance:o,emptyText:c,errorText:r,useItemID:u,boostsCarousel:l,fetchItems:d=()=>{},checkForUpdates:a=()=>{},checkForUpdatesInterval:h=15e3,headerStart:p,headerEnd:m,timelineStart:g,refresh:v,view:y,filterContext:w,showFollowedTags:b,showReplyParent:S,clearWhenRefresh:_}){const{_:T}=le(),A=We(x),[k,C]=M([]),[E,R]=M("start"),[F,D]=M(!1),[W,G]=M(!1),[X,q]=M(!0),Z=j();__BENCHMARK.start(`timeline-${s}-load`);const B=Ae(()=>ui(),[]),ee=y!=="media",$=j(0),K=ec(H=>{G(!1),R("loading"),(async()=>{try{const ke=$.current=Date.now();let{done:De,value:xe}=await d(H);if(ke!==$.current)return;if(Array.isArray(xe)){const[Me,me]=xe.reduce((N,O)=>(O._pinned?N[0].push(O):N[1].push(O),N),[[],[]]);xe=me,ee&&(l&&(xe=Cr(xe)),xe=Ir(xe,o)),Me.length&&(xe=Me.concat(xe)),C(H?xe:N=>[...N,...xe]),xe.length||(De=!0),D(!De)}else D(!1);R("default"),__BENCHMARK.end(`timeline-${s}-load`)}catch{R("error"),H&&!k.length&&r&&fe(r)}finally{K.cancel()}})()},1e3,{leading:!0}),Y=".timeline-item, .timeline-item-alt",te=qe("j, shift+j",(H,ke)=>{if(H.shiftKey!==ke.shift)return;const De=document.activeElement.closest(Y),xe=De==null?void 0:De.getBoundingClientRect(),Me=Array.from(Z.current.querySelectorAll(Y)).filter(me=>!!me.offsetHeight);if(De&&xe.top0){const me=Me.indexOf(De);let N=Me[me+1];ke.shift&&(N=Me.find((O,oe)=>oe>me&&!O.classList.contains("timeline-item-alt"))),N&&(N.focus(),N.scrollIntoView(fn))}else{const me=Me.find(N=>{const O=N.getBoundingClientRect();return O.top>=44&&O.left>=0});me&&(me.focus(),me.scrollIntoView(fn))}},{useKey:!0,ignoreEventWhen:H=>H.metaKey||H.ctrlKey||H.altKey}),J=qe("k, shift+k",(H,ke)=>{if(H.shiftKey!==ke.shift)return;const De=document.activeElement.closest(Y),xe=De==null?void 0:De.getBoundingClientRect(),Me=Array.from(Z.current.querySelectorAll(Y)).filter(me=>!!me.offsetHeight);if(De&&xe.top0){const me=Me.indexOf(De);let N=Me[me-1];ke.shift&&(N=Me.findLast((O,oe)=>oe{const O=N.getBoundingClientRect();return O.top>=44&&O.left>=0});me&&(me.focus(),me.scrollIntoView(fn))}},{useKey:!0,ignoreEventWhen:H=>H.metaKey||H.ctrlKey||H.altKey}),ue=qe(["enter","o"],()=>{const H=document.activeElement;H!=null&&H.matches(Y)&&H.click()},{useKey:!0,ignoreEventWhen:H=>H.metaKey||H.ctrlKey||H.altKey||H.shiftKey}),he=k.length>0&&E!=="loading"&&W,ne=it(()=>{var H;he&&K(!0),(H=Z.current)==null||H.scrollTo({top:0,behavior:"smooth"})},[K,he]),we=qe(".",ne,{useKey:!0,ignoreEventWhen:H=>H.metaKey||H.ctrlKey||H.altKey||H.shiftKey}),Ce=j(),[se,Te]=M(!1);Er({scrollableRef:Z,distanceFromEnd:2,scrollThresholdStart:44},({scrollDirection:H,nearReachStart:ke,reachStart:De})=>{if(Ce.current){const xe=H==="end"&&!ke;Ce.current.hidden=xe}Te(ke),De&&K(!0)},[]),Q(()=>{var H;(H=Z.current)==null||H.scrollTo({top:0}),K(!0)},[]);const Ie=j(!0);Q(()=>{var H;if(Ie.current){Ie.current=!1;return}_&&(k!=null&&k.length)&&((H=K.cancel)==null||H.call(K),C([])),K(!0)},[_,v]);const Pe=j(y);Q(()=>{Pe.current!==y&&(Pe.current=y,C([]))},[y]);const $e=it(async({disableIdleCheck:H=!1}={})=>{const ke=Z.current?getComputedStyle(Z.current).pointerEvents==="none":!1;A.settings.autoRefresh&&Z.current.scrollTop<16&&(H||window.__IDLE__)&&!Dr()&&!ke?K(!0):await a()&&G(!0)},[s,K,a,A.settings.autoRefresh]),Ee=j();return Gt(H=>{if(H){const ke=Date.now()-Ee.current;(!Ee.current||ke>1e3*3)&&$e({disableIdleCheck:!0})}else Ee.current=Date.now();q(H)},[a,$e,A.settings.autoRefresh]),fi($e,X&&!W?h*(se?1:2):null),e(Dn.Provider,{value:w,children:e("div",{id:`${s}-page`,class:`deck-container ${B?"deck-container-media-first":""}`,ref:H=>{Z.current=H,te.current=H,J.current=H,ue.current=H,we.current=H},tabIndex:"-1",onClick:H=>{Ce.current&&H.target.closest(".timeline-item, .timeline-item-alt")&&setTimeout(()=>{Ce.current.hidden=!1},250)},children:e("div",{class:"timeline-deck deck",children:[e("header",{ref:Ce,onClick:H=>{var ke;H.target.closest("a, button")||(ke=Z.current)==null||ke.scrollTo({top:0,behavior:"smooth"})},onDblClick:H=>{H.target.closest("a, button")||K(!0)},class:E==="loading"?"loading":"",children:[e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),p??e(ge,{to:"/",class:"button plain home-button",children:e(I,{icon:"home",size:"l",alt:T({id:"i0qMbr"})})})]}),n&&(i||e("h1",{children:n})),e("div",{class:"header-side",children:!!m&&m})]}),he&&e("button",{class:"updates-button shiny-pill",type:"button",onClick:ne,children:[e(I,{icon:"arrow-up"})," ",e(f,{id:"2yr1/p"})]})]}),!!g&&e("div",{class:`timeline-start ${E==="loading"?"loading":""}`,children:g}),k.length?e(U,{children:[e("ul",{class:`timeline ${y?`timeline-${y}`:""}`,children:[k.map(H=>e($r,{status:H,instance:o,useItemID:u,filterContext:w,view:y,showFollowedTags:b,showReplyParent:S,mediaFirst:B},H.id+(H==null?void 0:H._pinned)+y)),F&&E==="loading"&&(y==="media"?null:e(U,{children:[e("li",{style:{height:"20vh"},children:e(Ge,{skeleton:!0,mediaFirst:B})}),e("li",{style:{height:"25vh"},children:e(Ge,{skeleton:!0,mediaFirst:B})})]}))]}),E==="default"&&(F?e(Tt,{root:Z.current,rootMargin:`0px 0px ${screen.height*1.5}px 0px`,onChange:H=>{H&&K()},children:e("button",{type:"button",class:"plain block",onClick:()=>K(),style:{marginBlockEnd:"6em"},children:e(f,{id:"uXRAkV"})})}):e("p",{class:"ui-state insignificant",children:e(f,{id:"2EYeAZ"})}))]}):E==="loading"?e("ul",{class:"timeline",children:Array.from({length:5}).map((H,ke)=>y==="media"?e("div",{style:{height:"50vh"}}):e("li",{children:e(Ge,{skeleton:!0,mediaFirst:B})},ke))}):E!=="error"&&E!=="start"&&e("p",{class:"ui-state",children:c}),E==="error"&&e("p",{class:"ui-state",children:[r,e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>K(!k.length),children:e(f,{id:"KDw4GX"})})]})]})})})}const $r=ut(({status:n,instance:i,useItemID:s,filterContext:o,view:c,showFollowedTags:r,showReplyParent:u,mediaFirst:l})=>{const{_:d}=le(),{id:a,reblog:h,items:p,type:m,_pinned:g}=n;g&&(s=!1);const v=(h==null?void 0:h.id)||a,y=i?`/${i}/s/${v}`:`/s/${v}`;if(p){let b=zt(p,o),S="";if(m==="boosts"?S=pe._({id:"NuqppG",values:{0:b.length}}):m==="pinned"&&(S=d({id:"GlfmCu"})),m==="boosts"||m==="pinned"){const A=new Set;if(b.sort((k,C)=>{const E=Vt(k.filtered,o),R=Vt(C.filtered,o);return E&&(E==null?void 0:E.action)!=="blur"&&A.add(k.id),R&&(R==null?void 0:R.action)!=="blur"&&A.add(C.id),E&&!R?1:!E&&R?-1:0}),A.size>=2){const C=[],E=[];b.forEach(F=>{A.has(F.id)?E.push(F):C.push(F)});const R=[];for(let F=0;F{const{id:C,reblog:E,_pinned:R,_grouped:F}=k;if(F)return e("li",{class:"timeline-item-carousel-group",children:k.posts.map(G=>{const{id:X,reblog:q,_pinned:Z}=G,B=(q==null?void 0:q.id)||X,ee=i?`/${i}/s/${B}`:`/s/${B}`;return Z&&(s=!1),e(ge,{class:"status-carousel-link timeline-item-alt",to:ee,children:s?e(Ge,{statusID:X,instance:i,size:"s"}):e(Ge,{status:G,instance:i,size:"s"})})})},C);const D=(E==null?void 0:E.id)||C,W=i?`/${i}/s/${D}`:`/s/${D}`;return R&&(s=!1),e("li",{children:e(ge,{class:"status-carousel-link timeline-item-alt",to:W,children:s?e(Ge,{statusID:C,instance:i,size:"s",contentTextWeight:!0,enableCommentHint:!0,mediaFirst:l}):e(Ge,{status:k,instance:i,size:"s",contentTextWeight:!0,enableCommentHint:!0,mediaFirst:l})})},C)})})},`timeline-${a}`)}const T=b.length>3;return b.map((A,k)=>{const{id:C,_differentAuthor:E}=A,R=i?`/${i}/s/${C}`:`/s/${C}`,F=k>0&&k0||T&&F&&(m==="thread"||m==="conversation"&&!E&&!b[k-1]._differentAuthor&&!b[k+1]._differentAuthor),G=k===0,X=k===b.length-1;return e("li",{class:`timeline-item-container timeline-item-container-type-${m} timeline-item-container-${G?"start":X?"end":"middle"} ${E?"timeline-item-diff-author":""}`,children:e(ge,{class:"status-link timeline-item",to:R,children:W?e(Pr,{status:A,instance:i,filterContext:o}):s?e(Ge,{statusID:C,instance:i,enableCommentHint:X,showFollowedTags:r}):e(Ge,{status:A,instance:i,enableCommentHint:X,showFollowedTags:r})})},`timeline-${C}`)})}const w=`timeline-${a+g}`;return c==="media"?s?e(ns,{class:"timeline-item",parent:"li",statusID:a,instance:i},w):e(ns,{class:"timeline-item",parent:"li",status:n,instance:i},w):e("li",{children:e(ge,{class:"status-link timeline-item",to:y,children:s?e(Ge,{statusID:a,instance:i,enableCommentHint:!0,showFollowedTags:r,showReplyParent:u,mediaFirst:l}):e(Ge,{status:n,instance:i,enableCommentHint:!0,showFollowedTags:r,showReplyParent:u,mediaFirst:l})})},w)},(n,i)=>{var c,r;const s=(((c=n.status)==null?void 0:c.id)||"").toString(),o=(((r=i.status)==null?void 0:r.id)||"").toString();return s===o&&n.instance===i.instance&&n.view===i.view});function Nr({title:n,class:i,children:s}){const{_:o}=le(),c=j(),r=j(),u=j(),[l,d]=M(!1);return Q(()=>{setTimeout(()=>{d(!0)},1)},[]),e("div",{class:`status-carousel ${i}`,children:[e("header",{children:[e("h3",{children:n}),e("span",{children:[e("button",{ref:r,type:"button",class:"small plain2",onClick:()=>{var h,p;const a=Math.min(320,(h=c.current)==null?void 0:h.offsetWidth)*(Ot()?1:-1);(p=c.current)==null||p.scrollBy({left:a,behavior:"smooth"})},children:e(I,{icon:"chevron-left",alt:o({id:"DHhJ7s"})})})," ",e("button",{ref:u,type:"button",class:"small plain2",onClick:()=>{var h,p;const a=Math.min(320,(h=c.current)==null?void 0:h.offsetWidth)*(Ot()?-1:1);(p=c.current)==null||p.scrollBy({left:a,behavior:"smooth"})},children:e(I,{icon:"chevron-right",alt:o({id:"hXzOVo"})})})]})]}),e("ul",{ref:c,children:[e(Tt,{class:"status-carousel-beacon",onChange:a=>{r.current&&(r.current.disabled=a)}}),s[0],l&&s.slice(1),e(Tt,{class:"status-carousel-beacon",onChange:a=>{u.current&&(u.current.disabled=a)}})]})]})}function Pr({status:n,instance:i,filterContext:s}){const{_:o}=le(),c=We(x),{id:r,visibility:u,language:l}=n,d=Nn(n),a=lt(r,i),h=Vt(n.filtered,s);return e("article",{class:`status compact-thread ${u==="direct"?"visibility-direct":""}`,tabindex:"-1",children:[c.statusThreadNumber[a]?e("div",{class:"status-thread-badge",children:[e(I,{icon:"thread",size:"s",alt:o({id:"e66y2Z"})}),c.statusThreadNumber[a]?` ${c.statusThreadNumber[a]}/X`:""]}):e("div",{class:"status-thread-badge",children:e(I,{icon:"thread",size:"s",alt:o({id:"e66y2Z"})})}),e("div",{class:"content-compact",title:d,lang:l,dir:"auto",children:h&&(h==null?void 0:h.action)!=="blur"?e("b",{class:"status-filtered-badge badge-meta horizontal",title:(h==null?void 0:h.titlesStr)||"",children:h!=null&&h.titlesStr?e(f,{id:"sr6maL",values:{0:h.titlesStr},components:{0:e("span",{}),1:e("span",{})}}):e("span",{children:e(f,{id:"03Qqf9"})})}):e(U,{children:[d,n.sensitive&&n.spoilerText&&e(U,{children:[" ",e("span",{class:"spoiler-badge",children:e(I,{icon:"eye-close",size:"s",alt:o({id:"gnKo7f"})})})]})]})})]})}function Dr(){return!!document.querySelector(".deck-backdrop, #modal-container > *")}const qt=20,Ei=1983,is=`${Ei}-01`,Or=(()=>{try{const n=document.createElement("input");return n.setAttribute("type","month"),n.type==="month"}catch{return!1}})();async function zr(n){var o;const{masto:i}=re({instance:n}),s=await i.v2.search.list({q:"from:me",type:"statuses",limit:1});return!!((o=s==null?void 0:s.statuses)!=null&&o.length)}const Ur=bt(zr);function Br(){const{i18n:n,_:i}=le(),s=We(x),{id:o,...c}=Mt(),[r,u]=vt(),l=r.get("month"),d=!r.get("replies"),a=!!r.get("boosts"),h=r.get("tagged"),p=!!r.get("media"),{masto:m,instance:g,authenticated:v}=re({instance:c.instance}),{masto:y,instance:w}=re(),b=j(),S=[l,d,a,h,p],[_,T]=M(),A=j(0);Q(()=>{A.current=0},S);const k=Ae(()=>ui(),[]),C=Ae(()=>g===w,[g,w]),[E,R]=M(!1);Q(()=>{C&&_!=null&&_.acct&&(async()=>{const J=await Ur(g);R(J)})()},[g,C,_==null?void 0:_.acct]);async function F(J){var se,Te,Ie,Pe;const ue=/^\d{4}-[01]\d$/.test(l),he=((Te=(se=l==null?void 0:l.split)==null?void 0:se.call(l,"-"))==null?void 0:Te[0])>=Ei;if(ue&&he){if(!_)return{value:[],done:!0};const[$e,Ee]=l.split("-"),H=parseInt(Ee,10)-1,ke=new Date($e,H,0),De=`${ke.getFullYear()}-${(ke.getMonth()+1).toString().padStart(2,"0")}-${ke.getDate().toString().padStart(2,"0")}`,xe=new Date($e,H+1,1),Me=`${xe.getFullYear()}-${(xe.getMonth()+1).toString().padStart(2,"0")}-${xe.getDate().toString().padStart(2,"0")}`;let me;J?(me=qt+1,A.current=0):(me=qt+A.current+1,A.current+=qt);const N=await m.v2.search.list({q:`from:${_.acct} after:${De} before:${Me}`,type:"statuses",limit:me,offset:A.current});if((Ie=N==null?void 0:N.statuses)!=null&&Ie.length){const O=N.statuses.slice(0,qt);O.forEach(Le=>{et(Le,g)});const oe=N.statuses.length<=qt;return{value:O,done:oe}}else return{value:[],done:!0}}let ne=[];if(J){const{value:$e}=await m.v1.accounts.$select(o).statuses.list({pinned:!0}).values().next();if($e!=null&&$e.length&&!h&&!p){const Ee=$e.map(H=>(et(H,g),{...H,_pinned:!0}));if(Ee.length>=3){const H=Ee.map(ke=>ke.id);ne.push({id:H,items:Ee,type:"pinned"})}else ne.push(...Ee)}}(J||!b.current)&&(b.current=m.v1.accounts.$select(o).statuses.list({limit:qt,exclude_replies:d,exclude_reblogs:a,only_media:p||void 0,tagged:h}).values());const{value:we,done:Ce}=await b.current.next();if(we!=null&&we.length){if(ne.length){let $e=[];((Pe=ne[0])==null?void 0:Pe.type)==="pinned"?$e=ne[0].id:$e=ne.filter(H=>H._pinned).map(H=>H.id),$e.every(H=>we.some(ke=>ke.id===H))&&(ne=[])}ne.push(...we),we.forEach($e=>{et($e,g)})}return{value:ne,done:Ce}}const[D,W]=M([]);let G=i({id:"/cKnpj"});if(_!=null&&_.acct){const J=(/@/.test(_.acct)?"":"@")+_.acct,ue=_!=null&&_.displayName?`${_.displayName} (${J})`:`${J}`;if(!d)G=i({id:"hS1Opy",values:{accountDisplay:ue}});else if(a)G=i({id:"A/CX5F",values:{accountDisplay:ue}});else if(h)G=i({id:"QQrO94",values:{accountDisplay:ue,tagged:h}});else if(p)G=i({id:"NoG5wD",values:{accountDisplay:ue}});else if(l){const he=new Date(l).toLocaleString(n.locale,{month:"long",year:"numeric"});G=i({id:"8GjLvB",values:{accountDisplay:ue,monthYear:he}})}else G=ue}tt(G,"/:instance?/a/:id");const X=it(()=>Hr(o,m),[o,m]);Q(()=>{(async()=>{try{const J=await X();T(J)}catch{}if(!k)try{const J=await m.v1.accounts.$select(o).featuredTags.list();W(J)}catch{}})()},[o,k]);const{displayName:q,acct:Z,emojis:B}=_||{},ee=j(),$=Ae(()=>{const J=!d||a||h||p||!!l,ue=s.accounts[`${o}@${g}`];return e(U,{children:[e(Gs,{instance:g,account:ue||o,fetchAccount:X,authenticated:v,standalone:!0,showEndorsements:!0}),!k&&e("div",{class:"filter-bar",ref:ee,style:{position:"relative"},children:[J?e(ge,{to:`/${g}/a/${o}`,class:"insignificant filter-clear",title:i({id:"u8JHrO"}),children:e(I,{icon:"x",size:"l",alt:i({id:"xCJdfg"})})},"clear-filters"):e(I,{icon:"filter",class:"insignificant",size:"l",alt:i({id:"cSev+j"})}),e(ge,{to:`/${g}/a/${o}${d?"?replies=1":""}`,onClick:()=>{d&&fe(i({id:"PIWNSQ"}))},class:d?"":"is-active",children:e(f,{id:"5BFynH"})}),e(ge,{to:`/${g}/a/${o}${a?"":"?boosts=0"}`,onClick:()=>{a||fe(i({id:"Qd13i0"}))},class:a?"is-active":"",children:e(f,{id:"usxQx0"})}),e(ge,{to:`/${g}/a/${o}${p?"":"?media=1"}`,onClick:()=>{p||fe(i({id:"rKpfPY"}))},class:p?"is-active":"",children:e(f,{id:"xYilR2"})}),D.map(he=>e(ge,{to:`/${g}/a/${o}${h===he.name?"":`?tagged=${encodeURIComponent(he.name)}`}`,onClick:()=>{h!==he.name&&fe(i({id:"L+HFfr",values:{0:he.name}}))},class:h===he.name?"is-active":"",children:e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),he.name]})},he.id)),E&&(Or?e("label",{class:`filter-field ${l?"is-active":""}`,children:[e(I,{icon:"month",size:"l"}),e("input",{type:"month",disabled:!(_!=null&&_.acct),value:l||"",min:is,max:new Date().toISOString().slice(0,7),onInput:he=>{const{value:ne,validity:we}=he.currentTarget;if(!we.valid)return;u(ne?{month:ne}:{});const[Ce,se]=ne.split("-"),Te=parseInt(se,10)-1,Ie=new Date(Ce,Te);fe(i({id:"0WUFGD",values:{0:Ie.toLocaleString(n.locale,{month:"long",year:"numeric"})}}))}})]}):e(Fr,{class:`filter-field ${l?"is-active":""}`,disabled:!(_!=null&&_.acct),value:l||"",min:is,max:new Date().toISOString().slice(0,7),onInput:he=>{const{value:ne,validity:we}=he;we.valid&&u(ne?{month:ne}:{})}}))]})]})},[o,g,v,D,X,E,...S]);Q(()=>{var ue;const J=(ue=ee.current)==null?void 0:ue.querySelector(".is-active");J&&ee.current.scrollTo({behavior:"smooth",left:J.offsetLeft-(ee.current.offsetWidth-J.offsetWidth)/2})},[D,E,...S]);const K=Ae(()=>{var ue;return _!=null&&_.url?(ue=URL.parse(_.url))==null?void 0:ue.hostname:null},[_]),te=!!_&&!(g===K);return e(U,{children:[e(At,{title:`${_!=null&&_.acct?"@"+_.acct:i({id:"+owNNn"})}`,titleComponent:e("h1",{class:"header-double-lines header-account",children:[e("b",{children:e(Rs,{text:q,emojis:B})}),e("div",{children:e("span",{class:"bidi-isolate",children:["@",Z]})})]}),id:"account-statuses",instance:g,emptyText:i({id:"+k97fV"}),errorText:i({id:"scd9lw"}),fetchItems:F,useItemID:!0,view:p||k?"media":void 0,boostsCarousel:s.settings.boostsCarousel,timelineStart:$,refresh:[d,a,h,p,l+(_==null?void 0:_.acct)].toString(),headerEnd:e(dt,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(I,{icon:"more",size:"l",alt:i({id:"2FYpfJ"})})}),children:[e(ye,{disabled:!te,onClick:()=>{(async()=>{try{const{masto:J}=re({instance:K}),ue=await J.v1.accounts.lookup({acct:_.acct}),{id:he}=ue;location.hash=`/${K}/a/${he}`}catch{alert(i({id:"FgdLx0"}))}})()},children:[e(I,{icon:"transfer"})," ",e("small",{class:"menu-double-lines",children:e(f,{id:"/JFxxT",values:{0:K?e(U,{children:[" ","(",e("b",{children:un.toUnicode(K)}),")"]}):null}})})]}),!C&&e(ye,{onClick:()=>{(async()=>{try{const J=await y.v1.accounts.lookup({acct:_.acct+"@"+g}),{id:ue}=J;location.hash=`/${w}/a/${ue}`}catch{alert(i({id:"FgdLx0"}))}})()},children:[e(I,{icon:"transfer"})," ",e("small",{class:"menu-double-lines",children:e(f,{id:"HkuyOu",values:{currentInstance:w},components:{0:e("b",{})}})})]})]})},o),Z&&e("data",{class:"compose-data",value:JSON.stringify({draftStatus:{status:`@${Z} `}})})]})}function Fr(n){const{i18n:i}=le(),{class:s,disabled:o,value:c,min:r,max:u,onInput:l=()=>{}}=n,[d,a]=(c==null?void 0:c.split("-"))||[],h=j(),p=j(),m=(g,v)=>{const[y,w]=(r==null?void 0:r.split("-"))||[],[b,S]=(u==null?void 0:u.split("-"))||[];return!(vb||v===y&&gS)};return e("div",{class:s,children:[e(I,{icon:"month",size:"l"}),e("select",{ref:h,disabled:o,value:a||"",onInput:g=>{const{value:v}=g.currentTarget,y=p.current.value;if(!m(v,y))return{value:"",validity:{valid:!1}};l({value:v?`${y}-${v}`:"",validity:{valid:!0}})},children:[e("option",{value:"",children:e(f,{id:"HajiZl"})}),e("option",{disabled:!0,children:"-----"}),Array.from({length:12},(g,v)=>e("option",{value:(v+1).toString().padStart(2,"0"),children:new Date(0,v).toLocaleString(i.locale,{month:"long"})},v))]})," ",e("input",{ref:p,type:"number",disabled:o,value:d||new Date().getFullYear(),min:(r==null?void 0:r.slice(0,4))||Ei,max:(u==null?void 0:u.slice(0,4))||new Date().getFullYear(),onInput:g=>{const{value:v,validity:y}=g.currentTarget,w=h.current.value;if(!y.valid||!m(w,v))return{value:"",validity:{valid:!1}};l({value:v?`${v}-${w}`:"",validity:{valid:!0}})},style:{width:"4.5em"}})]})}function Kr(n,i){return i.v1.accounts.$select(n).fetch()}const Hr=bt(Kr,{maxAge:30*60*1e3});function qr(){var g;const n=Mt(),{year:i}=n;tt(i?`Annual Report: ${i}`:"Annual Report");const{masto:s,instance:o}=re(),[c,r]=M(null),[u,l]=M("default");Q(()=>{i&&(async()=>{l("loading");const v=await s.v1.annualReports.$select(i).fetch();r(v),l("default")})()},[i]);const{accounts:d,annualReports:a,statuses:h}=c||{},p=(g=a==null?void 0:a.find(v=>v.year==i))==null?void 0:g.data,m=new Date;return e("div",{id:"annual-report-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"report",children:[e("h1",{children:[i," #Wrapstodon"]}),u==="loading"&&e("p",{children:[e(Be,{abrupt:!0})," ",e(f,{id:"Pwqkdw"})]}),!!p&&e("dl",{children:Object.entries(p).map(([v,y])=>e(U,{children:[e("dt",{children:v}),e("dd",{class:`report-${v}`,children:Array.isArray(y)?e("table",{children:[e("thead",{children:e("tr",{children:Object.entries(y[0]).map(([w,b])=>e("th",{class:w!=="month"&&typeof b=="number"?"number":"",children:w}))})}),e("tbody",{children:y.map(w=>e("tr",{children:Object.entries(w).map(([b,S])=>e("td",{class:b!=="month"&&typeof S=="number"?"number":"",children:S&&/(accountId)/i.test(b)&&/^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test(v)?e(yt,{account:d==null?void 0:d.find(_=>_.id===S),showAvatar:!0}):b==="month"?m.setMonth(S-1)&&m.toLocaleString(void 0,{month:"long"}):typeof S=="number"?S.toLocaleString():S}))}))})]}):typeof y=="object"?/^(topStatuses)$/i.test(v)?e("dl",{children:Object.entries(y).map(([w,b])=>e(U,{children:[e("dt",{children:w}),e("dd",{children:b&&e(ge,{to:`/${o}/s/${b}`,children:e(Ge,{status:h==null?void 0:h.find(S=>S.id===b),size:"s",readOnly:!0})})})]}))}):e("table",{children:e("tbody",{children:Object.entries(y).map(([w,b])=>e("tr",{children:[e("th",{children:w}),e("td",{class:typeof b=="number"?"number":"",children:b})]}))})}):typeof y=="string"?y:JSON.stringify(y,null,2)})]}))})]}),e("hr",{}),e("p",{style:{textAlign:"center"},children:e(ge,{to:"/",children:e(f,{id:"iWpEwy"})})})]})}const Yr=20;function to(){const{_:n}=le();tt(n({id:"7Ff7ia"}),"/bookmarks");const{masto:i,instance:s}=re(),o=j();async function c(r){return(r||!o.current)&&(o.current=i.v1.bookmarks.list({limit:Yr}).values()),await o.current.next()}return e(At,{title:n({id:"7Ff7ia"}),id:"bookmarks",emptyText:n({id:"8k2w6G"}),errorText:n({id:"UoL+FC"}),instance:s,fetchItems:c})}const jr=""+new URL("catch-up-O5q5C75Z.png",import.meta.url).href,Vr="home",ht=[{label:{id:"Ov9hfp"},value:1},{label:{id:"tVE2wM"},value:2},{label:{id:"8+HOWa"},value:3},{label:{id:"1o+mEC"},value:4},{label:{id:"dZZ8oA"},value:5},{label:{id:"lpPucp"},value:6},{label:{id:"r9r5X6"},value:7},{label:{id:"I9uBFA"},value:8},{label:{id:"pBYFlb"},value:9},{label:{id:"wvL7OJ"},value:10},{label:{id:"7Vb+qD"},value:11},{label:{id:"VU1Pnd"},value:12},{label:{id:"vpc27K"},value:13}],Gr={original:{id:"HxF6Fk"},replies:{id:"N8UzTV"},boosts:{id:"puY2t0"},followedTags:{id:"lCLRBe"},groups:{id:"zhrjek"},filtered:{id:"03Qqf9"}},Wr=["createdAt","repliesCount","favouritesCount","reblogsCount","density"],Zr=[null,"account"],Xr=Ss(n=>new Intl.DateTimeFormat(n||void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"}));function Jr(){const{i18n:n,_:i,_:s}=le(),o=Xr(n.locale);tt("Catch-up","/catchup");const{masto:c,instance:r}=re(),[u,l]=vt(),d=u.get("id"),[a,h]=M("start"),[p,m]=M(!1),g=Ae(()=>kt(),[]),v=L=>L===g,y=Je("@pixelfed/home-include-reblogs");async function w({maxCreatedAt:L}){var be,ve,_e;const V=L?new Date(L):null,ae=[],ie=c.v1.timelines.home.list({limit:40}),z=ie.values();e:for(;;)try{y&&ie.params&&(typeof ie.params=="string"?ie.params+="&include_reblogs=true":ie.params.include_reblogs=!0);const Ze=await z.next(),{value:Fe}=Ze;if(Fe!=null&&Fe.length){await eo(Fe,r);let de=!1;for(let ze=0;ze=V){const He=!v(((ve=(be=Ke.reblog)==null?void 0:be.account)==null?void 0:ve.id)||Ke.account.id)&&Vt(((_e=Ke.reblog)==null?void 0:_e.filtered)||Ke.filtered,Vr);if((He==null?void 0:He.action)==="hide")continue;Ke._filtered=He;const at=lt(Ke.id,r);Ke._followedTags=x.statusFollowedTags[at]?[...x.statusFollowedTags[at]]:[],ae.push(Ke),de=!0}if(!de)break e}}else break e;await new Promise(de=>setTimeout(de,1e3))}catch{break e}return ae.forEach(Ze=>{if(Ze!=null&&Ze.inReplyToId){const Fe=ae.find(de=>de.id===Ze.inReplyToId);Fe&&!Fe.inReplyToId&&(Fe._thread=!0)}}),ae}const[b,S]=M([]),_=j(),T=j(),A=Ae(()=>An(),[]),k=it(async({duration:L}={})=>{const V=Date.now(),ae=L?V-L:null;h("loading");const ie=await w({maxCreatedAt:ae}),z=`${A}-${tc()}`;try{await gt.catchup.set(z,{id:z,posts:ie,count:ie.length,startAt:ae,endAt:V}),l({id:z})}catch{}},[]);Q(()=>{d?(async()=>{const L=await gt.catchup.get(d);L&&(L.posts.sort((V,ae)=>V.createdAt>ae.createdAt?1:-1),S(L.posts),h("results"))})():a==="results"&&(S([]),h("start"))},[d]);const[C,E]=Lt(L=>L+1,0),[R,F]=M(null),[D,W]=M([]);Q(()=>{(async()=>{try{const L=await gt.catchup.keys();if(L.length){const V=An(),ae=L.filter(ie=>ie.startsWith(`${V}-`));if(ae.length){let ie=await gt.catchup.getMany(ae);ie.sort((_e,Ze)=>Ze.endAt-_e.endAt);let z=ie.slice(0,3),be=ie.slice(3);const ve=z.map(_e=>{const{id:Ze,count:Fe,startAt:de,endAt:ze}=_e;return{id:Ze,count:Fe,startAt:de,endAt:ze}});W(ve),F(z[0].endAt),ie=null,z=null,queueMicrotask(()=>{be.length&>.catchup.delMany(be.map(_e=>_e.id)).then(()=>{be=null}).catch(_e=>{})});return}}}catch{}W([])})()},[C]),Q(()=>{a==="start"&&E()},[a==="start"]);const[G,X]=Ae(()=>{var Ze,Fe,de,ze,Ke,nt;let L=0,V=0,ae=0,ie=0,z=0,be=0;const ve={};for(const Re of b){Re._filtered&&((Ze=Re._filtered)==null?void 0:Ze.action)!=="blur"?(L++,Re.__FILTER="filtered"):Re.group?(V++,Re.__FILTER="groups"):Re.reblog?(ae++,Re.__FILTER="boosts"):(Fe=Re._followedTags)!=null&&Fe.length?(z++,Re.__FILTER="followedTags"):Re.inReplyToId&&Re.inReplyToAccountId!==((de=Re.account)==null?void 0:de.id)?(ie++,Re.__FILTER="replies"):(be++,Re.__FILTER="original");const He=Re.reblog||Re;if(Re.__FILTER!=="filtered"&&((ze=He.card)!=null&&ze.url)&&((Ke=He.card)!=null&&Ke.image)&&((nt=He.card)==null?void 0:nt.type)==="link"){const{card:at,favouritesCount:Nt,reblogsCount:Pt}=He;let{url:st}=at;if(st=st.replace(/\/$/,""),!ve[st])ve[st]={postID:He.id,card:at,shared:1,sharers:[Re.account],likes:Nt,boosts:Pt};else{if(ve[st].sharers.find(Fn=>Fn.id===Re.account.id))continue;ve[st].shared++,ve[st].sharers.push(Re.account),ve[st].postID!==He.id&&(ve[st].likes+=Nt,ve[st].boosts+=Pt)}}}let _e=[];for(const Re in ve)_e.push({url:Re,...ve[Re]});if(_e.sort((Re,He)=>Re.shared>He.shared?-1:Re.sharedHe.boosts?-1:Re.boostsHe.likes?-1:Re.likes10)e:for(let Re=10;Re<_e.length;Re++){const{shared:He}=_e[Re];if(He<=1){_e=_e.slice(0,Re);break e}}return[{filtered:L,groups:V,boosts:ae,replies:ie,followedTags:z,original:be},_e]},[b]),[q,Z]=M("all"),[B,ee]=M(null),[$,K]=M(1),[Y,te]=M("createdAt"),[J,ue]=M("asc"),[he,ne]=M(null),[we,Ce,se]=Ae(()=>{const L={},V=new Map;let ae=b.filter(z=>{const be=q==="all"||z.__FILTER===q;return be&&(L[z.account.id]=z.account,V.set(z.account.id,(V.get(z.account.id)||0)+1)),be});const ie={};return ae.forEach(z=>{z.reblog&&(ie[z.reblog.id]?(ie[z.reblog.id].__BOOSTERS?ie[z.reblog.id].__BOOSTERS.add(z.account):ie[z.reblog.id].__BOOSTERS=new Set([z.account]),z.__HIDDEN=!0):ie[z.reblog.id]=z)}),B&&V.has(B)&&(ae=ae.filter(z=>z.account.id===B||[...z.__BOOSTERS||[]].find(be=>be.id===B))),[ae,L,Object.fromEntries(V)]},[q,B,b]),Te=Ae(()=>{const L={};return we.forEach(V=>{L[V.id]=V}),L},[we]),Ie=Ae(()=>Object.keys(se).sort((L,V)=>se[V]-se[L]),[se]),Pe=Ae(()=>{const L={};return Ie.forEach((V,ae)=>{L[V]=ae}),we.filter(V=>!V.__HIDDEN).sort((V,ae)=>{if(he==="account"){const ie=V.account.id,z=ae.account.id,be=L[ie],ve=L[z],_e=be-ve;if(_e!==0)return _e}if(Y!=="createdAt"&&(V=V.reblog||V,ae=ae.reblog||ae,Y!=="density"&&V[Y]===ae[Y]))return V.createdAt>ae.createdAt?1:-1;if(Y==="density"){const ie=ss(V),z=ss(ae);return J==="asc"?ie>z?1:-1:z>ie?1:-1}return J==="asc"?V[Y]>ae[Y]?1:-1:ae[Y]>V[Y]?1:-1})},[we,Y,J,he,Ie]),$e=j(null),Ee=j(null),H=j(!1);Q(()=>{b.length>100||H.current||Ee.current&&(Fs(Ee.current,{duration:200}),H.current=!0)},[b,Ee]);const ke=b.length>160?"3d":"2d",De=Ae(()=>ke!=="2d"?null:b.map(L=>{const V=Te[L.id];return e("span",{class:`post-dot ${V?"post-dot-highlight":""}`},L.id)}),[Te]),xe=Ae(()=>ke!=="3d"||!(b!=null&&b.length)?null:ol(b,"createdAt",320).map((V,ae)=>e("div",{class:"posts-bin",children:V.map(ie=>{const z=Te[ie.id];return e("span",{class:`post-dot ${z?"post-dot-highlight":""}`},ie.id)})},ae)),[Te]),Me=j(null),me=Ae(()=>R?(Date.now()-R)/1e3/60/60:null,[R,$]);Q(()=>{if(a!=="results")return;const L=B&&Ce[B]?Ce[B].username:"",V=J==="asc"?0:1,ae={account:"authors"};let ie=fe({duration:5e3,text:s({id:"TLYeLT",values:{selectedFilterCategory:q,sortBy:Y,sortOrder:J,groupBy:he}})});return()=>{var z;(z=ie==null?void 0:ie.hideToast)==null||z.call(ie)}},[a,q,B,Y,J,he,Ce]),Q(()=>{var L;if(B&&Ce[B]){const V=Ee.current.querySelector(`[data-author="${B}"]`),ae=(L=Ee.current)==null?void 0:L.getBoundingClientRect(),ie=V==null?void 0:V.getBoundingClientRect();ie.leftae.right?V.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}):ie.top<0&&V.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}},[B,Ce]);const[N,O]=M(!1),oe=".catchup-list > li > a",Le=qe("j",()=>{const L=document.activeElement.closest(oe),V=L==null?void 0:L.getBoundingClientRect(),ae=Array.from(Me.current.querySelectorAll(oe));if(L&&V.top0){const ie=ae.indexOf(L),z=ae[ie+1];z&&(z.focus(),z.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}))}else{const ie=ae.find(z=>z.getBoundingClientRect().top>=0);ie&&(ie.focus(),ie.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))}},{useKey:!0,preventDefault:!0,ignoreEventWhen:L=>L.metaKey||L.ctrlKey||L.altKey||L.shiftKey}),P=qe("k",()=>{const L=document.activeElement.closest(oe),V=L==null?void 0:L.getBoundingClientRect(),ae=Array.from(Me.current.querySelectorAll(oe));if(L&&V.top0){const ie=ae.indexOf(L);let z=ae[ie-1];z&&(z.focus(),z.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}))}else{const ie=ae.find(z=>{const be=z.getBoundingClientRect();return be.top>=44&&be.left>=0});ie&&(ie.focus(),ie.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))}},{useKey:!0,preventDefault:!0,ignoreEventWhen:L=>L.metaKey||L.ctrlKey||L.altKey||L.shiftKey}),ce=qe("h, l",(L,V)=>{var ie,z,be;const ae=V.keys[0];if(B){const ve=Ie.indexOf(B);ae==="h"?ve>0&&ve=0&&(ee(Ie[ve+1]),(z=Me.current)==null||z.focus())}else ae==="l"&&(ee(Ie[0]),(be=Me.current)==null||be.focus())},{useKey:!0,preventDefault:!0,ignoreEventWhen:L=>L.metaKey||L.ctrlKey||L.altKey||L.shiftKey,enableOnFormTags:["input"]}),Se=qe("esc",()=>{var L;ee(null),(L=Me.current)==null||L.focus()},{preventDefault:!0,ignoreEventWhen:L=>L.metaKey||L.ctrlKey||L.altKey||L.shiftKey,enableOnFormTags:["input"],useKey:!0}),Ne=qe(".",()=>{var L;(L=Me.current)==null||L.scrollTo({top:0,behavior:"smooth"})},{useKey:!0,preventDefault:!0,ignoreEventWhen:L=>L.metaKey||L.ctrlKey||L.altKey||L.shiftKey,enableOnFormTags:["input"]}),Oe=it(L=>{const V=document.activeElement,ae=(V==null?void 0:V.tagName)==="INPUT"&&V.type==="radio";if((L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="ArrowLeft"||L.key==="ArrowRight")&&ae){V.blur();return}},[]);return e("div",{ref:L=>{Me.current=L,Le.current=L,P.current=L,ce.current=L,Se.current=L,Ne.current=L},id:"catchup-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck wide",children:[e("header",{class:`${a==="loading"?"loading":""}`,onClick:L=>{var V;L.target.closest("a, button")||(V=Me.current)==null||V.scrollTo({top:0,behavior:"smooth"})},children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),a==="results"&&e(ge,{to:"/catchup",class:"button plain",children:e(I,{icon:"history2",size:"l",alt:s({id:"xrl8fj"})})}),a==="start"&&e(ge,{to:"/",class:"button plain",children:e(I,{icon:"home",size:"l",alt:s({id:"i0qMbr"})})})]}),e("h1",{children:a!=="start"&&e(f,{id:"wyL/3/",components:{0:e("sup",{})}})}),e("div",{class:"header-side",children:a!=="start"&&a!=="loading"&&e("button",{type:"button",class:"plain",onClick:()=>{O(!0)},children:e(f,{id:"c3XJ18"})})})]})}),e("main",{onKeyDown:Oe,children:[a==="start"&&e("div",{class:"catchup-start",children:[e("h1",{children:e(f,{id:"wyL/3/",components:{0:e("sup",{})}})}),e("details",{children:[e("summary",{children:e(f,{id:"CxKPv6"})}),e("p",{children:e(f,{id:"YMU1CK"})}),e("img",{src:jr,width:"1200",height:"900",alt:s({id:"CeInO2"})}),e("p",{children:e("button",{type:"button",onClick:L=>{L.target.closest("details").open=!1},children:e(f,{id:"2jI8hh"})})})]}),e("p",{children:e(f,{id:"1RfGk7"})}),e("p",{children:e("b",{children:e(f,{id:"OOEonE"})})}),e("div",{class:"catchup-form",children:[e("input",{ref:_,type:"range",value:$,min:ht[0].value,max:ht[ht.length-1].value,step:"1",list:"catchup-ranges",onChange:L=>K(+L.target.value)})," ",e("span",{style:{width:"8em"},children:[i(ht[$-1].label),e("br",{}),e("small",{class:"insignificant",children:$==ht[ht.length-1].value?s({id:"NMNiaO"}):ct(new Date(Date.now()-$*60*60*1e3))})]}),e("datalist",{id:"catchup-ranges",children:ht.map(({label:L,value:V})=>e("option",{value:V,label:i(L)}))})," ",e("button",{type:"button",onClick:()=>{var L;if($me?e("p",{class:"catchup-info",children:[e(I,{icon:"info"})," ",e(f,{id:"AGyV7s"})]}):$===ht[ht.length-1].value&&R?e("p",{class:"catchup-info",children:e("label",{children:[e("input",{type:"checkbox",switch:!0,checked:!0,ref:T})," ",e(f,{id:"dDJEHI",values:{0:o.format(new Date(R))}})]})}):null,e("p",{class:"insignificant",children:e("small",{children:e(f,{id:"EAjFM0"})})}),!!(D!=null&&D.length)&&e("div",{class:"catchup-prev",children:[e("p",{children:e(f,{id:"Yfb9A8"})}),e("ul",{children:D.map(L=>e("li",{children:[e(ge,{to:`/catchup?id=${L.id}`,children:[e(I,{icon:"history2"})," ",e("span",{children:L.startAt?o.formatRange(new Date(L.startAt),new Date(L.endAt)):`… – ${o.format(new Date(L.endAt))}`})]})," ",e("span",{children:[e("small",{class:"ib insignificant",children:e(f,{id:"S6XZwv",values:{0:L.count}})})," ",e("button",{type:"button",class:"light danger small",onClick:async()=>{var ae;if(confirm(s({id:"D9CmP2"}))){let ie=fe(s({id:"xJUo4P",values:{0:L.id}}));await gt.catchup.del(L.id),(ae=ie==null?void 0:ie.hideToast)==null||ae.call(ie),fe(s({id:"1dyGG/",values:{0:L.id}})),E()}},children:e(I,{icon:"x",alt:s({id:"t/YqKh"})})})]})]},L.id))}),D.length>=3&&e("p",{children:e("small",{children:e(f,{id:"sXmrl4"})})})]})]}),a==="loading"&&e("div",{class:"ui-state catchup-start",children:[e(Be,{abrupt:!0}),e("p",{class:"insignificant",children:e(f,{id:"rbUTzD"})}),e("p",{class:"insignificant",children:e(f,{id:"q9urQO"})})]}),a==="results"&&e(U,{children:[e("div",{class:"catchup-header",children:[b.length>0&&e("p",{children:e("b",{class:"ib",children:o.formatRange(new Date(b[0].createdAt),new Date(b[b.length-1].createdAt))})}),e("aside",{children:[e("button",{hidden:q==="all"&&!B&&Y==="createdAt"&&J==="asc",type:"button",class:"plain4 small",onClick:()=>{Z("all"),ee(null),te("createdAt"),ne(null),ue("asc")},children:e(f,{id:"I9EnzM"})}),(X==null?void 0:X.length)>0&&e("button",{type:"button",class:"plain small",onClick:()=>m(!p),children:[e(f,{id:"EIZREX"})," ",e(I,{icon:"chevron-down",style:{transform:p?"rotate(180deg)":"rotate(0deg)"}})]})]})]}),e("div",{class:"shazam-container no-animation",hidden:!p,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"catchup-top-links links-bar",children:X.map(L=>{const{card:V,shared:ae,sharers:ie,likes:z,boosts:be}=L,{blurhash:ve,title:_e,description:Ze,url:Fe,image:de,imageDescription:ze,language:Ke,width:nt,height:Re,publishedAt:He}=V,at=$s(Fe);let Nt;if(ve){const Pt=mi(ve),st=xi(Pt);Nt=Ai([.6,st[1],st[2]])}return e("a",{href:Fe,target:"_blank",rel:"noopener",class:"link-block",style:Nt?{"--accent-color":`rgb(${Nt.join(",")})`,"--accent-alpha-color":`rgba(${Nt.join(",")}, 0.4)`}:{},children:e("article",{children:[e("figure",{children:e("img",{src:de,alt:ze,width:nt,height:Re,loading:"lazy"})}),e("div",{class:"article-body",children:[e("header",{children:[e("div",{class:"article-meta",children:[e("span",{class:"domain",children:at})," ",!!He&&e(U,{children:"· "}),!!He&&e(U,{children:e(_t,{datetime:He,format:"micro"})})]}),!!_e&&e("h1",{class:"title",lang:Ke,dir:"auto",title:_e,children:_e})]}),!!Ze&&e("p",{class:"description",lang:Ke,dir:"auto",title:Ze,children:Ze}),e("hr",{}),e("p",{style:{whiteSpace:"nowrap"},children:e(f,{id:"bfSr6z",values:{0:ie.map(Pt=>{const{avatarStatic:st,displayName:Fn}=Pt;return e("button",{type:"button",class:"plain",style:{padding:0},onClick:Li=>{Li.preventDefault(),Li.stopPropagation();const{id:So}=Pt;ee(So),Z("all")},children:e(mt,{url:st,size:"s",alt:Fn})})})}})})]})]})},Fe)})})})}),b.length>=5&&(ke==="3d"?e("div",{class:"catchup-posts-viz-time-bar",children:xe}):e("div",{class:"catchup-posts-viz-bar",children:De})),b.length>=2&&e("div",{class:"catchup-filters",children:[e("label",{class:"filter-cat",children:[e("input",{type:"radio",name:"filter-cat",checked:q.toLowerCase()==="all",onChange:()=>{Z("all")}}),e(f,{id:"N40H+G"})," ",e("span",{class:"count",children:b.length})]}),Object.entries(Gr).map(([L,V])=>!!G[L]&&e("label",{class:"filter-cat",title:(G[L]/b.length*100).toFixed(2)+"%",children:[e("input",{type:"radio",name:"filter-cat",checked:q.toLowerCase()===L.toLowerCase(),onChange:()=>{Z(L),L==="boosts"&&(te("reblogsCount"),ue("desc"),ne(null))}}),i(V)," ",e("span",{class:"count",children:G[L]})]},i(V)))]}),b.length>=2&&!!se&&e("div",{class:"catchup-filters authors-filters",ref:Ee,children:[Ie.map(L=>e("label",{class:"filter-author","data-author":L,children:[e("input",{type:"radio",name:"filter-author",checked:B===L,onChange:()=>{ee(L)},onClick:()=>{B===L&&ee(null)}}),e(mt,{url:Ce[L].avatarStatic||Ce[L].avatar,size:"xxl",alt:`${Ce[L].displayName} (@${Ce[L].acct})`})," ",e("span",{class:"count",children:se[L]}),e("span",{class:"username",children:Ce[L].username})]},`${L}-${se[L]}`)),Ie.length>5&&e("small",{style:{whiteSpace:"nowrap",paddingInline:"1em",opacity:.33},children:e(f,{id:"HHtYi7",values:{0:Ie.length}})},"authors-count")]}),b.length>=2&&e("div",{class:"catchup-filters",children:[e("span",{class:"filter-label",children:e(f,{id:"f6Hub0"})})," ",e("fieldset",{class:"radio-field-group",children:Wr.map(L=>e("label",{class:"filter-sort",onClick:V=>{Y===L&&(V.preventDefault(),V.stopPropagation(),ue(J==="asc"?"desc":"asc"))},children:[e("input",{type:"radio",name:"filter-sort-cat",checked:Y===L,onChange:()=>{te(L);const V=/(replies|favourites|reblogs)/.test(L)?"desc":"asc";ue(V)}}),{createdAt:s({id:"mYGY3B"}),repliesCount:s({id:"N8UzTV"}),favouritesCount:s({id:"zZOZj7"}),reblogsCount:s({id:"puY2t0"}),density:s({id:"0tQ7AD"})}[L],Y===L&&(J==="asc"?" ↑":" ↓")]},L))}),e("span",{class:"filter-label",children:e(f,{id:"group.filter"})})," ",e("fieldset",{class:"radio-field-group",children:Zr.map(L=>e("label",{class:"filter-group",children:[e("input",{type:"radio",name:"filter-group",checked:he===L,onChange:()=>{ne(L)},disabled:L==="account"&&B}),{account:s({id:"dpqPBg"})}[L]||s({id:"EdQY6l"})]},L||"none"))}),B&&Ie.length>1?e("button",{type:"button",class:"plain6 small",onClick:()=>{ee(null)},style:{whiteSpace:"nowrap"},children:e(f,{id:"/dlmrZ"})}):null]}),e("ul",{class:`catchup-list catchup-filter-${q||""} ${Y?`catchup-sort-${Y}`:""} ${B&&Ce[B]?"catchup-selected-author":""} ${he?`catchup-group-${he}`:""}`,children:Pe.map((L,V)=>{var z;const ae=((z=L.reblog)==null?void 0:z.id)||L.id;let ie=!1;return he==="account"&&($e.current&&L.account.id!==$e.current&&V>0&&(ie=!0),$e.current=L.account.id),e(U,{children:[ie&&e("li",{class:"separator"}),e(el,{to:`/${r}/s/${ae}`,post:L,root:Me.current})]},`${L.id}-${ie}`)})}),e("footer",{children:we.length>5&&e("p",{children:[s(q==="boosts"?{id:"eVosYr"}:{id:"rhmyFK"})," ",e("button",{type:"button",class:"textual",onClick:()=>{Me.current.scrollTop=0},children:e(f,{id:"0MgdN+"})}),"."]})})]})]})]}),N&&e(Ye,{onClose:()=>O(!1),children:e("div",{class:"sheet",id:"catchup-help-sheet",children:[e("button",{type:"button",class:"sheet-close",onClick:()=>O(!1),children:e(I,{icon:"x",alt:s({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:e(f,{id:"c3XJ18"})})}),e("main",{children:e("dl",{children:[e("dt",{children:e(f,{id:"EIZREX"})}),e("dd",{children:e(f,{id:"YmGrIy"})}),e("dt",{children:e(f,{id:"coaNtr"})}),e("dd",{children:e(f,{id:"UUrqX1"})}),e("dt",{children:e(f,{id:"ScQBC/"})}),e("dd",{children:e(f,{id:"srocAr"})}),e("dt",{children:e(f,{id:"77Emn0"})}),e("dd",{children:e("table",{children:e("tbody",{children:[e("tr",{children:[e("td",{children:e(f,{id:"Gy9P9T"})}),e("td",{children:e("kbd",{children:"j"})})]}),e("tr",{children:[e("td",{children:e(f,{id:"6XYpYY"})}),e("td",{children:e("kbd",{children:"k"})})]}),e("tr",{children:[e("td",{children:e(f,{id:"f5dduh"})}),e("td",{children:e("kbd",{children:"l"})})]}),e("tr",{children:[e("td",{children:e(f,{id:"rj0vxZ"})}),e("td",{children:e("kbd",{children:"h"})})]}),e("tr",{children:[e("td",{children:e(f,{id:"jsFF8C"})}),e("td",{children:e("kbd",{children:"Enter"})})]}),e("tr",{children:[e("td",{children:e(f,{id:"bUUv3P"})}),e("td",{children:e("kbd",{children:"."})})]})]})})})]})})]})})]})}const Qr=ut(function({post:n}){const{id:i,account:s,group:o,reblog:c,inReplyToId:r,inReplyToAccountId:u,_followedTags:l,_filtered:d,visibility:a,__BOOSTERS:h}=n,p=r&&u!==s.id,m=!!d&&(d==null?void 0:d.action)!=="blur",g=v=>{v.shiftKey};return e("article",{class:`post-line ${o?"group":c?"reblog":l!=null&&l.length?"followed-tags":""} ${p?"reply-to":""} ${m?"filtered":""} visibility-${a}`,onMouseEnter:g,children:[e("span",{class:"post-author",children:c?e("span",{class:"post-reblog-avatar",children:[e(mt,{url:s.avatarStatic||s.avatar,squircle:s.bot}),(h==null?void 0:h.size)>0?[...h].map(v=>e(mt,{url:v.avatarStatic||v.avatar,squircle:v.bot})):""," ",e(I,{icon:"rocket"})," ",e(yt,{account:c.account,showAvatar:!0})]}):e(yt,{account:s,showAvatar:!0})}),e(il,{post:c||n,filterInfo:d}),e("span",{class:"post-meta",children:[e(sl,{post:c||n})," ",e(_t,{datetime:new Date((c==null?void 0:c.createdAt)||n.createdAt),format:"micro"})]})]})},(n,i)=>{var s,o;return((s=n==null?void 0:n.post)==null?void 0:s.id)===((o=i==null?void 0:i.post)==null?void 0:o.id)}),el=({root:n,to:i,...s})=>{const o=j(),[c,r]=M(!1);return Q(()=>{const u=new IntersectionObserver(l=>{l[0].isIntersecting&&(queueMicrotask(()=>r(!0)),u.unobserve(o.current))},{root:n,rootMargin:`${Math.max(320,screen.height*.75)}px`});return o.current&&u.observe(o.current),()=>{o.current&&u.unobserve(o.current)}},[]),c?e("li",{children:e(ge,{to:i,children:e(Qr,{...s})})}):e("li",{ref:o,style:{height:"4em"}})},tl=8,nl=8;function ss(n){var d;const{spoilerText:i,content:s,poll:o,mediaAttachments:c,card:r}=n,u=(d=o==null?void 0:o.options)!=null&&d.length?o.options.reduce((a,h)=>a+h.title,""):"";return(i.length+Ns(s)+u.length)/140+(c!=null&&c.length?tl*c.length:r!=null&&r.image?nl:0)}const xt=48;function il({post:n,filterInfo:i}){var T;const{_:s}=le(),{spoilerText:o,sensitive:c,content:r,emojis:u,poll:l,mediaAttachments:d,card:a,inReplyToId:h,inReplyToAccountId:p,account:m,_thread:g}=n,v=h&&p===m.id||!!g,w=!!li()["reading:expand:spoilers"],b=w||!o&&!c&&(i==null?void 0:i.action)!=="blur",S=r?Nn(n):"",_=!o||w;return e("div",{class:"post-peek",title:o?"":S,children:[e("span",{class:"post-peek-content",children:[v&&!_&&e(U,{children:[e("span",{class:"post-peek-tag post-peek-thread",children:"Thread"})," "]}),i&&(i==null?void 0:i.action)!=="blur"?e("span",{class:"post-peek-filtered",children:i!=null&&i.titlesStr?s({id:"suKjh3",values:{0:i.titlesStr}}):s({id:"03Qqf9"})}):e(U,{children:[!!o&&e("span",{class:"post-peek-spoiler",children:[e(I,{icon:`${w?"eye-open":"eye-close"}`})," ",o]}),_&&e("div",{class:"post-peek-html",children:[v&&e(U,{children:[e("span",{class:"post-peek-tag post-peek-thread",children:e(f,{id:"e66y2Z"})})," "]}),!!r&&e("div",{dangerouslySetInnerHTML:{__html:nc(r,u)}}),!!((T=l==null?void 0:l.options)!=null&&T.length)&&l.options.map(A=>e("div",{children:[l.multiple?"▪️":"•"," ",A.title]})),!r&&(d==null?void 0:d.length)===1&&d[0].description&&e(U,{children:[e("span",{class:"post-peek-tag post-peek-alt",children:"ALT"})," ",e("div",{children:d[0].description})]})]})]})]}),(!i||(i==null?void 0:i.action)==="blur")&&e("span",{class:"post-peek-post-content",children:[!!l&&e("span",{class:"post-peek-tag post-peek-poll",children:[e(I,{icon:"poll",size:"s"}),e(f,{id:"4WUbF1"})]}),d!=null&&d.length?d.map(A=>{var F,D,W,G,X,q,Z,B,ee,$;const k=A.previewUrl||A.url,C=A.previewRemoteUrl||A.remoteUrl,E=(F=A.meta)!=null&&F.original?A.meta.original.width:((W=(D=A.meta)==null?void 0:D.small)==null?void 0:W.width)||((X=(G=A.meta)==null?void 0:G.original)==null?void 0:X.width),R=(q=A.meta)!=null&&q.original?A.meta.original.height:((B=(Z=A.meta)==null?void 0:Z.small)==null?void 0:B.height)||(($=(ee=A.meta)==null?void 0:ee.original)==null?void 0:$.height);return e("span",{class:"post-peek-media",children:{image:(k||C)&&b?e("img",{src:k,width:xt,height:xt,alt:A.description,loading:"lazy",onError:K=>{const{src:Y}=K.target;Y===k&&(K.target.src=C)},style:{"--anim-duration":`${Math.min(Math.max(Math.max(E,R)/100,5),120)}s`}}):e("span",{class:"post-peek-faux-media",children:"🖼"}),gifv:(k||C)&&b?e("img",{src:k,width:xt,height:xt,alt:A.description,loading:"lazy",onError:K=>{const{src:Y}=K.target;Y===k&&(K.target.src=C)}}):e("span",{class:"post-peek-faux-media",children:"🎞️"}),video:(k||C)&&b?e("img",{src:k,width:xt,height:xt,alt:A.description,loading:"lazy",onError:K=>{const{src:Y}=K.target;Y===k&&(K.target.src=C)}}):e("span",{class:"post-peek-faux-media",children:"📹"}),audio:e("span",{class:"post-peek-faux-media",children:"🎵"})}[A.type]||null},A.id)}):!!a&&a.image&&b&&e("span",{class:`post-peek-media post-peek-card card-${a.type||""}`,children:a.image?e("img",{src:a.image,width:xt,height:xt,alt:a.title||a.description||a.imageDescription,loading:"lazy",style:{"--anim-duration":a.width&&a.height&&`${Math.min(Math.max(Math.max(a.width,a.height)/100,5),120)}s`}}):e("span",{class:"post-peek-faux-media",children:"🔗"})})]})]})}function sl({post:n}){const{_:i}=le(),{reblogsCount:s,repliesCount:o,favouritesCount:c}=n;return e("span",{class:"post-stats",children:[o>0&&e("span",{class:"post-stat-replies",children:[e(I,{icon:"comment2",size:"s",alt:i({id:"N8UzTV"})})," ",Qe(o)]}),c>0&&e("span",{class:"post-stat-likes",children:[e(I,{icon:"heart",size:"s",alt:i({id:"zZOZj7"})})," ",Qe(c)]}),s>0&&e("span",{class:"post-stat-boosts",children:[e(I,{icon:"rocket",size:"s",alt:i({id:"puY2t0"})})," ",Qe(s)]})]})}function ol(n,i,s){const o=n.map(d=>new Date(d[i])),c=o.reduce((d,a)=>aa>d?a:d,o[0]),u=Math.min(r.getTime(),Date.now())-c.getTime(),l=Array.from({length:s},()=>[]);return n.forEach(d=>{const a=new Date(d[i]);if(a.getTime()>Date.now())l[l.length-1].push(d);else{const h=(a.getTime()-c.getTime())/u,p=Math.floor(h*(s-1));l[p].push(d)}}),l}const cl=20;function no(){const{_:n}=le();tt(n({id:"zZOZj7"}),"/favourites");const{masto:i,instance:s}=re(),o=j();async function c(r){return(r||!o.current)&&(o.current=i.v1.favourites.list({limit:cl}).values()),await o.current.next()}return e(At,{title:n({id:"zZOZj7"}),id:"favourites",emptyText:n({id:"PHIrMr"}),errorText:n({id:"khVljG"}),instance:s,fetchItems:c})}const al=["home","public","notifications","thread","account"],os=["thread","account"],rl={home:{id:"Buy2bt"},notifications:{id:"iDNBZe"},public:{id:"RO10dm"},thread:{id:"EnJuK0"},account:{id:"vrQQgz"}},ll=[0,30*60,60*60,6*60*60,12*60*60,60*60*24,60*60*24*7,60*60*24*30],Xn={0:{id:"qqeAJM"},1800:ot(30,"minute"),3600:ot(1,"hour"),21600:ot(6,"hour"),43200:ot(12,"hour"),86400:ot(24,"hour"),604800:ot(7,"day"),2592e3:ot(30,"day")};function dl(){const{_:n}=le(),{masto:i}=re();tt(n({id:"cSev+j"}),"/ft");const[s,o]=M("default"),[c,r]=M(!1),[u,l]=Lt(h=>h+1,0),[d,a]=M([]);return Q(()=>{o("loading"),(async()=>{try{const h=await i.v2.filters.list();h.sort((p,m)=>p.title.localeCompare(m.title)),h.forEach(p=>{var m;(m=p.keywords)!=null&&m.length&&p.keywords.sort((g,v)=>g.id-v.id)}),a(h),o("default")}catch{o("error")}})()},[u]),e("div",{id:"filters-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),e(ge,{to:"/",class:"button plain",children:e(I,{icon:"home",size:"l",alt:n({id:"i0qMbr"})})})]}),e("h1",{children:e(f,{id:"cSev+j"})}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>{r(!0)},children:e(I,{icon:"plus",size:"l",alt:n({id:"yFfBdX"})})})})]})}),e("main",{children:d.length>0?e(U,{children:[e("ul",{class:"filters-list",children:d.map(h=>{const{id:p,title:m,expiresAt:g,keywords:v}=h;return e("li",{children:[e("div",{children:[e("h2",{children:m}),(v==null?void 0:v.length)>0&&e("div",{children:v.map(y=>e(U,{children:[e("span",{class:"tag collapsed insignificant",children:y.wholeWord?`“${y.keyword}”`:y.keyword})," "]}))}),e("small",{class:"insignificant",children:e(io,{expiresAt:g})})]}),e("button",{type:"button",class:"plain",onClick:()=>{r({filter:h})},children:e(I,{icon:"pencil",size:"l",alt:"Edit filter"})})]},p)})}),d.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:e(f,{id:"5vzJxv",values:{0:d.length}})})})]}):s==="loading"?e("p",{class:"ui-state",children:e(Be,{})}):s==="error"?e("p",{class:"ui-state",children:e(f,{id:"qcAUwp"})}):e("p",{class:"ui-state",children:e(f,{id:"cWIHTt"})})})]}),!!c&&e(Ye,{title:n({id:"vCSBPD"}),onClose:()=>{r(!1)},children:e(fl,{filter:c==null?void 0:c.filter,onClose:h=>{h.state==="success"&&l(),r(!1)}})})]})}let ul=1;const hl=()=>ul++;function fl({filter:n,onClose:i}){var E;const{_:s,_:o}=le(),{masto:c}=re(),[r,u]=M("default"),l=!!n,{context:d,expiresAt:a,id:h,keywords:p,title:m,filterAction:g}=n||{},v=!!a,y=v&&new Date(a),[w,b]=M(p||[]),S=j(),[_,T]=M([]),[A,k]=M([]),C=w.filter(R=>!_.includes(R.id)&&!A.includes(R._id));return e("div",{class:"sheet",id:"filters-add-edit-modal",children:[!!i&&e("button",{type:"button",class:"sheet-close",onClick:i,children:e(I,{icon:"x",alt:o({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:o(l?{id:"3mOee6"}:{id:"yFfBdX"})})}),e("main",{children:e("form",{onSubmit:R=>{R.preventDefault();const F=new FormData(R.target),D=F.get("title"),W=F.getAll("keyword_attributes[][id]"),G=F.getAll("keyword_attributes[][keyword]"),X=[...S.current.querySelectorAll('input[name="keyword_attributes[][whole_word]"]')].map($=>$.checked),q=G.map(($,K)=>({id:W[K]||void 0,keyword:$,wholeWord:X[K]}));l&&(_!=null&&_.length)&&_.forEach($=>{q.push({id:$,_destroy:!0})});const Z=F.getAll("context");let B=F.get("expires_in");const ee=F.get("filter_action");!D||!(Z!=null&&Z.length)||(u("loading"),(async()=>{try{let $;l?(B===""||B===null?v?B=Math.floor((y-new Date)/1e3):B=null:B==="0"||B===0?B=null:B=+B,$=await c.v2.filters.$select(h).update({title:D,context:Z,expiresIn:B,keywordsAttributes:q,filterAction:ee})):(B=+B||null,$=await c.v2.filters.create({title:D,context:Z,expiresIn:B,keywordsAttributes:q,filterAction:ee})),u("default"),i==null||i({state:"success",filter:$})}catch{u("error"),alert(o(l?{id:"H8RP+h"}:{id:"Fr0hAN"}))}})())},children:[e("div",{class:"filter-form-row",children:e("label",{children:[e("b",{children:e(f,{id:"MHrjPM"})}),e("input",{type:"text",name:"title",defaultValue:m,disabled:r==="loading",dir:"auto",required:!0})]})}),e("div",{class:"filter-form-keywords",ref:S,children:[C.length?e("ul",{class:"filter-keywords",children:C.map(R=>{const{id:F,keyword:D,wholeWord:W,_id:G}=R;return e("li",{children:[e("input",{type:"hidden",name:"keyword_attributes[][id]",value:F}),e("input",{name:"keyword_attributes[][keyword]",type:"text",defaultValue:D,disabled:r==="loading",required:!0,dir:"auto"}),e("div",{class:"filter-keyword-actions",children:[e("label",{children:[e("input",{name:"keyword_attributes[][whole_word]",type:"checkbox",value:F,defaultChecked:W,disabled:r==="loading"})," ",e(f,{id:"/7UQ7y"})]}),e("button",{type:"button",class:"light danger small",disabled:r==="loading",onClick:()=>{F?(_.push(F),T([..._])):G&&(A.push(G),k([...A]))},children:e(I,{icon:"x",alt:o({id:"t/YqKh"})})})]})]},`${F}-${G}`)})}):e("div",{class:"filter-keywords",children:e("div",{class:"insignificant",children:e(f,{id:"SYKm3p"})})}),e("footer",{class:"filter-keywords-footer",children:[e("button",{type:"button",class:"light",onClick:()=>{b([...w,{_id:hl(),keyword:"",wholeWord:!0}]),setTimeout(()=>{var F,D;const R=S.current.querySelectorAll('input[type="text"]');(D=(F=R[R.length-1])==null?void 0:F.focus)==null||D.call(F)},10)},children:e(f,{id:"qn5Dbn"})})," ",(C==null?void 0:C.length)>1&&e("small",{class:"insignificant",children:e(f,{id:"1JZ175",values:{0:C.length}})})]})]}),e("div",{class:"filter-form-cols",children:[e("div",{class:"filter-form-col",children:[e("div",{children:e("b",{children:e(f,{id:"uqf7Yq"})})}),al.map(R=>e("div",{children:[e("label",{class:os.includes(R)?"insignificant":"",children:[e("input",{type:"checkbox",name:"context",value:R,defaultChecked:d?d.includes(R):!0,disabled:r==="loading"})," ",s(rl[R]),os.includes(R)?"*":""]})," "]})),e("p",{children:e("small",{class:"insignificant",children:e(f,{id:"m0G499"})})})]}),e("div",{class:"filter-form-col",children:[l&&e(f,{id:"ucJk3m",components:{0:e("b",{}),1:e(io,{expiresAt:a,showNeverExpires:!0})}}),e("div",{children:[e("label",{for:"filters-expires_in",children:o(l?{id:"BcNdg+"}:{id:"agO/T/"})}),e("select",{id:"filters-expires_in",name:"expires_in",disabled:r==="loading",defaultValue:l?void 0:0,children:[l&&e("option",{}),ll.map(R=>e("option",{value:R,children:typeof Xn[R]=="function"?Xn[R]():s(Xn[R])}))]})]}),e("p",{children:[e(f,{id:"blQMpa"}),e("br",{}),((E=bs())==null?void 0:E.mastodon)>=5&&e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"blur",defaultChecked:g==="blur",disabled:r==="loading"})," ",e(f,{id:"ggxOw9"})]})," ",e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"warn",defaultChecked:g!=="hide"&&g!=="blur"||!l,disabled:r==="loading"})," ",e(f,{id:"jbreWy"})]})," ",e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"hide",defaultChecked:g==="hide",disabled:r==="loading"})," ",e(f,{id:"zNCBmf"})]})]})]})]}),e("footer",{class:"filter-form-footer",children:[e("span",{children:[e("button",{type:"submit",disabled:r==="loading",children:o(l?{id:"tfDRzk"}:{id:"hYgDIe"})})," ",e(Be,{abrupt:!0,hidden:r!=="loading"})]}),l&&e(pt,{disabled:r==="loading",align:"end",menuItemClassName:"danger",confirmLabel:o({id:"BPjyR2"}),onClick:()=>{u("loading"),(async()=>{try{await c.v2.filters.$select(h).remove(),u("default"),i==null||i({state:"success"})}catch{u("error"),alert(o({id:"4Dh9J1"}))}})()},children:e("button",{type:"button",class:"light danger",onClick:()=>{},disabled:r==="loading",children:e(f,{id:"Jb6/SB"})})})]})]})})]})}function io({expiresAt:n,showNeverExpires:i}){const{_:s}=le(),o=!!n,c=o&&new Date(n),r=o&&c<=new Date,[u,l]=Lt(d=>d+1,0);return fi(l,r||3e4),r?s({id:"M1RnFv"}):o?e(f,{id:"urGtsw",components:{0:e(_t,{datetime:c})}}):i&&s({id:"O1Aswy"})}function pl(){const{_:n}=le(),{masto:i,instance:s}=re();tt(n({id:"Xi1/bw"}),"/fh");const[o,c]=M("default"),[r,u]=M([]);return Q(()=>{c("loading"),(async()=>{try{const l=await Mn();u(l),c("default")}catch{c("error")}})()},[]),e("div",{id:"followed-hashtags-page",class:"deck-container",tabIndex:"-1",children:e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),e(ge,{to:"/",class:"button plain",children:e(I,{icon:"home",size:"l",alt:n({id:"i0qMbr"})})})]}),e("h1",{children:e(f,{id:"Xi1/bw"})}),e("div",{class:"header-side"})]})}),e("main",{children:r.length>0?e(U,{children:[e("ul",{class:"link-list",children:r.map(l=>e("li",{children:e(ge,{to:s?`/${s}/t/${l.name}`:`/t/${l.name}`,children:[e(I,{icon:"hashtag",alt:"#"})," ",e("span",{children:l.name})]})}))}),r.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:e(f,{id:"2S/uvJ",values:{0:r.length}})})})]}):o==="loading"?e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}):o==="error"?e("p",{class:"ui-state",children:e(f,{id:"2AeREO"})}):e("p",{class:"ui-state",children:e(f,{id:"vKsGhk"})})})]})})}const ml=20;function Ri({title:n,path:i,id:s,...o}){const{_:c}=le();tt(n||c({id:"following.title"}),i||"/following");const{masto:r,streaming:u,instance:l}=re(),d=We(x),a=j(),h=j(),p=j();__BENCHMARK.end("time-to-following");const m=Je("@pixelfed/home-include-reblogs");async function g(y){var S;(y||!h.current)&&(__BENCHMARK.start("fetch-home-first"),a.current=r.v1.timelines.home.list({limit:ml}),h.current=a.current.values()),m&&((S=a.current)!=null&&S.params)&&(typeof a.current.params=="string"?a.current.params+="&include_reblogs=true":a.current.params.include_reblogs=!0);const w=await h.current.next();let{value:b}=w;if(b!=null&&b.length){let _=!1;y&&(b[0].id!==p.current&&(_=!0),p.current=b[0].id),b.forEach(T=>{et(T,l)}),b=ts(b,l),y&&_&&Ar(),eo(b,l),b.sort((T,A)=>{const k=new Date(T.createdAt);return new Date(A.createdAt)-k})}return __BENCHMARK.end("fetch-home-first"),{...w,value:b}}async function v(){var y;try{const w={limit:5,since_id:p.current};Je("@pixelfed/home-include-reblogs")&&(w.include_reblogs=!0);const b=await r.v1.timelines.home.list(w).values().next();let{value:S}=b;const _=((y=S[0])==null?void 0:y.id)===p.current;return!!(S!=null&&S.length&&!_&&(p.current=S[0].id,S=ts(S,l),S=zt(S,"home"),S.some(T=>!T.reblog)))}catch{return!1}}return Q(()=>{let y;return(async()=>{if(u){y=u.user.subscribe();for await(const w of y){if(!y)break;if(w.event==="status.update"){const b=w.payload;et(b,l)}else if(w.event==="delete"){const b=w.payload,S=_s(b,l);S&&(S._deleted=!0)}}}})(),()=>{var w;(w=y==null?void 0:y.unsubscribe)==null||w.call(y),y=null}},[u]),e(At,{title:n||c({id:"following.title"}),id:s||"following",emptyText:c({id:"nJEKbY"}),errorText:c({id:"7QSeK6"}),instance:l,fetchItems:g,checkForUpdates:v,useItemID:!0,boostsCarousel:d.settings.boostsCarousel,...o,filterContext:"home",showFollowedTags:!0,showReplyParent:!0})}const gl=20,yl=4,cs=yl+1;function so({media:n,columnMode:i,...s}){const{_:o}=le();let{hashtag:c,...r}=i?{}:Mt();s.hashtag&&(c=s.hashtag);let u=c.trim().split(/[\s+]+/);u.sort(),c=u[0];const[l,d]=vt(),a=n||!!l.get("media"),h=a?"?media=1":"",{masto:p,instance:m,authenticated:g}=re({instance:(s==null?void 0:s.instance)||r.instance}),{masto:v,instance:y,authenticated:w}=re(),b=u.map($=>`#${$}`).join(" "),S=o(m?a?{id:"kH0rA0",values:{hashtagTitle:b,instance:m}}:{id:"IK0zKi",values:{hashtagTitle:b,instance:m}}:a?{id:"hHSI3w",values:{hashtagTitle:b}}:{id:"+ZzjRY",values:{hashtagTitle:b}});tt(S,"/:instance?/t/:hashtag");const _=j(),T=Ae(()=>ui(),[]),A=j(void 0);async function k($){const K=await p.v1.timelines.tag.$select(c).list({limit:gl,any:u.slice(1),maxId:$?void 0:A.current,onlyMedia:a?!0:void 0}).values().next();let{value:Y}=K;return Y!=null&&Y.length&&($&&(_.current=Y[0].id),Y.forEach(te=>{et(te,m,{skipThreading:a||T})}),A.current=Y[Y.length-1].id),{...K,value:Y}}async function C(){var $;try{const K=await p.v1.timelines.tag.$select(c).list({limit:1,any:u.slice(1),since_id:_.current,onlyMedia:a}).values().next();let{value:Y}=K;const te=(($=Y[0])==null?void 0:$.id)===_.current;return Y!=null&&Y.length&&!te?(Y=zt(Y,"public"),!0):!1}catch{return!1}}const[E,R]=M("default"),[F,D]=M();Q(()=>{(async()=>{try{const $=await p.v1.tags.$select(c).fetch();D($)}catch{}})()},[c]);const W=u.length>=cs,[G,X]=M("default"),[q,Z]=M([]),[B,ee]=M(!1);return Q(()=>{g&&(async()=>{try{const $=await p.v1.featuredTags.list();Z($),ee($.some(K=>K.name.toLowerCase()===c.toLowerCase()))}catch{}})()},[]),e(U,{children:[e(At,{title:S,titleComponent:!!m&&e("h1",{class:"header-double-lines",children:[e("b",{dir:"auto",children:b}),e("div",{children:m})]}),id:"hashtag",instance:m,emptyText:o({id:"CNSLAW"}),errorText:o({id:"yjj6Ll"}),fetchItems:k,checkForUpdates:C,useItemID:!0,view:a||T?"media":void 0,refresh:a,filterContext:"public",headerEnd:e(dt,{portal:!0,setDownOverflow:!0,overflow:"auto",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(I,{icon:"more",size:"l",alt:o({id:"2FYpfJ"})})}),children:[!!F&&u.length===1&&e(U,{children:[e(pt,{subMenu:!0,confirm:F.following,confirmLabel:o({id:"ctJi7k",values:{hashtag:c}}),disabled:E==="loading"||!g,onClick:()=>{R("loading"),F.following?p.v1.tags.$select(c).unfollow().then(()=>{D({...F,following:!1}),fe(o({id:"doK/ij",values:{hashtag:c}}))}).catch($=>{alert($)}).finally(()=>{R("default")}):p.v1.tags.$select(c).follow().then(()=>{D({...F,following:!0}),fe(o({id:"R9+aEN",values:{hashtag:c}}))}).catch($=>{alert($)}).finally(()=>{R("default")})},children:F.following?e(U,{children:[e(I,{icon:"check-circle"})," ",e("span",{children:e(f,{id:"HOSk7R"})})]}):e(U,{children:[e(I,{icon:"plus"})," ",e("span",{children:e(f,{id:"MKEPCY"})})]})}),e(ye,{type:"checkbox",checked:B,disabled:G==="loading"||!g,onClick:()=>{if(X("loading"),B){const $=q.find(K=>K.name.toLowerCase()===c.toLowerCase()).id;$?p.v1.featuredTags.$select($).remove().then(()=>{ee(!1),fe(o({id:"VH+Tf9"})),Z(q.filter(K=>K.id!==$))}).catch(K=>{}).finally(()=>{X("default")}):fe(o({id:"3OLv47"}))}else p.v1.featuredTags.create({name:c}).then($=>{ee(!0),fe(o({id:"9ra4hn"})),Z(q.concat($))}).catch($=>{}).finally(()=>{X("default")})},children:B?e(U,{children:[e(I,{icon:"check-circle"}),e("span",{children:e(f,{id:"9ra4hn"})})]}):e(U,{children:[e(I,{icon:"check-circle"}),e("span",{children:e(f,{id:"UlJ3QN"})})]})}),e(Ve,{})]}),!T&&e(U,{children:[e(gi,{className:"plain",children:e(f,{id:"cSev+j"})}),e(ye,{type:"checkbox",checked:!!a,onClick:()=>{a?l.delete("media"):l.set("media","1"),d(l)},children:[e(I,{icon:"check-circle",alt:"☑️"})," ",e("span",{class:"menu-grow",children:e(f,{id:"eK4SL/"})})]}),e(Ve,{})]}),e(ic,{className:"menu-field",disabled:W,children:({ref:$})=>e("form",{onSubmit:K=>{var te,J;K.preventDefault();const Y=(J=(te=K.target[0].value)==null?void 0:te.trim)==null?void 0:J.call(te);Y&&!u.some(ue=>ue.toLowerCase()===Y.toLowerCase())&&(u.push(Y),u.sort(),location.hash=m?`/${m}/t/${u.join("+")}${h}`:`/t/${u.join("+")}${h}`)},children:[e(I,{icon:"hashtag"}),e("input",{ref:$,type:"text",placeholder:W?pe._({id:"ouWc/D",values:{TOTAL_TAGS_LIMIT:cs}}):o({id:"cxL5F9"}),required:!0,autocorrect:"off",autocapitalize:"off",spellCheck:!1,pattern:"[^#][^\\s#]+[^#]",disabled:W,dir:"auto"})]})}),e(sc,{takeOverflow:!0,children:u.map(($,K)=>e(ye,{disabled:u.length===1,onClick:Y=>{u.splice(K,1),u.sort(),location.hash=m?`/${m}/t/${u.join("+")}${h}`:`/t/${u.join("+")}${h}`},children:[e(I,{icon:"x",alt:o({id:"OISAkj"}),class:"danger-icon"}),e("span",{class:"bidi-isolate",children:[e("span",{class:"more-insignificant",children:"#"}),$]})]},$))}),e(Ve,{}),e(ye,{disabled:!w,onClick:()=>{if(x.shortcuts.length>=It){alert(pe._({id:"XN1xAY",values:{SHORTCUTS_LIMIT:It}}));return}const $={type:"hashtag",hashtag:u.join(" "),instance:m,media:a?"on":void 0};x.shortcuts.some(Y=>Y.type===$.type&&Y.hashtag.split(/[\s+]+/).sort().join(" ")===$.hashtag.split(/[\s+]+/).sort().join(" ")&&(Y.instance?Y.instance===$.instance:!0)&&(Y.media?!!Y.media==!!$.media:!0))?alert(o({id:"kfeQnS"})):(x.shortcuts.push($),fe(o({id:"MIhb91"})))},children:[e(I,{icon:"shortcut"})," ",e("span",{children:e(f,{id:"i02Lq/"})})]}),e(ye,{onClick:()=>{let $=prompt(o({id:"2MQ2cd"}));if(!/\./.test($)){$&&alert(o({id:"7WddtO"}));return}$&&($=$.toLowerCase().trim(),location.hash=`/${$}/t/${u.join("+")}${h}`)},children:[e(I,{icon:"bus"})," ",e("span",{children:e(f,{id:"Sq04Yc"})})]}),y!==m&&e(ye,{onClick:()=>{location.hash=`/${y}/t/${u.join("+")}${h}`},children:[e(I,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:e(f,{id:"iAzCp4",values:{currentInstance:y},components:{0:e("b",{})}})})]})]})},m+b),!i&&!!(u!=null&&u.length)&&e("data",{class:"compose-data",value:JSON.stringify({draftStatus:{status:`${u.length>1?`
+
+`:" "}${b}`}})})]})}const bl=20;function oo(n){var S;const{_:i}=le(),s=We(x),{masto:o,instance:c}=re(),r=(n==null?void 0:n.id)||((S=Mt())==null?void 0:S.id),u=j(),l=j();async function d(_){(_||!l.current)&&(l.current=o.v1.timelines.list.$select(r).list({limit:bl}).values());const T=await l.current.next();let{value:A}=T;return A!=null&&A.length&&(_&&(u.current=A[0].id),A.forEach(k=>{et(k,c)})),{...T,value:A}}async function a(){var _;try{const T=await o.v1.timelines.list.$select(r).list({limit:1,since_id:u.current});let{value:A}=T;const k=((_=A[0])==null?void 0:_.id)===u.current;return A!=null&&A.length&&!k?(A=zt(A,"home"),!0):!1}catch{return!1}}const[h,p]=M([]),[m,g]=M({title:"List"});tt(m.title,"/l/:id"),Q(()=>{(async()=>{try{const _=await js(r);g(_)}catch{}})()},[r]);const[v,y]=M(!1),[w,b]=M(!1);return e(U,{children:[e(At,{title:m.title,id:"list",emptyText:i({id:"KkDhfU"}),errorText:i({id:"7QSeK6"}),instance:c,fetchItems:d,checkForUpdates:a,useItemID:!0,boostsCarousel:s.settings.boostsCarousel,filterContext:"home",showReplyParent:!0,headerStart:e(dt,{overflow:"auto",menuButton:e("button",{type:"button",class:"plain",children:[e(I,{icon:"list",size:"l",alt:i({id:"h16FyT"})}),e(I,{icon:"chevron-down",size:"s"})]}),onMenuChange:_=>{_.open&&hn().then(p)},children:[e(je,{to:"/l",children:e("span",{children:e(f,{id:"BHWx+g"})})}),(h==null?void 0:h.length)>0&&e(U,{children:[e(Ve,{}),h.map(_=>e(je,{to:`/l/${_.id}`,children:e("span",{children:[_.title,_.exclusive&&e(U,{children:[" ",e(Bt,{})]})]})},_.id))]})]}),headerEnd:e(dt,{portal:!0,setDownOverflow:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(I,{icon:"more",size:"l",alt:i({id:"2FYpfJ"})})}),children:[(m==null?void 0:m.exclusive)&&e(U,{children:[e(gi,{className:"plain",children:[e(Bt,{})," ",e(f,{id:"FNptcJ"})]}),e(Ve,{})]}),e(ye,{onClick:()=>y({list:m}),children:[e(I,{icon:"pencil",size:"l"}),e("span",{children:e(f,{id:"ePK91l"})})]}),e(ye,{onClick:()=>b(!0),children:[e(I,{icon:"group",size:"l"}),e("span",{children:e(f,{id:"hB02vO"})})]})]})},r),v&&e(Ye,{onClick:_=>{_.target===_.currentTarget&&y(!1)},children:e(Ti,{list:v==null?void 0:v.list,onClose:_=>{_.state==="success"&&_.list?g(_.list):_.state==="deleted"&&(location.hash="/l"),y(!1)}})}),w&&e(Ye,{onClick:_=>{_.target===_.currentTarget&&b(!1)},children:e(wl,{listID:r,onClose:()=>b(!1)})})]})}const vl=40;function wl({listID:n,onClose:i}){const{_:s}=le(),{masto:o,instance:c}=re(),[r,u]=M([]),[l,d]=M("default"),[a,h]=M(!1),p=j();async function m(g){h(!1),d("loading"),(async()=>{try{(g||!p.current)&&(p.current=o.v1.lists.$select(n).accounts.list({limit:vl}).values());const v=await p.current.next();let{done:y,value:w}=v;w!=null&&w.length?(u(g?w:r.concat(w)),h(!y)):h(!1),d("default")}catch{d("error")}})()}return Q(()=>{m(!0)},[]),e("div",{class:"sheet",id:"list-manage-members-container",children:[!!i&&e("button",{type:"button",class:"sheet-close",onClick:i,children:e(I,{icon:"x",alt:s({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:e(f,{id:"hB02vO"})})}),e("main",{children:e("ul",{children:[r.map(g=>e("li",{children:[e(ft,{account:g,instance:c}),e(kl,{account:g,listID:n})]},g.id)),a&&l==="default"&&e(Tt,{as:"li",onChange:g=>g&&m(),children:e("button",{type:"button",class:"light block",onClick:m,children:e(f,{id:"uXRAkV"})})})]})})]})}function kl({account:n,listID:i}){const{_:s}=le(),{masto:o}=re(),[c,r]=M("default"),[u,l]=M(!1);return e(pt,{confirm:!u,confirmLabel:e("span",{children:e(f,{id:"j5n9Ry",values:{0:n.username},components:{0:e("span",{class:"bidi-isolate"})}})}),align:"end",menuItemClassName:"danger",onClick:()=>{u?(r("loading"),(async()=>{try{await o.v1.lists.$select(i).accounts.create({accountIds:[n.id]}),r("default"),l(!1)}catch{r("error")}})()):(r("loading"),(async()=>{try{await o.v1.lists.$select(i).accounts.remove({accountIds:[n.id]}),r("default"),l(!0)}catch{r("error")}})())},children:e("button",{type:"button",class:`light ${u?"":"danger"}`,disabled:c==="loading",children:s(u?{id:"m16xKo"}:{id:"MWIaew"})})})}const Sl={mention:["account","status"],status:["account","status"],reblog:["account","status"],follow:["account"],follow_request:["account"],favourite:["account","status"],poll:["status"],update:["status"]},_l=["favourite","reblog","follow"],co=n=>_l.includes(n);function ao(n){return n.filter(i=>{const{type:s,id:o,createdAt:c}=i;if(!s)return!1;const r=Sl[s];return r!=null&&r.length?r.every(u=>!!i[u]):!0})}function ro(n){if(n!=null&&n.notificationGroups){const{accounts:i=[],notificationGroups:s=[],statuses:o=[]}=n;return s.map(c=>{const{sampleAccountIds:r,statusId:u}=c,l=(r==null?void 0:r.map(a=>i.find(h=>h.id===a)))||[],d=(o==null?void 0:o.find(a=>a.id===u))||null;return{...c,sampleAccounts:l,status:d}})}return n}function Cl(n){const i=n.map(u=>{const{latestPageNotificationAt:l,mostRecentNotificationId:d,sampleAccounts:a,notificationsCount:h}=u;return{id:""+d,createdAt:l,account:a[0],...u}}),s={},o=[];for(let u=0;u0&&(m==null?void 0:m.length)>0&&p>(m==null?void 0:m.length))&&(d==="favourite"||d==="reblog")&&(y="favourite+reblog");const b=`${a==null?void 0:a.id}-${y}-${v}`,S=s[b];if(!co(d))o.push(l);else if(S)m.forEach(_=>{const T=S.sampleAccounts.find(A=>A.id===_.id);T?(T._types.push(d),T._types.sort().reverse()):S.sampleAccounts.push({..._,_types:[d]})}),S.notificationsCount=Math.min(S.notificationsCount,p),S._notificationsCount.push(p),S._sampleAccountsCount.push(m==null?void 0:m.length),S._accounts=S.sampleAccounts,S._groupKeys.push(g);else{const _=m.map(T=>({...T,_types:[d]}));s[b]={...l,sampleAccounts:_,type:y,_accounts:_,_groupKeys:g?[g]:[],_notificationsCount:[p],_sampleAccountsCount:[m==null?void 0:m.length]},o.push(s[b])}}const c={},r=[];for(let u=0;uS.id===h.id);b?(b._types.push(p),b._types.sort().reverse(),w._ids+=`-${d}`):(h._types=[p],w._accounts.push(h),w._ids+=`-${d}`)}else{h&&(h._types=[p]);let b=i[y]={...l,type:v,_ids:d,_accounts:h?[h]:[]};s[u++]=b}}const o={},c=[];for(let r=0,u=0;r{et(A,c)})),{..._,value:T==null?void 0:T.map(A=>A.status)}}const m=j(),g=j();async function v(S){(S||!m.current)&&(m.current=o.v1.conversations.list({limit:as}).values());const _=await m.current.next();let{value:T}=_;return T=T==null?void 0:T.filter(A=>A.lastStatus),T!=null&&T.length&&(S&&(g.current=T[0].lastStatus.id),T.forEach(({lastStatus:A})=>{et(A,c)})),{..._,value:T==null?void 0:T.map(A=>A.lastStatus)}}function y(...S){return d==="private"?v(...S):p(...S)}async function w(){var S;if(d==="private")try{const _=await o.v1.conversations.list({limit:1,since_id:g.current}).values().next();let{value:T}=_;const A=((S=T[0])==null?void 0:S.id)===g.current;return T!=null&&T.length&&!A?(g.current=T[0].lastStatus.id,!0):!1}catch{return!1}else try{const _=await o.v1.notifications.list({limit:1,types:["mention"],since_id:h.current}).values().next();let{value:T}=_;return T!=null&&T.length?(h.current=T[0].id,!0):!1}catch{return!1}}const b=Ae(()=>e("div",{class:"filter-bar centered",children:[e(ge,{to:"/mentions",class:d?"":"is-active",onClick:S=>{n&&(S.preventDefault(),l(null))},children:e(f,{id:"N40H+G"})}),e(ge,{to:"/mentions?type=private",class:d==="private"?"is-active":"",onClick:S=>{n&&(S.preventDefault(),l("private"))},children:e(f,{id:"zwBp5t"})})]}),[d]);return e(At,{title:s({id:"/bZzdR"}),id:"mentions",emptyText:s({id:"03jFGT"}),errorText:s({id:"pqR9KF"}),instance:c,fetchItems:y,checkForUpdates:w,useItemID:!0,timelineStart:b,refresh:d,filterContext:"notifications"})}const Al=80,xl=20,El=new URLSearchParams,pn={block:"center",inline:"center",behavior:"smooth"},uo=Ss(()=>Je("@mastodon/grouped-notifications"),{maxAge:1e3*60*5});function ho(n={}){const{masto:i}=re();return x.settings.groupedNotificationsAlpha&&uo()?i.v2.notifications.list({limit:xl,...n}):i.v1.notifications.list({limit:Al,...n})}function fo(n={}){return ho(n).values()}function po(n){return x.settings.groupedNotificationsAlpha&&uo()?Cl(n):Il(n)}const Rl=["forNotFollowing","forNotFollowers","forNewAccounts","forPrivateMentions","forLimitedAccounts"],Ll={forNotFollowing:{id:"d+hDoa"},forNotFollowers:{id:"oAwuQj"},forNewAccounts:{id:"Srs8u7"},forPrivateMentions:{id:"IDC5Uw"},forLimitedAccounts:{id:"XMGM2e"}};function Ml({columnMode:n}){var Le;const{_:i,_:s}=le();tt(s({id:"iDNBZe"}),"/notifications");const{masto:o,instance:c}=re(),r=We(x),[u,l]=M("default"),[d]=n?[El]:vt(),a=d.get("id"),h=d.get("access_token"),[p,m]=M(!1),[g,v]=M(!1),y=j(),{nearReachEnd:w,scrollDirection:b,reachStart:S,nearReachStart:_}=xr({scrollableRef:y}),T=b==="end"&&!_,[A,k]=M([]),[C,E]=M([]),R=j(),F=j();async function D(P){var Ne;if((P||!F.current)&&(R.current=ho({excludeTypes:["follow_request"]}),F.current=R.current.values()),/max_id=($|&)/i.test((Ne=F.current)==null?void 0:Ne.nextParams))return{done:!0};const ce=await F.current.next(),Se=ro(ce.value);if(Se!=null&&Se.length){Se.forEach(L=>{et(L.status,c,{skipThreading:!0})});const Oe=po(Se);P?(x.notificationsLast=Oe[0],x.notifications=Oe,o.v1.markers.create({notifications:{lastReadId:Oe[0].id}}).catch(()=>{})):x.notifications.push(...Oe)}return x.notificationsShowNew=!1,x.notificationsLastFetchTime=Date.now(),ce}async function W(){try{return await o.v1.followRequests.list({limit:80})}catch{return[]}}const G=()=>{l("loading"),(async()=>{try{const P=await W();k(P),l("default")}catch{l("error")}})()};async function X(){try{return await o.v1.announcements.list()}catch{return[]}}const q=Je("@mastodon/filtered-notifications"),[Z,B]=M(!1),[ee,$]=M({});function K(){return o.v2.notifications.policy.fetch().catch(()=>{})}function Y(){K().then(P=>{$(P)}).catch(()=>{})}const[te,J]=M(null);function ue(){return o.v1.notifications.requests.list()}const he=P=>{we(!1),l("loading"),(async()=>{try{const ce=D(P);P&&(X().then(Ne=>{Ne.sort((Oe,L)=>{const V=new Date(Oe.updatedAt||Oe.createdAt);return new Date(L.updatedAt||L.createdAt)-V}),E(Ne)}).catch(()=>{}),W().then(Ne=>{k(Ne)}).catch(()=>{}),q&&Y());const{done:Se}=await ce;m(!Se),l("default")}catch{l("error")}})()};Q(()=>{he(!0)},[]),Q(()=>{S&&he(!0)},[S]);const[ne,we]=M(!1),Ce=it(({disableIdleCheck:P=!1}={})=>{var ce;u!=="loading"&&r.settings.autoRefresh&&((ce=y.current)==null?void 0:ce.scrollTop)<16&&(P||window.__IDLE__)&&!$l()&&he(!0)},[r.notificationsShowNew,r.settings.autoRefresh,u]),se=j();Gt(P=>{if(P){const ce=Date.now()-se.current;!se.current||ce>1e3*3?Ce({disableIdleCheck:!0}):se.current=Date.now()}});const Te=j(!0);Q(()=>{let P=No(x,"notificationsShowNew",ce=>{if(Te.current){Te.current=!1;return}u!=="loading"&&(ce&&Ce(),we(ce))});return()=>P==null?void 0:P()},[]);const Ie=new Date,Pe=new Date(Ie-24*60*60*1e3);let $e=new Date;const Ee=!r.notifications.some(P=>new Date(P.createdAt).toDateString()===Ie.toDateString()),H=j();Q(()=>{a&&(x.routeNotification={id:a,accessToken:atob(h)})},[a,h]);const[ke,De]=M(null);Q(async()=>{var Ne,Oe,L;const P=new Date;if(P.getMonth()!==11||!Je("@mastodon/annual-report"))return;let ce=Ue.account.get("annualReportNotification");if(ce){De(ce);return}const Se=fo({types:["annual_report"]});try{const V=await Se.next();ce=(Oe=(Ne=V==null?void 0:V.value)==null?void 0:Ne.notificationGroups)==null?void 0:Oe[0],((L=ce==null?void 0:ce.annualReport)==null?void 0:L.year)==P.getFullYear()&&(De(ce),Ue.account.set("annualReportNotification",ce))}catch{}},[]);const xe=".notification",Me=qe("j",()=>{const P=document.activeElement.closest(xe),ce=P==null?void 0:P.getBoundingClientRect(),Se=Array.from(y.current.querySelectorAll(xe));if(P&&ce.top0){const Ne=Se.indexOf(P);let Oe=Se[Ne+1];Oe&&(Oe.focus(),Oe.scrollIntoView(pn))}else{const Ne=Se.find(Oe=>{const L=Oe.getBoundingClientRect();return L.top>=44&&L.left>=0});Ne&&(Ne.focus(),Ne.scrollIntoView(pn))}},{useKey:!0,ignoreEventWhen:P=>P.metaKey||P.ctrlKey||P.altKey||P.shiftKey}),me=qe("k",()=>{const P=document.activeElement.closest(xe),ce=P==null?void 0:P.getBoundingClientRect(),Se=Array.from(y.current.querySelectorAll(xe));if(P&&ce.top0){const Ne=Se.indexOf(P);let Oe=Se[Ne-1];Oe&&(Oe.focus(),Oe.scrollIntoView(pn))}else{const Ne=Se.find(Oe=>{const L=Oe.getBoundingClientRect();return L.top>=44&&L.left>=0});Ne&&(Ne.focus(),Ne.scrollIntoView(pn))}},{useKey:!0,ignoreEventWhen:P=>P.metaKey||P.ctrlKey||P.altKey||P.shiftKey}),N=qe(["enter","o"],()=>{const P=document.activeElement.closest(xe),ce=P==null?void 0:P.querySelector(".status-link");ce&&ce.click()},{useKey:!0,ignoreEventWhen:P=>P.metaKey||P.ctrlKey||P.altKey||P.shiftKey}),O=new Date,oe=Ae(()=>ct(O,{forceOpts:{weekday:"long"}}),[O]);return e("div",{id:"notifications-page",class:"deck-container",ref:P=>{y.current=P,Me.current=P,me.current=P,N.current=P},tabIndex:"-1",children:[e("div",{class:`timeline-deck deck ${g?"only-mentions":""}`,children:[e("header",{hidden:T,onClick:P=>{var ce;P.target.closest("a, button")||(ce=y.current)==null||ce.scrollTo({top:0,behavior:"smooth"})},onDblClick:P=>{P.target.closest("a, button")||he(!0)},class:u==="loading"?"loading":"",children:[e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),e(ge,{to:"/",class:"button plain",children:e(I,{icon:"home",size:"l",alt:s({id:"i0qMbr"})})})]}),e("h1",{children:e(f,{id:"iDNBZe"})}),e("div",{class:"header-side",children:q&&e("button",{type:"button",class:"button plain4",onClick:()=>{B(!0)},children:e(I,{icon:"settings",size:"l",alt:s({id:"a/+arl"})})})})]}),ne&&u!=="loading"&&e("button",{class:"updates-button shiny-pill",type:"button",onClick:()=>{var P;he(!0),(P=y.current)==null||P.scrollTo({top:0,behavior:"smooth"})},children:[e(I,{icon:"arrow-up"})," ",e(f,{id:"Jy9RU/"})]})]}),C.length>0&&e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:e("details",{class:"announcements",children:[e("summary",{children:[e("span",{children:[e(I,{icon:"announce",class:"announcement-icon",size:"l"})," ",e(f,{id:"0whvLM",values:{0:C.length}})," ",e("small",{class:"insignificant",children:c})]}),C.length>1&&e("span",{class:"announcements-nav-buttons",children:C.map((P,ce)=>e("button",{type:"button",class:"plain2 small",onClick:()=>{var Se;(Se=H.current)==null||Se.children[ce].scrollIntoView({behavior:"smooth",block:"nearest"})},children:ce+1}))})]}),e("ul",{class:`announcements-list-${C.length>1?"multiple":"single"}`,ref:H,children:C.map(P=>e("li",{children:e(Nl,{announcement:P})}))})]})})}),A.length>0&&e("div",{class:"follow-requests",children:[e("h2",{class:"timeline-header",children:e(f,{id:"6Fs1Ba"})}),A.length>5?e("details",{children:[e("summary",{children:e(f,{id:"7dHKu4",values:{0:A.length}})}),e("ul",{children:A.map(P=>e("li",{children:[e(ft,{account:P}),e(si,{accountID:P.id,onChange:()=>{}})]},P.id))})]}):e("ul",{children:A.map(P=>e("li",{children:[e(ft,{account:P}),e(si,{accountID:P.id,onChange:()=>{}})]},P.id))})]}),q&&((Le=ee==null?void 0:ee.summary)==null?void 0:Le.pendingRequestsCount)>0&&e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:e("div",{class:"filtered-notifications",children:e("details",{onToggle:async P=>{const{open:ce}=P.target;if(ce){const Se=await ue();J(Se)}},children:[e("summary",{children:e(f,{id:"N3Bq0f",values:{0:ee.summary.pendingRequestsCount}})}),te?(te==null?void 0:te.length)>0&&e("ul",{children:te.map(P=>{var ce,Se;return e("li",{children:[e("div",{class:"request-notifcations",children:[!((ce=P.lastStatus)!=null&&ce.id)&&e(ft,{useAvatarStatic:!0,showStats:!0,account:P.account}),((Se=P.lastStatus)==null?void 0:Se.id)&&e("div",{class:"last-post",children:e(ge,{class:"status-link",to:`/${c}/s/${P.lastStatus.id}`,children:e(Ge,{status:P.lastStatus,size:"s",readOnly:!0})})}),e(Dl,{request:P})]}),e(Ol,{request:P,onChange:()=>{he(!0)}})]},P.id)})}):e("p",{class:"ui-state",children:e(Be,{abrupt:!0})})]})})})}),ke&&e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:e(ln,{notification:ke})})}),e("div",{id:"mentions-option",children:e("label",{children:[e("input",{type:"checkbox",checked:g,onChange:P=>{v(P.target.checked)}})," ",e(f,{id:"0udtPI"})]})}),e("h2",{class:"timeline-header",children:[e(f,{id:"ecUA8p"})," ",e("small",{class:"insignificant bidi-isolate",children:oe})]}),Ee&&e("p",{class:"ui-state insignificant",children:u==="default"?s({id:"KS7iJH"}):e(U,{children:"…"})}),r.notifications.length?e(Dn.Provider,{value:"notifications",children:r.notifications.filter(P=>P.type!=="follow_request").map(P=>{if(g&&P.type!=="mention")return null;const ce=new Date(P.createdAt),Se=ce.toDateString()!==$e.toDateString();Se&&($e=ce);const Ne=ce.toDateString()===Pe.toDateString()?s({id:"y/0uwd"}):ct($e,{hideTime:!0}),Oe=ct($e,{forceOpts:{weekday:"long"}});return e(U,{children:[Se&&e("h2",{class:"timeline-header",children:[e("span",{children:Ne})," ",e("small",{class:"insignificant bidi-isolate",children:Oe})]}),e(ln,{instance:c,notification:P},P._ids||P.id)]},P._ids||P.id)})}):e(U,{children:[u==="loading"&&e(U,{children:e("ul",{class:"timeline flat",children:Array.from({length:5}).map((P,ce)=>e("li",{class:"notification skeleton",children:[e("div",{class:"notification-type",children:e(I,{icon:"notification",size:"xl"})}),e("div",{class:"notification-content",children:e("p",{children:"███████████ ████"})})]}))})}),u==="error"&&e("p",{class:"ui-state",children:[e(f,{id:"gjzl8E"}),e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>he(!0),children:e(f,{id:"KDw4GX"})})]})]}),p&&e(Tt,{onChange:P=>{P&&he()},children:e("button",{type:"button",class:"plain block",disabled:u==="loading",onClick:()=>he(),style:{marginBlockEnd:"6em"},children:u==="loading"?e(Be,{abrupt:!0}):e(f,{id:"uXRAkV"})})})]}),q&&Z&&e(Ye,{onClick:P=>{P.target===P.currentTarget&&B(!1)},children:e("div",{class:"sheet",id:"notifications-settings",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:()=>B(!1),children:e(I,{icon:"x",alt:s({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:e(f,{id:"a/+arl"})})}),e("main",{children:e("form",{onSubmit:P=>{P.preventDefault();const{forNotFollowing:ce,forNotFollowers:Se,forNewAccounts:Ne,forPrivateMentions:Oe,forLimitedAccounts:L}=P.target,V={...ee,forNotFollowing:ce.value,forNotFollowers:Se.value,forNewAccounts:Ne.value,forPrivateMentions:Oe.value,forLimitedAccounts:L.value};$(V),B(!1),(async()=>{try{await o.v2.notifications.policy.update(V),fe(s({id:"4+7X9i"}))}catch{}})()},children:[e("p",{children:e(f,{id:"WrkPTf"})}),e("div",{class:"notification-policy-fields",children:Rl.map(P=>{const ce=ee[P];return e("div",{children:e("label",{children:[i(Ll[P]),e("select",{name:P,defaultValue:ce,class:"small",children:[e("option",{value:"accept",children:e(f,{id:"g3UF2V"})}),e("option",{value:"filter",children:e(f,{id:"o7J4JM"})}),e("option",{value:"drop",children:e(f,{id:"gbbkE7"})})]})]})},P)})}),e("p",{children:e("button",{type:"submit",children:e(f,{id:"tfDRzk"})})})]})})]})})]})}function $l(){return!!document.querySelector(".deck-backdrop, #modal-container > *")}function Nl({announcement:n}){const{instance:i}=re(),{contact:s}=vs(),o=s==null?void 0:s.account,{id:c,content:r,startsAt:u,endsAt:l,published:d,allDay:a,publishedAt:h,updatedAt:p,read:m,mentions:g,statuses:v,tags:y,emojis:w,reactions:b}=n,S=new Date(h),_=ct(S),T=new Date(p),A=ct(T);return e("div",{class:"announcement-block",children:[e(ft,{account:o}),e("div",{class:"announcement-content",onClick:Es({mentions:g,instance:i}),dangerouslySetInnerHTML:{__html:Qn(r,{emojis:w})}}),e("p",{class:"insignificant",children:[e("time",{datetime:S.toISOString(),children:ct(S)}),p&&A!==_&&e(U,{children:[" ","•"," ",e("span",{class:"ib",children:e(f,{id:"TbFrLc",values:{0:ct(T)},components:{0:e("time",{datetime:T.toISOString()})}})})]})]}),e("div",{class:"announcement-reactions",hidden:!0,children:b.map(k=>{const{name:C,count:E,me:R,staticUrl:F,url:D}=k;return e("button",{type:"button",class:`plain4 small ${R?"reacted":""}`,children:[D||F?e("img",{src:D||F,alt:C,width:"16",height:"16"}):e("span",{children:C})," ",e("span",{class:"count",children:Qe(E)})]})})})]})}function Pl(n){const{masto:i}=re();return i.v1.notifications.list({accountID:n})}function Dl({request:n}){var p;const{instance:i}=re(),[s,o]=M("loading"),{account:c,lastStatus:r}=n,[u,l]=M(!1),[d,a]=M([]);function h(){l(!1)}return Q(()=>{var m;(m=n==null?void 0:n.account)!=null&&m.id&&u&&(o("loading"),(async()=>{const g=await Pl(n.account.id);a(g||[]),o("default")})())},[u,(p=n==null?void 0:n.account)==null?void 0:p.id]),e(U,{children:[e("button",{type:"button",class:"plain4 request-notifications-account",onClick:()=>{l(!0)},children:[e(I,{icon:"notification",class:"more-insignificant"})," ",e("small",{children:e(f,{id:"H0wUNM",values:{0:c.username},components:{0:e("span",{class:"bidi-isolate"})}})})," ",e(I,{icon:"chevron-down"})]}),u&&e(Ye,{onClick:m=>{m.target===m.currentTarget&&h()},children:e("div",{class:"sheet",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:h,children:e(I,{icon:"x",alt:t`Close`})}),e("header",{children:e("b",{children:e(f,{id:"MXOmPt",values:{0:c.username},components:{0:e("span",{class:"bidi-isolate"})}})})}),e("main",{children:s==="loading"?e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}):d.map(m=>e("div",{class:"notification-peek",onClick:g=>{const{target:v}=g;(g.target.tagName==="BUTTON"||g.target.tagName==="A")&&h()},children:e(ln,{instance:i,notification:m,isStatic:!0})}))})]})})]})}function Ol({request:n,onChange:i}){const{_:s}=le(),{masto:o}=re(),[c,r]=M("default"),[u,l]=M(null),d=u!==null;return e("p",{class:"notification-request-buttons",children:[e("button",{type:"button",disabled:c==="loading"||d,onClick:()=>{r("loading"),(async()=>{try{await o.v1.notifications.requests.$select(n.id).accept(),l("accept"),r("default"),i({request:n,state:"accept"}),fe(s({id:"ZtBMwU",values:{0:n.account.username}}))}catch{r("error"),fe(s({id:"S92JKG"}))}})()},children:e(f,{id:"h7peZQ"})})," ",e("button",{type:"button",disabled:c==="loading"||d,class:"light danger",onClick:()=>{r("loading"),(async()=>{try{await o.v1.notifications.requests.$select(n.id).dismiss(),l("dismiss"),r("default"),i({request:n,state:"dismiss"}),fe(s({id:"ibBDry",values:{0:n.account.username}}))}catch{r("error"),fe(s({id:"S5aemF"}))}})()},children:e(f,{id:"1QfxQT"})}),e("span",{class:"notification-request-states",children:c==="loading"?e(Be,{abrupt:!0}):u==="accept"?e(I,{icon:"check-circle",alt:s({id:"bzMKg7"}),class:"notification-accepted"}):u==="dismiss"&&e(I,{icon:"x-circle",alt:s({id:"J6hrEy"}),class:"notification-dismissed"})})]})}const mo=ut(Ml),zl=20;function oi({local:n,columnMode:i,...s}){const{_:o}=le(),c=We(x),r=!!n,u=i?{}:Mt(),{masto:l,instance:d}=re({instance:(s==null?void 0:s.instance)||u.instance}),{masto:a,instance:h}=re(),p=o(r?{id:"u96B/B",values:{instance:d}}:{id:"PgVqvd",values:{instance:d}});tt(p,r?"/:instance?/p/l":"/:instance?/p");const m=j(),g=j();async function v(w){if(w||!g.current){const _={limit:zl,local:r||void 0};!r&&Je("@pixelfed/global-feed")&&(_.remote=!0),g.current=l.v1.timelines.public.list(_).values()}const b=await g.current.next();let{value:S}=b;return S!=null&&S.length&&(w&&(m.current=S[0].id),S.forEach(_=>{et(_,d)})),{...b,value:S}}async function y(){var w;try{const b=await l.v1.timelines.public.list({limit:1,local:r,since_id:m.current}).values().next();let{value:S}=b;const _=((w=S[0])==null?void 0:w.id)===m.current;return S!=null&&S.length&&!_?(S=zt(S,"public"),!0):!1}catch{return!1}}return e(At,{title:p,titleComponent:e("h1",{class:"header-double-lines",children:[e("b",{children:o(r?{id:"pJQgQV"}:{id:"cg0I+x"})}),e("div",{children:d})]}),id:"public",instance:d,emptyText:o({id:"BiZJ6G"}),errorText:o({id:"scd9lw"}),fetchItems:v,checkForUpdates:y,useItemID:!0,headerStart:e(U,{}),boostsCarousel:c.settings.boostsCarousel,filterContext:"public",headerEnd:e(dt,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(I,{icon:"more",size:"l",alt:o({id:"2FYpfJ"})})}),children:[e(ye,{href:r?`/#/${d}/p`:`/#/${d}/p/l`,children:r?e(U,{children:[e(I,{icon:"transfer"})," ",e("span",{children:e(f,{id:"dXMiUw"})})]}):e(U,{children:[e(I,{icon:"transfer"})," ",e("span",{children:e(f,{id:"t2B/we"})})]})}),e(Ve,{}),e(ye,{onClick:()=>{let w=prompt(o({id:"2MQ2cd"}));if(!/\./.test(w)){w&&alert(o({id:"7WddtO"}));return}w&&(w=w.toLowerCase().trim(),location.hash=r?`/${w}/p/l`:`/${w}/p`)},children:[e(I,{icon:"bus"})," ",e("span",{children:e(f,{id:"Sq04Yc"})})]}),h!==d&&e(ye,{onClick:()=>{location.hash=r?`/${h}/p/l`:`/${h}/p`},children:[e(I,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:e(f,{id:"iAzCp4",values:{currentInstance:h},components:{0:e("b",{})}})})]})]})},d+r)}const mn=5,Jn=40,Ul=new URLSearchParams,gn={block:"nearest",inline:"center",behavior:"smooth"};function go({columnMode:n,...i}){const{_:s}=le(),o=n?{}:Mt(),{masto:c,instance:r,authenticated:u}=re({instance:o.instance}),[l,d]=M("default"),[a]=n?[Ul]:vt(),h=j(),p=(i==null?void 0:i.query)||a.get("q"),m=n?"statuses":(i==null?void 0:i.type)||a.get("type");let g=s({id:"A1taO8"});if(p)switch(m){case"statuses":g=s({id:"6YeoAt",values:{q:p}});break;case"accounts":g=s({id:"fpgumQ",values:{q:p}});break;case"hashtags":g=s({id:"AuiMZZ",values:{q:p}});break;default:g=s({id:"wr3GZI",values:{q:p}})}tt(g,"/search");const[v,y]=M(!1),w=j(0);Q(()=>{w.current=0},[p,m]);const b=j();St(()=>{var $,K;(K=($=b.current)==null?void 0:$.scrollTo)==null||K.call($,0,0)},[p,m]);const[S,_]=M([]),[T,A]=M([]),[k,C]=M([]);Q(()=>{_([]),A([]),C([])},[p]);const E={statuses:S,accounts:T,hashtags:k},R={statuses:_,accounts:A,hashtags:C},[F,D]=M({}),W=async $=>{if(!($!=null&&$.length))return;const K=await Pn($,F);K&&D({...F,...K})};function G($){$&&(w.current=0),!(!$&&!u)&&(d("loading"),$&&!m&&(_(S.slice(0,mn)),A(T.slice(0,mn)),C(k.slice(0,mn))),(async()=>{var Y,te,J,ue,he,ne;const K={q:p,resolve:u,limit:mn};m&&(K.limit=Jn,K.type=m,u&&(K.offset=w.current));try{const we=await c.v2.search.list(K);if(m)if($){R[m](we[m]);const Ce=(Y=we[m])==null?void 0:Y.length;w.current=Jn,y(!!Ce)}else if(((J=(te=we[m])==null?void 0:te[0])==null?void 0:J.id)===((he=(ue=E[m])==null?void 0:ue[0])==null?void 0:he.id))y(!1);else{R[m](se=>[...se,...we[m]]);const Ce=(ne=we[m])==null?void 0:ne.length;w.current=w.current+Jn,y(!!Ce)}else _(we.statuses||[]),A(we.accounts||[]),C(we.hashtags||[]),w.current=0,y(!1);W(we.accounts),d("default")}catch{d("error")}})())}const X=j();Gt($=>{var Y;const K=((Y=b.current)==null?void 0:Y.scrollTop)===0;if($&&K){const te=Date.now()-X.current;!X.current||te>1e3*3?G(!0):X.current=Date.now()}}),Q(()=>{var K,Y;let $;return(Y=(K=h.current)==null?void 0:K.setValue)==null||Y.call(K,p||""),p?G(!0):$=setTimeout(()=>{var te,J;(J=(te=h.current)==null?void 0:te.focus)==null||J.call(te)},150),()=>clearTimeout($)},[p,m,r]),qe(["Slash","/"],$=>{var K,Y,te,J;(Y=(K=h.current)==null?void 0:K.focus)==null||Y.call(K),(J=(te=h.current)==null?void 0:te.select)==null||J.call(te)},{useKey:!0,preventDefault:!0,ignoreEventWhen:$=>$.metaKey||$.ctrlKey||$.altKey||$.shiftKey});const q=".timeline > li > a, .hashtag-list > li > a",Z=qe("j",()=>{const $=document.activeElement.closest(q),K=$==null?void 0:$.getBoundingClientRect(),Y=Array.from(b.current.querySelectorAll(q));if($&&K.top0){const te=Y.indexOf($);let J=Y[te+1];J&&(J.focus(),J.scrollIntoView(gn))}else{const te=Y.find(J=>{const ue=J.getBoundingClientRect();return ue.top>=44&&ue.left>=0});te&&(te.focus(),te.scrollIntoView(gn))}},{useKey:!0,ignoreEventWhen:$=>$.metaKey||$.ctrlKey||$.altKey||$.shiftKey}),B=qe("k",()=>{const $=document.activeElement.closest(q),K=$==null?void 0:$.getBoundingClientRect(),Y=Array.from(b.current.querySelectorAll(q));if($&&K.top0){const te=Y.indexOf($);let J=Y[te-1];J&&(J.focus(),J.scrollIntoView(gn))}else{const te=Y.find(J=>{const ue=J.getBoundingClientRect();return ue.top>=44&&ue.left>=0});te&&(te.focus(),te.scrollIntoView(gn))}},{useKey:!0,ignoreEventWhen:$=>$.metaKey||$.ctrlKey||$.altKey||$.shiftKey}),[ee]=ki();return e("div",{id:"search-page",class:"deck-container",tabIndex:"-1",ref:$=>{b.current=$,Z.current=$,B.current=$},children:e("div",{class:"timeline-deck deck",children:[e("header",{class:l==="loading"?"loading":"",children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:e($t,{})}),e(Qs,{ref:h}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>{G(!0)},disabled:l==="loading",children:e(I,{icon:"search",size:"l",alt:s({id:"A1taO8"})})})})]})}),e("main",{children:[!!p&&!n&&e("div",{ref:ee,class:`filter-bar ${l==="loading"?"loading":""}`,children:[!!m&&e(ge,{to:`/search${p?`?q=${encodeURIComponent(p)}`:""}`,children:[e(I,{icon:"chevron-left"})," ",e(f,{id:"N40H+G"})]}),[{label:s({id:"bPwFdf"}),type:"accounts",to:`/search?q=${encodeURIComponent(p)}&type=accounts`},{label:s({id:"VwUsHI"}),type:"hashtags",to:`/search?q=${encodeURIComponent(p)}&type=hashtags`},{label:s({id:"+owNNn"}),type:"statuses",to:`/search?q=${encodeURIComponent(p)}&type=statuses`}].sort(($,K)=>$.type===m?-1:K.type===m?1:0).map($=>e(ge,{to:$.to,children:$.label},$.type))]}),p?e(U,{children:[(!m||m==="accounts")&&e(U,{children:[m!=="accounts"&&e("h2",{class:"timeline-header",children:[e(f,{id:"bPwFdf"})," ",e(ge,{to:`/search?q=${encodeURIComponent(p)}&type=accounts`,children:e(I,{icon:"arrow-right",size:"l",alt:s({id:"V1fa9u"})})})]}),T.length>0?e(U,{children:[e("ul",{class:"timeline flat accounts-list",children:T.map($=>e("li",{children:e(ft,{account:$,instance:r,showStats:!0,relationship:F[$.id]})},$.id))}),m!=="accounts"&&e("div",{class:"ui-state",children:e(ge,{class:"plain button",to:`/search?q=${encodeURIComponent(p)}&type=accounts`,children:[e(f,{id:"BMmtZ8"})," ",e(I,{icon:"arrow-right"})]})})]}):!m&&(l==="loading"?e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}):e("p",{class:"ui-state",children:e(f,{id:"YYB61U"})}))]}),(!m||m==="hashtags")&&e(U,{children:[m!=="hashtags"&&e("h2",{class:"timeline-header",children:[e(f,{id:"VwUsHI"})," ",e(ge,{to:`/search?q=${encodeURIComponent(p)}&type=hashtags`,children:e(I,{icon:"arrow-right",size:"l",alt:s({id:"V1fa9u"})})})]}),k.length>0?e(U,{children:[e("ul",{class:"link-list hashtag-list",children:k.map($=>{var J;const{name:K,history:Y}=$,te=(J=Y==null?void 0:Y.reduce)==null?void 0:J.call(Y,(ue,he)=>ue+ +he.uses,0);return e("li",{children:e(ge,{to:r?`/${r}/t/${K}`:`/t/${K}`,children:[e(I,{icon:"hashtag",alt:"#"}),e("span",{children:K}),!!te&&e("span",{class:"count",children:Qe(te)})]})},`${K}-${te}`)})}),m!=="hashtags"&&e("div",{class:"ui-state",children:e(ge,{class:"plain button",to:`/search?q=${encodeURIComponent(p)}&type=hashtags`,children:[e(f,{id:"Nc/W5J"})," ",e(I,{icon:"arrow-right"})]})})]}):!m&&(l==="loading"?e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}):e("p",{class:"ui-state",children:e(f,{id:"4MFM3P"})}))]}),(!m||m==="statuses")&&e(U,{children:[m!=="statuses"&&e("h2",{class:"timeline-header",children:[e(f,{id:"+owNNn"})," ",e(ge,{to:`/search?q=${encodeURIComponent(p)}&type=statuses`,children:e(I,{icon:"arrow-right",size:"l",alt:s({id:"V1fa9u"})})})]}),S.length>0?e(U,{children:[e("ul",{class:"timeline",children:S.map($=>e("li",{children:e(ge,{class:"status-link",to:r?`/${r}/s/${$.id}`:`/s/${$.id}`,children:e(Ge,{status:$})})},$.id))}),m!=="statuses"&&e("div",{class:"ui-state",children:e(ge,{class:"plain button",to:`/search?q=${encodeURIComponent(p)}&type=statuses`,children:[e(f,{id:"LYCgej"})," ",e(I,{icon:"arrow-right"})]})})]}):!m&&(l==="loading"?e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}):e("p",{class:"ui-state",children:e(f,{id:"Hzi9AA"})}))]}),!!m&&(l==="default"?v?e(Tt,{onChange:$=>{$&&G()},children:e("button",{type:"button",class:"plain block",onClick:()=>G(),style:{marginBlockEnd:"6em"},children:e(f,{id:"uXRAkV"})})}):e("p",{class:"ui-state insignificant",children:e(f,{id:"2EYeAZ"})}):l==="loading"&&e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}))]}):l==="loading"?e("p",{class:"ui-state",children:e(Be,{abrupt:!0})}):e("p",{class:"ui-state",children:e(f,{id:"fGn1Hk"})})]})]})})}const Bl=20,yo=10*60*1e3,Fl=bt(n=>n.v1.trends.links.list().values().next(),{maxAge:yo}),Kl=bt(n=>n.v1.trends.tags.list().values().next(),{maxAge:yo});function Hl(n){return Je("@pixelfed/trending")?n.pixelfed.v2.discover.posts.trending.list({range:"daily"}).values():n.v1.trends.statuses.list({limit:Bl}).values()}function ql(n,i){return n.v1.timelines.link.list(i).values()}function bo({columnMode:n,...i}){const{_:s}=le(),o=We(x),c=n?{}:Mt(),{masto:r,instance:u}=re({instance:(i==null?void 0:i.instance)||c.instance}),{masto:l,instance:d}=re(),a=s({id:"cI3UEs",values:{instance:u}});tt(a,"/:instance?/trending");const h=j(),p=u===d,[m,g]=M([]),[v,y]=M([]),w=j();async function b(X){var B;if(X||!w.current){if(w.current=Hl(r),Je("@mastodon/trending-hashtags"))try{const{value:ee}=await Kl(r);ee!=null&&ee.length&&g(ee)}catch{}if(Je("@mastodon/trending-links"))try{const{value:ee}=await Fl(r,u),$=(B=ee==null?void 0:ee.filter)==null?void 0:B.call(ee,K=>K.type==="link");$!=null&&$.length&&y($)}catch{}}const q=await w.current.next();let{value:Z}=q;return Z!=null&&Z.length&&(X&&(h.current=Z[0].id),Z.forEach(ee=>{et(ee,u)})),{...q,value:Z}}const[S,_]=M(!1),T=j(),[A,k]=M(null),C=!!A,E=j(),R=p&&Je("@mastodon/trending-link-posts");Q(()=>{A&&E.current&&E.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[A]);const F=j();async function D(X){(X||!T.current)&&(_(!0),T.current=ql(r,{url:A})),F.current=A;const q=await T.current.next();let{value:Z}=q;return Z!=null&&Z.length&&(Z=zt(Z,"public"),Z.forEach(B=>{et(B,u)})),F.current===A&&_(!1),{...q,value:Z}}async function W(){try{const X=await r.v1.trends.statuses.list({limit:1}).values().next();let{value:q}=X;return q=zt(q,"public"),q!=null&&q.length&&q[0].id!==h.current?(h.current=q[0].id,!0):!1}catch{return!1}}const G=Ae(()=>e(U,{children:[!!m.length&&e("div",{class:"filter-bar expandable",children:[e(I,{icon:"chart",class:"insignificant",size:"l"}),m.map((X,q)=>{const{name:Z,history:B}=X,ee=B.reduce(($,K)=>$+ +K.uses,0);return e(ge,{to:`/${u}/t/${Z}`,children:[e("span",{dir:"auto",children:[e("span",{class:"more-insignificant",children:"#"}),Z]}),e("span",{class:"filter-count",children:Qe(ee)})]},Z)})]}),!!v.length&&e("div",{class:"links-bar",children:[e("header",{children:e("h3",{children:e(f,{id:"9veeTb"})})}),v.map(X=>{var H,ke;const{authors:q,authorName:Z,authorUrl:B,blurhash:ee,description:$,height:K,image:Y,imageDescription:te,language:J,providerName:ue,providerUrl:he,publishedAt:ne,title:we,url:Ce,width:se}=X,Te=(ke=(H=q==null?void 0:q[0])==null?void 0:H.account)!=null&&ke.id?q[0].account:null,Ie=we.length<30,Pe=!!(Z||Te),$e=$s(Ce);let Ee;if(ee){const De=mi(ee),xe=xi(De);Ee=Ai([.6,xe[1],xe[2]])}return e("div",{children:[e("a",{ref:A===Ce?E:null,href:Ce,target:"_blank",rel:"noopener",class:`link-block ${C?A===Ce?"active":"inactive":""}`,style:Ee?{"--accent-color":`rgb(${Ee.join(",")})`,"--accent-alpha-color":`rgba(${Ee.join(",")}, 0.4)`}:{},children:e("article",{children:[e("figure",{children:e("img",{src:Y,alt:te,width:se,height:K,loading:"lazy"})}),e("div",{class:"article-body",children:[e("header",{children:[e("div",{class:"article-meta",children:[e("span",{class:"domain",children:$e})," ",!!ne&&e(U,{children:"· "}),!!ne&&e(U,{children:e(_t,{datetime:ne,format:"micro"})})]}),!!we&&e("h1",{class:"title",lang:J,dir:"auto",title:we,children:we})]}),!!$&&e("p",{class:`description ${Pe&&!Ie?"":"more-lines"}`,lang:J,dir:"auto",title:$,children:$}),Pe&&e(U,{children:[e("hr",{}),e("p",{class:"byline",children:e("small",{children:e(f,{id:"aavdrC",values:{0:Te?e(yt,{account:Te,showAvatar:!0}):B?e("a",{href:B,target:"_blank",rel:"noopener",children:Z}):Z}})})})]})]})]})}),R&&e("button",{type:"button",class:"small plain4 block",onClick:()=>{k(Ce)},disabled:Ce===A,children:[e(I,{icon:"comment2"})," ",e("span",{children:e(f,{id:"/bZzdR"})})," ",e(I,{icon:"chevron-down"})]})]},Ce)})]}),R&&!!v.length&&e("div",{class:`timeline-header-block ${C?"blended":""}`,children:C?e(U,{children:[e("div",{style:{width:50,flexShrink:0,textAlign:"center"},children:S?e(Be,{abrupt:!0}):e("button",{type:"button",class:"light",onClick:()=>{k(null)},children:e(I,{icon:"x",alt:s({id:"9Q/4xJ"})})})}),e("p",{children:e(f,{id:"BATCqf",values:{0:A.replace(/^https?:\/\/(www\.)?/i,"").replace(/\/$/,"")},components:{0:e("span",{class:"link-text"})}})})]}):e("p",{class:"insignificant",children:e(f,{id:"Vosm4k"})})})]}),[m,v,A,S]);return e(At,{title:a,titleComponent:e("h1",{class:"header-double-lines",children:[e("b",{children:e(f,{id:"4/iCqx"})}),e("div",{children:u})]}),id:"trending",instance:u,emptyText:s({id:"6HA9+s"}),errorText:s({id:"scd9lw"}),fetchItems:C?D:b,checkForUpdates:C?void 0:W,checkForUpdatesInterval:5*60*1e3,useItemID:!0,headerStart:e(U,{}),boostsCarousel:o.settings.boostsCarousel,filterContext:"public",timelineStart:G,refresh:A,clearWhenRefresh:!0,view:C?"link-mentions":void 0,headerEnd:e(dt,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(I,{icon:"more",size:"l",alt:s({id:"2FYpfJ"})})}),children:[e(ye,{onClick:()=>{let X=prompt(s({id:"2MQ2cd"}));if(!/\./.test(X)){X&&alert(s({id:"7WddtO"}));return}X&&(X=X.toLowerCase().trim(),location.hash=`/${X}/trending`)},children:[e(I,{icon:"bus"})," ",e("span",{children:e(f,{id:"Sq04Yc"})})]}),d!==u&&e(ye,{onClick:()=>{location.hash=`/${d}/trending`},children:[e(I,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:e(f,{id:"iAzCp4",values:{currentInstance:d},components:{0:e("b",{})}})})]})]})},u)}const rs={block:"nearest",inline:"nearest",behavior:"smooth"};function Yl(){const{_:n}=le();tt(n({id:"i0qMbr"}),"/");const i=We(x),{shortcuts:s}=i,o=s.map(c=>{if(!c)return null;const{type:r,...u}=c,l={following:Ri,notifications:mo,list:oo,public:oi,bookmarks:to,favourites:no,hashtag:so,mentions:lo,trending:bo,search:go}[r];return!l||r==="search"&&!u.query||r==="list"&&!u.id?null:e(l,{...u,columnMode:!0},r+JSON.stringify(u))});return qe(["1","2","3","4","5","6","7","8","9"],c=>{try{const r=parseInt(c.key,10)-1,u=document.querySelectorAll("#columns > *")[r];u&&(u.focus(),u.scrollIntoView(rs))}catch{}},{useKey:!0,ignoreEventWhen:c=>c.metaKey||c.ctrlKey||c.altKey||c.shiftKey}),qe(["[","]"],(c,r)=>{const u=r.keys[0],l=document.activeElement.closest("#columns > *"),d=Ot(),a=d?"]":"[",h=d?"[":"]";let p;u===a?p=l?l.previousElementSibling:document.querySelectorAll("#columns > *")[0]:u===h&&(p=l?l.nextElementSibling:document.querySelectorAll("#columns > *")[1]),p&&(p.focus(),p.scrollIntoView(rs))},{useKey:!0,ignoreEventWhen:c=>c.metaKey||c.ctrlKey||c.altKey||c.shiftKey}),e("div",{id:"columns",onContextMenu:c=>{c.target.closest(".deck > header")&&!c.target.closest("a")&&!c.target.closest("button")&&(c.preventDefault(),x.showShortcutsSettings=!0)},onFocus:()=>{const c=document.activeElement.closest("#columns > *");c&&document.querySelectorAll("#columns > *").forEach(r=>{r.classList.toggle("focus",r===c)})},children:o})}function jl(){var s;const{_:n}=le(),i=We(x);return __BENCHMARK.end("time-to-home"),Q(()=>{(async()=>{const o=await gt.drafts.keys();if(o.length){const c=An();o.filter(u=>u.startsWith(c)).length&&(x.showDrafts=!0)}})()},[]),e(U,{children:(i.settings.shortcutsViewMode==="multi-column"||!i.settings.shortcutsViewMode&&i.settings.shortcutsColumnsMode)&&((s=i.shortcuts)!=null&&s.length)?e(Yl,{}):e(Ri,{title:n({id:"i0qMbr"}),path:"/",id:"home",headerStart:!1,headerEnd:e(Vl,{})})})}function Vl(){const{_:n}=le(),i=We(x),s=j(),[o,c]=M(void 0);return e(U,{children:[e(ge,{ref:s,to:"/notifications",class:`button plain notifications-button ${i.notificationsShowNew?"has-badge":""} ${o||""}`,onClick:r=>{r.stopPropagation(),window.matchMedia("(min-width: calc(40em))").matches&&(r.preventDefault(),c(u=>u?void 0:"open"))},children:e(I,{icon:"notification",size:"l",alt:n({id:"iDNBZe"})})}),e(Wl,{state:o,anchorRef:s,onClose:()=>c(void 0)})]})}const Gl=5;function Wl({anchorRef:n,state:i,onClose:s}){const{masto:o,instance:c}=re(),r=We(x),[u,l]=M("default"),d=fo();async function a(){const w=await d.next(),b=ro(w.value);if(b!=null&&b.length){b.forEach(_=>{et(_.status,c,{skipThreading:!0})});const S=po(b);x.notificationsLast=S[0],x.notifications=S,o.v1.markers.create({notifications:{lastReadId:S[0].id}}).catch(()=>{})}return x.notificationsShowNew=!1,x.notificationsLastFetchTime=Date.now(),w}const[h,p]=M(!1);function m(){return o.v1.followRequests.list({limit:1})}function g({skipFollowRequests:w=!1}={}){l("loading"),(async()=>{try{if(await a(),!w){const b=await m();p(!!(b!=null&&b.length))}l("default")}catch{l("error")}})()}const v=j(),y=52;return Q(()=>{if(i==="open")if(r.notificationsShowNew){const w=v.current;(w==null?void 0:w.scrollTop)<=y&&g({skipFollowRequests:!0})}else g()},[i,r.notificationsShowNew]),e(pi,{ref:v,menuClassName:"notifications-menu",state:i,anchorRef:n,onClose:s,portal:{target:document.body},containerProps:{onClick:()=>{var w,b;(b=(w=v.current)==null?void 0:w.closeMenu)==null||b.call(w)}},overflow:"auto",viewScroll:"close",position:"anchor",align:"center",boundingBoxPadding:"8 8 8 8",children:[e("header",{children:e("h2",{children:e(f,{id:"iDNBZe"})})}),e(Dn.Provider,{value:"notifications",children:e("main",{children:r.notifications.length?e(U,{children:r.notifications.slice(0,Gl).map(w=>e(ln,{instance:c,notification:w,disableContextMenu:!0},w._ids||w.id))}):u==="loading"?e("div",{class:"ui-state",children:e(Be,{abrupt:!0})}):u==="error"&&e("div",{class:"ui-state",children:[e("p",{children:e(f,{id:"5GFQTh"})}),e("p",{children:e("button",{type:"button",onClick:g,children:e(f,{id:"KDw4GX"})})})]})})}),e("footer",{children:[e(ge,{to:"/mentions",class:"button plain",children:[e(I,{icon:"at"})," ",e("span",{children:e(f,{id:"/bZzdR"})})]}),e(ge,{to:"/notifications",class:"button plain2",children:[h?e(f,{id:"OdVhdR",components:{0:e("span",{class:"tag collapsed"}),1:e("span",{})}}):e("b",{children:e(f,{id:"gukqfD"})})," ",e(I,{icon:"arrow-right"})]})]})]})}const Zl=ut(jl),Xl=[/^\/@[^@\/]+\/(?:statuses|posts)\/([^\/]+)/i,/\/notes\/([^\/]+)/i,/^\/(?:notice|objects)\/([a-z0-9-]+)/i,/\/@[^@\/]+\/post\/([^\/]+)/i,/\/@[^@\/]+@?[^\/]+?\/([^\/]+)/i,/^\/p\/[^\/]+\/([^\/]+)/i];function vo(n){const i=URL.parse(n);if(!i)return{};const{hostname:s,pathname:o}=i;for(const c of Xl){const[,r]=o.match(c)||[];if(r)return{instance:s,id:r}}return{}}function Jl(n){const{instance:i,id:s}=vo(n);return i&&s?`/${i}/s/${s}`:null}function Ql(){const i=Jt().pathname.replace(/^\//,""),s=vo(i),o=s!=null&&s.instance?`/${s.instance}/s/${s.id}`:null,[c,r]=M("loading");return St(()=>{r("loading"),(async()=>{try{const{instance:u,id:l}=s;if(l){const{masto:d}=re({instance:u});if(await d.v1.statuses.$select(l).fetch()){window.location.hash=o+"?view=full";return}}}catch{}{const{masto:u,instance:l}=re(),d=await u.v2.search.list({q:i,limit:1,resolve:!0});if(d.statuses.length){const a=d.statuses[0];window.location.hash=`/${l}/s/${a.id}?view=full`}else if(d.accounts.length){const a=d.accounts[0];window.location.hash=`/${l}/a/${a.id}`}else o?window.location.hash=o+"?view=full":r("error")}})()},[o]),e("div",{class:"ui-state",tabIndex:"-1",children:[c==="loading"?e(U,{children:[e(Be,{abrupt:!0}),e("h2",{children:e(f,{id:"RTAr/z"})}),e("p",{children:e("a",{href:i,target:"_blank",rel:"noopener",children:i})})]}):e(U,{children:[e("h2",{children:e(f,{id:"ufzZSJ"})}),e("p",{children:e("a",{href:i,target:"_blank",rel:"noopener",children:i})})]}),e("hr",{}),e("p",{children:e(ge,{to:"/",children:e(f,{id:"iWpEwy"})})})]})}function ed(){const{_:n}=le();tt(n({id:"h16FyT"}),"/l");const[i,s]=M("default"),[o,c]=Lt(h=>h+1,0),[r,u]=M([]);Q(()=>{s("loading"),(async()=>{try{const h=await ii();u(h),s("default")}catch{s("error")}})()},[o]);const[l,d]=M(!1),a=r.some(h=>h.exclusive);return e("div",{id:"lists-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),e(ge,{to:"/",class:"button plain",children:e(I,{icon:"home",size:"l"})})]}),e("h1",{children:e(f,{id:"h16FyT"})}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>d(!0),children:e(I,{icon:"plus",size:"l",alt:n({id:"Sb2gYF"})})})})]})}),e("main",{children:r.length>0?e(U,{children:[e("ul",{class:"link-list",children:r.map(h=>e("li",{children:e(ge,{to:`/l/${h.id}`,children:[e(I,{icon:"list"})," ",e("span",{children:[h.title,h.exclusive&&e(U,{children:[" ",e(Bt,{insignificant:!0})]})]})]})}))}),r.length>1&&e("footer",{class:"ui-state",children:[a&&e("p",{children:e("small",{class:"insignificant",children:[e(Bt,{})," ",e(f,{id:"FNptcJ"})]})}),e("p",{children:e("small",{class:"insignificant",children:e(f,{id:"8prZNK",values:{0:r.length}})})})]})]}):i==="loading"?e("p",{class:"ui-state",children:e(Be,{})}):i==="error"?e("p",{class:"ui-state",children:e(f,{id:"v/l5uA"})}):e("p",{class:"ui-state",children:e(f,{id:"IvPikw"})})})]}),l&&e(Ye,{onClick:h=>{h.target===h.currentTarget&&d(!1)},children:e(Ti,{list:l==null?void 0:l.list,onClose:h=>{h.state==="success"&&c(),d(!1)}})})]})}const td=""+new URL("instances-LA7224ZB.json",import.meta.url).href,nd={BASE_URL:"./",DEV:!1,MODE:"production",PHANPY_CLIENT_NAME:"Phanpy",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",PHANPY_TRANSLANG_INSTANCES:"translang.phanpy.social",PHANPY_WEBSITE:"https://phanpy.social",PROD:!0,SSR:!1,VITE_APP_ENV:"production"},{PHANPY_DEFAULT_INSTANCE:id}=nd;function sd(){var _,T;const{_:n}=le();tt(n({id:"sQia9P"}),"/login");const i=j(),s=Ue.local.get("instanceURL"),[o,c]=M("default"),[r]=vt(),u=r.get("instance"),l=r.get("submit"),[d,a]=M(u||(s==null?void 0:s.toLowerCase())||""),[h,p]=M([]),m=j();Q(()=>{(async()=>{try{const k=await(await fetch(td)).json();p(k),m.current=new oc(k)}catch{}})()},[]);const g=A=>{A&&(async()=>{try{const C=await(await fetch(`https://${A}/.well-known/host-meta`)).text(),D=new DOMParser().parseFromString(C,"text/xml").getElementsByTagName("Link")[0].getAttribute("template"),W=URL.parse(D),{host:G}=W;A!==G&&(A=G)}catch{}Ue.local.set("instanceURL",A),c("loading");try{let k=Cs(A);k||(k=await Bc({instanceURL:A}),Po(A,k));const{client_id:C,client_secret:E}=k,R=await Nc({instanceURL:A}),F=Do(A);if(R)if(C&&E){const[D,W]=await Fc({instanceURL:A,client_id:C,forceLogin:F});Ue.sessionCookie.set("codeVerifier",W),location.href=D}else alert(n({id:"ZP1FIA"}));else C&&E?location.href=await Kc({instanceURL:A,client_id:C,forceLogin:F}):alert(n({id:"ZP1FIA"}));c("default")}catch{c("error")}})()},v=d?d.replace(/^https?:\/\//,"").replace(/\/+$/,"").replace(/^@?[^@]+@/,"").trim():null,y=/[^\s\r\n\t\/\\]+\.[^\s\r\n\t\/\\]+/.test(v)&&!/[\s\/\\@]/.test(v),w=v?(T=(_=m.current)==null?void 0:_.search(v,{limit:10}))==null?void 0:T.map(A=>A.item):[],b=y?v:w!=null&&w.length?w[0]:d?h.find(A=>A.includes(d)):null,S=A=>{A.preventDefault(),g(b)};return l&&Q(()=>{g(u||b)},[]),e("main",{id:"login",style:{textAlign:"center"},children:e("form",{onSubmit:S,children:[e("h1",{children:[e("img",{src:_i,alt:"",width:"80",height:"80"}),e("br",{}),e(f,{id:"sQia9P"})]}),e("label",{children:[e("p",{children:e(f,{id:"kyAi7k"})}),e("input",{value:d,required:!0,type:"text",class:"large",id:"instanceURL",ref:i,disabled:o==="loading",autocorrect:"off",autocapitalize:"off",autocomplete:"off",spellCheck:!1,placeholder:n({id:"u3gOdY"}),onInput:A=>{a(A.target.value)},dir:"auto"}),(w==null?void 0:w.length)>0?e("ul",{id:"instances-suggestions",children:w.map((A,k)=>e("li",{children:e("button",{type:"button",class:"plain5",onClick:()=>{g(A)},children:A})}))}):e("div",{id:"instances-eg",children:e(f,{id:"/OvbEC"})})]}),o==="error"&&e("p",{class:"error",children:e(f,{id:"rmBHZn"})}),e("div",{children:[e("button",{disabled:o==="loading"||!d||!b,children:n(b?{id:"2xahsi",values:{selectedInstanceText:b}}:{id:"xGVfLh"})})," "]}),e(Be,{hidden:o!=="loading"}),e("hr",{}),!id&&e("p",{children:e("a",{href:"https://joinmastodon.org/servers",target:"_blank",children:e(f,{id:"LcOiWS"})})}),e("p",{children:e(ge,{to:"/",children:e(f,{id:"iWpEwy"})})}),e(Ci,{})]})})}const od=40;function cd(){const{_:n}=le(),i=We(x);tt(n({id:"+GkIdc"}),"/sp");const{masto:s}=re(),[o,c]=M([]),[r,u]=M("default"),[l,d]=Lt(p=>p+1,0),[a,h]=M(!1);return Q(d,[i.reloadScheduledPosts]),Q(()=>{u("loading"),(async()=>{try{const p=s.v1.scheduledStatuses.list({limit:od}).values(),m=[];let g;do g=(await p.next()).value,g!=null&&g.length&&m.push(...g);while(g!=null&&g.length);c(m)}catch{u("error")}finally{u("default")}})()},[l]),e("div",{id:"scheduled-posts-page",class:"deck-container",tabIndex:"-1",children:e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e($t,{}),e(ge,{to:"/",class:"button plain",children:e(I,{icon:"home",size:"l",alt:n({id:"i0qMbr"})})})]}),e("h1",{children:e(f,{id:"+GkIdc"})}),e("div",{class:"header-side",children:e(dt,{portal:!0,setDownOverflow:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(I,{icon:"more",size:"l",alt:n({id:"2FYpfJ"})})}),children:e(ye,{onClick:()=>{d()},children:[e(I,{icon:"refresh",size:"l"}),e("span",{children:e(f,{id:"lCF0wC"})})]})})})]})}),e("main",{children:[o.length?e("ul",{class:"posts-list",children:o.map(p=>{const{id:m,params:g,scheduledAt:v,mediaAttachments:y}=p,{inReplyToId:w,language:b,poll:S,sensitive:_,spoilerText:T,text:A,visibility:k}=g,C={id:m,inReplyToId:w,language:b,mediaAttachments:y,poll:S?{...S,expiresAt:new Date(Date.now()+S.expiresIn*1e3),options:S.options.map(E=>({title:E,votesCount:0}))}:void 0,sensitive:_,spoilerText:T,text:A,visibility:k,content:`${A}
`};return e("li",{children:e(ad,{status:C,scheduledAt:v,onClick:()=>{h({post:C,scheduledAt:new Date(v)})}})},m)})}):e("p",{class:"ui-state",children:r==="loading"?e(Be,{}):n({id:"mZYb1f"})}),a&&e(Ye,{onClick:p=>{p.target===p.currentTarget&&h(!1)},children:e(rd,{post:a.post,scheduledAt:a.scheduledAt,onClose:()=>h(!1)})})]})]})})}function ad({status:n,scheduledAt:i,onClick:s}){const o=Ae(()=>{const c=(new Date(i).getTime()-Date.now())/36e5;return c<24?"time":c<720?"day":"month"},[i]);return e("button",{type:"button",class:"textual block",onClick:s,children:[e("div",{class:`post-schedule-meta post-schedule-${o}`,children:[e(I,{icon:o,class:"insignificant"})," ",e("span",{children:e(f,{id:"aEp6lO",values:{0:ct(i,{formatOpts:{weekday:"short",second:"numeric"}})},components:{0:e("b",{}),1:e(_t,{datetime:i}),2:e("small",{})}})})]}),e(Ge,{status:n,size:"s",previewMode:!0,readOnly:!0})]})}function rd({post:n,scheduledAt:i,onClose:s}){const{masto:o}=re(),{_:c}=le(),[r,u]=M("default"),[l,d]=M(),a=l&&l.getTime()!==i.getTime(),h=cc(),p=i&&i<=Date.now(),{inReplyToId:m}=n,[g,v]=M(null);return e("div",{id:"scheduled-post-sheet",class:"sheet",children:[e("button",{type:"button",class:"sheet-close",onClick:s,children:e(I,{icon:"x",size:"l",alt:c({id:"yz7wBu"})})}),e("header",{children:e("h2",{children:[e(f,{id:"orjBLU",components:{0:e("b",{}),1:e(_t,{datetime:i})}}),e("br",{}),e("small",{children:ct(i,{formatOpts:{weekday:"short",second:"numeric"}})})]})}),e("main",{tabIndex:"-1",children:[!!g&&e("div",{class:"status-reply",children:e(Ge,{status:g,size:"s",previewMode:!0,readOnly:!0})}),e(Ge,{status:n,size:"s",previewMode:!0,readOnly:!0,onMediaClick:(y,w,b,S)=>{y.preventDefault(),x.showMediaModal={mediaAttachments:n.mediaAttachments,mediaIndex:w}}}),e("form",{onSubmit:y=>{y.preventDefault(),u("loading"),(async()=>{try{await o.v1.scheduledStatuses.$select(n.id).update({scheduledAt:l.toISOString()}),fe(c({id:"40naR1"})),s(),u("default"),x.reloadScheduledPosts++}catch{u("error"),fe(c({id:"ZM3jAs"}))}})()},children:e("footer",{children:[e("div",{class:"row",children:e("span",{children:[e(ac,{scheduledAt:i,setScheduledAt:y=>{d(y)}})," ",e("small",{class:"ib",children:h})]})}),e("div",{class:"row",children:[e("button",{disabled:!a||r==="loading"||p,children:e(f,{id:"QqW27M"})}),e("span",{class:"grow"}),e(pt,{align:"end",menuItemClassName:"danger",confirmLabel:c({id:"09u3Kk"}),onClick:()=>{u("loading"),(async()=>{try{await re().masto.v1.scheduledStatuses.$select(n.id).remove(),fe(c({id:"/zL/Mq"})),s(),u("default"),x.reloadScheduledPosts++}catch{u("error"),fe(c({id:"aOh6Md"}))}})()},children:e("button",{type:"button",class:"light danger",disabled:r==="loading"||p,children:e(f,{id:"Jb6/SB"})})})]})]})})]})]})}const ld={BASE_URL:"./",DEV:!1,MODE:"production",PHANPY_CLIENT_NAME:"Phanpy",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",PHANPY_TRANSLANG_INSTANCES:"translang.phanpy.social",PHANPY_WEBSITE:"https://phanpy.social",PROD:!0,SSR:!1,VITE_APP_ENV:"production"},{PHANPY_DEFAULT_INSTANCE:ls}=ld,yn=40,dd=10,ud=5;let ci={},Sn={},_n={};function Cn(n){delete Sn[n],delete _n[n]}const tn={block:"nearest",inline:"center",behavior:"smooth"},ds=".status-link:not(details:not([open]) > summary ~ *, details:not([open]) > summary ~ * *), .status-focus:not(details:not([open]) > summary ~ *, details:not([open]) > summary ~ * *)",us=/\/s\//i;function hd(n){var C;const{_:i}=le(),{id:s}=n,{masto:o,instance:c}=re({instance:n.instance}),r=We(x),[u,l]=vt(),d=u.get("media"),a=u.get("media-only"),h=parseInt(d||a,10);let p=h>0;const m=u.get("mediaStatusID"),g=_s(m,c);m&&!g&&(p=!1);const v=p&&!!a,y=lt(s,c),[w,b]=M(x.statuses[y]);Q(()=>{x.statuses[y]&&b(x.statuses[y])},[y]);const S=Ae(()=>{const{prevLocation:E}=x,R=((E==null?void 0:E.pathname)||"")+((E==null?void 0:E.search)||""),F=cn("/:instance/s/:id",R)||cn("/s/:id",R);return!R||F?"/":R},[]);Q(()=>{!w&&p&&(async()=>{try{const E=await o.v1.statuses.$select(s).fetch();et(E,c),b(E)}catch{alert("Unable to load post."),location.hash=S}})()},[p]);const _=m?(C=r.statuses[lt(m,c)])==null?void 0:C.mediaAttachments:w==null?void 0:w.mediaAttachments,T=()=>window.matchMedia("(min-width: calc(40em + 350px))").matches?"large":"small",A=it(()=>{T()==="small"&&r.prevLocation?history.back():v?location.hash=S:(u.delete("media"),u.delete("mediaStatusID"),l(u))},[v,S,r.prevLocation]),k=it((E,R,F,D)=>{var W,G;if(T()==="large"&&!v){A();return}if(p&&document.startViewTransition){const X=F[R],{id:q,blurhash:Z,url:B}=X,ee=rc(q||Z||B),K=(G=(W=[...document.querySelectorAll(`.status .media [data-view-transition-name="${ee}"]`)]).filter)==null?void 0:G.call(W,te=>{const J=te.getBoundingClientRect();return J.top0&&J.left0}),Y=K.length===1?K[0]:K.find(te=>!!te.closest(".status-deck"));Y?document.startViewTransition(()=>{var J;Y.style.viewTransitionName=ee,D!=null&&D.current&&((J=D.current.querySelectorAll(".media img, .media video"))==null||J.forEach(ue=>{ue.style.viewTransitionName=""})),A()}).ready.finally(()=>{Y.style.viewTransitionName=""}):A()}else A()},[p,v]);return Q(()=>{let E=setTimeout(()=>{const R=document.querySelector(".carousel");R&&R.focus()},100);return()=>clearTimeout(E)},[v]),Q(()=>{const E=document.querySelectorAll(".deck-container");return E.forEach(R=>{R.setAttribute("inert","")}),()=>{E.forEach(R=>{R.removeAttribute("inert")})}},[]),e("div",{class:"deck-backdrop",children:[p?_!=null&&_.length?e(Xs,{mediaAttachments:_,statusID:m||s,instance:c,lang:w==null?void 0:w.language,index:h-1,onClose:k}):e("div",{class:"media-modal-container loading",children:e(Be,{abrupt:!0})}):e(ge,{to:S}),!v&&e(pd,{id:s,instance:n.instance,closeLink:S})]})}function fd(n){const{linkable:i,to:s,onClick:o,...c}=n;return i?e(ge,{class:"status-link",to:s,onClick:o,...c}):e("div",{class:"status-focus",tabIndex:0,...c})}function hs(n,i){return new Date(i.created_at)-new Date(n.created_at)}function pd({id:n,closeLink:i="/",instance:s}){var Me,me;const{_:o}=le(),[c,r]=vt(),u=c.get("media"),l=c.get("mediaStatusID"),d=parseInt(u,10)>0,a=j(!x.prevLocation&&(history.length===1||"navigation"in window&&((me=(Me=navigation==null?void 0:navigation.entries)==null?void 0:Me.call(navigation))==null?void 0:me.length)===1)),[h,p]=M(c.get("view")||a.current?"full":null),m=!!parseInt(c.get("translate")),{masto:g,instance:v}=re({instance:s}),{masto:y,instance:w,authenticated:b}=re(),S=v===w,_=We(x),[T,A]=M([]),[k,C]=M("default"),E=j(),R=lt(n,v),F=j(0),D=j();Q(()=>{var N;(N=D.current)==null||N.focus()},[]),Q(()=>{var O;const N=Ps(()=>{if(!D.current)return;const{scrollTop:oe}=D.current;k!=="loading"&&(_n[n]=oe)},50);return(O=D.current)==null||O.addEventListener("scroll",N,{passive:!0}),N(),()=>{var oe;N.cancel(),(oe=D.current)==null||oe.removeEventListener("scroll",N)}},[n,k!=="loading"]);const W=j(),G=j(),X=({reloadHero:N}={})=>{C("loading");let O;const oe=Sn[n];if(oe){const Le=oe.filter(P=>x.statuses[R]);A(Le)}else A([{id:n}]);return(async()=>{var Ne,Oe;const Le=()=>Di(()=>g.v1.statuses.$select(n).fetch(),{retries:4}),P=Di(()=>g.v1.statuses.$select(n).context.fetch(),{retries:8}),ce=!!_.statuses[R];let Se=_.statuses[R];if(!(ce&&!N))try{Se=await Le(),et(Se,v),await new Promise(L=>{setTimeout(L,100)})}catch{C("error");return}try{let L=function(de,ze){const Ke=ze+1;return Ke>_e&&(_e=ze),de==null?void 0:de.map(nt=>({id:nt.id,account:nt.account,repliesCount:nt.repliesCount,content:nt.content,weight:on(nt),level:Ke,replies:L(nt.__replies,Ke)}))};const V=await P,{ancestors:ae,descendants:ie}=V;ae.sort(hs),ie.sort(hs),F.current=(ie==null?void 0:ie.length)||0;const z=new Set;ae.forEach(de=>{et(de,v,{skipThreading:!0}),de.inReplyToId&&!ae.find(ze=>ze.id===de.inReplyToId)&&z.add(de.inReplyToId)});const be=ae.every(de=>de.account.id===Se.account.id),ve=[];ie.forEach(de=>{if(et(de,v,{skipThreading:!0}),de.inReplyToId&&!ie.find(ze=>ze.id===de.inReplyToId)&&de.inReplyToId!==Se.id&&z.add(de.inReplyToId),de.inReplyToAccountId===de.account.id)ve.push(de);else if(de.inReplyToId===Se.id)ve.push(de);else if(!de.inReplyToAccountId&&ve.find(ze=>ze.id===de.inReplyToId&&ze.account.id===Se.account.id)&&de.account.id===Se.account.id)ve.push(de);else{const ze=ie.find(Ke=>Ke.id===de.inReplyToId);ze&&(ze.__replies||(ze.__replies=[]),ze.__replies.push(de))}}),ve.sort((de,ze)=>{const Ke=Se.account.id;return de.account.id===Ke&&ze.account.id!==Ke?-1:ze.account.id===Ke&&de.account.id!==Ke?1:0}),z.size;let _e=1;const Ze=[...ae.map(de=>({id:de.id,ancestor:!0,isThread:be,accountID:de.account.id,account:de.account,repliesCount:de.repliesCount,weight:on(de)})),{id:n,accountID:Se.account.id,weight:on(Se)},...ve.map(de=>({id:de.id,account:de.account,accountID:de.account.id,descendant:!0,thread:de.account.id===Se.account.id,weight:on(de),level:1,replies:L(de.__replies,1)}))];C("default"),W.current={offsetTop:(Ne=E.current)==null?void 0:Ne.offsetTop,scrollTop:(Oe=D.current)==null?void 0:Oe.scrollTop};const Fe=ae.length||0;Fe>=te&&J(Fe+1),A(Ze),Sn[n]=Ze,Oo(Se,v)}catch{C("error")}})(),G.current=Date.now(),()=>{clearTimeout(O)}};Q(X,[n,g]);const[q,Z]=M(!1);Q(()=>{let N=setInterval(()=>{const O=Date.now();G.current&&O-G.current>=6e4&&Z(!0)},6e4);return()=>{clearInterval(N)}},[]),St(()=>{var O,oe;if(!T.length)return;const N=_n[n];if(N)D.current.scrollTop=N;else if(W.current){const Le={offsetTop:(O=E.current)==null?void 0:O.offsetTop,scrollTop:(oe=D.current)==null?void 0:oe.scrollTop},P=Le.offsetTop-W.current.offsetTop+Le.scrollTop;D.current.scrollTop=P}else T.length===1&&(D.current.scrollTop=0);W.current=null},[T]),Q(()=>{_.reloadStatusPage<=0||(async()=>{try{const{instanceURL:N}=di(),O=`https://${N}/api/v1/statuses/${n}/context`;return await(await caches.open("api")).delete(O,{ignoreVary:!0}),X({reloadHero:!0})}catch{}})()},[_.reloadStatusPage]),Q(()=>()=>{_n={},x.reloadStatusPage=0,Sn={},ci={},ai.clear()},[]);const B=_.statuses[R]||_.statuses[n],ee=Ae(()=>{if(!B)return"";const{account:N}=B,O=document.createElement("div");return O.innerHTML=N.displayName,O.innerText.trim()},[B]),$=Ae(()=>{if(!B)return"";let N=Nn(B);return N.length>64&&(N=N.slice(0,64)+"…"),N},[B]);tt(ee&&$?`${ee}: "${$}"`:o({id:"post.title"}),"/:instance?/s/:id");const K=Ae(()=>{var O;if(!B)return;const{url:N}=B;if(N)return(O=URL.parse(N))==null?void 0:O.hostname},[B]),Y=Ae(()=>{if(K)return K===v},[K,v]),[te,J]=M(yn),ue=Ae(()=>T.length-te,[T.length,te]),he=T.some(N=>N.descendant),ne=T.filter(N=>N.ancestor),[we,Ce]=M(!0),se=Ae(()=>{if(!E.current||we)return null;const{top:N}=E.current.getBoundingClientRect();return N>0?"down":"up"},[we]);qe("esc",()=>{location.hash=i},{enabled:!d,ignoreEventWhen:N=>!!document.querySelector("#modal-container > *")||N.metaKey||N.ctrlKey||N.altKey||N.shiftKey,useKey:!0}),qe("backspace",()=>{location.hash=i},{useKey:!0,ignoreEventWhen:N=>N.metaKey||N.ctrlKey||N.altKey||N.shiftKey}),qe("j",()=>{const N=document.activeElement.closest(".status-link, .status-focus"),O=N==null?void 0:N.getBoundingClientRect(),oe=Array.from(D.current.querySelectorAll(ds));if(N&&O.top0){const Le=oe.indexOf(N);let P=oe[Le+1];P&&(P.focus(),P.scrollIntoView(tn))}else{const Le=oe.find(P=>{const ce=P.getBoundingClientRect();return ce.top>=44&&ce.left>=0});Le&&(Le.focus(),Le.scrollIntoView(tn))}},{useKey:!0,ignoreEventWhen:N=>N.metaKey||N.ctrlKey||N.altKey||N.shiftKey}),qe("k",()=>{const N=document.activeElement.closest(".status-link, .status-focus"),O=N==null?void 0:N.getBoundingClientRect(),oe=Array.from(D.current.querySelectorAll(ds));if(N&&O.top0){const Le=oe.indexOf(N);let P=oe[Le-1];P&&(P.focus(),P.scrollIntoView(tn))}else{const Le=oe.find(P=>{const ce=P.getBoundingClientRect();return ce.top>=44&&ce.left>=0});Le&&(Le.focus(),Le.scrollIntoView(tn))}},{useKey:!0,ignoreEventWhen:N=>N.metaKey||N.ctrlKey||N.altKey||N.shiftKey}),qe("x",()=>{const N=document.activeElement.closest(".status-link, .status-focus");if(N){const O=N.nextElementSibling;O&&O.tagName.toLowerCase()==="details"&&(O.open=!O.open)}},{useKey:!0,ignoreEventWhen:N=>N.metaKey||N.ctrlKey||N.altKey||N.shiftKey});const[Te,Ie]=M(!1),Pe=j(d?"media+status":"status"),$e=it((N,O,oe,Le)=>{N.preventDefault(),N.stopPropagation(),r({media:O+1,mediaStatusID:Le.id})},[n]),Ee=it((N,O)=>{Cn(O.id)},[]);Q(()=>{let N;return l&&d&&(N=setTimeout(()=>{var oe;const O=(oe=D.current)==null?void 0:oe.querySelector(`.status-link[href*="/${l}"]`);O&&O.scrollIntoView(tn)},400)),()=>{clearTimeout(N)}},[l,d]);const H=it((N,O)=>{const{id:oe,ancestor:Le,isThread:P,descendant:ce,thread:Se,replies:Ne,repliesCount:Oe,weight:L,level:V}=N,ae=oe===n;return e("li",{ref:ae?E:null,class:`${Le?"ancestor":""} ${ce?"descendant":""} ${Se?"thread":""} ${ae?"hero":""}`,children:[ae?e(U,{children:[e(Tt,{threshold:.1,onChange:z=>{queueMicrotask(()=>{requestAnimationFrame(()=>{Ce(z)})})},class:"status-focus",tabIndex:0,children:e(Ge,{statusID:oe,instance:v,withinContext:!0,size:"l",enableTranslate:!0,forceTranslate:m})}),k!=="loading"&&!b?e("div",{class:"post-status-banner",children:[e("p",{children:e(f,{id:"Vyeh4F"})}),e(ge,{to:ls?`/login?instance=${ls}&submit=1`:"/login",class:"button",children:e(f,{id:"sQia9P"})})]}):!S&&e("div",{class:"post-status-banner",children:[e("p",{children:e(f,{id:"j5roNG",values:{instance:v},components:{0:e("b",{})}})}),e("button",{type:"button",disabled:k==="loading",onClick:()=>{C("loading"),(async()=>{try{const z=await y.v2.search.list({q:B.url,type:"statuses",resolve:!0,limit:1});if(z.statuses.length){const be=z.statuses[0];location.hash=w?`/${w}/s/${be.id}`:`/s/${be.id}`}else throw new Error("No results")}catch(z){C("default"),alert(o({id:"DnepCE",values:{e:z}}))}})()},children:[e(I,{icon:"transfer"})," ",e(f,{id:"ejAVrO"})]})]})]}):e(fd,{linkable:P||Le,to:v?`/${v}/s/${oe}`:`/s/${oe}`,onClick:()=>{Cn(oe)},children:[O===0&&Le?e(Tt,{threshold:.5,onChange:z=>{queueMicrotask(()=>{requestAnimationFrame(()=>{Ie(z)})})},children:e(Ge,{statusID:oe,instance:v,withinContext:!0,size:Se||Le?"m":"s",enableTranslate:!0,onMediaClick:$e,onStatusLinkClick:Ee})}):e(Ge,{statusID:oe,instance:v,withinContext:!0,size:Se||Le?"m":"s",enableTranslate:!0,onMediaClick:$e,onStatusLinkClick:Ee,showActionsBar:!!ce}),Le&&Oe>1&&e("div",{class:"replies-link",children:[e(I,{icon:"comment2",alt:o({id:"N8UzTV"})})," ",e("span",{title:Oe,children:Qe(Oe)})]})," "]}),ce&&(Ne==null?void 0:Ne.length)>0&&e(wo,{instance:v,replies:Ne,hasParentThread:Se,level:V,accWeight:L,openAll:F.currentCn(oe)}}),k==="loading"&&ae&&!!(B!=null&&B.repliesCount)&&!he&&e("div",{class:"status-loading",children:e(Be,{abrupt:B.repliesCount>=3})}),k==="error"&&ae&&!!(B!=null&&B.repliesCount)&&!he&&e("div",{class:"status-error",children:[e(f,{id:"HQJU6W"}),e("br",{}),e("button",{type:"button",class:"plain",onClick:()=>{x.reloadStatusPage++},children:e(f,{id:"KDw4GX"})})]})]},oe)},[n,v,k,b,S,m,$e,Ee,he]),ke=Ae(()=>{var N;if("navigation"in window&&(navigation!=null&&navigation.entries)){const O=navigation.entries()[navigation.currentEntry.index-1];if(O!=null&&O.url)return us.test(O.url)}return us.test((N=x.prevLocation)==null?void 0:N.pathname)},[R]),De=Ae(()=>{if(!ue)return[];const N=[];function O(oe){N.push(oe.id),oe.replies&&oe.replies.forEach(O)}return T.slice(te).forEach(O),N.map(oe=>lt(oe,v))},[ue,T,te,v]),xe=Ae(()=>T.slice(0,te).map(H),[T,te,H]);return Q(()=>{let N=setTimeout(()=>{if(!E.current)return;const O=E.current.querySelector(".spoiler-button:not(.spoiling), .spoiler-media-button:not(.spoiling)");O&&O.click()},1e3);return()=>clearTimeout(N)},[n]),e("div",{tabIndex:"-1",ref:D,class:`status-deck deck contained ${T.length>1?"padded-bottom":""} ${Pe.current==="status"&&!a.current?"slide-in":""} ${h?`deck-view-${h}`:""}`,onAnimationEnd:N=>{Pe.current==="status"&&(Pe.current=null)},children:[e("header",{class:`${k==="loading"?"loading":""}`,onDblClick:N=>{x.reloadStatusPage++},children:e("div",{class:"header-grid header-grid-2",children:[e("h1",{children:[ke&&e("button",{type:"button",class:"plain deck-back",onClick:()=>{history.back()},children:e(I,{icon:"chevron-left",size:"xl",alt:o({id:"iH8pgl"})})}),!we&&B&&k!=="loading"?e(U,{children:[e("span",{class:"hero-heading",children:[e(yt,{account:B.account,instance:v,showAvatar:!0,short:!0})," ",e("span",{class:"insignificant",children:["•"," ",e(_t,{datetime:B.createdAt,format:"micro"})]})]})," ",e("button",{type:"button",class:"ancestors-indicator light small",onClick:N=>{N.preventDefault(),N.stopPropagation(),E.current.scrollIntoView({behavior:"smooth",block:"start"})},title:o({id:"NCy+Nw"}),children:e(I,{icon:se==="down"?"arrow-down":"arrow-up"})})]}):e(U,{children:[e(f,{id:"post.title"})," ",e("button",{type:"button",class:"ancestors-indicator light small",onClick:N=>{N.preventDefault(),N.stopPropagation(),D.current.scrollTo({top:0,behavior:"smooth"})},hidden:!ne.length||Te,title:o({id:"R8CUl0",values:{0:ne.length}}),children:[e(I,{icon:"arrow-up"}),ne.filter((N,O,oe)=>oe.findIndex(Le=>Le.accountID===N.accountID)===O).slice(0,3).map(N=>{var O;return e(mt,{url:N.account.avatarStatic||N.account.avatar,alt:N.account.displayName,squircle:(O=N.account)==null?void 0:O.bot},N.account.id)}),ne.length>3&&e(U,{children:[" ",e("span",{class:"insignificant",children:Qe(ne.length)})]})]})]})]}),e("div",{class:"header-side",children:[e("button",{type:"button",class:"plain4 button-switch-view",style:{display:h==="full"?"":"none"},onClick:()=>{p(null),c.delete("media"),c.delete("media-only"),c.delete("view"),r(c)},title:o({id:"+/xYEI"}),children:e(I,{icon:"layout4",size:"l"})}),q&&e("button",{type:"button",class:"plain button-refresh",onClick:()=>{x.reloadStatusPage++,Z(!1)},children:e(I,{icon:"refresh",size:"l",alt:o({id:"lCF0wC"})})}),e(dt,{align:"end",portal:{target:D.current},menuButton:e("button",{type:"button",class:"button plain4",children:e(I,{icon:"more",alt:o({id:"2FYpfJ"}),size:"xl"})}),children:[e(ye,{disabled:k==="loading",onClick:()=>{x.reloadStatusPage++},children:[e(I,{icon:"refresh"}),e("span",{children:e(f,{id:"lCF0wC"})})]}),e(ye,{className:"menu-switch-view",onClick:()=>{p(h==="full"?null:"full"),c.delete("media"),c.delete("media-only"),h==="full"?c.delete("view"):c.set("view","full"),r(c)},children:[e(I,{icon:{"":"layout5",full:"layout4"}[h||""]}),e("span",{children:o(h==="full"?{id:"+/xYEI"}:{id:"2LiWsE"})})]}),e(ye,{onClick:()=>{Array.from(D.current.querySelectorAll(".spoiler-button:not(.spoiling), .spoiler-media-button:not(.spoiling)")).forEach(O=>{O.click()})},children:[e(I,{icon:"eye-open"})," ",e("span",{children:e(f,{id:"8r8KmB"})})]}),e(Ve,{}),e(gi,{className:"plain",children:e(f,{id:"Rsjgm0"})}),e(ye,{disabled:!K||Y,onClick:()=>{const N=Jl(B.url);N?location.hash=N:alert(o({id:"9J6biQ"}))},children:[e(I,{icon:"transfer"}),e("small",{class:"menu-double-lines",children:o(K?{id:"Kp9SAs",values:{0:un.toUnicode(K)}}:{id:"lb07+k"})})]})]}),e(ge,{class:"button plain deck-close",to:i,children:e(I,{icon:"x",size:"xl",alt:o({id:"yz7wBu"})})})]})]})}),T.length&&B?e("ul",{class:`timeline flat contextual grow ${k==="loading"?"loading":""}`,children:[xe,ue>0&&e("li",{class:"descendant descendant-more",children:e("button",{type:"button",class:"plain block show-more",disabled:k==="loading",onClick:()=>J(N=>N+yn),style:{marginBlockEnd:"6em"},"data-state-post-ids":De.join(" "),children:[e("div",{class:"ib avatars-bunch",children:T.slice(te,te+5).map(N=>e(mt,{url:N.account.avatarStatic},N.id))})," ",e("div",{class:"ib",children:[e(f,{id:"uXRAkV"})," ",e("span",{class:"tag",children:ue>yn?`${yn}+`:ue})]})]})})]}):e(U,{children:[k==="loading"&&e("ul",{class:"timeline flat contextual grow loading",children:e("li",{children:e(Ge,{skeleton:!0,size:"l"})})}),k==="error"&&e("p",{class:"ui-state",children:[e(f,{id:"JWxodU"}),e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>{x.reloadStatusPage++},children:e(f,{id:"KDw4GX"})})]})]})]})}function wo({replies:n,instance:i,hasParentThread:s,level:o,accWeight:c,openAll:r,parentLink:u}){const{_:l}=le(),[d,a]=vt(),h=C=>C.reduce((E,R)=>{const{repliesCount:F,replies:D}=R,W=(D==null?void 0:D.length)||F;return E+W+h(D||[])},0),p=n.length+h(n),m=n.length===p,g=n.map(C=>C.account).filter((C,E,R)=>R.findIndex(F=>F.id===C.id)===E).slice(0,3),v=Ae(()=>n==null?void 0:n.reduce((C,E)=>C+(E==null?void 0:E.weight),c),[c,n==null?void 0:n.length]);let y=!1;(r||v<=ud||!s&&p===1&&on(n[0])<2)&&(y=!0);const w=ci[n[0].id],b=it((C,E,R,F)=>{C.preventDefault(),C.stopPropagation(),a({media:E+1,mediaStatusID:F.id})},[]),S=j();St(()=>{var E;function C(R){R.target.dataset.scrollLeft=R.target.scrollLeft}return(E=S.current)==null||E.addEventListener("scroll",C,{passive:!0}),()=>{var R;(R=S.current)==null||R.removeEventListener("scroll",C)}},[]);const[_,T]=M(w||y);Q(()=>{let C;return!w&&!y&&(C=setTimeout(()=>T(!0),100)),()=>clearTimeout(C)},[w,y]);const A=y?"div":"details",k=A==="details";return e(A,{ref:S,class:"replies",open:k?w||y:void 0,onToggle:k?C=>{const{open:E}=C.target;ci[n[0].id]=E}:void 0,style:{"--comments-level":o},"data-comments-level":o,"data-comments-level-overflow":o>4,children:[!y&&e("summary",{class:"replies-summary",hidden:y,children:[e("span",{class:"avatars",children:g.map(C=>e(mt,{url:C.avatarStatic,title:`${C.displayName} @${C.username}`,squircle:C==null?void 0:C.bot},C.id))}),e("span",{class:"replies-counts",children:[e("b",{children:e(f,{id:"DOQUen",values:{0:n.length,1:Qe(n.length)},components:{0:e("span",{title:n.length})}})}),!m&&p>1&&e(U,{children:[" ","·"," ",e("span",{children:e(f,{id:"qSQQSe",values:{0:Qe(p),totalComments:p},components:{0:e("span",{title:p})}})})]})]}),e(I,{icon:"chevron-down",class:"replies-summary-chevron"}),!!u&&e(ge,{class:"replies-parent-link",to:u.to,onClick:u.onClick,title:l({id:"ZlV82A"}),children:"»"})]}),_&&e("ul",{children:n.map(C=>{var E,R;return e("li",{children:[e("div",{class:"status-focus",tabIndex:0,children:[e(Ge,{statusID:C.id,instance:i,withinContext:!0,size:"s",enableTranslate:!0,onMediaClick:b,showActionsBar:!0}),!((E=C.replies)!=null&&E.length)&&C.repliesCount>0&&e("div",{class:"replies-link",children:[e(I,{icon:"comment2",alt:l({id:"N8UzTV"})})," ",e("span",{title:C.repliesCount,children:Qe(C.repliesCount)})]})]}),((R=C.replies)==null?void 0:R.length)&&e(wo,{instance:i,replies:C.replies,level:C.level,accWeight:y?v:C.weight,openAll:r,parentLink:{to:i?`/${i}/s/${C.id}`:`/s/${C.id}`,onClick:()=>{Cn(C.id)}}})]},C.id)})})]})}const md=140,gd=35,yd=70,bd=140,ai=new Map;function on(n){var g,v;const i=ai.get(n.id);if(i)return i;const{spoilerText:s,content:o,mediaAttachments:c,poll:r,card:u}=n,l=Ns(s+o),d=c!=null&&c.length?md:0,a=(((g=r==null?void 0:r.options)==null?void 0:g.length)||0)*gd,h=u&&(c!=null&&c.length||(v=r==null?void 0:r.options)!=null&&v.length)?0:yd,m=(l+d+a+h)/bd;return ai.set(n.id,m),m}const vd=ut(hd);function wd(){const n=Mt(),{id:i,instance:s}=n;return e(vd,{id:i,instance:s})}const kd=""+new URL("boosts-carousel-BiOaNdMT.jpg",import.meta.url).href,Sd=""+new URL("grouped-notifications-DFgwVVj3.jpg",import.meta.url).href,_d=""+new URL("multi-column-ROck0NVt.jpg",import.meta.url).href,Cd=""+new URL("multi-hashtag-timeline-DH5INVHi.jpg",import.meta.url).href,Id=""+new URL("nested-comments-thread-hv59kZLc.jpg",import.meta.url).href,Td="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%20102%2028'%3e%3cpath%20fill='none'%20d='M0%200h101.5v27.5H0z'/%3e%3cg%20fill-rule='nonzero'%3e%3cpath%20fill='url(%23a)'%20d='M2.32%2021.85c1.4%200%202.21-.85%202.21-2.3v-4.64H8.5c4.45%200%207.54-2.9%207.54-7.24%200-4.35-2.98-7.24-7.32-7.24h-6.4C.93.43.11%201.28.11%202.73v16.82c0%201.45.82%202.3%202.21%202.3Zm2.21-10.4V3.94h3c2.54%200%204%201.34%204%203.75s-1.47%203.76-4%203.76h-3Z'/%3e%3cpath%20fill='url(%23b)'%20d='M20.52%2021.88c1.25%200%202.13-.76%202.13-2.23v-7.04c0-2.07%201.2-3.49%203.21-3.49%201.95%200%202.95%201.23%202.95%203.25v7.28c0%201.47.89%202.23%202.13%202.23%201.26%200%202.14-.76%202.14-2.23v-8.18c0-3.64-1.99-5.9-5.48-5.9-2.38%200-4.1%201.12-4.93%203.1h-.09V2.3c0-1.38-.78-2.2-2.1-2.2-1.31%200-2.1.82-2.1%202.2v17.34c0%201.47.9%202.23%202.14%202.23Z'/%3e%3cpath%20fill='url(%23c)'%20d='M40.45%2021.82c1.96%200%203.93-.98%204.8-2.65h.1v.8c.08%201.27.89%201.91%202.05%201.91%201.21%200%202.08-.73%202.08-2.15v-8.95c0-3.17-2.63-5.25-6.65-5.25-3.26%200-5.78%201.16-6.5%203.04-.15.32-.23.63-.23.96%200%20.97.75%201.64%201.79%201.64.69%200%201.23-.26%201.7-.79.95-1.23%201.74-1.65%203.04-1.65%201.62%200%202.64.85%202.64%202.31v1.04l-3.95.24c-3.93.23-6.13%201.88-6.13%204.74%200%202.83%202.27%204.76%205.26%204.76Zm1.4-3.09c-1.43%200-2.4-.73-2.4-1.9%200-1.12.91-1.83%202.51-1.95l3.31-.2v1.14c0%201.7-1.54%202.91-3.41%202.91Z'/%3e%3cpath%20fill='url(%23d)'%20d='M54.37%2021.88c1.26%200%202.14-.76%202.14-2.23v-7.09c0-2.03%201.21-3.44%203.13-3.44s2.89%201.17%202.89%203.22v7.31c0%201.47.88%202.23%202.14%202.23%201.24%200%202.13-.76%202.13-2.23v-8.2c0-3.68-1.96-5.87-5.45-5.87-2.41%200-4%201.07-4.83%203.01h-.09v-.87c0-1.35-.85-2.17-2.14-2.17-1.28%200-2.06.82-2.06%202.15v11.95c0%201.47.9%202.23%202.14%202.23Z'/%3e%3cpath%20fill='url(%23e)'%20d='M71.65%2027.17c1.26%200%202.14-.76%202.14-2.23v-6h.09a5.15%205.15%200%200%200%204.88%202.88c3.92%200%206.35-3.05%206.35-8.1%200-5.07-2.44-8.1-6.43-8.1a5.12%205.12%200%200%200-4.86%202.99h-.09v-.85c0-1.45-.88-2.21-2.1-2.21-1.24%200-2.11.76-2.11%202.2v17.2c0%201.46.89%202.22%202.13%202.22Zm5.6-8.8c-2.1%200-3.47-1.8-3.47-4.65%200-2.81%201.37-4.67%203.47-4.67%202.14%200%203.49%201.83%203.49%204.67%200%202.86-1.35%204.66-3.5%204.66Z'/%3e%3cpath%20fill='url(%23f)'%20d='M89.61%2027.39c3.44%200%205.26-1.5%206.73-5.55l4.81-13.1a4%204%200%200%200%20.24-1.26c0-1.13-.85-1.93-2.08-1.93-1.1%200-1.71.51-2.07%201.7l-3.4%2010.9h-.08L90.35%207.28c-.36-1.25-.94-1.73-2.07-1.73-1.26%200-2.21.83-2.21%201.99%200%20.35.09.82.25%201.26l5%2013.21-.21.56c-.52%201.1-1.32%201.42-2.07%201.42l-.75-.01c-.96%200-1.56.54-1.56%201.4%200%201.29%201%202%202.88%202Z'/%3e%3c/g%3e%3cdefs%3e%3cradialGradient%20id='a'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='b'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='c'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='d'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='e'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='f'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e",Ad={BASE_URL:"./",DEV:!1,MODE:"production",PHANPY_CLIENT_NAME:"Phanpy",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",PHANPY_TRANSLANG_INSTANCES:"translang.phanpy.social",PHANPY_WEBSITE:"https://phanpy.social",PROD:!0,SSR:!1,VITE_APP_ENV:"production"},{PHANPY_DEFAULT_INSTANCE:nn,PHANPY_WEBSITE:fs,PHANPY_PRIVACY_POLICY_URL:xd,PHANPY_DEFAULT_INSTANCE_REGISTRATION_URL:ps}=Ad,ms=fs?fs.replace(/https?:\/\//g,"").replace(/\/$/,""):null,gs=`${"2025-06-12T23:49:22.800Z".slice(0,10).replace(/-/g,".")}.43d0d1e`;function ko(){const{_:n}=le();return tt(null,["/","/welcome"]),e("main",{id:"welcome",children:[e("div",{class:"hero-container",children:[e("div",{class:"hero-content",children:[e("h1",{children:[e("img",{src:_i,alt:"",width:"160",height:"160",style:{aspectRatio:"1/1",marginBlockEnd:-16}}),e("img",{src:Td,alt:"Phanpy",width:"200"})]}),e("p",{class:"desc",children:e(f,{id:"Ogtv0V"})}),e("p",{children:e(ge,{to:nn?`/login?instance=${nn}&submit=1`:"/login",class:"button",children:n(nn?{id:"sQia9P"}:{id:"ZLoGls"})})}),nn&&ps&&e("p",{children:e("a",{href:ps,class:"button plain5",children:e(f,{id:"e+RpCP"})})}),!nn&&e("p",{class:"insignificant",children:e("small",{children:e(f,{id:"fvAsUK",components:{0:e("br",{})}})})})]}),(ms||gs)&&e("p",{class:"app-site-version",children:e("small",{children:[ms," ",gs]})}),e("p",{children:e(f,{id:"BskFI2",components:{0:e("a",{href:"https://github.com/cheeaun/phanpy",target:"_blank"}),1:e("a",{href:"https://mastodon.social/@cheeaun",target:"_blank",onClick:i=>{i.preventDefault(),x.showAccount="cheeaun@mastodon.social"}}),2:e("a",{href:xd,target:"_blank"})}})}),e("div",{children:e(Ci,{})})]}),e("div",{id:"why-container",children:e("div",{class:"sections",children:[e("section",{children:[e("img",{src:kd,alt:n({id:"S5cYrQ"}),loading:"lazy"}),e("h4",{children:e(f,{id:"Tu+sCN"})}),e("p",{children:e(f,{id:"e2uVlo"})})]}),e("section",{children:[e("img",{src:Id,alt:n({id:"CGQ27z"}),loading:"lazy"}),e("h4",{children:e(f,{id:"cYE45+"})}),e("p",{children:e(f,{id:"Pc7QKh"})})]}),e("section",{children:[e("img",{src:Sd,alt:n({id:"rnrM7k"}),loading:"lazy"}),e("h4",{children:e(f,{id:"4RRMre"})}),e("p",{children:e(f,{id:"8GMtDr"})})]}),e("section",{children:[e("img",{src:_d,alt:n({id:"VLKtvP"}),loading:"lazy"}),e("h4",{children:e(f,{id:"pEkad9"})}),e("p",{children:e(f,{id:"t7Py5R"})})]}),e("section",{children:[e("img",{src:Cd,alt:n({id:"wOax6E"}),loading:"lazy"}),e("h4",{children:e(f,{id:"Wi1Ov0"})}),e("p",{children:e(f,{id:"tS2i+h"})})]})]})})]})}const Ed=window.alert;window.__nativeAlert||(window.__nativeAlert=Ed);window.alert=function(n){n instanceof Error&&(n!=null&&n.message)&&(n=n.message),typeof n!="string"&&(n=JSON.stringify(n));const i=lc({text:n,className:"alert",gravity:"top",position:"center",duration:1e4,offset:{y:48},onClick:()=>{i.hideToast()}});i.showToast()};window.__STATES__=x;window.__STATES_STATS__=()=>{const n=["statuses","accounts","spoilers","unfurledLinks","statusQuotes"],i={};n.forEach(c=>{i[c]=Object.keys(x[c]).length});const{statuses:s}=x,o=[];for(const c in s)document.querySelector(`[data-state-post-id~="${c}"], [data-state-post-ids~="${c}"]`)||o.push(c)};setInterval(()=>{if(!window.__IDLE__)return;const{statuses:n,unfurledLinks:i,notifications:s}=x;let o=0;const{instance:c}=re();for(const r in n){if(!window.__IDLE__)break;try{const u=document.querySelector(`[data-state-post-id~="${r}"], [data-state-post-ids~="${r}"]`),l=s.some(d=>{var a;return r===lt((a=d.status)==null?void 0:a.id,c)});if(!u&&!l){delete x.statuses[r],delete x.statusQuotes[r];for(const d in i){const a=i[d];if(lt(a.id,a.instance)===r){delete x.unfurledLinks[d];break}}o++}}catch{}}},15*60*1e3);setTimeout(()=>{for(const n in Kt)setTimeout(()=>{var i,s,o,c,r,u;Array.isArray(Kt[n])?(s=(i=Kt[n])[0])==null||s.call(i):typeof Kt[n]=="object"?(c=(o=Kt[n]).module)==null||c.call(o):(u=(r=Kt)[n])==null||u.call(r)},1)},5e3);(()=>{window.__IDLE__=!0;const n=["mousemove","mousedown","resize","keydown","touchstart","pointerdown","pointermove","wheel"],i=()=>{window.__IDLE__=!0},o=Ps(i,3e3),c=()=>{window.__IDLE__=!1,o()};n.forEach(r=>{window.addEventListener(r,c,{passive:!0,capture:!0})}),window.addEventListener("blur",i,{passive:!0}),document.documentElement.addEventListener("mouseleave",r=>{!r.relatedTarget&&!r.toElement&&i()},{passive:!0})})();const Rd=/iPad|iPhone|iPod/.test(navigator.userAgent);Rd&&document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible"){if(document.getElementsByClassName("media-modal-container").length>0)return;const i=Ue.local.get("theme");let s;if(i){if(s=document.querySelector('meta[name="theme-color"][data-theme-setting="manual"]'),s){const o=s.content,c=i==="light"?s.dataset.themeLightColorTemp:s.dataset.themeDarkColorTemp;s.content=c||"",setTimeout(()=>{s.content=o},10)}}else{const o=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(s=document.querySelector(`meta[name="theme-color"][media*="${o}"]`),s){const c=s.dataset.content,r=s.dataset.contentTemp;s.content=r||"",setTimeout(()=>{s.content=c},10)}}}});{const n=Ue.local.get("theme");if(n){document.documentElement.classList.add(`is-${n}`),document.querySelector('meta[name="color-scheme"]').setAttribute("content",n||"dark light");const s=document.querySelector('meta[data-theme-setting="manual"]');s&&(s.name="theme-color",s.content=n==="light"?s.dataset.themeLightColor:s.dataset.themeDarkColor),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(c=>{c.name=""})}const i=Ue.local.get("textSize");i&&document.documentElement.style.setProperty("--text-size",`${i}px`)}ws(x,n=>{var i;for(const[s,o,c,r]of n){if(o.join(".")==="settings.shortcutsViewMode"){const u=document.getElementById("app");u&&(u.dataset.shortcutsViewMode=(i=x.shortcuts)!=null&&i.length?c:"")}o.join(".")==="settings.cloakMode"&&document.body.classList.toggle("cloak",c)}});const bn=new Map;window.__BENCH_RESULTS=new Map;window.__BENCHMARK={start(n){},end(n){}};function Ld(){const[n,i]=M(!1),[s,o]=M("loading");__BENCHMARK.start("app-init"),__BENCHMARK.start("time-to-following"),__BENCHMARK.start("time-to-home"),__BENCHMARK.start("time-to-isLoggedIn"),le(),Q(()=>{const r=Ue.local.get("instanceURL"),u=decodeURIComponent((window.location.search.match(/code=([^&]+)/)||[,""])[1]);if(u){window.history.replaceState({},document.title,window.location.pathname||"/");const{client_id:l,client_secret:d,vapid_key:a}=Cs(r)||{},h=Tn(r)||a,p=Ue.sessionCookie.get("codeVerifier");(async()=>{o("loading");const{access_token:m}=await Hc({instanceURL:r,client_id:l,client_secret:d,code:u,code_verifier:p||void 0});if(m){const g=zo({instance:r,accessToken:m});await Promise.allSettled([Hn(g),qn(g,r),Uo(g,r,m,h)]),$i(),window.__IGNORE_GET_ACCOUNT_ERROR__=!0,i(!0),o("default")}else o("error");__BENCHMARK.end("app-init")})()}else{window.__IGNORE_GET_ACCOUNT_ERROR__=!0;const l=decodeURIComponent((window.location.search.match(/account=([^&]+)/)||[,""])[1]);let d;if(l&&(d=Bo(l),d&&(In(d.info.id),window.history.replaceState({},document.title,window.location.pathname||"/"))),d||(d=di()),d){In(d.info.id);const{client:a}=re({account:d}),{instance:h}=a;$i(),o("loading"),(async()=>{try{Fo()&&Ko(h)?(Hn(a),qn(a,h)):await Promise.allSettled([Hn(a),qn(a,h)])}catch{}finally{i(!0),o("default"),__BENCHMARK.end("app-init")}})()}else o("default"),__BENCHMARK.end("app-init")}Ue.sessionCookie.del("clientID"),Ue.sessionCookie.del("clientSecret"),Ue.sessionCookie.del("codeVerifier")},[]);let c=Jt();return x.currentLocation=c.pathname,Q(ni,[c,n]),/\/https?:/.test(c.pathname)?e(Ql,{}):s==="loading"?e(Be,{id:"loader-root"}):e(U,{children:[e($d,{isLoggedIn:n}),e(Nd,{isLoggedIn:n}),e(hi,{children:e(Xe,{path:"/:instance?/s/:id",element:e(wd,{})})}),n&&e(pc,{}),n&&e(_r,{}),e(gr,{}),n&&e(wr,{}),e(hc,{isLoggedIn:n}),e(kr,{onClose:ni}),e(mc,{})]})}function Md({isLoggedIn:n}){return n&&__BENCHMARK.end("time-to-isLoggedIn"),n?e(Zl,{}):e(ko,{})}const $d=ut(({isLoggedIn:n})=>{const i=Jt(),s=Ae(()=>{const{pathname:o}=i;return!/^\/(login|welcome|_sandbox)/i.test(o)},[i]);return e(hi,{location:s||i,children:[e(Xe,{path:"/",element:e(Md,{isLoggedIn:n})}),e(Xe,{path:"/login",element:e(sd,{})}),e(Xe,{path:"/welcome",element:e(ko,{})}),void 0]})});function ys(){return x.prevLocation||null}function Nd({isLoggedIn:n}){const i=Jt(),s=j(ys());return Ae(()=>cn("/:instance/s/:id",i.pathname)||cn("/s/:id",i.pathname),[i.pathname,cn])?s.current||(s.current=ys()):s.current=null,e(hi,{location:s.current||i,children:[n&&e(U,{children:[e(Xe,{path:"/notifications",element:e(mo,{})}),e(Xe,{path:"/mentions",element:e(lo,{})}),e(Xe,{path:"/following",element:e(Ri,{})}),e(Xe,{path:"/b",element:e(to,{})}),e(Xe,{path:"/f",element:e(no,{})}),e(Xe,{path:"/l",children:[e(Xe,{index:!0,element:e(ed,{})}),e(Xe,{path:":id",element:e(oo,{})})]}),e(Xe,{path:"/fh",element:e(pl,{})}),e(Xe,{path:"/sp",element:e(cd,{})}),e(Xe,{path:"/ft",element:e(dl,{})}),e(Xe,{path:"/catchup",element:e(Jr,{})}),e(Xe,{path:"/annual_report/:year",element:e(qr,{})})]}),e(Xe,{path:"/:instance?/t/:hashtag",element:e(so,{})}),e(Xe,{path:"/:instance?/a/:id",element:e(Br,{})}),e(Xe,{path:"/:instance?/p",children:[e(Xe,{index:!0,element:e(oi,{})}),e(Xe,{path:"l",element:e(oi,{local:!0})})]}),e(Xe,{path:"/:instance?/trending",element:e(bo,{})}),e(Xe,{path:"/:instance?/search",element:e(go,{})})]})}Ho();qo(e(Yo,{i18n:pe,children:e(jo,{children:e(Ld,{})})}),document.getElementById("app"));setTimeout(()=>{try{Object.keys(localStorage).forEach(n=>{n.startsWith("iconify")&&localStorage.removeItem(n)}),Object.keys(sessionStorage).forEach(n=>{n.startsWith("iconify")&&sessionStorage.removeItem(n)}),localStorage.removeItem("settings:boostsCarousel")}catch{}},5e3);if("serviceWorker"in navigator&&typeof caches<"u"){const i=["icons"];let s=!1;const o=1e4,c=60*60*1e3;async function r(){if(window.__IDLE__)try{const u=await caches.keys();for(const l of u){if(i.includes(l))continue;const d=await caches.open(l),a=await d.keys();if(a.length>50){const h=a.slice(50);for(const p of h)await d.delete(p)}}s=!0}catch{}setTimeout(r,s?c:o)}setTimeout(r,o)}window.__CLOAK__=()=>{document.body.classList.toggle("cloak")};
+//# sourceMappingURL=main-BcxE7N7D.js.map
diff --git a/assets/main-BcxE7N7D.js.map b/assets/main-BcxE7N7D.js.map
new file mode 100644
index 0000000..1262726
--- /dev/null
+++ b/assets/main-BcxE7N7D.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"main-BcxE7N7D.js","sources":["../../node_modules/just-debounce-it/index.mjs","../../node_modules/swiped-events/src/swiped-events.js","../../src/utils/usePageVisibility.js","../../src/components/background-service.jsx","../../src/components/compose-button.jsx","../../src/components/keyboard-shortcuts-help.jsx","../../node_modules/@formkit/auto-animate/index.mjs","../../node_modules/@formkit/auto-animate/preact/index.mjs","../../src/utils/oauth-pkce.js","../../src/utils/auth.js","../../src/pages/accounts.jsx","../../src/assets/logo.svg","../../src/components/lang-selector.jsx","../../src/utils/push-notifications.js","../../src/pages/settings.jsx","../../src/utils/focus-deck.js","../../src/utils/useLocationChange.js","../../src/utils/lists.js","../../src/components/list-exclusive-badge.jsx","../../src/components/list-add-edit.jsx","../../src/components/account-info.jsx","../../src/components/account-sheet.jsx","../../src/components/drafts.jsx","../../src/components/embed-modal.jsx","../../src/components/generic-accounts.jsx","../../src/components/media-alt-modal.jsx","../../node_modules/chroma-js/src/utils/limit.js","../../node_modules/chroma-js/src/utils/type.js","../../node_modules/chroma-js/src/utils/unpack.js","../../node_modules/chroma-js/src/utils/index.js","../../node_modules/chroma-js/src/utils/multiply-matrices.js","../../node_modules/chroma-js/src/io/lab/lab-constants.js","../../node_modules/chroma-js/src/io/lab/lab2rgb.js","../../node_modules/chroma-js/src/io/oklab/oklab2rgb.js","../../node_modules/chroma-js/src/io/lab/rgb2lab.js","../../node_modules/chroma-js/src/io/oklab/rgb2oklab.js","../../node_modules/chroma-js/src/io/lch/lch2lab.js","../../node_modules/chroma-js/src/io/oklch/oklch2rgb.js","../../node_modules/chroma-js/src/io/lch/lab2lch.js","../../node_modules/chroma-js/src/io/oklch/rgb2oklch.js","../../src/components/media-modal.jsx","../../src/components/report-modal.jsx","../../node_modules/lz-string/libs/lz-string.js","../../src/assets/floating-button.svg","../../src/assets/multi-column.svg","../../src/assets/tab-menu-bar.svg","../../src/utils/followed-tags.js","../../src/components/AsyncText.jsx","../../src/components/shortcuts-settings.jsx","../../src/components/modals.jsx","../../src/components/follow-request-buttons.jsx","../../src/components/notification.jsx","../../src/components/notification-service.jsx","../../src/components/search-form.jsx","../../src/components/search-command.jsx","../../src/components/shortcuts.jsx","../../src/utils/timeline-utils.js","../../src/utils/useScroll.js","../../src/utils/useScrollFn.js","../../src/components/media-post.jsx","../../src/components/nav-menu.jsx","../../src/components/timeline.jsx","../../src/pages/account-statuses.jsx","../../src/pages/annual-report.jsx","../../src/pages/bookmarks.jsx","../../src/assets/features/catch-up.png","../../src/pages/catchup.jsx","../../src/pages/favourites.jsx","../../src/pages/filters.jsx","../../src/pages/followed-hashtags.jsx","../../src/pages/following.jsx","../../src/pages/hashtag.jsx","../../src/pages/list.jsx","../../src/utils/group-notifications.js","../../src/pages/mentions.jsx","../../src/pages/notifications.jsx","../../src/pages/public.jsx","../../src/pages/search.jsx","../../src/pages/trending.jsx","../../src/components/columns.jsx","../../src/pages/home.jsx","../../src/utils/get-instance-status-url.js","../../src/pages/http-route.jsx","../../src/pages/lists.jsx","../../src/data/instances.json?url","../../src/pages/login.jsx","../../src/pages/scheduled-posts.jsx","../../src/pages/status.jsx","../../src/pages/status-route.jsx","../../src/assets/features/boosts-carousel.jpg","../../src/assets/features/grouped-notifications.jpg","../../src/assets/features/multi-column.jpg","../../src/assets/features/multi-hashtag-timeline.jpg","../../src/assets/features/nested-comments-thread.jpg","../../src/assets/logo-text.svg","../../src/pages/welcome.jsx","../../src/utils/toast-alert.js","../../src/app.jsx","../../src/main.jsx"],"sourcesContent":["var functionDebounce = debounce;\n\nfunction debounce(fn, wait, callFirst) {\n var timeout = null;\n var debouncedFn = null;\n\n var clear = function() {\n if (timeout) {\n clearTimeout(timeout);\n\n debouncedFn = null;\n timeout = null;\n }\n };\n\n var flush = function() {\n var call = debouncedFn;\n clear();\n\n if (call) {\n call();\n }\n };\n\n var debounceWrapper = function() {\n if (!wait) {\n return fn.apply(this, arguments);\n }\n\n var context = this;\n var args = arguments;\n var callNow = callFirst && !timeout;\n clear();\n\n debouncedFn = function() {\n fn.apply(context, args);\n };\n\n timeout = setTimeout(function() {\n timeout = null;\n\n if (!callNow) {\n var call = debouncedFn;\n debouncedFn = null;\n\n return call();\n }\n }, wait);\n\n if (callNow) {\n return debouncedFn();\n }\n };\n\n debounceWrapper.cancel = clear;\n debounceWrapper.flush = flush;\n\n return debounceWrapper;\n}\n\nexport {functionDebounce as default};\n","/*!\n * swiped-events.js - v@version@\n * Pure JavaScript swipe events\n * https://github.com/john-doherty/swiped-events\n * @inspiration https://stackoverflow.com/questions/16348031/disable-scrolling-when-touch-moving-certain-element\n * @author John Doherty \n * @license MIT\n */\n(function (window, document) {\n\n 'use strict';\n\n // patch CustomEvent to allow constructor creation (IE/Chrome)\n if (typeof window.CustomEvent !== 'function') {\n\n window.CustomEvent = function (event, params) {\n\n params = params || { bubbles: false, cancelable: false, detail: undefined };\n\n var evt = document.createEvent('CustomEvent');\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return evt;\n };\n\n window.CustomEvent.prototype = window.Event.prototype;\n }\n\n document.addEventListener('touchstart', handleTouchStart, false);\n document.addEventListener('touchmove', handleTouchMove, false);\n document.addEventListener('touchend', handleTouchEnd, false);\n\n var xDown = null;\n var yDown = null;\n var xDiff = null;\n var yDiff = null;\n var timeDown = null;\n var startEl = null;\n var touchCount = 0;\n\n /**\n * Fires swiped event if swipe detected on touchend\n * @param {object} e - browser event object\n * @returns {void}\n */\n function handleTouchEnd(e) {\n\n // if the user released on a different target, cancel!\n if (startEl !== e.target) return;\n\n var swipeThreshold = parseInt(getNearestAttribute(startEl, 'data-swipe-threshold', '20'), 10); // default 20 units\n var swipeUnit = getNearestAttribute(startEl, 'data-swipe-unit', 'px'); // default px\n var swipeTimeout = parseInt(getNearestAttribute(startEl, 'data-swipe-timeout', '500'), 10); // default 500ms\n var timeDiff = Date.now() - timeDown;\n var eventType = '';\n var changedTouches = e.changedTouches || e.touches || [];\n\n if (swipeUnit === 'vh') {\n swipeThreshold = Math.round((swipeThreshold / 100) * document.documentElement.clientHeight); // get percentage of viewport height in pixels\n }\n if (swipeUnit === 'vw') {\n swipeThreshold = Math.round((swipeThreshold / 100) * document.documentElement.clientWidth); // get percentage of viewport height in pixels\n }\n\n if (Math.abs(xDiff) > Math.abs(yDiff)) { // most significant\n if (Math.abs(xDiff) > swipeThreshold && timeDiff < swipeTimeout) {\n if (xDiff > 0) {\n eventType = 'swiped-left';\n }\n else {\n eventType = 'swiped-right';\n }\n }\n }\n else if (Math.abs(yDiff) > swipeThreshold && timeDiff < swipeTimeout) {\n if (yDiff > 0) {\n eventType = 'swiped-up';\n }\n else {\n eventType = 'swiped-down';\n }\n }\n\n if (eventType !== '') {\n\n var eventData = {\n dir: eventType.replace(/swiped-/, ''),\n touchType: (changedTouches[0] || {}).touchType || 'direct',\n fingers: touchCount, // Number of fingers used\n xStart: parseInt(xDown, 10),\n xEnd: parseInt((changedTouches[0] || {}).clientX || -1, 10),\n yStart: parseInt(yDown, 10),\n yEnd: parseInt((changedTouches[0] || {}).clientY || -1, 10)\n };\n\n // fire `swiped` event event on the element that started the swipe\n startEl.dispatchEvent(new CustomEvent('swiped', { bubbles: true, cancelable: true, detail: eventData }));\n\n // fire `swiped-dir` event on the element that started the swipe\n startEl.dispatchEvent(new CustomEvent(eventType, { bubbles: true, cancelable: true, detail: eventData }));\n }\n\n // reset values\n xDown = null;\n yDown = null;\n timeDown = null;\n }\n /**\n * Records current location on touchstart event\n * @param {object} e - browser event object\n * @returns {void}\n */\n function handleTouchStart(e) {\n\n // if the element has data-swipe-ignore=\"true\" we stop listening for swipe events\n if (e.target.getAttribute('data-swipe-ignore') === 'true') return;\n\n startEl = e.target;\n\n timeDown = Date.now();\n xDown = e.touches[0].clientX;\n yDown = e.touches[0].clientY;\n xDiff = 0;\n yDiff = 0;\n touchCount = e.touches.length;\n }\n\n /**\n * Records location diff in px on touchmove event\n * @param {object} e - browser event object\n * @returns {void}\n */\n function handleTouchMove(e) {\n\n if (!xDown || !yDown) return;\n\n var xUp = e.touches[0].clientX;\n var yUp = e.touches[0].clientY;\n\n xDiff = xDown - xUp;\n yDiff = yDown - yUp;\n }\n\n /**\n * Gets attribute off HTML element or nearest parent\n * @param {object} el - HTML element to retrieve attribute from\n * @param {string} attributeName - name of the attribute\n * @param {any} defaultValue - default value to return if no match found\n * @returns {any} attribute value or defaultValue\n */\n function getNearestAttribute(el, attributeName, defaultValue) {\n\n // walk up the dom tree looking for attributeName\n while (el && el !== document.documentElement) {\n\n var attributeValue = el.getAttribute(attributeName);\n\n if (attributeValue) {\n return attributeValue;\n }\n\n el = el.parentNode;\n }\n\n return defaultValue;\n }\n\n}(window, document));\n","import { useEffect, useRef } from 'preact/hooks';\n\nexport default function usePageVisibility(fn = () => {}, deps = []) {\n const savedCallback = useRef(fn);\n useEffect(() => {\n savedCallback.current = fn;\n }, [deps]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n const hidden = document.hidden || document.visibilityState === 'hidden';\n console.log('👀 Page visibility changed', hidden ? 'hidden' : 'visible');\n savedCallback.current(!hidden);\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () =>\n document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, []);\n}\n","import { useLingui } from '@lingui/react/macro';\nimport { memo } from 'preact/compat';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useHotkeys } from 'react-hotkeys-hook';\n\nimport { api } from '../utils/api';\nimport showToast from '../utils/show-toast';\nimport states, { saveStatus } from '../utils/states';\nimport useInterval from '../utils/useInterval';\nimport usePageVisibility from '../utils/usePageVisibility';\n\nconst STREAMING_TIMEOUT = 1000 * 3; // 3 seconds\nconst POLL_INTERVAL = 20_000; // 20 seconds\n\nexport default memo(function BackgroundService({ isLoggedIn }) {\n const { t } = useLingui();\n\n // Notifications service\n // - WebSocket to receive notifications when page is visible\n const [visible, setVisible] = useState(true);\n const visibleTimeout = useRef();\n usePageVisibility((visible) => {\n clearTimeout(visibleTimeout.current);\n if (visible) {\n setVisible(true);\n } else {\n visibleTimeout.current = setTimeout(() => {\n setVisible(false);\n }, POLL_INTERVAL);\n }\n });\n\n const checkLatestNotification = async (masto, instance, skipCheckMarkers) => {\n if (states.notificationsLast) {\n const notificationsIterator = masto.v1.notifications\n .list({\n limit: 1,\n sinceId: states.notificationsLast.id,\n })\n .values();\n const { value: notifications } = await notificationsIterator.next();\n if (notifications?.length) {\n if (skipCheckMarkers) {\n states.notificationsShowNew = true;\n } else {\n let lastReadId;\n try {\n const markers = await masto.v1.markers.fetch({\n timeline: 'notifications',\n });\n lastReadId = markers?.notifications?.lastReadId;\n } catch (e) {}\n if (lastReadId) {\n states.notificationsShowNew = notifications[0].id !== lastReadId;\n } else {\n states.notificationsShowNew = true;\n }\n }\n }\n }\n };\n\n useEffect(() => {\n let sub;\n let streamTimeout;\n let pollNotifications;\n if (isLoggedIn && visible) {\n const { masto, streaming, instance } = api();\n (async () => {\n // 1. Get the latest notification\n await checkLatestNotification(masto, instance);\n\n let hasStreaming = false;\n // 2. Start streaming\n if (streaming) {\n streamTimeout = setTimeout(() => {\n (async () => {\n try {\n hasStreaming = true;\n sub = streaming.user.notification.subscribe();\n console.log('🎏 Streaming notification', sub);\n for await (const entry of sub) {\n if (!sub) break;\n if (!visible) break;\n console.log('🔔🔔 Notification entry', entry);\n if (entry.event === 'notification') {\n console.log('🔔🔔 Notification', entry);\n saveStatus(entry.payload, instance, {\n skipThreading: true,\n });\n }\n states.notificationsShowNew = true;\n }\n console.log('💥 Streaming notification loop STOPPED');\n } catch (e) {\n hasStreaming = false;\n console.error(e);\n }\n\n if (!hasStreaming) {\n console.log('🎏 Streaming failed, fallback to polling');\n pollNotifications = setInterval(() => {\n checkLatestNotification(masto, instance, true);\n }, POLL_INTERVAL);\n }\n })();\n }, STREAMING_TIMEOUT);\n }\n })();\n }\n return () => {\n sub?.unsubscribe?.();\n sub = null;\n clearTimeout(streamTimeout);\n clearInterval(pollNotifications);\n };\n }, [visible, isLoggedIn]);\n\n // Check for updates service\n const lastCheckDate = useRef();\n const checkForUpdates = () => {\n lastCheckDate.current = Date.now();\n console.log('✨ Check app update');\n fetch('./version.json')\n .then((r) => r.json())\n .then((info) => {\n if (info) states.appVersion = info;\n })\n .catch((e) => {\n console.error(e);\n });\n };\n useInterval(checkForUpdates, visible && 1000 * 60 * 30); // 30 minutes\n usePageVisibility((visible) => {\n if (visible) {\n if (!lastCheckDate.current) {\n checkForUpdates();\n } else {\n const diff = Date.now() - lastCheckDate.current;\n if (diff > 1000 * 60 * 60) {\n // 1 hour\n checkForUpdates();\n }\n }\n }\n });\n\n // Global keyboard shortcuts \"service\"\n useHotkeys(\n 'shift+alt+k',\n (e) => {\n // Need modifers check due to useKey: true\n if (!e.shiftKey || !e.altKey) return;\n\n const currentCloakMode = states.settings.cloakMode;\n states.settings.cloakMode = !currentCloakMode;\n showToast({\n text: currentCloakMode ? t`Cloak mode disabled` : t`Cloak mode enabled`,\n });\n },\n {\n useKey: true,\n ignoreEventWhen: (e) => e.metaKey || e.ctrlKey,\n },\n );\n\n return null;\n});\n","import { Trans, useLingui } from '@lingui/react/macro';\nimport { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { useHotkeys } from 'react-hotkeys-hook';\nimport { useLongPress } from 'use-long-press';\nimport { useSnapshot } from 'valtio';\n\nimport { api } from '../utils/api';\nimport niceDateTime from '../utils/nice-date-time';\nimport openCompose from '../utils/open-compose';\nimport openOSK from '../utils/open-osk';\nimport pmem from '../utils/pmem';\nimport safeBoundingBoxPadding from '../utils/safe-bounding-box-padding';\nimport showCompose from '../utils/show-compose';\nimport states from '../utils/states';\nimport statusPeek from '../utils/status-peek';\nimport { getCurrentAccountID } from '../utils/store-utils';\n\nimport Icon from './icon';\nimport Loader from './loader';\nimport MenuLink from './menu-link';\nimport RelativeTime from './relative-time';\nimport SubMenu2 from './submenu2';\n\n// Function to fetch the latest posts from the current user\n// Use pmem to memoize fetch results for 1 minute\nconst fetchLatestPostsMemoized = pmem(\n async (masto, currentAccountID) => {\n const statusesIterator = masto.v1.accounts\n .$select(currentAccountID)\n .statuses.list({\n limit: 3,\n exclude_replies: true,\n exclude_reblogs: true,\n })\n .values();\n const { value } = await statusesIterator.next();\n return value || [];\n },\n { maxAge: 60000 },\n); // 1 minute cache\n\nexport default function ComposeButton() {\n const { t } = useLingui();\n const snapStates = useSnapshot(states);\n const { masto } = api();\n\n // Context menu state\n const [menuOpen, setMenuOpen] = useState(false);\n const [latestPosts, setLatestPosts] = useState([]);\n const [loadingPosts, setLoadingPosts] = useState(false);\n const buttonRef = useRef(null);\n const menuRef = useRef(null);\n\n const columnMode = snapStates.settings.shortcutsViewMode === 'multi-column';\n\n function handleButton(e) {\n // useKey will even listen to Shift\n // e.g. press Shift (without c) will trigger this 😱\n if (e.key && e.key.toLowerCase() !== 'c') return;\n\n if (snapStates.composerState.minimized) {\n states.composerState.minimized = false;\n openOSK();\n return;\n }\n\n const composeDataElements = document.querySelectorAll('data.compose-data');\n // If there's a lot of them, ignore\n const opts =\n !columnMode && composeDataElements.length === 1\n ? JSON.parse(composeDataElements[0].value)\n : undefined;\n\n if (e.shiftKey) {\n const newWin = openCompose(opts);\n\n if (!newWin) {\n states.showCompose = opts || true;\n }\n } else {\n openOSK();\n states.showCompose = opts || true;\n }\n }\n\n useHotkeys('c, shift+c', handleButton, {\n useKey: true,\n ignoreEventWhen: (e) => {\n const hasModal = !!document.querySelector('#modal-container > *');\n return hasModal || e.metaKey || e.ctrlKey || e.altKey;\n },\n });\n\n // Setup longpress handler to open context menu\n const bindLongPress = useLongPress(\n () => {\n setMenuOpen(true);\n },\n {\n threshold: 600,\n },\n );\n\n const fetchLatestPosts = useCallback(async () => {\n try {\n setLoadingPosts(true);\n const currentAccountID = getCurrentAccountID();\n if (!currentAccountID) {\n return;\n }\n const posts = await fetchLatestPostsMemoized(masto, currentAccountID);\n setLatestPosts(posts);\n } catch (error) {\n } finally {\n setLoadingPosts(false);\n }\n }, [masto]);\n\n // Function to handle opening the compose window to reply to a post\n const handleReplyToPost = useCallback((post) => {\n showCompose({\n replyToStatus: post,\n });\n setMenuOpen(false);\n }, []);\n\n useEffect(() => {\n if (menuOpen) {\n fetchLatestPosts();\n }\n }, [fetchLatestPosts, menuOpen]);\n\n return (\n <>\n \n setMenuOpen(false)}\n direction=\"top\"\n gap={8} // Add gap between menu and button\n unmountOnClose\n portal={{\n target: document.body,\n }}\n boundingBoxPadding={safeBoundingBoxPadding()}\n containerProps={{\n style: {\n zIndex: 19,\n },\n onClick: () => {\n menuRef.current?.closeMenu?.();\n },\n }}\n submenuOpenDelay={600}\n >\n \n {' '}\n \n Scheduled Posts\n \n \n \n \n {' '}\n \n Add to thread\n \n {loadingPosts ? '…' : }\n >\n }\n >\n {latestPosts.length > 0 &&\n latestPosts.map((post) => {\n const createdDate = new Date(post.createdAt);\n const isWithinDay =\n new Date().getTime() - createdDate.getTime() < 86400000;\n\n return (\n \n );\n })}\n \n \n >\n );\n}\n","import './keyboard-shortcuts-help.css';\n\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { memo } from 'preact/compat';\nimport { useHotkeys } from 'react-hotkeys-hook';\nimport { useSnapshot } from 'valtio';\n\nimport states from '../utils/states';\n\nimport Icon from './icon';\nimport Modal from './modal';\n\nexport default memo(function KeyboardShortcutsHelp() {\n const { t } = useLingui();\n const snapStates = useSnapshot(states);\n\n function onClose() {\n states.showKeyboardShortcutsHelp = false;\n }\n\n useHotkeys(\n '?',\n () => {\n console.log('help');\n states.showKeyboardShortcutsHelp = true;\n },\n {\n useKey: true,\n ignoreEventWhen: (e) => {\n const isCatchUpPage = /\\/catchup/i.test(location.hash);\n return isCatchUpPage || e.metaKey || e.ctrlKey || e.altKey;\n // const hasModal = !!document.querySelector('#modal-container > *');\n // return hasModal;\n },\n },\n );\n\n return (\n !!snapStates.showKeyboardShortcutsHelp && (\n \n \n
\n
\n \n Keyboard shortcuts\n
\n \n
\n \n \n {[\n {\n action: t`Keyboard shortcuts help`,\n keys: ?,\n },\n {\n action: t`Next post`,\n keys: j,\n },\n {\n action: t`Previous post`,\n keys: k,\n },\n {\n action: t`Skip carousel to next post`,\n keys: (\n \n Shift + j\n \n ),\n },\n {\n action: t`Skip carousel to previous post`,\n keys: (\n \n Shift + k\n \n ),\n },\n {\n action: t`Load new posts`,\n keys: .,\n },\n {\n action: t`Open post details`,\n keys: (\n \n Enter or o\n \n ),\n },\n {\n action: (\n \n Expand content warning or\n
\n toggle expanded/collapsed thread\n \n ),\n keys: x,\n },\n {\n action: t`Close post or dialogs`,\n keys: (\n \n Esc or Backspace\n \n ),\n },\n {\n action: t`Focus column in multi-column mode`,\n keys: (\n \n 1 to 9\n \n ),\n },\n {\n action: t`Focus next column in multi-column mode`,\n keys: ],\n },\n {\n action: t`Focus previous column in multi-column mode`,\n keys: [,\n },\n {\n action: t`Compose new post`,\n keys: c,\n },\n {\n action: t`Compose new post (new window)`,\n className: 'insignificant',\n keys: (\n \n Shift + c\n \n ),\n },\n {\n action: t`Send post`,\n keys: (\n \n Ctrl + Enter or ⌘ +{' '}\n Enter\n \n ),\n },\n {\n action: t`Search`,\n keys: /,\n },\n {\n action: t`Reply`,\n keys: r,\n },\n {\n action: t`Reply (new window)`,\n className: 'insignificant',\n keys: (\n \n Shift + r\n \n ),\n },\n {\n action: t`Like (favourite)`,\n keys: (\n \n l or f\n \n ),\n },\n {\n action: t`Boost`,\n keys: (\n \n Shift + b\n \n ),\n },\n {\n action: t`Bookmark`,\n keys: d,\n },\n {\n action: t`Toggle Cloak mode`,\n keys: (\n \n Shift + Alt + k\n \n ),\n },\n ].map(({ action, className, keys }) => (\n \n {action} | \n {keys} | \n
\n ))}\n \n
\n \n
\n \n )\n );\n});\n","/**\n * A set of all the parents currently being observe. This is the only non weak\n * registry.\n */\nconst parents = new Set();\n/**\n * Element coordinates that is constantly kept up to date.\n */\nconst coords = new WeakMap();\n/**\n * Siblings of elements that have been removed from the dom.\n */\nconst siblings = new WeakMap();\n/**\n * Animations that are currently running.\n */\nconst animations = new WeakMap();\n/**\n * A map of existing intersection observers used to track element movements.\n */\nconst intersections = new WeakMap();\n/**\n * Intervals for automatically checking the position of elements occasionally.\n */\nconst intervals = new WeakMap();\n/**\n * The configuration options for each group of elements.\n */\nconst options = new WeakMap();\n/**\n * Debounce counters by id, used to debounce calls to update positions.\n */\nconst debounces = new WeakMap();\n/**\n * All parents that are currently enabled are tracked here.\n */\nconst enabled = new WeakSet();\n/**\n * The document used to calculate transitions.\n */\nlet root;\n/**\n * The root’s XY scroll positions.\n */\nlet scrollX = 0;\nlet scrollY = 0;\n/**\n * Used to sign an element as the target.\n */\nconst TGT = \"__aa_tgt\";\n/**\n * Used to sign an element as being part of a removal.\n */\nconst DEL = \"__aa_del\";\n/**\n * Used to sign an element as being \"new\". When an element is removed from the\n * dom, but may cycle back in we can sign it with new to ensure the next time\n * it is recognized we consider it new.\n */\nconst NEW = \"__aa_new\";\n/**\n * Callback for handling all mutations.\n * @param mutations - A mutation list\n */\nconst handleMutations = (mutations) => {\n const elements = getElements(mutations);\n // If elements is \"false\" that means this mutation that should be ignored.\n if (elements) {\n elements.forEach((el) => animate(el));\n }\n};\n/**\n *\n * @param entries - Elements that have been resized.\n */\nconst handleResizes = (entries) => {\n entries.forEach((entry) => {\n if (entry.target === root)\n updateAllPos();\n if (coords.has(entry.target))\n updatePos(entry.target);\n });\n};\n/**\n * Observe this elements position.\n * @param el - The element to observe the position of.\n */\nfunction observePosition(el) {\n const oldObserver = intersections.get(el);\n oldObserver === null || oldObserver === void 0 ? void 0 : oldObserver.disconnect();\n let rect = coords.get(el);\n let invocations = 0;\n const buffer = 5;\n if (!rect) {\n rect = getCoords(el);\n coords.set(el, rect);\n }\n const { offsetWidth, offsetHeight } = root;\n const rootMargins = [\n rect.top - buffer,\n offsetWidth - (rect.left + buffer + rect.width),\n offsetHeight - (rect.top + buffer + rect.height),\n rect.left - buffer,\n ];\n const rootMargin = rootMargins\n .map((px) => `${-1 * Math.floor(px)}px`)\n .join(\" \");\n const observer = new IntersectionObserver(() => {\n ++invocations > 1 && updatePos(el);\n }, {\n root,\n threshold: 1,\n rootMargin,\n });\n observer.observe(el);\n intersections.set(el, observer);\n}\n/**\n * Update the exact position of a given element.\n * @param el - An element to update the position of.\n */\nfunction updatePos(el) {\n clearTimeout(debounces.get(el));\n const optionsOrPlugin = getOptions(el);\n const delay = isPlugin(optionsOrPlugin) ? 500 : optionsOrPlugin.duration;\n debounces.set(el, setTimeout(async () => {\n const currentAnimation = animations.get(el);\n try {\n await (currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.finished);\n coords.set(el, getCoords(el));\n observePosition(el);\n }\n catch {\n // ignore errors as the `.finished` promise is rejected when animations were cancelled\n }\n }, delay));\n}\n/**\n * Updates all positions that are currently being tracked.\n */\nfunction updateAllPos() {\n clearTimeout(debounces.get(root));\n debounces.set(root, setTimeout(() => {\n parents.forEach((parent) => forEach(parent, (el) => lowPriority(() => updatePos(el))));\n }, 100));\n}\n/**\n * Its possible for a quick scroll or other fast events to get past the\n * intersection observer, so occasionally we need want \"cold-poll\" for the\n * latests and greatest position. We try to do this in the most non-disruptive\n * fashion possible. First we only do this ever couple seconds, staggard by a\n * random offset.\n * @param el - Element\n */\nfunction poll(el) {\n setTimeout(() => {\n intervals.set(el, setInterval(() => lowPriority(updatePos.bind(null, el)), 2000));\n }, Math.round(2000 * Math.random()));\n}\n/**\n * Perform some operation that is non critical at some point.\n * @param callback\n */\nfunction lowPriority(callback) {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => callback());\n }\n else {\n requestAnimationFrame(() => callback());\n }\n}\n/**\n * The mutation observer responsible for watching each root element.\n */\nlet mutations;\n/**\n * A resize observer, responsible for recalculating elements on resize.\n */\nlet resize;\n/**\n * Ensure the browser is supported.\n */\nconst supportedBrowser = typeof window !== \"undefined\" && \"ResizeObserver\" in window;\n/**\n * If this is in a browser, initialize our Web APIs\n */\nif (supportedBrowser) {\n root = document.documentElement;\n mutations = new MutationObserver(handleMutations);\n resize = new ResizeObserver(handleResizes);\n window.addEventListener(\"scroll\", () => {\n scrollY = window.scrollY;\n scrollX = window.scrollX;\n });\n resize.observe(root);\n}\n/**\n * Retrieves all the elements that may have been affected by the last mutation\n * including ones that have been removed and are no longer in the DOM.\n * @param mutations - A mutation list.\n * @returns\n */\nfunction getElements(mutations) {\n const observedNodes = mutations.reduce((nodes, mutation) => {\n return [\n ...nodes,\n ...Array.from(mutation.addedNodes),\n ...Array.from(mutation.removedNodes),\n ];\n }, []);\n // Short circuit if _only_ comment nodes are observed\n const onlyCommentNodesObserved = observedNodes.every((node) => node.nodeName === \"#comment\");\n if (onlyCommentNodesObserved)\n return false;\n return mutations.reduce((elements, mutation) => {\n // Short circuit if we find a purposefully deleted node.\n if (elements === false)\n return false;\n if (mutation.target instanceof Element) {\n target(mutation.target);\n if (!elements.has(mutation.target)) {\n elements.add(mutation.target);\n for (let i = 0; i < mutation.target.children.length; i++) {\n const child = mutation.target.children.item(i);\n if (!child)\n continue;\n if (DEL in child) {\n return false;\n }\n target(mutation.target, child);\n elements.add(child);\n }\n }\n if (mutation.removedNodes.length) {\n for (let i = 0; i < mutation.removedNodes.length; i++) {\n const child = mutation.removedNodes[i];\n if (DEL in child) {\n return false;\n }\n if (child instanceof Element) {\n elements.add(child);\n target(mutation.target, child);\n siblings.set(child, [\n mutation.previousSibling,\n mutation.nextSibling,\n ]);\n }\n }\n }\n }\n return elements;\n }, new Set());\n}\n/**\n * Assign the target to an element.\n * @param el - The root element\n * @param child\n */\nfunction target(el, child) {\n if (!child && !(TGT in el))\n Object.defineProperty(el, TGT, { value: el });\n else if (child && !(TGT in child))\n Object.defineProperty(child, TGT, { value: el });\n}\n/**\n * Determines what kind of change took place on the given element and then\n * performs the proper animation based on that.\n * @param el - The specific element to animate.\n */\nfunction animate(el) {\n var _a;\n const isMounted = el.isConnected;\n const preExisting = coords.has(el);\n if (isMounted && siblings.has(el))\n siblings.delete(el);\n if (animations.has(el)) {\n (_a = animations.get(el)) === null || _a === void 0 ? void 0 : _a.cancel();\n }\n if (NEW in el) {\n add(el);\n }\n else if (preExisting && isMounted) {\n remain(el);\n }\n else if (preExisting && !isMounted) {\n remove(el);\n }\n else {\n add(el);\n }\n}\n/**\n * Removes all non-digits from a string and casts to a number.\n * @param str - A string containing a pixel value.\n * @returns\n */\nfunction raw(str) {\n return Number(str.replace(/[^0-9.\\-]/g, \"\"));\n}\n/**\n * Get the scroll offset of elements\n * @param el - Element\n * @returns\n */\nfunction getScrollOffset(el) {\n let p = el.parentElement;\n while (p) {\n if (p.scrollLeft || p.scrollTop) {\n return { x: p.scrollLeft, y: p.scrollTop };\n }\n p = p.parentElement;\n }\n return { x: 0, y: 0 };\n}\n/**\n * Get the coordinates of elements adjusted for scroll position.\n * @param el - Element\n * @returns\n */\nfunction getCoords(el) {\n const rect = el.getBoundingClientRect();\n const { x, y } = getScrollOffset(el);\n return {\n top: rect.top + y,\n left: rect.left + x,\n width: rect.width,\n height: rect.height,\n };\n}\n/**\n * Returns the width/height that the element should be transitioned between.\n * This takes into account box-sizing.\n * @param el - Element being animated\n * @param oldCoords - Old set of Coordinates coordinates\n * @param newCoords - New set of Coordinates coordinates\n * @returns\n */\nfunction getTransitionSizes(el, oldCoords, newCoords) {\n let widthFrom = oldCoords.width;\n let heightFrom = oldCoords.height;\n let widthTo = newCoords.width;\n let heightTo = newCoords.height;\n const styles = getComputedStyle(el);\n const sizing = styles.getPropertyValue(\"box-sizing\");\n if (sizing === \"content-box\") {\n const paddingY = raw(styles.paddingTop) +\n raw(styles.paddingBottom) +\n raw(styles.borderTopWidth) +\n raw(styles.borderBottomWidth);\n const paddingX = raw(styles.paddingLeft) +\n raw(styles.paddingRight) +\n raw(styles.borderRightWidth) +\n raw(styles.borderLeftWidth);\n widthFrom -= paddingX;\n widthTo -= paddingX;\n heightFrom -= paddingY;\n heightTo -= paddingY;\n }\n return [widthFrom, widthTo, heightFrom, heightTo].map(Math.round);\n}\n/**\n * Retrieves animation options for the current element.\n * @param el - Element to retrieve options for.\n * @returns\n */\nfunction getOptions(el) {\n return TGT in el && options.has(el[TGT])\n ? options.get(el[TGT])\n : { duration: 250, easing: \"ease-in-out\" };\n}\n/**\n * Returns the target of a given animation (generally the parent).\n * @param el - An element to check for a target\n * @returns\n */\nfunction getTarget(el) {\n if (TGT in el)\n return el[TGT];\n return undefined;\n}\n/**\n * Checks if animations are enabled or disabled for a given element.\n * @param el - Any element\n * @returns\n */\nfunction isEnabled(el) {\n const target = getTarget(el);\n return target ? enabled.has(target) : false;\n}\n/**\n * Iterate over the children of a given parent.\n * @param parent - A parent element\n * @param callback - A callback\n */\nfunction forEach(parent, ...callbacks) {\n callbacks.forEach((callback) => callback(parent, options.has(parent)));\n for (let i = 0; i < parent.children.length; i++) {\n const child = parent.children.item(i);\n if (child) {\n callbacks.forEach((callback) => callback(child, options.has(child)));\n }\n }\n}\n/**\n * Always return tuple to provide consistent interface\n */\nfunction getPluginTuple(pluginReturn) {\n if (Array.isArray(pluginReturn))\n return pluginReturn;\n return [pluginReturn];\n}\n/**\n * Determine if config is plugin\n */\nfunction isPlugin(config) {\n return typeof config === \"function\";\n}\n/**\n * The element in question is remaining in the DOM.\n * @param el - Element to flip\n * @returns\n */\nfunction remain(el) {\n const oldCoords = coords.get(el);\n const newCoords = getCoords(el);\n if (!isEnabled(el))\n return coords.set(el, newCoords);\n let animation;\n if (!oldCoords)\n return;\n const pluginOrOptions = getOptions(el);\n if (typeof pluginOrOptions !== \"function\") {\n const deltaX = oldCoords.left - newCoords.left;\n const deltaY = oldCoords.top - newCoords.top;\n const [widthFrom, widthTo, heightFrom, heightTo] = getTransitionSizes(el, oldCoords, newCoords);\n const start = {\n transform: `translate(${deltaX}px, ${deltaY}px)`,\n };\n const end = {\n transform: `translate(0, 0)`,\n };\n if (widthFrom !== widthTo) {\n start.width = `${widthFrom}px`;\n end.width = `${widthTo}px`;\n }\n if (heightFrom !== heightTo) {\n start.height = `${heightFrom}px`;\n end.height = `${heightTo}px`;\n }\n animation = el.animate([start, end], {\n duration: pluginOrOptions.duration,\n easing: pluginOrOptions.easing,\n });\n }\n else {\n const [keyframes] = getPluginTuple(pluginOrOptions(el, \"remain\", oldCoords, newCoords));\n animation = new Animation(keyframes);\n animation.play();\n }\n animations.set(el, animation);\n coords.set(el, newCoords);\n animation.addEventListener(\"finish\", updatePos.bind(null, el));\n}\n/**\n * Adds the element with a transition.\n * @param el - Animates the element being added.\n */\nfunction add(el) {\n if (NEW in el)\n delete el[NEW];\n const newCoords = getCoords(el);\n coords.set(el, newCoords);\n const pluginOrOptions = getOptions(el);\n if (!isEnabled(el))\n return;\n let animation;\n if (typeof pluginOrOptions !== \"function\") {\n animation = el.animate([\n { transform: \"scale(.98)\", opacity: 0 },\n { transform: \"scale(0.98)\", opacity: 0, offset: 0.5 },\n { transform: \"scale(1)\", opacity: 1 },\n ], {\n duration: pluginOrOptions.duration * 1.5,\n easing: \"ease-in\",\n });\n }\n else {\n const [keyframes] = getPluginTuple(pluginOrOptions(el, \"add\", newCoords));\n animation = new Animation(keyframes);\n animation.play();\n }\n animations.set(el, animation);\n animation.addEventListener(\"finish\", updatePos.bind(null, el));\n}\n/**\n * Clean up after removing an element from the dom.\n * @param el - Element being removed\n * @param styles - Optional styles that should be removed from the element.\n */\nfunction cleanUp(el, styles) {\n var _a;\n el.remove();\n coords.delete(el);\n siblings.delete(el);\n animations.delete(el);\n (_a = intersections.get(el)) === null || _a === void 0 ? void 0 : _a.disconnect();\n setTimeout(() => {\n if (DEL in el)\n delete el[DEL];\n Object.defineProperty(el, NEW, { value: true, configurable: true });\n if (styles && el instanceof HTMLElement) {\n for (const style in styles) {\n el.style[style] = \"\";\n }\n }\n }, 0);\n}\n/**\n * Animates the removal of an element.\n * @param el - Element to remove\n */\nfunction remove(el) {\n var _a;\n if (!siblings.has(el) || !coords.has(el))\n return;\n const [prev, next] = siblings.get(el);\n Object.defineProperty(el, DEL, { value: true, configurable: true });\n const finalX = window.scrollX;\n const finalY = window.scrollY;\n if (next && next.parentNode && next.parentNode instanceof Element) {\n next.parentNode.insertBefore(el, next);\n }\n else if (prev && prev.parentNode) {\n prev.parentNode.appendChild(el);\n }\n else {\n (_a = getTarget(el)) === null || _a === void 0 ? void 0 : _a.appendChild(el);\n }\n if (!isEnabled(el))\n return cleanUp(el);\n const [top, left, width, height] = deletePosition(el);\n const optionsOrPlugin = getOptions(el);\n const oldCoords = coords.get(el);\n if (finalX !== scrollX || finalY !== scrollY) {\n adjustScroll(el, finalX, finalY, optionsOrPlugin);\n }\n let animation;\n let styleReset = {\n position: \"absolute\",\n top: `${top}px`,\n left: `${left}px`,\n width: `${width}px`,\n height: `${height}px`,\n margin: \"0\",\n pointerEvents: \"none\",\n transformOrigin: \"center\",\n zIndex: \"100\",\n };\n if (!isPlugin(optionsOrPlugin)) {\n Object.assign(el.style, styleReset);\n animation = el.animate([\n {\n transform: \"scale(1)\",\n opacity: 1,\n },\n {\n transform: \"scale(.98)\",\n opacity: 0,\n },\n ], { duration: optionsOrPlugin.duration, easing: \"ease-out\" });\n }\n else {\n const [keyframes, options] = getPluginTuple(optionsOrPlugin(el, \"remove\", oldCoords));\n if ((options === null || options === void 0 ? void 0 : options.styleReset) !== false) {\n styleReset = (options === null || options === void 0 ? void 0 : options.styleReset) || styleReset;\n Object.assign(el.style, styleReset);\n }\n animation = new Animation(keyframes);\n animation.play();\n }\n animations.set(el, animation);\n animation.addEventListener(\"finish\", cleanUp.bind(null, el, styleReset));\n}\n/**\n * If the element being removed is at the very bottom of the page, and the\n * the page was scrolled into a space being \"made available\" by the element\n * that was removed, the page scroll will have jumped up some amount. We need\n * to offset the jump by the amount that the page was \"automatically\" scrolled\n * up. We can do this by comparing the scroll position before and after the\n * element was removed, and then offsetting by that amount.\n *\n * @param el - The element being deleted\n * @param finalX - The final X scroll position\n * @param finalY - The final Y scroll position\n * @param optionsOrPlugin - The options or plugin\n * @returns\n */\nfunction adjustScroll(el, finalX, finalY, optionsOrPlugin) {\n const scrollDeltaX = scrollX - finalX;\n const scrollDeltaY = scrollY - finalY;\n const scrollBefore = document.documentElement.style.scrollBehavior;\n const scrollBehavior = getComputedStyle(root).scrollBehavior;\n if (scrollBehavior === \"smooth\") {\n document.documentElement.style.scrollBehavior = \"auto\";\n }\n window.scrollTo(window.scrollX + scrollDeltaX, window.scrollY + scrollDeltaY);\n if (!el.parentElement)\n return;\n const parent = el.parentElement;\n let lastHeight = parent.clientHeight;\n let lastWidth = parent.clientWidth;\n const startScroll = performance.now();\n // Here we use a manual scroll animation to keep the element using the same\n // easing and timing as the parent’s scroll animation.\n function smoothScroll() {\n requestAnimationFrame(() => {\n if (!isPlugin(optionsOrPlugin)) {\n const deltaY = lastHeight - parent.clientHeight;\n const deltaX = lastWidth - parent.clientWidth;\n if (startScroll + optionsOrPlugin.duration > performance.now()) {\n window.scrollTo({\n left: window.scrollX - deltaX,\n top: window.scrollY - deltaY,\n });\n lastHeight = parent.clientHeight;\n lastWidth = parent.clientWidth;\n smoothScroll();\n }\n else {\n document.documentElement.style.scrollBehavior = scrollBefore;\n }\n }\n });\n }\n smoothScroll();\n}\n/**\n * Determines the position of the element being removed.\n * @param el - The element being deleted\n * @returns\n */\nfunction deletePosition(el) {\n const oldCoords = coords.get(el);\n const [width, , height] = getTransitionSizes(el, oldCoords, getCoords(el));\n let offsetParent = el.parentElement;\n while (offsetParent &&\n (getComputedStyle(offsetParent).position === \"static\" ||\n offsetParent instanceof HTMLBodyElement)) {\n offsetParent = offsetParent.parentElement;\n }\n if (!offsetParent)\n offsetParent = document.body;\n const parentStyles = getComputedStyle(offsetParent);\n const parentCoords = coords.get(offsetParent) || getCoords(offsetParent);\n const top = Math.round(oldCoords.top - parentCoords.top) -\n raw(parentStyles.borderTopWidth);\n const left = Math.round(oldCoords.left - parentCoords.left) -\n raw(parentStyles.borderLeftWidth);\n return [top, left, width, height];\n}\n/**\n * A function that automatically adds animation effects to itself and its\n * immediate children. Specifically it adds effects for adding, moving, and\n * removing DOM elements.\n * @param el - A parent element to add animations to.\n * @param options - An optional object of options.\n */\nfunction autoAnimate(el, config = {}) {\n if (mutations && resize) {\n const mediaQuery = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n const isDisabledDueToReduceMotion = mediaQuery.matches &&\n !isPlugin(config) &&\n !config.disrespectUserMotionPreference;\n if (!isDisabledDueToReduceMotion) {\n enabled.add(el);\n if (getComputedStyle(el).position === \"static\") {\n Object.assign(el.style, { position: \"relative\" });\n }\n forEach(el, updatePos, poll, (element) => resize === null || resize === void 0 ? void 0 : resize.observe(element));\n if (isPlugin(config)) {\n options.set(el, config);\n }\n else {\n options.set(el, { duration: 250, easing: \"ease-in-out\", ...config });\n }\n mutations.observe(el, { childList: true });\n parents.add(el);\n }\n }\n return Object.freeze({\n parent: el,\n enable: () => {\n enabled.add(el);\n },\n disable: () => {\n enabled.delete(el);\n },\n isEnabled: () => enabled.has(el),\n });\n}\n/**\n * The vue directive.\n */\nconst vAutoAnimate = {\n mounted: (el, binding) => {\n autoAnimate(el, binding.value || {});\n },\n // ignore ssr see #96:\n getSSRProps: () => ({}),\n};\n\nexport { autoAnimate as default, getTransitionSizes, vAutoAnimate };\n","import { useRef, useState, useEffect } from 'preact/hooks';\nimport autoAnimate from '../index.mjs';\n\n/**\n * AutoAnimate hook for adding dead-simple transitions and animations to preact.\n * @param options - Auto animate options or a plugin\n * @returns\n */\nfunction useAutoAnimate(options) {\n const element = useRef(null);\n const [controller, setController] = useState();\n const setEnabled = (enabled) => {\n if (controller) {\n enabled ? controller.enable() : controller.disable();\n }\n };\n useEffect(() => {\n if (element.current instanceof HTMLElement)\n setController(autoAnimate(element.current, options || {}));\n }, []);\n return [element, setEnabled];\n}\n\nexport { useAutoAnimate };\n","function dec2hex(dec) {\n return ('0' + dec.toString(16)).slice(-2);\n}\nexport function verifier() {\n var array = new Uint32Array(56 / 2);\n window.crypto.getRandomValues(array);\n return Array.from(array, dec2hex).join('');\n}\nfunction sha256(plain) {\n // returns promise ArrayBuffer\n const encoder = new TextEncoder();\n const data = encoder.encode(plain);\n return window.crypto.subtle.digest('SHA-256', data);\n}\nfunction base64urlencode(a) {\n let str = '';\n const bytes = new Uint8Array(a);\n const len = bytes.byteLength;\n for (var i = 0; i < len; i++) {\n str += String.fromCharCode(bytes[i]);\n }\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\nexport async function generateCodeChallenge(v) {\n const hashed = await sha256(v);\n return base64urlencode(hashed);\n}\n\n// If /.well-known/oauth-authorization-server exists and code_challenge_methods_supported includes \"S256\", means support PKCE\nexport async function supportsPKCE({ instanceURL }) {\n if (!instanceURL) return false;\n try {\n const res = await fetch(\n `https://${instanceURL}/.well-known/oauth-authorization-server`,\n );\n if (!res.ok || res.status !== 200) return false;\n const json = await res.json();\n if (json.code_challenge_methods_supported?.includes('S256')) return true;\n return false;\n } catch (e) {\n return false;\n }\n}\n\n// For debugging\nwindow.__generateCodeChallenge = generateCodeChallenge;\n","import { generateCodeChallenge, verifier } from './oauth-pkce';\n\nconst {\n DEV,\n PHANPY_CLIENT_NAME: CLIENT_NAME,\n PHANPY_WEBSITE: WEBSITE,\n} = import.meta.env;\n\nconst SCOPES = 'read write follow push';\n\n/*\n PHANPY_WEBSITE is set to the default official site.\n It's used in pre-built releases, so there's no way to change it dynamically\n without rebuilding.\n Therefore, we can't use it as redirect_uri.\n We only use PHANPY_WEBSITE if it's \"same\" as current location URL.\n \n Very basic check based on location.hostname for now\n*/\nconst sameSite = WEBSITE\n ? WEBSITE.toLowerCase().includes(location.hostname)\n : false;\nconst currentLocation = location.origin + location.pathname;\nconst REDIRECT_URI = DEV || !sameSite ? currentLocation : WEBSITE;\n\nexport async function registerApplication({ instanceURL }) {\n const registrationParams = new URLSearchParams({\n client_name: CLIENT_NAME,\n redirect_uris: REDIRECT_URI,\n scopes: SCOPES,\n website: WEBSITE,\n });\n const registrationResponse = await fetch(\n `https://${instanceURL}/api/v1/apps`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: registrationParams.toString(),\n },\n );\n const registrationJSON = await registrationResponse.json();\n console.log({ registrationJSON });\n return registrationJSON;\n}\n\nexport async function getPKCEAuthorizationURL({\n instanceURL,\n client_id,\n forceLogin = false,\n}) {\n const codeVerifier = verifier();\n const codeChallenge = await generateCodeChallenge(codeVerifier);\n const params = new URLSearchParams({\n client_id,\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n redirect_uri: REDIRECT_URI,\n response_type: 'code',\n scope: SCOPES,\n });\n if (forceLogin) params.append('force_login', true);\n const authorizationURL = `https://${instanceURL}/oauth/authorize?${params.toString()}`;\n return [authorizationURL, codeVerifier];\n}\n\nexport async function getAuthorizationURL({\n instanceURL,\n client_id,\n forceLogin = false,\n}) {\n const authorizationParams = new URLSearchParams({\n client_id,\n scope: SCOPES,\n redirect_uri: REDIRECT_URI,\n // redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n response_type: 'code',\n });\n if (forceLogin) authorizationParams.append('force_login', true);\n const authorizationURL = `https://${instanceURL}/oauth/authorize?${authorizationParams.toString()}`;\n return authorizationURL;\n}\n\nexport async function getAccessToken({\n instanceURL,\n client_id,\n client_secret,\n code,\n code_verifier,\n}) {\n const params = new URLSearchParams({\n client_id,\n redirect_uri: REDIRECT_URI,\n grant_type: 'authorization_code',\n code,\n // scope: SCOPES, // Not needed\n // client_secret,\n // code_verifier,\n });\n if (client_secret) {\n params.append('client_secret', client_secret);\n }\n if (code_verifier) {\n params.append('code_verifier', code_verifier);\n }\n const tokenResponse = await fetch(`https://${instanceURL}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: params.toString(),\n });\n const tokenJSON = await tokenResponse.json();\n console.log({ tokenJSON });\n return tokenJSON;\n}\n\nexport async function revokeAccessToken({\n instanceURL,\n client_id,\n client_secret,\n token,\n}) {\n try {\n const params = new URLSearchParams({\n client_id,\n client_secret,\n token,\n });\n\n const revokeResponse = await fetch(`https://${instanceURL}/oauth/revoke`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: params.toString(),\n keepalive: true,\n });\n\n return revokeResponse.ok;\n } catch (error) {\n console.erro('Error revoking token', error);\n return false;\n }\n}\n","import './accounts.css';\n\nimport { useAutoAnimate } from '@formkit/auto-animate/preact';\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';\nimport { useReducer } from 'preact/hooks';\n\nimport Avatar from '../components/avatar';\nimport Icon from '../components/icon';\nimport Link from '../components/link';\nimport MenuConfirm from '../components/menu-confirm';\nimport MenuLink from '../components/menu-link';\nimport Menu2 from '../components/menu2';\nimport NameText from '../components/name-text';\nimport RelativeTime from '../components/relative-time';\nimport { api } from '../utils/api';\nimport { revokeAccessToken } from '../utils/auth';\nimport niceDateTime from '../utils/nice-date-time';\nimport states from '../utils/states';\nimport store from '../utils/store';\nimport {\n getAccounts,\n getCurrentAccountID,\n saveAccounts,\n setCurrentAccountID,\n} from '../utils/store-utils';\n\nconst isStandalone = window.matchMedia('(display-mode: standalone)').matches;\n\nfunction Accounts({ onClose }) {\n const { t } = useLingui();\n const { masto } = api();\n // Accounts\n const accounts = getAccounts();\n const currentAccount = getCurrentAccountID();\n const moreThanOneAccount = accounts.length > 1;\n\n const [_, reload] = useReducer((x) => x + 1, 0);\n const [accountsListParent] = useAutoAnimate();\n\n return (\n \n {!!onClose && (\n
\n )}\n \n
\n \n \n {accounts.map((account, i) => {\n const isCurrent = account.info.id === currentAccount;\n const isDefault = i === 0; // first account is always default\n return (\n - \n
\n {moreThanOneAccount && (\n
\n \n \n )}\n
{\n if (isCurrent) {\n try {\n const info = await masto.v1.accounts\n .$select(account.info.id)\n .fetch();\n console.log('fetched account info', info);\n account.info = info;\n saveAccounts(accounts);\n reload();\n } catch (e) {}\n }\n }}\n />\n {\n if (isCurrent) {\n states.showAccount = `${account.info.username}@${account.instanceURL}`;\n } else {\n setCurrentAccountID(account.info.id);\n location.reload();\n }\n }}\n />\n \n \n {isDefault && moreThanOneAccount && (\n <>\n \n Default\n {' '}\n >\n )}\n \n \n \n }\n >\n {moreThanOneAccount && (\n <>\n \n {!isStandalone && !isCurrent && (\n \n \n \n Switch in new tab/window\n \n \n )}\n \n >\n )}\n \n \n {moreThanOneAccount && (\n <>\n \n \n \n \n >\n )}\n \n \n \n \n Log out{' '}\n \n @{account.info.acct}\n \n ?\n \n \n >\n }\n disabled={!isCurrent}\n menuItemClassName=\"danger\"\n onClick={async () => {\n // const yes = confirm('Log out?');\n // if (!yes) return;\n await revokeAccessToken({\n instanceURL: account.instanceURL,\n client_id: account.clientId,\n client_secret: account.clientSecret,\n token: account.accessToken,\n });\n accounts.splice(i, 1);\n saveAccounts(accounts);\n // location.reload();\n location.href = location.pathname || '/';\n }}\n >\n \n \n Log out…\n \n \n {!!account?.createdAt && (\n \n )}\n \n
\n \n );\n })}\n
\n \n \n {' '}\n \n Add an existing account\n \n \n
\n {moreThanOneAccount && (\n \n \n \n Note: Default account will always be used for first\n load. Switched accounts will persist during the session.\n \n \n
\n )}\n \n \n
\n );\n}\n\nexport default Accounts;\n","export default \"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%2064%2064'%3e%3cpath%20fill='none'%20d='M0%200h63.994v63.994H0z'/%3e%3cpath%20fill='%23a4bff7'%20d='M37.774%2011.471c14.639%203.752%2019.034%2016.557%2015.889%2031.304-.696%203.261-2.563%206.661-6.356%208.693-3.204%201.717-8.07%202.537-15.338.55l-9.634-2.404C11.651%2046.992%208.378%2038.733%2010.027%2031.823c3.627-15.201%2015.543-23.48%2027.747-20.352Z'/%3e%3cpath%20fill='%23d8e7fe'%20d='M36.76%2015.429c12.289%203.15%2015.547%2014.114%2012.907%2026.493-.947%204.44-4.937%209.365-16.664%206.143l-9.684-2.417c-7.854-1.923-10.53-7.8-9.318-12.877%203.016-12.639%2012.611-19.943%2022.759-17.342Z'/%3e%3cpath%20fill='%236081e6'%20d='M27.471%2024.991c-1.457-.698-7.229%203.213-7.663%208.926-.182%202.39%204.55%203.237%205.071-.169.725-4.743%203.715-8.218%202.592-8.757Zm10.746%202.005c-2.083.327-.382%205.901-.595%2010.727-.123%202.8%204.388%203.464%204.703%202.011%201.098-5.073-2.066-13.058-4.108-12.738Z'/%3e%3c/svg%3e\"","import { useLingui } from '@lingui/react';\nimport { useMemo } from 'preact/hooks';\n\nimport { CATALOGS, DEFAULT_LANG, DEV_LOCALES, LOCALES } from '../locales';\nimport { activateLang } from '../utils/lang';\nimport localeCode2Text from '../utils/localeCode2Text';\nimport store from '../utils/store';\n\nconst regionMaps = {\n 'zh-CN': 'zh-Hans',\n 'zh-TW': 'zh-Hant',\n 'pt-BR': 'pt-BR',\n};\n\nexport default function LangSelector() {\n const { i18n } = useLingui();\n\n // Sorted on render, so the order won't suddenly change based on current locale\n const populatedLocales = useMemo(() => {\n return LOCALES.map((lang) => {\n // Don't need regions for now, it makes text too noisy\n // Wait till there's too many languages and there are regional clashes\n const regionlessCode = regionMaps[lang] || lang.replace(/-[a-z]+$/i, '');\n\n const native = localeCode2Text({\n code: regionlessCode,\n locale: lang,\n fallback: CATALOGS.find((c) => c.code === lang)?.nativeName,\n });\n\n // Not used when rendering because it'll change based on current locale\n // Only used for sorting on render\n const _common = localeCode2Text({\n code: regionlessCode,\n locale: i18n.locale,\n fallback: CATALOGS.find((c) => c.code === lang)?.name,\n });\n\n return {\n code: lang,\n regionlessCode,\n _common,\n native,\n };\n }).sort((a, b) => {\n // Sort by common name\n const order = a._common.localeCompare(b._common, i18n.locale);\n if (order !== 0) return order;\n // Sort by code (fallback)\n if (a.code < b.code) return -1;\n if (a.code > b.code) return 1;\n return 0;\n });\n }, []);\n\n return (\n \n );\n}\n","// Utils for push notifications\nimport { api } from './api';\nimport { getVapidKey } from './store-utils';\n\n// Subscription is an object with the following structure:\n// {\n// data: {\n// alerts: {\n// admin: {\n// report: boolean,\n// signUp: boolean,\n// },\n// favourite: boolean,\n// follow: boolean,\n// mention: boolean,\n// poll: boolean,\n// reblog: boolean,\n// status: boolean,\n// update: boolean,\n// }\n// },\n// policy: \"all\" | \"followed\" | \"follower\" | \"none\",\n// subscription: {\n// endpoint: string,\n// keys: {\n// auth: string,\n// p256dh: string,\n// },\n// },\n// }\n\n// Back-end CRUD\n// =============\n\nfunction createBackendPushSubscription(subscription) {\n const { masto } = api();\n return masto.v1.push.subscription.create(subscription);\n}\n\nfunction fetchBackendPushSubscription() {\n const { masto } = api();\n return masto.v1.push.subscription.fetch();\n}\n\nfunction updateBackendPushSubscription(subscription) {\n const { masto } = api();\n return masto.v1.push.subscription.update(subscription);\n}\n\nfunction removeBackendPushSubscription() {\n const { masto } = api();\n return masto.v1.push.subscription.remove();\n}\n\n// Front-end\n// =========\n\nexport function isPushSupported() {\n return 'serviceWorker' in navigator && 'PushManager' in window;\n}\n\nexport function getRegistration() {\n // return navigator.serviceWorker.ready;\n return navigator.serviceWorker.getRegistration();\n}\n\nasync function getSubscription() {\n const registration = await getRegistration();\n const subscription = registration\n ? await registration.pushManager.getSubscription()\n : undefined;\n return { registration, subscription };\n}\n\nfunction urlBase64ToUint8Array(base64String) {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = `${base64String}${padding}`\n .replace(/-/g, '+')\n .replace(/_/g, '/');\n\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n\n return outputArray;\n}\n\n// Front-end <-> back-end\n// ======================\n\nexport async function initSubscription() {\n if (!isPushSupported()) return;\n const { subscription } = await getSubscription();\n let backendSubscription = null;\n try {\n backendSubscription = await fetchBackendPushSubscription();\n } catch (err) {\n if (/(not found|unknown)/i.test(err.message)) {\n // No subscription found\n } else {\n // Other error\n throw err;\n }\n }\n console.log('INIT subscription', {\n subscription,\n backendSubscription,\n });\n\n // Check if the subscription changed\n if (backendSubscription && subscription) {\n const sameEndpoint = backendSubscription.endpoint === subscription.endpoint;\n const vapidKey = getVapidKey();\n const sameKey = backendSubscription.serverKey === vapidKey;\n if (!sameEndpoint) {\n throw new Error('Backend subscription endpoint changed');\n }\n if (sameKey) {\n // Subscription didn't change\n } else {\n // Subscription changed\n console.error('🔔 Subscription changed', {\n sameEndpoint,\n serverKey: backendSubscription.serverKey,\n vapIdKey: vapidKey,\n endpoint1: backendSubscription.endpoint,\n endpoint2: subscription.endpoint,\n sameKey,\n key1: backendSubscription.serverKey,\n key2: vapidKey,\n });\n throw new Error('Backend subscription key and vapid key changed');\n // Only unsubscribe from backend, not from browser\n // await removeBackendPushSubscription();\n // // Now let's resubscribe\n // // NOTE: I have no idea if this works\n // return await updateSubscription({\n // data: backendSubscription.data,\n // policy: backendSubscription.policy,\n // });\n }\n }\n\n if (subscription && !backendSubscription) {\n // check if account's vapidKey is same as subscription's applicationServerKey\n const vapidKey = getVapidKey();\n if (vapidKey) {\n const { applicationServerKey } = subscription.options;\n const vapidKeyStr = urlBase64ToUint8Array(vapidKey).toString();\n const applicationServerKeyStr = new Uint8Array(\n applicationServerKey,\n ).toString();\n const sameKey = vapidKeyStr === applicationServerKeyStr;\n if (sameKey) {\n // Subscription didn't change\n } else {\n // Subscription changed\n console.error('🔔 Subscription changed', {\n vapidKeyStr,\n applicationServerKeyStr,\n sameKey,\n });\n // Unsubscribe since backend doesn't have a subscription\n await subscription.unsubscribe();\n throw new Error('Subscription key and vapid key changed');\n }\n } else {\n console.warn('No vapidKey found');\n }\n }\n\n // Check if backend subscription returns 404\n // if (subscription && !backendSubscription) {\n // // Re-subscribe to backend\n // backendSubscription = await createBackendPushSubscription({\n // subscription,\n // data: {},\n // policy: 'all',\n // });\n // }\n\n return { subscription, backendSubscription };\n}\n\nexport async function updateSubscription({ data, policy }) {\n console.log('🔔 Updating subscription', { data, policy });\n if (!isPushSupported()) return;\n let { registration, subscription } = await getSubscription();\n let backendSubscription = null;\n\n if (subscription) {\n try {\n backendSubscription = await updateBackendPushSubscription({\n data,\n policy,\n });\n // TODO: save subscription in user settings\n } catch (error) {\n // Backend doesn't have a subscription for this user\n // Create a new one\n backendSubscription = await createBackendPushSubscription({\n subscription,\n data,\n policy,\n });\n // TODO: save subscription in user settings\n }\n } else {\n // User is not subscribed\n const vapidKey = getVapidKey();\n if (!vapidKey) throw new Error('No server key found');\n subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: urlBase64ToUint8Array(vapidKey),\n });\n backendSubscription = await createBackendPushSubscription({\n subscription,\n data,\n policy,\n });\n // TODO: save subscription in user settings\n }\n\n return { subscription, backendSubscription };\n}\n\nexport async function removeSubscription() {\n if (!isPushSupported()) return;\n const { subscription } = await getSubscription();\n if (subscription) {\n await removeBackendPushSubscription();\n await subscription.unsubscribe();\n }\n}\n","import './settings.css';\n\nimport { Plural, Trans, useLingui } from '@lingui/react/macro';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useSnapshot } from 'valtio';\n\nimport logo from '../assets/logo.svg';\n\nimport Icon from '../components/icon';\nimport LangSelector from '../components/lang-selector';\nimport Link from '../components/link';\nimport RelativeTime from '../components/relative-time';\nimport languages from '../data/translang-languages';\nimport { api, getPreferences, setPreferences } from '../utils/api';\nimport getTranslateTargetLanguage from '../utils/get-translate-target-language';\nimport localeCode2Text from '../utils/localeCode2Text';\nimport prettyBytes from '../utils/pretty-bytes';\nimport {\n initSubscription,\n isPushSupported,\n removeSubscription,\n updateSubscription,\n} from '../utils/push-notifications';\nimport showToast from '../utils/show-toast';\nimport states from '../utils/states';\nimport store from '../utils/store';\nimport { getAPIVersions, getVapidKey } from '../utils/store-utils';\nimport supports from '../utils/supports';\n\nconst DEFAULT_TEXT_SIZE = 16;\nconst TEXT_SIZES = [14, 15, 16, 17, 18, 19, 20];\nconst {\n PHANPY_WEBSITE: WEBSITE,\n PHANPY_PRIVACY_POLICY_URL: PRIVACY_POLICY_URL,\n PHANPY_TRANSLANG_INSTANCES: TRANSLANG_INSTANCES,\n PHANPY_IMG_ALT_API_URL: IMG_ALT_API_URL,\n PHANPY_GIPHY_API_KEY: GIPHY_API_KEY,\n} = import.meta.env;\n\nconst targetLanguages = Object.entries(languages.tl).map(([code, name]) => ({\n code,\n name,\n}));\n\nconst TRANSLATION_API_NAME = 'TransLang API';\n\nfunction Settings({ onClose }) {\n const { t } = useLingui();\n const snapStates = useSnapshot(states);\n const currentTheme = store.local.get('theme') || 'auto';\n const themeFormRef = useRef();\n const targetLanguage =\n snapStates.settings.contentTranslationTargetLanguage || null;\n const systemTargetLanguage = getTranslateTargetLanguage();\n const systemTargetLanguageText = localeCode2Text(systemTargetLanguage);\n const currentTextSize = store.local.get('textSize') || DEFAULT_TEXT_SIZE;\n\n const [prefs, setPrefs] = useState(getPreferences());\n const { masto, authenticated, instance } = api();\n // Get preferences every time Settings is opened\n // NOTE: Disabled for now because I don't expect this to change often. Also for some reason, the /api/v1/preferences endpoint is cached for a while and return old prefs if refresh immediately after changing them.\n // useEffect(() => {\n // const { masto } = api();\n // (async () => {\n // try {\n // const preferences = await masto.v1.preferences.fetch();\n // setPrefs(preferences);\n // store.account.set('preferences', preferences);\n // } catch (e) {\n // // Silently fail\n // console.error(e);\n // }\n // })();\n // }, []);\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n
\n \n \n - \n
\n \n
\n \n \n - \n
\n \n
\n \n \n \n A\n \n {' '}\n {\n const value = parseInt(e.target.value, 10);\n const html = document.documentElement;\n // set CSS variable\n html.style.setProperty('--text-size', `${value}px`);\n // save to local storage\n if (value === DEFAULT_TEXT_SIZE) {\n store.local.del('textSize');\n } else {\n store.local.set('textSize', e.target.value);\n }\n }}\n />{' '}\n \n \n A\n \n \n \n
\n \n - \n \n \n
\n \n \n Volunteer translations\n \n \n \n \n \n
\n \n {authenticated && (\n <>\n \n Posting\n
\n \n \n - \n
\n \n
\n \n \n
\n \n
\n \n \n {' '}\n \n \n Synced to your instance server's settings.{' '}\n \n Go to your instance ({instance}) for more settings.\n \n \n \n
\n >\n )}\n \n Experiments\n
\n \n \n - \n \n
\n - \n \n
\n {!!TRANSLANG_INSTANCES && (\n - \n \n
\n
\n \n
\n
\n
\n
\n
\n {targetLanguages.map((lang) => {\n const common = localeCode2Text({\n code: lang.code,\n fallback: lang.name,\n });\n const native = localeCode2Text({\n code: lang.code,\n locale: lang.code,\n });\n const showCommon = native && common !== native;\n return (\n \n );\n })}\n
\n
\n
\n \n \n Note: This feature uses external translation services,\n powered by{' '}\n \n {TRANSLATION_API_NAME}\n \n .\n \n \n
\n
\n
\n
\n
\n \n \n Automatically show translation for posts in timeline.\n Only works for short posts without content\n warning, media and poll.\n \n \n
\n
\n
\n \n )}\n {!!GIPHY_API_KEY && authenticated && (\n - \n \n
\n
\n \n Note: This feature uses external GIF search service,\n powered by{' '}\n \n GIPHY\n \n . G-rated (suitable for viewing by all ages), tracking\n parameters are stripped, referrer information is omitted\n from requests, but search queries and IP address\n information will still reach their servers.\n \n \n
\n \n )}\n {!!IMG_ALT_API_URL && authenticated && (\n - \n \n
\n \n \n Only for new images while composing new posts.\n \n \n
\n \n
\n \n Note: This feature uses external AI service, powered by{' '}\n \n img-alt-api\n \n . May not work well. Only for images and in English.\n \n \n
\n \n )}\n {authenticated &&\n supports('@mastodon/grouped-notifications') &&\n getAPIVersions()?.mastodon >= 2 && (\n - \n \n
\n \n \n Alpha-stage feature. Potentially improved grouping\n window but basic grouping logic.\n \n \n
\n \n )}\n {authenticated && (\n - \n \n
\n \n \n ⚠️⚠️⚠️ Very experimental.\n
\n Stored in your own profile’s notes. Profile (private)\n notes are mainly used for other profiles, and hidden for\n own profile.\n \n \n
\n \n \n \n Note: This feature uses currently-logged-in instance\n server API.\n \n \n
\n \n )}\n - \n \n
\n \n \n Replace text as blocks, useful when taking screenshots, for\n privacy reasons.\n \n \n
\n \n {authenticated && (\n - \n \n
\n )}\n
\n \n {authenticated && }\n \n About\n
\n \n \n

\n
\n
\n \n \n Sponsor\n {' '}\n ·{' '}\n \n Donate\n {' '}\n ·{' '}\n \n Patreon\n {' '}\n ·{' '}\n \n What's new\n {' '}\n ·{' '}\n \n Privacy Policy\n \n
\n {__BUILD_TIME__ && (\n \n {WEBSITE && (\n <>\n \n Site:{' '}\n {WEBSITE.replace(/https?:\\/\\//g, '').replace(/\\/$/, '')}\n \n
\n >\n )}\n \n Version:{' '}\n {\n e.target.select();\n // Copy to clipboard\n try {\n navigator.clipboard.writeText(e.target.value);\n showToast(t`Version string copied`);\n } catch (e) {\n console.warn(e);\n showToast(t`Unable to copy version string`);\n }\n }}\n />{' '}\n {!__FAKE_COMMIT_HASH__ && (\n \n (\n \n \n \n )\n \n )}\n \n
\n )}\n \n {(import.meta.env.DEV || import.meta.env.PHANPY_DEV) && (\n \n
\n \n \n Sandbox\n \n
\n Debugging
\n \n Vapid key: {getVapidKey()}\n
\n {__BENCH_RESULTS?.size > 0 && (\n \n {Array.from(__BENCH_RESULTS.entries()).map(\n ([name, duration]) => (\n - \n {name}: {duration}ms\n
\n ),\n )}\n
\n )}\n Service Worker Cache
\n {' '}\n {' '}\n {' '}\n \n \n )}\n \n
\n );\n}\n\nasync function getCachesKeys() {\n const keys = await caches.keys();\n const total = {};\n for (const key of keys) {\n const cache = await caches.open(key);\n const k = await cache.keys();\n total[key] = k.length;\n }\n return total;\n}\n\nasync function getCachesSize() {\n const keys = await caches.keys();\n let total = {};\n let TOTAL = 0;\n for (const key of keys) {\n const cache = await caches.open(key);\n const k = await cache.keys();\n for (const item of k) {\n try {\n const response = await cache.match(item);\n const blob = await response.blob();\n total[key] = (total[key] || 0) + blob.size;\n TOTAL += blob.size;\n } catch (e) {\n alert('Failed to get cache size for ' + item);\n alert(e);\n }\n }\n }\n return {\n ...Object.fromEntries(\n Object.entries(total).map(([k, v]) => [k, prettyBytes(v)]),\n ),\n TOTAL: prettyBytes(TOTAL),\n };\n}\n\nfunction clearCacheKey(key) {\n return caches.delete(key);\n}\n\nasync function clearCaches() {\n const keys = await caches.keys();\n for (const key of keys) {\n await caches.delete(key);\n }\n}\n\nfunction PushNotificationsSection({ onClose }) {\n const { t } = useLingui();\n if (!isPushSupported()) return null;\n\n const { instance } = api();\n const [uiState, setUIState] = useState('default');\n const pushFormRef = useRef();\n const [allowNotifications, setAllowNotifications] = useState(false);\n const [needRelogin, setNeedRelogin] = useState(false);\n const previousPolicyRef = useRef();\n useEffect(() => {\n (async () => {\n setUIState('loading');\n try {\n const { subscription, backendSubscription } = await initSubscription();\n if (\n backendSubscription?.policy &&\n backendSubscription.policy !== 'none'\n ) {\n setAllowNotifications(true);\n const { alerts, policy } = backendSubscription;\n console.log('backendSubscription', backendSubscription);\n previousPolicyRef.current = policy;\n const { elements } = pushFormRef.current;\n const policyEl = elements.namedItem('policy');\n if (policyEl) policyEl.value = policy;\n // alerts is {}, iterate it\n Object.entries(alerts).forEach(([alert, value]) => {\n const el = elements.namedItem(alert);\n if (el?.type === 'checkbox') {\n el.checked = !!value;\n }\n });\n }\n setUIState('default');\n } catch (err) {\n console.warn(err);\n if (/outside.*authorized/i.test(err.message)) {\n setNeedRelogin(true);\n } else {\n alert(err?.message || err);\n }\n setUIState('error');\n }\n })();\n }, []);\n\n const isLoading = uiState === 'loading';\n\n return (\n \n );\n}\n\nexport default Settings;\n","const focusDeck = () => {\n let timer = setTimeout(() => {\n const columns = document.getElementById('columns');\n if (columns) {\n // Focus focused column\n const focusedColumn = columns.querySelector('.deck-container.focus');\n if (focusedColumn) {\n focusedColumn.focus();\n } else {\n // Focus first column within viewport\n const firstVisibleColumn = Array.from(\n columns.querySelectorAll('.deck-container'),\n ).find((column) => {\n const columnRect = column.getBoundingClientRect();\n return columnRect.left >= 0;\n });\n if (firstVisibleColumn) {\n firstVisibleColumn.focus();\n } else {\n // Focus first column\n columns.querySelector('.deck-container')?.focus?.();\n }\n }\n } else {\n const modals = document.querySelectorAll('#modal-container > *');\n if (modals?.length) {\n // Focus last modal\n const modal = modals[modals.length - 1]; // last one\n const modalFocusElement =\n modal.querySelector('[tabindex=\"-1\"]') || modal;\n if (modalFocusElement) {\n modalFocusElement.focus();\n return;\n }\n }\n const backDrop = document.querySelector('.deck-backdrop');\n if (backDrop) return;\n // Focus last deck\n const pages = document.querySelectorAll('.deck-container');\n const page = pages[pages.length - 1]; // last one\n if (page && page.tabIndex === -1) {\n console.log('FOCUS', page);\n page.focus();\n }\n }\n }, 100);\n return () => clearTimeout(timer);\n};\n\nexport default focusDeck;\n","import { useEffect, useRef } from 'preact/hooks';\nimport { useLocation } from 'react-router-dom';\n\n// Hook that runs a callback when the location changes\n// Won't run on the first render\n\nexport default function useLocationChange(fn) {\n if (!fn) return;\n const location = useLocation();\n const currentLocationRef = useRef(location.pathname);\n useEffect(() => {\n // console.log('location', {\n // current: currentLocationRef.current,\n // next: location.pathname,\n // });\n if (\n currentLocationRef.current &&\n location.pathname !== currentLocationRef.current\n ) {\n fn?.();\n }\n }, [location.pathname, fn]);\n}\n","import { api } from './api';\nimport pmem from './pmem';\nimport store from './store';\n\nconst FETCH_MAX_AGE = 1000 * 60; // 1 minute\nconst MAX_AGE = 24 * 60 * 60 * 1000; // 1 day\n\nexport const fetchLists = pmem(\n async () => {\n const { masto } = api();\n const lists = await masto.v1.lists.list();\n lists.sort((a, b) => a.title.localeCompare(b.title));\n\n if (lists.length) {\n setTimeout(() => {\n // Save to local storage, with saved timestamp\n store.account.set('lists', {\n lists,\n updatedAt: Date.now(),\n });\n }, 1);\n }\n\n return lists;\n },\n {\n maxAge: FETCH_MAX_AGE,\n },\n);\n\nexport async function getLists() {\n try {\n const { lists, updatedAt } = store.account.get('lists') || {};\n if (!lists?.length) return await fetchLists();\n if (Date.now() - updatedAt > MAX_AGE) {\n // Stale-while-revalidate\n fetchLists();\n return lists;\n }\n return lists;\n } catch (e) {\n return [];\n }\n}\n\nexport const fetchList = pmem(\n (id) => {\n const { masto } = api();\n return masto.v1.lists.$select(id).fetch();\n },\n {\n maxAge: FETCH_MAX_AGE,\n },\n);\n\nexport async function getList(id) {\n const { lists } = store.account.get('lists') || {};\n console.log({ lists });\n if (lists?.length) {\n const theList = lists.find((l) => l.id === id);\n if (theList) return theList;\n }\n try {\n return fetchList(id);\n } catch (e) {\n return null;\n }\n}\n\nexport async function getListTitle(id) {\n const list = await getList(id);\n return list?.title || '';\n}\n\nexport function addListStore(list) {\n const { lists } = store.account.get('lists') || {};\n if (lists?.length) {\n lists.push(list);\n lists.sort((a, b) => a.title.localeCompare(b.title));\n store.account.set('lists', {\n lists,\n updatedAt: Date.now(),\n });\n }\n}\n\nexport function updateListStore(list) {\n const { lists } = store.account.get('lists') || {};\n if (lists?.length) {\n const index = lists.findIndex((l) => l.id === list.id);\n if (index !== -1) {\n lists[index] = list;\n lists.sort((a, b) => a.title.localeCompare(b.title));\n store.account.set('lists', {\n lists,\n updatedAt: Date.now(),\n });\n }\n }\n}\n\nexport function deleteListStore(listID) {\n const { lists } = store.account.get('lists') || {};\n if (lists?.length) {\n const index = lists.findIndex((l) => l.id === listID);\n if (index !== -1) {\n lists.splice(index, 1);\n store.account.set('lists', {\n lists,\n updatedAt: Date.now(),\n });\n }\n }\n}\n","import './list-exclusive-badge.css';\n\nimport { useLingui } from '@lingui/react/macro';\n\nimport Icon from './icon';\n\nfunction ListExclusiveBadge({ insignificant }) {\n const { t } = useLingui();\n return (\n \n );\n}\n\nexport default ListExclusiveBadge;\n","import { Trans, useLingui } from '@lingui/react/macro';\nimport { useEffect, useRef, useState } from 'preact/hooks';\n\nimport { api } from '../utils/api';\nimport { addListStore, deleteListStore, updateListStore } from '../utils/lists';\nimport supports from '../utils/supports';\n\nimport Icon from './icon';\nimport ListExclusiveBadge from './list-exclusive-badge';\nimport MenuConfirm from './menu-confirm';\n\nfunction ListAddEdit({ list, onClose }) {\n const { t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('default');\n const editMode = !!list;\n const nameFieldRef = useRef();\n const repliesPolicyFieldRef = useRef();\n const exclusiveFieldRef = useRef();\n useEffect(() => {\n if (editMode) {\n nameFieldRef.current.value = list.title;\n repliesPolicyFieldRef.current.value = list.repliesPolicy;\n if (exclusiveFieldRef.current) {\n exclusiveFieldRef.current.checked = list.exclusive;\n }\n }\n }, [editMode]);\n const supportsExclusive =\n supports('@mastodon/list-exclusive') ||\n supports('@gotosocial/list-exclusive');\n\n return (\n \n {!!onClose && (\n
\n )}{' '}\n
\n {editMode ? t`Edit list` : t`New list`}
\n \n
\n \n \n
\n );\n}\n\nexport default ListAddEdit;\n","import './account-info.css';\n\nimport { msg, plural } from '@lingui/core/macro';\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { MenuDivider, MenuItem } from '@szhsin/react-menu';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'preact/hooks';\nimport punycode from 'punycode/';\n\nimport { api } from '../utils/api';\nimport enhanceContent from '../utils/enhance-content';\nimport getHTMLText from '../utils/getHTMLText';\nimport handleContentLinks from '../utils/handle-content-links';\nimport i18nDuration from '../utils/i18n-duration';\nimport { getLists } from '../utils/lists';\nimport niceDateTime from '../utils/nice-date-time';\nimport pmem from '../utils/pmem';\nimport { fetchRelationships } from '../utils/relationships';\nimport shortenNumber from '../utils/shorten-number';\nimport showCompose from '../utils/show-compose';\nimport showToast from '../utils/show-toast';\nimport states from '../utils/states';\nimport store from '../utils/store';\nimport {\n getAccounts,\n getCurrentAccountID,\n saveAccounts,\n updateAccount,\n} from '../utils/store-utils';\nimport supports from '../utils/supports';\n\nimport AccountBlock from './account-block';\nimport Avatar from './avatar';\nimport EmojiText from './emoji-text';\nimport Icon from './icon';\nimport Link from './link';\nimport ListAddEdit from './list-add-edit';\nimport Loader from './loader';\nimport MenuConfirm from './menu-confirm';\nimport Menu2 from './menu2';\nimport Modal from './modal';\nimport SubMenu2 from './submenu2';\nimport TranslationBlock from './translation-block';\n\nconst MUTE_DURATIONS = [\n 60 * 5, // 5 minutes\n 60 * 30, // 30 minutes\n 60 * 60, // 1 hour\n 60 * 60 * 6, // 6 hours\n 60 * 60 * 24, // 1 day\n 60 * 60 * 24 * 3, // 3 days\n 60 * 60 * 24 * 7, // 1 week\n 60 * 60 * 24 * 30, // 30 days\n 0, // forever\n];\nconst MUTE_DURATIONS_LABELS = {\n 0: msg`Forever`,\n 300: i18nDuration(5, 'minute'),\n 1_800: i18nDuration(30, 'minute'),\n 3_600: i18nDuration(1, 'hour'),\n 21_600: i18nDuration(6, 'hour'),\n 86_400: i18nDuration(1, 'day'),\n 259_200: i18nDuration(3, 'day'),\n 604_800: i18nDuration(1, 'week'),\n 2592_000: i18nDuration(30, 'day'),\n};\n\nconst LIMIT = 80;\n\nconst ACCOUNT_INFO_MAX_AGE = 1000 * 60 * 10; // 10 mins\n\nfunction fetchFamiliarFollowers(currentID, masto) {\n return masto.v1.accounts.familiarFollowers.fetch({\n id: [currentID],\n });\n}\nconst memFetchFamiliarFollowers = pmem(fetchFamiliarFollowers, {\n maxAge: ACCOUNT_INFO_MAX_AGE,\n});\n\nasync function fetchPostingStats(accountID, masto) {\n const fetchStatuses = masto.v1.accounts\n .$select(accountID)\n .statuses.list({\n limit: 20,\n })\n .values()\n .next();\n\n const { value: statuses } = await fetchStatuses;\n console.log('fetched statuses', statuses);\n const stats = {\n total: statuses.length,\n originals: 0,\n replies: 0,\n boosts: 0,\n };\n // Categories statuses by type\n // - Original posts (not replies to others)\n // - Threads (self-replies + 1st original post)\n // - Boosts (reblogs)\n // - Replies (not-self replies)\n statuses.forEach((status) => {\n if (status.reblog) {\n stats.boosts++;\n } else if (\n !!status.inReplyToId &&\n status.inReplyToAccountId !== status.account.id // Not self-reply\n ) {\n stats.replies++;\n } else {\n stats.originals++;\n }\n });\n\n // Count days since last post\n if (statuses.length) {\n stats.daysSinceLastPost = Math.ceil(\n (Date.now() - new Date(statuses[statuses.length - 1].createdAt)) /\n 86400000,\n );\n }\n\n console.log('posting stats', stats);\n return stats;\n}\nconst memFetchPostingStats = pmem(fetchPostingStats, {\n maxAge: ACCOUNT_INFO_MAX_AGE,\n});\n\nconst ENDORSEMENTS_LIMIT = 80;\n\nfunction AccountInfo({\n account,\n fetchAccount = () => {},\n standalone,\n instance,\n authenticated,\n showEndorsements = false,\n}) {\n const { i18n, t } = useLingui();\n const { masto, authenticated: currentAuthenticated } = api({\n instance,\n });\n const { masto: currentMasto, instance: currentInstance } = api();\n const [uiState, setUIState] = useState('default');\n const isString = typeof account === 'string';\n const [info, setInfo] = useState(isString ? null : account);\n\n const sameCurrentInstance = useMemo(\n () => instance === currentInstance,\n [instance, currentInstance],\n );\n\n useEffect(() => {\n if (!isString) {\n setInfo(account);\n return;\n }\n setUIState('loading');\n (async () => {\n try {\n const info = await fetchAccount();\n states.accounts[`${info.id}@${instance}`] = info;\n setInfo(info);\n setUIState('default');\n } catch (e) {\n console.error(e);\n setInfo(null);\n setUIState('error');\n }\n })();\n }, [isString, account, fetchAccount]);\n\n const {\n acct,\n avatar,\n avatarStatic,\n bot,\n createdAt,\n displayName,\n emojis,\n fields,\n followersCount,\n followingCount,\n group,\n // header,\n // headerStatic,\n id,\n lastStatusAt,\n locked,\n note,\n statusesCount,\n url,\n username,\n memorial,\n moved,\n roles,\n hideCollections,\n } = info || {};\n let headerIsAvatar = false;\n let { header, headerStatic } = info || {};\n if (!header || /missing\\.png$/.test(header)) {\n if (avatar && !/missing\\.png$/.test(avatar)) {\n header = avatar;\n headerIsAvatar = true;\n if (avatarStatic && !/missing\\.png$/.test(avatarStatic)) {\n headerStatic = avatarStatic;\n }\n }\n }\n\n const isSelf = useMemo(() => id === getCurrentAccountID(), [id]);\n\n useEffect(() => {\n const infoHasEssentials = !!(\n info?.id &&\n info?.username &&\n info?.acct &&\n info?.avatar &&\n info?.avatarStatic &&\n info?.displayName &&\n info?.url\n );\n if (isSelf && instance && infoHasEssentials) {\n const accounts = getAccounts();\n let updated = false;\n accounts.forEach((account) => {\n if (account.info.id === info.id && account.instanceURL === instance) {\n account.info = info;\n updated = true;\n }\n });\n if (updated) {\n console.log('Updated account info', info);\n saveAccounts(accounts);\n }\n }\n }, [isSelf, info, instance]);\n\n const accountInstance = useMemo(() => {\n if (!url) return null;\n const hostname = URL.parse(url)?.hostname;\n if (!hostname) return null;\n const domain = punycode.toUnicode(hostname);\n return domain;\n }, [url]);\n\n const [headerCornerColors, setHeaderCornerColors] = useState([]);\n\n const followersIterator = useRef();\n const familiarFollowersCache = useRef([]);\n async function fetchFollowers(firstLoad) {\n if (firstLoad || !followersIterator.current) {\n followersIterator.current = masto.v1.accounts\n .$select(id)\n .followers.list({\n limit: LIMIT,\n })\n .values();\n }\n const results = await followersIterator.current.next();\n if (isSelf) return results;\n if (!sameCurrentInstance) return results;\n\n const { value } = results;\n let newValue = [];\n // On first load, fetch familiar followers, merge to top of results' `value`\n // Remove dups on every fetch\n if (firstLoad) {\n let familiarFollowers = [];\n try {\n familiarFollowers = await masto.v1.accounts.familiarFollowers.fetch({\n id: [id],\n });\n } catch (e) {}\n familiarFollowersCache.current = familiarFollowers?.[0]?.accounts || [];\n newValue = [\n ...familiarFollowersCache.current,\n ...value.filter(\n (account) =>\n !familiarFollowersCache.current.some(\n (familiar) => familiar.id === account.id,\n ),\n ),\n ];\n } else if (value?.length) {\n newValue = value.filter(\n (account) =>\n !familiarFollowersCache.current.some(\n (familiar) => familiar.id === account.id,\n ),\n );\n }\n\n return {\n ...results,\n value: newValue,\n };\n }\n\n const followingIterator = useRef();\n async function fetchFollowing(firstLoad) {\n if (firstLoad || !followingIterator.current) {\n followingIterator.current = masto.v1.accounts\n .$select(id)\n .following.list({\n limit: LIMIT,\n })\n .values();\n }\n const results = await followingIterator.current.next();\n return results;\n }\n\n const LinkOrDiv = standalone ? 'div' : Link;\n const accountLink = instance ? `/${instance}/a/${id}` : `/a/${id}`;\n\n const [familiarFollowers, setFamiliarFollowers] = useState([]);\n const [postingStats, setPostingStats] = useState();\n const [postingStatsUIState, setPostingStatsUIState] = useState('default');\n const hasPostingStats = !!postingStats?.total;\n\n const renderFamiliarFollowers = async (currentID) => {\n try {\n const followers = await memFetchFamiliarFollowers(\n currentID,\n currentMasto,\n );\n console.log('fetched familiar followers', followers);\n setFamiliarFollowers(\n followers[0].accounts.slice(0, FAMILIAR_FOLLOWERS_LIMIT),\n );\n } catch (e) {\n console.error(e);\n }\n };\n\n const renderPostingStats = async () => {\n if (!id) return;\n setPostingStatsUIState('loading');\n try {\n const stats = await memFetchPostingStats(id, masto);\n setPostingStats(stats);\n setPostingStatsUIState('default');\n } catch (e) {\n console.error(e);\n setPostingStatsUIState('error');\n }\n };\n\n const onRelationshipChange = useCallback(\n ({ relationship, currentID }) => {\n if (!relationship.following) {\n renderFamiliarFollowers(currentID);\n if (!standalone && statusesCount > 0) {\n // Only render posting stats if not standalone and has posts\n renderPostingStats();\n }\n }\n },\n [standalone, id, statusesCount],\n );\n\n const onProfileUpdate = useCallback(\n (newAccount) => {\n if (newAccount.id === id) {\n console.log('Updated account info', newAccount);\n setInfo(newAccount);\n states.accounts[`${newAccount.id}@${instance}`] = newAccount;\n }\n },\n [id, instance],\n );\n\n const isStringURL = isString && account && /^https?:\\/\\//.test(account);\n\n const [showEditProfile, setShowEditProfile] = useState(false);\n\n const [renderEndorsements, setRenderEndorsements] = useState(false);\n\n return (\n <>\n \n {uiState === 'error' && (\n
\n )}\n {uiState === 'loading' ? (\n <>\n
\n
\n \n
███████ ████ ████
\n
████ ████████ ██████ █████████ ████ ██
\n
\n \n \n \n \n \n \n
\n \n >\n ) : (\n info && (\n <>\n {!!moved && (\n
\n
\n \n {displayName} has indicated that their new account\n is now:\n \n
\n
{\n e.stopPropagation();\n states.showAccount = moved;\n }}\n />\n \n )}\n {!!header && !/missing\\.png$/.test(header) && (\n {\n if (e.target.crossOrigin) {\n if (e.target.src !== headerStatic) {\n e.target.src = headerStatic;\n } else {\n e.target.removeAttribute('crossorigin');\n e.target.src = header;\n }\n } else if (e.target.src !== headerStatic) {\n e.target.src = headerStatic;\n } else {\n e.target.remove();\n }\n }}\n crossOrigin=\"anonymous\"\n onLoad={(e) => {\n e.target.classList.add('loaded');\n try {\n // Get color from four corners of image\n const canvas = window.OffscreenCanvas\n ? new OffscreenCanvas(1, 1)\n : document.createElement('canvas');\n const ctx = canvas.getContext('2d', {\n willReadFrequently: true,\n });\n canvas.width = e.target.width;\n canvas.height = e.target.height;\n ctx.imageSmoothingEnabled = false;\n ctx.drawImage(e.target, 0, 0);\n // const colors = [\n // ctx.getImageData(0, 0, 1, 1).data,\n // ctx.getImageData(e.target.width - 1, 0, 1, 1).data,\n // ctx.getImageData(0, e.target.height - 1, 1, 1).data,\n // ctx.getImageData(\n // e.target.width - 1,\n // e.target.height - 1,\n // 1,\n // 1,\n // ).data,\n // ];\n // Get 10x10 pixels from corners, get average color from each\n const pixelDimension = 10;\n const colors = [\n ctx.getImageData(0, 0, pixelDimension, pixelDimension)\n .data,\n ctx.getImageData(\n e.target.width - pixelDimension,\n 0,\n pixelDimension,\n pixelDimension,\n ).data,\n ctx.getImageData(\n 0,\n e.target.height - pixelDimension,\n pixelDimension,\n pixelDimension,\n ).data,\n ctx.getImageData(\n e.target.width - pixelDimension,\n e.target.height - pixelDimension,\n pixelDimension,\n pixelDimension,\n ).data,\n ].map((data) => {\n let r = 0;\n let g = 0;\n let b = 0;\n let a = 0;\n for (let i = 0; i < data.length; i += 4) {\n r += data[i];\n g += data[i + 1];\n b += data[i + 2];\n a += data[i + 3];\n }\n const dataLength = data.length / 4;\n return [\n r / dataLength,\n g / dataLength,\n b / dataLength,\n a / dataLength,\n ];\n });\n const rgbColors = colors.map((color) => {\n const [r, g, b, a] = lightenRGB(color);\n return `rgba(${r}, ${g}, ${b}, ${a})`;\n });\n setHeaderCornerColors(rgbColors);\n console.log({ colors, rgbColors });\n } catch (e) {\n // Silently fail\n }\n }}\n />\n )}\n
\n {standalone ? (\n \n {}}\n />\n \n }\n >\n \n \n \n \n \n {!!headerStatic && !headerIsAvatar && (\n \n )}\n {currentAuthenticated &&\n isSelf &&\n supports('@mastodon/profile-edit') && (\n <>\n \n \n >\n )}\n \n ) : (\n \n )}\n \n \n \n {!!memorial && (\n \n In Memoriam\n \n )}\n {!!bot && (\n \n Automated\n \n )}\n {!!group && (\n \n Group\n \n )}\n {roles?.map((role) => (\n \n {role.name}\n {!!accountInstance && (\n <>\n {' '}\n \n {accountInstance}\n \n >\n )}\n \n ))}\n \n \n {!!postingStats && (\n {\n // states.showAccount = false;\n // }}\n >\n \n
\n {hasPostingStats ? (\n
\n
\n {postingStats.daysSinceLastPost < 365\n ? plural(postingStats.total, {\n one: plural(\n postingStats.daysSinceLastPost,\n {\n one: `Last 1 post in the past 1 day`,\n other: `Last 1 post in the past ${postingStats.daysSinceLastPost} days`,\n },\n ),\n other: plural(\n postingStats.daysSinceLastPost,\n {\n one: `Last ${postingStats.total} posts in the past 1 day`,\n other: `Last ${postingStats.total} posts in the past ${postingStats.daysSinceLastPost} days`,\n },\n ),\n })\n : plural(postingStats.total, {\n one: 'Last 1 post in the past year(s)',\n other: `Last ${postingStats.total} posts in the past year(s)`,\n })}\n
\n
\n
\n \n {' '}\n Original\n {' '}\n \n {' '}\n Replies\n {' '}\n \n {' '}\n Boosts\n \n
\n
\n ) : (\n
\n Post stats unavailable.\n
\n )}\n
\n
\n \n )}\n {!moved && (\n \n )}\n \n \n \n >\n )\n )}\n \n {!!showEditProfile && (\n {\n setShowEditProfile(false);\n }}\n >\n {\n setShowEditProfile(false);\n if (state === 'success' && account) {\n onProfileUpdate(account);\n }\n }}\n />\n \n )}\n >\n );\n}\n\nconst FAMILIAR_FOLLOWERS_LIMIT = 3;\n\nfunction RelatedActions({\n info,\n instance,\n standalone,\n authenticated,\n onRelationshipChange = () => {},\n onProfileUpdate = () => {},\n setShowEditProfile = () => {},\n showEndorsements = false,\n renderEndorsements = false,\n setRenderEndorsements = () => {},\n}) {\n if (!info) return null;\n const { _, t } = useLingui();\n const {\n masto: currentMasto,\n instance: currentInstance,\n authenticated: currentAuthenticated,\n } = api();\n const sameInstance = instance === currentInstance;\n\n const [relationshipUIState, setRelationshipUIState] = useState('default');\n const [relationship, setRelationship] = useState(null);\n\n const { id, acct, url, username, locked, lastStatusAt, note, fields, moved } =\n info;\n const accountID = useRef(id);\n\n const {\n following,\n showingReblogs,\n notifying,\n followedBy,\n blocking,\n blockedBy,\n muting,\n mutingNotifications,\n requested,\n domainBlocking,\n endorsed,\n note: privateNote,\n } = relationship || {};\n\n const [currentInfo, setCurrentInfo] = useState(null);\n const [isSelf, setIsSelf] = useState(false);\n\n const acctWithInstance = acct.includes('@') ? acct : `${acct}@${instance}`;\n\n const supportsEndorsements = supports('@mastodon/endorsements');\n\n useEffect(() => {\n if (info) {\n const currentAccount = getCurrentAccountID();\n let currentID;\n (async () => {\n if (sameInstance && authenticated) {\n currentID = id;\n } else if (!sameInstance && currentAuthenticated) {\n // Grab this account from my logged-in instance\n const acctHasInstance = info.acct.includes('@');\n try {\n const results = await currentMasto.v2.search.list({\n q: acctHasInstance ? info.acct : `${info.username}@${instance}`,\n type: 'accounts',\n limit: 1,\n resolve: true,\n });\n console.log('🥏 Fetched account from logged-in instance', results);\n if (results.accounts.length) {\n currentID = results.accounts[0].id;\n setCurrentInfo(results.accounts[0]);\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n if (!currentID) return;\n\n if (currentAccount === currentID) {\n // It's myself!\n setIsSelf(true);\n return;\n }\n\n accountID.current = currentID;\n\n // if (moved) return;\n\n setRelationshipUIState('loading');\n\n const fetchRelationships = currentMasto.v1.accounts.relationships.fetch(\n {\n id: [currentID],\n },\n );\n\n try {\n const relationships = await fetchRelationships;\n console.log('fetched relationship', relationships);\n setRelationshipUIState('default');\n\n if (relationships.length) {\n const relationship = relationships[0];\n setRelationship(relationship);\n onRelationshipChange({ relationship, currentID });\n }\n } catch (e) {\n console.error(e);\n setRelationshipUIState('error');\n }\n })();\n }\n }, [info, authenticated]);\n\n useEffect(() => {\n if (info && isSelf) {\n updateAccount(info);\n }\n }, [info, isSelf]);\n\n const loading = relationshipUIState === 'loading';\n\n const [showTranslatedBio, setShowTranslatedBio] = useState(false);\n const [showAddRemoveLists, setShowAddRemoveLists] = useState(false);\n const [showPrivateNoteModal, setShowPrivateNoteModal] = useState(false);\n const [lists, setLists] = useState([]);\n\n return (\n <>\n \n \n {followedBy ? (\n \n Follows you\n \n ) : !!lastStatusAt ? (\n \n \n Last post:{' '}\n \n {niceDateTime(lastStatusAt, {\n hideTime: true,\n })}\n \n \n \n ) : (\n \n )}\n {muting && (\n \n Muted\n \n )}\n {blocking && (\n \n Blocked\n \n )}\n {' '}\n \n {!!privateNote && (\n \n )}\n \n \n \n }\n onMenuChange={(e) => {\n if (following && e.open) {\n // Fetch lists that have this account\n (async () => {\n try {\n const lists = await currentMasto.v1.accounts\n .$select(accountID.current)\n .lists.list();\n console.log('fetched account lists', lists);\n setLists(lists);\n } catch (e) {\n console.error(e);\n }\n })();\n }\n }}\n >\n {currentAuthenticated && !isSelf ? (\n <>\n \n \n {supports('@mastodon/profile-private-note') && (\n \n )}\n {following && !!relationship && (\n <>\n \n \n >\n )}\n {supportsEndorsements && following && (\n \n )}\n {showEndorsements &&\n supportsEndorsements &&\n !renderEndorsements && (\n \n )}\n {/* Add/remove from lists is only possible if following the account */}\n {following && (\n \n )}\n \n >\n ) : (\n supportsEndorsements &&\n !renderEndorsements && (\n <>\n \n \n >\n )\n )}\n \n \n \n {!!relationship && (\n <>\n \n {muting ? (\n \n ) : (\n \n \n \n \n \n \n \n >\n }\n >\n \n \n )}\n {followedBy && (\n \n \n \n \n Remove @{username}{' '}\n from followers?\n \n \n >\n }\n onClick={() => {\n setRelationshipUIState('loading');\n (async () => {\n try {\n const newRelationship = await currentMasto.v1.accounts\n .$select(currentInfo?.id || id)\n .removeFromFollowers();\n console.log(\n 'removing from followers',\n newRelationship,\n );\n setRelationship(newRelationship);\n setRelationshipUIState('default');\n showToast(t`@${username} removed from followers`);\n states.reloadGenericAccounts.id = 'followers';\n states.reloadGenericAccounts.counter++;\n } catch (e) {\n console.error(e);\n setRelationshipUIState('error');\n }\n })();\n }}\n >\n \n \n Remove follower…\n \n \n )}\n \n \n \n \n Block @{username}?\n \n \n >\n }\n itemProps={{\n className: 'danger',\n }}\n menuItemClassName=\"danger\"\n onClick={() => {\n // if (!blocking && !confirm(`Block @${username}?`)) {\n // return;\n // }\n setRelationshipUIState('loading');\n (async () => {\n try {\n if (blocking) {\n const newRelationship = await currentMasto.v1.accounts\n .$select(currentInfo?.id || id)\n .unblock();\n console.log('unblocking', newRelationship);\n setRelationship(newRelationship);\n setRelationshipUIState('default');\n showToast(t`Unblocked @${username}`);\n } else {\n const newRelationship = await currentMasto.v1.accounts\n .$select(currentInfo?.id || id)\n .block();\n console.log('blocking', newRelationship);\n setRelationship(newRelationship);\n setRelationshipUIState('default');\n showToast(t`Blocked @${username}`);\n }\n states.reloadGenericAccounts.id = 'block';\n states.reloadGenericAccounts.counter++;\n } catch (e) {\n console.error(e);\n setRelationshipUIState('error');\n if (blocking) {\n showToast(t`Unable to unblock @${username}`);\n } else {\n showToast(t`Unable to block @${username}`);\n }\n }\n })();\n }}\n >\n {blocking ? (\n <>\n \n \n \n Unblock @{username}\n \n \n >\n ) : (\n <>\n \n \n \n Block @{username}…\n \n \n >\n )}\n \n \n >\n )}\n {currentAuthenticated &&\n isSelf &&\n standalone &&\n supports('@mastodon/profile-edit') && (\n <>\n \n \n >\n )}\n {import.meta.env.DEV && currentAuthenticated && isSelf && (\n <>\n \n \n >\n )}\n \n {!relationship && relationshipUIState === 'loading' && (\n \n )}\n {!!relationship && !moved && (\n \n {requested\n ? t`Withdraw follow request?`\n : t`Unfollow @${info.acct || info.username}?`}\n \n }\n menuItemClassName=\"danger\"\n align=\"end\"\n disabled={loading}\n onClick={() => {\n setRelationshipUIState('loading');\n (async () => {\n try {\n let newRelationship;\n\n if (following || requested) {\n // const yes = confirm(\n // requested\n // ? 'Withdraw follow request?'\n // : `Unfollow @${info.acct || info.username}?`,\n // );\n\n // if (yes) {\n newRelationship = await currentMasto.v1.accounts\n .$select(accountID.current)\n .unfollow();\n // }\n } else {\n newRelationship = await currentMasto.v1.accounts\n .$select(accountID.current)\n .follow();\n }\n\n if (newRelationship) {\n setRelationship(newRelationship);\n\n // Show endorsements if start following\n if (newRelationship.following) {\n setRenderEndorsements('onlyOpenIfHasEndorsements');\n }\n }\n setRelationshipUIState('default');\n } catch (e) {\n alert(e);\n setRelationshipUIState('error');\n }\n })();\n }}\n >\n \n \n )}\n \n
\n {!!showTranslatedBio && (\n {\n setShowTranslatedBio(false);\n }}\n >\n setShowTranslatedBio(false)}\n />\n \n )}\n {!!showAddRemoveLists && (\n {\n setShowAddRemoveLists(false);\n }}\n >\n setShowAddRemoveLists(false)}\n />\n \n )}\n {!!showPrivateNoteModal && (\n {\n setShowPrivateNoteModal(false);\n }}\n >\n {\n setRelationship(relationship);\n // onRelationshipChange({ relationship, currentID: accountID.current });\n }}\n onClose={() => setShowPrivateNoteModal(false)}\n />\n \n )}\n >\n );\n}\n\n// Apply more alpha if high luminence\nfunction lightenRGB([r, g, b]) {\n const luminence = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n console.log('luminence', luminence);\n let alpha;\n if (luminence >= 220) {\n alpha = 1;\n } else if (luminence <= 50) {\n alpha = 0.1;\n } else {\n alpha = luminence / 255;\n }\n alpha = Math.min(1, alpha);\n return [r, g, b, alpha];\n}\n\nfunction niceAccountURL(url) {\n if (!url) return;\n const urlObj = URL.parse(url);\n if (!urlObj) return;\n const { host, pathname } = urlObj;\n const path = pathname.replace(/\\/$/, '').replace(/^\\//, '');\n return (\n <>\n {punycode.toUnicode(host)}/\n \n {path}\n >\n );\n}\n\nfunction TranslatedBioSheet({ note, fields, onClose }) {\n const { t } = useLingui();\n const fieldsText =\n fields\n ?.map(({ name, value }) => `${name}\\n${getHTMLText(value)}`)\n .join('\\n\\n') || '';\n\n const text = getHTMLText(note) + (fieldsText ? `\\n\\n${fieldsText}` : '');\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n \n Translated Bio\n
\n \n
\n \n {text}\n
\n \n \n
\n );\n}\n\nfunction AddRemoveListsSheet({ accountID, onClose }) {\n const { t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('default');\n const [lists, setLists] = useState([]);\n const [listsContainingAccount, setListsContainingAccount] = useState([]);\n const [reloadCount, reload] = useReducer((c) => c + 1, 0);\n\n useEffect(() => {\n setUIState('loading');\n (async () => {\n try {\n const lists = await getLists();\n setLists(lists);\n const listsContainingAccount = await masto.v1.accounts\n .$select(accountID)\n .lists.list();\n console.log({ lists, listsContainingAccount });\n setListsContainingAccount(listsContainingAccount);\n setUIState('default');\n } catch (e) {\n console.error(e);\n setUIState('error');\n }\n })();\n }, [reloadCount]);\n\n const [showListAddEditModal, setShowListAddEditModal] = useState(false);\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n \n Add/Remove from Lists\n
\n \n
\n {lists.length > 0 ? (\n \n {lists.map((list) => {\n const inList = listsContainingAccount.some(\n (l) => l.id === list.id,\n );\n return (\n - \n \n
\n );\n })}\n
\n ) : uiState === 'loading' ? (\n \n \n
\n ) : uiState === 'error' ? (\n \n Unable to load lists.\n
\n ) : (\n \n No lists.\n
\n )}\n \n \n {showListAddEditModal && (\n
{\n if (e.target === e.currentTarget) {\n setShowListAddEditModal(false);\n }\n }}\n >\n {\n if (result.state === 'success') {\n reload();\n }\n setShowListAddEditModal(false);\n }}\n />\n \n )}\n
\n );\n}\n\nfunction PrivateNoteSheet({\n account,\n note: initialNote,\n onRelationshipChange = () => {},\n onClose = () => {},\n}) {\n const { t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('default');\n const textareaRef = useRef(null);\n\n useEffect(() => {\n let timer;\n if (textareaRef.current && !initialNote) {\n timer = setTimeout(() => {\n textareaRef.current.focus?.();\n }, 100);\n }\n return () => {\n clearTimeout(timer);\n };\n }, []);\n\n return (\n \n {!!onClose && (\n \n )}\n \n \n \n Private note about{' '}\n \n @{account?.username || account?.acct}\n \n \n \n \n \n \n \n
\n );\n}\n\nconst SUPPORTED_IMAGE_FORMATS = [\n 'image/jpeg',\n 'image/png',\n 'image/gif',\n 'image/webp',\n];\nconst SUPPORTED_IMAGE_FORMATS_STR = SUPPORTED_IMAGE_FORMATS.join(',');\n\nfunction EditProfileSheet({ onClose = () => {} }) {\n const { t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('loading');\n const [account, setAccount] = useState(null);\n const [headerPreview, setHeaderPreview] = useState(null);\n const [avatarPreview, setAvatarPreview] = useState(null);\n\n useEffect(() => {\n (async () => {\n try {\n const acc = await masto.v1.accounts.verifyCredentials();\n setAccount(acc);\n setUIState('default');\n } catch (e) {\n console.error(e);\n setUIState('error');\n }\n })();\n }, []);\n\n console.log('EditProfileSheet', account);\n const { displayName, source, avatar, header } = account || {};\n const { note, fields } = source || {};\n const fieldsAttributesRef = useRef(null);\n\n const avatarMediaAttachments = [\n ...(avatar ? [{ type: 'image', url: avatar }] : []),\n ...(avatarPreview ? [{ type: 'image', url: avatarPreview }] : []),\n ];\n const headerMediaAttachments = [\n ...(header ? [{ type: 'image', url: header }] : []),\n ...(headerPreview ? [{ type: 'image', url: headerPreview }] : []),\n ];\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n
\n {uiState === 'loading' ? (\n \n \n
\n ) : (\n \n )}\n \n
\n );\n}\n\nfunction FieldsAttributesRow({ name, value, disabled, index: i }) {\n const [hasValue, setHasValue] = useState(!!value);\n return (\n \n \n \n | \n \n setHasValue(!!e.currentTarget.value)}\n dir=\"auto\"\n />\n | \n
\n );\n}\n\nfunction AccountHandleInfo({ acct, instance }) {\n // acct = username or username@server\n let [username, server] = acct.split('@');\n if (!server) server = instance;\n const encodedAcct = punycode.toASCII(acct);\n return (\n \n
\n {username}\n @\n {server}\n \n
\n \n username\n {' '}\n \n {' '}\n server domain name\n \n
\n
\n );\n}\n\nfunction Endorsements({\n accountID: id,\n info,\n open = false,\n onlyOpenIfHasEndorsements = false,\n}) {\n const { masto } = api();\n const endorsementsContainer = useRef();\n const [endorsementsUIState, setEndorsementsUIState] = useState('default');\n const [endorsements, setEndorsements] = useState([]);\n const [relationshipsMap, setRelationshipsMap] = useState({});\n useEffect(() => {\n if (!supports('@mastodon/endorsements')) return;\n if (!open) return;\n (async () => {\n setEndorsementsUIState('loading');\n try {\n const accounts = await masto.v1.accounts.$select(id).endorsements.list({\n limit: ENDORSEMENTS_LIMIT,\n });\n console.log({ endorsements: accounts });\n if (!accounts.length) {\n setEndorsementsUIState('default');\n return;\n }\n setEndorsements(accounts);\n setEndorsementsUIState('default');\n setTimeout(() => {\n endorsementsContainer.current.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n }, 300);\n\n const relationships = await fetchRelationships(\n accounts,\n relationshipsMap,\n );\n if (relationships) {\n setRelationshipsMap(relationships);\n }\n } catch (e) {\n console.error(e);\n setEndorsementsUIState('error');\n }\n })();\n }, [open, id]);\n\n const reallyOpen = onlyOpenIfHasEndorsements\n ? open && endorsements.length > 0\n : open;\n\n if (!reallyOpen) return null;\n\n return (\n \n
\n
\n
\n Profiles featured by @{info.username}\n
\n {endorsementsUIState === 'loading' ? (\n
\n \n
\n ) : endorsements.length > 0 ? (\n
10 ? 'expanded' : ''\n }`}\n >\n {endorsements.map((account) => (\n - \n \n
\n ))}\n
\n ) : (\n
\n No featured profiles.\n
\n )}\n
\n
\n
\n );\n}\n\nexport default AccountInfo;\n","import { useLingui } from '@lingui/react/macro';\nimport { useEffect } from 'preact/hooks';\n\nimport { api } from '../utils/api';\nimport states from '../utils/states';\nimport useLocationChange from '../utils/useLocationChange';\n\nimport AccountInfo from './account-info';\nimport Icon from './icon';\n\nfunction AccountSheet({ account, instance: propInstance, onClose }) {\n const { t } = useLingui();\n const { masto, instance, authenticated } = api({ instance: propInstance });\n const isString = typeof account === 'string';\n\n useEffect(() => {\n if (!isString) {\n states.accounts[`${account.id}@${instance}`] = account;\n }\n }, [account]);\n\n useLocationChange(onClose);\n\n return (\n {\n // const accountBlock = e.target.closest('.account-block');\n // if (accountBlock) {\n // onClose({\n // destination: 'account-statuses',\n // });\n // }\n // }}\n >\n {!!onClose && (\n
\n )}\n
{\n if (isString) {\n try {\n const info = await masto.v1.accounts.lookup({\n acct: account,\n skip_webfinger: false,\n });\n return info;\n } catch (e) {\n const result = await masto.v2.search.list({\n q: account,\n type: 'accounts',\n limit: authenticated ? 1 : 11, // Magic number\n resolve: authenticated,\n });\n if (result.accounts.length) {\n const accountWithSameString = result.accounts.find(\n (a) => a.url === account || account.startsWith(a.url),\n );\n if (accountWithSameString) {\n return accountWithSameString;\n }\n }\n if (/^https?:\\/\\/[^/]+\\/@[^/]+$/.test(account)) {\n const accountURL = URL.parse(account);\n if (accountURL) {\n const { hostname, pathname } = accountURL;\n const acct =\n pathname.replace(/^\\//, '').replace(/\\/$/, '') +\n '@' +\n hostname;\n const result = await masto.v2.search.list({\n q: acct,\n type: 'accounts',\n limit: 1,\n resolve: authenticated,\n });\n if (result.accounts.length) {\n return result.accounts[0];\n }\n }\n }\n }\n } else {\n return account;\n }\n }}\n />\n \n );\n}\n\nexport default AccountSheet;\n","import './drafts.css';\n\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { useEffect, useMemo, useReducer, useState } from 'react';\n\nimport { api } from '../utils/api';\nimport db from '../utils/db';\nimport niceDateTime from '../utils/nice-date-time';\nimport states from '../utils/states';\nimport { getCurrentAccountNS } from '../utils/store-utils';\n\nimport Icon from './icon';\nimport Loader from './loader';\nimport MenuConfirm from './menu-confirm';\n\nfunction Drafts({ onClose }) {\n const { t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('default');\n const [drafts, setDrafts] = useState([]);\n const [reloadCount, reload] = useReducer((c) => c + 1, 0);\n\n useEffect(() => {\n setUIState('loading');\n (async () => {\n try {\n const keys = await db.drafts.keys();\n if (keys.length) {\n const ns = getCurrentAccountNS();\n const ownKeys = keys.filter((key) => key.startsWith(ns));\n if (ownKeys.length) {\n const drafts = await db.drafts.getMany(ownKeys);\n drafts.sort(\n (a, b) =>\n new Date(b.updatedAt).getTime() -\n new Date(a.updatedAt).getTime(),\n );\n setDrafts(drafts);\n } else {\n setDrafts([]);\n }\n } else {\n setDrafts([]);\n }\n setUIState('default');\n } catch (e) {\n console.error(e);\n setUIState('error');\n }\n })();\n }, [reloadCount]);\n\n const hasDrafts = drafts?.length > 0;\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n
\n {hasDrafts ? (\n <>\n \n {drafts.length > 1 && (\n \n \n Delete all drafts?\n \n }\n menuItemClassName=\"danger\"\n disabled={uiState === 'loading'}\n onClick={() => {\n (async () => {\n // const yes = confirm('Delete all drafts?');\n // if (yes) {\n setUIState('loading');\n try {\n await db.drafts.delMany(\n drafts.map((draft) => draft.key),\n );\n setUIState('default');\n reload();\n } catch (e) {\n console.error(e);\n alert(t`Error deleting drafts! Please try again.`);\n setUIState('error');\n }\n // }\n })();\n }}\n >\n \n \n
\n )}\n >\n ) : (\n \n No drafts found.\n
\n )}\n \n
\n );\n}\n\nfunction MiniDraft({ draft }) {\n const { t } = useLingui();\n const { draftStatus, replyTo } = draft;\n const { status, spoilerText, poll, mediaAttachments } = draftStatus;\n const hasPoll = poll?.options?.length > 0;\n const hasMedia = mediaAttachments?.length > 0;\n const hasPollOrMedia = hasPoll || hasMedia;\n const firstImageMedia = useMemo(() => {\n if (!hasMedia) return;\n const image = mediaAttachments.find((media) => /image/.test(media.type));\n if (!image) return;\n const { file } = image;\n const objectURL = URL.createObjectURL(file);\n return objectURL;\n }, [hasMedia, mediaAttachments]);\n return (\n <>\n \n {hasPollOrMedia && (\n
\n {hasPoll && }\n {hasMedia && (\n \n {' '}\n {mediaAttachments?.length}\n \n )}\n
\n )}\n
\n {!!spoilerText &&
{spoilerText}
}\n {!!status &&
{status}
}\n
\n
\n >\n );\n}\n\nexport default Drafts;\n","import './embed-modal.css';\n\nimport { Trans, useLingui } from '@lingui/react/macro';\n\nimport Icon from './icon';\n\nfunction EmbedModal({ html, url, width, height, onClose = () => {} }) {\n const { t } = useLingui();\n return (\n \n );\n}\n\nexport default EmbedModal;\n","import './generic-accounts.css';\n\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { InView } from 'react-intersection-observer';\nimport { useSnapshot } from 'valtio';\n\nimport { api } from '../utils/api';\nimport { fetchRelationships } from '../utils/relationships';\nimport states from '../utils/states';\nimport useLocationChange from '../utils/useLocationChange';\n\nimport AccountBlock from './account-block';\nimport Icon from './icon';\nimport Link from './link';\nimport Loader from './loader';\nimport Status from './status';\n\nexport default function GenericAccounts({\n instance,\n excludeRelationshipAttrs = [],\n postID,\n onClose = () => {},\n blankCopy,\n}) {\n const { t } = useLingui();\n const { masto, instance: currentInstance } = api();\n const isCurrentInstance = instance ? instance === currentInstance : true;\n const snapStates = useSnapshot(states);\n ``;\n const [uiState, setUIState] = useState('default');\n const [showMore, setShowMore] = useState(false);\n\n useLocationChange(onClose);\n\n if (!snapStates.showGenericAccounts) {\n return null;\n }\n\n const {\n id,\n heading,\n fetchAccounts,\n accounts: staticAccounts,\n showReactions,\n } = snapStates.showGenericAccounts;\n\n const [accounts, setAccounts] = useState(\n staticAccounts?.length ? staticAccounts : [],\n );\n\n const [relationshipsMap, setRelationshipsMap] = useState({});\n\n const loadRelationships = async (accounts) => {\n if (!accounts?.length) return;\n if (!isCurrentInstance) return;\n const relationships = await fetchRelationships(accounts, relationshipsMap);\n if (relationships) {\n setRelationshipsMap({\n ...relationshipsMap,\n ...relationships,\n });\n }\n };\n\n const loadAccounts = (firstLoad) => {\n if (!fetchAccounts) return;\n if (firstLoad && !accounts?.length) setAccounts([]);\n setUIState('loading');\n (async () => {\n try {\n const { done, value } = await fetchAccounts(firstLoad);\n if (Array.isArray(value)) {\n if (firstLoad) {\n const accounts = [];\n for (let i = 0; i < value.length; i++) {\n const account = value[i];\n const theAccount = accounts.find(\n (a, j) => a.id === account.id && i !== j,\n );\n if (!theAccount) {\n accounts.push({\n _types: [],\n ...account,\n });\n } else {\n theAccount._types.push(...account._types);\n }\n }\n setAccounts(accounts);\n } else {\n // setAccounts((prev) => [...prev, ...value]);\n // Merge accounts by id and _types\n setAccounts((prev) => {\n const newAccounts = prev;\n for (const account of value) {\n const theAccount = newAccounts.find((a) => a.id === account.id);\n if (!theAccount) {\n newAccounts.push(account);\n } else {\n theAccount._types.push(...account._types);\n }\n }\n return newAccounts;\n });\n }\n setShowMore(!done);\n\n loadRelationships(value);\n } else {\n setShowMore(false);\n }\n setUIState('default');\n } catch (e) {\n console.error(e);\n setUIState('error');\n }\n })();\n };\n\n const firstLoad = useRef(true);\n useEffect(() => {\n if (accounts?.length > 0) {\n // setAccounts(staticAccounts);\n if (fetchAccounts) {\n loadAccounts(true);\n firstLoad.current = false;\n } else {\n loadRelationships(accounts);\n }\n } else {\n loadAccounts(true);\n firstLoad.current = false;\n }\n }, [fetchAccounts]);\n\n useEffect(() => {\n if (firstLoad.current) return;\n // reloadGenericAccounts contains value like {id: 'mute', counter: 1}\n // We only need to reload if the id matches\n if (snapStates.reloadGenericAccounts?.id === id) {\n loadAccounts(true);\n }\n }, [snapStates.reloadGenericAccounts.counter]);\n\n const post = states.statuses[postID];\n\n return (\n \n
\n
\n {heading || t`Accounts`}
\n \n
\n {post && (\n \n \n \n )}\n {accounts.length > 0 ? (\n <>\n \n {uiState === 'default' ? (\n showMore ? (\n {\n if (inView) {\n loadAccounts();\n }\n }}\n >\n \n \n ) : (\n \n The end.\n
\n )\n ) : (\n uiState === 'loading' && (\n \n \n
\n )\n )}\n >\n ) : uiState === 'loading' ? (\n \n \n
\n ) : uiState === 'error' ? (\n \n Error loading accounts\n
\n ) : (\n \n {blankCopy || t`Nothing to show`}\n
\n )}\n \n
\n );\n}\n","import { Trans, useLingui } from '@lingui/react/macro';\nimport { Menu, MenuItem } from '@szhsin/react-menu';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useSnapshot } from 'valtio';\n\nimport getTranslateTargetLanguage from '../utils/get-translate-target-language';\nimport localeMatch from '../utils/locale-match';\nimport { speak, supportsTTS } from '../utils/speech';\nimport states from '../utils/states';\n\nimport Icon from './icon';\nimport Menu2 from './menu2';\nimport TranslationBlock from './translation-block';\n\nconst FORCE_TRANSLATE_LIMIT = 140;\n\nexport default function MediaAltModal({ alt, lang, onClose }) {\n const { t } = useLingui();\n const snapStates = useSnapshot(states);\n const [forceTranslate, setForceTranslate] = useState(false);\n const targetLanguage = getTranslateTargetLanguage(true);\n const contentTranslationHideLanguages =\n snapStates.settings.contentTranslationHideLanguages || [];\n const differentLanguage =\n !!lang &&\n lang !== targetLanguage &&\n !localeMatch([lang], [targetLanguage]) &&\n !contentTranslationHideLanguages.find(\n (l) => lang === l || localeMatch([lang], [l]),\n );\n\n useEffect(() => {\n const isShortAlt = alt?.length > 0 && alt?.length <= FORCE_TRANSLATE_LIMIT;\n if (differentLanguage && isShortAlt) {\n setForceTranslate(true);\n }\n }, [differentLanguage, alt]);\n\n return (\n \n {!!onClose && (\n
\n )}\n \n
\n \n {alt}\n
\n {(differentLanguage || forceTranslate) && (\n \n )}\n \n
\n );\n}\n","const { min, max } = Math;\n\nexport default (x, low = 0, high = 1) => {\n return min(max(low, x), high);\n};\n","// ported from jQuery's $.type\nconst classToType = {};\nfor (let name of [\n 'Boolean',\n 'Number',\n 'String',\n 'Function',\n 'Array',\n 'Date',\n 'RegExp',\n 'Undefined',\n 'Null'\n]) {\n classToType[`[object ${name}]`] = name.toLowerCase();\n}\nexport default function (obj) {\n return classToType[Object.prototype.toString.call(obj)] || 'object';\n}\n","import type from './type.js';\n\nexport default (args, keyOrder = null) => {\n // if called with more than 3 arguments, we return the arguments\n if (args.length >= 3) return Array.prototype.slice.call(args);\n // with less than 3 args we check if first arg is object\n // and use the keyOrder string to extract and sort properties\n if (type(args[0]) == 'object' && keyOrder) {\n return keyOrder\n .split('')\n .filter((k) => args[0][k] !== undefined)\n .map((k) => args[0][k]);\n }\n // otherwise we just return the first argument\n // (which we suppose is an array of args)\n return args[0].slice(0);\n};\n","const { PI, min, max } = Math;\n\nconst rnd2 = (a) => Math.round(a * 100) / 100;\nconst rnd3 = (a) => Math.round(a * 100) / 100;\n\nexport { default as clip_rgb } from './clip_rgb.js';\nexport { default as limit } from './limit.js';\nexport { default as type } from './type.js';\nexport { default as unpack } from './unpack.js';\nexport { default as last } from './last.js';\n\nconst TWOPI = PI * 2;\nconst PITHIRD = PI / 3;\nconst DEG2RAD = PI / 180;\nconst RAD2DEG = 180 / PI;\n\n/**\n * Reverse the first three elements of an array\n *\n * @param {any[]} arr\n * @returns {any[]}\n */\nfunction reverse3(arr) {\n return [...arr.slice(0, 3).reverse(), ...arr.slice(3)];\n}\n\nexport { PI, TWOPI, PITHIRD, DEG2RAD, RAD2DEG, min, max, rnd2, rnd3, reverse3 };\n","// from https://www.w3.org/TR/css-color-4/multiply-matrices.js\nexport default function multiplyMatrices(A, B) {\n let m = A.length;\n\n if (!Array.isArray(A[0])) {\n // A is vector, convert to [[a, b, c, ...]]\n A = [A];\n }\n\n if (!Array.isArray(B[0])) {\n // B is vector, convert to [[a], [b], [c], ...]]\n B = B.map((x) => [x]);\n }\n\n let p = B[0].length;\n let B_cols = B[0].map((_, i) => B.map((x) => x[i])); // transpose B\n let product = A.map((row) =>\n B_cols.map((col) => {\n if (!Array.isArray(row)) {\n return col.reduce((a, c) => a + c * row, 0);\n }\n\n return row.reduce((a, c, i) => a + c * (col[i] || 0), 0);\n })\n );\n\n if (m === 1) {\n product = product[0]; // Avoid [[a, b, c, ...]]\n }\n\n if (p === 1) {\n return product.map((x) => x[0]); // Avoid [[a], [b], [c], ...]]\n }\n\n return product;\n}\n","const labConstants = {\n // Corresponds roughly to RGB brighter/darker\n Kn: 18,\n\n // D65 standard referent\n labWhitePoint: 'd65',\n Xn: 0.95047,\n Yn: 1,\n Zn: 1.08883,\n\n t0: 0.137931034, // 4 / 29\n t1: 0.206896552, // 6 / 29\n t2: 0.12841855, // 3 * t1 * t1\n t3: 0.008856452, // t1 * t1 * t1,\n\n kE: 216.0 / 24389.0,\n kKE: 8.0,\n kK: 24389.0 / 27.0,\n\n RefWhiteRGB: {\n // sRGB\n X: 0.95047,\n Y: 1,\n Z: 1.08883\n },\n\n MtxRGB2XYZ: {\n m00: 0.4124564390896922,\n m01: 0.21267285140562253,\n m02: 0.0193338955823293,\n m10: 0.357576077643909,\n m11: 0.715152155287818,\n m12: 0.11919202588130297,\n m20: 0.18043748326639894,\n m21: 0.07217499330655958,\n m22: 0.9503040785363679\n },\n\n MtxXYZ2RGB: {\n m00: 3.2404541621141045,\n m01: -0.9692660305051868,\n m02: 0.055643430959114726,\n m10: -1.5371385127977166,\n m11: 1.8760108454466942,\n m12: -0.2040259135167538,\n m20: -0.498531409556016,\n m21: 0.041556017530349834,\n m22: 1.0572251882231791\n },\n\n // used in rgb2xyz\n As: 0.9414285350000001,\n Bs: 1.040417467,\n Cs: 1.089532651,\n\n MtxAdaptMa: {\n m00: 0.8951,\n m01: -0.7502,\n m02: 0.0389,\n m10: 0.2664,\n m11: 1.7135,\n m12: -0.0685,\n m20: -0.1614,\n m21: 0.0367,\n m22: 1.0296\n },\n\n MtxAdaptMaI: {\n m00: 0.9869929054667123,\n m01: 0.43230526972339456,\n m02: -0.008528664575177328,\n m10: -0.14705425642099013,\n m11: 0.5183602715367776,\n m12: 0.04004282165408487,\n m20: 0.15996265166373125,\n m21: 0.0492912282128556,\n m22: 0.9684866957875502\n }\n};\n\nexport default labConstants;\n\n// taken from https://de.mathworks.com/help/images/ref/whitepoint.html\nconst ILLUMINANTS = new Map([\n // ASTM E308-01\n ['a', [1.0985, 0.35585]],\n // Wyszecki & Stiles, p. 769\n ['b', [1.0985, 0.35585]],\n // C ASTM E308-01\n ['c', [0.98074, 1.18232]],\n // D50 (ASTM E308-01)\n ['d50', [0.96422, 0.82521]],\n // D55 (ASTM E308-01)\n ['d55', [0.95682, 0.92149]],\n // D65 (ASTM E308-01)\n ['d65', [0.95047, 1.08883]],\n // E (ASTM E308-01)\n ['e', [1, 1, 1]],\n // F2 (ASTM E308-01)\n ['f2', [0.99186, 0.67393]],\n // F7 (ASTM E308-01)\n ['f7', [0.95041, 1.08747]],\n // F11 (ASTM E308-01)\n ['f11', [1.00962, 0.6435]],\n ['icc', [0.96422, 0.82521]]\n]);\n\nexport function setLabWhitePoint(name) {\n const ill = ILLUMINANTS.get(String(name).toLowerCase());\n if (!ill) {\n throw new Error('unknown Lab illuminant ' + name);\n }\n labConstants.labWhitePoint = name;\n labConstants.Xn = ill[0];\n labConstants.Zn = ill[1];\n}\n\nexport function getLabWhitePoint() {\n return labConstants.labWhitePoint;\n}\n","import LAB_CONSTANTS from './lab-constants.js';\nimport { unpack } from '../../utils/index.js';\n\n/*\n * L* [0..100]\n * a [-100..100]\n * b [-100..100]\n */\nconst lab2rgb = (...args) => {\n args = unpack(args, 'lab');\n const [L, a, b] = args;\n const [x, y, z] = lab2xyz(L, a, b);\n const [r, g, b_] = xyz2rgb(x, y, z);\n return [r, g, b_, args.length > 3 ? args[3] : 1];\n};\n\nconst lab2xyz = (L, a, b) => {\n const { kE, kK, kKE, Xn, Yn, Zn } = LAB_CONSTANTS;\n\n const fy = (L + 16.0) / 116.0;\n const fx = 0.002 * a + fy;\n const fz = fy - 0.005 * b;\n\n const fx3 = fx * fx * fx;\n const fz3 = fz * fz * fz;\n\n const xr = fx3 > kE ? fx3 : (116.0 * fx - 16.0) / kK;\n const yr = L > kKE ? Math.pow((L + 16.0) / 116.0, 3.0) : L / kK;\n const zr = fz3 > kE ? fz3 : (116.0 * fz - 16.0) / kK;\n\n const x = xr * Xn;\n const y = yr * Yn;\n const z = zr * Zn;\n\n return [x, y, z];\n};\n\nconst compand = (linear) => {\n /* sRGB */\n const sign = Math.sign(linear);\n linear = Math.abs(linear);\n return (\n (linear <= 0.0031308\n ? linear * 12.92\n : 1.055 * Math.pow(linear, 1.0 / 2.4) - 0.055) * sign\n );\n};\n\nconst xyz2rgb = (x, y, z) => {\n const { MtxAdaptMa, MtxAdaptMaI, MtxXYZ2RGB, RefWhiteRGB, Xn, Yn, Zn } =\n LAB_CONSTANTS;\n\n const As = Xn * MtxAdaptMa.m00 + Yn * MtxAdaptMa.m10 + Zn * MtxAdaptMa.m20;\n const Bs = Xn * MtxAdaptMa.m01 + Yn * MtxAdaptMa.m11 + Zn * MtxAdaptMa.m21;\n const Cs = Xn * MtxAdaptMa.m02 + Yn * MtxAdaptMa.m12 + Zn * MtxAdaptMa.m22;\n\n const Ad =\n RefWhiteRGB.X * MtxAdaptMa.m00 +\n RefWhiteRGB.Y * MtxAdaptMa.m10 +\n RefWhiteRGB.Z * MtxAdaptMa.m20;\n const Bd =\n RefWhiteRGB.X * MtxAdaptMa.m01 +\n RefWhiteRGB.Y * MtxAdaptMa.m11 +\n RefWhiteRGB.Z * MtxAdaptMa.m21;\n const Cd =\n RefWhiteRGB.X * MtxAdaptMa.m02 +\n RefWhiteRGB.Y * MtxAdaptMa.m12 +\n RefWhiteRGB.Z * MtxAdaptMa.m22;\n\n const X1 =\n (x * MtxAdaptMa.m00 + y * MtxAdaptMa.m10 + z * MtxAdaptMa.m20) *\n (Ad / As);\n const Y1 =\n (x * MtxAdaptMa.m01 + y * MtxAdaptMa.m11 + z * MtxAdaptMa.m21) *\n (Bd / Bs);\n const Z1 =\n (x * MtxAdaptMa.m02 + y * MtxAdaptMa.m12 + z * MtxAdaptMa.m22) *\n (Cd / Cs);\n\n const X2 =\n X1 * MtxAdaptMaI.m00 + Y1 * MtxAdaptMaI.m10 + Z1 * MtxAdaptMaI.m20;\n const Y2 =\n X1 * MtxAdaptMaI.m01 + Y1 * MtxAdaptMaI.m11 + Z1 * MtxAdaptMaI.m21;\n const Z2 =\n X1 * MtxAdaptMaI.m02 + Y1 * MtxAdaptMaI.m12 + Z1 * MtxAdaptMaI.m22;\n\n const r = compand(\n X2 * MtxXYZ2RGB.m00 + Y2 * MtxXYZ2RGB.m10 + Z2 * MtxXYZ2RGB.m20\n );\n const g = compand(\n X2 * MtxXYZ2RGB.m01 + Y2 * MtxXYZ2RGB.m11 + Z2 * MtxXYZ2RGB.m21\n );\n const b = compand(\n X2 * MtxXYZ2RGB.m02 + Y2 * MtxXYZ2RGB.m12 + Z2 * MtxXYZ2RGB.m22\n );\n\n return [r * 255, g * 255, b * 255];\n};\n\nexport default lab2rgb;\nexport { xyz2rgb };\n","import { unpack } from '../../utils/index.js';\nimport multiplyMatrices from '../../utils/multiply-matrices.js';\nimport { xyz2rgb } from '../lab/lab2rgb.js';\n\nconst oklab2rgb = (...args) => {\n args = unpack(args, 'lab');\n const [L, a, b, ...rest] = args;\n const [X, Y, Z] = OKLab_to_XYZ([L, a, b]);\n const [r, g, b_] = xyz2rgb(X, Y, Z);\n return [r, g, b_, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];\n};\n\n// from https://www.w3.org/TR/css-color-4/#color-conversion-code\nfunction OKLab_to_XYZ(OKLab) {\n // Given OKLab, convert to XYZ relative to D65\n var LMStoXYZ = [\n [1.2268798758459243, -0.5578149944602171, 0.2813910456659647],\n [-0.0405757452148008, 1.112286803280317, -0.0717110580655164],\n [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816]\n ];\n var OKLabtoLMS = [\n [1.0, 0.3963377773761749, 0.2158037573099136],\n [1.0, -0.1055613458156586, -0.0638541728258133],\n [1.0, -0.0894841775298119, -1.2914855480194092]\n ];\n\n var LMSnl = multiplyMatrices(OKLabtoLMS, OKLab);\n return multiplyMatrices(\n LMStoXYZ,\n LMSnl.map((c) => c ** 3)\n );\n}\n\nexport default oklab2rgb;\n","import LAB_CONSTANTS from './lab-constants.js';\nimport { unpack } from '../../utils/index.js';\n\nconst rgb2lab = (...args) => {\n const [r, g, b, ...rest] = unpack(args, 'rgb');\n const [x, y, z] = rgb2xyz(r, g, b);\n const [L, a, b_] = xyz2lab(x, y, z);\n return [L, a, b_, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];\n};\n\nfunction xyz2lab(x, y, z) {\n const { Xn, Yn, Zn, kE, kK } = LAB_CONSTANTS;\n const xr = x / Xn;\n const yr = y / Yn;\n const zr = z / Zn;\n\n const fx = xr > kE ? Math.pow(xr, 1.0 / 3.0) : (kK * xr + 16.0) / 116.0;\n const fy = yr > kE ? Math.pow(yr, 1.0 / 3.0) : (kK * yr + 16.0) / 116.0;\n const fz = zr > kE ? Math.pow(zr, 1.0 / 3.0) : (kK * zr + 16.0) / 116.0;\n\n return [116.0 * fy - 16.0, 500.0 * (fx - fy), 200.0 * (fy - fz)];\n}\n\nfunction gammaAdjustSRGB(companded) {\n const sign = Math.sign(companded);\n companded = Math.abs(companded);\n const linear =\n companded <= 0.04045\n ? companded / 12.92\n : Math.pow((companded + 0.055) / 1.055, 2.4);\n return linear * sign;\n}\n\nconst rgb2xyz = (r, g, b) => {\n // normalize and gamma adjust\n r = gammaAdjustSRGB(r / 255);\n g = gammaAdjustSRGB(g / 255);\n b = gammaAdjustSRGB(b / 255);\n\n const { MtxRGB2XYZ, MtxAdaptMa, MtxAdaptMaI, Xn, Yn, Zn, As, Bs, Cs } =\n LAB_CONSTANTS;\n\n let x = r * MtxRGB2XYZ.m00 + g * MtxRGB2XYZ.m10 + b * MtxRGB2XYZ.m20;\n let y = r * MtxRGB2XYZ.m01 + g * MtxRGB2XYZ.m11 + b * MtxRGB2XYZ.m21;\n let z = r * MtxRGB2XYZ.m02 + g * MtxRGB2XYZ.m12 + b * MtxRGB2XYZ.m22;\n\n const Ad = Xn * MtxAdaptMa.m00 + Yn * MtxAdaptMa.m10 + Zn * MtxAdaptMa.m20;\n const Bd = Xn * MtxAdaptMa.m01 + Yn * MtxAdaptMa.m11 + Zn * MtxAdaptMa.m21;\n const Cd = Xn * MtxAdaptMa.m02 + Yn * MtxAdaptMa.m12 + Zn * MtxAdaptMa.m22;\n\n let X = x * MtxAdaptMa.m00 + y * MtxAdaptMa.m10 + z * MtxAdaptMa.m20;\n let Y = x * MtxAdaptMa.m01 + y * MtxAdaptMa.m11 + z * MtxAdaptMa.m21;\n let Z = x * MtxAdaptMa.m02 + y * MtxAdaptMa.m12 + z * MtxAdaptMa.m22;\n\n X *= Ad / As;\n Y *= Bd / Bs;\n Z *= Cd / Cs;\n\n x = X * MtxAdaptMaI.m00 + Y * MtxAdaptMaI.m10 + Z * MtxAdaptMaI.m20;\n y = X * MtxAdaptMaI.m01 + Y * MtxAdaptMaI.m11 + Z * MtxAdaptMaI.m21;\n z = X * MtxAdaptMaI.m02 + Y * MtxAdaptMaI.m12 + Z * MtxAdaptMaI.m22;\n\n return [x, y, z];\n};\n\nexport default rgb2lab;\nexport { rgb2xyz };\n","import { unpack } from '../../utils/index.js';\nimport multiplyMatrices from '../../utils/multiply-matrices.js';\nimport { rgb2xyz } from '../lab/rgb2lab.js';\n\nconst rgb2oklab = (...args) => {\n const [r, g, b, ...rest] = unpack(args, 'rgb');\n const xyz = rgb2xyz(r, g, b);\n const oklab = XYZ_to_OKLab(xyz);\n return [...oklab, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];\n};\n\n// from https://www.w3.org/TR/css-color-4/#color-conversion-code\nfunction XYZ_to_OKLab(XYZ) {\n // Given XYZ relative to D65, convert to OKLab\n const XYZtoLMS = [\n [0.819022437996703, 0.3619062600528904, -0.1288737815209879],\n [0.0329836539323885, 0.9292868615863434, 0.0361446663506424],\n [0.0481771893596242, 0.2642395317527308, 0.6335478284694309]\n ];\n const LMStoOKLab = [\n [0.210454268309314, 0.7936177747023054, -0.0040720430116193],\n [1.9779985324311684, -2.4285922420485799, 0.450593709617411],\n [0.0259040424655478, 0.7827717124575296, -0.8086757549230774]\n ];\n\n const LMS = multiplyMatrices(XYZtoLMS, XYZ);\n // JavaScript Math.cbrt returns a sign-matched cube root\n // beware if porting to other languages\n // especially if tempted to use a general power function\n return multiplyMatrices(\n LMStoOKLab,\n LMS.map((c) => Math.cbrt(c))\n );\n // L in range [0,1]. For use in CSS, multiply by 100 and add a percent\n}\n\nexport default rgb2oklab;\n","import { unpack, DEG2RAD } from '../../utils/index.js';\nconst { sin, cos } = Math;\n\nconst lch2lab = (...args) => {\n /*\n Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.\n These formulas were invented by David Dalrymple to obtain maximum contrast without going\n out of gamut if the parameters are in the range 0-1.\n\n A saturation multiplier was added by Gregor Aisch\n */\n let [l, c, h] = unpack(args, 'lch');\n if (isNaN(h)) h = 0;\n h = h * DEG2RAD;\n return [l, cos(h) * c, sin(h) * c];\n};\n\nexport default lch2lab;\n","import { unpack } from '../../utils/index.js';\nimport lch2lab from '../lch/lch2lab.js';\nimport oklab2rgb from '../oklab/oklab2rgb.js';\n\nconst oklch2rgb = (...args) => {\n args = unpack(args, 'lch');\n const [l, c, h, ...rest] = args;\n const [L, a, b_] = lch2lab(l, c, h);\n const [r, g, b] = oklab2rgb(L, a, b_);\n return [r, g, b, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];\n};\n\nexport default oklch2rgb;\n","import { unpack, RAD2DEG } from '../../utils/index.js';\nconst { sqrt, atan2, round } = Math;\n\nconst lab2lch = (...args) => {\n const [l, a, b] = unpack(args, 'lab');\n const c = sqrt(a * a + b * b);\n let h = (atan2(b, a) * RAD2DEG + 360) % 360;\n if (round(c * 10000) === 0) h = Number.NaN;\n return [l, c, h];\n};\n\nexport default lab2lch;\n","import { unpack } from '../../utils/index.js';\nimport rgb2oklab from '../oklab/rgb2oklab.js';\nimport lab2lch from '../lch/lab2lch.js';\n\nconst rgb2oklch = (...args) => {\n const [r, g, b, ...rest] = unpack(args, 'rgb');\n const [l, a, b_] = rgb2oklab(r, g, b);\n const [L, c, h] = lab2lch(l, a, b_);\n return [L, c, h, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];\n};\n\nexport default rgb2oklch;\n","import { Trans, useLingui } from '@lingui/react/macro';\nimport { MenuDivider, MenuItem } from '@szhsin/react-menu';\nimport { getBlurHashAverageColor } from 'fast-blurhash';\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\nimport { useHotkeys } from 'react-hotkeys-hook';\n\nimport { oklch2rgb, rgb2oklch } from '../utils/color-utils';\nimport isRTL from '../utils/is-rtl';\nimport showToast from '../utils/show-toast';\nimport states from '../utils/states';\nimport store from '../utils/store';\n\nimport Icon from './icon';\nimport Link from './link';\nimport Media from './media';\nimport MenuLink from './menu-link';\nimport Menu2 from './menu2';\n\nconst { PHANPY_IMG_ALT_API_URL: IMG_ALT_API_URL } = import.meta.env;\n\nfunction MediaModal({\n mediaAttachments,\n statusID,\n instance,\n lang,\n index = 0,\n onClose = () => {},\n}) {\n const { t } = useLingui();\n const [uiState, setUIState] = useState('default');\n const carouselRef = useRef(null);\n\n const [currentIndex, setCurrentIndex] = useState(index);\n const carouselFocusItem = useRef(null);\n useLayoutEffect(() => {\n carouselFocusItem.current?.scrollIntoView();\n\n // history.pushState({ mediaModal: true }, '');\n // const handlePopState = (e) => {\n // if (e.state?.mediaModal) {\n // onClose();\n // }\n // };\n // window.addEventListener('popstate', handlePopState);\n // return () => {\n // window.removeEventListener('popstate', handlePopState);\n // };\n }, []);\n const prevStatusID = useRef(statusID);\n useEffect(() => {\n const scrollLeft = index * carouselRef.current.clientWidth;\n const differentStatusID = prevStatusID.current !== statusID;\n if (differentStatusID) prevStatusID.current = statusID;\n carouselRef.current.focus();\n carouselRef.current.scrollTo({\n left: scrollLeft * (isRTL() ? -1 : 1),\n behavior: differentStatusID ? 'auto' : 'smooth',\n });\n }, [index, statusID]);\n\n const [showControls, setShowControls] = useState(true);\n\n useEffect(() => {\n let handleSwipe = (e) => {\n onClose(e, currentIndex, mediaAttachments, carouselRef);\n };\n if (carouselRef.current) {\n carouselRef.current.addEventListener('swiped-down', handleSwipe);\n }\n return () => {\n if (carouselRef.current) {\n carouselRef.current.removeEventListener('swiped-down', handleSwipe);\n }\n };\n }, [currentIndex, mediaAttachments]);\n\n useHotkeys(\n 'esc',\n (e) => {\n onClose(e, currentIndex, mediaAttachments, carouselRef);\n },\n {\n ignoreEventWhen: (e) => {\n const hasModal = !!document.querySelector('#modal-container > *');\n return hasModal || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey;\n },\n useKey: true,\n },\n [onClose, currentIndex, mediaAttachments],\n );\n\n useEffect(() => {\n let handleScroll = () => {\n const { clientWidth, scrollLeft } = carouselRef.current;\n const index = Math.round(Math.abs(scrollLeft) / clientWidth);\n setCurrentIndex(index);\n };\n if (carouselRef.current) {\n carouselRef.current.addEventListener('scroll', handleScroll, {\n passive: true,\n });\n }\n return () => {\n if (carouselRef.current) {\n carouselRef.current.removeEventListener('scroll', handleScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n let timer = setTimeout(() => {\n carouselRef.current?.focus?.();\n }, 100);\n return () => clearTimeout(timer);\n }, []);\n\n const mediaOkColors = useMemo(() => {\n return mediaAttachments?.map((media) => {\n const { blurhash } = media;\n if (blurhash) {\n const averageColor = getBlurHashAverageColor(blurhash);\n return rgb2oklch(averageColor);\n }\n return null;\n });\n }, [mediaAttachments]);\n const mediaAccentColors = useMemo(() => {\n return mediaOkColors?.map((okColor) => {\n if (okColor) {\n return {\n light: oklch2rgb([0.95, 0.01, okColor[2]]),\n dark: oklch2rgb([0.35, 0.01, okColor[2]]),\n default: oklch2rgb([0.6, okColor[1], okColor[2]]),\n };\n }\n return null;\n });\n });\n const mediaAccentGradients = useMemo(() => {\n const gap = 5;\n const range = 100 / mediaAccentColors.length;\n const colors = mediaAccentColors.map((color, i) => {\n const start = i * range + gap;\n const end = (i + 1) * range - gap;\n if (color?.light && color?.dark) {\n return {\n light: `\n rgb(${color.light?.join(',')}) ${start}%, \n rgb(${color.light?.join(',')}) ${end}%\n `,\n dark: `\n rgb(${color.dark?.join(',')}) ${start}%, \n rgb(${color.dark?.join(',')}) ${end}%\n `,\n };\n }\n\n return {\n light: `\n transparent ${start}%, \n transparent ${end}%\n `,\n dark: `\n transparent ${start}%, \n transparent ${end}%\n `,\n };\n });\n const lightGradient = colors.map((color) => color.light).join(', ');\n const darkGradient = colors.map((color) => color.dark).join(', ');\n return {\n light: lightGradient,\n dark: darkGradient,\n };\n }, [mediaAccentColors]);\n\n let toastRef = useRef(null);\n useEffect(() => {\n return () => {\n toastRef.current?.hideToast?.();\n };\n }, []);\n\n useLayoutEffect(() => {\n const currentColor = mediaAccentColors[currentIndex];\n let $meta;\n let metaColor;\n if (currentColor) {\n const theme = store.local.get('theme');\n if (theme) {\n const mediaColor = `rgb(${currentColor[theme].join(',')})`;\n console.log({ mediaColor });\n $meta = document.querySelector(\n `meta[name=\"theme-color\"][data-theme-setting=\"manual\"]`,\n );\n if ($meta) {\n metaColor = $meta.content;\n $meta.content = mediaColor;\n }\n } else {\n const colorScheme = window.matchMedia('(prefers-color-scheme: dark)')\n .matches\n ? 'dark'\n : 'light';\n const mediaColor = `rgb(${currentColor[colorScheme].join(',')})`;\n console.log({ mediaColor });\n $meta = document.querySelector(\n `meta[name=\"theme-color\"][media*=\"${colorScheme}\"]`,\n );\n if ($meta) {\n metaColor = $meta.content;\n $meta.content = mediaColor;\n }\n }\n }\n return () => {\n // Reset meta color\n if ($meta && metaColor) {\n $meta.content = metaColor;\n }\n };\n }, [currentIndex, mediaAccentColors]);\n\n return (\n \n );\n}\n\nexport default MediaModal;\n","import './report-modal.css';\n\nimport { msg } from '@lingui/core/macro';\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { Fragment } from 'preact';\nimport { useMemo, useRef, useState } from 'preact/hooks';\n\nimport { api } from '../utils/api';\nimport showToast from '../utils/show-toast';\nimport { getCurrentInstance } from '../utils/store-utils';\n\nimport AccountBlock from './account-block';\nimport Icon from './icon';\nimport Loader from './loader';\nimport Status from './status';\n\n// NOTE: `dislike` hidden for now, it's actually not used for reporting\n// Mastodon shows another screen for unfollowing, muting or blocking instead of reporting\n\nconst CATEGORIES = [, /*'dislike'*/ 'spam', 'legal', 'violation', 'other'];\n// `violation` will be set if there are `rule_ids[]`\n\nconst CATEGORIES_INFO = {\n // dislike: {\n // label: 'Dislike',\n // description: 'Not something you want to see',\n // },\n spam: {\n label: msg`Spam`,\n description: msg`Malicious links, fake engagement, or repetitive replies`,\n },\n legal: {\n label: msg`Illegal`,\n description: msg`Violates the law of your or the server's country`,\n },\n violation: {\n label: msg`Server rule violation`,\n description: msg`Breaks specific server rules`,\n stampLabel: msg`Violation`,\n },\n other: {\n label: msg`Other`,\n description: msg`Issue doesn't fit other categories`,\n excludeStamp: true,\n },\n};\n\nfunction ReportModal({ account, post, onClose }) {\n const { _, t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('default');\n const [username, domain] = account.acct.split('@');\n\n const [rules, currentDomain] = useMemo(() => {\n const { rules, domain } = getCurrentInstance();\n return [rules || [], domain];\n });\n\n const [selectedCategory, setSelectedCategory] = useState(null);\n const [showRules, setShowRules] = useState(false);\n\n const rulesRef = useRef(null);\n const [hasRules, setHasRules] = useState(false);\n\n return (\n \n
\n
{post ? t`Report Post` : t`Report @${username}`}
\n \n \n
\n \n {post ? (\n
\n ) : (\n
\n )}\n
\n {!!selectedCategory &&\n !CATEGORIES_INFO[selectedCategory].excludeStamp && (\n \n {_(\n CATEGORIES_INFO[selectedCategory].stampLabel ||\n _(CATEGORIES_INFO[selectedCategory].label),\n )}\n \n Pending review\n \n \n )}\n \n \n
\n );\n}\n\nexport default ReportModal;\n","// Copyright (c) 2013 Pieroxy \n// This work is free. You can redistribute it and/or modify it\n// under the terms of the WTFPL, Version 2\n// For more information see LICENSE.txt or http://www.wtfpl.net/\n//\n// For more information, the home page:\n// http://pieroxy.net/blog/pages/lz-string/testing.html\n//\n// LZ-based compression algorithm, version 1.4.5\nvar LZString = (function() {\n\n// private property\nvar f = String.fromCharCode;\nvar keyStrBase64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\nvar keyStrUriSafe = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$\";\nvar baseReverseDic = {};\n\nfunction getBaseValue(alphabet, character) {\n if (!baseReverseDic[alphabet]) {\n baseReverseDic[alphabet] = {};\n for (var i=0 ; i>> 8;\n buf[i*2+1] = current_value % 256;\n }\n return buf;\n },\n\n //decompress from uint8array (UCS-2 big endian format)\n decompressFromUint8Array:function (compressed) {\n if (compressed===null || compressed===undefined){\n return LZString.decompress(compressed);\n } else {\n var buf=new Array(compressed.length/2); // 2 bytes per character\n for (var i=0, TotalLen=buf.length; i> 1;\n }\n } else {\n value = 1;\n for (i=0 ; i> 1;\n }\n }\n context_enlargeIn--;\n if (context_enlargeIn == 0) {\n context_enlargeIn = Math.pow(2, context_numBits);\n context_numBits++;\n }\n delete context_dictionaryToCreate[context_w];\n } else {\n value = context_dictionary[context_w];\n for (i=0 ; i> 1;\n }\n\n\n }\n context_enlargeIn--;\n if (context_enlargeIn == 0) {\n context_enlargeIn = Math.pow(2, context_numBits);\n context_numBits++;\n }\n // Add wc to the dictionary.\n context_dictionary[context_wc] = context_dictSize++;\n context_w = String(context_c);\n }\n }\n\n // Output the code for w.\n if (context_w !== \"\") {\n if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {\n if (context_w.charCodeAt(0)<256) {\n for (i=0 ; i> 1;\n }\n } else {\n value = 1;\n for (i=0 ; i> 1;\n }\n }\n context_enlargeIn--;\n if (context_enlargeIn == 0) {\n context_enlargeIn = Math.pow(2, context_numBits);\n context_numBits++;\n }\n delete context_dictionaryToCreate[context_w];\n } else {\n value = context_dictionary[context_w];\n for (i=0 ; i> 1;\n }\n\n\n }\n context_enlargeIn--;\n if (context_enlargeIn == 0) {\n context_enlargeIn = Math.pow(2, context_numBits);\n context_numBits++;\n }\n }\n\n // Mark the end of the stream\n value = 2;\n for (i=0 ; i> 1;\n }\n\n // Flush the last char\n while (true) {\n context_data_val = (context_data_val << 1);\n if (context_data_position == bitsPerChar-1) {\n context_data.push(getCharFromInt(context_data_val));\n break;\n }\n else context_data_position++;\n }\n return context_data.join('');\n },\n\n decompress: function (compressed) {\n if (compressed == null) return \"\";\n if (compressed == \"\") return null;\n return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });\n },\n\n _decompress: function (length, resetValue, getNextValue) {\n var dictionary = [],\n next,\n enlargeIn = 4,\n dictSize = 4,\n numBits = 3,\n entry = \"\",\n result = [],\n i,\n w,\n bits, resb, maxpower, power,\n c,\n data = {val:getNextValue(0), position:resetValue, index:1};\n\n for (i = 0; i < 3; i += 1) {\n dictionary[i] = i;\n }\n\n bits = 0;\n maxpower = Math.pow(2,2);\n power=1;\n while (power!=maxpower) {\n resb = data.val & data.position;\n data.position >>= 1;\n if (data.position == 0) {\n data.position = resetValue;\n data.val = getNextValue(data.index++);\n }\n bits |= (resb>0 ? 1 : 0) * power;\n power <<= 1;\n }\n\n switch (next = bits) {\n case 0:\n bits = 0;\n maxpower = Math.pow(2,8);\n power=1;\n while (power!=maxpower) {\n resb = data.val & data.position;\n data.position >>= 1;\n if (data.position == 0) {\n data.position = resetValue;\n data.val = getNextValue(data.index++);\n }\n bits |= (resb>0 ? 1 : 0) * power;\n power <<= 1;\n }\n c = f(bits);\n break;\n case 1:\n bits = 0;\n maxpower = Math.pow(2,16);\n power=1;\n while (power!=maxpower) {\n resb = data.val & data.position;\n data.position >>= 1;\n if (data.position == 0) {\n data.position = resetValue;\n data.val = getNextValue(data.index++);\n }\n bits |= (resb>0 ? 1 : 0) * power;\n power <<= 1;\n }\n c = f(bits);\n break;\n case 2:\n return \"\";\n }\n dictionary[3] = c;\n w = c;\n result.push(c);\n while (true) {\n if (data.index > length) {\n return \"\";\n }\n\n bits = 0;\n maxpower = Math.pow(2,numBits);\n power=1;\n while (power!=maxpower) {\n resb = data.val & data.position;\n data.position >>= 1;\n if (data.position == 0) {\n data.position = resetValue;\n data.val = getNextValue(data.index++);\n }\n bits |= (resb>0 ? 1 : 0) * power;\n power <<= 1;\n }\n\n switch (c = bits) {\n case 0:\n bits = 0;\n maxpower = Math.pow(2,8);\n power=1;\n while (power!=maxpower) {\n resb = data.val & data.position;\n data.position >>= 1;\n if (data.position == 0) {\n data.position = resetValue;\n data.val = getNextValue(data.index++);\n }\n bits |= (resb>0 ? 1 : 0) * power;\n power <<= 1;\n }\n\n dictionary[dictSize++] = f(bits);\n c = dictSize-1;\n enlargeIn--;\n break;\n case 1:\n bits = 0;\n maxpower = Math.pow(2,16);\n power=1;\n while (power!=maxpower) {\n resb = data.val & data.position;\n data.position >>= 1;\n if (data.position == 0) {\n data.position = resetValue;\n data.val = getNextValue(data.index++);\n }\n bits |= (resb>0 ? 1 : 0) * power;\n power <<= 1;\n }\n dictionary[dictSize++] = f(bits);\n c = dictSize-1;\n enlargeIn--;\n break;\n case 2:\n return result.join('');\n }\n\n if (enlargeIn == 0) {\n enlargeIn = Math.pow(2, numBits);\n numBits++;\n }\n\n if (dictionary[c]) {\n entry = dictionary[c];\n } else {\n if (c === dictSize) {\n entry = w + w.charAt(0);\n } else {\n return null;\n }\n }\n result.push(entry);\n\n // Add w+entry[0] to the dictionary.\n dictionary[dictSize++] = w + entry.charAt(0);\n enlargeIn--;\n\n w = entry;\n\n if (enlargeIn == 0) {\n enlargeIn = Math.pow(2, numBits);\n numBits++;\n }\n\n }\n }\n};\n return LZString;\n})();\n\nif (typeof define === 'function' && define.amd) {\n define(function () { return LZString; });\n} else if( typeof module !== 'undefined' && module != null ) {\n module.exports = LZString\n} else if( typeof angular !== 'undefined' && angular != null ) {\n angular.module('LZString', [])\n .factory('LZString', function () {\n return LZString;\n });\n}\n","export default \"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2084%2062'%3e%3crect%20width='64'%20height='48'%20x='18'%20y='2'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3crect%20width='32'%20height='48'%20x='2'%20y='12'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%234169E1'%20d='M14%2052a4%204%200%201%201-8%200%204%204%200%200%201%208%200Zm64-42a4%204%200%201%201-8%200%204%204%200%200%201%208%200Z'/%3e%3c/svg%3e\"","export default \"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2082%2062'%3e%3crect%20width='78'%20height='58'%20x='2'%20y='2'%20fill='%23999'%20fill-opacity='.3'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3crect%20width='18'%20height='46'%20x='8'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3crect%20width='18'%20height='46'%20x='32'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3crect%20width='18'%20height='46'%20x='56'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3c/svg%3e\"","export default \"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2084%2062'%3e%3crect%20width='64'%20height='48'%20x='18'%20y='2'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%23999'%20fill-opacity='.3'%20d='M19%203h62v10H19z'/%3e%3cpath%20stroke='%234169E1'%20stroke-width='2'%20d='M43%208a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3cpath%20stroke='%23999'%20stroke-width='2'%20d='M52%208a2%202%200%201%201-4%200%202%202%200%200%201%204%200Zm9%200a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3crect%20width='32'%20height='48'%20x='2'%20y='12'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%23999'%20fill-opacity='.3'%20d='M3%2049h30v10H3z'/%3e%3cpath%20stroke='%234169E1'%20stroke-width='2'%20d='M11%2054a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3cpath%20stroke='%23999'%20stroke-width='2'%20d='M20%2054a2%202%200%201%201-4%200%202%202%200%200%201%204%200Zm9%200a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3c/svg%3e\"","import { api } from '../utils/api';\nimport store from '../utils/store';\n\nconst LIMIT = 200;\nconst MAX_FETCH = 10;\n\nexport async function fetchFollowedTags() {\n const { masto } = api();\n const iterator = masto.v1.followedTags\n .list({\n limit: LIMIT,\n })\n .values();\n const tags = [];\n let fetchCount = 0;\n do {\n const { value, done } = await iterator.next();\n if (done || value?.length === 0) break;\n tags.push(...value);\n fetchCount++;\n } while (fetchCount < MAX_FETCH);\n tags.sort((a, b) => a.name.localeCompare(b.name));\n console.log(tags);\n\n if (tags.length) {\n setTimeout(() => {\n // Save to local storage, with saved timestamp\n store.account.set('followedTags', {\n tags,\n updatedAt: Date.now(),\n });\n }, 1);\n }\n\n return tags;\n}\n\nconst MAX_AGE = 24 * 60 * 60 * 1000; // 1 day\nexport async function getFollowedTags() {\n try {\n const { tags, updatedAt } = store.account.get('followedTags') || {};\n if (!tags?.length) return await fetchFollowedTags();\n if (Date.now() - updatedAt > MAX_AGE) {\n // Stale-while-revalidate\n fetchFollowedTags();\n return tags;\n }\n return tags;\n } catch (e) {\n return [];\n }\n}\n\nconst fauxDiv = document.createElement('div');\nexport const extractTagsFromStatus = (content) => {\n if (!content) return [];\n if (content.indexOf('#') === -1) return [];\n fauxDiv.innerHTML = content;\n const hashtagLinks = fauxDiv.querySelectorAll('a.hashtag');\n if (!hashtagLinks.length) return [];\n return Array.from(hashtagLinks).map((a) =>\n a.innerText.trim().replace(/^[^#]*#+/, ''),\n );\n};\n","import { useEffect, useState } from 'preact/hooks';\n\nfunction AsyncText({ children }) {\n if (typeof children === 'string') return children;\n const [text, setText] = useState('');\n useEffect(() => {\n Promise.resolve(children).then(setText);\n }, [children]);\n return text;\n}\n\nexport default AsyncText;\n","import './shortcuts-settings.css';\n\nimport { useAutoAnimate } from '@formkit/auto-animate/preact';\nimport { msg, t } from '@lingui/core/macro';\nimport { Plural, Trans, useLingui } from '@lingui/react/macro';\nimport {\n compressToEncodedURIComponent,\n decompressFromEncodedURIComponent,\n} from 'lz-string';\nimport { useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport { useSnapshot } from 'valtio';\n\nimport floatingButtonUrl from '../assets/floating-button.svg';\nimport multiColumnUrl from '../assets/multi-column.svg';\nimport tabMenuBarUrl from '../assets/tab-menu-bar.svg';\n\nimport { api } from '../utils/api';\nimport { fetchFollowedTags } from '../utils/followed-tags';\nimport { getLists, getListTitle } from '../utils/lists';\nimport pmem from '../utils/pmem';\nimport showToast from '../utils/show-toast';\nimport states from '../utils/states';\nimport store from '../utils/store';\nimport { getCurrentAccountID } from '../utils/store-utils';\n\nimport AsyncText from './AsyncText';\nimport Icon from './icon';\nimport MenuConfirm from './menu-confirm';\nimport Modal from './modal';\n\nexport const SHORTCUTS_LIMIT = 9;\n\nconst TYPES = [\n 'following',\n 'mentions',\n 'notifications',\n 'list',\n 'public',\n 'trending',\n 'search',\n 'hashtag',\n 'bookmarks',\n 'favourites',\n // NOTE: Hide for now\n // 'account-statuses', // Need @acct search first\n];\nconst TYPE_TEXT = {\n following: msg`Home / Following`,\n notifications: msg`Notifications`,\n list: msg`Lists`,\n public: msg`Public (Local / Federated)`,\n search: msg`Search`,\n 'account-statuses': msg`Account`,\n bookmarks: msg`Bookmarks`,\n favourites: msg`Likes`,\n hashtag: msg`Hashtag`,\n trending: msg`Trending`,\n mentions: msg`Mentions`,\n};\nconst TYPE_PARAMS = {\n list: [\n {\n text: msg`List ID`,\n name: 'id',\n notRequired: true,\n },\n ],\n public: [\n {\n text: msg`Local only`,\n name: 'local',\n type: 'checkbox',\n },\n {\n text: msg`Instance`,\n name: 'instance',\n type: 'text',\n placeholder: msg`Optional, e.g. mastodon.social`,\n notRequired: true,\n },\n ],\n trending: [\n {\n text: msg`Instance`,\n name: 'instance',\n type: 'text',\n placeholder: msg`Optional, e.g. mastodon.social`,\n notRequired: true,\n },\n ],\n search: [\n {\n text: msg`Search term`,\n name: 'query',\n type: 'text',\n placeholder: msg`Optional, unless for multi-column mode`,\n notRequired: true,\n },\n ],\n 'account-statuses': [\n {\n text: '@',\n name: 'id',\n type: 'text',\n placeholder: 'cheeaun@mastodon.social',\n },\n ],\n hashtag: [\n {\n text: '#',\n name: 'hashtag',\n type: 'text',\n placeholder: msg`e.g. PixelArt (Max 5, space-separated)`,\n pattern: '[^#]+',\n },\n {\n text: msg`Media only`,\n name: 'media',\n type: 'checkbox',\n },\n {\n text: msg`Instance`,\n name: 'instance',\n type: 'text',\n placeholder: msg`Optional, e.g. mastodon.social`,\n notRequired: true,\n },\n ],\n};\nconst fetchAccountTitle = pmem(async ({ id }) => {\n const account = await api().masto.v1.accounts.$select(id).fetch();\n return account.username || account.acct || account.displayName;\n});\nexport const SHORTCUTS_META = {\n following: {\n id: 'home',\n title: (_, index) =>\n index === 0\n ? t`Home`\n : t({ id: 'following.title', message: 'Following' }),\n path: '/',\n icon: 'home',\n },\n mentions: {\n id: 'mentions',\n title: msg`Mentions`,\n path: '/mentions',\n icon: 'at',\n },\n notifications: {\n id: 'notifications',\n title: msg`Notifications`,\n path: '/notifications',\n icon: 'notification',\n },\n list: {\n id: ({ id }) => (id ? 'list' : 'lists'),\n title: ({ id }) => (id ? getListTitle(id) : t`Lists`),\n path: ({ id }) => (id ? `/l/${id}` : '/l'),\n icon: 'list',\n excludeViewMode: ({ id }) => (!id ? ['multi-column'] : []),\n },\n public: {\n id: 'public',\n title: ({ local }) => (local ? t`Local` : t`Federated`),\n subtitle: ({ instance }) => instance || api().instance,\n path: ({ local, instance }) => `/${instance}/p${local ? '/l' : ''}`,\n icon: ({ local }) => (local ? 'building' : 'earth'),\n },\n trending: {\n id: 'trending',\n title: msg`Trending`,\n subtitle: ({ instance }) => instance || api().instance,\n path: ({ instance }) => `/${instance}/trending`,\n icon: 'chart',\n },\n search: {\n id: 'search',\n title: ({ query }) => (query ? `“${query}”` : t`Search`),\n path: ({ query }) =>\n query\n ? `/search?q=${encodeURIComponent(query)}&type=statuses`\n : '/search',\n icon: 'search',\n excludeViewMode: ({ query }) => (!query ? ['multi-column'] : []),\n },\n 'account-statuses': {\n id: 'account-statuses',\n title: fetchAccountTitle,\n path: ({ id }) => `/a/${id}`,\n icon: 'user',\n },\n bookmarks: {\n id: 'bookmarks',\n title: msg`Bookmarks`,\n path: '/b',\n icon: 'bookmark',\n },\n favourites: {\n id: 'favourites',\n title: msg`Likes`,\n path: '/f',\n icon: 'heart',\n },\n hashtag: {\n id: 'hashtag',\n title: ({ hashtag }) => hashtag,\n subtitle: ({ instance }) => instance || api().instance,\n path: ({ hashtag, instance, media }) =>\n `${instance ? `/${instance}` : ''}/t/${hashtag.split(/\\s+/).join('+')}${\n media ? '?media=1' : ''\n }`,\n icon: 'hashtag',\n },\n};\n\nfunction ShortcutsSettings({ onClose }) {\n const { _ } = useLingui();\n const snapStates = useSnapshot(states);\n const { shortcuts } = snapStates;\n const [showForm, setShowForm] = useState(false);\n const [showImportExport, setShowImportExport] = useState(false);\n\n const [shortcutsListParent] = useAutoAnimate();\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n \n Shortcuts{' '}\n \n beta\n \n
\n \n
\n \n Specify a list of shortcuts that'll appear as:\n
\n \n {[\n {\n value: 'float-button',\n label: t`Floating button`,\n imgURL: floatingButtonUrl,\n },\n {\n value: 'tab-menu-bar',\n label: t`Tab/Menu bar`,\n imgURL: tabMenuBarUrl,\n },\n {\n value: 'multi-column',\n label: t`Multi-column`,\n imgURL: multiColumnUrl,\n },\n ].map(({ value, label, imgURL }) => {\n const checked =\n snapStates.settings.shortcutsViewMode === value ||\n (value === 'float-button' &&\n !snapStates.settings.shortcutsViewMode);\n return (\n
\n );\n })}\n
\n {shortcuts.length > 0 ? (\n <>\n \n {shortcuts.filter(Boolean).map((shortcut, i) => {\n // const key = i + Object.values(shortcut);\n const key = Object.values(shortcut).join('-');\n const { type } = shortcut;\n if (!SHORTCUTS_META[type]) return null;\n let { icon, title, subtitle, excludeViewMode } =\n SHORTCUTS_META[type];\n if (typeof title === 'function') {\n title = title(shortcut, i);\n } else {\n title = _(title);\n }\n if (typeof subtitle === 'function') {\n subtitle = subtitle(shortcut, i);\n } else {\n subtitle = _(subtitle);\n }\n if (typeof icon === 'function') {\n icon = icon(shortcut, i);\n }\n if (typeof excludeViewMode === 'function') {\n excludeViewMode = excludeViewMode(shortcut, i);\n }\n const excludedViewMode = excludeViewMode?.includes(\n snapStates.settings.shortcutsViewMode,\n );\n return (\n - \n \n \n {title}\n {subtitle && (\n <>\n {' '}\n {subtitle}\n >\n )}\n {excludedViewMode && (\n \n Not available in current view mode\n \n )}\n \n \n \n \n \n {/* */}\n \n
\n );\n })}\n
\n {shortcuts.length === 1 &&\n snapStates.settings.shortcutsViewMode !== 'float-button' && (\n \n {' '}\n \n \n Add more than one shortcut/column to make this work.\n \n \n
\n )}\n >\n ) : (\n \n )}\n \n {shortcuts.length >= SHORTCUTS_LIMIT &&\n (snapStates.settings.shortcutsViewMode === 'multi-column'\n ? t`Max ${SHORTCUTS_LIMIT} columns`\n : t`Max ${SHORTCUTS_LIMIT} shortcuts`)}\n
\n \n \n \n
\n \n {showForm && (\n
{\n if (e.target === e.currentTarget) {\n setShowForm(false);\n }\n }}\n >\n {\n console.log('onSubmit', result);\n if (mode === 'edit') {\n states.shortcuts[showForm.shortcutIndex] = result;\n } else {\n states.shortcuts.push(result);\n }\n }}\n onClose={() => setShowForm(false)}\n />\n \n )}\n {showImportExport && (\n
{\n if (e.target === e.currentTarget) {\n setShowImportExport(false);\n }\n }}\n >\n setShowImportExport(false)}\n />\n \n )}\n
\n );\n}\n\nconst FORM_NOTES = {\n list: msg`Specific list is optional. For multi-column mode, list is required, else the column will not be shown.`,\n search: msg`For multi-column mode, search term is required, else the column will not be shown.`,\n hashtag: msg`Multiple hashtags are supported. Space-separated.`,\n};\n\nfunction ShortcutForm({\n onSubmit,\n disabled,\n shortcut,\n shortcutIndex,\n onClose,\n}) {\n const { _ } = useLingui();\n console.log('shortcut', shortcut);\n const editMode = !!shortcut;\n const [currentType, setCurrentType] = useState(shortcut?.type || null);\n\n const [uiState, setUIState] = useState('default');\n const [lists, setLists] = useState([]);\n const [followedHashtags, setFollowedHashtags] = useState([]);\n useEffect(() => {\n (async () => {\n if (currentType !== 'list') return;\n try {\n setUIState('loading');\n const lists = await getLists();\n setLists(lists);\n setUIState('default');\n } catch (e) {\n console.error(e);\n setUIState('error');\n }\n })();\n\n (async () => {\n if (currentType !== 'hashtag') return;\n try {\n const tags = await fetchFollowedTags();\n setFollowedHashtags(tags);\n } catch (e) {\n console.error(e);\n }\n })();\n }, [currentType]);\n\n const formRef = useRef();\n useEffect(() => {\n if (editMode && currentType && TYPE_PARAMS[currentType]) {\n // Populate form\n const form = formRef.current;\n TYPE_PARAMS[currentType].forEach(({ name, type }) => {\n const input = form.querySelector(`[name=\"${name}\"]`);\n if (input && shortcut[name]) {\n if (type === 'checkbox') {\n input.checked = shortcut[name] === 'on' ? true : false;\n } else {\n input.value = shortcut[name];\n }\n }\n });\n }\n }, [editMode, currentType]);\n\n return (\n \n );\n}\n\nfunction ImportExport({ shortcuts, onClose }) {\n const { _ } = useLingui();\n const { masto } = api();\n const shortcutsStr = useMemo(() => {\n if (!shortcuts) return '';\n if (!shortcuts.filter(Boolean).length) return '';\n return compressToEncodedURIComponent(\n JSON.stringify(shortcuts.filter(Boolean)),\n );\n }, [shortcuts]);\n const [importShortcutStr, setImportShortcutStr] = useState('');\n const [importUIState, setImportUIState] = useState('default');\n const parsedImportShortcutStr = useMemo(() => {\n if (!importShortcutStr) {\n setImportUIState('default');\n return null;\n }\n try {\n const parsed = JSON.parse(\n decompressFromEncodedURIComponent(importShortcutStr),\n );\n // Very basic validation, I know\n if (!Array.isArray(parsed)) throw new Error('Not an array');\n setImportUIState('default');\n return parsed;\n } catch (err) {\n // Fallback to JSON string parsing\n // There's a chance that someone might want to import a JSON string instead of the compressed version\n try {\n const parsed = JSON.parse(importShortcutStr);\n if (!Array.isArray(parsed)) throw new Error('Not an array');\n setImportUIState('default');\n return parsed;\n } catch (err) {\n setImportUIState('error');\n return null;\n }\n }\n }, [importShortcutStr]);\n const hasCurrentSettings = states.shortcuts.length > 0;\n\n const shortcutsImportFieldRef = useRef();\n\n return (\n \n {!!onClose && (\n
\n )}\n
\n \n \n Import/Export Shortcuts\n \n
\n \n
\n \n \n {' '}\n \n Import\n \n
\n \n {\n setImportShortcutStr(e.target.value);\n }}\n dir=\"auto\"\n />\n {states.settings.shortcutSettingsCloudImportExport && (\n \n )}\n
\n {!!parsedImportShortcutStr &&\n Array.isArray(parsedImportShortcutStr) && (\n <>\n \n {parsedImportShortcutStr.length} shortcut\n {parsedImportShortcutStr.length > 1 ? 's' : ''}{' '}\n \n ({importShortcutStr.length} characters)\n \n
\n \n {parsedImportShortcutStr.map((shortcut) => (\n - \n \n // Compare all properties\n Object.keys(s).every(\n (key) => s[key] === shortcut[key],\n ),\n )\n ? 1\n : 0,\n }}\n >\n *\n \n \n {_(TYPE_TEXT[shortcut.type])}\n {shortcut.type === 'list' && ' ⚠️'}{' '}\n {TYPE_PARAMS[shortcut.type]?.map?.(\n ({ text, name, type }) =>\n shortcut[name] ? (\n <>\n \n {text}:{' '}\n {type === 'checkbox'\n ? shortcut[name] === 'on'\n ? '✅'\n : '❌'\n : shortcut[name]}\n {' '}\n >\n ) : null,\n )}\n \n
\n ))}\n
\n \n \n * Exists in current shortcuts\n \n
\n \n ⚠️{' '}\n \n List may not work if it's from a different account.\n \n \n
\n >\n )}\n {importUIState === 'error' && (\n \n \n ⚠️ Invalid settings format\n \n
\n )}\n \n {hasCurrentSettings && (\n <>\n
\n }\n onClick={() => {\n // states.shortcuts = [\n // ...states.shortcuts,\n // ...parsedImportShortcutStr,\n // ];\n // Append non-unique shortcuts only\n const nonUniqueShortcuts = parsedImportShortcutStr.filter(\n (shortcut) =>\n !states.shortcuts.some((s) =>\n // Compare all properties\n Object.keys(s).every(\n (key) => s[key] === shortcut[key],\n ),\n ),\n );\n if (!nonUniqueShortcuts.length) {\n showToast(t`No new shortcuts to import`);\n return;\n }\n let newShortcuts = [\n ...states.shortcuts,\n ...nonUniqueShortcuts,\n ];\n const exceededLimit = newShortcuts.length > SHORTCUTS_LIMIT;\n if (exceededLimit) {\n // If exceeded, trim it\n newShortcuts = newShortcuts.slice(0, SHORTCUTS_LIMIT);\n }\n states.shortcuts = newShortcuts;\n showToast(\n exceededLimit\n ? t`Shortcuts imported. Exceeded max ${SHORTCUTS_LIMIT}, so the rest are not imported.`\n : t`Shortcuts imported`,\n );\n onClose?.();\n }}\n >\n \n {' '}\n >\n )}\n {\n states.shortcuts = parsedImportShortcutStr;\n showToast(t`Shortcuts imported`);\n onClose?.();\n }}\n >\n \n \n
\n \n \n \n {' '}\n \n Export\n \n
\n \n {\n if (!e.target.value) return;\n e.target.select();\n // Copy url to clipboard\n try {\n navigator.clipboard.writeText(e.target.value);\n showToast(t`Shortcuts copied`);\n } catch (e) {\n console.error(e);\n showToast(t`Unable to copy shortcuts`);\n }\n }}\n dir=\"auto\"\n />\n
\n \n {' '}\n {navigator?.share &&\n navigator?.canShare?.({\n text: shortcutsStr,\n }) && (\n \n )}{' '}\n {states.settings.shortcutSettingsCloudImportExport && (\n \n )}{' '}\n {shortcutsStr.length > 0 && (\n \n \n \n )}\n
\n {!!shortcutsStr && (\n \n \n \n Raw Shortcuts JSON\n \n
\n \n \n )}\n \n {states.settings.shortcutSettingsCloudImportExport && (\n \n )}\n \n \n );\n}\n\nexport default ShortcutsSettings;\n","import { useLingui } from '@lingui/react/macro';\nimport { useEffect } from 'preact/hooks';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport { subscribe, useSnapshot } from 'valtio';\n\nimport Accounts from '../pages/accounts';\nimport Settings from '../pages/settings';\nimport focusDeck from '../utils/focus-deck';\nimport showToast from '../utils/show-toast';\nimport states from '../utils/states';\n\nimport AccountSheet from './account-sheet';\nimport ComposeSuspense, { preload } from './compose-suspense';\nimport Drafts from './drafts';\nimport EmbedModal from './embed-modal';\nimport GenericAccounts from './generic-accounts';\nimport MediaAltModal from './media-alt-modal';\nimport MediaModal from './media-modal';\nimport Modal from './modal';\nimport ReportModal from './report-modal';\nimport ShortcutsSettings from './shortcuts-settings';\n\nsubscribe(states, (changes) => {\n for (const [action, path, value, prevValue] of changes) {\n // When closing modal, focus on deck\n if (/^show/i.test(path) && !value) {\n focusDeck();\n }\n }\n});\n\nexport default function Modals() {\n const { t } = useLingui();\n const snapStates = useSnapshot(states);\n const navigate = useNavigate();\n const location = useLocation();\n\n useEffect(() => {\n setTimeout(preload, 1000);\n }, []);\n\n return (\n <>\n {!!snapStates.showCompose && (\n \n {\n const { newStatus, instance, type, scheduledAt } = results || {};\n states.showCompose = false;\n window.__COMPOSE__ = null;\n if (newStatus) {\n states.reloadStatusPage++;\n if (scheduledAt) states.reloadScheduledPosts++;\n showToast({\n text: {\n post: scheduledAt\n ? t`Post scheduled`\n : t`Post published. Check it out.`,\n reply: scheduledAt\n ? t`Reply scheduled`\n : t`Reply posted. Check it out.`,\n edit: t`Post updated. Check it out.`,\n }[type || 'post'],\n delay: 1000,\n duration: 10_000, // 10 seconds\n onClick: (toast) => {\n toast.hideToast();\n states.prevLocation = location;\n if (scheduledAt) {\n navigate('/sp');\n } else {\n navigate(\n instance\n ? `/${instance}/s/${newStatus.id}`\n : `/s/${newStatus.id}`,\n );\n }\n },\n });\n }\n }}\n />\n \n )}\n {!!snapStates.showSettings && (\n {\n states.showSettings = false;\n }}\n >\n {\n states.showSettings = false;\n }}\n />\n \n )}\n {!!snapStates.showAccounts && (\n {\n states.showAccounts = false;\n }}\n >\n {\n states.showAccounts = false;\n }}\n />\n \n )}\n {!!snapStates.showAccount && (\n {\n states.showAccount = false;\n }}\n >\n {\n states.showAccount = false;\n // states.showGenericAccounts = false;\n // if (destination) {\n // states.showAccounts = false;\n // }\n }}\n />\n \n )}\n {!!snapStates.showDrafts && (\n {\n states.showDrafts = false;\n }}\n >\n (states.showDrafts = false)} />\n \n )}\n {!!snapStates.showMediaModal && (\n {\n if (\n e.target === e.currentTarget ||\n e.target.classList.contains('media')\n ) {\n states.showMediaModal = false;\n }\n }}\n >\n {\n states.showMediaModal = false;\n }}\n />\n \n )}\n {!!snapStates.showShortcutsSettings && (\n {\n states.showShortcutsSettings = false;\n }}\n >\n (states.showShortcutsSettings = false)}\n />\n \n )}\n {!!snapStates.showGenericAccounts && (\n {\n states.showGenericAccounts = false;\n }}\n >\n (states.showGenericAccounts = false)}\n blankCopy={snapStates.showGenericAccounts.blankCopy}\n />\n \n )}\n {!!snapStates.showMediaAlt && (\n {\n states.showMediaAlt = false;\n }}\n >\n {\n states.showMediaAlt = false;\n }}\n />\n \n )}\n {!!snapStates.showEmbedModal && (\n {\n states.showEmbedModal = false;\n }}\n >\n {\n states.showEmbedModal = false;\n }}\n />\n \n )}\n {!!snapStates.showReportModal && (\n {\n states.showReportModal = false;\n }}\n >\n {\n states.showReportModal = false;\n }}\n />\n \n )}\n >\n );\n}\n","import { Trans, useLingui } from '@lingui/react/macro';\nimport { useState } from 'preact/hooks';\n\nimport { api } from '../utils/api';\n\nimport Icon from './icon';\nimport Loader from './loader';\n\nfunction FollowRequestButtons({ accountID, onChange }) {\n const { t } = useLingui();\n const { masto } = api();\n const [uiState, setUIState] = useState('default');\n const [requestState, setRequestState] = useState(null); // accept, reject\n const [relationship, setRelationship] = useState(null);\n\n const hasRelationship = relationship !== null;\n\n return (\n \n {' '}\n \n \n {hasRelationship && requestState ? (\n requestState === 'accept' ? (\n \n ) : (\n \n )\n ) : (\n \n )}\n \n
\n );\n}\n\nexport default FollowRequestButtons;\n","import { msg, t } from '@lingui/core/macro';\nimport { Plural, Select, Trans, useLingui } from '@lingui/react/macro';\nimport { Fragment } from 'preact';\nimport { memo } from 'preact/compat';\n\nimport { api } from '../utils/api';\nimport { isFiltered } from '../utils/filters';\nimport shortenNumber from '../utils/shorten-number';\nimport states, { statusKey } from '../utils/states';\nimport { getCurrentAccountID } from '../utils/store-utils';\nimport useTruncated from '../utils/useTruncated';\n\nimport Avatar from './avatar';\nimport CustomEmoji from './custom-emoji';\nimport FollowRequestButtons from './follow-request-buttons';\nimport Icon from './icon';\nimport Link from './link';\nimport NameText from './name-text';\nimport Status from './status';\n\nconst NOTIFICATION_ICONS = {\n mention: 'comment',\n status: 'notification',\n reblog: 'rocket',\n follow: 'follow',\n follow_request: 'follow-add',\n favourite: 'heart',\n poll: 'poll',\n update: 'pencil',\n 'admin.signup': 'account-edit',\n 'admin.report': 'account-warning',\n severed_relationships: 'heart-break',\n moderation_warning: 'alert',\n emoji_reaction: 'emoji2',\n 'pleroma:emoji_reaction': 'emoji2',\n annual_report: 'celebrate',\n};\n\n/*\nNotification types\n==================\nmention = Someone mentioned you in their status\nstatus = Someone you enabled notifications for has posted a status\nreblog = Someone boosted one of your statuses\nfollow = Someone followed you\nfollow_request = Someone requested to follow you\nfavourite = Someone favourited one of your statuses\npoll = A poll you have voted in or created has ended\nupdate = A status you interacted with has been edited\nadmin.sign_up = Someone signed up (optionally sent to admins)\nadmin.report = A new report has been filed\nsevered_relationships = Severed relationships\nmoderation_warning = Moderation warning\n*/\n\nfunction emojiText({ account, emoji, emoji_url }) {\n let url;\n let staticUrl;\n if (typeof emoji_url === 'string') {\n url = emoji_url;\n } else {\n url = emoji_url?.url;\n staticUrl = emoji_url?.staticUrl;\n }\n const emojiObject = url ? (\n \n ) : (\n emoji\n );\n return (\n \n {account} reacted to your post with {emojiObject}\n \n );\n}\n\nconst contentText = {\n status: ({ account }) => {account} published a post.,\n reblog: ({\n count,\n account,\n postsCount,\n postType,\n components: { Subject },\n }) => (\n {account} boosted your reply.}\n other={{account} boosted your post.}\n />\n }\n other={\n \n {account} boosted {postsCount} of your posts.\n \n }\n />\n }\n other={\n