phanpy-cz/assets/main-1wKRS81d.js
2024-06-16 20:14:43 +02:00

26 lines
250 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{s as T,a as Q,b as qe,c as be,g as ct,d as ds,e as St,p as ht,u as Ks,L as $e,f as jt,h as us,i as Zs,C as Js,j as Ke,k as Xs,l as hn,m as He,n as hs,t as Qs,o as ei,q as $n,r as ti,v as An,w as Rn}from"./useTitle-dCp14HlU.js";import{F as z,_ as G,p as $,u as _e,x as Je,a as Me,b as e,k as _,y as mt,c as pn,M as de,d as ze,e as Tt,q as pe,f as xt,g as Qe,I as rt,A as lt,h as fn,l as _n,s as ps,i as fs,j as it,T as ni,m as si,n as ii,P as oi,J as ai,C as ms,o as ci,r as gt,t as ri,v as li,w as gs,z as di,B as ui,D as hi,E as pi,G as Et,H as bs,K as Ln,L as fi,R as mn,N as Ue,O as mi,Q as gi}from"./vendor-GrW-f9CX.js";import{u as gn,s as se,o as En,a as bi,I as w,M as Ae,A as st,N as It,b as Ze,c as et,L as oe,g as ys,l as yi,t as Mn,R as bt,d as je,e as Xe,f as Re,h as ws,i as on,E as vs,j as Ge,n as ot,k as wi,S as Wt,m as Pn,T as ks,p as nt,q as bn,r as Be,v as Dn,w as vi,x as ki,y as Ss,C as Si,z as Ii,F as Is,B as Mt,D as Ci,G as $t,H as yn,J as Cs,K as Ti,O as Nt}from"./status-FORkhePO.js";function Ct(t=()=>{},n=[]){const i=z(t);G(()=>{i.current=t},[n]),G(()=>{const s=()=>{const o=document.hidden||document.visibilityState==="hidden";i.current(!o)};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[])}const xi=1e3*3,$i=15e3,Ai=Je(function({isLoggedIn:n}){const[i,s]=$(!0);Ct(s);const o=async(d,r,u)=>{var f;if(T.notificationsLast){const c=d.v1.notifications.list({limit:1,sinceId:T.notificationsLast.id}),{value:p}=await c.next();if(p!=null&&p.length)if(u)T.notificationsShowNew=!0;else{let l;try{const b=await d.v1.markers.fetch({timeline:"notifications"});l=(f=b==null?void 0:b.notifications)==null?void 0:f.lastReadId}catch{}l?T.notificationsShowNew=p[0].id!==l:T.notificationsShowNew=!0}}};G(()=>{let d,r;if(n&&i){const{masto:u,streaming:f,instance:c}=Q();(async()=>{await o(u,c);let p=!1;f&&(r=setTimeout(()=>{(async()=>{try{p=!0,d=f.user.notification.subscribe();for await(const l of d){if(!d||!i)break;l.event==="notification"&&qe(l.payload,c,{skipThreading:!0}),T.notificationsShowNew=!0}}catch{p=!1}p||(r=setInterval(()=>{o(u,c,!0)},$i))})()},xi))})()}return()=>{var u;(u=d==null?void 0:d.unsubscribe)==null||u.call(d),d=null,clearTimeout(r),clearInterval(r)}},[i,n]);const a=z(),h=()=>{a.current=Date.now(),fetch("./version.json").then(d=>d.json()).then(d=>{d&&(T.appVersion=d)}).catch(d=>{})};return gn(h,i&&1e3*60*30),Ct(d=>{d&&(a.current?Date.now()-a.current>1e3*60*60&&h():h())}),_e("shift+alt+k",()=>{const d=T.settings.cloakMode;T.settings.cloakMode=!d,se({text:`Cloak mode ${d?"disabled":"enabled"}`})}),null});function Ri(){const t=Me(T);function n(i){if(t.composerState.minimized){T.composerState.minimized=!1,En();return}i.shiftKey?bi()||(T.showCompose=!0):(En(),T.showCompose=!0)}return _e("c, shift+c",n,{ignoreEventWhen:i=>!!document.querySelector("#modal-container > *")}),e("button",{type:"button",id:"compose-button",onClick:n,class:`${t.composerState.minimized?"min":""} ${t.composerState.publishing?"loading":""} ${t.composerState.publishingError?"error":""}`,children:e(w,{icon:"quill",size:"xl",alt:"Compose"})})}const _i=Je(function(){const n=Me(T);function i(){T.showKeyboardShortcutsHelp=!1}return _e("?, shift+?, shift+slash",s=>{T.showKeyboardShortcutsHelp=!0},{ignoreEventWhen:s=>!!document.querySelector("#modal-container > *")}),!!n.showKeyboardShortcutsHelp&&e(Ae,{onClose:i,children:e("div",{id:"keyboard-shortcuts-help-container",class:"sheet",tabindex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:i,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Keyboard shortcuts"})}),e("main",{children:e("table",{children:[{action:"Keyboard shortcuts help",keys:e("kbd",{children:"?"})},{action:"Next post",keys:e("kbd",{children:"j"})},{action:"Previous post",keys:e("kbd",{children:"k"})},{action:"Skip carousel to next post",keys:e(_,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"j"})]})},{action:"Skip carousel to previous post",keys:e(_,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"k"})]})},{action:"Load new posts",keys:e("kbd",{children:"."})},{action:"Open post details",keys:e(_,{children:[e("kbd",{children:"Enter"})," or ",e("kbd",{children:"o"})]})},{action:e(_,{children:["Expand content warning or",e("br",{}),"toggle expanded/collapsed thread"]}),keys:e("kbd",{children:"x"})},{action:"Close post or dialogs",keys:e(_,{children:[e("kbd",{children:"Esc"})," or ",e("kbd",{children:"Backspace"})]})},{action:"Focus column in multi-column mode",keys:e(_,{children:[e("kbd",{children:"1"})," to ",e("kbd",{children:"9"})]})},{action:"Compose new post",keys:e("kbd",{children:"c"})},{action:"Compose new post (new window)",className:"insignificant",keys:e(_,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"c"})]})},{action:"Send post",keys:e(_,{children:[e("kbd",{children:"Ctrl"})," + ",e("kbd",{children:"Enter"})," or ",e("kbd",{children:"⌘"})," +"," ",e("kbd",{children:"Enter"})]})},{action:"Search",keys:e("kbd",{children:"/"})},{action:"Reply",keys:e("kbd",{children:"r"})},{action:"Reply (new window)",className:"insignificant",keys:e(_,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"r"})]})},{action:"Like (favourite)",keys:e(_,{children:[e("kbd",{children:"l"})," or ",e("kbd",{children:"f"})]})},{action:"Boost",keys:e(_,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"b"})]})},{action:"Bookmark",keys:e("kbd",{children:"d"})},{action:"Toggle Cloak mode",keys:e(_,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"Alt"})," + ",e("kbd",{children:"k"})]})}].map(({action:s,className:o,keys:a})=>e("tr",{children:[e("th",{class:o,children:s}),e("td",{children:a})]},s))})})]})})});function Li({onClose:t}){const{masto:n}=Q(),i=be.local.getJSON("accounts"),s=ct(),o=i.length>1,[a,h]=mt(r=>r+1,0),[d]=pn();return e("div",{id:"accounts-container",class:"sheet",tabIndex:"-1",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(w,{icon:"x"})}),e("header",{class:"header-grid",children:e("h2",{children:"Accounts"})}),e("main",{children:e("section",{children:[e("ul",{class:"accounts-list",ref:d,children:i.map((r,u)=>{const f=r.info.id===s,c=u===0;return e("li",{children:[e("div",{children:[o&&e("span",{class:`current ${f?"is-current":""}`,children:e(w,{icon:"check-circle",alt:"Current"})}),e(st,{url:r.info.avatarStatic,size:"xxl",onDblClick:async()=>{if(f)try{const p=await n.v1.accounts.$select(r.info.id).fetch();r.info=p,be.local.setJSON("accounts",i),h()}catch{}}}),e(It,{account:o?{...r.info,acct:/@/.test(r.info.acct)?r.info.acct:`${r.info.acct}@${r.instanceURL}`}:r.info,showAcct:!0,onClick:()=>{f?T.showAccount=`${r.info.username}@${r.instanceURL}`:(ds(r.info.id),location.reload())}})]}),e("div",{class:"actions",children:[c&&o&&e(_,{children:[e("span",{class:"tag",children:"Default"})," "]}),e(Ze,{align:"end",menuButton:e("button",{type:"button",title:"More",class:"plain more-button",children:e(w,{icon:"more",size:"l",alt:"More"})}),children:[e(de,{onClick:()=>{T.showAccount=`${r.info.username}@${r.instanceURL}`},children:[e(w,{icon:"user"}),e("span",{children:"View profile…"})]}),e(ze,{}),o&&e(de,{disabled:c,onClick:()=>{i.splice(u,1),i.unshift(r),be.local.setJSON("accounts",i),h()},children:[e(w,{icon:"check-circle"}),e("span",{children:"Set as default"})]}),e(et,{subMenu:!0,confirmLabel:e(_,{children:[e(w,{icon:"exit"}),e("span",{children:["Log out @",r.info.acct,"?"]})]}),disabled:!f,menuItemClassName:"danger",onClick:()=>{i.splice(u,1),be.local.setJSON("accounts",i),location.href=location.pathname||"/"},children:[e(w,{icon:"exit"}),e("span",{children:"Log out…"})]})]})]})]},r.info.id)})}),e("p",{children:e(oe,{to:"/login",class:"button plain2",onClick:t,children:[e(w,{icon:"plus"})," ",e("span",{children:"Add an existing account"})]})}),o&&e("p",{children:e("small",{children:["Note: ",e("i",{children:"Default"})," account will always be used for first load. Switched accounts will persist during the session."]})})]})})]})}const wn="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";function Nn(t){const{masto:n}=Q();return n.v1.push.subscription.create(t)}function Ei(){const{masto:t}=Q();return t.v1.push.subscription.fetch()}function Mi(t){const{masto:n}=Q();return n.v1.push.subscription.update(t)}function Pi(){const{masto:t}=Q();return t.v1.push.subscription.remove()}function Jt(){return"serviceWorker"in navigator&&"PushManager"in window}function Di(){return navigator.serviceWorker.getRegistration()}async function vn(){const t=await Di(),n=t?await t.pushManager.getSubscription():void 0;return{registration:t,subscription:n}}function Ts(t){const n="=".repeat((4-t.length%4)%4),i=`${t}${n}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(i),o=new Uint8Array(s.length);for(let a=0;a<s.length;++a)o[a]=s.charCodeAt(a);return o}async function Ni(){if(!Jt())return;const{subscription:t}=await vn();let n=null;try{n=await Ei()}catch(i){if(!/(not found|unknown)/i.test(i.message))throw i}if(n&&t){const i=n.endpoint===t.endpoint,{vapidKey:s}=St(),o=n.serverKey===s;if(!i)throw new Error("Backend subscription endpoint changed");if(!o)throw new Error("Backend subscription key and vapid key changed")}if(t&&!n){const{vapidKey:i}=St(),{applicationServerKey:s}=t.options,o=Ts(i).toString(),a=new Uint8Array(s).toString();if(!(o===a))throw await t.unsubscribe(),new Error("Subscription key and vapid key changed")}return{subscription:t,backendSubscription:n}}async function Un({data:t,policy:n}){if(!Jt())return;let{registration:i,subscription:s}=await vn(),o=null;if(s)try{o=await Mi({data:t,policy:n})}catch{o=await Nn({subscription:s,data:t,policy:n})}else{const{vapidKey:a}=St();if(!a)throw new Error("No server key found");s=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ts(a)}),o=await Nn({subscription:s,data:t,policy:n})}return{subscription:s,backendSubscription:o}}async function Fn(){if(!Jt())return;const{subscription:t}=await vn();t&&(await Pi(),await t.unsubscribe())}var Ui={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",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",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const On=16,ft=[14,15,16,17,18,19,20],{PHANPY_WEBSITE:zn,PHANPY_PRIVACY_POLICY_URL:Fi,PHANPY_IMG_ALT_API_URL:Oi,PHANPY_GIPHY_API_KEY:zi}=Ui;function Bi({onClose:t}){const n=Me(T),i=be.local.get("theme")||"auto",s=z(),o=n.settings.contentTranslationTargetLanguage||null,a=ys(),h=yi(a),d=be.local.get("textSize")||On,[r,u]=$(be.account.get("preferences")||{}),{masto:f,authenticated:c,instance:p}=Q();return e("div",{id:"settings-container",class:"sheet",tabIndex:"-1",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Settings"})}),e("main",{children:[e("section",{children:e("ul",{children:[e("li",{children:[e("div",{children:e("label",{children:"Appearance"})}),e("div",{children:e("form",{ref:s,onInput:l=>{l.preventDefault();const m=new FormData(s.current).get("theme"),k=document.documentElement;if(m==="auto"){k.classList.remove("is-light","is-dark");const g=document.querySelector('meta[data-theme-setting="manual"]');g&&(g.name=""),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(C=>{C.name="theme-color"})}else{k.classList.toggle("is-light",m==="light"),k.classList.toggle("is-dark",m==="dark");const g=document.querySelector('meta[data-theme-setting="manual"]');g&&(g.name="theme-color",g.content=m==="light"?g.dataset.themeLightColor:g.dataset.themeDarkColor),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(C=>{C.name=""})}document.querySelector('meta[name="color-scheme"]').setAttribute("content",m==="auto"?"dark light":m),m==="auto"?be.local.del("theme"):be.local.set("theme",m)},children:e("div",{class:"radio-group",children:[e("label",{children:[e("input",{type:"radio",name:"theme",value:"light",defaultChecked:i==="light"}),e("span",{children:"Light"})]}),e("label",{children:[e("input",{type:"radio",name:"theme",value:"dark",defaultChecked:i==="dark"}),e("span",{children:"Dark"})]}),e("label",{children:[e("input",{type:"radio",name:"theme",value:"auto",defaultChecked:i!=="light"&&i!=="dark"}),e("span",{children:"Auto"})]})]})})})]}),e("li",{children:[e("div",{children:e("label",{children:"Text size"})}),e("div",{class:"range-group",children:[e("span",{style:{fontSize:ft[0]},children:"A"})," ",e("input",{type:"range",min:ft[0],max:ft[ft.length-1],step:"1",value:d,list:"sizes",onChange:l=>{const b=parseInt(l.target.value,10);document.documentElement.style.setProperty("--text-size",`${b}px`),b===On?be.local.del("textSize"):be.local.set("textSize",l.target.value)}})," ",e("span",{style:{fontSize:ft[ft.length-1]},children:"A"}),e("datalist",{id:"sizes",children:ft.map(l=>e("option",{value:l}))})]})]})]})}),c&&e(_,{children:[e("h3",{children:"Posting"}),e("section",{children:e("ul",{children:e("li",{children:[e("div",{children:e("label",{for:"posting-privacy-field",children:["Default visibility"," ",e(w,{icon:"cloud",alt:"Synced",class:"synced-icon"})]})}),e("div",{children:e("select",{id:"posting-privacy-field",value:r["posting:default:visibility"]||"public",onChange:l=>{const{value:b}=l.target;(async()=>{try{await f.v1.accounts.updateCredentials({source:{privacy:b}}),u({...r,"posting:default:visibility":b}),be.account.set("preferences",{...r,"posting:default:visibility":b})}catch{alert("Failed to update posting privacy")}})()},children:[e("option",{value:"public",children:"Public"}),e("option",{value:"unlisted",children:"Unlisted"}),e("option",{value:"private",children:"Followers only"})]})})]})})}),e("p",{class:"section-postnote",children:[e(w,{icon:"cloud",alt:"Synced",class:"synced-icon"})," ",e("small",{children:["Synced to your instance server's settings."," ",e("a",{href:`https://${p}/`,target:"_blank",rel:"noopener noreferrer",children:["Go to your instance (",p,") for more settings."]})]})]})]}),e("h3",{children:"Experiments"}),e("section",{children:e("ul",{children:[e("li",{children:e("label",{children:[e("input",{type:"checkbox",checked:n.settings.autoRefresh,onChange:l=>{T.settings.autoRefresh=l.target.checked}})," ","Auto refresh timeline posts"]})}),e("li",{children:e("label",{children:[e("input",{type:"checkbox",checked:n.settings.boostsCarousel,onChange:l=>{T.settings.boostsCarousel=l.target.checked}})," ","Boosts carousel"]})}),e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.contentTranslation,onChange:l=>{const{checked:b}=l.target;T.settings.contentTranslation=b,b||(T.settings.contentTranslationTargetLanguage=null)}})," ","Post translation"]}),e("div",{class:`sub-section ${n.settings.contentTranslation?"":"more-insignificant"}`,children:[e("div",{children:e("label",{children:["Translate to"," ",e("select",{value:o||"",disabled:!n.settings.contentTranslation,onChange:l=>{T.settings.contentTranslationTargetLanguage=l.target.value||null},children:[e("option",{value:"",children:["System language (",h,")"]}),e("option",{disabled:!0,children:"──────────"}),Mn.map(l=>e("option",{value:l.code,children:l.name}))]})]})}),e("hr",{}),e("p",{class:"checkbox-fieldset",children:['Hide "Translate" button for',n.settings.contentTranslationHideLanguages.length>0&&e(_,{children:[" ","(",n.settings.contentTranslationHideLanguages.length,")"]}),":",e("div",{class:"checkbox-fields",children:Mn.map(l=>e("label",{children:[e("input",{type:"checkbox",checked:n.settings.contentTranslationHideLanguages.includes(l.code),onChange:b=>{const{checked:m}=b.target;m?T.settings.contentTranslationHideLanguages.push(l.code):T.settings.contentTranslationHideLanguages=n.settings.contentTranslationHideLanguages.filter(k=>k!==l.code)}})," ",l.name]}))})]}),e("p",{class:"insignificant",children:e("small",{children:["Note: This feature uses external translation services, powered by"," ",e("a",{href:"https://github.com/cheeaun/lingva-api",target:"_blank",rel:"noopener noreferrer",children:"Lingva API"})," ","&"," ",e("a",{href:"https://github.com/thedaviddelta/lingva-translate",target:"_blank",rel:"noopener noreferrer",children:"Lingva Translate"}),"."]})}),e("hr",{}),e("div",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.contentTranslationAutoInline,disabled:!n.settings.contentTranslation,onChange:l=>{T.settings.contentTranslationAutoInline=l.target.checked}})," ","Auto inline translation"]}),e("p",{class:"insignificant",children:e("small",{children:["Automatically show translation for posts in timeline. Only works for ",e("b",{children:"short"})," posts without content warning, media and poll."]})})]})]})]}),!!zi&&c&&e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.composerGIFPicker,onChange:l=>{T.settings.composerGIFPicker=l.target.checked}})," ","GIF Picker for composer"]}),e("div",{class:"sub-section insignificant",children:e("small",{children:["Note: This feature uses external GIF search service, powered by"," ",e("a",{href:"https://developers.giphy.com/",target:"_blank",rel:"noopener noreferrer",children:"GIPHY"}),". G-rated (suitable for viewing by all ages), tracking parameters are stripped, referrer information is omitted from requests, but search queries and IP address information will still reach their servers."]})})]}),!!Oi&&c&&e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.mediaAltGenerator,onChange:l=>{T.settings.mediaAltGenerator=l.target.checked}})," ","Image description generator"," ",e(w,{icon:"sparkles2",class:"more-insignificant"})]}),e("div",{class:"sub-section insignificant",children:e("small",{children:"Only for new images while composing new posts."})}),e("div",{class:"sub-section insignificant",children:e("small",{children:["Note: This feature uses external AI service, powered by"," ",e("a",{href:"https://github.com/cheeaun/img-alt-api",target:"_blank",rel:"noopener noreferrer",children:"img-alt-api"}),". May not work well. Only for images and in English."]})})]}),c&&e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.shortcutSettingsCloudImportExport,onChange:l=>{T.settings.shortcutSettingsCloudImportExport=l.target.checked}})," ",'"Cloud" import/export for shortcuts settings'," ",e(w,{icon:"cloud",class:"more-insignificant"})]}),e("div",{class:"sub-section insignificant",children:e("small",{children:["⚠️⚠️⚠️ Very experimental.",e("br",{}),"Stored in your own profiles notes. Profile (private) notes are mainly used for other profiles, and hidden for own profile."]})}),e("div",{class:"sub-section insignificant",children:e("small",{children:"Note: This feature uses currently-logged-in instance server API."})})]}),e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.cloakMode,onChange:l=>{T.settings.cloakMode=l.target.checked}})," ","Cloak mode"," ",e("span",{class:"insignificant",children:["(",e("samp",{children:"Text"})," → ",e("samp",{children:"████"}),")"]})]}),e("div",{class:"sub-section insignificant",children:e("small",{children:"Replace text as blocks, useful when taking screenshots, for privacy reasons."})})]}),c&&e("li",{children:e("button",{type:"button",class:"light",onClick:()=>{T.showDrafts=!0,T.showSettings=!1},children:"Unsent drafts"})})]})}),c&&e(qi,{onClose:t}),e("h3",{children:"About"}),e("section",{children:[e("div",{style:{display:"flex",flexWrap:"wrap",gap:8,lineHeight:1.25,alignItems:"center",marginTop:8},children:[e("img",{src:wn,alt:"",width:"64",height:"64",style:{aspectRatio:"1/1",verticalAlign:"middle",background:"#b7cdf9",borderRadius:12}}),e("div",{children:[e("b",{children:"Phanpy"})," ",e("a",{href:"https://hachyderm.io/@phanpy",rel:"noopener noreferrer",onClick:l=>{l.preventDefault(),T.showAccount="phanpy@hachyderm.io"},children:"@phanpy"}),e("br",{}),e("a",{href:"https://github.com/cheeaun/phanpy",target:"_blank",rel:"noopener noreferrer",children:"Built"})," ","by"," ",e("a",{href:"https://mastodon.social/@cheeaun",rel:"noopener noreferrer",onClick:l=>{l.preventDefault(),T.showAccount="cheeaun@mastodon.social"},children:"@cheeaun"})]})]}),e("p",{children:[e("a",{href:"https://github.com/sponsors/cheeaun",target:"_blank",rel:"noopener noreferrer",children:"Sponsor"})," ","·"," ",e("a",{href:"https://www.buymeacoffee.com/cheeaun",target:"_blank",rel:"noopener noreferrer",children:"Donate"})," ","·"," ",e("a",{href:Fi,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]}),e("p",{children:[zn&&e(_,{children:[e("span",{class:"insignificant",children:"Site:"})," ",zn.replace(/https?:\/\//g,"").replace(/\/$/,""),e("br",{})]}),e("span",{class:"insignificant",children:"Version:"})," ",e("input",{type:"text",class:"version-string",readOnly:!0,size:"18",value:`${"2024-06-03T11:04:51.985Z".slice(0,10).replace(/-/g,".")}.0a6030c`,onClick:l=>{l.target.select();try{navigator.clipboard.writeText(l.target.value),se("Version string copied")}catch{se("Unable to copy version string")}}})," ",e("span",{class:"ib insignificant",children:["(",e("a",{href:"https://github.com/cheeaun/phanpy/commit/0a6030c",target:"_blank",rel:"noopener noreferrer",children:e(bt,{datetime:new Date("2024-06-03T11:04:51.985Z")})}),")"]})]})]})]})]})}function qi({onClose:t}){if(!Jt())return null;const{instance:n}=Q(),[i,s]=$("default"),o=z(),[a,h]=$(!1),[d,r]=$(!1),u=z();G(()=>{(async()=>{s("loading");try{const{subscription:c,backendSubscription:p}=await Ni();if(p!=null&&p.policy&&p.policy!=="none"){h(!0);const{alerts:l,policy:b}=p;u.current=b;const{elements:m}=o.current,k=m.namedItem("policy");k&&(k.value=b),Object.keys(l).forEach(g=>{const y=m.namedItem(g);(y==null?void 0:y.type)==="checkbox"&&(y.checked=!0)})}s("default")}catch(c){/outside.*authorized/i.test(c.message)?r(!0):alert((c==null?void 0:c.message)||c),s("error")}})()},[]);const f=i==="loading";return e("form",{ref:o,onChange:()=>{setTimeout(()=>{const c=Object.fromEntries(new FormData(o.current)),p=!!c["policy-allow"],l={data:{policy:c.policy,alerts:{mention:!!c.mention,favourite:!!c.favourite,reblog:!!c.reblog,follow:!!c.follow,follow_request:!!c.followRequest,poll:!!c.poll,update:!!c.update,status:!!c.status}}};let b=0;Object.keys(l.data.alerts).forEach(k=>{l.data.alerts[k]?b++:delete l.data.alerts[k]});const m=u.current!==l.data.policy;p&&b>0?m?Fn().then(()=>{Un(l)}).catch(k=>{alert("Failed to update subscription. Please try again.")}):Un(l).catch(k=>{alert("Failed to update subscription. Please try again.")}):Fn().catch(k=>{alert("Failed to remove subscription. Please try again.")})},100)},children:[e("h3",{children:"Push Notifications (beta)"}),e("section",{children:e("ul",{children:e("li",{children:[e("label",{children:[e("input",{type:"checkbox",disabled:f||d,name:"policy-allow",checked:a,onChange:async c=>{const{checked:p}=c.target;if(p){const l=await Notification.requestPermission();l==="granted"?h(!0):(h(!1),l==="denied"&&alert("Push notifications are blocked. Please enable them in your browser settings."))}else h(!1)}})," ","Allow from"," ",e("select",{name:"policy",disabled:f||d||!a,children:[{value:"all",label:"anyone"},{value:"followed",label:"people I follow"},{value:"follower",label:"followers"}].map(c=>e("option",{value:c.value,children:c.label}))})]}),e("div",{class:"shazam-container no-animation",style:{width:"100%"},hidden:!a,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"sub-section",children:e("ul",{children:[{value:"mention",label:"Mentions"},{value:"favourite",label:"Likes"},{value:"reblog",label:"Boosts"},{value:"follow",label:"Follows"},{value:"followRequest",label:"Follow requests"},{value:"poll",label:"Polls"},{value:"update",label:"Post edits"},{value:"status",label:"New posts"}].map(c=>e("li",{children:e("label",{children:[e("input",{type:"checkbox",name:c.value})," ",c.label]})}))})})})}),d&&e("div",{class:"sub-section",children:e("p",{children:["Push permission was not granted since your last login. You'll need to"," ",e(oe,{to:`/login?instance=${n}`,onClick:t,children:[e("b",{children:"log in"})," again to grant push permission"]}),"."]})})]})})}),e("p",{class:"section-postnote",children:e("small",{children:["NOTE: Push notifications only work for ",e("b",{children:"one account"}),"."]})})]})}const an=()=>{let t=setTimeout(()=>{if(!document.getElementById("columns")){const i=document.querySelectorAll("#modal-container > *");if(i!=null&&i.length){const h=i[i.length-1],d=h.querySelector('[tabindex="-1"]')||h;if(d){d.focus();return}}if(document.querySelector(".deck-backdrop"))return;const o=document.querySelectorAll(".deck-container"),a=o[o.length-1];a&&a.tabIndex===-1&&a.focus()}},100);return()=>clearTimeout(t)};function xs(t){if(!t)return;const n=Tt(),i=z(n.pathname);G(()=>{i.current&&n.pathname!==i.current&&(t==null||t())},[n.pathname,t])}const $s=1e3*60,Hi=24*60*60*1e3,cn=ht(async()=>{const{masto:t}=Q(),n=await t.v1.lists.list();return n.sort((i,s)=>i.title.localeCompare(s.title)),n.length&&setTimeout(()=>{be.account.set("lists",{lists:n,updatedAt:Date.now()})},1),n},{maxAge:$s});async function Pt(){try{const{lists:t,updatedAt:n}=be.account.get("lists")||{};return t!=null&&t.length?(Date.now()-n>Hi&&cn(),t):await cn()}catch{return[]}}const Vi=ht(t=>{const{masto:n}=Q();return n.v1.lists.$select(t).fetch()},{maxAge:$s});async function As(t){const{lists:n}=be.account.get("lists")||{};if(n!=null&&n.length){const i=n.find(s=>s.id===t);if(i)return i}try{return Vi(t)}catch{return null}}async function Gi(t){const n=await As(t);return(n==null?void 0:n.title)||""}function Yi(t){const{lists:n}=be.account.get("lists")||{};n!=null&&n.length&&(n.push(t),n.sort((i,s)=>i.title.localeCompare(s.title)),be.account.set("lists",{lists:n,updatedAt:Date.now()}))}function ji(t){const{lists:n}=be.account.get("lists")||{};if(n!=null&&n.length){const i=n.findIndex(s=>s.id===t.id);i!==-1&&(n[i]=t,n.sort((s,o)=>s.title.localeCompare(o.title)),be.account.set("lists",{lists:n,updatedAt:Date.now()}))}}function Wi(t){const{lists:n}=be.account.get("lists")||{};if(n!=null&&n.length){const i=n.findIndex(s=>s.id===t);i!==-1&&(n.splice(i,1),be.account.set("lists",{lists:n,updatedAt:Date.now()}))}}function kn({list:t,onClose:n}){const{masto:i}=Q(),[s,o]=$("default"),a=!!t,h=z(),d=z(),r=z();G(()=>{a&&(h.current.value=t.title,d.current.value=t.repliesPolicy,r.current&&(r.current.checked=t.exclusive))},[a]);const u=je("@mastodon/list-exclusive");return e("div",{class:"sheet",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(w,{icon:"x"})})," ",e("header",{children:e("h2",{children:a?"Edit list":"New list"})}),e("main",{children:e("form",{class:"list-form",onSubmit:f=>{f.preventDefault();const c=new FormData(f.target),p=c.get("title"),l=c.get("replies_policy"),b=c.get("exclusive")==="on";o("loading"),(async()=>{try{let m;a?m=await i.v1.lists.$select(t.id).update({title:p,replies_policy:l,exclusive:b}):m=await i.v1.lists.create({title:p,replies_policy:l,exclusive:b}),o("default"),n==null||n({state:"success",list:m}),setTimeout(()=>{a?ji(m):Yi(m)},1)}catch{o("error"),alert(a?"Unable to edit list.":"Unable to create list.")}})()},children:[e("div",{class:"list-form-row",children:e("label",{for:"list-title",children:["Name"," ",e("input",{ref:h,type:"text",id:"list-title",name:"title",required:!0,disabled:s==="loading",dir:"auto"})]})}),e("div",{class:"list-form-row",children:e("select",{ref:d,name:"replies_policy",required:!0,disabled:s==="loading",children:[e("option",{value:"list",children:"Show replies to list members"}),e("option",{value:"followed",children:"Show replies to people I follow"}),e("option",{value:"none",children:"Don't show replies"})]})}),u&&e("div",{class:"list-form-row",children:e("label",{class:"label-block",children:[e("input",{ref:r,type:"checkbox",name:"exclusive",disabled:s==="loading"})," ","Hide posts on this list from Home/Following"]})}),e("div",{class:"list-form-footer",children:[e("button",{type:"submit",disabled:s==="loading",children:a?"Save":"Create"}),a&&e(et,{disabled:s==="loading",align:"end",menuItemClassName:"danger",confirmLabel:"Delete this list?",onClick:()=>{o("loading"),(async()=>{try{await i.v1.lists.$select(t.id).remove(),o("default"),n==null||n({state:"deleted"}),setTimeout(()=>{Wi(t.id)},1)}catch{o("error"),alert("Unable to delete list.")}})()},children:e("button",{type:"button",class:"light danger",disabled:s==="loading",children:"Delete…"})})]})]})})]})}const Ki=[60*5,60*30,60*60,60*60*6,60*60*24,60*60*24*3,60*60*24*7,0],Bn={0:"Forever",300:"5 minutes",1800:"30 minutes",3600:"1 hour",21600:"6 hours",86400:"1 day",259200:"3 days",604800:"1 week"},qn=80,Rs=1e3*60*10;function Zi(t,n){return n.v1.accounts.familiarFollowers.fetch({id:[t]})}const Ji=ht(Zi,{maxAge:Rs});async function Xi(t,n){const i=n.v1.accounts.$select(t).statuses.list({limit:20}).next(),{value:s}=await i,o={total:s.length,originals:0,replies:0,boosts:0};return s.forEach(a=>{a.reblog?o.boosts++:a.inReplyToId&&a.inReplyToAccountId!==a.account.id?o.replies++:o.originals++}),s.length&&(o.daysSinceLastPost=Math.ceil((Date.now()-new Date(s[s.length-1].createdAt))/864e5)),o}const Qi=ht(Xi,{maxAge:Rs});function _s({account:t,fetchAccount:n=()=>{},standalone:i,instance:s,authenticated:o}){const{masto:a}=Q({instance:s}),{masto:h,instance:d}=Q(),[r,u]=$("default"),f=typeof t=="string",[c,p]=$(f?null:t),l=pe(()=>s===d,[s,d]);G(()=>{if(!f){p(t);return}u("loading"),(async()=>{try{const S=await n();T.accounts[`${S.id}@${s}`]=S,p(S),u("default")}catch{p(null),u("error")}})()},[f,t,n]);const{acct:b,avatar:m,avatarStatic:k,bot:g,createdAt:y,displayName:C,emojis:v,fields:I,followersCount:x,followingCount:L,group:Y,id:j,lastStatusAt:M,locked:ee,note:X,statusesCount:A,url:P,username:E,memorial:U,moved:V,roles:ye,hideCollections:ve}=c||{};let fe=!1,{header:ne,headerStatic:me}=c||{};(!ne||/missing\.png$/.test(ne))&&m&&!/missing\.png$/.test(m)&&(ne=m,fe=!0,k&&!/missing\.png$/.test(k)&&(me=k));const ue=pe(()=>j===ct(),[j]);G(()=>{const S=!!(c!=null&&c.id&&(c!=null&&c.username)&&(c!=null&&c.acct)&&(c!=null&&c.avatar)&&(c!=null&&c.avatarStatic)&&(c!=null&&c.displayName)&&(c!=null&&c.url));if(ue&&s&&S){const N=be.local.getJSON("accounts");let B=!1;N.forEach(O=>{O.info.id===c.id&&O.instanceURL===s&&(O.info=c,B=!0)}),B&&be.local.setJSON("accounts",N)}},[ue,c,s]);const he=pe(()=>P?xt.toUnicode(new URL(P).hostname):null,[P]),[ke,Le]=$([]),Te=z(),Pe=z([]);async function Fe(S){var K;(S||!Te.current)&&(Te.current=a.v1.accounts.$select(j).followers.list({limit:qn}));const N=await Te.current.next();if(ue||!l)return N;const{value:B}=N;let O=[];if(S){let ge=[];try{ge=await a.v1.accounts.familiarFollowers.fetch({id:[j]})}catch{}Pe.current=((K=ge==null?void 0:ge[0])==null?void 0:K.accounts)||[],O=[...Pe.current,...B.filter(le=>!Pe.current.some(ie=>ie.id===le.id))]}else B!=null&&B.length&&(O=B.filter(ge=>!Pe.current.some(le=>le.id===ge.id)));return{...N,value:O}}const xe=z();async function J(S){return(S||!xe.current)&&(xe.current=a.v1.accounts.$select(j).following.list({limit:qn})),await xe.current.next()}const ae=i?"div":oe,te=s?`/${s}/a/${j}`:`/a/${j}`,[Se,Ie]=$([]),[F,re]=$(),[D,W]=$("default"),R=!!(F!=null&&F.total),q=async S=>{try{const N=await Ji(S,h);Ie(N[0].accounts.slice(0,eo))}catch{}},Z=async()=>{if(j){W("loading");try{const S=await Qi(j,a);re(S),W("default")}catch{W("error")}}},ce=Qe(({relationship:S,currentID:N})=>{S.following||(q(N),!i&&A>0&&Z())},[i,j,A]),De=Qe(S=>{S.id===j&&(p(S),T.accounts[`${S.id}@${s}`]=S)},[j,s]);return e("div",{tabIndex:"-1",class:`account-container ${r==="loading"?"skeleton":""}`,style:{"--header-color-1":ke[0],"--header-color-2":ke[1],"--header-color-3":ke[2],"--header-color-4":ke[3]},children:[r==="error"&&e("div",{class:"ui-state",children:[e("p",{children:"Unable to load account."}),e("p",{children:e("a",{href:f?t:P,target:"_blank",rel:"noopener noreferrer",children:["Go to account page ",e(w,{icon:"external"})]})})]}),r==="loading"?e(_,{children:[e("header",{children:e(Xe,{avatarSize:"xxxl",skeleton:!0})}),e("main",{children:[e("div",{class:"note",children:[e("p",{children:"███████ ████ ████"}),e("p",{children:"████ ████████ ██████ █████████ ████ ██"})]}),e("div",{class:"account-metadata-box",children:[e("div",{class:"profile-metadata",children:[e("div",{class:"profile-field",children:[e("b",{class:"more-insignificant",children:"███"}),e("p",{children:"██████"})]}),e("div",{class:"profile-field",children:[e("b",{class:"more-insignificant",children:"████"}),e("p",{children:"███████████"})]})]}),e("div",{class:"stats",children:[e("div",{children:[e("span",{children:"██"})," Followers"]}),e("div",{children:[e("span",{children:"██"})," Following"]}),e("div",{children:[e("span",{children:"██"})," Posts"]})]})]}),e("div",{class:"actions",children:[e("span",{}),e("span",{class:"buttons",children:e("button",{type:"button",title:"More",class:"plain",disabled:!0,children:e(w,{icon:"more",size:"l",alt:"More"})})})]})]})]}):c&&e(_,{children:[!!V&&e("div",{class:"account-moved",children:[e("p",{children:[e("b",{children:C})," has indicated that their new account is now:"]}),e(Xe,{account:V,instance:s,onClick:S=>{S.stopPropagation(),T.showAccount=V}})]}),!!ne&&!/missing\.png$/.test(ne)&&e("img",{src:ne,alt:"",class:`header-banner ${fe?"header-is-avatar":""}`,onError:S=>{S.target.crossOrigin?S.target.src!==me?S.target.src=me:(S.target.removeAttribute("crossorigin"),S.target.src=ne):S.target.src!==me?S.target.src=me:S.target.remove()},crossOrigin:"anonymous",onLoad:S=>{S.target.classList.add("loaded");try{const N=window.OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"),B=N.getContext("2d",{willReadFrequently:!0});N.width=S.target.width,N.height=S.target.height,B.imageSmoothingEnabled=!1,B.drawImage(S.target,0,0);const O=10,ge=[B.getImageData(0,0,O,O).data,B.getImageData(S.target.width-O,0,O,O).data,B.getImageData(0,S.target.height-O,O,O).data,B.getImageData(S.target.width-O,S.target.height-O,O,O).data].map(le=>{let ie=0,Ce=0,Ne=0,Oe=0;for(let Ve=0;Ve<le.length;Ve+=4)ie+=le[Ve],Ce+=le[Ve+1],Ne+=le[Ve+2],Oe+=le[Ve+3];const Ee=le.length/4;return[ie/Ee,Ce/Ee,Ne/Ee,Oe/Ee]}).map(le=>{const[ie,Ce,Ne,Oe]=no(le);return`rgba(${ie}, ${Ce}, ${Ne}, ${Oe})`});Le(ge)}catch{}}}),e("header",{children:i?e(Ze,{shift:window.matchMedia("(min-width: calc(40em))").matches?114:64,menuButton:e("div",{children:e(Xe,{account:c,instance:s,avatarSize:"xxxl",onClick:()=>{}})}),children:[e("div",{class:"szh-menu__header",children:e(lo,{acct:b,instance:s})}),e(de,{onClick:()=>{const S=`@${b}`;try{navigator.clipboard.writeText(S),se("Handle copied")}catch{se("Unable to copy handle")}},children:[e(w,{icon:"link"}),e("span",{children:"Copy handle"})]}),e(de,{href:P,target:"_blank",children:[e(w,{icon:"external"}),e("span",{children:"Go to original profile page"})]}),e(ze,{}),e(Re,{href:c.avatar,target:"_blank",children:[e(w,{icon:"user"}),e("span",{children:"View profile image"})]}),e(Re,{href:c.header,target:"_blank",children:[e(w,{icon:"media"}),e("span",{children:"View profile header"})]})]}):e(Xe,{account:c,instance:s,avatarSize:"xxxl",internal:!0})}),e("div",{class:"faux-header-bg","aria-hidden":"true"}),e("main",{children:[!!U&&e("span",{class:"tag",children:"In Memoriam"}),!!g&&e("span",{class:"tag",children:[e(w,{icon:"bot"})," Automated"]}),!!Y&&e("span",{class:"tag",children:[e(w,{icon:"group"})," Group"]}),ye==null?void 0:ye.map(S=>e("span",{class:"tag",children:[S.name,!!he&&e(_,{children:[" ",e("span",{class:"more-insignificant",children:he})]})]})),e("div",{class:"note",dir:"auto",onClick:ws({instance:d}),dangerouslySetInnerHTML:{__html:on(X,{emojis:v})}}),e("div",{class:"account-metadata-box",children:[(I==null?void 0:I.length)>0&&e("div",{class:"profile-metadata",children:I.map(({name:S,value:N,verifiedAt:B},O)=>e("div",{class:`profile-field ${B?"profile-verified":""}`,dir:"auto",children:[e("b",{children:[e(vs,{text:S,emojis:v})," ",!!B&&e(w,{icon:"check-circle",size:"s"})]}),e("p",{dangerouslySetInnerHTML:{__html:on(N,{emojis:v})}})]},S+O))}),e("div",{class:"stats",children:[e(ae,{tabIndex:0,to:te,onClick:()=>{setTimeout(()=>{T.showGenericAccounts={id:"followers",heading:"Followers",fetchAccounts:Fe,instance:s,excludeRelationshipAttrs:ue?["followedBy"]:[],blankCopy:ve?"This user has chosen to not make this information available.":void 0}},0)},children:[!!Se.length&&e("span",{class:"shazam-container-horizontal",children:e("span",{class:"shazam-container-inner stats-avatars-bunch",children:Se.map(S=>e(st,{url:S.avatarStatic,size:"s",alt:`${S.displayName} @${S.acct}`,squircle:S==null?void 0:S.bot}))})}),e("span",{title:x,children:Ge(x)})," ","Followers"]}),e(ae,{class:"insignificant",tabIndex:0,to:te,onClick:()=>{setTimeout(()=>{T.showGenericAccounts={heading:"Following",fetchAccounts:J,instance:s,excludeRelationshipAttrs:ue?["following"]:[],blankCopy:ve?"This user has chosen to not make this information available.":void 0}},0)},children:[e("span",{title:L,children:Ge(L)})," ","Following",e("br",{})]}),e(ae,{class:"insignificant",to:te,children:[e("span",{title:A,children:Ge(A)})," ","Posts"]}),!!y&&e("div",{class:"insignificant",children:["Joined"," ",e("time",{datetime:y,children:ot(y,{hideTime:!0})})]})]})]}),!!F&&e(ae,{to:te,class:"account-metadata-box",children:e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:R?e("div",{class:"posting-stats",title:`${Math.round(F.originals/F.total*100)}% original posts, ${Math.round(F.replies/F.total*100)}% replies, ${Math.round(F.boosts/F.total*100)}% boosts`,children:[e("div",{children:F.daysSinceLastPost<365?`Last ${F.total} post${F.total>1?"s":""} in the past
${F.daysSinceLastPost} day${F.daysSinceLastPost>1?"s":""}`:`
Last ${F.total} posts in the past year(s)
`}),e("div",{class:"posting-stats-bar",style:{"--originals-percentage":`${F.originals/F.total*100}%`,"--replies-percentage":`${(F.originals+F.replies)/F.total*100}%`}}),e("div",{class:"posting-stats-legends",children:[e("span",{class:"ib",children:[e("span",{class:"posting-stats-legend-item posting-stats-legend-item-originals"})," ","Original"]})," ",e("span",{class:"ib",children:[e("span",{class:"posting-stats-legend-item posting-stats-legend-item-replies"})," ","Replies"]})," ",e("span",{class:"ib",children:[e("span",{class:"posting-stats-legend-item posting-stats-legend-item-boosts"})," ","Boosts"]})]})]}):e("div",{class:"posting-stats",children:"Post stats unavailable."})})})}),!V&&e("div",{class:"account-metadata-box",children:e("div",{class:"shazam-container no-animation",hidden:!!F,children:e("div",{class:"shazam-container-inner",children:e("button",{type:"button",class:"posting-stats-button",disabled:D==="loading",onClick:()=>{Z()},children:[e("div",{class:`posting-stats-bar posting-stats-icon ${D==="loading"?"loading":""}`,style:{"--originals-percentage":"33%","--replies-percentage":"66%"}}),"View post stats"," "]})})})})]}),e("footer",{children:e(to,{info:c,instance:s,standalone:i,authenticated:o,onRelationshipChange:ce,onProfileUpdate:De})})]})]})}const eo=3;function to({info:t,instance:n,standalone:i,authenticated:s,onRelationshipChange:o=()=>{},onProfileUpdate:a=()=>{}}){var Ie;if(!t)return null;const{masto:h,instance:d,authenticated:r}=Q(),u=n===d,[f,c]=$("default"),[p,l]=$(null),{id:b,acct:m,url:k,username:g,locked:y,lastStatusAt:C,note:v,fields:I,moved:x}=t,L=z(b),{following:Y,showingReblogs:j,notifying:M,followedBy:ee,blocking:X,blockedBy:A,muting:P,mutingNotifications:E,requested:U,domainBlocking:V,endorsed:ye,note:ve}=p||{},[fe,ne]=$(null),[me,ue]=$(!1);G(()=>{if(t){const F=ct();let re;(async()=>{if(u&&s)re=b;else if(!u&&r){const W=t.acct.includes("@");try{const R=await h.v2.search.fetch({q:W?t.acct:`${t.username}@${n}`,type:"accounts",limit:1,resolve:!0});R.accounts.length&&(re=R.accounts[0].id,ne(R.accounts[0]))}catch{}}if(!re)return;if(F===re){ue(!0);return}L.current=re,c("loading");const D=h.v1.accounts.relationships.fetch({id:[re]});try{const W=await D;if(c("default"),W.length){const R=W[0];l(R),o({relationship:R,currentID:re})}}catch{c("error")}})()}},[t,s]),G(()=>{t&&me&&Ks(t)},[t,me]);const he=f==="loading",[ke,Le]=$(!1),[Te,Pe]=$(!1),[Fe,xe]=$(!1),[J,ae]=$(!1),[te,Se]=$([]);return e(_,{children:[e("div",{class:"actions",children:[e("span",{children:[ee?e("span",{class:"tag",children:"Follows you"}):C?e("small",{class:"insignificant",children:["Last post:"," ",e("span",{class:"ib",children:ot(C,{hideTime:!0})})]}):e("span",{}),P&&e("span",{class:"tag danger",children:"Muted"}),X&&e("span",{class:"tag danger",children:"Blocked"})]})," ",e("span",{class:"buttons",children:[!!ve&&e("button",{type:"button",class:"private-note-tag",title:"Private note",onClick:()=>{xe(!0)},dir:"auto",children:e("span",{children:ve})}),e(Ze,{portal:{target:document.body},containerProps:{style:{zIndex:1001}},align:"center",position:"anchor",overflow:"auto",menuButton:e("button",{type:"button",title:"More",class:"plain",disabled:he,children:e(w,{icon:"more",size:"l",alt:"More"})}),onMenuChange:F=>{Y&&F.open&&(async()=>{try{const re=await h.v1.accounts.$select(L.current).lists.list();Se(re)}catch{}})()},children:[r&&!me&&e(_,{children:[e(de,{onClick:()=>{wi({draftStatus:{status:`@${(fe==null?void 0:fe.acct)||m} `}})},children:[e(w,{icon:"at"}),e("span",{children:["Mention @",g]})]}),e(de,{onClick:()=>{Le(!0)},children:[e(w,{icon:"translate"}),e("span",{children:"Translate bio"})]}),je("@mastodon/profile-private-note")&&e(de,{onClick:()=>{xe(!0)},children:[e(w,{icon:"pencil"}),e("span",{children:ve?"Edit private note":"Add private note"})]}),Y&&!!p&&e(_,{children:[e(de,{onClick:()=>{c("loading"),(async()=>{try{const F=await h.v1.accounts.$select(L.current).follow({notify:!M});F&&l(F),c("default"),se(F.notifying?`Notifications enabled for @${g}'s posts.`:` Notifications disabled for @${g}'s posts.`)}catch(F){alert(F),c("error")}})()},children:[e(w,{icon:"notification"}),e("span",{children:M?"Disable notifications":"Enable notifications"})]}),e(de,{onClick:()=>{c("loading"),(async()=>{try{const F=await h.v1.accounts.$select(L.current).follow({reblogs:!j});F&&l(F),c("default"),se(F.showingReblogs?`Boosts from @${g} disabled.`:`Boosts from @${g} enabled.`)}catch(F){alert(F),c("error")}})()},children:[e(w,{icon:"rocket"}),e("span",{children:j?"Disable boosts":"Enable boosts"})]})]}),Y&&e(de,{onClick:()=>{Pe(!0)},children:[e(w,{icon:"list"}),te.length?e(_,{children:[e("small",{class:"menu-grow",children:["Add/Remove from Lists",e("br",{}),e("span",{class:"more-insignificant",children:te.map(F=>F.title).join(", ")})]}),e("small",{class:"more-insignificant",children:te.length})]}):e("span",{children:"Add/Remove from Lists"})]}),e(ze,{})]}),e(de,{onClick:()=>{const F=`@${(fe==null?void 0:fe.acct)||m}`;try{navigator.clipboard.writeText(F),se("Handle copied")}catch{se("Unable to copy handle")}},children:[e(w,{icon:"copy"}),e("small",{children:["Copy handle",e("br",{}),e("span",{class:"more-insignificant",children:["@",(fe==null?void 0:fe.acct)||m]})]})]}),e(de,{href:k,target:"_blank",children:[e(w,{icon:"external"}),e("small",{class:"menu-double-lines",children:so(k)})]}),e("div",{class:"menu-horizontal",children:[e(de,{onClick:()=>{try{navigator.clipboard.writeText(k),se("Link copied")}catch{se("Unable to copy link")}},children:[e(w,{icon:"link"}),e("span",{children:"Copy"})]}),(navigator==null?void 0:navigator.share)&&((Ie=navigator==null?void 0:navigator.canShare)==null?void 0:Ie.call(navigator,{url:k}))&&e(de,{onClick:()=>{try{navigator.share({url:k})}catch{alert("Sharing doesn't seem to work.")}},children:[e(w,{icon:"share"}),e("span",{children:"Share…"})]})]}),!!p&&e(_,{children:[e(ze,{}),P?e(de,{onClick:()=>{c("loading"),(async()=>{try{const F=await h.v1.accounts.$select((fe==null?void 0:fe.id)||b).unmute();l(F),c("default"),se(`Unmuted @${g}`),T.reloadGenericAccounts.id="mute",T.reloadGenericAccounts.counter++}catch{c("error")}})()},children:[e(w,{icon:"unmute"}),e("span",{children:["Unmute @",g]})]}):e(Wt,{menuClassName:"menu-blur",openTrigger:"clickOnly",direction:"bottom",overflow:"auto",shift:16,label:e(_,{children:[e(w,{icon:"mute"}),e("span",{class:"menu-grow",children:["Mute @",g,"…"]}),e("span",{style:{textOverflow:"clip"},children:[e(w,{icon:"time"}),e(w,{icon:"chevron-right"})]})]}),children:e("div",{class:"menu-wrap",children:Ki.map(F=>e(de,{onClick:()=>{c("loading"),(async()=>{try{const re=await h.v1.accounts.$select((fe==null?void 0:fe.id)||b).mute({duration:F});l(re),c("default"),se(`Muted @${g} for ${Bn[F]}`),T.reloadGenericAccounts.id="mute",T.reloadGenericAccounts.counter++}catch{c("error"),se(`Unable to mute @${g}`)}})()},children:Bn[F]}))})}),ee&&e(et,{subMenu:!0,menuItemClassName:"danger",confirmLabel:e(_,{children:[e(w,{icon:"user-x"}),e("span",{children:["Remove @",g," from followers?"]})]}),onClick:()=>{c("loading"),(async()=>{try{const F=await h.v1.accounts.$select((fe==null?void 0:fe.id)||b).removeFromFollowers();l(F),c("default"),se(`@${g} removed from followers`),T.reloadGenericAccounts.id="followers",T.reloadGenericAccounts.counter++}catch{c("error")}})()},children:[e(w,{icon:"user-x"}),e("span",{children:"Remove follower…"})]}),e(et,{subMenu:!0,confirm:!X,confirmLabel:e(_,{children:[e(w,{icon:"block"}),e("span",{children:["Block @",g,"?"]})]}),menuItemClassName:"danger",onClick:()=>{c("loading"),(async()=>{try{if(X){const F=await h.v1.accounts.$select((fe==null?void 0:fe.id)||b).unblock();l(F),c("default"),se(`Unblocked @${g}`)}else{const F=await h.v1.accounts.$select((fe==null?void 0:fe.id)||b).block();l(F),c("default"),se(`Blocked @${g}`)}T.reloadGenericAccounts.id="block",T.reloadGenericAccounts.counter++}catch{c("error"),X?se(`Unable to unblock @${g}`):se(`Unable to block @${g}`)}})()},children:X?e(_,{children:[e(w,{icon:"unblock"}),e("span",{children:["Unblock @",g]})]}):e(_,{children:[e(w,{icon:"block"}),e("span",{children:["Block @",g,"…"]})]})}),e(de,{className:"danger",onClick:()=>{T.showReportModal={account:fe||t}},children:[e(w,{icon:"flag"}),e("span",{children:["Report @",g,"…"]})]})]}),r&&me&&i&&je("@mastodon/profile-edit")&&e(_,{children:[e(ze,{}),e(de,{onClick:()=>{ae(!0)},children:[e(w,{icon:"pencil"}),e("span",{children:"Edit profile"})]})]}),!1]}),!p&&f==="loading"&&e($e,{abrupt:!0}),!!p&&!x&&e(et,{confirm:Y||U,confirmLabel:e("span",{children:U?"Withdraw follow request?":`Unfollow @${t.acct||t.username}?`}),menuItemClassName:"danger",align:"end",disabled:he,onClick:()=>{c("loading"),(async()=>{try{let F;Y||U?F=await h.v1.accounts.$select(L.current).unfollow():F=await h.v1.accounts.$select(L.current).follow(),F&&l(F),c("default")}catch(F){alert(F),c("error")}})()},children:e("button",{type:"button",class:`${Y||U?"light swap":""}`,"data-swap-state":Y||U?"danger":"",disabled:he,children:Y?e(_,{children:[e("span",{children:"Following"}),e("span",{children:"Unfollow…"})]}):U?e(_,{children:[e("span",{children:"Requested"}),e("span",{children:"Withdraw…"})]}):y?e(_,{children:[e(w,{icon:"lock"})," ",e("span",{children:"Follow"})]}):"Follow"})})]})]}),!!ke&&e(Ae,{onClose:()=>{Le(!1)},children:e(io,{note:v,fields:I,onClose:()=>Le(!1)})}),!!Te&&e(Ae,{onClose:()=>{Pe(!1)},children:e(oo,{accountID:L.current,onClose:()=>Pe(!1)})}),!!Fe&&e(Ae,{onClose:()=>{xe(!1)},children:e(ao,{account:t,note:ve,onRelationshipChange:F=>{l(F)},onClose:()=>xe(!1)})}),!!J&&e(Ae,{onClose:()=>{ae(!1)},children:e(co,{onClose:({state:F,account:re}={})=>{ae(!1),F==="success"&&re&&a(re)}})})]})}function no([t,n,i]){const s=.2126*t+.7152*n+.0722*i;let o;return s>=220?o=1:s<=50?o=.1:o=s/255,o=Math.min(1,o),[t,n,i,o]}function so(t){if(!t)return;const n=new URL(t),{host:i,pathname:s}=n,o=s.replace(/\/$/,"").replace(/^\//,"");return e(_,{children:[e("span",{class:"more-insignificant",children:[xt.toUnicode(i),"/"]}),e("wbr",{}),e("span",{children:o})]})}function io({note:t,fields:n,onClose:i}){const s=(n==null?void 0:n.map(({name:a,value:h})=>`${a}
${Pn(h)}`).join(`
`))||"",o=Pn(t)+(s?`
${s}`:"");return e("div",{class:"sheet",children:[!!i&&e("button",{type:"button",class:"sheet-close",onClick:i,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Translated Bio"})}),e("main",{children:[e("p",{style:{whiteSpace:"pre-wrap"},children:o}),e(ks,{forceTranslate:!0,text:o})]})]})}function oo({accountID:t,onClose:n}){const{masto:i}=Q(),[s,o]=$("default"),[a,h]=$([]),[d,r]=$([]),[u,f]=mt(l=>l+1,0);G(()=>{o("loading"),(async()=>{try{const l=await Pt();h(l);const b=await i.v1.accounts.$select(t).lists.list();r(b),o("default")}catch{o("error")}})()},[u]);const[c,p]=$(!1);return e("div",{class:"sheet",id:"list-add-remove-container",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Add/Remove from Lists"})}),e("main",{children:[a.length>0?e("ul",{class:"list-add-remove",children:a.map(l=>{const b=d.some(m=>m.id===l.id);return e("li",{children:e("button",{type:"button",class:`light ${b?"checked":""}`,disabled:s==="loading",onClick:()=>{o("loading"),(async()=>{try{b?await i.v1.lists.$select(l.id).accounts.remove({accountIds:[t]}):await i.v1.lists.$select(l.id).accounts.create({accountIds:[t]}),f()}catch{o("error"),alert(b?"Unable to remove from list.":"Unable to add to list.")}})()},children:[e(w,{icon:"check-circle"}),e("span",{children:l.title})]})})})}):s==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):s==="error"?e("p",{class:"ui-state",children:"Unable to load lists."}):e("p",{class:"ui-state",children:"No lists."}),e("button",{type:"button",class:"plain2",onClick:()=>p(!0),disabled:s!=="default",children:[e(w,{icon:"plus",size:"l"})," ",e("span",{children:"New list"})]})]}),c&&e(Ae,{onClick:l=>{l.target===l.currentTarget&&p(!1)},children:e(kn,{list:c==null?void 0:c.list,onClose:l=>{l.state==="success"&&f(),p(!1)}})})]})}function ao({account:t,note:n,onRelationshipChange:i=()=>{},onClose:s=()=>{}}){const{masto:o}=Q(),[a,h]=$("default"),d=z(null);return G(()=>{let r;return d.current&&!n&&(r=setTimeout(()=>{var u,f;(f=(u=d.current).focus)==null||f.call(u)},100)),()=>{clearTimeout(r)}},[]),e("div",{class:"sheet",id:"private-note-container",children:[!!s&&e("button",{type:"button",class:"sheet-close",onClick:s,children:e(w,{icon:"x"})}),e("header",{children:e("b",{children:["Private note about @",(t==null?void 0:t.username)||(t==null?void 0:t.acct)]})}),e("main",{children:e("form",{onSubmit:r=>{r.preventDefault();const f=new FormData(r.target).get("note");(f==null?void 0:f.trim())!==(n==null?void 0:n.trim())&&(h("loading"),(async()=>{try{const c=await o.v1.accounts.$select(t==null?void 0:t.id).note.create({comment:f});h("default"),i(c),s()}catch(c){h("error"),alert((c==null?void 0:c.message)||"Unable to update private note.")}})())},children:[e("textarea",{ref:d,name:"note",disabled:a==="loading",children:n}),e("footer",{children:[e("button",{type:"button",class:"light",disabled:a==="loading",onClick:()=>{s==null||s()},children:"Cancel"}),e("span",{children:[e($e,{abrupt:!0,hidden:a!=="loading"}),e("button",{disabled:a==="loading",type:"submit",children:"Save & close"})]})]})]})})]})}function co({onClose:t=()=>{}}){const{masto:n}=Q(),[i,s]=$("loading"),[o,a]=$(null);G(()=>{(async()=>{try{const c=await n.v1.accounts.verifyCredentials();a(c),s("default")}catch{s("error")}})()},[]);const{displayName:h,source:d}=o||{},{note:r,fields:u}=d||{},f=z(null);return e("div",{class:"sheet",id:"edit-profile-container",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(w,{icon:"x"})}),e("header",{children:e("b",{children:"Edit profile"})}),e("main",{children:i==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):e("form",{onSubmit:c=>{c.preventDefault();const p=new FormData(c.target),l=p.get("display_name"),b=p.get("note"),m=f.current.querySelectorAll('input[name^="fields_attributes"]'),k=[];m.forEach(g=>{const y=g.name,[C,v,I]=y.match(/fields_attributes\[(\d+)\]\[(.+)\]/)||[],x=g.value?g.value.trim():"";v&&I&&x&&(k[v]||(k[v]={}),k[v][I]=x)}),k.forEach(g=>{g.name&&!g.value&&(g.value="")}),(async()=>{try{const g=await n.v1.accounts.updateCredentials({displayName:l,note:b,fieldsAttributes:k});t==null||t({state:"success",account:g})}catch(g){alert((g==null?void 0:g.message)||"Unable to update profile.")}})()},children:[e("p",{children:e("label",{children:["Name"," ",e("input",{type:"text",name:"display_name",defaultValue:h,maxLength:30,disabled:i==="loading"})]})}),e("p",{children:e("label",{children:["Bio",e("textarea",{defaultValue:r,name:"note",maxLength:500,rows:"5",disabled:i==="loading"})]})}),e("p",{children:"Extra fields"}),e("table",{ref:f,children:[e("thead",{children:e("tr",{children:[e("th",{children:"Label"}),e("th",{children:"Content"})]})}),e("tbody",{children:Array.from({length:Math.max(4,u.length)}).map((c,p)=>{const{name:l="",value:b=""}=u[p]||{};return e(ro,{name:l,value:b,index:p,disabled:i==="loading"},p)})})]}),e("footer",{children:[e("button",{type:"button",class:"light",disabled:i==="loading",onClick:()=>{t==null||t()},children:"Cancel"}),e("button",{type:"submit",disabled:i==="loading",children:"Save"})]})]})})]})}function ro({name:t,value:n,disabled:i,index:s}){const[o,a]=$(!!n);return e("tr",{children:[e("td",{children:e("input",{type:"text",name:`fields_attributes[${s}][name]`,defaultValue:t,disabled:i,maxLength:255,required:o})}),e("td",{children:e("input",{type:"text",name:`fields_attributes[${s}][value]`,defaultValue:n,disabled:i,maxLength:255,onChange:h=>a(!!h.currentTarget.value)})})]})}function lo({acct:t,instance:n}){let[i,s]=t.split("@");return s||(s=n),e("div",{class:"handle-info",children:[e("span",{class:"handle-handle",children:[e("b",{class:"handle-username",children:i}),e("span",{class:"handle-at",children:"@"}),e("b",{class:"handle-server",children:s})]}),e("div",{class:"handle-legend",children:[e("span",{class:"ib",children:[e("span",{class:"handle-legend-icon username"})," username"]})," ",e("span",{class:"ib",children:[e("span",{class:"handle-legend-icon server"})," server domain name"]})]})]})}function uo({account:t,instance:n,onClose:i}){const{masto:s,instance:o,authenticated:a}=Q({instance:n}),h=typeof t=="string";return G(()=>{h||(T.accounts[`${t.id}@${o}`]=t)},[t]),xs(i),e("div",{class:"sheet",children:[!!i&&e("button",{type:"button",class:"sheet-close outer",onClick:i,children:e(w,{icon:"x"})}),e(_s,{instance:o,authenticated:a,account:t,fetchAccount:async()=>{if(h)try{return await s.v1.accounts.lookup({acct:t,skip_webfinger:!1})}catch{const r=await s.v2.search.fetch({q:t,type:"accounts",limit:1,resolve:a});if(r.accounts.length)return r.accounts[0];if(/https?:\/\/[^/]+\/@/.test(t)){const u=new URL(t),{hostname:f,pathname:c}=u,p=c.replace(/^\//,"").replace(/\/$/,"")+"@"+f,l=await s.v2.search.fetch({q:p,type:"accounts",limit:1,resolve:a});if(l.accounts.length)return l.accounts[0]}}else return t}})]})}function ho({onClose:t}){const{masto:n}=Q(),[i,s]=$("default"),[o,a]=$([]),[h,d]=mt(u=>u+1,0);G(()=>{s("loading"),(async()=>{try{const u=await nt.drafts.keys();if(u.length){const f=jt(),c=u.filter(p=>p.startsWith(f));if(c.length){const p=await nt.drafts.getMany(c);p.sort((l,b)=>new Date(b.updatedAt).getTime()-new Date(l.updatedAt).getTime()),a(p)}else a([])}else a([]);s("default")}catch{s("error")}})()},[h]);const r=(o==null?void 0:o.length)>0;return e("div",{class:"sheet",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(w,{icon:"x"})}),e("header",{children:[e("h2",{children:["Unsent drafts ",e($e,{abrupt:!0,hidden:i!=="loading"})]}),r&&e("div",{class:"insignificant",children:"Looks like you have unsent drafts. Let's continue where you left off."})]}),e("main",{children:r?e(_,{children:[e("ul",{class:"drafts-list",children:o.map(u=>{const{updatedAt:f,key:c,draftStatus:p,replyTo:l}=u,b=new Date(f);return e("li",{children:[e("div",{class:"mini-draft-meta",children:[e("b",{children:[e(w,{icon:l?"reply":"quill",size:"s"})," ",e("time",{children:[!!l&&e(_,{children:["@",l.account.acct,e("br",{})]}),ot(b)]})]}),e(et,{confirmLabel:e("span",{children:"Delete this draft?"}),menuItemClassName:"danger",align:"end",disabled:i==="loading",onClick:()=>{(async()=>{try{await nt.drafts.del(c),d()}catch{alert("Error deleting draft! Please try again.")}})()},children:e("button",{type:"button",class:"small light",disabled:i==="loading",children:"Delete…"})})]}),e("button",{type:"button",disabled:i==="loading",class:"draft-item",onClick:async()=>{let m;if(l){s("loading");try{m=await n.v1.statuses.$select(l.id).fetch()}catch{alert("Error fetching reply-to status!"),s("default");return}s("default")}window.__COMPOSE__={draftStatus:p,replyToStatus:m},T.showCompose=!0,T.showDrafts=!1},children:e(po,{draft:u})})]},f)})}),o.length>1&&e("p",{children:e(et,{confirmLabel:e("span",{children:"Delete all drafts?"}),menuItemClassName:"danger",disabled:i==="loading",onClick:()=>{(async()=>{s("loading");try{await nt.drafts.delMany(o.map(u=>u.key)),s("default"),d()}catch{alert("Error deleting drafts! Please try again."),s("error")}})()},children:e("button",{type:"button",class:"light danger",disabled:i==="loading",children:"Delete all…"})})})]}):e("p",{children:"No drafts found."})})]})}function po({draft:t}){var c;const{draftStatus:n,replyTo:i}=t,{status:s,spoilerText:o,poll:a,mediaAttachments:h}=n,d=((c=a==null?void 0:a.options)==null?void 0:c.length)>0,r=(h==null?void 0:h.length)>0,u=d||r,f=pe(()=>{if(!r)return;const p=h.find(m=>/image/.test(m.type));if(!p)return;const{file:l}=p;return URL.createObjectURL(l)},[r,h]);return e(_,{children:e("div",{class:"mini-draft",children:[u&&e("div",{class:`mini-draft-aside ${f?"has-image":""}`,style:f?{"--bg-image":`url(${f})`}:{},children:[d&&e(w,{icon:"poll"}),r&&e("span",{children:[e(w,{icon:"attachment"})," ",e("small",{children:h==null?void 0:h.length})]})]}),e("div",{class:"mini-draft-main",children:[!!o&&e("div",{class:"mini-draft-spoiler",children:o}),!!s&&e("div",{class:"mini-draft-status",children:s})]})]})})}function fo({html:t,url:n,width:i,height:s,onClose:o=()=>{}}){return e("div",{class:"embed-modal-container",children:[e("div",{class:"top-controls",children:[e("button",{type:"button",class:"light",onClick:()=>o(),children:e(w,{icon:"x"})}),n&&e("a",{href:n,target:"_blank",rel:"noopener noreferrer",class:"button plain",children:[e("span",{children:"Open link"})," ",e(w,{icon:"external"})]})]}),e("div",{class:"embed-content",dangerouslySetInnerHTML:{__html:t},style:{"--width":i+"px","--height":s+"px","--aspect-ratio":`${i}/${s}`}})]})}function mo({instance:t,excludeRelationshipAttrs:n=[],postID:i,onClose:s=()=>{},blankCopy:o="Nothing to show"}){const{masto:a,instance:h}=Q(),d=t?t===h:!0,r=Me(T),[u,f]=$("default"),[c,p]=$([]),[l,b]=$(!1);if(xs(s),!r.showGenericAccounts)return null;const{id:m,heading:k,fetchAccounts:g,accounts:y,showReactions:C}=r.showGenericAccounts,[v,I]=$({}),x=async M=>{if(!(M!=null&&M.length)||!d)return;const ee=await bn(M,v);ee&&I({...v,...ee})},L=M=>{g&&(M&&p([]),f("loading"),(async()=>{try{const{done:ee,value:X}=await g(M);if(Array.isArray(X)){if(M){const A=[];for(let P=0;P<X.length;P++){const E=X[P],U=A.find((V,ye)=>V.id===E.id&&P!==ye);U?U._types.push(...E._types):A.push({_types:[],...E})}p(A)}else p(A=>{const P=A;for(const E of X){const U=P.find(V=>V.id===E.id);U?U._types.push(...E._types):P.push(E)}return P});b(!ee),x(X)}else b(!1);f("default")}catch{f("error")}})())},Y=z(!0);G(()=>{(y==null?void 0:y.length)>0?(p(y),x(y)):(L(!0),Y.current=!1)},[y,g]),G(()=>{var M;Y.current||((M=r.reloadGenericAccounts)==null?void 0:M.id)===m&&L(!0)},[r.reloadGenericAccounts.counter]);const j=T.statuses[i];return e("div",{id:"generic-accounts-container",class:"sheet",tabindex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:s,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:k||"Accounts"})}),e("main",{children:[j&&e(oe,{to:`/${t||h}/s/${j.id}`,class:"post-preview",children:e(Be,{status:j,size:"s",readOnly:!0})}),c.length>0?e(_,{children:[e("ul",{class:"accounts-list",children:c.map(M=>{var A,P;const ee=v[M.id],X=`${M.id}-${((A=M._types)==null?void 0:A.length)||""}`;return e("li",{children:[C&&((P=M._types)==null?void 0:P.length)>0&&e("div",{class:"reactions-block",children:M._types.map(E=>e(w,{icon:{reblog:"rocket",favourite:"heart"}[E],class:`${E}-icon`}))}),e("div",{class:"account-relationships",children:e(Xe,{account:M,showStats:!0,relationship:ee,excludeRelationshipAttrs:n})})]},X)})}),u==="default"?l?e(rt,{onChange:M=>{M&&L()},children:e("button",{type:"button",class:"plain block",onClick:()=>L(),children:"Show more…"})}):e("p",{class:"ui-state insignificant",children:"The end."}):u==="loading"&&e("p",{class:"ui-state",children:e($e,{abrupt:!0})})]}):u==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):u==="error"?e("p",{class:"ui-state",children:"Error loading accounts"}):e("p",{class:"ui-state insignificant",children:o})]})]})}function go({alt:t,lang:n,onClose:i}){const s=Me(T),[o,a]=$(!1),h=ys(!0),d=s.settings.contentTranslationHideLanguages||[],r=!!n&&n!==h&&!Dn([n],[h])&&!d.find(u=>n===u||Dn([n],[u]));return e("div",{class:"sheet",tabindex:"-1",children:[!!i&&e("button",{type:"button",class:"sheet-close outer",onClick:i,children:e(w,{icon:"x"})}),e("header",{class:"header-grid",children:[e("h2",{children:"Media description"}),e("div",{class:"header-side",children:e(Ze,{align:"end",menuButton:e("button",{type:"button",class:"plain4",children:e(w,{icon:"more",alt:"More",size:"xl"})}),children:[e(de,{disabled:o,onClick:()=>{a(!0)},children:[e(w,{icon:"translate"}),e("span",{children:"Translate"})]}),vi&&e(de,{onClick:()=>{ki(t,n)},children:[e(w,{icon:"speak"}),e("span",{children:"Speak"})]})]})})]}),e("main",{lang:n,dir:"auto",children:[e("p",{style:{whiteSpace:"pre-wrap",textWrap:"pretty"},children:t}),(r||o)&&e(ks,{forceTranslate:o,sourceLanguage:n,text:t})]})]})}function Qt(t,n,i){return Math.max(Math.min(t,i),n)}const en=t=>t>=.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,tn=t=>t>=.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t;function Sn([t,n,i]){t=en(t/255),n=en(n/255),i=en(i/255);var s=.4122214708*t+.5363325363*n+.0514459929*i,o=.2119034982*t+.6806995451*n+.1073969566*i,a=.0883024619*t+.2817188376*n+.6299787005*i;return s=Math.cbrt(s),o=Math.cbrt(o),a=Math.cbrt(a),[s*.2104542553+o*.793617785+a*-.0040720468,s*1.9779984951+o*-2.428592205+a*.4505937099,s*.0259040371+o*.7827717662+a*-.808675766]}function In([t,n,r]){var s=t+n*.3963377774+r*.2158037573,o=t+n*-.1055613458+r*-.0638541728,a=t+n*-.0894841775+r*-1.291485548;s=s**3,o=o**3,a=a**3;var h=s*4.0767416621+o*-3.3077115913+a*.2309699292,d=s*-1.2684380046+o*2.6097574011+a*-.3413193965,r=s*-.0041960863+o*-.7034186147+a*1.707614701;return h=255*tn(h),d=255*tn(d),r=255*tn(r),h=Qt(h,0,255),d=Qt(d,0,255),r=Qt(r,0,255),h=Math.round(h),d=Math.round(d),r=Math.round(r),[h,d,r]}var bo={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",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",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_IMG_ALT_API_URL:jc}=bo;function Ls({mediaAttachments:t,statusID:n,instance:i,lang:s,index:o=0,onClose:a=()=>{}}){var y,C;const[h,d]=$("default"),r=z(null),[u,f]=$(o),c=z(null);lt(()=>{var v;(v=c.current)==null||v.scrollIntoView()},[]);const p=z(n);G(()=>{const v=o*r.current.clientWidth,I=p.current!==n;I&&(p.current=n),r.current.scrollTo({left:v,behavior:I?"auto":"smooth"}),r.current.focus()},[o,n]);const[l,b]=$(!0);G(()=>{let v=()=>{a()};return r.current&&r.current.addEventListener("swiped-down",v),()=>{r.current&&r.current.removeEventListener("swiped-down",v)}},[]),_e("esc",a,{ignoreEventWhen:v=>!!document.querySelector("#modal-container > *")},[a]),G(()=>{let v=()=>{const{clientWidth:I,scrollLeft:x}=r.current,L=Math.round(x/I);f(L)};return r.current&&r.current.addEventListener("scroll",v,{passive:!0}),()=>{r.current&&r.current.removeEventListener("scroll",v)}},[]),G(()=>{let v=setTimeout(()=>{var I,x;(x=(I=r.current)==null?void 0:I.focus)==null||x.call(I)},100);return()=>clearTimeout(v)},[]);const m=pe(()=>t==null?void 0:t.map(v=>{const{blurhash:I}=v;if(I){const x=fn(I),L=Sn(x);return In([.6,L[1],L[2]])}return null}),[t]),k=pe(()=>{var x;const I=100/m.length;return((x=m==null?void 0:m.map((L,Y)=>{const j=Y*I+5,M=(Y+1)*I-5;return L?`
rgba(${L==null?void 0:L.join(",")}, 0.4) ${j}%,
rgba(${L==null?void 0:L.join(",")}, 0.4) ${M}%
`:`
transparent ${j}%,
transparent ${M}%
`}))==null?void 0:x.join(", "))||"transparent"},[m]);let g=z(null);return G(()=>()=>{var v,I;(I=(v=g.current)==null?void 0:v.hideToast)==null||I.call(v)},[]),e("div",{class:`media-modal-container media-modal-count-${t==null?void 0:t.length}`,children:[e("div",{ref:r,tabIndex:"0","data-swipe-threshold":"44",class:"carousel",onClick:v=>{(v.target.classList.contains("carousel-item")||v.target.classList.contains("media")||v.target.classList.contains("media-zoom"))&&a()},style:t.length>1?{backgroundAttachment:"local",backgroundImage:`linear-gradient(
to right, ${k})`}:{},children:t==null?void 0:t.map((v,I)=>{const x=t.length===1?m[I]:null;return e("div",{class:"carousel-item",style:x?{"--accent-color":`rgb(${x==null?void 0:x.join(",")})`,"--accent-alpha-color":`rgba(${x==null?void 0:x.join(",")}, 0.4)`}:{},tabindex:"0",ref:I===u?c:null,onClick:L=>{L.target.classList.contains("media")||b(!l)},children:[!!v.description&&e("button",{type:"button",class:"media-alt",hidden:!l,onClick:()=>{T.showMediaAlt={alt:v.description,lang:s}},children:[e("span",{class:"alt-badge",children:"ALT"}),e("span",{class:"media-alt-desc",lang:s,dir:"auto",children:v.description})]}),e(Ss,{media:v,showOriginal:!0,lang:s})]},v.id)})}),e("div",{class:"carousel-top-controls",hidden:!l,children:[e("span",{children:e("button",{type:"button",class:"carousel-button",onClick:()=>a(),children:e(w,{icon:"x"})})}),(t==null?void 0:t.length)>1?e("span",{class:"carousel-dots",children:t==null?void 0:t.map((v,I)=>e("button",{type:"button",disabled:I===u,class:`carousel-dot ${I===u?"active":""}`,onClick:x=>{x.preventDefault(),x.stopPropagation(),r.current.scrollTo({left:r.current.clientWidth*I,behavior:"smooth"}),r.current.focus()},children:e(w,{icon:"round",size:"s"})},v.id))}):e("span",{}),e("span",{children:[e(Ze,{overflow:"auto",align:"end",position:"anchor",gap:4,menuClassName:"glass-menu",menuButton:e("button",{type:"button",class:"carousel-button",children:e(w,{icon:"more",alt:"More"})}),children:[e(Re,{href:((y=t[u])==null?void 0:y.remoteUrl)||((C=t[u])==null?void 0:C.url),class:"carousel-button",target:"_blank",title:"Open original media in new window",children:[e(w,{icon:"popout"}),e("span",{children:"Open original media"})]}),!1]})," ",e(oe,{to:`${i?`/${i}`:""}/s/${n}${window.matchMedia("(min-width: calc(40em + 350px))").matches?`?media=${u+1}`:""}`,class:"button carousel-button media-post-link",children:[e("span",{class:"button-label",children:"View post "}),"»"]})]})]}),(t==null?void 0:t.length)>1&&e("div",{class:"carousel-controls",hidden:!l,children:[e("button",{type:"button",class:"carousel-button",hidden:u===0,onClick:v=>{v.preventDefault(),v.stopPropagation(),r.current.focus(),r.current.scrollTo({left:r.current.clientWidth*(u-1),behavior:"smooth"})},children:e(w,{icon:"arrow-left"})}),e("button",{type:"button",class:"carousel-button",hidden:u===t.length-1,onClick:v=>{v.preventDefault(),v.stopPropagation(),r.current.focus(),r.current.scrollTo({left:r.current.clientWidth*(u+1),behavior:"smooth"})},children:e(w,{icon:"arrow-right"})})]})]})}const yo=[,"spam","legal","violation","other"],At={spam:{label:"Spam",description:"Malicious links, fake engagement, or repetitive replies"},legal:{label:"Illegal",description:"Violates the law of your or the server's country"},violation:{label:"Server rule violation",description:"Breaks specific server rules",stampLabel:"Violation"},other:{label:"Other",description:"Issue doesn't fit other categories",excludeStamp:!0}};function wo({account:t,post:n,onClose:i}){const{masto:s}=Q(),[o,a]=$("default"),[h,d]=t.acct.split("@"),[r,u]=pe(()=>{const{rules:g,domain:y}=us();return[g||[],y]}),[f,c]=$(null),[p,l]=$(!1),b=z(null),[m,k]=$(!1);return e("div",{class:"report-modal-container",children:[e("div",{class:"top-controls",children:[e("h1",{children:n?"Report Post":`Report @${h}`}),e("button",{type:"button",class:"plain4 small",disabled:o==="loading",onClick:()=>i(),children:e(w,{icon:"x",size:"xl"})})]}),e("main",{children:[e("div",{class:"report-preview",children:n?e(Be,{status:n,size:"s",previewMode:!0}):e(Xe,{account:t,avatarSize:"xxl",useAvatarStatic:!0,showStats:!0,showActivity:!0})}),!!f&&!At[f].excludeStamp&&e("span",{class:"rubber-stamp","aria-hidden":"true",children:[At[f].stampLabel||At[f].label,e("small",{children:"Pending review"})]},f),e("form",{onSubmit:g=>{g.preventDefault();const y=new FormData(g.target),C=Object.fromEntries(y.entries());let{category:v,comment:I,forward:x}=C;I||(I=void 0),x==="on"&&(x=!0);const L=v==="violation"?Object.entries(C).filter(([j])=>j.startsWith("rule_ids")).map(([j,M])=>M):void 0,Y={category:v,comment:I,forward:x,ruleIds:L};a("loading"),(async()=>{try{await s.v1.reports.create({accountId:t.id,statusIds:n!=null&&n.id?[n.id]:void 0,category:v,comment:I,ruleIds:L,forward:x}),a("success"),se(n?"Post reported":"Profile reported"),i()}catch(j){a("error"),se((j==null?void 0:j.message)||(n?"Unable to report post":"Unable to report profile"))}})()},children:[e("p",{children:n?"What's the issue with this post?":"What's the issue with this profile?"}),e("section",{class:"report-categories",children:yo.map(g=>g==="violation"&&!(r!=null&&r.length)?null:e(_,{children:[e("label",{class:"report-category",children:[e("input",{type:"radio",name:"category",value:g,required:!0,disabled:o==="loading",onChange:y=>{c(y.target.value),l(y.target.value==="violation")}}),e("span",{children:[At[g].label,"  ",e("small",{class:"ib insignificant",children:At[g].description})]})]}),g==="violation"&&!!(r!=null&&r.length)&&e("div",{class:"shazam-container no-animation",hidden:!p,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"report-rules",ref:b,children:r.map((y,C)=>e("label",{class:"report-rule",children:[e("input",{type:"checkbox",name:`rule_ids[${C}]`,value:y.id,required:p&&!m,disabled:o==="loading",onChange:v=>{const{checked:I}=v.target;I?k(!0):b.current.querySelectorAll("input:checked").length||k(!1)}}),e("span",{children:y.text})]},y.id))})})})]},g))}),e("section",{class:"report-comment",children:[e("p",{children:e("label",{for:"report-comment",children:"Additional info"})}),e("textarea",{maxlength:"1000",rows:"1",name:"comment",id:"report-comment",disabled:o==="loading"})]}),!!d&&d!==u&&e("section",{children:e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,name:"forward",disabled:o==="loading"})," ",e("span",{children:["Forward to ",e("i",{children:d})]})]})})}),e("footer",{children:[e("button",{type:"submit",disabled:o==="loading",children:"Send Report"})," ",e("button",{type:"submit",class:"plain2",disabled:o==="loading",onClick:async()=>{try{await s.v1.accounts.$select(t.id).mute(),se(`Muted ${h}`)}catch{se(`Unable to mute ${h}`)}},children:["Send Report ",e("small",{class:"ib",children:"+ Mute profile"})]})," ",e("button",{type:"submit",class:"plain2",disabled:o==="loading",onClick:async()=>{try{await s.v1.accounts.$select(t.id).block(),se(`Blocked ${h}`)}catch{se(`Unable to block ${h}`)}},children:["Send Report ",e("small",{class:"ib",children:"+ Block profile"})]}),e($e,{hidden:o!=="loading"})]})]})]})]})}const vo="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",ko="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",So="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",Io=200,Co=10;async function Kt(){const{masto:t}=Q(),n=t.v1.followedTags.list({limit:Io}),i=[];let s=0;do{const{value:o,done:a}=await n.next();if(a||(o==null?void 0:o.length)===0)break;i.push(...o),s++}while(s<Co);return i.sort((o,a)=>o.name.localeCompare(a.name)),i.length&&setTimeout(()=>{be.account.set("followedTags",{tags:i,updatedAt:Date.now()})},1),i}const To=24*60*60*1e3;async function xo(){try{const{tags:t,updatedAt:n}=be.account.get("followedTags")||{};return t!=null&&t.length?(Date.now()-n>To&&Kt(),t):await Kt()}catch{return[]}}const Hn=document.createElement("div"),$o=t=>{if(!t)return[];if(t.indexOf("#")===-1)return[];Hn.innerHTML=t;const n=Hn.querySelectorAll("a.hashtag");return n.length?Array.from(n).map(i=>i.innerText.trim().replace(/^[^#]*#+/,"")):[]};function qt({children:t}){if(typeof t=="string")return t;const[n,i]=$("");return G(()=>{Promise.resolve(t).then(i)},[t]),n}const at=9,Ao=["following","mentions","notifications","list","public","trending","search","hashtag","bookmarks","favourites"],Es={following:"Home / Following",notifications:"Notifications",list:"Lists",public:"Public (Local / Federated)",search:"Search","account-statuses":"Account",bookmarks:"Bookmarks",favourites:"Likes",hashtag:"Hashtag",trending:"Trending",mentions:"Mentions"},Ht={list:[{text:"List ID",name:"id",notRequired:!0}],public:[{text:"Local only",name:"local",type:"checkbox"},{text:"Instance",name:"instance",type:"text",placeholder:"Optional, e.g. mastodon.social",notRequired:!0}],trending:[{text:"Instance",name:"instance",type:"text",placeholder:"Optional, e.g. mastodon.social",notRequired:!0}],search:[{text:"Search term",name:"query",type:"text",placeholder:"Optional, unless for multi-column mode",notRequired:!0}],"account-statuses":[{text:"@",name:"id",type:"text",placeholder:"cheeaun@mastodon.social"}],hashtag:[{text:"#",name:"hashtag",type:"text",placeholder:"e.g. PixelArt (Max 5, space-separated)",pattern:"[^#]+"},{text:"Media only",name:"media",type:"checkbox"},{text:"Instance",name:"instance",type:"text",placeholder:"Optional, e.g. mastodon.social",notRequired:!0}]},Ro=ht(async({id:t})=>{const n=await Q().masto.v1.accounts.$select(t).fetch();return n.username||n.acct||n.displayName}),Zt={following:{id:"home",title:(t,n)=>n===0?"Home":"Following",path:"/",icon:"home"},mentions:{id:"mentions",title:"Mentions",path:"/mentions",icon:"at"},notifications:{id:"notifications",title:"Notifications",path:"/notifications",icon:"notification"},list:{id:({id:t})=>t?"list":"lists",title:({id:t})=>t?Gi(t):"Lists",path:({id:t})=>t?`/l/${t}`:"/l",icon:"list",excludeViewMode:({id:t})=>t?[]:["multi-column"]},public:{id:"public",title:({local:t})=>t?"Local":"Federated",subtitle:({instance:t})=>t||Q().instance,path:({local:t,instance:n})=>`/${n}/p${t?"/l":""}`,icon:({local:t})=>t?"building":"earth"},trending:{id:"trending",title:"Trending",subtitle:({instance:t})=>t||Q().instance,path:({instance:t})=>`/${t}/trending`,icon:"chart"},search:{id:"search",title:({query:t})=>t?`${t}`:"Search",path:({query:t})=>t?`/search?q=${encodeURIComponent(t)}&type=statuses`:"/search",icon:"search",excludeViewMode:({query:t})=>t?[]:["multi-column"]},"account-statuses":{id:"account-statuses",title:Ro,path:({id:t})=>`/a/${t}`,icon:"user"},bookmarks:{id:"bookmarks",title:"Bookmarks",path:"/b",icon:"bookmark"},favourites:{id:"favourites",title:"Likes",path:"/f",icon:"heart"},hashtag:{id:"hashtag",title:({hashtag:t})=>t,subtitle:({instance:t})=>t||Q().instance,path:({hashtag:t,instance:n,media:i})=>`${n?`/${n}`:""}/t/${t.split(/\s+/).join("+")}${i?"?media=1":""}`,icon:"hashtag"}};function _o({onClose:t}){const n=Me(T),{shortcuts:i}=n,[s,o]=$(!1),[a,h]=$(!1),[d]=pn();return e("div",{id:"shortcuts-settings-container",class:"sheet",tabindex:"-1",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:[e(w,{icon:"shortcut"})," Shortcuts"," ",e("sup",{style:{fontSize:12,opacity:.5,textTransform:"uppercase"},children:"beta"})]})}),e("main",{children:[e("p",{children:"Specify a list of shortcuts that'll appear as:"}),e("div",{class:"shortcuts-view-mode",children:[{value:"float-button",label:"Floating button",imgURL:vo},{value:"tab-menu-bar",label:"Tab/Menu bar",imgURL:So},{value:"multi-column",label:"Multi-column",imgURL:ko}].map(({value:r,label:u,imgURL:f})=>{const c=n.settings.shortcutsViewMode===r||r==="float-button"&&!n.settings.shortcutsViewMode;return e("label",{class:c?"checked":"",children:[e("input",{type:"radio",name:"shortcuts-view-mode",value:r,checked:c,onChange:p=>{T.settings.shortcutsViewMode=p.target.value}})," ",e("img",{src:f,alt:"",width:"80",height:"58"})," ",e("span",{children:u})]},r)})}),i.length>0?e(_,{children:[e("ol",{class:"shortcuts-list",ref:d,children:i.filter(Boolean).map((r,u)=>{const f=Object.values(r).join("-"),{type:c}=r;if(!Zt[c])return null;let{icon:p,title:l,subtitle:b,excludeViewMode:m}=Zt[c];typeof l=="function"&&(l=l(r,u)),typeof b=="function"&&(b=b(r,u)),typeof p=="function"&&(p=p(r,u)),typeof m=="function"&&(m=m(r,u));const k=m==null?void 0:m.includes(n.settings.shortcutsViewMode);return e("li",{children:[e(w,{icon:p}),e("span",{class:"shortcut-text",children:[e(qt,{children:l}),b&&e(_,{children:[" ",e("small",{class:"ib insignificant",children:b})]}),k&&e("span",{class:"tag",children:"Not available in current view mode"})]}),e("span",{class:"shortcut-actions",children:[e("button",{type:"button",class:"plain small",disabled:u===0,onClick:()=>{const g=Array.from(T.shortcuts);if(u>0){const y=T.shortcuts[u-1];g[u-1]=r,g[u]=y,T.shortcuts=g}},children:e(w,{icon:"arrow-up",alt:"Move up"})}),e("button",{type:"button",class:"plain small",disabled:u===i.length-1,onClick:()=>{const g=Array.from(T.shortcuts);if(u<T.shortcuts.length-1){const y=T.shortcuts[u+1];g[u+1]=r,g[u]=y,T.shortcuts=g}},children:e(w,{icon:"arrow-down",alt:"Move down"})}),e("button",{type:"button",class:"plain small",onClick:()=>{o({shortcut:r,shortcutIndex:u})},children:e(w,{icon:"pencil",alt:"Edit"})})]})]},f)})}),i.length===1&&n.settings.shortcutsViewMode!=="float-button"&&e("div",{class:"ui-state insignificant",children:[e(w,{icon:"info"})," ",e("small",{children:"Add more than one shortcut/column to make this work."})]})]}):e("div",{class:"ui-state insignificant",children:[e("p",{children:n.settings.shortcutsViewMode==="multi-column"?"No columns yet. Tap on the Add column button.":"No shortcuts yet. Tap on the Add shortcut button."}),e("p",{children:["Not sure what to add?",e("br",{}),"Try adding"," ",e("a",{href:"#",onClick:r=>{r.preventDefault(),T.shortcuts=[{type:"following"},{type:"notifications"}]},children:"Home / Following and Notifications"})," ","first."]})]}),e("p",{class:"insignificant",children:i.length>=at&&(n.settings.shortcutsViewMode==="multi-column"?`Max ${at} columns`:`Max ${at} shortcuts`)}),e("p",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e("button",{type:"button",class:"light",onClick:()=>h(!0),children:"Import/export"}),e("button",{type:"button",disabled:i.length>=at,onClick:()=>o(!0),children:[e(w,{icon:"plus"})," ",e("span",{children:n.settings.shortcutsViewMode==="multi-column"?"Add column…":"Add shortcut…"})]})]})]}),s&&e(Ae,{onClick:r=>{r.target===r.currentTarget&&o(!1)},children:e(Lo,{shortcut:s.shortcut,shortcutIndex:s.shortcutIndex,onSubmit:({result:r,mode:u})=>{u==="edit"?T.shortcuts[s.shortcutIndex]=r:T.shortcuts.push(r)},onClose:()=>o(!1)})}),a&&e(Ae,{onClick:r=>{r.target===r.currentTarget&&h(!1)},children:e(Eo,{shortcuts:i,onClose:()=>h(!1)})})]})}const Vn={list:"Specific list is optional. For multi-column mode, list is required, else the column will not be shown.",search:"For multi-column mode, search term is required, else the column will not be shown.",hashtag:"Multiple hashtags are supported. Space-separated."};function Lo({onSubmit:t,disabled:n,shortcut:i,shortcutIndex:s,onClose:o}){var k,g;const a=!!i,[h,d]=$((i==null?void 0:i.type)||null),{masto:r}=Q(),[u,f]=$("default"),[c,p]=$([]),[l,b]=$([]);G(()=>{(async()=>{if(h==="list")try{f("loading");const y=await Pt();p(y),f("default")}catch{f("error")}})(),(async()=>{if(h==="hashtag")try{const y=await Kt();b(y)}catch{}})()},[h]);const m=z();return G(()=>{if(a&&h&&Ht[h]){const y=m.current;Ht[h].forEach(({name:C,type:v})=>{const I=y.querySelector(`[name="${C}"]`);I&&i[C]&&(v==="checkbox"?I.checked=i[C]==="on":I.value=i[C])})}},[a,h]),e("div",{id:"shortcut-settings-form",class:"sheet",children:[!!o&&e("button",{type:"button",class:"sheet-close",onClick:o,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:[a?"Edit":"Add"," shortcut"]})}),e("main",{tabindex:"-1",children:e("form",{ref:m,onSubmit:y=>{y.preventDefault();const C=new FormData(y.target),v={};C.forEach((I,x)=>{v[x]=I==null?void 0:I.trim(),x==="instance"&&(v[x]=v[x].replace(/^https?:\/\//,"").replace(/\/+$/,""),v[x]=v[x].replace(/^@?[^@]+@/,""))}),v.type&&(t({result:v,mode:a?"edit":"add"}),y.target.reset(),d(null),o==null||o())},children:[e("p",{children:e("label",{children:[e("span",{children:"Timeline"}),e("select",{required:!0,disabled:n,onChange:y=>{d(y.target.value)},defaultValue:a?i.type:void 0,name:"type",children:[e("option",{}),Ao.map(y=>e("option",{value:y,children:Es[y]}))]})]})}),(g=(k=Ht[h])==null?void 0:k.map)==null?void 0:g.call(k,({text:y,name:C,type:v,placeholder:I,pattern:x,notRequired:L})=>h==="list"?e("p",{children:e("label",{children:[e("span",{children:"List"}),e("select",{name:"id",required:!L,disabled:n||u==="loading",defaultValue:a?i.id:void 0,children:[e("option",{value:""}),c.map(Y=>e("option",{value:Y.id,children:Y.title}))]})]})}):e("p",{children:e("label",{children:[e("span",{children:y})," ",e("input",{type:v,switch:v==="checkbox"||void 0,name:C,placeholder:I,required:v==="text"&&!L,disabled:n,list:h==="hashtag"?"followed-hashtags-datalist":null,autocorrect:"off",autocapitalize:"off",spellCheck:!1,pattern:x}),h==="hashtag"&&l.length>0&&e("datalist",{id:"followed-hashtags-datalist",children:l.map(Y=>e("option",{value:Y.name}))})]})})),!!Vn[h]&&e("p",{class:"form-note insignificant",children:[e(w,{icon:"info"}),Vn[h]]}),e("footer",{children:[e("button",{type:"submit",class:"block",disabled:n||u==="loading",children:a?"Save":"Add"}),a&&e("button",{type:"button",class:"light danger",onClick:()=>{T.shortcuts.splice(s,1),o==null||o()},children:"Remove"})]})]})})]})}function Eo({shortcuts:t,onClose:n}){var c;const{masto:i}=Q(),s=pe(()=>!t||!t.filter(Boolean).length?"":_n.compressToEncodedURIComponent(JSON.stringify(t.filter(Boolean))),[t]),[o,a]=$(""),[h,d]=$("default"),r=pe(()=>{if(!o)return d("default"),null;try{const p=JSON.parse(_n.decompressFromEncodedURIComponent(o));if(!Array.isArray(p))throw new Error("Not an array");return d("default"),p}catch{try{const l=JSON.parse(o);if(!Array.isArray(l))throw new Error("Not an array");return d("default"),l}catch{return d("error"),null}}},[o]),u=T.shortcuts.length>0,f=z();return e("div",{id:"import-export-container",class:"sheet",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:["Import/Export ",e("small",{class:"ib insignificant",children:"Shortcuts"})]})}),e("main",{tabindex:"-1",children:[e("section",{children:[e("h3",{children:[e(w,{icon:"arrow-down-circle",size:"l",class:"insignificant"})," ",e("span",{children:"Import"})]}),e("p",{class:"field-button",children:[e("input",{ref:f,type:"text",name:"import",placeholder:"Paste shortcuts here",class:"block",onInput:p=>{a(p.target.value)}}),T.settings.shortcutSettingsCloudImportExport&&e("button",{type:"button",class:"plain2 small",disabled:h==="cloud-downloading",onClick:async()=>{d("cloud-downloading");const p=ct();se("Downloading saved shortcuts from instance server…");try{const b=(await i.v1.accounts.relationships.fetch({id:[p]}))[0];if(b){const{note:m=""}=b;if(/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/.test(m)){const k=m.match(/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/)[1],{v:g,dt:y,data:C}=JSON.parse(k);f.current.value=C,f.current.dispatchEvent(new Event("input"))}}d("default")}catch{d("error"),se("Unable to download shortcuts")}},title:"Download shortcuts from instance server",children:[e(w,{icon:"cloud"}),e(w,{icon:"arrow-down"})]})]}),!!r&&Array.isArray(r)&&e(_,{children:[e("p",{children:[e("b",{children:r.length})," shortcut",r.length>1?"s":""," ",e("small",{class:"insignificant",children:["(",o.length," characters)"]})]}),e("ol",{class:"import-settings-list",children:r.map(p=>{var l,b;return e("li",{children:[e("span",{style:{opacity:t.some(m=>Object.keys(m).every(k=>m[k]===p[k]))?1:0},children:"*"}),e("span",{children:[Es[p.type],p.type==="list"&&" ⚠️"," ",(b=(l=Ht[p.type])==null?void 0:l.map)==null?void 0:b.call(l,({text:m,name:k,type:g})=>p[k]?e(_,{children:[e("span",{class:"tag collapsed insignificant",children:[m,":"," ",g==="checkbox"?p[k]==="on"?"✅":"❌":p[k]]})," "]}):null)]})]})})}),e("p",{children:[e("small",{children:"* Exists in current shortcuts"}),e("br",{}),e("small",{children:"⚠️ List may not work if it's from a different account."})]})]}),h==="error"&&e("p",{class:"error",children:e("small",{children:"⚠️ Invalid settings format"})}),e("p",{children:[u&&e(_,{children:[e(et,{confirmLabel:"Append to current shortcuts?",menuFooter:e("div",{class:"footer",children:"Only shortcuts that dont exist in current shortcuts will be appended."}),onClick:()=>{const p=r.filter(m=>!T.shortcuts.some(k=>Object.keys(k).every(g=>k[g]===m[g])));if(!p.length){se("No new shortcuts to import");return}let l=[...T.shortcuts,...p];const b=l.length>at;b&&(l=l.slice(0,at)),T.shortcuts=l,se(b?`Shortcuts imported. Exceeded max ${at}, so the rest are not imported.`:"Shortcuts imported"),n==null||n()},children:e("button",{type:"button",class:"plain2",disabled:!r,children:"Import & append…"})})," "]}),e(et,{confirmLabel:u?"Override current shortcuts?":"Import shortcuts?",menuItemClassName:u?"danger":void 0,onClick:()=>{T.shortcuts=r,se("Shortcuts imported"),n==null||n()},children:e("button",{type:"button",class:"plain2",disabled:!r,children:u?"or override…":"Import…"})})]})]}),e("section",{children:[e("h3",{children:[e(w,{icon:"arrow-up-circle",size:"l",class:"insignificant"})," ",e("span",{children:"Export"})]}),e("p",{children:e("input",{style:{width:"100%"},type:"text",value:s,readOnly:!0,onClick:p=>{if(p.target.value){p.target.select();try{navigator.clipboard.writeText(p.target.value),se("Shortcuts copied")}catch{se("Unable to copy shortcuts")}}}})}),e("p",{children:[e("button",{type:"button",class:"plain2",disabled:!s,onClick:()=>{try{navigator.clipboard.writeText(s),se("Shortcut settings copied")}catch{se("Unable to copy shortcut settings")}},children:[e(w,{icon:"clipboard"})," ",e("span",{children:"Copy"})]})," ",(navigator==null?void 0:navigator.share)&&((c=navigator==null?void 0:navigator.canShare)==null?void 0:c.call(navigator,{text:s}))&&e("button",{type:"button",class:"plain2",disabled:!s,onClick:()=>{try{navigator.share({text:s})}catch{alert("Sharing doesn't seem to work.")}},children:[e(w,{icon:"share"})," ",e("span",{children:"Share"})]})," ",T.settings.shortcutSettingsCloudImportExport&&e("button",{type:"button",class:"plain2",disabled:h==="cloud-uploading",onClick:async()=>{d("cloud-uploading");const p=ct();try{const b=(await i.v1.accounts.relationships.fetch({id:[p]}))[0];if(b){const{note:m=""}=b;let k="";if(/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/.test(m)){const g=JSON.stringify({v:"1",dt:Date.now(),data:s});k=m.replace(/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/,`<phanpy-shortcuts-settings>${g}</phanpy-shortcuts-settings>`)}else k=`${m}
<phanpy-shortcuts-settings>${settingsJSON}</phanpy-shortcuts-settings>`;se("Saving shortcuts to instance server…"),await i.v1.accounts.$select(p).note.create({comment:k}),d("default"),se("Shortcuts saved")}}catch{d("error"),se("Unable to save shortcuts")}},title:"Sync to instance server",children:[e(w,{icon:"cloud"}),e(w,{icon:"arrow-up"})]})," ",s.length>0&&e("small",{class:"insignificant ib",children:[s.length," characters"]})]}),!!s&&e("details",{children:[e("summary",{class:"insignificant",children:e("small",{children:"Raw Shortcuts JSON"})}),e("textarea",{style:{width:"100%"},rows:10,readOnly:!0,children:JSON.stringify(t.filter(Boolean),null,2)})]})]}),T.settings.shortcutSettingsCloudImportExport&&e("footer",{children:e("p",{children:[e(w,{icon:"cloud"})," Import/export settings from/to instance server (Very experimental)"]})})]})]})}ps(T,t=>{for(const[n,i,s,o]of t)/^show/i.test(i)&&!s&&an()});function Mo(){var s,o,a,h,d,r,u,f;const t=Me(T),n=fs(),i=Tt();return G(()=>{setTimeout(Zs,1e3)},[]),e(_,{children:[!!t.showCompose&&e(Ae,{class:`solid ${t.composerState.minimized?"min":""}`,minimized:!!t.composerState.minimized,children:e(Js,{replyToStatus:typeof t.showCompose!="boolean"?t.showCompose.replyToStatus:((s=window.__COMPOSE__)==null?void 0:s.replyToStatus)||null,editStatus:((o=T.showCompose)==null?void 0:o.editStatus)||((a=window.__COMPOSE__)==null?void 0:a.editStatus)||null,draftStatus:((h=T.showCompose)==null?void 0:h.draftStatus)||((d=window.__COMPOSE__)==null?void 0:d.draftStatus)||null,onClose:c=>{const{newStatus:p,instance:l,type:b}=c||{};T.showCompose=!1,window.__COMPOSE__=null,p&&(T.reloadStatusPage++,se({text:{post:"Post published. Check it out.",reply:"Reply posted. Check it out.",edit:"Post updated. Check it out."}[b||"post"],delay:1e3,duration:1e4,onClick:m=>{m.hideToast(),T.prevLocation=i,n(l?`/${l}/s/${p.id}`:`/s/${p.id}`)}}))}})}),!!t.showSettings&&e(Ae,{onClose:()=>{T.showSettings=!1},children:e(Bi,{onClose:()=>{T.showSettings=!1}})}),!!t.showAccounts&&e(Ae,{onClose:()=>{T.showAccounts=!1},children:e(Li,{onClose:()=>{T.showAccounts=!1}})}),!!t.showAccount&&e(Ae,{onClose:()=>{T.showAccount=!1},children:e(uo,{account:((r=t.showAccount)==null?void 0:r.account)||t.showAccount,instance:(u=t.showAccount)==null?void 0:u.instance,onClose:({destination:c}={})=>{T.showAccount=!1}})}),!!t.showDrafts&&e(Ae,{onClose:()=>{T.showDrafts=!1},children:e(ho,{onClose:()=>T.showDrafts=!1})}),!!t.showMediaModal&&e(Ae,{onClick:c=>{(c.target===c.currentTarget||c.target.classList.contains("media"))&&(T.showMediaModal=!1)},children:e(Ls,{mediaAttachments:t.showMediaModal.mediaAttachments,instance:t.showMediaModal.instance,index:t.showMediaModal.index,statusID:t.showMediaModal.statusID,onClose:()=>{T.showMediaModal=!1}})}),!!t.showShortcutsSettings&&e(Ae,{onClose:()=>{T.showShortcutsSettings=!1},children:e(_o,{onClose:()=>T.showShortcutsSettings=!1})}),!!t.showGenericAccounts&&e(Ae,{onClose:()=>{T.showGenericAccounts=!1},children:e(mo,{instance:t.showGenericAccounts.instance,excludeRelationshipAttrs:t.showGenericAccounts.excludeRelationshipAttrs,postID:t.showGenericAccounts.postID,onClose:()=>T.showGenericAccounts=!1,blankCopy:t.showGenericAccounts.blankCopy})}),!!t.showMediaAlt&&e(Ae,{onClose:c=>{T.showMediaAlt=!1},children:e(go,{alt:t.showMediaAlt.alt||t.showMediaAlt,lang:(f=t.showMediaAlt)==null?void 0:f.lang,onClose:()=>{T.showMediaAlt=!1}})}),!!t.showEmbedModal&&e(Ae,{class:"solid",onClose:()=>{T.showEmbedModal=!1},children:e(fo,{html:t.showEmbedModal.html,url:t.showEmbedModal.url,width:t.showEmbedModal.width,height:t.showEmbedModal.height,onClose:()=>{T.showEmbedModal=!1}})}),!!t.showReportModal&&e(Ae,{onClose:()=>{T.showReportModal=!1},children:e(wo,{account:t.showReportModal.account,post:t.showReportModal.post,onClose:()=>{T.showReportModal=!1}})})]})}function rn({accountID:t,onChange:n}){const{masto:i}=Q(),[s,o]=$("default"),[a,h]=$(null),[d,r]=$(null),u=d!==null;return e("p",{class:"follow-request-buttons",children:[e("button",{type:"button",disabled:s==="loading"||u,onClick:()=>{o("loading"),h("accept"),(async()=>{try{const f=await i.v1.followRequests.$select(t).authorize();if(!(f!=null&&f.followedBy))throw new Error("Follow request not accepted");r(f),n()}catch{}o("default")})()},children:"Accept"})," ",e("button",{type:"button",disabled:s==="loading"||u,class:"light danger",onClick:()=>{o("loading"),h("reject"),(async()=>{try{const f=await i.v1.followRequests.$select(t).reject();if(f!=null&&f.followedBy)throw new Error("Follow request not rejected");r(f),n()}catch{o("default")}})()},children:"Reject"}),e("span",{class:"follow-request-states",children:u&&a?a==="accept"?e(w,{icon:"check-circle",alt:"Accepted",class:"follow-accepted"}):e(w,{icon:"x-circle",alt:"Rejected",class:"follow-rejected"}):e($e,{hidden:s!=="loading"})})]})}const Gn={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"};function Yn(t,n){let i,s;return typeof n=="string"?i=n:(i=n==null?void 0:n.url,s=n==null?void 0:n.staticUrl),i?e(_,{children:["reacted to your post with"," ",e(Si,{url:i,staticUrl:s,alt:t})]}):`reacted to your post with ${t}.`}const vt={mention:"mentioned you in their post.",status:"published a post.",reblog:"boosted your post.","reblog+account":t=>`boosted ${t} of your posts.`,reblog_reply:"boosted your reply.",follow:"followed you.",follow_request:"requested to follow you.",favourite:"liked your post.","favourite+account":t=>`liked ${t} of your posts.`,favourite_reply:"liked your reply.",poll:"A poll you have voted in or created has ended.","poll-self":"A poll you have created has ended.","poll-voted":"A poll you have voted in has ended.",update:"A post you interacted with has been edited.","favourite+reblog":"boosted & liked your post.","favourite+reblog+account":t=>`boosted & liked ${t} of your posts.`,"favourite+reblog_reply":"boosted & liked your reply.","admin.sign_up":"signed up.","admin.report":t=>e(_,{children:["reported ",t]}),severed_relationships:t=>e(_,{children:["Lost connections with ",e("i",{children:t}),"."]}),moderation_warning:e("b",{children:"Moderation warning"}),emoji_reaction:Yn,"pleroma:emoji_reaction":Yn},Po={account_suspension:({from:t,targetName:n})=>e(_,{children:["An admin from ",e("i",{children:t})," has suspended ",e("i",{children:n}),", which means you can no longer receive updates from them or interact with them."]}),domain_block:({from:t,targetName:n,followersCount:i,followingCount:s})=>e(_,{children:["An admin from ",e("i",{children:t})," has blocked ",e("i",{children:n}),". Affected followers: ",i,", followings: ",s,"."]}),user_domain_block:({targetName:t,followersCount:n,followingCount:i})=>e(_,{children:["You have blocked ",e("i",{children:t}),". Removed followers: ",n,", followings: ",i,"."]})},Do={none:"Your account has received a moderation warning.",disable:"Your account has been disabled.",mark_statuses_as_sensitive:"Some of your posts have been marked as sensitive.",delete_statuses:"Some of your posts have been deleted.",sensitive:"Your posts will be marked as sensitive from now on.",silence:"Your account has been limited.",suspend:"Your account has been suspended."},nn=30;function No({notification:t,instance:n,isStatic:i,disableContextMenu:s}){var j,M,ee,X,A,P;const{id:o,status:a,account:h,report:d,event:r,moderation_warning:u,_accounts:f,_statuses:c}=t;let{type:p}=t;const l=(a==null?void 0:a.reblog)||a,b=l==null?void 0:l.id,m=ct(),k=m===(h==null?void 0:h.id),g=(j=a==null?void 0:a.poll)==null?void 0:j.voted,y=!!(a!=null&&a.inReplyToAccountId)&&(a==null?void 0:a.inReplyToAccountId)!==m&&((M=a==null?void 0:a.account)==null?void 0:M.id)===m;let C=0,v=0;if(p==="favourite+reblog"){for(const E of f)(ee=E._types)!=null&&ee.includes("favourite")&&C++,(X=E._types)!=null&&X.includes("reblog")&&v++;!v&&C&&(p="favourite"),!C&&v&&(p="reblog")}let I;if(p==="poll"?I=vt[k?"poll-self":g?"poll-voted":"poll"]:p==="reblog"||p==="favourite"||p==="favourite+reblog"?(c==null?void 0:c.length)>1?I=vt[`${p}+account`]:y?I=vt[`${p}_reply`]:I=vt[p]:vt[p]?I=vt[p]:I=`[Unknown notification type: ${p}]`,typeof I=="function"){const E=(c==null?void 0:c.length)||(f==null?void 0:f.length);if(p==="admin.report"){const U=d==null?void 0:d.targetAccount;U&&(I=I(e(It,{account:U,showAvatar:!0})))}else if(p==="severed_relationships"){const U=r==null?void 0:r.targetName;U&&(I=I(U))}else if((p==="emoji_reaction"||p==="pleroma:emoji_reaction")&&t.emoji){const U=t.emoji_url||((P=(A=a==null?void 0:a.emojis)==null?void 0:A.find)==null?void 0:P.call(A,V=>(V==null?void 0:V.shortcode)===t.emoji.replace(/^:/,"").replace(/:$/,"")));I=I(t.emoji,U)}else E&&(I=I(E))}if(p==="mention"&&!a)return null;const x=t.createdAt&&new Date(t.createdAt).toLocaleString(),L={"favourite+reblog":"Boosted/Liked by…",favourite:"Liked by…",reblog:"Boosted by…",follow:"Followed by…"}[p]||"Accounts",Y=()=>{T.showGenericAccounts={heading:L,accounts:f,showReactions:p==="favourite+reblog",excludeRelationshipAttrs:p==="follow"?["followedBy"]:[],postID:Ke(b,n)}};return e("div",{class:`notification notification-${p}`,"data-notification-id":o,tabIndex:"0",children:[e("div",{class:`notification-type notification-${p}`,title:x,children:p==="favourite+reblog"?e(_,{children:[e(w,{icon:"rocket",size:"xl",alt:p,class:"reblog-icon"}),e(w,{icon:"heart",size:"xl",alt:p,class:"favourite-icon"})]}):e(w,{icon:Gn[p]||"notification",size:"xl",alt:p})}),e("div",{class:"notification-content",children:[p!=="mention"&&e(_,{children:[e("p",{children:[!/poll|update/i.test(p)&&e(_,{children:(f==null?void 0:f.length)>1?e(_,{children:[e("b",{tabIndex:"0",onClick:Y,children:[e("span",{title:f.length,children:Ge(f.length)})," ","people"]})," "]}):h&&e(_,{children:[e(It,{account:h,showAvatar:!0})," "]})}),I,p==="mention"&&e("span",{class:"insignificant",children:[" ","•"," ",e(bt,{datetime:t.createdAt,format:"micro"})]})]}),p==="follow_request"&&e(rn,{accountID:h.id}),p==="severed_relationships"&&e("div",{children:[Po[r.type]({from:n,...r}),e("br",{}),e("a",{href:`https://${n}/severed_relationships`,target:"_blank",rel:"noopener noreferrer",children:["Learn more ",e(w,{icon:"external",size:"s"})]}),"."]}),p==="moderation_warning"&&!!u&&e("div",{children:[Do[u.action],e("br",{}),e("a",{href:`/disputes/strikes/${u.id}`,target:"_blank",rel:"noopener noreferrer",children:["Learn more ",e(w,{icon:"external",size:"s"})]}),"."]})]}),(f==null?void 0:f.length)>1&&e("p",{class:"avatars-stack",children:[f.slice(0,nn).map(E=>e(_,{children:[e("a",{href:E.url,rel:"noopener noreferrer",class:"account-avatar-stack",onClick:U=>{U.preventDefault(),T.showAccount=E},children:[e(st,{url:E.avatarStatic,size:f.length<=10?"xxl":f.length<20?"xl":"l",alt:`${E.displayName} @${E.acct}`,squircle:E==null?void 0:E.bot},E.id),p==="favourite+reblog"&&e("div",{class:"account-sub-icons",children:E._types.map(U=>e(w,{icon:Gn[U],size:"s",class:`${U}-icon`}))})]},E.id)," "]},E.id)),e("button",{type:"button",class:"small plain",onClick:Y,children:[f.length>nn&&`+${f.length-nn}`,e(w,{icon:"chevron-down"})]})]}),(c==null?void 0:c.length)>1&&e("ul",{class:"notification-group-statuses",children:c.map(E=>e("li",{children:e(jn,{class:`status-link status-type-${p}`,to:n?`/${n}/s/${E.id}`:`/s/${E.id}`,children:e(Be,{status:E,size:"s",previewMode:!0,allowContextMenu:!0})})},E.id))}),a&&(!(c!=null&&c.length)||(c==null?void 0:c.length)<=1)&&e(jn,{class:`status-link status-type-${p}`,to:n?`/${n}/s/${b}`:`/s/${b}`,onContextMenu:s?void 0:E=>{const U=E.target.querySelector(".status");if(U){if(E.metaKey)return;E.preventDefault(),U.dispatchEvent(new MouseEvent("contextmenu",{clientX:E.clientX,clientY:E.clientY}))}},children:i?e(Be,{status:l,size:"s",readOnly:!0,allowContextMenu:!0}):e(Be,{statusID:b,size:"s",readOnly:!0,allowContextMenu:!0})})]})]})}function jn(t){const n=Ii();return e(oe,{...t,"data-read-more":"Read more →",ref:n})}const Xt=Je(No,(t,n)=>{var i,s;return((i=t.notification)==null?void 0:i.id)===((s=n.notification)==null?void 0:s.id)});"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const{type:n,id:i,accessToken:s}=(t==null?void 0:t.data)||{};n==="notification"&&(T.routeNotification={id:i,accessToken:s})});const Uo=Je(function(){if(!("serviceWorker"in navigator))return null;const n=Me(T),{routeNotification:i}=n,{id:s,accessToken:o}=i||{},[a,h]=$(!1);lt(()=>{if(!s||!o)return;const{instance:r}=Q(),{masto:u,instance:f}=Q({accessToken:o}),c=r===f,p=o?Xs(o):St();(async()=>{const l=await u.v1.notifications.$select(s).fetch();if(l&&p){const b=p.instanceURL,{type:m,status:k,account:g}=l,y=!!document.querySelector("#modal-container > *"),C=m==="follow"&&!!(g!=null&&g.id),v=!!(g!=null&&g.id),I=!!(k!=null&&k.id);C&&c?T.showAccount={account:g,instance:b}:y||!c||v&&I?h({id:s,account:p,notification:l,sameInstance:c}):I?location.hash=`/${r}/s/${k.id}`:C?location.hash=`/${r}/a/${g.id}`:location.hash="/notifications"}})()},[s,o]),lt(()=>{navigator!=null&&navigator.clearAppBadge&&navigator.clearAppBadge()},[]),Ct(r=>{r&&(navigator!=null&&navigator.clearAppBadge)&&navigator.clearAppBadge()});const d=()=>{h(!1),T.routeNotification=null,/\/notifications\?id=/i.test(location.hash)&&(location.hash="/notifications")};if(a){const{id:r,account:u,notification:f,sameInstance:c}=a;return e(Ae,{onClick:p=>{p.target===p.currentTarget&&d()},children:e("div",{class:"sheet",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:d,children:e(w,{icon:"x"})}),e("header",{children:e("b",{children:"Notification"})}),e("main",{children:[!c&&e("p",{children:"This notification is from your other account."}),e("div",{class:"notification-peek",onClick:p=>{const{target:l}=p;(p.target.tagName==="BUTTON"||p.target.tagName==="A")&&d()},children:e(Xt,{instance:u.instanceURL,notification:f,isStatic:!0})}),e("div",{style:{textAlign:"end"},children:e(oe,{to:"/notifications",class:"button light",onClick:d,children:[e("span",{children:"View all notifications"})," ",e(w,{icon:"arrow-right"})]})})]})]})})}return null}),Ms=si((t,n)=>{const{instance:i}=Q(),[s,o]=it(),[a,h]=$(!1),[d,r]=$(s.get("q")||""),u=s.get("type"),f=z(null),c=z(null);return ni(n,()=>({setValue:p=>{r(p)},focus:()=>{c.current.focus()},select:()=>{c.current.select()},blur:()=>{c.current.blur()}})),e("form",{ref:f,class:"search-popover-container",onSubmit:p=>{var b;if(p.preventDefault(),/\/search/.test(location.hash))if(d){const m={q:d};u&&(m.type=u),o(m)}else o({});else d?location.hash=`/search?q=${encodeURIComponent(d)}${u?`&type=${u}`:""}`:location.hash="/search";(b=t==null?void 0:t.onSubmit)==null||b.call(t,p)},children:[e("input",{ref:c,value:d,name:"q",type:"search",placeholder:"Search",dir:"auto",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",onSearch:p=>{p.target.value||o({})},onInput:p=>{r(p.target.value),h(!0)},onFocus:()=>{var p,l;h(!0),(l=(p=f.current)==null?void 0:p.querySelector(".search-popover-item"))==null||l.classList.add("focus")},onBlur:()=>{var p,l;setTimeout(()=>{h(!1)},100),(l=(p=f.current)==null?void 0:p.querySelector(".search-popover-item.focus"))==null||l.classList.remove("focus")},onKeyDown:p=>{var b;const{key:l}=p;switch(l){case"Escape":h(!1);break;case"Down":case"ArrowDown":if(p.preventDefault(),a){const m=f.current.querySelector(".search-popover-item.focus");if(m){let k=m.nextElementSibling;for(;k&&k.hidden;)k=k.nextElementSibling;k&&(k.classList.add("focus"),Array.from(k.parentElement.children).filter(y=>y!==k).forEach(y=>{y.classList.remove("focus")}))}else{const k=f.current.querySelector(".search-popover-item");k&&k.classList.add("focus")}}break;case"Up":case"ArrowUp":if(p.preventDefault(),a){const m=document.querySelector(".search-popover-item.focus");if(m){let k=m.previousElementSibling;for(;k&&k.hidden;)k=k.previousElementSibling;k&&(k.classList.add("focus"),Array.from(k.parentElement.children).filter(y=>y!==k).forEach(y=>{y.classList.remove("focus")}))}else{const k=document.querySelector(".search-popover-item:last-child");k&&k.classList.add("focus")}}break;case"Enter":if(a){const m=document.querySelector(".search-popover-item.focus");m&&(p.preventDefault(),m.click()),h(!1),(b=t==null?void 0:t.onSubmit)==null||b.call(t,p)}break}}}),e("div",{class:"search-popover",hidden:!a||!d,children:!!d&&[{label:e(_,{children:[d," ",e("small",{class:"insignificant",children:" accounts, hashtags & posts"})]}),to:`/search?q=${encodeURIComponent(d)}`,top:!u&&!/\s/.test(d),hidden:!!u},{label:e(_,{children:["Posts with ",e("q",{children:d})]}),to:`/search?q=${encodeURIComponent(d)}&type=statuses`,hidden:/^https?:/.test(d),top:/\s/.test(d),icon:"document",queryType:"statuses"},{label:e(_,{children:["Posts tagged with ",e("mark",{children:["#",d.replace(/^#/,"")]})]}),to:`/${i}/t/${d.replace(/^#/,"")}`,hidden:/^@/.test(d)||/^https?:/.test(d)||/\s/.test(d),top:/^#/.test(d),type:"link",icon:"hashtag",queryType:"hashtags"},{label:e(_,{children:["Look up ",e("mark",{children:d})]}),to:`/${d}`,hidden:!/^https?:/.test(d),top:/^https?:/.test(d),type:"link"},{label:e(_,{children:["Accounts with ",e("q",{children:d})]}),to:`/search?q=${encodeURIComponent(d)}&type=accounts`,icon:"group",queryType:"accounts"}].sort((p,l)=>{if(u){if(p.queryType===u)return-1;if(l.queryType===u)return 1}return p.top&&!l.top?-1:!p.top&&l.top?1:0}).filter(({hidden:p})=>!p).map(({label:p,to:l,icon:b,type:m},k)=>e(oe,{to:l,class:`search-popover-item ${k===0?"focus":""}`,onClick:g=>{var y;(y=t==null?void 0:t.onSubmit)==null||y.call(t,g)},children:[e(w,{icon:b||(m==="link"?"arrow-right":"search"),class:"more-insignificant"}),e("span",{children:p})," "]}))})]})}),Fo=Je(function({onClose:n=()=>{}}){const[i,s]=$(!1),o=z(null);_e(["Slash","/"],h=>{s(!0),setTimeout(()=>{var d,r,u,f;(r=(d=o.current)==null?void 0:d.focus)==null||r.call(d),(f=(u=o.current)==null?void 0:u.select)==null||f.call(u)},0)},{preventDefault:!0,ignoreEventWhen:h=>{const d=/\/search/.test(location.hash),r=!!document.querySelector("#modal-container > *");return d||r}});const a=()=>{s(!1),n()};return _e("esc",h=>{var d,r;(r=(d=o.current)==null?void 0:d.blur)==null||r.call(d),a()},{enabled:i,enableOnFormTags:!0,preventDefault:!0}),e("div",{id:"search-command-container",hidden:!i,onClick:h=>{h.target===h.currentTarget&&a()},children:e(Ms,{ref:o,onSubmit:()=>{a()}})})});function Oo(){const{instance:t}=Q(),n=Me(T),{shortcuts:i,settings:s}=n;if(!i.length||s.shortcutsViewMode==="multi-column"||!s.shortcutsViewMode&&s.shortcutsColumnsMode)return null;const o=z(),a=z(!1),h=i.map((f,c)=>{const{type:p,...l}=f;if(!Zt[p])return null;let{id:b,path:m,title:k,subtitle:g,icon:y}=Zt[p];return typeof b=="function"&&(b=b(l,c)),typeof m=="function"&&(m=m({...l,instance:l.instance||t},c)),typeof k=="function"&&(k=k(l,c)),typeof g=="function"&&(g=g(l,c)),typeof y=="function"&&(y=y(l,c)),b==="lists"&&(a.current=!0),{id:b,path:m,title:k,subtitle:g,icon:y}}).filter(Boolean),d=fs();_e(["1","2","3","4","5","6","7","8","9"],(f,c)=>{var l,b;const p=parseInt(c.keys[0],10)-1;if(p<h.length){const{path:m}=h[p];m&&(d(m),(b=(l=o.current)==null?void 0:l.closeMenu)==null||b.call(l))}});const[r,u]=$([]);return e("div",{id:"shortcuts",children:n.settings.shortcutsViewMode==="tab-menu-bar"?e("nav",{class:"tab-bar",onContextMenu:f=>{f.preventDefault(),T.showShortcutsSettings=!0},children:e("ul",{children:h.map(({id:f,path:c,title:p,subtitle:l,icon:b},m)=>e("li",{children:e(oe,{class:l?"has-subtitle":"",to:c,onClick:k=>{if(k.target.classList.contains("is-active")){k.preventDefault();const g=document.getElementById(`${f}-page`);if(g){g.scrollTop=0;const y=g.querySelector(".updates-button");y&&y.click()}}},children:[e(w,{icon:b,size:"xl",alt:p}),e("span",{children:[e(qt,{children:p}),l&&e(_,{children:[e("br",{}),e("small",{children:l})]})]})]})},`${m}-${f}-${p}-${l}-${c}`))})}):e(Ze,{instanceRef:o,overflow:"auto",viewScroll:"close",menuClassName:"glass-menu shortcuts-menu",gap:8,position:"anchor",onMenuChange:f=>{f.open&&a.current&&Pt().then(u)},menuButton:e("button",{type:"button",id:"shortcuts-button",class:"plain",onContextMenu:f=>{f.preventDefault(),T.showShortcutsSettings=!0},onTransitionStart:f=>{var c,p;try{const{target:l}=f;getComputedStyle(l).pointerEvents==="none"&&((p=(c=o.current)==null?void 0:c.closeMenu)==null||p.call(c))}catch{}},children:e(w,{icon:"shortcut",size:"xl",alt:"Shortcuts"})}),children:h.map(({id:f,path:c,title:p,subtitle:l,icon:b},m)=>f==="lists"?e(Wt,{menuClassName:"glass-menu",overflow:"auto",gap:-8,label:e(_,{children:[e(w,{icon:b,size:"l"}),e("span",{class:"menu-grow",children:e(qt,{children:p})}),e(w,{icon:"chevron-right"})]}),children:[e(Re,{to:"/l",children:e("span",{children:"All Lists"})}),e(ze,{}),r==null?void 0:r.map(k=>e(Re,{to:`/l/${k.id}`,children:e("span",{children:k.title})},k.id))]}):e(Re,{to:c,class:"glass-menu-item",children:[e(w,{icon:b,size:"l"})," ",e("span",{class:"menu-grow",children:[e("span",{children:e(qt,{children:p})}),l&&e(_,{children:[" ",e("small",{class:"more-insignificant",children:l})]})]}),e("span",{class:"menu-shortcut hide-until-focus-visible",children:m+1})]},`${m}-${f}-${p}-${l}-${c}`))})})}const zo=Je(Oo);function Bo(t){var o;let n=[],i=[],s=0;for(let a=0;a<t.length;a++){const h=t[a];h.reblog&&!((o=h.account)!=null&&o.group)?(i.push(h),s++):(n.push(h),s<3&&(s=0))}if(t.length>10&&(i.length>t.length/4||s>=3)){const a=i.map(h=>h.id);if(i.length>t.length*3/4)n=[...n,{id:a,items:i,type:"boosts"}];else{const h=Math.floor(n.length/2);n=[...n.slice(0,h),{id:a,items:i,type:"boosts"},...n.slice(h)]}return n}else return t}function Wn(t,n){const i=be.account.get("boostedStatusIDs")||{},s=t.filter(a=>{if(!a.reblog)return!0;const h=`${n}-${a.reblog.id}`,d=i[h];return d&&d!==a.id?!1:(i[h]=a.id,!0)}),o=Object.keys(i);return o.length>50&&o.slice(0,o.length-50).forEach(a=>{delete i[a]}),be.account.set("boostedStatusIDs",i),s}function qo(t,n){const i=[];let s=0;t.forEach(d=>{for(let u=0;u<i.length;u++){if(i[u].find(f=>f.id===d.id))return;if(i[u].find(f=>f.id===d.inReplyToId)||i[u].find(f=>f.inReplyToId===d.id)){i[u].push(d);return}}const r=t.find(u=>u.id===d.inReplyToId);r&&(i[s++]=[d,r])});for(let d=0;d<i.length;d++)for(let r=d+1;r<i.length;r++)i[d].find(f=>i[r].includes(f))&&(i[d]=[...i[d],...i[r]],i[d]=i[d].filter((f,c,p)=>p.findIndex(l=>l.id===f.id)===c),i.splice(r,1),r--);i.forEach(d=>{d.sort((r,u)=>!r.inReplyToId&&!u.inReplyToId?new Date(r.createdAt)-new Date(u.createdAt):r.inReplyToId===u.id?1:u.inReplyToId===r.id||!r.inReplyToId?-1:u.inReplyToId?new Date(r.createdAt)-new Date(u.createdAt):1)}),i.forEach(d=>{const r=d[0].account.id;d.forEach(u=>{u.account.id!==r&&(u._differentAuthor=!0)})}),i.length;const o=[],a=[],h=[];return t.forEach(d=>{if(d.reblog){o.push(d);return}for(let r=0;r<i.length;r++)if(i[r].find(u=>u.id===d.id)){if(a.includes(r))return;const u=i[r];u.sort((c,p)=>{const l=new Date(c.createdAt),b=new Date(p.createdAt);return l-b});const f=u[0].account.id;o.push({id:u.map(c=>c.id),items:u,type:u.every(c=>c.account.id===f)?"thread":"conversation"}),a.push(r);return}if(d.inReplyToId&&d.inReplyToAccountId!==d.account.id){const r=Ke(d.id,n);T.statusReply[r]||h.push({sKey:r,inReplyToId:d.inReplyToId})}o.push(d)}),h!=null&&h.length&&queueMicrotask(()=>{const{masto:d}=Q({instance:n});async function r(){for(let u=0;u<h.length;u++){const{sKey:f,inReplyToId:c}=h[u];try{const p=await Ho(c,d);qe(p,n,{skipThreading:!0,skipUnfurling:!0}),T.statusReply[f]={id:p.id,instance:n},await new Promise(l=>setTimeout(l,1e3))}catch{}}}if(je("@mastodon/fetch-multiple-statuses")){const u=h.map(({inReplyToId:f})=>f);(async()=>{var f;try{const c=await d.v1.statuses.list({id:u});if(c!=null&&c.length)for(const p of c){qe(p,n,{skipThreading:!0,skipUnfurling:!0});const l=(f=h.find(({inReplyToId:b})=>b===p.id))==null?void 0:f.sKey;l&&(T.statusReply[l]={id:p.id,instance:n})}else r()}catch{r()}})()}else r()}),o}const Ho=ht((t,n)=>n.v1.statuses.$select(t).fetch());async function Ps(t,n){const i=await xo();if(!i.length)return;const{statusFollowedTags:s}=T,o=[];if(t.forEach(a=>{var p;if(a.reblog)return;const{id:h,content:d,tags:r=[]}=a,u=Ke(h,n);if((p=s[u])!=null&&p.length)return;const f=$o(d);if(!f.length&&!r.length)return;const c=i.reduce((l,b)=>((f.some(m=>m.toLowerCase()===b.name.toLowerCase())||r.some(m=>m.name.toLowerCase()===b.name.toLowerCase()))&&l.push(b.name),l),[]);c.length&&o.push({item:a,sKey:u,followedTags:c})}),o.length){const a=o.map(d=>d.item.account),h=await bn(a);if(!h)return;o.forEach(d=>{const{item:r,sKey:u,followedTags:f}=d,c=h[r.account.id];c&&!c.following&&(s[u]=f)})}}function Vo(){T.statusFollowedTags={}}function Go({scrollableRef:t,distanceFromStart:n=1,distanceFromEnd:i=1,scrollThresholdStart:s=10,scrollThresholdEnd:o=10,direction:a="vertical",distanceFromStartPx:h,distanceFromEndPx:d}={}){const[r,u]=$(null),[f,c]=$(!1),[p,l]=$(!1),[b,m]=$(!1),[k,g]=$(!1),y=a==="vertical";return lt(()=>{const C=t.current;if(!C)return{};let v=y?C.scrollTop:C.scrollLeft;function I(){const{scrollTop:x,scrollLeft:L,scrollHeight:Y,scrollWidth:j,clientHeight:M,clientWidth:ee}=C,X=y?x:L,A=y?Y:j,P=y?M:ee,E=Math.abs(X-v),U=h||Math.min(P*n,A,X),V=d||Math.min(P*i,A,A-X-P);E>=(v<X?o:s)&&(u(v<X?"end":"start"),v=X),c(X<=0),l(X+P>=A),m(X<=U),g(X+P>=A-V)}return C.addEventListener("scroll",I,{passive:!0}),()=>C.removeEventListener("scroll",I)},[n,i,s,o]),{scrollDirection:r,reachStart:f,reachEnd:p,nearReachStart:b,nearReachEnd:k,init:()=>{t.current&&t.current.dispatchEvent(new Event("scroll"))}}}function Yo({scrollableRef:t,distanceFromStart:n=1,distanceFromEnd:i=1,scrollThresholdStart:s=10,scrollThresholdEnd:o=10,direction:a="vertical",distanceFromStartPx:h,distanceFromEndPx:d,init:r}={},u,f){if(!u)return;const c=a==="vertical",p=z(null),l=z(null),b=ii(()=>{let m=!1,k=!1,g=!1,y=!1;const C=t.current,{scrollTop:v,scrollLeft:I,scrollHeight:x,scrollWidth:L,clientHeight:Y,clientWidth:j}=C,M=c?v:I,ee=c?x:L,X=c?Y:j,A=Math.abs(M-p.current),P=h||Math.min(X*n,ee,M),E=d||Math.min(X*i,ee,ee-M-X);A>=(p.current<M?o:s)&&(l.current=p.current<M?"end":"start",p.current=M),m=M<=0,k=M+X>=ee,g=M<=P,y=M+X>=ee-E,u({scrollDirection:l.current,reachStart:m,reachEnd:k,nearReachStart:g,nearReachEnd:y})},500);lt(()=>{const m=t.current;return m?(p.current=m[c?"scrollTop":"scrollLeft"],m.addEventListener("scroll",b,{passive:!0}),()=>m.removeEventListener("scroll",b)):{}},[n,i,s,o,...f]),G(()=>{r&&t.current&&queueMicrotask(()=>{t.current.dispatchEvent(new Event("scroll"))})},[r])}function jo({class:t,statusID:n,status:i,instance:s,parent:o,onMediaClick:a}){let h=Ke(n,s);const d=Me(T);if(i||(i=d.statuses[h]||d.statuses[n],h=Ke(i==null?void 0:i.id,s)),!i)return null;const{account:{acct:r,avatar:u,avatarStatic:f,id:c,url:p,displayName:l,username:b,emojis:m,bot:k,group:g},id:y,repliesCount:C,reblogged:v,reblogsCount:I,favourited:x,favouritesCount:L,bookmarked:Y,poll:j,muted:M,sensitive:ee,spoilerText:X,visibility:A,language:P,editedAt:E,filtered:U,card:V,createdAt:ye,inReplyToId:ve,inReplyToAccountId:fe,content:ne,mentions:me,mediaAttachments:ue,reblog:he,uri:ke,url:Le,emojis:Te,_deleted:Pe,_pinned:Fe}=i;if(!(ue!=null&&ue.length))return null;const xe=W=>{W.shiftKey},J=pe(()=>ct(),[]),ae=pe(()=>J&&J===c,[c,J]),te=oi(Is),Se=!ae&&Mt(U,te);if((Se==null?void 0:Se.action)==="hide")return null;const Ie=ee,re=pe(()=>(be.account.get("preferences")||{})["reading:expand:media"]||"default",[])==="show_all",D=o||"div";return ue.map((W,R)=>{const q=`${h}-${W.id}`,Z=Se==null?void 0:Se.titlesStr;return e(D,{"data-state-post-id":h,onMouseEnter:xe,"data-spoiler-text":X||(ee?"Sensitive media":void 0),"data-filtered-text":Se?`Filtered${Z?`: ${Z}`:""}`:void 0,class:`
media-post
${Se?"filtered":""}
${Ie?"has-spoiler":""}
${re?"show-media":""}
`,children:e(Ss,{class:t,media:W,lang:P,to:`/${s}/s/${y}?media-only=${R+1}`,onClick:a?ce=>a(ce,R,W,i):void 0})},q)})}const Kn=Je(jo);function Wo(t){var I,x,L,Y,j;const n=Me(T),{masto:i,instance:s,authenticated:o}=Q(),[a,h]=pe(()=>{const M=be.local.getJSON("accounts")||[];return[M.find(X=>X.info.id===ct())||M[0],M.length>1]},[]),d=(n.settings.shortcutsViewMode==="multi-column"||!n.settings.shortcutsViewMode&&n.settings.shortcutsColumnsMode)&&!n.shortcuts.find(M=>M.type==="following"),r=ai(()=>{T.showAccounts=!0},{threshold:600,detect:"touch",cancelOnMovement:!0}),u=z(),[f,c]=$(void 0),p=Ci([0,0,n.settings.shortcutsViewMode==="tab-menu-bar"?50:0,0]),l=z();async function b(M){return(M||!l.current)&&(l.current=i.v1.mutes.list({limit:80})),await l.current.next()}const m=z();async function k(M){return(M||!m.current)&&(m.current=i.v1.blocks.list({limit:80})),await m.current.next()}const g=je("@mastodon/lists"),[y,C]=$([]);G(()=>{g&&f==="open"&&Pt().then(C)},[f==="open"]);const v=z();return e(_,{children:[e("button",{ref:u,type:"button",class:`button plain nav-menu-button ${h?"with-avatar":""} ${f==="open"?"active":""}`,style:{position:"relative"},onClick:()=>{v.current=Date.now(),c(M=>M?void 0:"open")},onContextMenu:M=>{M.preventDefault(),T.showAccounts=!0},...r(),children:[h&&e(st,{url:((I=a==null?void 0:a.info)==null?void 0:I.avatar)||((x=a==null?void 0:a.info)==null?void 0:x.avatarStatic),size:"l",squircle:(L=a==null?void 0:a.info)==null?void 0:L.bot}),e(w,{icon:"menu",size:h?"s":"l"})]}),e(ms,{menuClassName:"nav-menu",state:f,anchorRef:u,onClose:()=>{c(void 0)},containerProps:{style:{zIndex:10},onClick:()=>{Date.now()-v.current<300}},portal:{target:document.body},...t,overflow:"auto",viewScroll:"close",position:"anchor",align:"center",boundingBoxPadding:p,unmountOnClose:!0,children:[!!((Y=n.appVersion)!=null&&Y.commitHash)&&n.appVersion.commitHash!=="0a6030c"&&e("div",{class:"top-menu",children:[e(de,{onClick:()=>{confirm("Reload page now to update?")&&(async()=>{try{location.reload()}catch{}})()},children:[e(w,{icon:"sparkles",class:"sparkle-icon",size:"l"})," ",e("span",{children:"New update available…"})]}),e(ze,{})]}),e("section",{children:[e(Re,{to:"/",children:[e(w,{icon:"home",size:"l"})," ",e("span",{children:"Home"})]}),o?e(_,{children:[d&&e(Re,{to:"/following",children:[e(w,{icon:"following",size:"l"})," ",e("span",{children:"Following"})]}),e(Re,{to:"/catchup",children:[e(w,{icon:"history2",size:"l"}),e("span",{children:"Catch-up"})]}),je("@mastodon/mentions")&&e(Re,{to:"/mentions",children:[e(w,{icon:"at",size:"l"})," ",e("span",{children:"Mentions"})]}),e(Re,{to:"/notifications",children:[e(w,{icon:"notification",size:"l"})," ",e("span",{children:"Notifications"}),n.notificationsShowNew&&e("sup",{title:"New",style:{opacity:.5},children:[" ","•"]})]}),e(ze,{}),((j=a==null?void 0:a.info)==null?void 0:j.id)&&e(Re,{to:`/${s}/a/${a.info.id}`,children:[e(w,{icon:"user",size:"l"})," ",e("span",{children:"Profile"})]}),(y==null?void 0:y.length)>0?e(Wt,{menuClassName:"nav-submenu",overflow:"auto",gap:-8,label:e(_,{children:[e(w,{icon:"list",size:"l"}),e("span",{class:"menu-grow",children:"Lists"}),e(w,{icon:"chevron-right"})]}),children:[e(Re,{to:"/l",children:e("span",{children:"All Lists"})}),(y==null?void 0:y.length)>0&&e(_,{children:[e(ze,{}),y.map(M=>e(Re,{to:`/l/${M.id}`,children:e("span",{children:M.title})},M.id))]})]}):g&&e(Re,{to:"/l",children:[e(w,{icon:"list",size:"l"}),e("span",{children:"Lists"})]}),e(Re,{to:"/b",children:[e(w,{icon:"bookmark",size:"l"})," ",e("span",{children:"Bookmarks"})]}),e(Wt,{menuClassName:"nav-submenu",overflow:"auto",gap:-8,label:e(_,{children:[e(w,{icon:"more",size:"l"}),e("span",{class:"menu-grow",children:"More…"}),e(w,{icon:"chevron-right"})]}),children:[e(Re,{to:"/f",children:[e(w,{icon:"heart",size:"l"})," ",e("span",{children:"Likes"})]}),e(Re,{to:"/fh",children:[e(w,{icon:"hashtag",size:"l"})," ",e("span",{children:"Followed Hashtags"})]}),e(ze,{}),je("@mastodon/filters")&&e(Re,{to:"/ft",children:[e(w,{icon:"filters",size:"l"}),"Filters"]}),e(de,{onClick:()=>{T.showGenericAccounts={id:"mute",heading:"Muted users",fetchAccounts:b,excludeRelationshipAttrs:["muting"]}},children:[e(w,{icon:"mute",size:"l"})," Muted users…"]}),e(de,{onClick:()=>{T.showGenericAccounts={id:"block",heading:"Blocked users",fetchAccounts:k,excludeRelationshipAttrs:["blocking"]}},children:[e(w,{icon:"block",size:"l"}),"Blocked users…"]})," "]}),e(ze,{}),e(de,{onClick:()=>{T.showAccounts=!0},children:[e(w,{icon:"group",size:"l"})," ",e("span",{children:"Accounts…"})]})]}):e(_,{children:[e(ze,{}),e(Re,{to:"/login",children:[e(w,{icon:"user",size:"l"})," ",e("span",{children:"Log in"})]})]})]}),e("section",{children:[e(ze,{}),e(Re,{to:"/search",children:[e(w,{icon:"search",size:"l"})," ",e("span",{children:"Search"})]}),e(Re,{to:`/${s}/trending`,children:[e(w,{icon:"chart",size:"l"})," ",e("span",{children:"Trending"})]}),e(Re,{to:`/${s}/p/l`,children:[e(w,{icon:"building",size:"l"})," ",e("span",{children:"Local"})]}),e(Re,{to:`/${s}/p`,children:[e(w,{icon:"earth",size:"l"})," ",e("span",{children:"Federated"})]}),o?e(_,{children:[e(ze,{className:"divider-grow"}),e(de,{onClick:()=>{T.showKeyboardShortcutsHelp=!0},children:[e(w,{icon:"keyboard",size:"l"})," ",e("span",{children:"Keyboard shortcuts"})]}),e(de,{onClick:()=>{T.showShortcutsSettings=!0},children:[e(w,{icon:"shortcut",size:"l"})," ",e("span",{children:"Shortcuts / Columns…"})]}),e(de,{onClick:()=>{T.showSettings=!0},children:[e(w,{icon:"gear",size:"l"})," ",e("span",{children:"Settings…"})]})]}):e(_,{children:[e(ze,{}),e(de,{onClick:()=>{T.showSettings=!0},children:[e(w,{icon:"gear",size:"l"})," ",e("span",{children:"Settings…"})]})]})]})]})]})}const yt=Je(Wo),Ut={block:"nearest",inline:"center",behavior:"smooth"};function dt({title:t,titleComponent:n,id:i,instance:s,emptyText:o,errorText:a,useItemID:h,boostsCarousel:d,fetchItems:r=()=>{},checkForUpdates:u=()=>{},checkForUpdatesInterval:f=15e3,headerStart:c,headerEnd:p,timelineStart:l,refresh:b,view:m,filterContext:k,showFollowedTags:g,showReplyParent:y}){const C=Me(T),[v,I]=$([]),[x,L]=$("start"),[Y,j]=$(!1),[M,ee]=$(!1),[X,A]=$(!0),P=z(),E=pe(()=>hn(),[]),U=m!=="media",V=ci(J=>{ee(!1),x!=="loading"&&(L("loading"),(async()=>{try{let{done:ae,value:te}=await r(J);if(Array.isArray(te)){const[Se,Ie]=te.reduce((F,re)=>(re._pinned?F[0].push(re):F[1].push(re),F),[[],[]]);te=Ie,U&&(d&&(te=Bo(te)),te=qo(te,s)),Se.length&&(te=Se.concat(te)),I(J?te:F=>[...F,...te]),te.length||(ae=!0),j(!ae)}else j(!1);L("default")}catch{L("error")}finally{V.cancel()}})())},1500,{leading:!0,trailing:!1}),ye=".timeline-item, .timeline-item-alt",ve=_e("j, shift+j",(J,ae)=>{const te=document.activeElement.closest(ye),Se=te==null?void 0:te.getBoundingClientRect(),Ie=Array.from(P.current.querySelectorAll(ye));if(te&&Se.top<P.current.clientHeight&&Se.bottom>0){const F=Ie.indexOf(te);let re=Ie[F+1];ae.shift&&(re=Ie.find((D,W)=>W>F&&!D.classList.contains("timeline-item-alt"))),re&&(re.focus(),re.scrollIntoView(Ut))}else{const F=Ie.find(re=>{const D=re.getBoundingClientRect();return D.top>=44&&D.left>=0});F&&(F.focus(),F.scrollIntoView(Ut))}}),fe=_e("k, shift+k",(J,ae)=>{const te=document.activeElement.closest(ye),Se=te==null?void 0:te.getBoundingClientRect(),Ie=Array.from(P.current.querySelectorAll(ye));if(te&&Se.top<P.current.clientHeight&&Se.bottom>0){const F=Ie.indexOf(te);let re=Ie[F-1];ae.shift&&(re=Ie.findLast((D,W)=>W<F&&!D.classList.contains("timeline-item-alt"))),re&&(re.focus(),re.scrollIntoView(Ut))}else{const F=Ie.find(re=>{const D=re.getBoundingClientRect();return D.top>=44&&D.left>=0});F&&(F.focus(),F.scrollIntoView(Ut))}}),ne=_e(["enter","o"],()=>{const J=document.activeElement;J!=null&&J.matches(ye)&&J.click()}),me=v.length>0&&x!=="loading"&&M,ue=Qe(()=>{var J;me&&V(!0),(J=P.current)==null||J.scrollTo({top:0,behavior:"smooth"})},[V,me]),he=_e(".",ue),ke=z(),[Le,Te]=$(!1);Yo({scrollableRef:P,distanceFromEnd:2,scrollThresholdStart:44},({scrollDirection:J,nearReachStart:ae,reachStart:te})=>{if(ke.current){const Se=J==="end"&&!ae;ke.current.hidden=Se}Te(ae),te&&V(!0)},[]),G(()=>{var J;(J=P.current)==null||J.scrollTo({top:0}),V(!0)},[]),G(()=>{V(!0)},[b]);const Pe=z(m);G(()=>{Pe.current!==m&&(Pe.current=m,I([]))},[m]);const Fe=Qe(async({disableIdleCheck:J=!1}={})=>{const ae=P.current?getComputedStyle(P.current).pointerEvents==="none":!1;C.settings.autoRefresh&&P.current.scrollTop<16&&(J||window.__IDLE__)&&!Xo()&&!ae?V(!0):await u()&&ee(!0)},[i,V,u,C.settings.autoRefresh]),xe=z();return Ct(J=>{if(J){const ae=Date.now()-xe.current;(!xe.current||ae>1e3*3)&&Fe({disableIdleCheck:!0})}else xe.current=Date.now();A(J)},[u,Fe,C.settings.autoRefresh]),gn(Fe,X&&!M?f*(Le?1:2):null),e(Is.Provider,{value:k,children:e("div",{id:`${i}-page`,class:`deck-container ${E?"deck-container-media-first":""}`,ref:J=>{P.current=J,ve.current=J,fe.current=J,ne.current=J,he.current=J},tabIndex:"-1",children:e("div",{class:"timeline-deck deck",children:[e("header",{ref:ke,onClick:J=>{var ae;J.target.closest("a, button")||(ae=P.current)==null||ae.scrollTo({top:0,behavior:"smooth"})},onDblClick:J=>{J.target.closest("a, button")||V(!0)},class:x==="loading"?"loading":"",children:[e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(yt,{}),c??e(oe,{to:"/",class:"button plain home-button",children:e(w,{icon:"home",size:"l"})})]}),t&&(n||e("h1",{children:t})),e("div",{class:"header-side",children:!!p&&p})]}),me&&e("button",{class:"updates-button shiny-pill",type:"button",onClick:ue,children:[e(w,{icon:"arrow-up"})," New posts"]})]}),!!l&&e("div",{class:`timeline-start ${x==="loading"?"loading":""}`,children:l}),v.length?e(_,{children:[e("ul",{class:`timeline ${m?`timeline-${m}`:""}`,children:[v.map(J=>e(Ko,{status:J,instance:s,useItemID:h,filterContext:k,view:m,showFollowedTags:g,showReplyParent:y,mediaFirst:E},J.id+(J==null?void 0:J._pinned)+m)),Y&&x==="loading"&&(m==="media"?null:e(_,{children:[e("li",{style:{height:"20vh"},children:e(Be,{skeleton:!0,mediaFirst:E})}),e("li",{style:{height:"25vh"},children:e(Be,{skeleton:!0,mediaFirst:E})})]}))]}),x==="default"&&(Y?e(rt,{root:P.current,rootMargin:`0px 0px ${screen.height*1.5}px 0px`,onChange:J=>{J&&V()},children:e("button",{type:"button",class:"plain block",onClick:()=>V(),style:{marginBlockEnd:"6em"},children:"Show more…"})}):e("p",{class:"ui-state insignificant",children:"The end."}))]}):x==="loading"?e("ul",{class:"timeline",children:Array.from({length:5}).map((J,ae)=>m==="media"?e("div",{style:{height:"50vh"}}):e("li",{children:e(Be,{skeleton:!0,mediaFirst:E})},ae))}):x!=="error"&&x!=="start"&&e("p",{class:"ui-state",children:o}),x==="error"&&e("p",{class:"ui-state",children:[a,e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>V(!v.length),children:"Try again"})]})]})})})}const Ko=Je(({status:t,instance:n,useItemID:i,filterContext:s,view:o,showFollowedTags:a,showReplyParent:h,mediaFirst:d})=>{const{id:r,reblog:u,items:f,type:c,_pinned:p}=t;p&&(i=!1);const l=(u==null?void 0:u.id)||r,b=n?`/${n}/s/${l}`:`/s/${l}`;if(f){const k=$t(f,s);let g="";if(c==="boosts"?g=`${k.length} Boosts`:c==="pinned"&&(g="Pinned posts"),c==="boosts"||c==="pinned")return k.sort((v,I)=>{const x=Mt(v.filtered,s),L=Mt(I.filtered,s);return x&&!L?1:!x&&L?-1:0}),e("li",{class:"timeline-item-carousel",children:e(Zo,{title:g,class:`${c}-carousel`,children:k.map(v=>{const{id:I,reblog:x,_pinned:L}=v,Y=(x==null?void 0:x.id)||I,j=n?`/${n}/s/${Y}`:`/s/${Y}`;return L&&(i=!1),e("li",{children:e(oe,{class:"status-carousel-link timeline-item-alt",to:j,children:i?e(Be,{statusID:I,instance:n,size:"s",contentTextWeight:!0,enableCommentHint:!0,mediaFirst:d}):e(Be,{status:v,instance:n,size:"s",contentTextWeight:!0,enableCommentHint:!0,mediaFirst:d})})},I)})})},`timeline-${r}`);const C=k.length>3;return k.map((v,I)=>{const{id:x,_differentAuthor:L}=v,Y=n?`/${n}/s/${x}`:`/s/${x}`,j=I>0&&I<k.length-1,M=v.sensitive&&!!v.spoilerText,ee=!L&&M&&I>0||C&&j&&(c==="thread"||c==="conversation"&&!L&&!k[I-1]._differentAuthor&&!k[I+1]._differentAuthor),X=I===0,A=I===k.length-1;return e("li",{class:`timeline-item-container timeline-item-container-type-${c} timeline-item-container-${X?"start":A?"end":"middle"} ${L?"timeline-item-diff-author":""}`,children:e(oe,{class:"status-link timeline-item",to:Y,children:ee?e(Jo,{status:v,instance:n,filterContext:s}):i?e(Be,{statusID:x,instance:n,enableCommentHint:A,showFollowedTags:a}):e(Be,{status:v,instance:n,enableCommentHint:A,showFollowedTags:a})})},`timeline-${x}`)})}const m=`timeline-${r+p}`;return o==="media"?i?e(Kn,{class:"timeline-item",parent:"li",statusID:r,instance:n},m):e(Kn,{class:"timeline-item",parent:"li",status:t,instance:n},m):e("li",{children:e(oe,{class:"status-link timeline-item",to:b,children:i?e(Be,{statusID:r,instance:n,enableCommentHint:!0,showFollowedTags:a,showReplyParent:h,mediaFirst:d}):e(Be,{status:t,instance:n,enableCommentHint:!0,showFollowedTags:a,showReplyParent:h,mediaFirst:d})})},m)},(t,n)=>{var o,a;const i=(((o=t.status)==null?void 0:o.id)||"").toString(),s=(((a=n.status)==null?void 0:a.id)||"").toString();return i===s&&t.instance===n.instance&&t.view===n.view});function Zo({title:t,class:n,children:i}){const s=z(),o=z(),a=z(),[h,d]=$(!1);return G(()=>{setTimeout(()=>{d(!0)},1)},[]),e("div",{class:`status-carousel ${n}`,children:[e("header",{children:[e("h3",{children:t}),e("span",{children:[e("button",{ref:o,type:"button",class:"small plain2",onClick:()=>{var r,u;(u=s.current)==null||u.scrollBy({left:-Math.min(320,(r=s.current)==null?void 0:r.offsetWidth),behavior:"smooth"})},children:e(w,{icon:"chevron-left"})})," ",e("button",{ref:a,type:"button",class:"small plain2",onClick:()=>{var r,u;(u=s.current)==null||u.scrollBy({left:Math.min(320,(r=s.current)==null?void 0:r.offsetWidth),behavior:"smooth"})},children:e(w,{icon:"chevron-right"})})]})]}),e("ul",{ref:s,children:[e(rt,{class:"status-carousel-beacon",onChange:r=>{o.current&&(o.current.disabled=r)}}),i[0],h&&i.slice(1),e(rt,{class:"status-carousel-beacon",onChange:r=>{a.current&&(a.current.disabled=r)}})]})]})}function Jo({status:t,instance:n,filterContext:i}){const s=Me(T),{id:o,visibility:a,language:h}=t,d=yn(t),r=Ke(o,n),u=Mt(t.filtered,i);return e("article",{class:`status compact-thread ${a==="direct"?"visibility-direct":""}`,tabindex:"-1",children:[s.statusThreadNumber[r]?e("div",{class:"status-thread-badge",children:[e(w,{icon:"thread",size:"s"}),s.statusThreadNumber[r]?` ${s.statusThreadNumber[r]}/X`:""]}):e("div",{class:"status-thread-badge",children:e(w,{icon:"thread",size:"s"})}),e("div",{class:"content-compact",title:d,lang:h,dir:"auto",children:u?e("b",{class:"status-filtered-badge badge-meta horizontal",title:(u==null?void 0:u.titlesStr)||"",children:[e("span",{children:"Filtered"}),": ",e("span",{children:(u==null?void 0:u.titlesStr)||""})]}):e(_,{children:[d,t.sensitive&&t.spoilerText&&e(_,{children:[" ",e("span",{class:"spoiler-badge",children:e(w,{icon:"eye-close",size:"s"})})]})]})})]})}function Xo(){return!!document.querySelector(".deck-backdrop, #modal-container > *")}const kt=20,Cn=1983,Zn=`${Cn}-01`,Qo=(()=>{try{const t=document.createElement("input");return t.setAttribute("type","month"),t.type==="month"}catch{return!1}})();async function ea(t){var s;const{masto:n}=Q({instance:t}),i=await n.v2.search.fetch({q:"from:me",type:"statuses",limit:1});return!!((s=i==null?void 0:i.statuses)!=null&&s.length)}const ta=ht(ea);function na(){const t=Me(T),{id:n,...i}=gt(),[s,o]=it(),a=s.get("month"),h=!s.get("replies"),d=!!s.get("boosts"),r=s.get("tagged"),u=!!s.get("media"),{masto:f,instance:c,authenticated:p}=Q({instance:i.instance}),{masto:l,instance:b}=Q(),m=z(),k=[a,h,d,r,u],[g,y]=$(),C=z(0);G(()=>{C.current=0},k);const v=pe(()=>hn(),[]),I=pe(()=>c===b,[c,b]),[x,L]=$(!1);G(()=>{I&&g!=null&&g.acct&&(async()=>{const ne=await ta(c);L(ne)})()},[c,I,g==null?void 0:g.acct]);async function Y(ne){var Te,Pe,Fe,xe;const me=/^\d{4}-[01]\d$/.test(a),ue=((Pe=(Te=a==null?void 0:a.split)==null?void 0:Te.call(a,"-"))==null?void 0:Pe[0])>=Cn;if(me&&ue){if(!g)return{value:[],done:!0};const[J,ae]=a.split("-"),te=parseInt(ae,10)-1,Se=new Date(J,te,0),Ie=`${Se.getFullYear()}-${(Se.getMonth()+1).toString().padStart(2,"0")}-${Se.getDate().toString().padStart(2,"0")}`,F=new Date(J,te+1,1),re=`${F.getFullYear()}-${(F.getMonth()+1).toString().padStart(2,"0")}-${F.getDate().toString().padStart(2,"0")}`;let D;ne?(D=kt+1,C.current=0):(D=kt+C.current+1,C.current+=kt);const W=await f.v2.search.fetch({q:`from:${g.acct} after:${Ie} before:${re}`,type:"statuses",limit:D,offset:C.current});if((Fe=W==null?void 0:W.statuses)!=null&&Fe.length){const R=W.statuses.slice(0,kt);R.forEach(Z=>{qe(Z,c)});const q=W.statuses.length<=kt;return{value:R,done:q}}else return{value:[],done:!0}}let he=[];if(ne){const{value:J}=await f.v1.accounts.$select(n).statuses.list({pinned:!0}).next();if(J!=null&&J.length&&!r&&!u){const ae=J.map(te=>(qe(te,c),{...te,_pinned:!0}));if(ae.length>=3){const te=ae.map(Se=>Se.id);he.push({id:te,items:ae,type:"pinned"})}else he.push(...ae)}}(ne||!m.current)&&(m.current=f.v1.accounts.$select(n).statuses.list({limit:kt,exclude_replies:h,exclude_reblogs:d,only_media:u||void 0,tagged:r}));const{value:ke,done:Le}=await m.current.next();if(ke!=null&&ke.length){if(he.length){let J=[];((xe=he[0])==null?void 0:xe.type)==="pinned"?J=he[0].id:J=he.filter(te=>te._pinned).map(te=>te.id),J.every(te=>ke.some(Se=>Se.id===te))&&(he=[])}he.push(...ke),ke.forEach(J=>{qe(J,c)})}return{value:he,done:Le}}const[j,M]=$([]);He(g!=null&&g.acct?`${g!=null&&g.displayName?`${g.displayName} (${/@/.test(g.acct)?"":"@"}${g.acct})`:`${/@/.test(g.acct)?"":"@"}${g.acct}`}${h?d?" (- Boosts)":r?` (#${r})`:u?" (Media)":a?` (${new Date(a).toLocaleString("default",{month:"long",year:"numeric"})})`:"":" (+ Replies)"}`:"Account posts","/:instance?/a/:id");const ee=z(),X=Qe(()=>{const ne=ee.current||f.v1.accounts.$select(n).fetch();return ee.current=ne,ne},[n,f]);G(()=>{(async()=>{try{const ne=await X();y(ne)}catch{}if(!v)try{const ne=await f.v1.accounts.$select(n).featuredTags.list();M(ne)}catch{}})()},[n,v]);const{displayName:A,acct:P,emojis:E}=g||{},U=z(),V=pe(()=>{const ne=!h||d||r||u||!!a,me=t.accounts[`${n}@${c}`];return e(_,{children:[e(_s,{instance:c,account:me||n,fetchAccount:X,authenticated:p,standalone:!0}),!v&&e("div",{class:"filter-bar",ref:U,style:{position:"relative"},children:[ne?e(oe,{to:`/${c}/a/${n}`,class:"insignificant filter-clear",title:"Clear filters",children:e(w,{icon:"x",size:"l"})},"clear-filters"):e(w,{icon:"filter",class:"insignificant",size:"l"}),e(oe,{to:`/${c}/a/${n}${h?"?replies=1":""}`,onClick:()=>{h&&se("Showing post with replies")},class:h?"":"is-active",children:"+ Replies"}),e(oe,{to:`/${c}/a/${n}${d?"":"?boosts=0"}`,onClick:()=>{d||se("Showing posts without boosts")},class:d?"is-active":"",children:"- Boosts"}),e(oe,{to:`/${c}/a/${n}${u?"":"?media=1"}`,onClick:()=>{u||se("Showing posts with media")},class:u?"is-active":"",children:"Media"}),j.map(ue=>e(oe,{to:`/${c}/a/${n}${r===ue.name?"":`?tagged=${encodeURIComponent(ue.name)}`}`,onClick:()=>{r!==ue.name&&se(`Showing posts tagged with #${ue.name}`)},class:r===ue.name?"is-active":"",children:e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),ue.name]})},ue.id)),x&&(Qo?e("label",{class:`filter-field ${a?"is-active":""}`,children:[e(w,{icon:"month",size:"l"}),e("input",{type:"month",disabled:!(g!=null&&g.acct),value:a||"",min:Zn,max:new Date().toISOString().slice(0,7),onInput:ue=>{const{value:he,validity:ke}=ue.currentTarget;if(!ke.valid)return;o(he?{month:he}:{});const[Le,Te]=he.split("-"),Pe=parseInt(Te,10)-1,Fe=new Date(Le,Pe);se(`Showing posts in ${Fe.toLocaleString("default",{month:"long",year:"numeric"})}`)}})]}):e(sa,{class:`filter-field ${a?"is-active":""}`,disabled:!(g!=null&&g.acct),value:a||"",min:Zn,max:new Date().toISOString().slice(0,7),onInput:ue=>{const{value:he,validity:ke}=ue;ke.valid&&o(he?{month:he}:{})}}))]})]})},[n,c,p,j,X,x,...k]);G(()=>{var me;const ne=(me=U.current)==null?void 0:me.querySelector(".is-active");ne&&U.current.scrollTo({behavior:"smooth",left:ne.offsetLeft-(U.current.offsetWidth-ne.offsetWidth)/2})},[j,x,...k]);const ye=pe(()=>g!=null&&g.url?new URL(g.url).hostname:null,[g]),fe=!!g&&!(c===ye);return e(dt,{title:`${g!=null&&g.acct?"@"+g.acct:"Posts"}`,titleComponent:e("h1",{class:"header-double-lines header-account",children:[e("b",{children:e(vs,{text:A,emojis:E})}),e("div",{children:e("span",{children:["@",P]})})]}),id:"account-statuses",instance:c,emptyText:"Nothing to see here yet.",errorText:"Unable to load posts",fetchItems:Y,useItemID:!0,view:u||v?"media":void 0,boostsCarousel:t.settings.boostsCarousel,timelineStart:V,refresh:[h,d,r,u,a+(g==null?void 0:g.acct)].toString(),headerEnd:e(Ze,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(w,{icon:"more",size:"l"})}),children:[e(de,{disabled:!fe,onClick:()=>{(async()=>{try{const{masto:ne}=Q({instance:ye}),me=await ne.v1.accounts.lookup({acct:g.acct}),{id:ue}=me;location.hash=`/${ye}/a/${ue}`}catch{alert("Unable to fetch account info")}})()},children:[e(w,{icon:"transfer"})," ",e("small",{class:"menu-double-lines",children:["Switch to account's instance"," ",ye?e(_,{children:[" ","(",e("b",{children:xt.toUnicode(ye)}),")"]}):null]})]}),!I&&e(de,{onClick:()=>{(async()=>{try{const ne=await l.v1.accounts.lookup({acct:g.acct+"@"+c}),{id:me}=ne;location.hash=`/${b}/a/${me}`}catch{alert("Unable to fetch account info")}})()},children:[e(w,{icon:"transfer"})," ",e("small",{class:"menu-double-lines",children:["Switch to my instance (",e("b",{children:b}),")"]})]})]})},n)}function sa(t){const{class:n,disabled:i,value:s,min:o,max:a,onInput:h=()=>{}}=t,[d,r]=(s==null?void 0:s.split("-"))||[],u=z(),f=z(),c=(p,l)=>{const[b,m]=(o==null?void 0:o.split("-"))||[],[k,g]=(a==null?void 0:a.split("-"))||[];return!(l<b||l>k||l===b&&p<m||l===k&&p>g)};return e("div",{class:n,children:[e(w,{icon:"month",size:"l"}),e("select",{ref:u,disabled:i,value:r||"",onInput:p=>{const{value:l}=p.currentTarget,b=f.current.value;if(!c(l,b))return{value:"",validity:{valid:!1}};h({value:l?`${b}-${l}`:"",validity:{valid:!0}})},children:[e("option",{value:"",children:"Month"}),e("option",{disabled:!0,children:"-----"}),Array.from({length:12},(p,l)=>e("option",{value:(l+1).toString().padStart(2,"0"),children:new Date(0,l).toLocaleString("default",{month:"long"})},l))]})," ",e("input",{ref:f,type:"number",disabled:i,value:d||new Date().getFullYear(),min:(o==null?void 0:o.slice(0,4))||Cn,max:(a==null?void 0:a.slice(0,4))||new Date().getFullYear(),onInput:p=>{const{value:l,validity:b}=p.currentTarget,m=u.current.value;if(!b.valid||!c(m,l))return{value:"",validity:{valid:!1}};h({value:l?`${l}-${m}`:"",validity:{valid:!0}})},style:{width:"4.5em"}})]})}const ia=20;function Ds(){He("Bookmarks","/b");const{masto:t,instance:n}=Q(),i=z();async function s(o){return(o||!i.current)&&(i.current=t.v1.bookmarks.list({limit:ia})),await i.current.next()}return e(dt,{title:"Bookmarks",id:"bookmarks",emptyText:"No bookmarks yet. Go bookmark something!",errorText:"Unable to load bookmarks",instance:n,fetchItems:s})}const oa=""+new URL("catch-up-DuauQu-W.png",import.meta.url).href,aa="home",We=[{label:"last 1 hour",value:1},{label:"last 2 hours",value:2},{label:"last 3 hours",value:3},{label:"last 4 hours",value:4},{label:"last 5 hours",value:5},{label:"last 6 hours",value:6},{label:"last 7 hours",value:7},{label:"last 8 hours",value:8},{label:"last 9 hours",value:9},{label:"last 10 hours",value:10},{label:"last 11 hours",value:11},{label:"last 12 hours",value:12},{label:"beyond 12 hours",value:13}],ca=["Original","Replies","Boosts","Followed tags","Groups","Filtered"],ra=["createdAt","repliesCount","favouritesCount","reblogsCount","density"],la=[null,"account"],Jn={Filtered:"filtered",Groups:"group",Boosts:"boost",Replies:"reply","Followed tags":"followedTags",Original:"original"},da={Filtered:"filtered posts",Groups:"group posts",Boosts:"boosts",Replies:"replies","Followed tags":"followed-tag posts",Original:"original posts"},ua={createdAt:["oldest","latest"],repliesCount:["fewest replies","most replies"],favouritesCount:["fewest likes","most likes"],reblogsCount:["fewest boosts","most boosts"],density:["least dense","most dense"]};function ha(){He("Catch-up","/catchup");const{masto:t,instance:n}=Q(),[i,s]=it(),o=i.get("id"),[a,h]=$("start"),[d,r]=$(!1),u=pe(()=>ct(),[]),f=S=>S===u,c=je("@pixelfed/home-include-reblogs");async function p({maxCreatedAt:S}){var K,ge,le;const N=S?new Date(S):null,B=[],O=t.v1.timelines.home.list({limit:40});e:for(;;)try{c&&O.nextParams&&(typeof O.nextParams=="string"?O.nextParams+="&include_reblogs=true":O.nextParams.include_reblogs=!0);const ie=await O.next(),{value:Ce}=ie;if(Ce!=null&&Ce.length){await Ps(Ce,n);let Ne=!1;for(let Oe=0;Oe<Ce.length;Oe++){const Ee=Ce[Oe],Ve=new Date(Ee.createdAt);if(!N||Ve>=N){const we=!f(((ge=(K=Ee.reblog)==null?void 0:K.account)==null?void 0:ge.id)||Ee.account.id)&&Mt(((le=Ee.reblog)==null?void 0:le.filtered)||Ee.filtered,aa);if((we==null?void 0:we.action)==="hide")continue;Ee._filtered=we;const tt=Ke(Ee.id,n);Ee._followedTags=T.statusFollowedTags[tt]?[...T.statusFollowedTags[tt]]:[],B.push(Ee),Ne=!0}if(!Ne)break e}}else break e;await new Promise(Ne=>setTimeout(Ne,1e3))}catch{break e}return B.forEach(ie=>{if(ie!=null&&ie.inReplyToId){const Ce=B.find(Ne=>Ne.id===ie.inReplyToId);Ce&&!Ce.inReplyToId&&(Ce._thread=!0)}}),B}const[l,b]=$([]),m=z(),k=z(),g=pe(()=>jt(),[]),y=Qe(async({duration:S}={})=>{const N=Date.now(),B=S?N-S:null;h("loading");const O=await p({maxCreatedAt:B}),K=`${g}-${ri()}`;try{await nt.catchup.set(K,{id:K,posts:O,count:O.length,startAt:B,endAt:N}),s({id:K})}catch{}},[]);G(()=>{o?(async()=>{const S=await nt.catchup.get(o);S&&(S.posts.sort((N,B)=>N.createdAt>B.createdAt?1:-1),b(S.posts),h("results"))})():a==="results"&&(b([]),h("start"))},[o]);const[C,v]=mt(S=>S+1,0),[I,x]=$(null),[L,Y]=$([]);G(()=>{(async()=>{try{const S=await nt.catchup.keys();if(S.length){const N=jt(),B=S.filter(O=>O.startsWith(`${N}-`));if(B.length){let O=await nt.catchup.getMany(B);O.sort((ie,Ce)=>Ce.endAt-ie.endAt);let K=O.slice(0,3),ge=O.slice(3);const le=K.map(ie=>{const{id:Ce,count:Ne,startAt:Oe,endAt:Ee}=ie;return{id:Ce,count:Ne,startAt:Oe,endAt:Ee}});Y(le),x(K[0].endAt),O=null,K=null,queueMicrotask(()=>{ge.length&&nt.catchup.delMany(ge.map(ie=>ie.id)).then(()=>{ge=null}).catch(ie=>{})});return}}}catch{}Y([])})()},[C]),G(()=>{a==="start"&&v()},[a==="start"]);const[j,M]=pe(()=>{var Ce,Ne,Oe,Ee,Ve;let S=0,N=0,B=0,O=0,K=0,ge=0;const le={};for(const H of l){H._filtered?(S++,H.__FILTER="filtered"):H.group?(N++,H.__FILTER="group"):H.reblog?(B++,H.__FILTER="boost"):(Ce=H._followedTags)!=null&&Ce.length?(K++,H.__FILTER="followedTags"):H.inReplyToId&&H.inReplyToAccountId!==((Ne=H.account)==null?void 0:Ne.id)?(O++,H.__FILTER="reply"):(ge++,H.__FILTER="original");const we=H.reblog||H;if(H.__FILTER!=="filtered"&&((Oe=we.card)!=null&&Oe.url)&&((Ee=we.card)!=null&&Ee.image)&&((Ve=we.card)==null?void 0:Ve.type)==="link"){const{card:tt,favouritesCount:Dt,reblogsCount:pt}=we;let{url:Ye}=tt;if(Ye=Ye.replace(/\/$/,""),!le[Ye])le[Ye]={postID:we.id,card:tt,shared:1,sharers:[H.account],likes:Dt,boosts:pt};else{if(le[Ye].sharers.find(wt=>wt.id===H.account.id))continue;le[Ye].shared++,le[Ye].sharers.push(H.account),le[Ye].postID!==we.id&&(le[Ye].likes+=Dt,le[Ye].boosts+=pt)}}}let ie=[];for(const H in le)ie.push({url:H,...le[H]});if(ie.sort((H,we)=>H.shared>we.shared?-1:H.shared<we.shared?1:H.boosts>we.boosts?-1:H.boosts<we.boosts?1:H.likes>we.likes?-1:H.likes<we.likes?1:0),ie.length>10)e:for(let H=10;H<ie.length;H++){const{shared:we}=ie[H];if(we<=1){ie=ie.slice(0,H);break e}}return[{Filtered:S,Groups:N,Boosts:B,Replies:O,"Followed tags":K,Original:ge},ie]},[l]),[ee,X]=$("All"),[A,P]=$(null),[E,U]=$(1),[V,ye]=$("createdAt"),[ve,fe]=$("asc"),[ne,me]=$(null),[ue,he,ke]=pe(()=>{const S={},N=new Map;let B=l.filter(K=>{const ge=ee==="All"||K.__FILTER===Jn[ee];return ge&&(S[K.account.id]=K.account,N.set(K.account.id,(N.get(K.account.id)||0)+1)),ge});const O={};return B.forEach(K=>{K.reblog&&(O[K.reblog.id]?(O[K.reblog.id].__BOOSTERS?O[K.reblog.id].__BOOSTERS.add(K.account):O[K.reblog.id].__BOOSTERS=new Set([K.account]),K.__HIDDEN=!0):O[K.reblog.id]=K)}),A&&N.has(A)&&(B=B.filter(K=>K.account.id===A||[...K.__BOOSTERS||[]].find(ge=>ge.id===A))),[B,S,Object.fromEntries(N)]},[ee,A,l]),Le=pe(()=>{const S={};return ue.forEach(N=>{S[N.id]=N}),S},[ue]),Te=pe(()=>Object.keys(ke).sort((S,N)=>ke[N]-ke[S]),[ke]),Pe=pe(()=>{const S={};return Te.forEach((N,B)=>{S[N]=B}),ue.filter(N=>!N.__HIDDEN).sort((N,B)=>{if(ne==="account"){const O=N.account.id,K=B.account.id,ge=S[O],le=S[K],ie=ge-le;if(ie!==0)return ie}if(V!=="createdAt"&&(N=N.reblog||N,B=B.reblog||B,V!=="density"&&N[V]===B[V]))return N.createdAt>B.createdAt?1:-1;if(V==="density"){const O=Xn(N),K=Xn(B);return ve==="asc"?O>K?1:-1:K>O?1:-1}return ve==="asc"?N[V]>B[V]?1:-1:B[V]>N[V]?1:-1})},[ue,V,ve,ne,Te]),Fe=z(null),xe=z(null),J=z(!1);G(()=>{l.length>100||J.current||xe.current&&(li(xe.current,{duration:200}),J.current=!0)},[l,xe]);const ae=l.length>160?"3d":"2d",te=pe(()=>ae!=="2d"?null:l.map(S=>{const N=Le[S.id];return e("span",{class:`post-dot ${N?"post-dot-highlight":""}`},S.id)}),[Le]),Se=pe(()=>ae!=="3d"||!(l!=null&&l.length)?null:va(l,"createdAt",320).map((N,B)=>e("div",{class:"posts-bin",children:N.map(O=>{const K=Le[O.id];return e("span",{class:`post-dot ${K?"post-dot-highlight":""}`},O.id)})},B)),[Le]),Ie=z(null),F=pe(()=>I?(Date.now()-I)/1e3/60/60:null,[I,E]);G(()=>{if(a!=="results")return;const S=A&&he[A]?he[A].username:"",N=ve==="asc"?0:1,B={account:"authors"};let O=se({duration:5e3,text:`Showing ${da[ee]||"all posts"}${S?` by @${S}`:""}, ${ua[V][N]} first${ne?`, grouped by ${ne==="account"?B[ne]:""}`:""}`});return()=>{var K;(K=O==null?void 0:O.hideToast)==null||K.call(O)}},[a,ee,A,V,ve,ne,he]),G(()=>{var S;if(A&&he[A]){const N=xe.current.querySelector(`[data-author="${A}"]`),B=(S=xe.current)==null?void 0:S.getBoundingClientRect(),O=N==null?void 0:N.getBoundingClientRect();O.left<B.left||O.right>B.right?N.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}):O.top<0&&N.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}},[A,he]);const[re,D]=$(!1),W=".catchup-list > li > a",R=_e("j",()=>{const S=document.activeElement.closest(W),N=S==null?void 0:S.getBoundingClientRect(),B=Array.from(Ie.current.querySelectorAll(W));if(S&&N.top<Ie.current.clientHeight&&N.bottom>0){const O=B.indexOf(S),K=B[O+1];K&&(K.focus(),K.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}))}else{const O=B.find(K=>K.getBoundingClientRect().top>=0);O&&(O.focus(),O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))}},{preventDefault:!0,ignoreModifiers:!0}),q=_e("k",()=>{const S=document.activeElement.closest(W),N=S==null?void 0:S.getBoundingClientRect(),B=Array.from(Ie.current.querySelectorAll(W));if(S&&N.top<Ie.current.clientHeight&&N.bottom>0){const O=B.indexOf(S);let K=B[O-1];K&&(K.focus(),K.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}))}else{const O=B.find(K=>{const ge=K.getBoundingClientRect();return ge.top>=44&&ge.left>=0});O&&(O.focus(),O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))}},{preventDefault:!0,ignoreModifiers:!0}),Z=_e("h, l",(S,N)=>{var O,K,ge;const B=N.keys[0];if(A){const le=Te.indexOf(A);B==="h"?le>0&&le<Te.length&&(P(Te[le-1]),(O=Ie.current)==null||O.focus()):B==="l"&&le<Te.length-1&&le>=0&&(P(Te[le+1]),(K=Ie.current)==null||K.focus())}else B==="l"&&(P(Te[0]),(ge=Ie.current)==null||ge.focus())},{preventDefault:!0,ignoreModifiers:!0,enableOnFormTags:["input"]}),ce=_e("esc",()=>{var S;P(null),(S=Ie.current)==null||S.focus()},{preventDefault:!0,ignoreModifiers:!0,enableOnFormTags:["input"]}),De=_e(".",()=>{var S;(S=Ie.current)==null||S.scrollTo({top:0,behavior:"smooth"})},{preventDefault:!0,ignoreModifiers:!0,enableOnFormTags:["input"]});return e("div",{ref:S=>{Ie.current=S,R.current=S,q.current=S,Z.current=S,ce.current=S},id:"catchup-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck wide",children:[e("header",{class:`${a==="loading"?"loading":""}`,onClick:S=>{var N;S.target.closest("a, button")||(N=Ie.current)==null||N.scrollTo({top:0,behavior:"smooth"})},children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(yt,{}),a==="results"&&e(oe,{to:"/catchup",class:"button plain",children:e(w,{icon:"history2",size:"l"})}),a==="start"&&e(oe,{to:"/",class:"button plain",children:e(w,{icon:"home",size:"l"})})]}),e("h1",{children:a!=="start"&&e(_,{children:["Catch-up ",e("sup",{children:"beta"})]})}),e("div",{class:"header-side",children:a!=="start"&&a!=="loading"&&e("button",{type:"button",class:"plain",onClick:()=>{D(!0)},children:"Help"})})]})}),e("main",{children:[a==="start"&&e("div",{class:"catchup-start",children:[e("h1",{children:["Catch-up ",e("sup",{children:"beta"})]}),e("details",{children:[e("summary",{children:"What is this?"}),e("p",{children:"Catch-up is a separate timeline for your followings, offering a high-level view at a glance, with a simple, email-inspired interface to effortlessly sort and filter through posts."}),e("img",{src:oa,width:"1200",height:"900",alt:"Preview of Catch-up UI"}),e("p",{children:e("button",{type:"button",onClick:S=>{S.target.closest("details").open=!1},children:"Let's catch up"})})]}),e("p",{children:"Let's catch up on the posts from your followings."}),e("p",{children:e("b",{children:"Show me all posts from…"})}),e("div",{class:"catchup-form",children:[e("input",{ref:m,type:"range",value:E,min:We[0].value,max:We[We.length-1].value,step:"1",list:"catchup-ranges",onChange:S=>U(+S.target.value)})," ",e("span",{style:{width:"8em"},children:[We[E-1].label,e("br",{}),e("small",{class:"insignificant",children:E==We[We.length-1].value?"until the max":ot(new Date(Date.now()-E*60*60*1e3))})]}),e("datalist",{id:"catchup-ranges",children:We.map(({label:S,value:N})=>e("option",{value:N,label:S}))})," ",e("button",{type:"button",onClick:()=>{var S;if(E<We[We.length-1].value){let N;E===We[We.length-1].value&&((S=k.current)!=null&&S.checked)?N=Date.now()-I:N=E*60*60*1e3,y({duration:N})}else y()},children:"Catch up"})]}),F&&E>F?e("p",{class:"catchup-info",children:[e(w,{icon:"info"})," Overlaps with your last catch-up"]}):E===We[We.length-1].value&&I?e("p",{class:"catchup-info",children:e("label",{children:[e("input",{type:"checkbox",switch:!0,checked:!0,ref:k})," ","Until the last catch-up (",Ft.format(new Date(I)),")"]})}):null,e("p",{class:"insignificant",children:e("small",{children:"Note: your instance might only show a maximum of 800 posts in the Home timeline regardless of the time range. Could be less or more."})}),!!(L!=null&&L.length)&&e("div",{class:"catchup-prev",children:[e("p",{children:"Previously…"}),e("ul",{children:L.map(S=>e("li",{children:[e(oe,{to:`/catchup?id=${S.id}`,children:[e(w,{icon:"history2"})," ",e("span",{children:S.startAt?Ft.formatRange(new Date(S.startAt),new Date(S.endAt)):`… – ${Ft.format(new Date(S.endAt))}`})]})," ",e("span",{children:[e("small",{class:"ib insignificant",children:[S.count," posts"]})," ",e("button",{type:"button",class:"light danger small",onClick:async()=>{var B;if(confirm("Remove this catch-up?")){let O=se(`Removing Catch-up ${S.id}`);await nt.catchup.del(S.id),(B=O==null?void 0:O.hideToast)==null||B.call(O),se(`Catch-up ${S.id} removed`),v()}},children:e(w,{icon:"x"})})]})]},S.id))}),L.length>=3&&e("p",{children:e("small",{children:"Note: Only max 3 will be stored. The rest will be automatically removed."})})]})]}),a==="loading"&&e("div",{class:"ui-state catchup-start",children:[e($e,{abrupt:!0}),e("p",{class:"insignificant",children:"Fetching posts…"}),e("p",{class:"insignificant",children:"This might take a while."})]}),a==="results"&&e(_,{children:[e("div",{class:"catchup-header",children:[l.length>0&&e("p",{children:e("b",{class:"ib",children:Ft.formatRange(new Date(l[0].createdAt),new Date(l[l.length-1].createdAt))})}),e("aside",{children:[e("button",{hidden:ee==="All"&&!A&&V==="createdAt"&&ve==="asc",type:"button",class:"plain4 small",onClick:()=>{X("All"),P(null),ye("createdAt"),me(null),fe("asc")},children:"Reset filters"}),(M==null?void 0:M.length)>0&&e("button",{type:"button",class:"plain small",onClick:()=>r(!d),children:["Top links"," ",e(w,{icon:"chevron-down",style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]})]})]}),e("div",{class:"shazam-container no-animation",hidden:!d,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"catchup-top-links links-bar",children:M.map(S=>{const{card:N,shared:B,sharers:O,likes:K,boosts:ge}=S,{blurhash:le,title:ie,description:Ce,url:Ne,image:Oe,imageDescription:Ee,language:Ve,width:H,height:we,publishedAt:tt}=N,Dt=xt.toUnicode(new URL(Ne).hostname.replace(/^www\./,"").replace(/\/$/,""));let pt;if(le){const Ye=fn(le),wt=Sn(Ye);pt=In([.6,wt[1],wt[2]])}return e("a",{href:Ne,target:"_blank",rel:"noopener noreferrer",style:pt?{"--accent-color":`rgb(${pt.join(",")})`,"--accent-alpha-color":`rgba(${pt.join(",")}, 0.4)`}:{},children:e("article",{children:[e("figure",{children:e("img",{src:Oe,alt:Ee,width:H,height:we,loading:"lazy"})}),e("div",{class:"article-body",children:[e("header",{children:[e("div",{class:"article-meta",children:[e("span",{class:"domain",children:Dt})," ",!!tt&&e(_,{children:"· "}),!!tt&&e(_,{children:e(bt,{datetime:tt,format:"micro"})})]}),!!ie&&e("h1",{class:"title",lang:Ve,dir:"auto",title:ie,children:ie})]}),!!Ce&&e("p",{class:"description",lang:Ve,dir:"auto",title:Ce,children:Ce}),e("hr",{}),e("p",{style:{whiteSpace:"nowrap"},children:["Shared by"," ",O.map(Ye=>{const{avatarStatic:wt,displayName:Ws}=Ye;return e(st,{url:wt,size:"s",alt:Ws})})]})]})]})},Ne)})})})}),l.length>=5&&(ae==="3d"?e("div",{class:"catchup-posts-viz-time-bar",children:Se}):e("div",{class:"catchup-posts-viz-bar",children:te})),l.length>=2&&e("div",{class:"catchup-filters",children:[e("label",{class:"filter-cat",children:[e("input",{type:"radio",name:"filter-cat",checked:ee.toLowerCase()==="all",onChange:()=>{X("All")}}),"All ",e("span",{class:"count",children:l.length})]}),ca.map(S=>!!j[S]&&e("label",{class:"filter-cat",title:(j[S]/l.length*100).toFixed(2)+"%",children:[e("input",{type:"radio",name:"filter-cat",checked:ee.toLowerCase()===S.toLowerCase(),onChange:()=>{X(S)}}),S," ",e("span",{class:"count",children:j[S]})]},S))]}),l.length>=2&&!!ke&&e("div",{class:"catchup-filters authors-filters",ref:xe,children:[Te.map(S=>e("label",{class:"filter-author","data-author":S,children:[e("input",{type:"radio",name:"filter-author",checked:A===S,onChange:()=>{P(S)},onClick:()=>{A===S&&P(null)}}),e(st,{url:he[S].avatarStatic||he[S].avatar,size:"xxl",alt:`${he[S].displayName} (@${he[S].acct})`})," ",e("span",{class:"count",children:ke[S]}),e("span",{class:"username",children:he[S].username})]},`${S}-${ke[S]}`)),Te.length>5&&e("small",{style:{whiteSpace:"nowrap",paddingInline:"1em",opacity:.33},children:[Te.length," authors"]},"authors-count")]}),l.length>=2&&e("div",{class:"catchup-filters",children:[e("span",{class:"filter-label",children:"Sort"})," ",e("fieldset",{class:"radio-field-group",children:ra.map(S=>e("label",{class:"filter-sort",onClick:N=>{V===S&&(N.preventDefault(),N.stopPropagation(),fe(ve==="asc"?"desc":"asc"))},children:[e("input",{type:"radio",name:"filter-sort-cat",checked:V===S,onChange:()=>{ye(S);const N=/(replies|favourites|reblogs)/.test(S)?"desc":"asc";fe(N)}}),{createdAt:"Date",repliesCount:"Replies",favouritesCount:"Likes",reblogsCount:"Boosts",density:"Density"}[S],V===S&&(ve==="asc"?" ↑":" ↓")]},S))}),e("span",{class:"filter-label",children:"Group"})," ",e("fieldset",{class:"radio-field-group",children:la.map(S=>e("label",{class:"filter-group",children:[e("input",{type:"radio",name:"filter-group",checked:ne===S,onChange:()=>{me(S)},disabled:S==="account"&&A}),{account:"Authors"}[S]||"None"]},S||"none"))}),A&&Te.length>1?e("button",{type:"button",class:"plain6 small",onClick:()=>{P(null)},style:{whiteSpace:"nowrap"},children:"Show all authors"}):null]}),e("ul",{class:`catchup-list catchup-filter-${Jn[ee]||""} ${V?`catchup-sort-${V}`:""} ${A&&he[A]?"catchup-selected-author":""} ${ne?`catchup-group-${ne}`:""}`,children:Pe.map((S,N)=>{var K;const B=((K=S.reblog)==null?void 0:K.id)||S.id;let O=!1;return ne==="account"&&(Fe.current&&S.account.id!==Fe.current&&N>0&&(O=!0),Fe.current=S.account.id),e(_,{children:[O&&e("li",{class:"separator"}),e(fa,{to:`/${n}/s/${B}`,post:S,root:Ie.current})]},`${S.id}-${O}`)})}),e("footer",{children:ue.length>5&&e("p",{children:[ee==="Boosts"?"You don't have to read everything.":"That's all."," ",e("button",{type:"button",class:"textual",onClick:()=>{Ie.current.scrollTop=0},children:"Back to top"}),"."]})})]})]})]}),re&&e(Ae,{onClose:()=>D(!1),children:e("div",{class:"sheet",id:"catchup-help-sheet",children:[e("button",{type:"button",class:"sheet-close",onClick:()=>D(!1),children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Help"})}),e("main",{children:e("dl",{children:[e("dt",{children:"Top links"}),e("dd",{children:"Links shared by followings, sorted by shared counts, boosts and likes."}),e("dt",{children:"Sort: Density"}),e("dd",{children:'Posts are sorted by information density or depth. Shorter posts are "lighter" while longer posts are "heavier". Posts with photos are "heavier" than posts without photos.'}),e("dt",{children:"Group: Authors"}),e("dd",{children:"Posts are grouped by authors, sorted by posts count per author."}),e("dt",{children:"Keyboard shortcuts"}),e("dd",{children:[e("kbd",{children:"j"}),": Next post"]}),e("dd",{children:[e("kbd",{children:"k"}),": Previous post"]}),e("dd",{children:[e("kbd",{children:"l"}),": Next author"]}),e("dd",{children:[e("kbd",{children:"h"}),": Previous author"]}),e("dd",{children:[e("kbd",{children:"Enter"}),": Open post details"]}),e("dd",{children:[e("kbd",{children:"."}),": Scroll to top"]})]})})]})})]})}const pa=Je(function({post:t}){const{id:n,account:i,group:s,reblog:o,inReplyToId:a,inReplyToAccountId:h,_followedTags:d,_filtered:r,visibility:u,__BOOSTERS:f}=t,c=a&&h!==i.id,p=!!r,l=b=>{b.shiftKey};return e("article",{class:`post-line ${s?"group":o?"reblog":d!=null&&d.length?"followed-tags":""} ${c?"reply-to":""} ${p?"filtered":""} visibility-${u}`,onMouseEnter:l,children:[e("span",{class:"post-author",children:o?e("span",{class:"post-reblog-avatar",children:[e(st,{url:i.avatarStatic||i.avatar,squircle:i.bot}),(f==null?void 0:f.size)>0?[...f].map(b=>e(st,{url:b.avatarStatic||b.avatar,squircle:b.bot})):""," ",e(w,{icon:"rocket"})," ",e(It,{account:o.account,showAvatar:!0})]}):e(It,{account:i,showAvatar:!0})}),e(ba,{post:o||t,filterInfo:r}),e("span",{class:"post-meta",children:[e(ya,{post:o||t})," ",e(bt,{datetime:new Date((o==null?void 0:o.createdAt)||t.createdAt),format:"micro"})]})]})},(t,n)=>{var i,s;return((i=t==null?void 0:t.post)==null?void 0:i.id)===((s=n==null?void 0:n.post)==null?void 0:s.id)}),fa=({root:t,to:n,...i})=>{const s=z(),[o,a]=$(!1);return G(()=>{const h=new IntersectionObserver(d=>{d[0].isIntersecting&&(queueMicrotask(()=>a(!0)),h.unobserve(s.current))},{root:t,rootMargin:`${Math.max(320,screen.height*.75)}px`});return s.current&&h.observe(s.current),()=>{s.current&&h.unobserve(s.current)}},[]),o?e("li",{children:e(oe,{to:n,children:e(pa,{...i})})}):e("li",{ref:s,style:{height:"4em"}})},ma=8,ga=8;function Xn(t){var r;const{spoilerText:n,content:i,poll:s,mediaAttachments:o,card:a}=t,h=(r=s==null?void 0:s.options)!=null&&r.length?s.options.reduce((u,f)=>u+f.title,""):"";return(n.length+Cs(i)+h.length)/140+(o!=null&&o.length?ma*o.length:a!=null&&a.image?ga:0)}const ut=48;function ba({post:t,filterInfo:n}){var y;const{spoilerText:i,sensitive:s,content:o,emojis:a,poll:h,mediaAttachments:d,card:r,inReplyToId:u,inReplyToAccountId:f,account:c,_thread:p}=t,l=u&&f===c.id||!!p,b=pe(()=>!!(be.account.get("preferences")||{})["reading:expand:spoilers"],[]),m=b||!i&&!s,k=o?yn(t):"",g=!i||b;return e("div",{class:"post-peek",title:i?"":k,children:[e("span",{class:"post-peek-content",children:[l&&!g&&e(_,{children:[e("span",{class:"post-peek-tag post-peek-thread",children:"Thread"})," "]}),n?e("span",{class:"post-peek-filtered",children:["Filtered",n!=null&&n.titlesStr?`: ${n.titlesStr}`:""]}):e(_,{children:[!!i&&e("span",{class:"post-peek-spoiler",children:[e(w,{icon:`${b?"eye-open":"eye-close"}`})," ",i]}),g&&e("div",{class:"post-peek-html",children:[l&&e(_,{children:[e("span",{class:"post-peek-tag post-peek-thread",children:"Thread"})," "]}),!!o&&e("div",{dangerouslySetInnerHTML:{__html:Ti(o,a)}}),!!((y=h==null?void 0:h.options)!=null&&y.length)&&h.options.map(C=>e("div",{children:[h.multiple?"▪️":"•"," ",C.title]})),!o&&(d==null?void 0:d.length)===1&&d[0].description&&e(_,{children:[e("span",{class:"post-peek-tag post-peek-alt",children:"ALT"})," ",e("div",{children:d[0].description})]})]})]})]}),!n&&e("span",{class:"post-peek-post-content",children:[!!h&&e("span",{class:"post-peek-tag post-peek-poll",children:[e(w,{icon:"poll",size:"s"}),"Poll"]}),d!=null&&d.length?d.map(C=>{const v=C.previewUrl||C.url,I=C.previewRemoteUrl||C.remoteUrl;return e("span",{class:"post-peek-media",children:{image:(v||I)&&m?e("img",{src:v,width:ut,height:ut,alt:C.description,loading:"lazy",onError:x=>{const{src:L}=x.target;L===v&&(x.target.src=I)}}):e("span",{class:"post-peek-faux-media",children:"🖼"}),gifv:(v||I)&&m?e("img",{src:v,width:ut,height:ut,alt:C.description,loading:"lazy",onError:x=>{const{src:L}=x.target;L===v&&(x.target.src=I)}}):e("span",{class:"post-peek-faux-media",children:"🎞️"}),video:(v||I)&&m?e("img",{src:v,width:ut,height:ut,alt:C.description,loading:"lazy",onError:x=>{const{src:L}=x.target;L===v&&(x.target.src=I)}}):e("span",{class:"post-peek-faux-media",children:"📹"}),audio:e("span",{class:"post-peek-faux-media",children:"🎵"})}[C.type]||null},C.id)}):!!r&&r.image&&m&&e("span",{class:`post-peek-media post-peek-card card-${r.type||""}`,children:r.image?e("img",{src:r.image,width:ut,height:ut,alt:r.title||r.description||r.imageDescription,loading:"lazy"}):e("span",{class:"post-peek-faux-media",children:"🔗"})})]})]})}function ya({post:t}){const{reblogsCount:n,repliesCount:i,favouritesCount:s}=t;return e("span",{class:"post-stats",children:[i>0&&e("span",{class:"post-stat-replies",children:[e(w,{icon:"comment2",size:"s"})," ",Ge(i)]}),s>0&&e("span",{class:"post-stat-likes",children:[e(w,{icon:"heart",size:"s"})," ",Ge(s)]}),n>0&&e("span",{class:"post-stat-boosts",children:[e(w,{icon:"rocket",size:"s"})," ",Ge(n)]})]})}const{locale:wa}=new Intl.DateTimeFormat().resolvedOptions(),Ft=new Intl.DateTimeFormat(wa,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"});function va(t,n,i){const s=t.map(r=>new Date(r[n])),o=s.reduce((r,u)=>u<r?u:r,s[0]),h=s.reduce((r,u)=>u>r?u:r,s[0]).getTime()-o.getTime(),d=Array.from({length:i},()=>[]);return t.forEach(r=>{const f=(new Date(r[n]).getTime()-o.getTime())/h,c=Math.floor(f*(i-1));d[c].push(r)}),d}const ka=20;function Ns(){He("Likes","/f");const{masto:t,instance:n}=Q(),i=z();async function s(o){return(o||!i.current)&&(i.current=t.v1.favourites.list({limit:ka})),await i.current.next()}return e(dt,{title:"Likes",id:"favourites",emptyText:"No likes yet. Go like something!",errorText:"Unable to load likes",instance:n,fetchItems:s})}const Sa=["home","public","notifications","thread","account"],Qn=["notifications","thread","account"],Ia={home:"Home and lists",notifications:"Notifications",public:"Public timelines",thread:"Conversations",account:"Profiles"},Ca=[0,30*60,60*60,6*60*60,12*60*60,60*60*24,60*60*24*7,60*60*24*30],Ta={0:"Never",1800:"30 minutes",3600:"1 hour",21600:"6 hours",43200:"12 hours",86400:"24 hours",604800:"7 days",2592e3:"30 days"};function xa(){const{masto:t}=Q();He("Filters","/ft");const[n,i]=$("default"),[s,o]=$(!1),[a,h]=mt(u=>u+1,0),[d,r]=$([]);return G(()=>{i("loading"),(async()=>{try{const u=await t.v2.filters.list();u.sort((f,c)=>f.title.localeCompare(c.title)),u.forEach(f=>{var c;(c=f.keywords)!=null&&c.length&&f.keywords.sort((p,l)=>p.id-l.id)}),r(u),i("default")}catch{i("error")}})()},[a]),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(yt,{}),e(oe,{to:"/",class:"button plain",children:e(w,{icon:"home",size:"l"})})]}),e("h1",{children:"Filters"}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>{o(!0)},children:e(w,{icon:"plus",size:"l",alt:"New filter"})})})]})}),e("main",{children:d.length>0?e(_,{children:[e("ul",{class:"filters-list",children:d.map(u=>{const{id:f,title:c,expiresAt:p,keywords:l}=u;return e("li",{children:[e("div",{children:[e("h2",{children:c}),(l==null?void 0:l.length)>0&&e("div",{children:l.map(b=>e(_,{children:[e("span",{class:"tag collapsed insignificant",children:b.wholeWord?`${b.keyword}`:b.keyword})," "]}))}),e("small",{class:"insignificant",children:e(Us,{expiresAt:p})})]}),e("button",{type:"button",class:"plain",onClick:()=>{o({filter:u})},children:e(w,{icon:"pencil",size:"l",alt:"Edit filter"})})]},f)})}),d.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:[d.length," filter",d.length===1?"":"s"]})})]}):n==="loading"?e("p",{class:"ui-state",children:e($e,{})}):n==="error"?e("p",{class:"ui-state",children:"Unable to load filters."}):e("p",{class:"ui-state",children:"No filters yet."})})]}),!!s&&e(Ae,{title:"Add filter",onClose:()=>{o(!1)},children:e(Ra,{filter:s==null?void 0:s.filter,onClose:u=>{u.state==="success"&&h(),o(!1)}})})]})}let $a=1;const Aa=()=>$a++;function Ra({filter:t,onClose:n}){const{masto:i}=Q(),[s,o]=$("default"),a=!!t,{context:h,expiresAt:d,id:r,keywords:u,title:f,filterAction:c}=t||{},p=!!d,l=p&&new Date(d),[b,m]=$(u||[]),k=z(),[g,y]=$([]),[C,v]=$([]),I=b.filter(x=>!g.includes(x.id)&&!C.includes(x._id));return e("div",{class:"sheet",id:"filters-add-edit-modal",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:a?"Edit filter":"New filter"})}),e("main",{children:e("form",{onSubmit:x=>{x.preventDefault();const L=new FormData(x.target),Y=L.get("title"),j=L.getAll("keyword_attributes[][id]"),M=L.getAll("keyword_attributes[][keyword]"),ee=[...k.current.querySelectorAll('input[name="keyword_attributes[][whole_word]"]')].map(U=>U.checked),X=M.map((U,V)=>({id:j[V]||void 0,keyword:U,wholeWord:ee[V]}));a&&(g!=null&&g.length)&&g.forEach(U=>{X.push({id:U,_destroy:!0})});const A=L.getAll("context");let P=L.get("expires_in");const E=L.get("filter_action");!Y||!(A!=null&&A.length)||(o("loading"),(async()=>{try{let U;a?(P===""||P===null?p?P=Math.floor((l-new Date)/1e3):P=null:P==="0"||P===0?P=null:P=+P,U=await i.v2.filters.$select(r).update({title:Y,context:A,expiresIn:P,keywordsAttributes:X,filterAction:E})):(P=+P||null,U=await i.v2.filters.create({title:Y,context:A,expiresIn:P,keywordsAttributes:X,filterAction:E})),o("default"),n==null||n({state:"success",filter:U})}catch{o("error"),alert(a?"Unable to edit filter":"Unable to create filter")}})())},children:[e("div",{class:"filter-form-row",children:e("label",{children:[e("b",{children:"Title"}),e("input",{type:"text",name:"title",defaultValue:f,disabled:s==="loading",dir:"auto",required:!0})]})}),e("div",{class:"filter-form-keywords",ref:k,children:[I.length?e("ul",{class:"filter-keywords",children:I.map(x=>{const{id:L,keyword:Y,wholeWord:j,_id:M}=x;return e("li",{children:[e("input",{type:"hidden",name:"keyword_attributes[][id]",value:L}),e("input",{name:"keyword_attributes[][keyword]",type:"text",defaultValue:Y,disabled:s==="loading",required:!0}),e("div",{class:"filter-keyword-actions",children:[e("label",{children:[e("input",{name:"keyword_attributes[][whole_word]",type:"checkbox",value:L,defaultChecked:j,disabled:s==="loading"})," ","Whole word"]}),e("button",{type:"button",class:"light danger small",disabled:s==="loading",onClick:()=>{L?(g.push(L),y([...g])):M&&(C.push(M),v([...C]))},children:e(w,{icon:"x"})})]})]},`${L}-${M}`)})}):e("div",{class:"filter-keywords",children:e("div",{class:"insignificant",children:"No keywords. Add one."})}),e("footer",{class:"filter-keywords-footer",children:[e("button",{type:"button",class:"light",onClick:()=>{m([...b,{_id:Aa(),keyword:"",wholeWord:!0}]),setTimeout(()=>{var L,Y;const x=k.current.querySelectorAll('input[type="text"]');(Y=(L=x[x.length-1])==null?void 0:L.focus)==null||Y.call(L)},10)},children:"Add keyword"})," ",(I==null?void 0:I.length)>1&&e("small",{class:"insignificant",children:[I.length," keyword",I.length===1?"":"s"]})]})]}),e("div",{class:"filter-form-cols",children:[e("div",{class:"filter-form-col",children:[e("div",{children:e("b",{children:"Filter from…"})}),Sa.map(x=>e("div",{children:[e("label",{class:Qn.includes(x)?"insignificant":"",children:[e("input",{type:"checkbox",name:"context",value:x,defaultChecked:h?h.includes(x):!0,disabled:s==="loading"})," ",Ia[x],Qn.includes(x)?"*":""]})," "]})),e("p",{children:e("small",{class:"insignificant",children:"* Not implemented yet"})})]}),e("div",{class:"filter-form-col",children:[a&&e(_,{children:["Status:"," ",e("b",{children:e(Us,{expiresAt:d,showNeverExpires:!0})})]}),e("div",{children:[e("label",{for:"filters-expires_in",children:a?"Change expiry":"Expiry"}),e("select",{id:"filters-expires_in",name:"expires_in",disabled:s==="loading",defaultValue:a?void 0:0,children:[a&&e("option",{}),Ca.map(x=>e("option",{value:x,children:Ta[x]}))]})]}),e("p",{children:["Filtered post will be…",e("br",{}),e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"warn",defaultChecked:c==="warn"||!a,disabled:s==="loading"})," ","minimized"]})," ",e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"hide",defaultChecked:c==="hide",disabled:s==="loading"})," ","hidden"]})]})]})]}),e("footer",{class:"filter-form-footer",children:[e("span",{children:[e("button",{type:"submit",disabled:s==="loading",children:a?"Save":"Create"})," ",e($e,{abrupt:!0,hidden:s!=="loading"})]}),a&&e(et,{disabled:s==="loading",align:"end",menuItemClassName:"danger",confirmLabel:"Delete this filter?",onClick:()=>{o("loading"),(async()=>{try{await i.v2.filters.$select(r).remove(),o("default"),n==null||n({state:"success"})}catch{o("error"),alert("Unable to delete filter.")}})()},children:e("button",{type:"button",class:"light danger",onClick:()=>{},disabled:s==="loading",children:"Delete…"})})]})]})})]})}function Us({expiresAt:t,showNeverExpires:n}){const i=!!t,s=i&&new Date(t),o=i&&s<=new Date,[a,h]=mt(d=>d+1,0);return gn(h,o||3e4),o?"Expired":i?e(_,{children:["Expiring ",e(bt,{datetime:s})]}):n&&"Never expires"}function _a(){const{masto:t,instance:n}=Q();He("Followed Hashtags","/fh");const[i,s]=$("default"),[o,a]=$([]);return G(()=>{s("loading"),(async()=>{try{const h=await Kt();a(h),s("default")}catch{s("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(yt,{}),e(oe,{to:"/",class:"button plain",children:e(w,{icon:"home",size:"l"})})]}),e("h1",{children:"Followed Hashtags"}),e("div",{class:"header-side"})]})}),e("main",{children:o.length>0?e(_,{children:[e("ul",{class:"link-list",children:o.map(h=>e("li",{children:e(oe,{to:n?`/${n}/t/${h.name}`:`/t/${h.name}`,children:[e(w,{icon:"hashtag"})," ",e("span",{children:h.name})]})}))}),o.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:[o.length," hashtag",o.length===1?"":"s"]})})]}):i==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):i==="error"?e("p",{class:"ui-state",children:"Unable to load followed hashtags."}):e("p",{class:"ui-state",children:"No hashtags followed yet."})})]})})}const La=20;function Tn({title:t,path:n,id:i,...s}){He(t||"Following",n||"/following");const{masto:o,streaming:a,instance:h}=Q(),d=Me(T),r=z(),u=z(),f=je("@pixelfed/home-include-reblogs");async function c(l){var k;(l||!r.current)&&(r.current=o.v1.timelines.home.list({limit:La})),f&&((k=r.current)!=null&&k.nextParams)&&(typeof r.current.nextParams=="string"?r.current.nextParams+="&include_reblogs=true":r.current.nextParams.include_reblogs=!0);const b=await r.current.next();let{value:m}=b;if(m!=null&&m.length){let g=!1;l&&(m[0].id!==u.current&&(g=!0),u.current=m[0].id),m.forEach(y=>{qe(y,h)}),m=Wn(m,h),l&&g&&Vo(),Ps(m,h),m.sort((y,C)=>{const v=new Date(y.createdAt);return new Date(C.createdAt)-v})}return{...b,value:m}}async function p(){var l;try{const b={limit:5,since_id:u.current};je("@pixelfed/home-include-reblogs")&&(b.include_reblogs=!0);const m=await o.v1.timelines.home.list(b).next();let{value:k}=m;const g=((l=k[0])==null?void 0:l.id)===u.current;return!!(k!=null&&k.length&&!g&&(u.current=k[0].id,k=Wn(k,h),k=$t(k,"home"),k.some(y=>!y.reblog)))}catch{return!1}}return G(()=>{let l;return(async()=>{if(a){l=a.user.subscribe();for await(const b of l){if(!l)break;if(b.event==="status.update"){const m=b.payload;qe(m,h)}else if(b.event==="delete"){const m=b.payload,k=hs(m,h);k&&(k._deleted=!0)}}}})(),()=>{var b;(b=l==null?void 0:l.unsubscribe)==null||b.call(l),l=null}},[a]),e(dt,{title:t||"Following",id:i||"following",emptyText:"Nothing to see here.",errorText:"Unable to load posts.",instance:h,fetchItems:c,checkForUpdates:p,useItemID:!0,boostsCarousel:d.settings.boostsCarousel,...s,filterContext:"home",showFollowedTags:!0,showReplyParent:!0})}const Ea=20,Ma=4,es=Ma+1;function Fs({media:t,columnMode:n,...i}){let{hashtag:s,...o}=n?{}:gt();i.hashtag&&(s=i.hashtag);let a=s.trim().split(/[\s+]+/);a.sort(),s=a[0];const[h,d]=it(),r=t||!!h.get("media"),u=r?"?media=1":"",{masto:f,instance:c,authenticated:p}=Q({instance:(i==null?void 0:i.instance)||o.instance}),{masto:l,instance:b,authenticated:m}=Q(),k=a.map(A=>`#${A}`).join(" "),g=r?" (Media only)":"",y=c?`${k}${g} on ${c}`:`${k}${g}`;He(y,"/:instance?/t/:hashtag");const C=z(),v=pe(()=>hn(),[]),I=z(void 0);async function x(A){const P=await f.v1.timelines.tag.$select(s).list({limit:Ea,any:a.slice(1),maxId:A?void 0:I.current,onlyMedia:r?!0:void 0}).next();let{value:E}=P;return E!=null&&E.length&&(A&&(C.current=E[0].id),E.forEach(U=>{qe(U,c,{skipThreading:r||v})}),I.current=E[E.length-1].id),{...P,value:E}}async function L(){var A;try{const P=await f.v1.timelines.tag.$select(s).list({limit:1,any:a.slice(1),since_id:C.current,onlyMedia:r}).next();let{value:E}=P;const U=((A=E[0])==null?void 0:A.id)===C.current;return E!=null&&E.length&&!U?(E=$t(E,"public"),!0):!1}catch{return!1}}const[Y,j]=$("default"),[M,ee]=$();G(()=>{(async()=>{try{const A=await f.v1.tags.$select(s).fetch();ee(A)}catch{}})()},[s]);const X=a.length>=es;return e(dt,{title:y,titleComponent:!!c&&e("h1",{class:"header-double-lines",children:[e("b",{children:k}),e("div",{children:c})]}),id:"hashtag",instance:c,emptyText:"No one has posted anything with this tag yet.",errorText:"Unable to load posts with this tag",fetchItems:x,checkForUpdates:L,useItemID:!0,view:r||v?"media":void 0,refresh:r,filterContext:"public",headerEnd:e(Ze,{portal:!0,setDownOverflow:!0,overflow:"auto",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(w,{icon:"more",size:"l"})}),children:[!!M&&a.length===1&&e(_,{children:[e(et,{subMenu:!0,confirm:M.following,confirmLabel:`Unfollow #${s}?`,disabled:Y==="loading"||!p,onClick:()=>{j("loading"),M.following?f.v1.tags.$select(s).unfollow().then(()=>{ee({...M,following:!1}),se(`Unfollowed #${s}`)}).catch(A=>{alert(A)}).finally(()=>{j("default")}):f.v1.tags.$select(s).follow().then(()=>{ee({...M,following:!0}),se(`Followed #${s}`)}).catch(A=>{alert(A)}).finally(()=>{j("default")})},children:M.following?e(_,{children:[e(w,{icon:"check-circle"})," ",e("span",{children:"Following…"})]}):e(_,{children:[e(w,{icon:"plus"})," ",e("span",{children:"Follow"})]})}),e(ze,{})]}),!v&&e(_,{children:[e(gs,{className:"plain",children:"Filters"}),e(de,{type:"checkbox",checked:!!r,onClick:()=>{r?h.delete("media"):h.set("media","1"),d(h)},children:[e(w,{icon:"check-circle"})," ",e("span",{class:"menu-grow",children:"Media only"})]}),e(ze,{})]}),e(di,{className:"menu-field",disabled:X,children:({ref:A})=>e("form",{onSubmit:P=>{var U,V;P.preventDefault();const E=(V=(U=P.target[0].value)==null?void 0:U.trim)==null?void 0:V.call(U);E&&!a.some(ye=>ye.toLowerCase()===E.toLowerCase())&&(a.push(E),a.sort(),location.hash=c?`/${c}/t/${a.join("+")}`:`/t/${a.join("+")}${u}`)},children:[e(w,{icon:"hashtag"}),e("input",{ref:A,type:"text",placeholder:X?`Max ${es} tags`:"Add hashtag",required:!0,autocorrect:"off",autocapitalize:"off",spellCheck:!1,pattern:"[^#][^\\s#]+[^#]",disabled:X})]})}),e(ui,{takeOverflow:!0,children:a.map((A,P)=>e(de,{disabled:a.length===1,onClick:E=>{a.splice(P,1),a.sort(),location.hash=c?`/${c}/t/${a.join("+")}${u}`:`/t/${a.join("+")}${u}`},children:[e(w,{icon:"x",alt:"Remove hashtag",class:"danger-icon"}),e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),A]})]},A))}),e(ze,{}),e(de,{disabled:!m,onClick:()=>{if(T.shortcuts.length>=at){alert(`Max ${at} shortcuts reached. Unable to add shortcut.`);return}const A={type:"hashtag",hashtag:a.join(" "),instance:c,media:r?"on":void 0};T.shortcuts.some(E=>E.type===A.type&&E.hashtag.split(/[\s+]+/).sort().join(" ")===A.hashtag.split(/[\s+]+/).sort().join(" ")&&(E.instance?E.instance===A.instance:!0)&&(E.media?!!E.media==!!A.media:!0))?alert("This shortcut already exists"):(T.shortcuts.push(A),se("Hashtag shortcut added"))},children:[e(w,{icon:"shortcut"})," ",e("span",{children:"Add to Shorcuts"})]}),e(de,{onClick:()=>{let A=prompt('Enter a new instance e.g. "mastodon.social"');if(!/\./.test(A)){A&&alert("Invalid instance");return}A&&(A=A.toLowerCase().trim(),location.hash=`/${A}/t/${a.join("+")}${u}`)},children:[e(w,{icon:"bus"})," ",e("span",{children:"Go to another instance…"})]}),b!==c&&e(de,{onClick:()=>{location.hash=`/${b}/t/${a.join("+")}${u}`},children:[e(w,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:["Go to my instance (",e("b",{children:b}),")"]})]})]})},c+k)}const Pa=20;function Os(t){var g;const n=Me(T),{masto:i,instance:s}=Q(),o=(t==null?void 0:t.id)||((g=gt())==null?void 0:g.id),a=z(),h=z();async function d(y){(y||!h.current)&&(h.current=i.v1.timelines.list.$select(o).list({limit:Pa}));const C=await h.current.next();let{value:v}=C;return v!=null&&v.length&&(y&&(a.current=v[0].id),v.forEach(I=>{qe(I,s)})),{...C,value:v}}async function r(){var y;try{const C=await i.v1.timelines.list.$select(o).list({limit:1,since_id:a.current});let{value:v}=C;const I=((y=v[0])==null?void 0:y.id)===a.current;return v!=null&&v.length&&!I?(v=$t(v,"home"),!0):!1}catch{return!1}}const[u,f]=$([]);G(()=>{Pt().then(f)},[]);const[c,p]=$({title:"List"});He(c.title,"/l/:id"),G(()=>{(async()=>{try{const y=await As(o);p(y)}catch{}})()},[o]);const[l,b]=$(!1),[m,k]=$(!1);return e(_,{children:[e(dt,{title:c.title,id:"list",emptyText:"Nothing yet.",errorText:"Unable to load posts.",instance:s,fetchItems:d,checkForUpdates:r,useItemID:!0,boostsCarousel:n.settings.boostsCarousel,filterContext:"home",showReplyParent:!0,headerStart:e(Ze,{overflow:"auto",menuButton:e("button",{type:"button",class:"plain",children:[e(w,{icon:"list",size:"l",alt:"Lists"}),e(w,{icon:"chevron-down",size:"s"})]}),children:[e(Re,{to:"/l",children:e("span",{children:"All Lists"})}),(u==null?void 0:u.length)>0&&e(_,{children:[e(ze,{}),u.map(y=>e(Re,{to:`/l/${y.id}`,children:e("span",{children:y.title})},y.id))]})]}),headerEnd:e(Ze,{portal:!0,setDownOverflow:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(w,{icon:"more",size:"l"})}),children:[e(de,{onClick:()=>b({list:c}),children:[e(w,{icon:"pencil",size:"l"}),e("span",{children:"Edit"})]}),e(de,{onClick:()=>k(!0),children:[e(w,{icon:"group",size:"l"}),e("span",{children:"Manage members"})]})]})},o),l&&e(Ae,{onClick:y=>{y.target===y.currentTarget&&b(!1)},children:e(kn,{list:l==null?void 0:l.list,onClose:y=>{y.state==="success"&&y.list?p(y.list):y.state==="deleted"&&(location.hash="/l"),b(!1)}})}),m&&e(Ae,{onClick:y=>{y.target===y.currentTarget&&k(!1)},children:e(Na,{listID:o,onClose:()=>k(!1)})})]})}const Da=40;function Na({listID:t,onClose:n}){const{masto:i,instance:s}=Q(),[o,a]=$([]),[h,d]=$("default"),[r,u]=$(!1),f=z();async function c(p){u(!1),d("loading"),(async()=>{try{(p||!f.current)&&(f.current=i.v1.lists.$select(t).accounts.list({limit:Da}));const l=await f.current.next();let{done:b,value:m}=l;m!=null&&m.length?(a(p?m:o.concat(m)),u(!b)):u(!1),d("default")}catch{d("error")}})()}return G(()=>{c(!0)},[]),e("div",{class:"sheet",id:"list-manage-members-container",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Manage members"})}),e("main",{children:e("ul",{children:[o.map(p=>e("li",{children:[e(Xe,{account:p,instance:s}),e(Ua,{account:p,listID:t})]},p.id)),r&&h==="default"&&e(rt,{as:"li",onChange:p=>p&&c(),children:e("button",{type:"button",class:"light block",onClick:c,children:"Show more…"})})]})})]})}function Ua({account:t,listID:n}){const{masto:i}=Q(),[s,o]=$("default"),[a,h]=$(!1);return e(et,{confirm:!a,confirmLabel:e("span",{children:["Remove @",t.username," from list?"]}),align:"end",menuItemClassName:"danger",onClick:()=>{a?(o("loading"),(async()=>{try{await i.v1.lists.$select(n).accounts.create({accountIds:[t.id]}),o("default"),h(!1)}catch{o("error")}})()):(o("loading"),(async()=>{try{await i.v1.lists.$select(n).accounts.remove({accountIds:[t.id]}),o("default"),h(!0)}catch{o("error")}})())},children:e("button",{type:"button",class:`light ${a?"":"danger"}`,disabled:s==="loading",children:a?"Add":"Remove…"})})}const Fa={mention:["account","status"],status:["account","status"],reblog:["account","status"],follow:["account"],follow_request:["account"],favourite:["account","status"],poll:["status"],update:["status"]};function zs(t){return t.filter(n=>{const{type:i,id:s,createdAt:o}=n;if(!i)return!1;const a=Fa[i];return a!=null&&a.length?a.every(h=>!!n[h]):!0})}function Bs(t){t=zs(t);const n={},i=[];for(let a=0,h=0;a<t.length;a++){const d=t[a],{id:r,status:u,account:f,type:c,createdAt:p}=d,l=p?new Date(p).toLocaleDateString():"";let b=c;(c==="favourite"||c==="reblog")&&(b="favourite+reblog");const m=`${u==null?void 0:u.id}-${b}-${l}`,k=n[m];if(b==="follow_request")i[h++]=d;else if(k!=null&&k.account){const g=k._accounts.find(y=>y.id===f.id);g?(g._types.push(c),g._types.sort().reverse(),k.id+=`-${r}`):(f._types=[c],k._accounts.push(f),k.id+=`-${r}`)}else{f&&(f._types=[c]);let g=n[m]={...d,type:b,_accounts:f?[f]:[]};i[h++]=g}}const s={},o=[];for(let a=0,h=0;a<i.length;a++){const d=i[a],{id:r,account:u,_accounts:f,type:c,createdAt:p}=d,l=p?new Date(p).toLocaleDateString():"";if(c==="favourite+reblog"&&u&&f.length===1){const b=`${u==null?void 0:u.id}-${c}-${l}`,m=s[b];if(m)m._statuses.push(d.status),m.id+=`-${r}`;else{let k=s[b]={...d,type:c,_statuses:[d.status]};o[h++]=k}}else o[h++]=d}return o}const ts=20,Oa=new URLSearchParams;function qs({columnMode:t,...n}){const{masto:i,instance:s}=Q(),[o]=t?[Oa]:it(),[a,h]=$(null),d=(n==null?void 0:n.type)||o.get("type")||a;He(`Mentions${d==="private"?" (Private)":""}`,"/mentions");const r=z(),u=z();async function f(g){(g||!r.current)&&(r.current=i.v1.notifications.list({limit:ts,types:["mention"]}));const y=await r.current.next();let{value:C}=y;return C!=null&&C.length&&(C=zs(C),g&&(u.current=C[0].id),C.forEach(({status:v})=>{qe(v,s)})),{...y,value:C==null?void 0:C.map(v=>v.status)}}const c=z(),p=z();async function l(g){(g||!c.current)&&(c.current=i.v1.conversations.list({limit:ts}));const y=await c.current.next();let{value:C}=y;return C=C==null?void 0:C.filter(v=>v.lastStatus),C!=null&&C.length&&(g&&(p.current=C[0].lastStatus.id),C.forEach(({lastStatus:v})=>{qe(v,s)})),{...y,value:C==null?void 0:C.map(v=>v.lastStatus)}}function b(...g){return d==="private"?l(...g):f(...g)}async function m(){var g;if(d==="private")try{const y=await i.v1.conversations.list({limit:1,since_id:p.current}).next();let{value:C}=y;const v=((g=C[0])==null?void 0:g.id)===p.current;return C!=null&&C.length&&!v?(p.current=C[0].lastStatus.id,!0):!1}catch{return!1}else try{const y=await i.v1.notifications.list({limit:1,types:["mention"],since_id:u.current}).next();let{value:C}=y;return C!=null&&C.length?(u.current=C[0].id,!0):!1}catch{return!1}}const k=pe(()=>e("div",{class:"filter-bar centered",children:[e(oe,{to:"/mentions",class:d?"":"is-active",onClick:g=>{t&&(g.preventDefault(),h(null))},children:"All"}),e(oe,{to:"/mentions?type=private",class:d==="private"?"is-active":"",onClick:g=>{t&&(g.preventDefault(),h("private"))},children:"Private"})]}),[d]);return e(dt,{title:"Mentions",id:"mentions",emptyText:"No one mentioned you :(",errorText:"Unable to load mentions.",instance:s,fetchItems:b,checkForUpdates:m,useItemID:!0,timelineStart:k,refresh:d})}const za=80,Ba=new URLSearchParams,Ot={block:"center",inline:"center",behavior:"smooth"};function qa({columnMode:t}){var re;He("Notifications","/notifications");const{masto:n,instance:i}=Q(),s=Me(T),[o,a]=$("default"),[h]=t?[Ba]:it(),d=h.get("id"),r=h.get("access_token"),[u,f]=$(!1),[c,p]=$(!1),l=z(),{nearReachEnd:b,scrollDirection:m,reachStart:k,nearReachStart:g}=Go({scrollableRef:l}),y=m==="end"&&!g,[C,v]=$([]),[I,x]=$([]),L=z();async function Y(D){var q;if((D||!L.current)&&(L.current=n.v1.notifications.list({limit:za,excludeTypes:["follow_request"]})),/max_id=($|&)/i.test((q=L.current)==null?void 0:q.nextParams))return{done:!0};const W=await L.current.next(),R=W.value;if(R!=null&&R.length){R.forEach(ce=>{qe(ce.status,i,{skipThreading:!0})});const Z=Bs(R);D?(T.notificationsLast=R[0],T.notifications=Z,n.v1.markers.create({notifications:{lastReadId:R[0].id}}).catch(()=>{})):T.notifications.push(...Z)}return T.notificationsShowNew=!1,T.notificationsLastFetchTime=Date.now(),W}async function j(){try{return await n.v1.followRequests.list({limit:80})}catch{return[]}}const M=()=>{a("loading"),(async()=>{try{const D=await j();v(D),a("default")}catch{a("error")}})()};async function ee(){try{return await n.v1.announcements.list()}catch{return[]}}const X=je("@mastodon/filtered-notifications"),[A,P]=$(!1),[E,U]=$({});function V(){return n.v1.notifications.policy.fetch().catch(()=>{})}function ye(){V().then(D=>{U(D)}).catch(()=>{})}const[ve,fe]=$(null);function ne(){return n.v1.notifications.requests.list()}const me=D=>{he(!1),a("loading"),(async()=>{try{const W=Y(D);D&&(ee().then(q=>{q.sort((Z,ce)=>{const De=new Date(Z.updatedAt||Z.createdAt);return new Date(ce.updatedAt||ce.createdAt)-De}),x(q)}).catch(()=>{}),j().then(q=>{v(q)}).catch(()=>{}),X&&ye());const{done:R}=await W;f(!R),a("default")}catch{a("error")}})()};G(()=>{me(!0)},[]),G(()=>{k&&me(!0)},[k]);const[ue,he]=$(!1),ke=Qe(({disableIdleCheck:D=!1}={})=>{var W;o!=="loading"&&s.settings.autoRefresh&&((W=l.current)==null?void 0:W.scrollTop)<16&&(D||window.__IDLE__)&&!Ha()&&me(!0)},[s.notificationsShowNew,s.settings.autoRefresh,o]),Le=z();Ct(D=>{if(D){const W=Date.now()-Le.current;!Le.current||W>1e3*3?ke({disableIdleCheck:!0}):Le.current=Date.now()}});const Te=z(!0);G(()=>{let D=hi(T,"notificationsShowNew",W=>{if(Te.current){Te.current=!1;return}o!=="loading"&&(W&&ke(),he(W))});return()=>D==null?void 0:D()},[]);const Pe=new Date,Fe=new Date(Pe-24*60*60*1e3);let xe=new Date;const J=!s.notifications.some(D=>new Date(D.createdAt).toDateString()===Pe.toDateString()),ae=z();G(()=>{d&&(T.routeNotification={id:d,accessToken:atob(r)})},[d,r]);const te=".notification",Se=_e("j",()=>{const D=document.activeElement.closest(te),W=D==null?void 0:D.getBoundingClientRect(),R=Array.from(l.current.querySelectorAll(te));if(D&&W.top<l.current.clientHeight&&W.bottom>0){const q=R.indexOf(D);let Z=R[q+1];Z&&(Z.focus(),Z.scrollIntoView(Ot))}else{const q=R.find(Z=>{const ce=Z.getBoundingClientRect();return ce.top>=44&&ce.left>=0});q&&(q.focus(),q.scrollIntoView(Ot))}}),Ie=_e("k",()=>{const D=document.activeElement.closest(te),W=D==null?void 0:D.getBoundingClientRect(),R=Array.from(l.current.querySelectorAll(te));if(D&&W.top<l.current.clientHeight&&W.bottom>0){const q=R.indexOf(D);let Z=R[q-1];Z&&(Z.focus(),Z.scrollIntoView(Ot))}else{const q=R.find(Z=>{const ce=Z.getBoundingClientRect();return ce.top>=44&&ce.left>=0});q&&(q.focus(),q.scrollIntoView(Ot))}}),F=_e(["enter","o"],()=>{const D=document.activeElement.closest(te),W=D==null?void 0:D.querySelector(".status-link");W&&W.click()});return e("div",{id:"notifications-page",class:"deck-container",ref:D=>{l.current=D,Se.current=D,Ie.current=D,F.current=D},tabIndex:"-1",children:[e("div",{class:`timeline-deck deck ${c?"only-mentions":""}`,children:[e("header",{hidden:y,onClick:D=>{var W;D.target.closest("a, button")||(W=l.current)==null||W.scrollTo({top:0,behavior:"smooth"})},onDblClick:D=>{D.target.closest("a, button")||me(!0)},class:o==="loading"?"loading":"",children:[e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(yt,{}),e(oe,{to:"/",class:"button plain",children:e(w,{icon:"home",size:"l",alt:"Home"})})]}),e("h1",{children:"Notifications"}),e("div",{class:"header-side",children:X&&e("button",{type:"button",class:"button plain4",onClick:()=>{P(!0)},children:e(w,{icon:"settings",size:"l",alt:"Notifications settings"})})})]}),ue&&o!=="loading"&&e("button",{class:"updates-button shiny-pill",type:"button",onClick:()=>{var D;me(!0),(D=l.current)==null||D.scrollTo({top:0,behavior:"smooth"})},children:[e(w,{icon:"arrow-up"})," New notifications"]})]}),I.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(w,{icon:"announce",class:"announcement-icon",size:"l"})," ",e("b",{children:["Announcement",I.length>1?"s":""]})," ",e("small",{class:"insignificant",children:i})]}),I.length>1&&e("span",{class:"announcements-nav-buttons",children:I.map((D,W)=>e("button",{type:"button",class:"plain2 small",onClick:()=>{var R;(R=ae.current)==null||R.children[W].scrollIntoView({behavior:"smooth",block:"nearest"})},children:W+1}))})]}),e("ul",{class:`announcements-list-${I.length>1?"multiple":"single"}`,ref:ae,children:I.map(D=>e("li",{children:e(Va,{announcement:D})}))})]})})}),C.length>0&&e("div",{class:"follow-requests",children:[e("h2",{class:"timeline-header",children:"Follow requests"}),C.length>5?e("details",{children:[e("summary",{children:[C.length," follow requests"]}),e("ul",{children:C.map(D=>e("li",{children:[e(Xe,{account:D}),e(rn,{accountID:D.id,onChange:()=>{}})]},D.id))})]}):e("ul",{children:C.map(D=>e("li",{children:[e(Xe,{account:D}),e(rn,{accountID:D.id,onChange:()=>{}})]},D.id))})]}),X&&((re=E==null?void 0:E.summary)==null?void 0:re.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 D=>{const{open:W}=D.target;if(W){const R=await ne();fe(R)}},children:[e("summary",{children:["Filtered notifications from"," ",E.summary.pendingRequestsCount," people"]}),ve?(ve==null?void 0:ve.length)>0&&e("ul",{children:ve.map(D=>{var W,R;return e("li",{children:[e("div",{class:"request-notifcations",children:[!((W=D.lastStatus)!=null&&W.id)&&e(Xe,{useAvatarStatic:!0,showStats:!0,account:D.account}),((R=D.lastStatus)==null?void 0:R.id)&&e("div",{class:"last-post",children:e(oe,{class:"status-link",to:`/${i}/s/${D.lastStatus.id}`,children:e(Be,{status:D.lastStatus,size:"s",readOnly:!0})})}),e(Ya,{request:D})]}),e(ja,{request:D,onChange:()=>{me(!0)}})]},D.id)})}):e("p",{class:"ui-state",children:e($e,{abrupt:!0})})]})})})}),e("div",{id:"mentions-option",children:e("label",{children:[e("input",{type:"checkbox",checked:c,onChange:D=>{p(D.target.checked)}})," ","Only mentions"]})}),e("h2",{class:"timeline-header",children:"Today"}),J&&e("p",{class:"ui-state insignificant",children:o==="default"?"You're all caught up.":e(_,{children:"…"})}),s.notifications.length?e(_,{children:s.notifications.filter(D=>D.type!=="follow_request").map(D=>{if(c&&D.type!=="mention")return null;const W=new Date(D.createdAt),R=W.toDateString()!==xe.toDateString();R&&(xe=W);const q=W.toDateString()===Fe.toDateString()?"Yesterday":ot(xe,{hideTime:!0});return e(_,{children:[R&&e("h2",{class:"timeline-header",children:q}),e(Xt,{instance:i,notification:D},D.id)]},D.id)})}):e(_,{children:[o==="loading"&&e(_,{children:e("ul",{class:"timeline flat",children:Array.from({length:5}).map((D,W)=>e("li",{class:"notification skeleton",children:[e("div",{class:"notification-type",children:e(w,{icon:"notification",size:"xl"})}),e("div",{class:"notification-content",children:e("p",{children:"███████████ ████"})})]}))})}),o==="error"&&e("p",{class:"ui-state",children:["Unable to load notifications",e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>me(!0),children:"Try again"})]})]}),u&&e(rt,{onChange:D=>{D&&me()},children:e("button",{type:"button",class:"plain block",disabled:o==="loading",onClick:()=>me(),style:{marginBlockEnd:"6em"},children:o==="loading"?e($e,{abrupt:!0}):e(_,{children:"Show more…"})})})]}),X&&A&&e(Ae,{onClick:D=>{D.target===D.currentTarget&&P(!1)},children:e("div",{class:"sheet",id:"notifications-settings",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:()=>P(!1),children:e(w,{icon:"x"})}),e("header",{children:e("h2",{children:"Notifications settings"})}),e("main",{children:e("form",{onSubmit:D=>{D.preventDefault();const{filterNotFollowing:W,filterNotFollowers:R,filterNewAccounts:q,filterPrivateMentions:Z}=D.target,ce={filterNotFollowing:W.checked,filterNotFollowers:R.checked,filterNewAccounts:q.checked,filterPrivateMentions:Z.checked};U({...E,...ce}),P(!1),(async()=>{try{await n.v1.notifications.policy.update(ce),se("Notifications settings updated")}catch{}})()},children:[e("p",{children:"Filter out notifications from people:"}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:E.filterNotFollowing,name:"filterNotFollowing"})," ","You don't follow"]})}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:E.filterNotFollowers,name:"filterNotFollowers"})," ","Who don't follow you"]})}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:E.filterNewAccounts,name:"filterNewAccounts"})," ","With a new account"]})}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:E.filterPrivateMentions,name:"filterPrivateMentions"})," ","Who unsolicitedly private mention you"]})}),e("p",{children:e("button",{type:"submit",children:"Save"})})]})})]})})]})}function Ha(){return!!document.querySelector(".deck-backdrop, #modal-container > *")}function Va({announcement:t}){const{instance:n}=Q(),{contact:i}=us(),s=i==null?void 0:i.account,{id:o,content:a,startsAt:h,endsAt:d,published:r,allDay:u,publishedAt:f,updatedAt:c,read:p,mentions:l,statuses:b,tags:m,emojis:k,reactions:g}=t,y=new Date(f),C=ot(y),v=new Date(c),I=ot(v);return e("div",{class:"announcement-block",children:[e(Xe,{account:s}),e("div",{class:"announcement-content",onClick:ws({mentions:l,instance:n}),dangerouslySetInnerHTML:{__html:on(a,{emojis:k})}}),e("p",{class:"insignificant",children:[e("time",{datetime:y.toISOString(),children:ot(y)}),c&&I!==C&&e(_,{children:[" ","•"," ",e("span",{class:"ib",children:["Updated"," ",e("time",{datetime:v.toISOString(),children:ot(v)})]})]})]}),e("div",{class:"announcement-reactions",hidden:!0,children:g.map(x=>{const{name:L,count:Y,me:j,staticUrl:M,url:ee}=x;return e("button",{type:"button",class:`plain4 small ${j?"reacted":""}`,children:[ee||M?e("img",{src:ee||M,alt:L,width:"16",height:"16"}):e("span",{children:L})," ",e("span",{class:"count",children:Ge(Y)})]})})})]})}function Ga(t){const{masto:n}=Q();return n.v1.notifications.list({accountID:t})}function Ya({request:t}){var c;const{instance:n}=Q(),[i,s]=$("loading"),{account:o,lastStatus:a}=t,[h,d]=$(!1),[r,u]=$([]);function f(){d(!1)}return G(()=>{var p;(p=t==null?void 0:t.account)!=null&&p.id&&h&&(s("loading"),(async()=>{const l=await Ga(t.account.id);u(l||[]),s("default")})())},[h,(c=t==null?void 0:t.account)==null?void 0:c.id]),e(_,{children:[e("button",{type:"button",class:"plain4 request-notifications-account",onClick:()=>{d(!0)},children:[e(w,{icon:"notification",class:"more-insignificant"})," ",e("small",{children:["View notifications from @",o.username]})," ",e(w,{icon:"chevron-down"})]}),h&&e(Ae,{onClick:p=>{p.target===p.currentTarget&&f()},children:e("div",{class:"sheet",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:f,children:e(w,{icon:"x"})}),e("header",{children:e("b",{children:["Notifications from @",o.username]})}),e("main",{children:i==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):r.map(p=>e("div",{class:"notification-peek",onClick:l=>{const{target:b}=l;(l.target.tagName==="BUTTON"||l.target.tagName==="A")&&f()},children:e(Xt,{instance:n,notification:p,isStatic:!0})}))})]})})]})}function ja({request:t,onChange:n}){const{masto:i}=Q(),[s,o]=$("default"),[a,h]=$(null),d=a!==null;return e("p",{class:"notification-request-buttons",children:[e("button",{type:"button",disabled:s==="loading"||d,onClick:()=>{o("loading"),(async()=>{try{await i.v1.notifications.requests.$select(t.id).accept(),h("accept"),o("default"),n({request:t,state:"accept"}),se(`Notifications from @${t.account.username} will not be filtered from now on.`)}catch{o("error"),se("Unable to accept notification request")}})()},children:"Allow"})," ",e("button",{type:"button",disabled:s==="loading"||d,class:"light danger",onClick:()=>{o("loading"),(async()=>{try{await i.v1.notifications.requests.$select(t.id).dismiss(),h("dismiss"),o("default"),n({request:t,state:"dismiss"}),se(`Notifications from @${t.account.username} will not show up in Filtered notifications from now on.`)}catch{o("error"),se("Unable to dismiss notification request")}})()},children:"Dismiss"}),e("span",{class:"notification-request-states",children:s==="loading"?e($e,{abrupt:!0}):a==="accept"?e(w,{icon:"check-circle",alt:"Accepted",class:"notification-accepted"}):a==="dismiss"&&e(w,{icon:"x-circle",alt:"Dismissed",class:"notification-dismissed"})})]})}const Hs=Je(qa),Wa=20;function ln({local:t,columnMode:n,...i}){const s=Me(T),o=!!t,a=n?{}:gt(),{masto:h,instance:d}=Q({instance:(i==null?void 0:i.instance)||a.instance}),{masto:r,instance:u}=Q(),f=`${o?"Local":"Federated"} timeline (${d})`;He(f,o?"/:instance?/p/l":"/:instance?/p");const c=z(),p=z();async function l(m){(m||!p.current)&&(p.current=h.v1.timelines.public.list({limit:Wa,local:o,remote:!o}));const k=await p.current.next();let{value:g}=k;return g!=null&&g.length&&(m&&(c.current=g[0].id),g.forEach(y=>{qe(y,d)})),{...k,value:g}}async function b(){var m;try{const k=await h.v1.timelines.public.list({limit:1,local:o,since_id:c.current}).next();let{value:g}=k;const y=((m=g[0])==null?void 0:m.id)===c.current;return g!=null&&g.length&&!y?(g=$t(g,"public"),!0):!1}catch{return!1}}return e(dt,{title:f,titleComponent:e("h1",{class:"header-double-lines",children:[e("b",{children:o?"Local timeline":"Federated timeline"}),e("div",{children:d})]}),id:"public",instance:d,emptyText:"No one has posted anything yet.",errorText:"Unable to load posts",fetchItems:l,checkForUpdates:b,useItemID:!0,headerStart:e(_,{}),boostsCarousel:s.settings.boostsCarousel,filterContext:"public",headerEnd:e(Ze,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(w,{icon:"more",size:"l"})}),children:[e(de,{href:o?`/#/${d}/p`:`/#/${d}/p/l`,children:o?e(_,{children:[e(w,{icon:"transfer"})," ",e("span",{children:"Switch to Federated"})]}):e(_,{children:[e(w,{icon:"transfer"})," ",e("span",{children:"Switch to Local"})]})}),e(ze,{}),e(de,{onClick:()=>{let m=prompt('Enter a new instance e.g. "mastodon.social"');if(!/\./.test(m)){m&&alert("Invalid instance");return}m&&(m=m.toLowerCase().trim(),location.hash=o?`/${m}/p/l`:`/${m}/p`)},children:[e(w,{icon:"bus"})," ",e("span",{children:"Go to another instance…"})]}),u!==d&&e(de,{onClick:()=>{location.hash=o?`/${u}/p/l`:`/${u}/p`},children:[e(w,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:["Go to my instance (",e("b",{children:u}),")"]})]})]})},d+o)}const zt=5,sn=40,Ka=new URLSearchParams;function Vs({columnMode:t,...n}){const i=t?{}:gt(),{masto:s,instance:o,authenticated:a}=Q({instance:i.instance}),[h,d]=$("default"),[r]=t?[Ka]:it(),u=z(),f=(n==null?void 0:n.query)||r.get("q"),c=t?"statuses":(n==null?void 0:n.type)||r.get("type");He(f?`Search: ${f}${c?` (${{statuses:"Posts",accounts:"Accounts",hashtags:"Hashtags"}[c]})`:""}`:"Search","/search");const[p,l]=$(!1),b=z(0);G(()=>{b.current=0},[f,c]);const m=z();lt(()=>{var A,P;(P=(A=m.current)==null?void 0:A.scrollTo)==null||P.call(A,0,0)},[f,c]);const[k,g]=$([]),[y,C]=$([]),[v,I]=$([]);G(()=>{g([]),C([]),I([])},[f]);const x={statuses:g,accounts:C,hashtags:I},[L,Y]=$({}),j=async A=>{if(!(A!=null&&A.length))return;const P=await bn(A,L);P&&Y({...L,...P})};function M(A){A&&(b.current=0),!(!A&&!a)&&(d("loading"),A&&!c&&(g(k.slice(0,zt)),C(y.slice(0,zt)),I(v.slice(0,zt))),(async()=>{var E,U;const P={q:f,resolve:a,limit:zt};c&&(P.limit=sn,P.type=c,a&&(P.offset=b.current));try{const V=await s.v2.search.fetch(P);if(c)if(A){x[c](V[c]);const ye=(E=V[c])==null?void 0:E.length;b.current=sn,l(!!ye)}else{x[c](ve=>[...ve,...V[c]]);const ye=(U=V[c])==null?void 0:U.length;b.current=b.current+sn,l(!!ye)}else g(V.statuses||[]),C(V.accounts||[]),I(V.hashtags||[]),b.current=0,l(!1);j(V.accounts),d("default")}catch{d("error")}})())}const ee=z();Ct(A=>{var E;const P=((E=m.current)==null?void 0:E.scrollTop)===0;if(A&&P){const U=Date.now()-ee.current;!ee.current||U>1e3*3?M(!0):ee.current=Date.now()}}),G(()=>{var A,P,E,U;(P=(A=u.current)==null?void 0:A.setValue)==null||P.call(A,f||""),f?M(!0):(U=(E=u.current)==null?void 0:E.focus)==null||U.call(E)},[f,c,o]),_e(["/","Slash"],A=>{var P,E,U,V;(E=(P=u.current)==null?void 0:P.focus)==null||E.call(P),(V=(U=u.current)==null?void 0:U.select)==null||V.call(U)},{preventDefault:!0});const[X]=pn();return e("div",{id:"search-page",class:"deck-container",ref:m,children:e("div",{class:"timeline-deck deck",children:[e("header",{class:h==="loading"?"loading":"",children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:e(yt,{})}),e(Ms,{ref:u}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>{M(!0)},disabled:h==="loading",children:e(w,{icon:"search",size:"l"})})})]})}),e("main",{children:[!!f&&!t&&e("div",{ref:X,class:`filter-bar ${h==="loading"?"loading":""}`,children:[!!c&&e(oe,{to:`/search${f?`?q=${encodeURIComponent(f)}`:""}`,children:" All"}),[{label:"Accounts",type:"accounts",to:`/search?q=${encodeURIComponent(f)}&type=accounts`},{label:"Hashtags",type:"hashtags",to:`/search?q=${encodeURIComponent(f)}&type=hashtags`},{label:"Posts",type:"statuses",to:`/search?q=${encodeURIComponent(f)}&type=statuses`}].sort((A,P)=>A.type===c?-1:P.type===c?1:0).map(A=>e(oe,{to:A.to,children:A.label},A.type))]}),f?e(_,{children:[(!c||c==="accounts")&&e(_,{children:[c!=="accounts"&&e("h2",{class:"timeline-header",children:["Accounts"," ",e(oe,{to:`/search?q=${encodeURIComponent(f)}&type=accounts`,children:e(w,{icon:"arrow-right",size:"l"})})]}),y.length>0?e(_,{children:[e("ul",{class:"timeline flat accounts-list",children:y.map(A=>e("li",{children:e(Xe,{account:A,instance:o,showStats:!0,relationship:L[A.id]})},A.id))}),c!=="accounts"&&e("div",{class:"ui-state",children:e(oe,{class:"plain button",to:`/search?q=${encodeURIComponent(f)}&type=accounts`,children:["See more accounts ",e(w,{icon:"arrow-right"})]})})]}):!c&&(h==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):e("p",{class:"ui-state",children:"No accounts found."}))]}),(!c||c==="hashtags")&&e(_,{children:[c!=="hashtags"&&e("h2",{class:"timeline-header",children:["Hashtags"," ",e(oe,{to:`/search?q=${encodeURIComponent(f)}&type=hashtags`,children:e(w,{icon:"arrow-right",size:"l"})})]}),v.length>0?e(_,{children:[e("ul",{class:"link-list hashtag-list",children:v.map(A=>{var V;const{name:P,history:E}=A,U=(V=E==null?void 0:E.reduce)==null?void 0:V.call(E,(ye,ve)=>ye+ +ve.uses,0);return e("li",{children:e(oe,{to:o?`/${o}/t/${P}`:`/t/${P}`,children:[e(w,{icon:"hashtag"}),e("span",{children:P}),!!U&&e("span",{class:"count",children:Ge(U)})]})},`${P}-${U}`)})}),c!=="hashtags"&&e("div",{class:"ui-state",children:e(oe,{class:"plain button",to:`/search?q=${encodeURIComponent(f)}&type=hashtags`,children:["See more hashtags ",e(w,{icon:"arrow-right"})]})})]}):!c&&(h==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):e("p",{class:"ui-state",children:"No hashtags found."}))]}),(!c||c==="statuses")&&e(_,{children:[c!=="statuses"&&e("h2",{class:"timeline-header",children:["Posts"," ",e(oe,{to:`/search?q=${encodeURIComponent(f)}&type=statuses`,children:e(w,{icon:"arrow-right",size:"l"})})]}),k.length>0?e(_,{children:[e("ul",{class:"timeline",children:k.map(A=>e("li",{children:e(oe,{class:"status-link",to:o?`/${o}/s/${A.id}`:`/s/${A.id}`,children:e(Be,{status:A})})},A.id))}),c!=="statuses"&&e("div",{class:"ui-state",children:e(oe,{class:"plain button",to:`/search?q=${encodeURIComponent(f)}&type=statuses`,children:["See more posts ",e(w,{icon:"arrow-right"})]})})]}):!c&&(h==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):e("p",{class:"ui-state",children:"No posts found."}))]}),!!c&&(h==="default"?p?e(rt,{onChange:A=>{A&&M()},children:e("button",{type:"button",class:"plain block",onClick:()=>M(),style:{marginBlockEnd:"6em"},children:"Show more…"})}):e("p",{class:"ui-state insignificant",children:"The end."}):h==="loading"&&e("p",{class:"ui-state",children:e($e,{abrupt:!0})}))]}):h==="loading"?e("p",{class:"ui-state",children:e($e,{abrupt:!0})}):e("p",{class:"ui-state",children:"Enter your search term or paste a URL above to get started."})]})]})})}const Za=20,Ja=ht(t=>t.v1.trends.links.list().next(),{maxAge:10*60*1e3});function Xa(t){return je("@pixelfed/trending")?t.pixelfed.v2.discover.posts.trending.list({range:"daily"}):t.v1.trends.statuses.list({limit:Za})}function Gs({columnMode:t,...n}){const i=Me(T),s=t?{}:gt(),{masto:o,instance:a}=Q({instance:(n==null?void 0:n.instance)||s.instance}),{masto:h,instance:d}=Q(),r=`Trending (${a})`;He(r,"/:instance?/trending");const u=z(),[f,c]=$([]),[p,l]=$([]),b=z();async function m(y){var I;if(y||!b.current){if(b.current=Xa(o),je("@mastodon/trending-hashtags"))try{const x=o.v1.trends.tags.list(),{value:L}=await x.next();L!=null&&L.length&&c(L)}catch{}if(je("@mastodon/trending-links"))try{const{value:x}=await Ja(o,a),L=(I=x==null?void 0:x.filter)==null?void 0:I.call(x,Y=>Y.type==="link");L!=null&&L.length&&l(L)}catch{}}const C=await b.current.next();let{value:v}=C;return v!=null&&v.length&&(y&&(u.current=v[0].id),v.forEach(x=>{qe(x,a)})),{...C,value:v}}async function k(){try{const y=await o.v1.trends.statuses.list({limit:1}).next();let{value:C}=y;return C=$t(C,"public"),C!=null&&C.length&&C[0].id!==u.current?(u.current=C[0].id,!0):!1}catch{return!1}}const g=pe(()=>e(_,{children:[!!f.length&&e("div",{class:"filter-bar expandable",children:[e(w,{icon:"chart",class:"insignificant",size:"l"}),f.map((y,C)=>{const{name:v,history:I}=y,x=I.reduce((L,Y)=>L+ +Y.uses,0);return e(oe,{to:`/${a}/t/${v}`,children:[e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),v]}),e("span",{class:"filter-count",children:Ge(x)})]},v)})]}),!!p.length&&e("div",{class:"links-bar",children:[e("header",{children:e("h3",{children:"Trending News"})}),p.map(y=>{const{authorName:C,authorUrl:v,blurhash:I,description:x,height:L,image:Y,imageDescription:j,language:M,providerName:ee,providerUrl:X,publishedAt:A,title:P,url:E,width:U}=y,V=xt.toUnicode(new URL(E).hostname.replace(/^www\./,"").replace(/\/$/,""));let ye;if(I){const ve=fn(I),fe=Sn(ve);ye=In([.6,fe[1],fe[2]])}return e("a",{href:E,target:"_blank",rel:"noopener noreferrer",style:ye?{"--accent-color":`rgb(${ye.join(",")})`,"--accent-alpha-color":`rgba(${ye.join(",")}, 0.4)`}:{},children:e("article",{children:[e("figure",{children:e("img",{src:Y,alt:j,width:U,height:L,loading:"lazy"})}),e("div",{class:"article-body",children:[e("header",{children:[e("div",{class:"article-meta",children:[e("span",{class:"domain",children:V})," ",!!A&&e(_,{children:"· "}),!!A&&e(_,{children:e(bt,{datetime:A,format:"micro"})})]}),!!P&&e("h1",{class:"title",lang:M,dir:"auto",title:P,children:P})]}),!!x&&e("p",{class:"description",lang:M,dir:"auto",title:x,children:x})]})]})},E)})]})]}),[f,p]);return e(dt,{title:r,titleComponent:e("h1",{class:"header-double-lines",children:[e("b",{children:"Trending"}),e("div",{children:a})]}),id:"trending",instance:a,emptyText:"No trending posts.",errorText:"Unable to load posts",fetchItems:m,checkForUpdates:k,checkForUpdatesInterval:5*60*1e3,useItemID:!0,headerStart:e(_,{}),boostsCarousel:i.settings.boostsCarousel,filterContext:"public",timelineStart:g,headerEnd:e(Ze,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(w,{icon:"more",size:"l"})}),children:[e(de,{onClick:()=>{let y=prompt('Enter a new instance e.g. "mastodon.social"');if(!/\./.test(y)){y&&alert("Invalid instance");return}y&&(y=y.toLowerCase().trim(),location.hash=`/${y}/trending`)},children:[e(w,{icon:"bus"})," ",e("span",{children:"Go to another instance…"})]}),d!==a&&e(de,{onClick:()=>{location.hash=`/${d}/trending`},children:[e(w,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:["Go to my instance (",e("b",{children:d}),")"]})]})]})},a)}function Qa(){He("Home","/");const t=Me(T),{shortcuts:n}=t,i=n.map(s=>{if(!s)return null;const{type:o,...a}=s,h={following:Tn,notifications:Hs,list:Os,public:ln,bookmarks:Ds,favourites:Ns,hashtag:Fs,mentions:qs,trending:Gs,search:Vs}[o];return!h||o==="search"&&!a.query||o==="list"&&!a.id?null:e(h,{...a,columnMode:!0},o+JSON.stringify(a))});return _e(["1","2","3","4","5","6","7","8","9"],(s,o)=>{try{const a=parseInt(o.keys[0],10)-1;document.querySelectorAll("#columns > *")[a].focus()}catch{}}),e("div",{id:"columns",onContextMenu:s=>{s.target.closest(".deck > header")&&!s.target.closest("a")&&!s.target.closest("button")&&(s.preventDefault(),T.showShortcutsSettings=!0)},children:i})}function ec(){var n;const t=Me(T);return G(()=>{(async()=>{const i=await nt.drafts.keys();if(i.length){const s=jt();i.filter(a=>a.startsWith(s)).length&&(T.showDrafts=!0)}})()},[]),e(_,{children:(t.settings.shortcutsViewMode==="multi-column"||!t.settings.shortcutsViewMode&&t.settings.shortcutsColumnsMode)&&((n=t.shortcuts)!=null&&n.length)?e(Qa,{}):e(Tn,{title:"Home",path:"/",id:"home",headerStart:!1,headerEnd:e(tc,{})})})}function tc(){const t=Me(T),n=z(),[i,s]=$(void 0);return e(_,{children:[e(oe,{ref:n,to:"/notifications",class:`button plain notifications-button ${t.notificationsShowNew?"has-badge":""} ${i||""}`,onClick:o=>{o.stopPropagation(),window.matchMedia("(min-width: calc(40em))").matches&&(o.preventDefault(),s(a=>a?void 0:"open"))},children:e(w,{icon:"notification",size:"l",alt:"Notifications"})}),e(ic,{state:i,anchorRef:n,onClose:()=>s(void 0)})]})}const nc=80,sc=5;function ic({anchorRef:t,state:n,onClose:i}){const{masto:s,instance:o}=Q(),a=Me(T),[h,d]=$("default"),r=s.v1.notifications.list({limit:nc});async function u(){const b=await r.next(),m=b.value;if(m!=null&&m.length){m.forEach(g=>{qe(g.status,o,{skipThreading:!0})});const k=Bs(m);T.notificationsLast=m[0],T.notifications=k,s.v1.markers.create({notifications:{lastReadId:m[0].id}}).catch(()=>{})}return T.notificationsShowNew=!1,T.notificationsLastFetchTime=Date.now(),b}const[f,c]=$(!1);function p(){return s.v1.followRequests.list({limit:1})}function l(){d("loading"),(async()=>{try{await u();const b=await p();c(!!(b!=null&&b.length)),d("default")}catch{d("error")}})()}return G(()=>{n==="open"&&l()},[n]),e(ms,{menuClassName:"notifications-menu",state:n,anchorRef:t,onClose:i,portal:{target:document.body},overflow:"auto",viewScroll:"close",position:"anchor",align:"center",boundingBoxPadding:"8 8 8 8",children:[e("header",{children:e("h2",{children:"Notifications"})}),e("main",{children:a.notifications.length?e(_,{children:a.notifications.slice(0,sc).map(b=>e(Xt,{instance:o,notification:b,disableContextMenu:!0},b.id))}):h==="loading"?e("div",{class:"ui-state",children:e($e,{abrupt:!0})}):h==="error"&&e("div",{class:"ui-state",children:[e("p",{children:"Unable to fetch notifications."}),e("p",{children:e("button",{type:"button",onClick:l,children:"Try again"})})]})}),e("footer",{children:[e(oe,{to:"/mentions",class:"button plain",children:[e(w,{icon:"at"})," ",e("span",{children:"Mentions"})]}),e(oe,{to:"/notifications",class:"button plain2",children:[f?e(_,{children:[e("span",{class:"tag collapsed",children:"New"})," ",e("span",{children:"Follow Requests"})]}):e("b",{children:"See all"})," ",e(w,{icon:"arrow-right"})]})]})]})}const oc=Je(ec),ac=[/^\/@[^@\/]+\/(?:statuses|posts)\/([^\/]+)/i,/\/notes\/([^\/]+)/i,/^\/(?:notice|objects)\/([a-z0-9-]+)/i,/\/@[^@\/]+@?[^\/]+?\/([^\/]+)/i,/^\/p\/[^\/]+\/([^\/]+)/i];function Ys(t){const{hostname:n,pathname:i}=new URL(t);for(const s of ac){const[,o]=i.match(s)||[];if(o)return{instance:n,id:o}}return{}}function cc(t){const{instance:n,id:i}=Ys(t);return n&&i?`/${n}/s/${i}`:null}function rc(){const n=Tt().pathname.replace(/^\//,""),i=Ys(n),s=i!=null&&i.instance?`/${i.instance}/s/${i.id}`:null,[o,a]=$("loading");return lt(()=>{a("loading"),(async()=>{try{const{instance:h,id:d}=i,{masto:r}=Q({instance:h});if(await r.v1.statuses.$select(d).fetch()){window.location.hash=s+"?view=full";return}}catch{}{const{masto:h,instance:d}=Q(),r=await h.v2.search.fetch({q:n,limit:1,resolve:!0});if(r.statuses.length){const u=r.statuses[0];window.location.hash=`/${d}/s/${u.id}?view=full`}else if(r.accounts.length){const u=r.accounts[0];window.location.hash=`/${d}/a/${u.id}`}else s?window.location.hash=s+"?view=full":a("error")}})()},[s]),e("div",{class:"ui-state",tabIndex:"-1",children:[o==="loading"?e(_,{children:[e($e,{abrupt:!0}),e("h2",{children:"Resolving…"}),e("p",{children:e("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})})]}):e(_,{children:[e("h2",{children:"Unable to resolve URL"}),e("p",{children:e("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})})]}),e("hr",{}),e("p",{children:e(oe,{to:"/",children:"Go home"})})]})}function lc(){He("Lists","/l");const[t,n]=$("default"),[i,s]=mt(r=>r+1,0),[o,a]=$([]);G(()=>{n("loading"),(async()=>{try{const r=await cn();a(r),n("default")}catch{n("error")}})()},[i]);const[h,d]=$(!1);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(yt,{}),e(oe,{to:"/",class:"button plain",children:e(w,{icon:"home",size:"l"})})]}),e("h1",{children:"Lists"}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>d(!0),children:e(w,{icon:"plus",size:"l",alt:"New list"})})})]})}),e("main",{children:o.length>0?e(_,{children:[e("ul",{class:"link-list",children:o.map(r=>e("li",{children:e(oe,{to:`/l/${r.id}`,children:e("span",{children:[e(w,{icon:"list"})," ",e("span",{children:r.title})]})})}))}),o.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:[o.length," list",o.length===1?"":"s"]})})]}):t==="loading"?e("p",{class:"ui-state",children:e($e,{})}):t==="error"?e("p",{class:"ui-state",children:"Unable to load lists."}):e("p",{class:"ui-state",children:"No lists yet."})})]}),h&&e(Ae,{onClick:r=>{r.target===r.currentTarget&&d(!1)},children:e(kn,{list:h==null?void 0:h.list,onClose:r=>{r.state==="success"&&s(),d(!1)}})})]})}const dc=""+new URL("instances-MzK7fGXv.json",import.meta.url).href;var uc={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",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",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_CLIENT_NAME:hc,PHANPY_WEBSITE:pc}=uc,xn="read write follow push";async function fc({instanceURL:t}){const n=new URLSearchParams({client_name:hc,redirect_uris:location.origin+location.pathname,scopes:xn,website:pc});return await(await fetch(`https://${t}/api/v1/apps`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()})).json()}async function mc({instanceURL:t,client_id:n}){const i=new URLSearchParams({client_id:n,scope:xn,redirect_uri:location.origin+location.pathname,response_type:"code"});return`https://${t}/oauth/authorize?${i.toString()}`}async function gc({instanceURL:t,client_id:n,client_secret:i,code:s}){const o=new URLSearchParams({client_id:n,client_secret:i,redirect_uri:location.origin+location.pathname,grant_type:"authorization_code",code:s,scope:xn});return await(await fetch(`https://${t}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()})).json()}var bc={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",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",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_DEFAULT_INSTANCE:yc}=bc;function wc(){var y,C;He("Log in");const t=z(),n=be.local.get("instanceURL"),[i,s]=$("default"),[o]=it(),a=o.get("instance"),h=o.get("submit"),[d,r]=$(a||(n==null?void 0:n.toLowerCase())||""),[u,f]=$([]),c=z();G(()=>{(async()=>{try{const I=await(await fetch(dc)).json();f(I),c.current=new pi(I)}catch{}})()},[]);const p=v=>{v&&(be.local.set("instanceURL",v),(async()=>{s("loading");try{const{client_id:I,client_secret:x,vapid_key:L}=await fc({instanceURL:v});I&&x?(be.session.set("clientID",I),be.session.set("clientSecret",x),be.session.set("vapidKey",L),location.href=await mc({instanceURL:v,client_id:I})):alert("Failed to register application"),s("default")}catch{s("error")}})())},l=d?d.replace(/^https?:\/\//,"").replace(/\/+$/,"").replace(/^@?[^@]+@/,"").trim():null,b=/[^\s\r\n\t\/\\]+\.[^\s\r\n\t\/\\]+/.test(l)&&!/[\s\/\\@]/.test(l),m=l?(C=(y=c.current)==null?void 0:y.search(l,{limit:10}))==null?void 0:C.map(v=>v.item):[],k=b?l:m!=null&&m.length?m[0]:d?u.find(v=>v.includes(d)):null,g=v=>{v.preventDefault(),p(k)};return h&&G(()=>{p(a||k)},[]),e("main",{id:"login",style:{textAlign:"center"},children:e("form",{onSubmit:g,children:[e("h1",{children:[e("img",{src:wn,alt:"",width:"80",height:"80"}),e("br",{}),"Log in"]}),e("label",{children:[e("p",{children:"Instance"}),e("input",{value:d,required:!0,type:"text",class:"large",id:"instanceURL",ref:t,disabled:i==="loading",autocorrect:"off",autocapitalize:"off",autocomplete:"off",spellCheck:!1,placeholder:"instance domain",onInput:v=>{r(v.target.value)}}),(m==null?void 0:m.length)>0?e("ul",{id:"instances-suggestions",children:m.map((v,I)=>e("li",{children:e("button",{type:"button",class:"plain5",onClick:()=>{p(v)},children:v})}))}):e("div",{id:"instances-eg",children:"e.g. “mastodon.social”"})]}),i==="error"&&e("p",{class:"error",children:"Failed to log in. Please try again or another instance."}),e("div",{children:[e("button",{disabled:i==="loading"||!d||!k,children:k?`Continue with ${k}`:"Continue"})," "]}),e($e,{hidden:i!=="loading"}),e("hr",{}),!yc&&e("p",{children:e("a",{href:"https://joinmastodon.org/servers",target:"_blank",children:"Don't have an account? Create one!"})}),e("p",{children:e(oe,{to:"/",children:"Go home"})})]})})}const Bt=40,vc=10,kc=5;let dn={},Vt={},Gt={};function Yt(t){delete Vt[t],delete Gt[t]}const Rt={block:"nearest",inline:"center",behavior:"smooth"},ns=".status-link:not(details:not([open]) > summary ~ *, details:not([open]) > summary ~ * *), .status-focus:not(details:not([open]) > summary ~ *, details:not([open]) > summary ~ * *)",ss=/\/s\//i;function Sc(t){var v;const{id:n}=t,{masto:i,instance:s}=Q({instance:t.instance}),o=Me(T),[a,h]=it(),d=a.get("media"),r=a.get("media-only"),u=parseInt(d||r,10);let f=u>0;const c=a.get("mediaStatusID"),p=hs(c,s);c&&!p&&(f=!1);const l=f&&!!r,b=Ke(n,s),[m,k]=$(T.statuses[b]);G(()=>{T.statuses[b]&&k(T.statuses[b])},[b]);const g=pe(()=>{const{prevLocation:I}=T,x=((I==null?void 0:I.pathname)||"")+((I==null?void 0:I.search)||""),L=Et("/:instance/s/:id",x)||Et("/s/:id",x);return!x||L?"/":x},[]);G(()=>{!m&&f&&(async()=>{try{const I=await i.v1.statuses.$select(n).fetch();qe(I,s),k(I)}catch{alert("Unable to load post."),location.hash=g}})()},[f]);const y=c?(v=o.statuses[Ke(c,s)])==null?void 0:v.mediaAttachments:m==null?void 0:m.mediaAttachments,C=Qe(()=>{!window.matchMedia("(min-width: calc(40em + 350px))").matches&&o.prevLocation?history.back():l?location.hash=g:(a.delete("media"),a.delete("mediaStatusID"),h(a))},[l,g,o.prevLocation]);return G(()=>{let I=setTimeout(()=>{const x=document.querySelector(".carousel");x&&x.focus()},100);return()=>clearTimeout(I)},[l]),G(()=>{const I=document.querySelectorAll(".deck-container");return I.forEach(x=>{x.setAttribute("inert","")}),()=>{I.forEach(x=>{x.removeAttribute("inert")})}},[]),e("div",{class:"deck-backdrop",children:[f?y!=null&&y.length?e(Ls,{mediaAttachments:y,statusID:c||n,instance:s,lang:m==null?void 0:m.language,index:u-1,onClose:C}):e("div",{class:"media-modal-container loading",children:e($e,{abrupt:!0})}):e(oe,{to:g}),!l&&e(Cc,{id:n,instance:t.instance,closeLink:g})]})}function Ic(t){const{linkable:n,to:i,onClick:s,...o}=t;return n?e(oe,{class:"status-link",to:i,onClick:s,...o}):e("div",{class:"status-focus",tabIndex:0,...o})}function Cc({id:t,closeLink:n="/",instance:i}){var D,W;const[s,o]=it(),a=s.get("media"),h=s.get("mediaStatusID"),d=parseInt(a,10)>0,r=z(!T.prevLocation&&(history.length===1||"navigation"in window&&((W=(D=navigation==null?void 0:navigation.entries)==null?void 0:D.call(navigation))==null?void 0:W.length)===1)),[u,f]=$(s.get("view")||r.current?"full":null),c=!!parseInt(s.get("translate")),{masto:p,instance:l}=Q({instance:i}),{masto:b,instance:m,authenticated:k}=Q(),g=l===m,y=Me(T),[C,v]=$([]),[I,x]=$("default"),L=z(),Y=Ke(t,l),j=z(0),M=z();G(()=>{var R;(R=M.current)==null||R.focus()},[]),G(()=>{var q;const R=bs(()=>{if(!M.current)return;const{scrollTop:Z}=M.current;I!=="loading"&&(Gt[t]=Z)},50);return(q=M.current)==null||q.addEventListener("scroll",R,{passive:!0}),R(),()=>{var Z;R.cancel(),(Z=M.current)==null||Z.removeEventListener("scroll",R)}},[t,I!=="loading"]);const ee=z(),X=z(),A=({reloadHero:R}={})=>{x("loading");let q;const Z=Vt[t];if(Z){const ce=Z.filter(De=>T.statuses[Y]);v(ce)}else v([{id:t}]);return(async()=>{var B,O;const ce=()=>Ln(()=>p.v1.statuses.$select(t).fetch(),{retries:4}),De=Ln(()=>p.v1.statuses.$select(t).context.fetch(),{retries:8}),S=!!y.statuses[Y];let N=y.statuses[Y];if(!(S&&!R))try{N=await ce(),qe(N,l),await new Promise(K=>{setTimeout(K,100)})}catch{x("error");return}try{let K=function(H){return H==null?void 0:H.map(we=>({id:we.id,account:we.account,repliesCount:we.repliesCount,content:we.content,weight:Lt(we),replies:K(we.__replies)}))};const ge=await De,{ancestors:le,descendants:ie}=ge;j.current=(ie==null?void 0:ie.length)||0;const Ce=new Set;le.forEach(H=>{qe(H,l,{skipThreading:!0}),H.inReplyToId&&!le.find(we=>we.id===H.inReplyToId)&&Ce.add(H.inReplyToId)});const Ne=le.every(H=>H.account.id===N.account.id),Oe=[];ie.forEach(H=>{if(qe(H,l,{skipThreading:!0}),H.inReplyToId&&!ie.find(we=>we.id===H.inReplyToId)&&H.inReplyToId!==N.id&&Ce.add(H.inReplyToId),H.inReplyToAccountId===H.account.id)Oe.push(H);else if(H.inReplyToId===N.id)Oe.push(H);else if(!H.inReplyToAccountId&&Oe.find(we=>we.id===H.inReplyToId)&&H.account.id===N.account.id)Oe.push(H);else{const we=ie.find(tt=>tt.id===H.inReplyToId);we&&(we.__replies||(we.__replies=[]),we.__replies.push(H))}}),Ce.size;const Ee=[...le.map(H=>({id:H.id,ancestor:!0,isThread:Ne,accountID:H.account.id,account:H.account,repliesCount:H.repliesCount,weight:Lt(H)})),{id:t,accountID:N.account.id,weight:Lt(N)},...Oe.map(H=>({id:H.id,account:H.account,accountID:H.account.id,descendant:!0,thread:H.account.id===N.account.id,weight:Lt(H),replies:K(H.__replies)}))];x("default"),ee.current={offsetTop:(B=L.current)==null?void 0:B.offsetTop,scrollTop:(O=M.current)==null?void 0:O.scrollTop};const Ve=Ee.findIndex(H=>H.id===t);Ve>=ne&&me(Ve+1),v(Ee),Vt[t]=Ee,Qs(N,l)}catch{x("error")}})(),X.current=Date.now(),()=>{clearTimeout(q)}};G(A,[t,p]);const[P,E]=$(!1);G(()=>{let R=setInterval(()=>{const q=Date.now();X.current&&q-X.current>=6e4&&E(!0)},6e4);return()=>{clearInterval(R)}},[]),lt(()=>{var q,Z;if(!C.length)return;const R=Gt[t];if(R)M.current.scrollTop=R;else if(ee.current){const ce={offsetTop:(q=L.current)==null?void 0:q.offsetTop,scrollTop:(Z=M.current)==null?void 0:Z.scrollTop},De=ce.offsetTop-ee.current.offsetTop+ce.scrollTop;M.current.scrollTop=De}else C.length===1&&(M.current.scrollTop=0);ee.current=null},[C]),G(()=>{y.reloadStatusPage<=0||(async()=>{try{const{instanceURL:R}=St(),q=`https://${R}/api/v1/statuses/${t}/context`;return await(await caches.open("api")).delete(q,{ignoreVary:!0}),A({reloadHero:!0})}catch{}})()},[y.reloadStatusPage]),G(()=>()=>{Gt={},T.reloadStatusPage=0,Vt={},dn={},un.clear()},[]);const U=y.statuses[Y]||y.statuses[t],V=pe(()=>{if(!U)return"";const{account:R}=U,q=document.createElement("div");return q.innerHTML=R.displayName,q.innerText.trim()},[U]),ye=pe(()=>{if(!U)return"";let R=yn(U);return R.length>64&&(R=R.slice(0,64)+"…"),R},[U]);He(V&&ye?`${V}: "${ye}"`:"Status","/:instance?/s/:id");const ve=pe(()=>{if(!U)return;const{url:R}=U;if(R)return new URL(R).hostname},[U]),fe=pe(()=>{if(ve)return ve===l},[ve,l]),[ne,me]=$(Bt),ue=pe(()=>C.length-ne,[C.length,ne]),he=C.some(R=>R.descendant),ke=C.filter(R=>R.ancestor),[Le,Te]=$(!0),Pe=pe(()=>{if(!L.current||Le)return null;const{top:R}=L.current.getBoundingClientRect();return R>0?"down":"up"},[Le]);_e("esc",()=>{location.hash=n},{enabled:!d,ignoreEventWhen:R=>!!document.querySelector("#modal-container > *")}),_e("backspace",()=>{location.hash=n}),_e("j",()=>{const R=document.activeElement.closest(".status-link, .status-focus"),q=R==null?void 0:R.getBoundingClientRect(),Z=Array.from(M.current.querySelectorAll(ns));if(R&&q.top<M.current.clientHeight&&q.bottom>0){const ce=Z.indexOf(R);let De=Z[ce+1];De&&(De.focus(),De.scrollIntoView(Rt))}else{const ce=Z.find(De=>{const S=De.getBoundingClientRect();return S.top>=44&&S.left>=0});ce&&(ce.focus(),ce.scrollIntoView(Rt))}}),_e("k",()=>{const R=document.activeElement.closest(".status-link, .status-focus"),q=R==null?void 0:R.getBoundingClientRect(),Z=Array.from(M.current.querySelectorAll(ns));if(R&&q.top<M.current.clientHeight&&q.bottom>0){const ce=Z.indexOf(R);let De=Z[ce-1];De&&(De.focus(),De.scrollIntoView(Rt))}else{const ce=Z.find(De=>{const S=De.getBoundingClientRect();return S.top>=44&&S.left>=0});ce&&(ce.focus(),ce.scrollIntoView(Rt))}}),_e("x",()=>{const R=document.activeElement.closest(".status-link, .status-focus");if(R){const q=R.nextElementSibling;q&&q.tagName.toLowerCase()==="details"&&(q.open=!q.open)}});const[Fe,xe]=$(!1),J=z(d?"media+status":"status"),ae=Qe((R,q,Z,ce)=>{R.preventDefault(),R.stopPropagation(),o({media:q+1,mediaStatusID:ce.id})},[t]),te=Qe((R,q)=>{Yt(q.id)},[]);G(()=>{let R;return h&&d&&(R=setTimeout(()=>{var Z;const q=(Z=M.current)==null?void 0:Z.querySelector(`.status-link[href*="/${h}"]`);q&&q.scrollIntoView(Rt)},400)),()=>{clearTimeout(R)}},[h,d]);const Se=Qe((R,q)=>{const{id:Z,ancestor:ce,isThread:De,descendant:S,thread:N,replies:B,repliesCount:O,weight:K}=R,ge=Z===t;return e("li",{ref:ge?L:null,class:`${ce?"ancestor":""} ${S?"descendant":""} ${N?"thread":""} ${ge?"hero":""}`,children:[ge?e(_,{children:[e(rt,{threshold:.1,onChange:ie=>{queueMicrotask(()=>{requestAnimationFrame(()=>{Te(ie)})})},class:"status-focus",tabIndex:0,children:e(Be,{statusID:Z,instance:l,withinContext:!0,size:"l",enableTranslate:!0,forceTranslate:c})}),I!=="loading"&&!k?e("div",{class:"post-status-banner",children:[e("p",{children:"You're not logged in. Interactions (reply, boost, etc) are not possible."}),e(oe,{to:"/login",class:"button",children:"Log in"})]}):!g&&e("div",{class:"post-status-banner",children:[e("p",{children:["This post is from another instance (",e("b",{children:l}),"). Interactions (reply, boost, etc) are not possible."]}),e("button",{type:"button",disabled:I==="loading",onClick:()=>{x("loading"),(async()=>{try{const ie=await b.v2.search.fetch({q:U.url,type:"statuses",resolve:!0,limit:1});if(ie.statuses.length){const Ce=ie.statuses[0];location.hash=m?`/${m}/s/${Ce.id}`:`/s/${Ce.id}`}else throw new Error("No results")}catch(ie){x("default"),alert("Error: "+ie)}})()},children:[e(w,{icon:"transfer"})," Switch to my instance to enable interactions"]})]})]}):e(Ic,{linkable:De||ce,to:l?`/${l}/s/${Z}`:`/s/${Z}`,onClick:()=>{Yt(Z)},children:[q===0&&ce?e(rt,{threshold:.5,onChange:ie=>{queueMicrotask(()=>{requestAnimationFrame(()=>{xe(ie)})})},children:e(Be,{statusID:Z,instance:l,withinContext:!0,size:N||ce?"m":"s",enableTranslate:!0,onMediaClick:ae,onStatusLinkClick:te})}):e(Be,{statusID:Z,instance:l,withinContext:!0,size:N||ce?"m":"s",enableTranslate:!0,onMediaClick:ae,onStatusLinkClick:te,showActionsBar:!!S}),ce&&O>1&&e("div",{class:"replies-link",children:[e(w,{icon:"comment2"})," ",e("span",{title:O,children:Ge(O)})]})," "]}),S&&(B==null?void 0:B.length)>0&&e(js,{instance:l,replies:B,hasParentThread:N,level:1,accWeight:K,openAll:j.current<vc,parentLink:{to:l?`/${l}/s/${Z}`:`/s/${Z}`,onClick:()=>Yt(Z)}}),I==="loading"&&ge&&!!(U!=null&&U.repliesCount)&&!he&&e("div",{class:"status-loading",children:e($e,{abrupt:U.repliesCount>=3})}),I==="error"&&ge&&!!(U!=null&&U.repliesCount)&&!he&&e("div",{class:"status-error",children:["Unable to load replies.",e("br",{}),e("button",{type:"button",class:"plain",onClick:()=>{T.reloadStatusPage++},children:"Try again"})]})]},Z)},[t,l,I,k,g,c,ae,te,he]),Ie=pe(()=>{var R;if("navigation"in window&&(navigation!=null&&navigation.entries)){const q=navigation.entries()[navigation.currentEntry.index-1];if(q!=null&&q.url)return ss.test(q.url)}return ss.test((R=T.prevLocation)==null?void 0:R.pathname)},[Y]),F=pe(()=>{if(!ue)return[];const R=[];function q(Z){R.push(Z.id),Z.replies&&Z.replies.forEach(q)}return C.slice(ne).forEach(q),R.map(Z=>Ke(Z,l))},[ue,C,ne,l]),re=pe(()=>C.slice(0,ne).map(Se),[C,ne,Se]);return G(()=>{let R=setTimeout(()=>{if(!L.current)return;const q=L.current.querySelector(".spoiler-button:not(.spoiling), .spoiler-media-button:not(.spoiling)");q&&q.click()},1e3);return()=>clearTimeout(R)},[t]),e("div",{tabIndex:"-1",ref:M,class:`status-deck deck contained ${C.length>1?"padded-bottom":""} ${J.current==="status"&&!r.current?"slide-in":""} ${u?`deck-view-${u}`:""}`,onAnimationEnd:R=>{J.current==="status"&&(J.current=null)},children:[e("header",{class:`${I==="loading"?"loading":""}`,onDblClick:R=>{T.reloadStatusPage++},children:e("div",{class:"header-grid header-grid-2",children:[e("h1",{children:[Ie&&e("button",{type:"button",class:"plain deck-back",onClick:()=>{history.back()},children:e(w,{icon:"chevron-left",size:"xl"})}),!Le&&U&&I!=="loading"?e(_,{children:[e("span",{class:"hero-heading",children:[e(It,{account:U.account,instance:l,showAvatar:!0,short:!0})," ",e("span",{class:"insignificant",children:["•"," ",e(bt,{datetime:U.createdAt,format:"micro"})]})]})," ",e("button",{type:"button",class:"ancestors-indicator light small",onClick:R=>{R.preventDefault(),R.stopPropagation(),L.current.scrollIntoView({behavior:"smooth",block:"start"})},title:"Go to main post",children:e(w,{icon:Pe==="down"?"arrow-down":"arrow-up"})})]}):e(_,{children:["Post"," ",e("button",{type:"button",class:"ancestors-indicator light small",onClick:R=>{R.preventDefault(),R.stopPropagation(),M.current.scrollTo({top:0,behavior:"smooth"})},hidden:!ke.length||Fe,title:`${ke.length} posts above Go to top`,children:[e(w,{icon:"arrow-up"}),ke.filter((R,q,Z)=>Z.findIndex(ce=>ce.accountID===R.accountID)===q).slice(0,3).map(R=>e(st,{url:R.account.avatar,alt:R.account.displayName},R.account.id)),ke.length>3&&e(_,{children:[" ",e("span",{class:"insignificant",children:Ge(ke.length)})]})]})]})]}),e("div",{class:"header-side",children:[e("button",{type:"button",class:"plain4 button-switch-view",style:{display:u==="full"?"":"none"},onClick:()=>{f(null),s.delete("media"),s.delete("media-only"),s.delete("view"),o(s)},title:"Switch to Side Peek view",children:e(w,{icon:"layout4",size:"l"})}),P&&e("button",{type:"button",class:"plain button-refresh",onClick:()=>{T.reloadStatusPage++,E(!1)},children:e(w,{icon:"refresh",size:"l"})}),e(Ze,{align:"end",portal:{target:M.current},menuButton:e("button",{type:"button",class:"button plain4",children:e(w,{icon:"more",alt:"Actions",size:"xl"})}),children:[e(de,{disabled:I==="loading",onClick:()=>{T.reloadStatusPage++},children:[e(w,{icon:"refresh"}),e("span",{children:"Refresh"})]}),e(de,{className:"menu-switch-view",onClick:()=>{f(u==="full"?null:"full"),s.delete("media"),s.delete("media-only"),u==="full"?s.delete("view"):s.set("view","full"),o(s)},children:[e(w,{icon:{"":"layout5",full:"layout4"}[u||""]}),e("span",{children:["Switch to ",u==="full"?"Side Peek":"Full"," view"]})]}),e(de,{onClick:()=>{Array.from(M.current.querySelectorAll(".spoiler-button:not(.spoiling), .spoiler-media-button:not(.spoiling)")).forEach(q=>{q.click()})},children:[e(w,{icon:"eye-open"})," ",e("span",{children:"Show all sensitive content"})]}),e(ze,{}),e(gs,{className:"plain",children:"Experimental"}),e(de,{disabled:!ve||fe,onClick:()=>{const R=cc(U.url);R?location.hash=R:alert("Unable to switch")},children:[e(w,{icon:"transfer"}),e("small",{class:"menu-double-lines",children:["Switch to post's instance",ve?e(_,{children:[" ","(",e("b",{children:xt.toUnicode(ve)}),")"]}):""]})]})]}),e(oe,{class:"button plain deck-close",to:n,children:e(w,{icon:"x",size:"xl"})})]})]})}),C.length&&U?e("ul",{class:`timeline flat contextual grow ${I==="loading"?"loading":""}`,children:[re,ue>0&&e("li",{children:e("button",{type:"button",class:"plain block show-more",disabled:I==="loading",onClick:()=>me(R=>R+Bt),style:{marginBlockEnd:"6em"},"data-state-post-ids":F.join(" "),children:[e("div",{class:"ib avatars-bunch",children:C.slice(ne,ne+5).map(R=>e(st,{url:R.account.avatarStatic},R.id))})," ",e("div",{class:"ib",children:["Show more…"," ",e("span",{class:"tag",children:ue>Bt?`${Bt}+`:ue})]})]})})]}):e(_,{children:[I==="loading"&&e("ul",{class:"timeline flat contextual grow loading",children:e("li",{children:e(Be,{skeleton:!0,size:"l"})})}),I==="error"&&e("p",{class:"ui-state",children:["Unable to load post",e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>{T.reloadStatusPage++},children:"Try again"})]})]})]})}function js({replies:t,instance:n,hasParentThread:i,level:s,accWeight:o,openAll:a,parentLink:h}){const[d,r]=it(),u=y=>y.reduce((C,v)=>{const{repliesCount:I,replies:x}=v,L=(x==null?void 0:x.length)||I;return C+L+u(x||[])},0),f=t.length+u(t),c=t.length===f,p=t.map(y=>y.account).filter((y,C,v)=>v.findIndex(I=>I.id===y.id)===C).slice(0,3),l=pe(()=>t==null?void 0:t.reduce((y,C)=>y+(C==null?void 0:C.weight),o),[o,t==null?void 0:t.length]);let b=!1;(a||l<=kc||!i&&f===1&&Lt(t[0])<2)&&(b=!0);const m=dn[t[0].id],k=Qe((y,C,v,I)=>{y.preventDefault(),y.stopPropagation(),r({media:C+1,mediaStatusID:I.id})},[]),g=z();return lt(()=>{var C;function y(v){v.target.dataset.scrollLeft=v.target.scrollLeft}return(C=g.current)==null||C.addEventListener("scroll",y,{passive:!0}),()=>{var v;(v=g.current)==null||v.removeEventListener("scroll",y)}},[]),e("details",{ref:g,class:"replies",open:m||b,onToggle:y=>{const{open:C}=y.target;dn[t[0].id]=C},style:{"--comments-level":s},"data-comments-level":s,"data-comments-level-overflow":s>4,children:[e("summary",{class:"replies-summary",hidden:b,children:[e("span",{class:"avatars",children:p.map(y=>e(st,{url:y.avatarStatic,title:`${y.displayName} @${y.username}`,squircle:y==null?void 0:y.bot},y.id))}),e("span",{class:"replies-counts",children:[e("b",{children:[e("span",{title:t.length,children:Ge(t.length)})," ","repl",t.length===1?"y":"ies"]}),!c&&f>1&&e(_,{children:[" ","·"," ",e("span",{children:[e("span",{title:f,children:Ge(f)})," ","comment",f===1?"":"s"]})]})]}),e(w,{icon:"chevron-down",class:"replies-summary-chevron"}),!!h&&e(oe,{class:"replies-parent-link",to:h.to,onClick:h.onClick,title:"View post with its replies",children:"»"})]}),e("ul",{children:t.map(y=>{var C,v;return e("li",{children:[e("div",{class:"status-focus",tabIndex:0,children:[e(Be,{statusID:y.id,instance:n,withinContext:!0,size:"s",enableTranslate:!0,onMediaClick:k,showActionsBar:!0}),!((C=y.replies)!=null&&C.length)&&y.repliesCount>0&&e("div",{class:"replies-link",children:[e(w,{icon:"comment2"})," ",e("span",{title:y.repliesCount,children:Ge(y.repliesCount)})]})]}),((v=y.replies)==null?void 0:v.length)&&e(js,{instance:n,replies:y.replies,level:s+1,accWeight:b?l:y.weight,openAll:a,parentLink:{to:n?`/${n}/s/${y.id}`:`/s/${y.id}`,onClick:()=>{Yt(y.id)}}})]},y.id)})})]})}const Tc=140,xc=35,$c=70,Ac=140,un=new Map;function Lt(t){var l,b;const n=un.get(t.id);if(n)return n;const{spoilerText:i,content:s,mediaAttachments:o,poll:a,card:h}=t,d=Cs(i+s),r=o!=null&&o.length?Tc:0,u=(((l=a==null?void 0:a.options)==null?void 0:l.length)||0)*xc,f=h&&(o!=null&&o.length||(b=a==null?void 0:a.options)!=null&&b.length)?0:$c,p=(d+r+u+f)/Ac;return un.set(t.id,p),p}const Rc=Je(Sc);function _c(){const t=gt(),{id:n,instance:i}=t;return e(Rc,{id:n,instance:i})}const Lc=""+new URL("boosts-carousel-YjmjXTE6.jpg",import.meta.url).href,Ec=""+new URL("grouped-notifications-xYMFVY91.jpg",import.meta.url).href,Mc=""+new URL("multi-column-ETnJNDVb.jpg",import.meta.url).href,Pc=""+new URL("multi-hashtag-timeline-x-SDVR4g.jpg",import.meta.url).href,Dc=""+new URL("nested-comments-thread-Ib-fZGS3.jpg",import.meta.url).href,Nc="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";var Uc={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",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",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_DEFAULT_INSTANCE:_t,PHANPY_WEBSITE:is,PHANPY_PRIVACY_POLICY_URL:Fc,PHANPY_DEFAULT_INSTANCE_REGISTRATION_URL:os}=Uc,as=is?is.replace(/https?:\/\//g,"").replace(/\/$/,""):null,cs=`${"2024-06-03T11:04:51.985Z".slice(0,10).replace(/-/g,".")}.0a6030c`;function rs(){return He(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:wn,alt:"",width:"160",height:"160",style:{aspectRatio:"1/1",marginBlockEnd:-16}}),e("img",{src:Nc,alt:"Phanpy",width:"200"})]}),e("p",{class:"desc",children:"A minimalistic opinionated Mastodon web client."}),e("p",{children:e(oe,{to:_t?`/login?instance=${_t}&submit=1`:"/login",class:"button",children:_t?"Log in":"Log in with Mastodon"})}),_t&&os&&e("p",{children:e("a",{href:os,class:"button plain5",children:"Sign up"})}),!_t&&e("p",{class:"insignificant",children:e("small",{children:["Connect your existing Mastodon/Fediverse account.",e("br",{}),"Your credentials are not stored on this server."]})})]}),(as||cs)&&e("p",{class:"app-site-version",children:e("small",{children:[as," ",cs]})}),e("p",{children:[e("a",{href:"https://github.com/cheeaun/phanpy",target:"_blank",children:"Built"})," ","by"," ",e("a",{href:"https://mastodon.social/@cheeaun",target:"_blank",onClick:t=>{t.preventDefault(),T.showAccount="cheeaun@mastodon.social"},children:"@cheeaun"}),"."," ",e("a",{href:Fc,target:"_blank",children:"Privacy Policy"}),"."]})]}),e("div",{id:"why-container",children:e("div",{class:"sections",children:[e("section",{children:[e("img",{src:Lc,alt:"Screenshot of Boosts Carousel",loading:"lazy"}),e("h4",{children:"Boosts Carousel"}),e("p",{children:"Visually separate original posts and re-shared posts (boosted posts)."})]}),e("section",{children:[e("img",{src:Dc,alt:"Screenshot of nested comments thread",loading:"lazy"}),e("h4",{children:"Nested comments thread"}),e("p",{children:"Effortlessly follow conversations. Semi-collapsible replies."})]}),e("section",{children:[e("img",{src:Ec,alt:"Screenshot of grouped notifications",loading:"lazy"}),e("h4",{children:"Grouped notifications"}),e("p",{children:"Similar notifications are grouped and collapsed to reduce clutter."})]}),e("section",{children:[e("img",{src:Mc,alt:"Screenshot of multi-column UI",loading:"lazy"}),e("h4",{children:"Single or multi-column"}),e("p",{children:"By default, single column for zen-mode seekers. Configurable multi-column for power users."})]}),e("section",{children:[e("img",{src:Pc,alt:"Screenshot of multi-hashtag timeline with a form to add more hashtags",loading:"lazy"}),e("h4",{children:"Multi-hashtag timeline"}),e("p",{children:"Up to 5 hashtags combined into a single timeline."})]})]})})]})}const Oc=window.alert;window.__nativeAlert||(window.__nativeAlert=Oc);window.alert=function(t){t instanceof Error&&(t!=null&&t.message)&&(t=t.message),typeof t!="string"&&(t=JSON.stringify(t));const n=fi({text:t,className:"alert",gravity:"top",position:"center",duration:1e4,offset:{y:48},onClick:()=>{n.hideToast()}});n.showToast()};window.__STATES__=T;window.__STATES_STATS__=()=>{const t=["statuses","accounts","spoilers","unfurledLinks","statusQuotes"],n={};t.forEach(o=>{n[o]=Object.keys(T[o]).length});const{statuses:i}=T,s=[];for(const o in i)document.querySelector(`[data-state-post-id~="${o}"], [data-state-post-ids~="${o}"]`)||s.push(o)};setInterval(()=>{if(!window.__IDLE__)return;const{statuses:t,unfurledLinks:n,notifications:i}=T;let s=0;const{instance:o}=Q();for(const a in t){if(!window.__IDLE__)break;try{const h=document.querySelector(`[data-state-post-id~="${a}"], [data-state-post-ids~="${a}"]`),d=i.some(r=>{var u;return a===Ke((u=r.status)==null?void 0:u.id,o)});if(!h&&!d){delete T.statuses[a],delete T.statusQuotes[a];for(const r in n){const u=n[r];if(Ke(u.id,u.instance)===a){delete T.unfurledLinks[r];break}}s++}}catch{}}},15*60*1e3);setTimeout(()=>{for(const t in Nt)setTimeout(()=>{var n,i,s,o;Array.isArray(Nt[t])?(i=(n=Nt[t])[0])==null||i.call(n):(o=(s=Nt)[t])==null||o.call(s)},1)},5e3);(()=>{window.__IDLE__=!0;const t=["mousemove","mousedown","resize","keydown","touchstart","pointerdown","pointermove","wheel"],n=()=>{window.__IDLE__=!0},s=bs(n,3e3),o=()=>{window.__IDLE__=!1,s()};t.forEach(a=>{window.addEventListener(a,o,{passive:!0,capture:!0})}),window.addEventListener("blur",n,{passive:!0}),document.documentElement.addEventListener("mouseleave",a=>{!a.relatedTarget&&!a.toElement&&n()},{passive:!0})})();const zc=/iPad|iPhone|iPod/.test(navigator.userAgent);zc&&document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible"){const t=be.local.get("theme");let n;if(t){if(n=document.querySelector('meta[name="theme-color"][data-theme-setting="manual"]'),n){const i=n.content,s=t==="light"?n.dataset.themeLightColorTemp:n.dataset.themeDarkColorTemp;n.content=s||"",setTimeout(()=>{n.content=i},10)}}else{const i=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(n=document.querySelector(`meta[name="theme-color"][media*="${i}"]`),n){const s=n.dataset.content,o=n.dataset.contentTemp;n.content=o||"",setTimeout(()=>{n.content=s},10)}}}});{const t=be.local.get("theme");if(t){document.documentElement.classList.add(`is-${t}`),document.querySelector('meta[name="color-scheme"]').setAttribute("content",t||"dark light");const i=document.querySelector('meta[data-theme-setting="manual"]');i&&(i.name="theme-color",i.content=t==="light"?i.dataset.themeLightColor:i.dataset.themeDarkColor),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(o=>{o.name=""})}const n=be.local.get("textSize");n&&document.documentElement.style.setProperty("--text-size",`${n}px`)}ps(T,t=>{var n;for(const[i,s,o,a]of t){if(s.join(".")==="settings.shortcutsViewMode"){const h=document.getElementById("app");h&&(h.dataset.shortcutsViewMode=(n=T.shortcuts)!=null&&n.length?o:"")}s.join(".")==="settings.cloakMode"&&document.body.classList.toggle("cloak",o)}});function Bc(){const[t,n]=$(!1),[i,s]=$("loading");G(()=>{const a=be.local.get("instanceURL"),h=decodeURIComponent((window.location.search.match(/code=([^&]+)/)||[,""])[1]);if(h){window.history.replaceState({},document.title,window.location.pathname||"/");const d=be.session.get("clientID"),r=be.session.get("clientSecret"),u=be.session.get("vapidKey");(async()=>{s("loading");const{access_token:f}=await gc({instanceURL:a,client_id:d,client_secret:r,code:h}),c=ei({instance:a,accessToken:f});await Promise.allSettled([$n(c,a),ti(c,a,f,u)]),An(),Rn(c),n(!0),s("default")})()}else{window.__IGNORE_GET_ACCOUNT_ERROR__=!0;const d=St();if(d){ds(d.info.id);const{client:r}=Q({account:d}),{instance:u}=r;An(),Rn(r),s("loading"),(async()=>{try{await $n(r,u)}catch{}finally{n(!0),s("default")}})()}else s("default")}},[]);let o=Tt();return T.currentLocation=o.pathname,G(an,[o,t]),/\/https?:/.test(o.pathname)?e(rc,{}):e(_,{children:[e(qc,{isLoggedIn:t,loading:i==="loading"}),e(Hc,{isLoggedIn:t}),i==="default"&&e(mn,{children:e(Ue,{path:"/:instance?/s/:id",element:e(_c,{})})}),t&&e(Ri,{}),t&&e(zo,{}),e(Mo,{}),t&&e(Uo,{}),e(Ai,{isLoggedIn:t}),i!=="loading"&&e(Fo,{onClose:an}),e(_i,{})]})}function qc({isLoggedIn:t,loading:n}){const i=Tt(),s=pe(()=>{const{pathname:o}=i;return!/^\/(login|welcome)/i.test(o)},[i]);return e(mn,{location:s||i,children:[e(Ue,{path:"/",element:t?e(oc,{}):n?e($e,{id:"loader-root"}):e(rs,{})}),e(Ue,{path:"/login",element:e(wc,{})}),e(Ue,{path:"/welcome",element:e(rs,{})})]})}function ls(){return T.prevLocation||null}function Hc({isLoggedIn:t}){const n=Tt(),i=z(ls());return pe(()=>Et("/:instance/s/:id",n.pathname)||Et("/s/:id",n.pathname),[n.pathname,Et])?i.current||(i.current=ls()):i.current=null,e(mn,{location:i.current||n,children:[t&&e(_,{children:[e(Ue,{path:"/notifications",element:e(Hs,{})}),e(Ue,{path:"/mentions",element:e(qs,{})}),e(Ue,{path:"/following",element:e(Tn,{})}),e(Ue,{path:"/b",element:e(Ds,{})}),e(Ue,{path:"/f",element:e(Ns,{})}),e(Ue,{path:"/l",children:[e(Ue,{index:!0,element:e(lc,{})}),e(Ue,{path:":id",element:e(Os,{})})]}),e(Ue,{path:"/fh",element:e(_a,{})}),e(Ue,{path:"/ft",element:e(xa,{})}),e(Ue,{path:"/catchup",element:e(ha,{})})]}),e(Ue,{path:"/:instance?/t/:hashtag",element:e(Fs,{})}),e(Ue,{path:"/:instance?/a/:id",element:e(na,{})}),e(Ue,{path:"/:instance?/p",children:[e(Ue,{index:!0,element:e(ln,{})}),e(Ue,{path:"l",element:e(ln,{local:!0})})]}),e(Ue,{path:"/:instance?/trending",element:e(Gs,{})}),e(Ue,{path:"/:instance?/search",element:e(Vs,{})})]})}"AbortSignal"in window&&(AbortSignal.timeout=AbortSignal.timeout||(t=>{const n=new AbortController;return setTimeout(()=>n.abort(),t),n.signal}));gi(e(mi,{children:e(Bc,{})}),document.getElementById("app"));setTimeout(()=>{try{Object.keys(localStorage).forEach(t=>{t.startsWith("iconify")&&localStorage.removeItem(t)}),Object.keys(sessionStorage).forEach(t=>{t.startsWith("iconify")&&sessionStorage.removeItem(t)}),localStorage.removeItem("settings:boostsCarousel")}catch{}},5e3);window.__CLOAK__=()=>{document.body.classList.toggle("cloak")};
//# sourceMappingURL=main-1wKRS81d.js.map