phanpy-cz/assets/useTitle-dCp14HlU.js
2024-06-16 20:14:43 +02:00

4 lines
17 KiB
JavaScript

const __vite__fileDeps=["./polyfill-force-FXjoUqOk.js","./vendor-GrW-f9CX.js","./compose-W5mt71Ut.js","./status-FORkhePO.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
import{S as et,U as nt,V,W as st,X as ot,Y as rt,D as j,s as it,Z as at,b as v,$ as ct,p as ut,_ as lt,G as J,A as ft}from"./vendor-GrW-f9CX.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function K(t){const e=a.local.getJSON("accounts")||[];return t&&e.find(n=>n.info.id===t)||e[0]}function ht(t){return(a.local.getJSON("accounts")||[]).find(n=>n.accessToken===t)}function dt(t){return(a.local.getJSON("accounts")||[]).find(n=>n.instanceURL===t)}const Y=window.matchMedia("(display-mode: standalone)");function gt(){try{const t=a.session.get("currentAccount");if(t)return t}catch{}if(Y.matches)try{const t=a.local.get("currentAccount");if(t)return t}catch{}return null}function B(t){try{a.session.set("currentAccount",t)}catch{}if(Y.matches)try{a.local.set("currentAccount",t)}catch{}}function U(){window.__IGNORE_GET_ACCOUNT_ERROR__;const t=gt();return K(t)}function O(){const t=U(),{instanceURL:e,info:{id:n}}=t;return`${n}@${e}`}function mt(t){const e=a.local.getJSON("accounts")||[],n=e.find(o=>o.info.id===t.info.id);n?(n.info=t.info,n.instanceURL=t.instanceURL,n.accessToken=t.accessToken,n.vapidKey=t.vapidKey):e.push(t),a.local.setJSON("accounts",e),B(t.info.id)}function Ut(t){const e=a.local.getJSON("accounts")||[],n=e.find(o=>o.info.id===t.id);n&&(n.info.displayName!==t.displayName||n.info.avatar!==t.avatar||n.info.avatar_static!==t.avatar_static)&&(n.info={...n.info,...t},a.local.setJSON("accounts",e))}let M=null;function Q(){if(M)return M;try{const t=U(),e=a.local.getJSON("instances"),n=t.instanceURL.toLowerCase();return M=e[n]}catch{return{}}}function pt(t){const{configuration:e,maxMediaAttachments:n,maxTootChars:o,pleroma:r,pollLimits:s}=t,i=(e==null?void 0:e.statuses)||{};n&&(i.maxMediaAttachments??(i.maxMediaAttachments=n)),o&&(i.maxCharacters??(i.maxCharacters=o));const c=(e==null?void 0:e.polls)||{};return s&&(c.maxCharactersPerOption??(c.maxCharactersPerOption=s.maxOptionChars),c.maxExpiration??(c.maxExpiration=s.maxExpiration),c.maxOptions??(c.maxOptions=s.maxOptions),c.minExpiration??(c.minExpiration=s.minExpiration)),{...e,statuses:i,polls:c}}function Jt(){const t=Q();return pt(t)}function Gt(){const t=Q();return/pixelfed/i.test(t==null?void 0:t.version)}const N={get:t=>{try{return localStorage.getItem(t)}catch{return null}},getJSON:t=>{try{return JSON.parse(N.get(t))}catch{return null}},set:(t,e)=>{try{return localStorage.setItem(t,e)}catch{return null}},setJSON:(t,e)=>{try{return N.set(t,JSON.stringify(e))}catch{return null}},del:t=>{try{return localStorage.removeItem(t)}catch{return null}}},x={get:t=>{try{return sessionStorage.getItem(t)}catch{return null}},getJSON:t=>{try{return JSON.parse(x.get(t))}catch{return null}},set:(t,e)=>{try{return sessionStorage.setItem(t,e)}catch{return null}},setJSON:(t,e)=>{try{return x.set(t,JSON.stringify(e))}catch{return null}},del:t=>{try{return sessionStorage.removeItem(t)}catch{return null}}},wt={get:t=>{try{return N.getJSON(t)[O()]}catch{return null}},set:(t,e)=>{try{const n=N.getJSON(t)||{};return n[O()]=e,N.setJSON(t,n)}catch{return null}},del:t=>{try{const e=N.getJSON(t)||{};return delete e[O()],N.setJSON(t,e)}catch{return null}}},a={local:N,session:x,account:wt},P="mastodon.social",R={},A={};window.__ACCOUNT_APIS__=A;let p;function _({instance:t,accessToken:e}){/^https?:\/\//.test(t)&&(t=t.replace(/^https?:\/\//,"").replace(/\/+$/,"").toLowerCase());const n=t?`https://${t}`:`https://${P}`,r={masto:et({url:n,accessToken:e,timeout:3e4}),instance:t,accessToken:e};return R[t]=r,A[t]||(A[t]={}),e&&(A[t][e]=r),r}async function Ft(t,e){const{masto:n,accessToken:o}=t;let r;try{r=await n.v2.instance.fetch()}catch{}if(!r)try{r=await n.v1.instance.fetch()}catch{}if(!r)return;const{uri:s,urls:{streamingApi:i}={},domain:c,configuration:{urls:{streaming:u}={}}={}}=r,f=a.local.getJSON("instances")||{};if((s||c)&&(f[(c||s).replace(/^https?:\/\//,"").replace(/\/+$/,"").toLowerCase()]=r),e&&(f[e.toLowerCase()]=r),a.local.setJSON("instances",f),"WebSocket"in window&&(i||u)){const y=nt({streamingApiUrl:u||i,accessToken:o,implementation:WebSocket});t.streaming=y}}async function qt(t,e,n,o){const{masto:r}=t,s=await r.v1.accounts.verifyCredentials();B(s.id),mt({info:s,instanceURL:e.toLowerCase(),accessToken:n,vapidKey:o})}async function Dt(t){try{const{masto:e}=t,n=await e.v1.preferences.fetch();a.account.set("preferences",n)}catch{}}function k({instance:t,accessToken:e,accountID:n,account:o}={}){var u,f,L,y,S;if(t&&(t=t.toLowerCase().trim()),t&&e){const d=((u=A[t])==null?void 0:u[e])||_({instance:t,accessToken:e}),{masto:h,streaming:g}=d;return{masto:h,streaming:g,client:d,authenticated:!0,instance:t}}if(e)for(const d in A)if(A[d][e]){const h=A[d][e],{masto:g,streaming:w}=h;return{masto:g,streaming:w,client:h,authenticated:!0,instance:d}}else{const h=ht(e);if(h){const g=h.accessToken,w=h.instanceURL.toLowerCase().trim(),m=_({instance:w,accessToken:g}),{masto:T,streaming:C}=m;return{masto:T,streaming:C,client:m,authenticated:!0,instance:w}}else throw new Error("Access token not found")}if(o||n)if(o=o||K(n),o){const d=o.accessToken,h=o.instanceURL.toLowerCase().trim(),g=((f=A[h])==null?void 0:f[d])||_({instance:h,accessToken:d}),{masto:w,streaming:m}=g;return{masto:w,streaming:m,client:g,authenticated:!0,instance:h}}else throw new Error(`Account ${n} not found`);const r=U();if(t){if((p==null?void 0:p.instance)===t)return{masto:p.masto,streaming:p.streaming,client:p,authenticated:!0,instance:t};if((r==null?void 0:r.instanceURL)===t){const{accessToken:T}=r;return p=((L=A[t])==null?void 0:L[T])||_({instance:t,accessToken:T}),{masto:p.masto,streaming:p.streaming,client:p,authenticated:!0,instance:t}}const d=dt(t);if(d){const T=d.accessToken,C=((y=A[t])==null?void 0:y[T])||_({instance:t,accessToken:T}),{masto:I,streaming:tt}=C;return{masto:I,streaming:tt,client:C,authenticated:!0,instance:t}}const h=R[t]||_({instance:t}),{masto:g,streaming:w,accessToken:m}=h;return{masto:g,streaming:w,client:h,authenticated:!!m,instance:t}}if(p)return{masto:p.masto,streaming:p.streaming,client:p,authenticated:!0,instance:p.instance};if(r){const{accessToken:d,instanceURL:h}=r;return p=((S=A[h])==null?void 0:S[d])||_({instance:h,accessToken:d}),{masto:p.masto,streaming:p.streaming,client:p,authenticated:!0,instance:h}}const s=R[P]||_({instance:P}),{masto:i,streaming:c}=s;return{masto:i,streaming:c,client:s,authenticated:!1,instance:P}}window.__API__={currentAccountApi:p,apis:R,accountApis:A};function yt(t){try{const{pathname:e,hash:n}=new URL(t);return/^\/.*\/\d+$/i.test(e)||/^\/(@[^/]+|users\/[^/]+)\/(statuses|posts)\/\w+\/?$/i.test(e)||/^\/notes\/[a-z0-9]+$/i.test(e)||/^\/(notice|objects)\/[a-z0-9-]+$/i.test(e)||/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(n)}catch{return!1}}window._moize=V;function St(t,e={}){return V(t,{...e,maxSize:50,isDeepEqual:!0})}function Lt(t,e={}){return St(t,{isPromise:!0,...e})}function At(t,e){let n=[],o=!1;function r(){if(n.length===0){o=!1;return}n.shift()(),setTimeout(r,e)}return function(...s){const i=()=>t.apply(this,s);n.push(i),o||(o=!0,setTimeout(r,e))}}const Tt=st({limit:1,interval:1e3}),G=[/\/@[^@\/]+@?[^\/]+?\/(\d+)$/i,/\/notice\/(\w+)$/i];function Ct(t){var e;for(let n=0;n<G.length;n++){const o=(e=t.match(G[n]))==null?void 0:e[1];if(o)return o}return null}const _t=/(twitter|github)\.com/i,F={};function Nt(t,e){var h;const n=ot(b);if(_t.test(e)||F[e])return;if(new RegExp(t+"/").test((h=n.unfurledLinks[e])==null?void 0:h.url))return Promise.resolve(n.unfurledLinks[e]);let r,s=e;/\/\/elk\.[^\/]+\/[^\/]+\.[^\/]+/i.test(s)&&(s=s.replace(/elk\.[^\/]+\//i,"")),/\/\/trunks\.[^\/]+\/status\/[^\/]+\.[^\/]+/i.test(s)&&(s=s.replace(/trunks\.[^\/]+\/status\//i,"")),/\/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(s)&&(s=`https://${s.split("/#/")[1].replace(/\/s\//i,"/@fakeUsername/")}`);let i;try{i=new URL(s)}catch{return}const c=i.hostname,u=i.pathname;let f=Ct(u);if(f){const g=f,{masto:w}=k({instance:c});r=w.v1.statuses.$select(g).fetch().then(m=>{if(m!=null&&m.id)return{status:m,instance:c};throw new Error("No results")})}const{masto:L}=k({instance:t}),y=L.v2.search.fetch({q:s,type:"statuses",resolve:!0,limit:1}).then(g=>{const{statuses:w}=g;if(w.length>0){const m=w.filter(T=>{var C;return!((C=T.content)!=null&&C.toLowerCase().includes(s.toLowerCase()))});if(m.length===1)return{status:m[0],instance:t}}throw new Error("No results")});function S(g){const{status:w,instance:m}=g,{id:T}=w,C=`/${m}/s/${T}`,I={id:T,instance:m,url:C};return b.unfurledLinks[e]=I,W(w,m,{skipThreading:!0}),I}function d(g){F[e]=!0}return r?Promise.race([y,new Promise((w,m)=>setTimeout(m,3e3))]).catch(()=>r.catch(()=>y)).then(S).catch(d):y.then(S).catch(d)}const Et=Tt(Nt),l=rt({appVersion:{},prevLocation:null,currentLocation:null,statuses:{},statusThreadNumber:{},home:[],homeNew:[],homeLast:null,homeLastFetchTime:null,notifications:[],notificationsLast:null,notificationsNew:[],notificationsShowNew:!1,notificationsLastFetchTime:null,reloadStatusPage:0,reloadGenericAccounts:{id:null,counter:0},spoilers:{},spoilersMedia:{},scrollPositions:{},unfurledLinks:{},statusQuotes:{},statusFollowedTags:{},statusReply:{},accounts:{},routeNotification:null,composerState:{},showCompose:!1,showSettings:!1,showAccount:!1,showAccounts:!1,showDrafts:!1,showMediaModal:!1,showShortcutsSettings:!1,showKeyboardShortcutsHelp:!1,showGenericAccounts:!1,showMediaAlt:!1,showEmbedModal:!1,showReportModal:!1,shortcuts:[],settings:{autoRefresh:!1,shortcutsViewMode:null,shortcutsColumnsMode:!1,boostsCarousel:!0,contentTranslation:!0,contentTranslationTargetLanguage:null,contentTranslationHideLanguages:[],contentTranslationAutoInline:!1,shortcutSettingsCloudImportExport:!1,mediaAltGenerator:!1,composerGIFPicker:!1,cloakMode:!1}}),b=l;function Ht(){l.notificationsLast=a.account.get("notificationsLast")||null,l.shortcuts=a.account.get("shortcuts")??[],l.settings.autoRefresh=a.account.get("settings-autoRefresh")??!1,l.settings.shortcutsViewMode=a.account.get("settings-shortcutsViewMode")??null,a.account.get("settings-shortcutsColumnsMode")&&(l.settings.shortcutsColumnsMode=!0),l.settings.boostsCarousel=a.account.get("settings-boostsCarousel")??!0,l.settings.contentTranslation=a.account.get("settings-contentTranslation")??!0,l.settings.contentTranslationTargetLanguage=a.account.get("settings-contentTranslationTargetLanguage")||null,l.settings.contentTranslationHideLanguages=a.account.get("settings-contentTranslationHideLanguages")||[],l.settings.contentTranslationAutoInline=a.account.get("settings-contentTranslationAutoInline")??!1,l.settings.shortcutSettingsCloudImportExport=a.account.get("settings-shortcutSettingsCloudImportExport")??!1,l.settings.mediaAltGenerator=a.account.get("settings-mediaAltGenerator")??!1,l.settings.composerGIFPicker=a.account.get("settings-composerGIFPicker")??!1,l.settings.cloakMode=a.account.get("settings-cloakMode")??!1}j(l,"notificationsLast",t=>{a.account.set("notificationsLast",l.notificationsLast)});it(l,t=>{for(const[e,n,o,r]of t)n.join(".")==="settings.autoRefresh"&&a.account.set("settings-autoRefresh",!!o),n.join(".")==="settings.boostsCarousel"&&a.account.set("settings-boostsCarousel",!!o),n.join(".")==="settings.shortcutsViewMode"&&a.account.set("settings-shortcutsViewMode",o),n.join(".")==="settings.contentTranslation"&&a.account.set("settings-contentTranslation",!!o),n.join(".")==="settings.contentTranslationAutoInline"&&a.account.set("settings-contentTranslationAutoInline",!!o),n.join(".")==="settings.shortcutSettingsCloudImportExport"&&a.account.set("settings-shortcutSettingsCloudImportExport",!!o),n.join(".")==="settings.contentTranslationTargetLanguage"&&a.account.set("settings-contentTranslationTargetLanguage",o),/^settings\.contentTranslationHideLanguages/i.test(n.join("."))&&a.account.set("settings-contentTranslationHideLanguages",l.settings.contentTranslationHideLanguages),n.join(".")==="settings.mediaAltGenerator"&&a.account.set("settings-mediaAltGenerator",!!o),n.join(".")==="settings.composerGIFPicker"&&a.account.set("settings-composerGIFPicker",!!o),(n==null?void 0:n[0])==="shortcuts"&&a.account.set("shortcuts",l.shortcuts),n.join(".")==="settings.cloakMode"&&a.account.set("settings-cloakMode",!!o)});function E(t,e){if(t)return e?`${e}/${t}`:t}function It(t,e){if(e){const n=E(t,e);return l.statuses[n]}return l.statuses[t]}function W(t,e,n){typeof e=="object"&&(n=e,e=null);const{override:o=!0,skipThreading:r=!1,skipUnfurling:s=!1}=n||{};if(!t)return;const i=It(t.id,e);!o&&i||at(t,i)||(queueMicrotask(()=>{var u,f;const c=E(t.id,e);if(i!=null&&i._pinned&&(t._pinned=i._pinned),l.statuses[c]=t,(u=t.reblog)!=null&&u.id){const L=E(t.reblog.id,e);l.statuses[L]=t.reblog}if((f=t.quote)!=null&&f.id){const L=E(t.quote.id,e);l.statuses[L]=t.quote,l.statusQuotes[c]=[{id:t.quote.id,instance:e}]}}),r||queueMicrotask(()=>{vt(t.reblog||t,e)}),s||queueMicrotask(()=>{Rt(t.reblog||t,e)}))}function Pt(t,e){const{masto:n,instance:o}=k({instance:e});let r=0;async function s(i,c=0){const{inReplyToId:u,inReplyToAccountId:f}=i;if(!u||f!==i.account.id)return[i];if(u&&f!==i.account.id)throw"Not a thread";const L=E(u,o);let y=l.statuses[L];if(!y){if(r++>3)throw"Too many fetches for thread";await new Promise(S=>setTimeout(S,500*r)),y=await kt(u,n),W(y,o,{skipThreading:!0})}return[...await s(y,++c),i]}return s(t).then(i=>{i.length>1&&i.forEach((c,u)=>{const f=E(c.id,o);l.statusThreadNumber[f]=u+1})}).catch(i=>{})}const vt=At(Pt,100),q=document.createElement("div");function Rt(t,e){const{instance:n}=k(),o=t==null?void 0:t.content;if(/<a/i.test(o)){const s=E(t==null?void 0:t.id,e);q.innerHTML=o,[...q.querySelectorAll("a[href]:not(.u-url):not(.mention):not(.hashtag)")].filter(c=>{const u=c.href;return!(u===t.url||u===t.uri)&&yt(u)}).forEach((c,u)=>{Et(n,c.href).then(f=>{f&&s&&(Array.isArray(l.statusQuotes[s])||(l.statusQuotes[s]=[]),l.statusQuotes[s][u]||l.statusQuotes[s].splice(u,0,f))})})}}const kt=Lt((t,e)=>e.v1.statuses.$select(t).fetch()),bt="modulepreload",Ot=function(t,e){return new URL(t,e).href},D={},z=function(e,n,o){let r=Promise.resolve();if(n&&n.length>0){const s=document.getElementsByTagName("link"),i=document.querySelector("meta[property=csp-nonce]"),c=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.all(n.map(u=>{if(u=Ot(u,o),u in D)return;D[u]=!0;const f=u.endsWith(".css"),L=f?'[rel="stylesheet"]':"";if(!!o)for(let d=s.length-1;d>=0;d--){const h=s[d];if(h.href===u&&(!f||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${L}`))return;const S=document.createElement("link");if(S.rel=f?"stylesheet":bt,f||(S.as="script",S.crossOrigin=""),S.href=u,c&&S.setAttribute("nonce",c),document.head.appendChild(S),f)return new Promise((d,h)=>{S.addEventListener("load",d),S.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}return r.then(()=>e()).catch(s=>{const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=s,window.dispatchEvent(i),!i.defaultPrevented)throw s})};function Mt({abrupt:t,hidden:e,...n}){return v("span",{...n,class:`loader-container ${t?"abrupt":""} ${e?"hidden":""}`,children:v("span",{class:"loader"})})}const X=!ct();function Z(){if(!X)return z(()=>import("./polyfill-force-FXjoUqOk.js").then(t=>t.p),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{})}function $(){return z(()=>import("./compose-W5mt71Ut.js"),__vite__mapDeps([2,1,3]),import.meta.url)}async function Vt(){try{await Z(),$()}catch{}}function jt(t){const[e,n]=ut(null);return lt(()=>{(async()=>{try{if(X){const o=await $();n(o)}else{await Z();const o=await $();n(o)}}catch{}})()},[]),e!=null&&e.default?v(e.default,{...t}):v(Mt,{})}var xt={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:H}=xt;function Kt(t,e){function n(){const{currentLocation:o}=b,r=Array.isArray(e);let s=r?e:[];!r&&/:?\w+\?/.test(e)&&(s.push(e.replace(/(:\w+)\?/g,"$1")),s.push(e.replace(/\/?:\w+\?/g,"")));let i=!1;s.length?i=s.some(c=>J(c,o)):e&&(i=J(e,o)),i&&(document.title=t?`${t} / ${H}`:H)}ft(()=>{const o=j(b,"currentLocation",n);return n(),o},[t,e])}export{Jt as A,jt as C,Mt as L,z as _,k as a,W as b,a as c,B as d,U as e,O as f,gt as g,Q as h,Vt as i,E as j,ht as k,Gt as l,Kt as m,It as n,_ as o,Lt as p,Ft as q,qt as r,b as s,vt as t,Ut as u,Ht as v,Dt as w,St as x,yt as y,Et as z};
//# sourceMappingURL=useTitle-dCp14HlU.js.map