import{b4 as V,aA as B,b as $,X as E,M as H,x as R,d as u,q as D,m as F,_ as J}from"./app-QjDgb7aF.js";import{b as Q,a,E as h,j as b,g,i as m,k as U,u as s,I as X,J as L,D as W,H as z,f as C}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const G=Q({__name:"share",setup(K){const i=new URLSearchParams(window.location.search),w=i.get("localOnly"),_=i.get("visibility");let n=a("fetching"),p=a(i.get("title"));const d=i.get("text"),x=i.get("url");let k=a(null),v=a(null),y=a(null),I=a(V.noteVisibilities.includes(_)?_:null),S=a(w==="0"?!1:w==="1"?!0:null),M=a([]),P=a([]);async function N(){let r="";if(p.value&&(r+=`[ ${p.value} ]
`),d?.startsWith(`${p.value}.
`)?r+=d.replace(`${p.value}.
`,""):d&&p.value!==d&&(r+=`${d}
`),x&&(r+=`${x}`),k.value=r.trim(),I.value==="specified"){const t=i.get("visibleUserIds"),o=i.get("visibleAccts");await Promise.all([...t?t.split(",").map(e=>({userId:e})):[],...o?o.split(",").map(R.parse):[]].map(e=>"username"in e?{username:e.username,host:e.host===null?void 0:e.host}:e).map(e=>u("users/show",e).then(c=>{P.value.push(c)},()=>{console.error(`Invalid user query: ${JSON.stringify(e)}`)})))}try{const t=i.get("replyId"),o=i.get("replyUri");if(t)v.value=await u("notes/show",{noteId:t});else if(o){const l=await u("ap/show",{uri:o});l.type==="Note"&&(v.value=l.object)}const e=i.get("renoteId"),c=i.get("renoteUri");if(e)y.value=await u("notes/show",{noteId:e});else if(c){const l=await u("ap/show",{uri:c});l.type==="Note"&&(y.value=l.object)}const f=i.get("fileIds");f&&await Promise.all(f.split(",").map(l=>u("drive/files/show",{fileId:l}).then(O=>{M.value.push(O)},()=>{console.error(`Failed to fetch a file ${l}`)})))}catch(t){D({type:"error",title:t.message,text:t.name})}n.value="writing"}N();function j(){window.close(),window.setTimeout(()=>{F.push("/")},100)}const T=C(()=>[]),A=C(()=>[]);return B({title:$.ts.share,icon:"ph-share-network ph-bold ph-lg"}),(r,t)=>{const o=h("MkPageHeader"),e=h("MkSpacer"),c=h("MkStickyContainer");return b(),g(c,null,{header:m(()=>[U(o,{actions:T.value,tabs:A.value},null,8,["actions","tabs"])]),default:m(()=>[U(e,{"content-max":800},{default:m(()=>[s(n)==="writing"?(b(),g(E,{key:0,fixed:"",instant:!0,"initial-text":s(k),"initial-visibility":s(I),"initial-files":s(M),"initial-local-only":s(S),reply:s(v),renote:s(y),"initial-visible-users":s(P),class:"_panel",onPosted:t[0]||(t[0]=f=>X(n)?n.value="posted":n="posted")},null,8,["initial-text","initial-visibility","initial-files","initial-local-only","reply","renote","initial-visible-users"])):s(n)==="posted"?(b(),g(H,{key:1,primary:"",class:"close",onClick:t[1]||(t[1]=f=>j())},{default:m(()=>[L(W(s($).ts.close),1)]),_:1})):z("",!0)]),_:1})]),_:1})}}}),te=J(G,[["__scopeId","data-v-93f60c0e"]]);export{te as default};
//# sourceMappingURL=share-BcYH6my0.js.map
