most-box 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +23 -16
  2. package/out/about/index.html +2 -2
  3. package/out/admin/index.html +0 -0
  4. package/out/app/index.html +0 -0
  5. package/out/assets/AccountMenu-D_rcXDZr.js +1 -0
  6. package/out/assets/AppShell-CKP_dglR.js +1 -0
  7. package/out/assets/{AppTop-D-qYC0ep.js → AppTop-C03PsDr_.js} +1 -1
  8. package/out/assets/{CopyButton-BrEkzqEq.js → CopyButton-ClwBN6Iy.js} +1 -1
  9. package/out/assets/{MarketingHeader-CJXpogPY.js → MarketingHeader-ChTIIzXG.js} +1 -1
  10. package/out/assets/{MarketingLayout-Ch4sw5Qm.js → MarketingLayout-hkPAtieL.js} +1 -1
  11. package/out/assets/{MilkdownEditor-DfhuT9eU.js → MilkdownEditor-X9MUH_0q.js} +1 -1
  12. package/out/assets/{OpenSidebarButton-Bvwr7B6k.js → OpenSidebarButton-CXBAjjCE.js} +1 -1
  13. package/out/assets/{index-mjFWLwue.js → index-DJzLHA0V.js} +2 -2
  14. package/out/assets/{index.lazy-B5JMiv3z.js → index.lazy-B8ud1tpC.js} +1 -1
  15. package/out/assets/{index.lazy-B3jH9yBA.js → index.lazy-BEDWJZPP.js} +1 -1
  16. package/out/assets/{index.lazy-F3iHN_Ao.js → index.lazy-BQ_Dyw5C.js} +1 -1
  17. package/out/assets/{index.lazy-PnZR3z1V.js → index.lazy-C0L9TDqK.js} +1 -1
  18. package/out/assets/{index.lazy-CVOAOO0_.js → index.lazy-C8luNCxY.js} +1 -1
  19. package/out/assets/{index.lazy-8GSHLIGt.js → index.lazy-CT5TGyGl.js} +1 -1
  20. package/out/assets/{index.lazy-qDpRLqXu.js → index.lazy-CTLlLPjy.js} +1 -1
  21. package/out/assets/{index.lazy-BmpOpQqg.js → index.lazy-Cgrv1NmQ.js} +1 -1
  22. package/out/assets/{index.lazy-BbA_1LnY.js → index.lazy-CnpeKB4C.js} +1 -1
  23. package/out/assets/{index.lazy-D3iEq2ZW.js → index.lazy-CwAN1t6l.js} +2 -2
  24. package/out/assets/{index.lazy-CB3C6kMj.js → index.lazy-Cy249kq1.js} +1 -1
  25. package/out/assets/index.lazy-DA98XQ0Q.js +1 -0
  26. package/out/assets/index.lazy-DYhpVW5B.js +3 -0
  27. package/out/assets/{index.lazy-BAr7-dhf.js → index.lazy-b811JgFg.js} +1 -1
  28. package/out/assets/{index.lazy-CyFSwJuo.js → index.lazy-psYKmxdW.js} +1 -1
  29. package/out/assets/{saveLocalFile-BLTn3Z18.js → saveLocalFile-DTgdBgO9.js} +1 -1
  30. package/out/assets/useChannelMessages-BrqZa2SG.js +4 -0
  31. package/out/assets/{useGameRoom-DLN636mz.js → useGameRoom-B3wvUICl.js} +1 -1
  32. package/out/chat/index.html +0 -0
  33. package/out/chat/join/demo/index.html +0 -0
  34. package/out/chat/join/index.html +0 -0
  35. package/out/download/index.html +2 -2
  36. package/out/game/gandengyan/index.html +0 -0
  37. package/out/game/index.html +0 -0
  38. package/out/game/zhajinhua/index.html +0 -0
  39. package/out/index.html +2 -2
  40. package/out/note/index.html +0 -0
  41. package/out/ping/index.html +2 -2
  42. package/out/profile/index.html +0 -0
  43. package/out/web3/index.html +0 -0
  44. package/package.json +1 -1
  45. package/server/src/index.js +21 -1
  46. package/out/assets/AccountMenu-B26qus-Q.js +0 -1
  47. package/out/assets/AppShell-BiYQsNO8.js +0 -1
  48. package/out/assets/index.lazy-BMFwyE_Z.js +0 -3
  49. package/out/assets/index.lazy-s6Ok77GI.js +0 -1
  50. package/out/assets/useChannelMessages-DKlO_2oW.js +0 -4
@@ -1 +1 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,G as a,H as o,W as s,o as ee,t as c,u as te}from"./useAppStore-DNhyhD20.js";import{a as l}from"./i18n-DKsg67mH.js";import{t as u}from"./triangle-alert-BhNtjKm2.js";import{t as d}from"./download-Cy2BlfKM.js";import{t as ne}from"./external-link-D_AQSgxW.js";import{t as re}from"./file-text-zvTER2mN.js";import{t as f}from"./hard-drive-DL1KJHmG.js";import{t as p}from"./refresh-cw-CfkUlTK9.js";import{I as m,L as h}from"./index-mjFWLwue.js";import{t as ie}from"./MarketingHeader-CJXpogPY.js";import{t as g}from"./format-CAKfypjK.js";import{n as _,r as ae,s as oe,t as v}from"./downloadValidation-Dd43i9_9.js";var se=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),y=r(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),b=r(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),x=r(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),S=t(e(),1),C=n(),ce=1800;function w(e,t){return`most://${e}${t||``}`}function le(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function T(e,t){let n=e[t];return typeof n==`string`?n:void 0}function E(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function D(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=T(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:T(a,`taskId`),percent:E(a,`percent`),loaded:E(a,`loaded`),total:E(a,`total`),file:T(a,`file`),fileName:T(a,`fileName`),error:T(a,`error`)}}}function O(){let{t:e}=l(),{cid:t}=a({from:`/cid/$cid/`}),n=h({select:e=>e.searchStr}),r=c(e=>e.hasBackend),o=c(e=>e.addToast),m=c(e=>e.openConnectModal),T=i(e=>e.identity),E=i(e=>e.openLoginModal),O=(0,S.useMemo)(()=>w(t,n),[t,n]),k=(0,S.useMemo)(()=>oe(O),[O]),A=(0,S.useMemo)(()=>v(O,e),[O,e]),fe=k.fileName||t,[j,M]=(0,S.useState)({status:`idle`,message:``}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)({status:`idle`,message:``}),[L,R]=(0,S.useState)(``),[z,B]=(0,S.useState)(0),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[pe,G]=(0,S.useState)(``),[me,K]=(0,S.useState)(!1),q=(0,S.useRef)(0),J=(0,S.useRef)(null),Y=N?.fileName||fe,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,he=le(pe,e(`cid.saveToFallback`)),$=(0,S.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(r===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(r!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!T){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await _.checkDownload(O);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await ae(e)}),P(null)}},[r,O,e,T,A]);(0,S.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,S.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,S.useEffect)(()=>{$()},[$]),(0,S.useEffect)(()=>{if(r!==!0)return;let e=!1;return _.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[r]),(0,S.useEffect)(()=>{if(!L||!T)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await te(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=D(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,T]);let ge=async()=>{if(!T){E();return}if(r!==!0){m();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await _.downloadFile(O);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await ee(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},_e=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},ce)},ve=async()=>{L&&await _.cancelDownload(L).catch(()=>{})},ye=ue(j.status,F.status);return(0,C.jsxs)(`div`,{className:`cid-layout`,children:[(0,C.jsx)(ie,{}),(0,C.jsx)(`main`,{className:`cid-page`,children:(0,C.jsxs)(`section`,{className:`cid-shell`,children:[(0,C.jsxs)(`div`,{className:`cid-heading`,children:[(0,C.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,C.jsx)(`h1`,{children:e(`cid.title`)}),(0,C.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,C.jsxs)(`div`,{className:`cid-panel`,children:[(0,C.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,C.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,C.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,C.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,C.jsxs)(`a`,{className:`btn btn-primary`,href:O,onClick:_e,children:[(0,C.jsx)(ne,{size:16}),e(`cid.handoff.action`)]})]}),me&&(0,C.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,C.jsx)(u,{size:18}),(0,C.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,C.jsxs)(s,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(d,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,C.jsxs)(`div`,{className:`cid-status`,children:[(0,C.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ye}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`cid-status-label`,children:de(j.status,e)}),(0,C.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,C.jsxs)(`dl`,{className:`cid-details`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(re,{size:16}),e(`cid.fileNameLabel`)]}),(0,C.jsx)(`dd`,{children:Y})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,C.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,C.jsx)(`dd`,{children:X?g(X):e(`cid.unknownSize`)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(f,{size:16}),e(`cid.saveToLabel`)]}),(0,C.jsx)(`dd`,{children:he})]})]}),F.status!==`idle`&&(0,C.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,C.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,C.jsxs)(`div`,{className:`cid-progress`,children:[(0,C.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,C.jsx)(`span`,{children:V!==null&&U!==null?`${g(V)} / ${g(U)}`:`${z}%`})]})]}),(0,C.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:E,children:[(0,C.jsx)(b,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,children:[(0,C.jsx)(x,{size:16}),e(`cid.connectAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:ge,children:[Q?(0,C.jsx)(y,{className:`cid-spin-icon`,size:16}):(0,C.jsx)(d,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,C.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ve,children:[(0,C.jsx)(se,{size:16}),e(`cid.cancelAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,C.jsx)(p,{size:16}),e(`cid.retryAction`)]}),(0,C.jsx)(s,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})]})}function ue(e,t){return t===`completed`?(0,C.jsx)(m,{size:28}):t===`error`||e===`error`?(0,C.jsx)(u,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,C.jsx)(y,{size:28}):e===`backend-missing`?(0,C.jsx)(x,{size:28}):e===`login-required`?(0,C.jsx)(b,{size:28}):(0,C.jsx)(m,{size:28})}function de(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:O});export{k as Route};
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,G as a,H as o,W as s,o as ee,t as c,u as te}from"./useAppStore-DNhyhD20.js";import{a as l}from"./i18n-DKsg67mH.js";import{t as u}from"./triangle-alert-BhNtjKm2.js";import{t as d}from"./download-Cy2BlfKM.js";import{t as ne}from"./external-link-D_AQSgxW.js";import{t as re}from"./file-text-zvTER2mN.js";import{t as f}from"./hard-drive-DL1KJHmG.js";import{t as p}from"./refresh-cw-CfkUlTK9.js";import{I as m,L as h}from"./index-DJzLHA0V.js";import{t as ie}from"./MarketingHeader-ChTIIzXG.js";import{t as g}from"./format-CAKfypjK.js";import{n as _,r as ae,s as oe,t as v}from"./downloadValidation-Dd43i9_9.js";var se=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),y=r(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),b=r(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),x=r(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),S=t(e(),1),C=n(),ce=1800;function w(e,t){return`most://${e}${t||``}`}function le(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function T(e,t){let n=e[t];return typeof n==`string`?n:void 0}function E(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function D(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=T(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:T(a,`taskId`),percent:E(a,`percent`),loaded:E(a,`loaded`),total:E(a,`total`),file:T(a,`file`),fileName:T(a,`fileName`),error:T(a,`error`)}}}function O(){let{t:e}=l(),{cid:t}=a({from:`/cid/$cid/`}),n=h({select:e=>e.searchStr}),r=c(e=>e.hasBackend),o=c(e=>e.addToast),m=c(e=>e.openConnectModal),T=i(e=>e.identity),E=i(e=>e.openLoginModal),O=(0,S.useMemo)(()=>w(t,n),[t,n]),k=(0,S.useMemo)(()=>oe(O),[O]),A=(0,S.useMemo)(()=>v(O,e),[O,e]),fe=k.fileName||t,[j,M]=(0,S.useState)({status:`idle`,message:``}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)({status:`idle`,message:``}),[L,R]=(0,S.useState)(``),[z,B]=(0,S.useState)(0),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[pe,G]=(0,S.useState)(``),[me,K]=(0,S.useState)(!1),q=(0,S.useRef)(0),J=(0,S.useRef)(null),Y=N?.fileName||fe,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,he=le(pe,e(`cid.saveToFallback`)),$=(0,S.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(r===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(r!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!T){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await _.checkDownload(O);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await ae(e)}),P(null)}},[r,O,e,T,A]);(0,S.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,S.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,S.useEffect)(()=>{$()},[$]),(0,S.useEffect)(()=>{if(r!==!0)return;let e=!1;return _.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[r]),(0,S.useEffect)(()=>{if(!L||!T)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await te(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=D(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,T]);let ge=async()=>{if(!T){E();return}if(r!==!0){m();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await _.downloadFile(O);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await ee(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},_e=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},ce)},ve=async()=>{L&&await _.cancelDownload(L).catch(()=>{})},ye=ue(j.status,F.status);return(0,C.jsxs)(`div`,{className:`cid-layout`,children:[(0,C.jsx)(ie,{}),(0,C.jsx)(`main`,{className:`cid-page`,children:(0,C.jsxs)(`section`,{className:`cid-shell`,children:[(0,C.jsxs)(`div`,{className:`cid-heading`,children:[(0,C.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,C.jsx)(`h1`,{children:e(`cid.title`)}),(0,C.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,C.jsxs)(`div`,{className:`cid-panel`,children:[(0,C.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,C.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,C.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,C.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,C.jsxs)(`a`,{className:`btn btn-primary`,href:O,onClick:_e,children:[(0,C.jsx)(ne,{size:16}),e(`cid.handoff.action`)]})]}),me&&(0,C.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,C.jsx)(u,{size:18}),(0,C.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,C.jsxs)(s,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(d,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,C.jsxs)(`div`,{className:`cid-status`,children:[(0,C.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ye}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`cid-status-label`,children:de(j.status,e)}),(0,C.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,C.jsxs)(`dl`,{className:`cid-details`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(re,{size:16}),e(`cid.fileNameLabel`)]}),(0,C.jsx)(`dd`,{children:Y})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,C.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,C.jsx)(`dd`,{children:X?g(X):e(`cid.unknownSize`)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(f,{size:16}),e(`cid.saveToLabel`)]}),(0,C.jsx)(`dd`,{children:he})]})]}),F.status!==`idle`&&(0,C.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,C.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,C.jsxs)(`div`,{className:`cid-progress`,children:[(0,C.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,C.jsx)(`span`,{children:V!==null&&U!==null?`${g(V)} / ${g(U)}`:`${z}%`})]})]}),(0,C.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:E,children:[(0,C.jsx)(b,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,children:[(0,C.jsx)(x,{size:16}),e(`cid.connectAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:ge,children:[Q?(0,C.jsx)(y,{className:`cid-spin-icon`,size:16}):(0,C.jsx)(d,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,C.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ve,children:[(0,C.jsx)(se,{size:16}),e(`cid.cancelAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,C.jsx)(p,{size:16}),e(`cid.retryAction`)]}),(0,C.jsx)(s,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})]})}function ue(e,t){return t===`completed`?(0,C.jsx)(m,{size:28}):t===`error`||e===`error`?(0,C.jsx)(u,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,C.jsx)(y,{size:28}):e===`backend-missing`?(0,C.jsx)(x,{size:28}):e===`login-required`?(0,C.jsx)(b,{size:28}):(0,C.jsx)(m,{size:28})}function de(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:O});export{k as Route};
@@ -1 +1 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a,t as o}from"./useAppStore-DNhyhD20.js";import{a as s}from"./i18n-DKsg67mH.js";import{t as c}from"./arrow-right-BsHzC0ZL.js";import{a as l}from"./AccountMenu-B26qus-Q.js";import{t as u}from"./download-Cy2BlfKM.js";import{t as d}from"./external-link-D_AQSgxW.js";import{t as f}from"./folder-open-DOJ4bB58.js";import{t as p}from"./gamepad-2-BYqNgCQr.js";import{t as m}from"./hard-drive-DL1KJHmG.js";import{t as h}from"./message-square-CfApq8Ou.js";import{t as g}from"./notebook-pen-Bcd3MrtD.js";import{t as _}from"./wallet-D6HZocla.js";import{E as v,k as y}from"./index-mjFWLwue.js";import{t as b}from"./MarketingLayout-Ch4sw5Qm.js";var x=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),S=t(e(),1),C=n(),w=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,C.jsx)(f,{size:28}),path:`/app/`,requiresBackend:!0,heroKey:`portal.feature.app.hero`,descKey:`portal.feature.app.desc`,featureKeys:[`portal.feature.app.bullet.localIdentity`,`portal.feature.app.bullet.hyperswarm`,`portal.feature.app.bullet.largeFiles`,`portal.feature.app.bullet.cid`,`portal.feature.app.bullet.seedAfterDownload`,`portal.feature.app.bullet.noCloud`,`portal.feature.app.bullet.desktop`,`portal.feature.app.bullet.openSource`],steps:[{num:`1`,titleKey:`portal.feature.app.step.download.title`,descKey:`portal.feature.app.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.app.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.app.step.install.title`,descKey:`portal.feature.app.step.install.desc`,hideInDesktopClient:!0},{num:`3`,titleKey:`portal.feature.app.step.share.title`,descKey:`portal.feature.app.step.share.desc`}]},{id:`chat`,titleKey:`portal.feature.chat.title`,subtitleKey:`portal.feature.chat.subtitle`,icon:(0,C.jsx)(h,{size:28}),path:`/chat/`,requiresBackend:!0,heroKey:`portal.feature.chat.hero`,descKey:`portal.feature.chat.desc`,featureKeys:[`portal.feature.chat.bullet.encrypted`,`portal.feature.chat.bullet.identity`,`portal.feature.chat.bullet.sync`,`portal.feature.chat.bullet.offline`,`portal.feature.chat.bullet.noAccount`],steps:[{num:`1`,titleKey:`portal.feature.chat.step.download.title`,descKey:`portal.feature.chat.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.chat.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.chat.step.create.title`,descKey:`portal.feature.chat.step.create.desc`},{num:`3`,titleKey:`portal.feature.chat.step.send.title`,descKey:`portal.feature.chat.step.send.desc`}]},{id:`note`,titleKey:`portal.feature.note.title`,subtitleKey:`portal.feature.note.subtitle`,icon:(0,C.jsx)(g,{size:28}),path:`/note/`,requiresBackend:!1,heroKey:`portal.feature.note.hero`,descKey:`portal.feature.note.desc`,featureKeys:[`portal.feature.note.bullet.markdown`,`portal.feature.note.bullet.privacy`,`portal.feature.note.bullet.folders`,`portal.feature.note.bullet.web3`,`portal.feature.note.bullet.backup`,`portal.feature.note.bullet.independent`],steps:[{num:`1`,titleKey:`portal.feature.note.step.account.title`,descKey:`portal.feature.note.step.account.desc`},{num:`2`,titleKey:`portal.feature.note.step.create.title`,descKey:`portal.feature.note.step.create.desc`},{num:`3`,titleKey:`portal.feature.note.step.backup.title`,descKey:`portal.feature.note.step.backup.desc`}]},{id:`gandengyan`,titleKey:`portal.feature.game.title`,subtitleKey:`portal.feature.game.subtitle`,icon:(0,C.jsx)(p,{size:28}),path:`/game/gandengyan/`,requiresBackend:!0,heroKey:`portal.feature.game.hero`,descKey:`portal.feature.game.desc`,featureKeys:[`portal.feature.game.bullet.account`,`portal.feature.game.bullet.channel`,`portal.feature.game.bullet.link`,`portal.feature.game.bullet.rules`,`portal.feature.game.bullet.maintain`],steps:[{num:`1`,titleKey:`portal.feature.game.step.login.title`,descKey:`portal.feature.game.step.login.desc`},{num:`2`,titleKey:`portal.feature.game.step.create.title`,descKey:`portal.feature.game.step.create.desc`},{num:`3`,titleKey:`portal.feature.game.step.test.title`,descKey:`portal.feature.game.step.test.desc`}]},{id:`web3`,titleKey:`portal.feature.web3.title`,subtitleKey:`portal.feature.web3.subtitle`,icon:(0,C.jsx)(_,{size:28}),path:`/web3/`,requiresBackend:!1,heroKey:`portal.feature.web3.hero`,descKey:`portal.feature.web3.desc`,featureKeys:[`portal.feature.web3.bullet.frontend`,`portal.feature.web3.bullet.keys`,`portal.feature.web3.bullet.mnemonic`,`portal.feature.web3.bullet.eth`,`portal.feature.web3.bullet.pem`,`portal.feature.web3.bullet.qr`],steps:[{num:`1`,titleKey:`portal.feature.web3.step.username.title`,descKey:`portal.feature.web3.step.username.desc`},{num:`2`,titleKey:`portal.feature.web3.step.keys.title`,descKey:`portal.feature.web3.step.keys.desc`},{num:`3`,titleKey:`portal.feature.web3.step.export.title`,descKey:`portal.feature.web3.step.export.desc`}]}],T=[`chat`,`app`,`note`,`gandengyan`,`web3`];function E(){let e=o(e=>e.hasBackend),t=o(e=>e.openConnectModal),[n,r]=(0,S.useState)(`chat`),{t:i}=s(),f=v(),p=T.map(e=>w.find(t=>t.id===e)).filter(e=>!!e),h=p.find(e=>e.id===n)||p[0],g=i(h.titleKey),_=h.steps.filter(e=>!(f&&e.hideInDesktopClient));return(0,C.jsxs)(`div`,{className:`portal-page`,children:[(0,C.jsx)(`section`,{className:`portal-hero`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`h1`,{className:`portal-hero-title`,children:i(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:i(`portal.hero.subtitle`)})]})}),(0,C.jsx)(`section`,{className:`portal-cards-section`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`div`,{className:`portal-cards`,children:p.map(t=>{let o=n===t.id,s=t.requiresBackend,c=s?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=i(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${o?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(a,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:i(`portal.openFeature`,{title:l}),children:(0,C.jsx)(x,{size:16})}),(0,C.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,C.jsx)(`div`,{className:`portal-card-title`,children:l}),(0,C.jsx)(`div`,{className:`portal-card-subtitle`,children:i(t.subtitleKey)}),s?(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ${c}`,children:[c===`checking`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot checking`}),i(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),i(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),i(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),i(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":i(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(y,{size:16}),i(`portal.webConnectNode`)]}),(0,C.jsxs)(a,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(m,{size:16}),i(`portal.nodeAdmin`)]})]})]})}),(0,C.jsx)(`section`,{className:`portal-marketing`,children:(0,C.jsx)(`div`,{className:`mkt-container`,children:(0,C.jsxs)(`div`,{className:`portal-marketing-inner`,children:[(0,C.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,C.jsx)(`h2`,{children:i(h.heroKey)}),(0,C.jsx)(`p`,{children:i(h.descKey)})]}),(0,C.jsx)(`div`,{className:`portal-marketing-features`,children:h.featureKeys.map(e=>(0,C.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,C.jsx)(`span`,{className:`portal-feature-icon`,children:(0,C.jsx)(l,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:i(e)})]},e))}),(0,C.jsx)(`div`,{className:`portal-marketing-steps`,children:_.map((e,t)=>(0,C.jsxs)(`div`,{className:`portal-step`,children:[(0,C.jsx)(`span`,{className:`portal-step-num`,children:t+1}),(0,C.jsxs)(`div`,{className:`portal-step-content`,children:[(0,C.jsx)(`strong`,{children:i(e.titleKey)}),(0,C.jsx)(`p`,{children:i(e.descKey)}),e.code&&(0,C.jsx)(`code`,{className:`portal-step-code`,translate:`no`,children:e.code}),e.link&&e.linkTextKey&&(0,C.jsx)(`p`,{className:`portal-step-link`,children:(0,C.jsxs)(a,{to:e.link,children:[i(e.linkTextKey),` `,(0,C.jsx)(d,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(a,{to:h.path,className:`btn btn-primary`,children:[i(`portal.enterFeature`,{title:g}),(0,C.jsx)(c,{size:16})]}),h.requiresBackend&&e===!1&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(y,{size:16}),i(`portal.webConnectNode`)]}),!f&&(0,C.jsxs)(a,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(u,{size:16}),i(`nav.downloadClient`)]})]})]})]})})})]})}function D(){return(0,C.jsx)(b,{children:(0,C.jsx)(E,{})})}var O=i(`/`)({component:D});export{O as Route};
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a,t as o}from"./useAppStore-DNhyhD20.js";import{a as s}from"./i18n-DKsg67mH.js";import{a as c}from"./AccountMenu-D_rcXDZr.js";import{t as l}from"./arrow-right-BsHzC0ZL.js";import{t as u}from"./download-Cy2BlfKM.js";import{t as d}from"./external-link-D_AQSgxW.js";import{t as f}from"./folder-open-DOJ4bB58.js";import{t as p}from"./gamepad-2-BYqNgCQr.js";import{t as m}from"./hard-drive-DL1KJHmG.js";import{t as h}from"./message-square-CfApq8Ou.js";import{t as g}from"./notebook-pen-Bcd3MrtD.js";import{t as _}from"./wallet-D6HZocla.js";import{E as v,k as y}from"./index-DJzLHA0V.js";import{t as b}from"./MarketingLayout-hkPAtieL.js";var x=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),S=t(e(),1),C=n(),w=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,C.jsx)(f,{size:28}),path:`/app/`,requiresBackend:!0,heroKey:`portal.feature.app.hero`,descKey:`portal.feature.app.desc`,featureKeys:[`portal.feature.app.bullet.localIdentity`,`portal.feature.app.bullet.hyperswarm`,`portal.feature.app.bullet.largeFiles`,`portal.feature.app.bullet.cid`,`portal.feature.app.bullet.seedAfterDownload`,`portal.feature.app.bullet.noCloud`,`portal.feature.app.bullet.desktop`,`portal.feature.app.bullet.openSource`],steps:[{num:`1`,titleKey:`portal.feature.app.step.download.title`,descKey:`portal.feature.app.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.app.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.app.step.install.title`,descKey:`portal.feature.app.step.install.desc`,hideInDesktopClient:!0},{num:`3`,titleKey:`portal.feature.app.step.share.title`,descKey:`portal.feature.app.step.share.desc`}]},{id:`chat`,titleKey:`portal.feature.chat.title`,subtitleKey:`portal.feature.chat.subtitle`,icon:(0,C.jsx)(h,{size:28}),path:`/chat/`,requiresBackend:!0,heroKey:`portal.feature.chat.hero`,descKey:`portal.feature.chat.desc`,featureKeys:[`portal.feature.chat.bullet.encrypted`,`portal.feature.chat.bullet.identity`,`portal.feature.chat.bullet.sync`,`portal.feature.chat.bullet.offline`,`portal.feature.chat.bullet.noAccount`],steps:[{num:`1`,titleKey:`portal.feature.chat.step.download.title`,descKey:`portal.feature.chat.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.chat.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.chat.step.create.title`,descKey:`portal.feature.chat.step.create.desc`},{num:`3`,titleKey:`portal.feature.chat.step.send.title`,descKey:`portal.feature.chat.step.send.desc`}]},{id:`note`,titleKey:`portal.feature.note.title`,subtitleKey:`portal.feature.note.subtitle`,icon:(0,C.jsx)(g,{size:28}),path:`/note/`,requiresBackend:!1,heroKey:`portal.feature.note.hero`,descKey:`portal.feature.note.desc`,featureKeys:[`portal.feature.note.bullet.markdown`,`portal.feature.note.bullet.privacy`,`portal.feature.note.bullet.folders`,`portal.feature.note.bullet.web3`,`portal.feature.note.bullet.backup`,`portal.feature.note.bullet.independent`],steps:[{num:`1`,titleKey:`portal.feature.note.step.account.title`,descKey:`portal.feature.note.step.account.desc`},{num:`2`,titleKey:`portal.feature.note.step.create.title`,descKey:`portal.feature.note.step.create.desc`},{num:`3`,titleKey:`portal.feature.note.step.backup.title`,descKey:`portal.feature.note.step.backup.desc`}]},{id:`gandengyan`,titleKey:`portal.feature.game.title`,subtitleKey:`portal.feature.game.subtitle`,icon:(0,C.jsx)(p,{size:28}),path:`/game/gandengyan/`,requiresBackend:!0,heroKey:`portal.feature.game.hero`,descKey:`portal.feature.game.desc`,featureKeys:[`portal.feature.game.bullet.account`,`portal.feature.game.bullet.channel`,`portal.feature.game.bullet.link`,`portal.feature.game.bullet.rules`,`portal.feature.game.bullet.maintain`],steps:[{num:`1`,titleKey:`portal.feature.game.step.login.title`,descKey:`portal.feature.game.step.login.desc`},{num:`2`,titleKey:`portal.feature.game.step.create.title`,descKey:`portal.feature.game.step.create.desc`},{num:`3`,titleKey:`portal.feature.game.step.test.title`,descKey:`portal.feature.game.step.test.desc`}]},{id:`web3`,titleKey:`portal.feature.web3.title`,subtitleKey:`portal.feature.web3.subtitle`,icon:(0,C.jsx)(_,{size:28}),path:`/web3/`,requiresBackend:!1,heroKey:`portal.feature.web3.hero`,descKey:`portal.feature.web3.desc`,featureKeys:[`portal.feature.web3.bullet.frontend`,`portal.feature.web3.bullet.keys`,`portal.feature.web3.bullet.mnemonic`,`portal.feature.web3.bullet.eth`,`portal.feature.web3.bullet.pem`,`portal.feature.web3.bullet.qr`],steps:[{num:`1`,titleKey:`portal.feature.web3.step.username.title`,descKey:`portal.feature.web3.step.username.desc`},{num:`2`,titleKey:`portal.feature.web3.step.keys.title`,descKey:`portal.feature.web3.step.keys.desc`},{num:`3`,titleKey:`portal.feature.web3.step.export.title`,descKey:`portal.feature.web3.step.export.desc`}]}],T=[`chat`,`app`,`note`,`gandengyan`,`web3`];function E(){let e=o(e=>e.hasBackend),t=o(e=>e.openConnectModal),[n,r]=(0,S.useState)(`chat`),{t:i}=s(),f=v(),p=T.map(e=>w.find(t=>t.id===e)).filter(e=>!!e),h=p.find(e=>e.id===n)||p[0],g=i(h.titleKey),_=h.steps.filter(e=>!(f&&e.hideInDesktopClient));return(0,C.jsxs)(`div`,{className:`portal-page`,children:[(0,C.jsx)(`section`,{className:`portal-hero`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`h1`,{className:`portal-hero-title`,children:i(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:i(`portal.hero.subtitle`)})]})}),(0,C.jsx)(`section`,{className:`portal-cards-section`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`div`,{className:`portal-cards`,children:p.map(t=>{let o=n===t.id,s=t.requiresBackend,c=s?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=i(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${o?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(a,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:i(`portal.openFeature`,{title:l}),children:(0,C.jsx)(x,{size:16})}),(0,C.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,C.jsx)(`div`,{className:`portal-card-title`,children:l}),(0,C.jsx)(`div`,{className:`portal-card-subtitle`,children:i(t.subtitleKey)}),s?(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ${c}`,children:[c===`checking`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot checking`}),i(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),i(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),i(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),i(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":i(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(y,{size:16}),i(`portal.webConnectNode`)]}),(0,C.jsxs)(a,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(m,{size:16}),i(`portal.nodeAdmin`)]})]})]})}),(0,C.jsx)(`section`,{className:`portal-marketing`,children:(0,C.jsx)(`div`,{className:`mkt-container`,children:(0,C.jsxs)(`div`,{className:`portal-marketing-inner`,children:[(0,C.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,C.jsx)(`h2`,{children:i(h.heroKey)}),(0,C.jsx)(`p`,{children:i(h.descKey)})]}),(0,C.jsx)(`div`,{className:`portal-marketing-features`,children:h.featureKeys.map(e=>(0,C.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,C.jsx)(`span`,{className:`portal-feature-icon`,children:(0,C.jsx)(c,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:i(e)})]},e))}),(0,C.jsx)(`div`,{className:`portal-marketing-steps`,children:_.map((e,t)=>(0,C.jsxs)(`div`,{className:`portal-step`,children:[(0,C.jsx)(`span`,{className:`portal-step-num`,children:t+1}),(0,C.jsxs)(`div`,{className:`portal-step-content`,children:[(0,C.jsx)(`strong`,{children:i(e.titleKey)}),(0,C.jsx)(`p`,{children:i(e.descKey)}),e.code&&(0,C.jsx)(`code`,{className:`portal-step-code`,translate:`no`,children:e.code}),e.link&&e.linkTextKey&&(0,C.jsx)(`p`,{className:`portal-step-link`,children:(0,C.jsxs)(a,{to:e.link,children:[i(e.linkTextKey),` `,(0,C.jsx)(d,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(a,{to:h.path,className:`btn btn-primary`,children:[i(`portal.enterFeature`,{title:g}),(0,C.jsx)(l,{size:16})]}),h.requiresBackend&&e===!1&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(y,{size:16}),i(`portal.webConnectNode`)]}),!f&&(0,C.jsxs)(a,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(u,{size:16}),i(`nav.downloadClient`)]})]})]})]})})})]})}function D(){return(0,C.jsx)(b,{children:(0,C.jsx)(E,{})})}var O=i(`/`)({component:D});export{O as Route};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-DfhuT9eU.js","assets/jsx-runtime-Bt-cYkS5.js","assets/i18n-DKsg67mH.js","assets/index-mjFWLwue.js","assets/useAppStore-DNhyhD20.js","assets/useNavigate-DWlBD_-b.js","assets/index-FEwag7ej.css","assets/dist-CSyRxrry.js","assets/dist-RU_cpjXQ.js"])))=>i.map(i=>d[i]);
2
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,C as i,E as a,H as o,M as s,d as c,j as l,o as u,t as d,w as f}from"./useAppStore-DNhyhD20.js";import{n as ee}from"./useNavigate-DWlBD_-b.js";import{a as te}from"./i18n-DKsg67mH.js";import{a as ne,i as re,n as ie,o as p}from"./chatNoteDraft-DTy6In5R.js";import{t as ae}from"./OpenSidebarButton-Bvwr7B6k.js";import{n as m,t as oe}from"./trash-2-B9gno5q6.js";import{t as h}from"./folder-open-DOJ4bB58.js";import{t as g}from"./folder-6pYYnS2-.js";import{t as _}from"./lock-yG7M7GkB.js";import{t as se}from"./AppShell-BiYQsNO8.js";import{t as v}from"./notebook-pen-Bcd3MrtD.js";import{t as ce}from"./save-CfYzXcxH.js";import{t as le}from"./search-DLBOUfny.js";import{C as ue,E as y,L as de,M as b,O as fe,P as x,S as pe,T as me,c as S,d as C,f as w,l as he,m as T,p as ge,s as _e,t as E,u as ve,w as ye}from"./index-mjFWLwue.js";import{t as D}from"./AppTop-D-qYC0ep.js";var be=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),xe=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),O=t(e(),1),k=n();function A(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function Se({target:e,targetLabel:t,directories:n,onMove:r,onClose:i}){let{t:a}=te(),o=f(e.path||``),s=A(e),c=n.filter(t=>e.type===`directory`?t.path!==s&&!t.path.startsWith(`${s}/`):!0),[l,u]=(0,O.useState)(o),[d,ee]=(0,O.useState)(``),[ne,re]=(0,O.useState)(new Set),ie=f(d),p=d.trim()?ie:l,ae=f(p)===o,oe=a(`note.move.rootDirectory`),h=new Map;for(let e of c){let t=h.get(e.parentPath)||[];t.push(e),h.set(e.parentPath,t)}let _=c.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>ne.has(t.slice(0,n+1).join(`/`)))}),se=[{label:oe,path:``},...l.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function v(e){u(f(e)),ee(``)}function ce(e){v(e),h.has(e)&&re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function le(){ae||r(p)}return(0,k.jsx)(me,{onClose:i,children:(0,k.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`modal-header`,children:[(0,k.jsx)(`h3`,{children:a(`note.move.title`)}),(0,k.jsx)(`button`,{className:`btn btn-icon`,onClick:i,children:(0,k.jsx)(fe,{size:18})})]}),(0,k.jsxs)(`div`,{className:`note-move-target`,children:[(0,k.jsx)(`span`,{children:a(`note.move.moving`)}),(0,k.jsx)(`strong`,{translate:`no`,children:t||e.name})]}),(0,k.jsx)(`div`,{className:`note-move-path`,children:se.map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`span`,{children:`/`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>v(e.path),children:(0,k.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,k.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${l===``?`selected`:``}`,onClick:()=>v(``),children:[(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{children:oe})]}),c.length===0?(0,k.jsx)(`p`,{className:`note-move-empty`,children:a(`note.move.noFolders`)}):_.map(e=>{let t=h.has(e.path),n=ne.has(e.path);return(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${l===e.path?`selected`:``}`,onClick:()=>ce(e.path),children:[t?n?(0,k.jsx)(x,{className:`note-move-expander`,size:14}):(0,k.jsx)(m,{className:`note-move-expander`,size:14}):(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,k.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,k.jsx)(`input`,{className:`input input-compact`,value:d,onChange:e=>ee(e.target.value),placeholder:a(`note.move.pathPlaceholder`),translate:`no`}),(0,k.jsxs)(`div`,{className:`note-move-destination`,children:[(0,k.jsx)(`span`,{children:a(`note.move.destinationLabel`)}),(0,k.jsx)(`span`,{translate:p?`no`:`yes`,children:p||oe})]}),(0,k.jsxs)(`div`,{className:`modal-actions`,children:[(0,k.jsx)(`button`,{className:`btn btn-secondary`,onClick:i,children:a(`common.cancel`)}),(0,k.jsx)(`button`,{className:`btn btn-primary`,onClick:le,disabled:ae,children:a(`note.action.move`)})]})]})})}function Ce({children:e}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(D,{}),e]})}var we=(0,O.lazy)(async()=>({default:(await E(()=>import(`./MilkdownEditor-DfhuT9eU.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).MilkdownEditor})),j=/\[\[([^\]\n]+?)\]\]/g,M=/(```[\s\S]*?```)/g;function Te(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,file:t.get(`file`)||void 0,path:t.get(`path`)||void 0,chatDraft:t.get(`chatDraft`)||void 0,mode:n===`edit`?`edit`:void 0}}function N(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.file&&t.set(`file`,e.file),e.path&&t.set(`path`,e.path),e.chatDraft&&t.set(`chatDraft`,e.chatDraft),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function Ee(e){let t=e.indexOf(`?`),n=t>=0?e.slice(t):``;if(typeof window>`u`)return Te(n);try{return Te(new URL(e,window.location.origin).search)}catch{return Te(n)}}var P={"note.error.nameRequired":`note.error.nameRequired`,"note.error.nameNoSlash":`note.error.nameNoSlash`,"note.error.nameNoBackslash":`note.error.nameNoBackslash`,"note.error.nameInvalid":`note.error.nameInvalid`,"note.error.nameConflict":`note.error.nameConflict`,"note.error.moveIntoSelf":`note.error.moveIntoSelf`};function De(e,t,n){let r=e instanceof Error?e.message:``,i=P[r];return i?n(i):r||t}function Oe(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function F(e=``){return String(e).trim().replace(/\.md$/i,``)}function I(e){let t=F(e);return t?`${t}.md`:``}function ke(e,t,n){let r=F(e)||t;for(let e=0;e<1e3;e+=1){let t=I(e===0?r:`${r} ${e+1}`);if(t&&!n(t))return t}return I(`${r} ${Date.now()}`)}function Ae(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=I(t[n]),t.join(`/`)}function je(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=F(t[n]),t.join(`/`)}function Me(e){return je(i(e))}function L(e){let t=e.trim().replace(/^\/+/,``),n=t.search(/[#^]/);return je(n>=0?t.slice(0,n):t)}function Ne(e,t){let n=t?.trim();if(n)return n;let r=e.split(`/`).filter(Boolean);return r[r.length-1]||e}function R(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function Pe(e,t){return`[${R(e)}](<${t.replace(/>/g,`%3E`)}>)`}function Fe(e,t,n=``){let r=L(t);if(!r)return null;let i=r.toLowerCase(),a=e=>Me(e).toLowerCase();if(r.includes(`/`))return e.find(e=>a(e)===i)||null;let o=f(n);if(o){let t=f(`${o}/${r}`).toLowerCase(),n=e.find(e=>a(e)===t);if(n)return n}return e.find(e=>F(e.name).toLowerCase()===i)||null}function Ie(e,t,n,r=``,i){let a=e.indexOf(`|`),o=a>=0?e.slice(0,a):e,s=a>=0?e.slice(a+1):void 0,c=L(o);if(!c)return null;let l=Fe(t,o,r),u=l?n(l):i?.(c);return u?{label:Ne(c,s),href:u}:null}function Le(e,t,n,r=``,i){return e.includes(`[[`)?e.split(M).map(e=>e.startsWith("```")?e:e.replace(j,(e,a)=>{let o=Ie(a,t,n,r,i);return o?Pe(o.label,o.href):e})).join(``):e}function z(e){return e.type===`file`?F(e.name):e.name}function B(e){return e.type===`file`?je(e.fullPath):e.fullPath}function Re(e){return e.type===`file`?F(e.name):e.name}function ze(e=``){let t=f(e).split(`/`).filter(Boolean);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function Be(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Ve(e,t){if(t.length===0)return e;let n=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),n=!0);return n?r:e}function He(e){return{name:e.name,cid:`__dir__${e.fullPath}`,path:e.path,type:`directory`,size:0,created_at:e.updatedAt,updated_at:e.updatedAt}}function Ue(e,t){let n=[],r=new Map;function a(e){return e&&r.get(e)?.children||n}function o(e,t,n){let i=f(t?`${t}/${e}`:e),o=r.get(i);if(o)return o.updatedAt=Math.max(o.updatedAt,n),o;let s={id:`directory:${i}`,type:`directory`,name:e,path:t,fullPath:i,updatedAt:n,children:[]};return r.set(i,s),a(t).push(s),s}for(let t of e){let e=f(t.path||``),n=e.split(`/`).filter(Boolean),r=t.updated_at||t.created_at||0,s=``;for(let e of n)s=o(e,s,r).fullPath;a(s).push({id:`file:${t.cid}:${i(t)}`,type:`file`,name:t.name,path:e,fullPath:i(t),updatedAt:r,note:t,children:[]})}function s(e){e.sort((e,n)=>{if(e.type!==n.type)return e.type===`directory`?-1:1;let r=t(z(e),z(n));return r===0?t(B(e),B(n)):r});for(let t of e)t.type===`directory`&&s(t.children)}return s(n),n}function We(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=z(e).toLowerCase(),r=B(e).toLowerCase(),i=t.includes(n)||r.includes(n);if(e.type===`file`)return i?[e]:[];let a=i?e.children:We(e.children,n);return!i&&a.length===0?[]:[{...e,children:a}]}):e}function Ge({nodes:e,searchQuery:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=t.trim().length>0;return(0,k.jsx)(`div`,{className:`note-tree`,role:`tree`,children:e.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:c,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})}function V({node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=e.type===`directory`,l=c&&(t||n.has(e.fullPath)),u=e.type===`file`&&e.note?.cid===r,d=c&&f(i)===e.fullPath,ee=c?He(e):e.note||null,te=ee&&s?s(ee):null;return(0,k.jsxs)(`div`,{className:`note-tree-node`,role:`none`,children:[(0,k.jsxs)(`div`,{className:`note-tree-row ${c?`is-directory`:`is-file`} ${u?`is-active`:``} ${d?`is-folder-active`:``} ${te?`has-actions`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-tree-item`,role:`treeitem`,"aria-expanded":c?l:void 0,onClick:()=>{if(c){a(e);return}e.note&&o(e.note)},children:[(0,k.jsx)(`span`,{className:`note-tree-toggle`,"aria-hidden":`true`,children:c?l?(0,k.jsx)(x,{size:16}):(0,k.jsx)(m,{size:16}):(0,k.jsx)(`span`,{className:`note-tree-toggle-placeholder`})}),(0,k.jsx)(`span`,{className:`note-tree-label`,translate:`no`,children:z(e)}),e.note?.isSecret&&(0,k.jsx)(_,{className:`note-tree-lock`,size:14,"aria-hidden":`true`})]}),te]}),c&&l&&e.children.length>0&&(0,k.jsx)(`div`,{className:`note-tree-children`,role:`group`,children:e.children.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})]})}function Ke(e,t){let n=new Set;for(let t of e){let e=f(t.path).split(`/`).filter(Boolean);for(let t=0;t<e.length;t+=1)n.add(e.slice(0,t+1).join(`/`))}return Array.from(n).sort(t).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function H(e){return e.map(e=>({name:e.name,cid:e.path,path:f(e.directory),content:``,size:e.size,type:`file`,created_at:Number(e.mtimeMs)||Date.now(),updated_at:Number(e.mtimeMs)||Date.now(),isSecret:!1}))}function U(e,t){let n=I(t);return f(e?`${e}/${n}`:n)}function qe(e){let t=e||typeof window<`u`&&window.location.origin||``;if(!t)return!1;try{let e=new URL(t).hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}catch{return!1}}function W(e,t=``){let[n,r]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{let n=!1;return!e||!t?(r(!1),()=>{n=!0}):(ve().then(e=>{n||r(e.configured===!0)}).catch(()=>{n||r(!1)}),()=>{n=!0})},[e,t]),n}function G(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),c=(0,O.useRef)(null),u=d(e=>e.addToast),p=a(e=>e.wallet),m=a(e=>e.openLoginModal),h=d(e=>e.notes),g=d(e=>e.notesPath),y=d(e=>e.setNotesPath),x=d(e=>e.saveNote),pe=d(e=>e.deleteNote),me=d(e=>e.renameNote),S=d(e=>e.localDataReady),C=o.cid||``,w=h.find(e=>e.cid===C),he=!!C,T=he&&o.mode===`edit`,[ge,_e]=(0,O.useState)(``),[E,ve]=(0,O.useState)(null),[D,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(null),P=(0,O.useRef)(``),je=(0,O.useRef)(``),[Me,L]=(0,O.useState)(``),[Ne,R]=(0,O.useState)(``),[Pe,z]=(0,O.useState)(``),[B,He]=(0,O.useState)(``),[V,H]=(0,O.useState)(``),[U,qe]=(0,O.useState)(!1),[W,G]=(0,O.useState)(``),[K,q]=(0,O.useState)(!1),[Je,Ye]=(0,O.useState)(()=>new Set(ze(g)));(0,O.useEffect)(()=>{if(!C){L(``),R(``);return}if(!w){L(``),R(S?e(`note.error.notFound`):``);return}if(w.content.startsWith(`mp://1`)){if(!p){L(``),R(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){L(``),R(e(`note.error.decryptFailed`));return}L(t),R(``);return}L(w.content||``),R(``)},[C,S,w,e,p]),(0,O.useEffect)(()=>{if(!T){q(!1);return}if(!C||!w){z(``),He(``),H(``),qe(!1),G(S?e(`note.error.notFound`):``);return}if(z(F(w.name)),He(w.path||``),qe(w.isSecret===!0||w.content.startsWith(`mp://1`)),w.content.startsWith(`mp://1`)){if(!p){H(``),G(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){H(``),G(e(`note.error.decryptFailed`));return}H(t),G(``);return}H(w.content||``),G(``)},[C,T,S,w,e,p]);let Xe=(0,O.useMemo)(()=>Ue(h,n),[n,h]),Ze=(0,O.useMemo)(()=>We(Xe,ge),[Xe,ge]),Qe=w?.isSecret===!0||w?.content.startsWith(`mp://1`)===!0,J=e(T?U?`note.privacy.secret`:`note.privacy.public`:Qe?`note.privacy.secret`:`note.privacy.public`),$e=(0,O.useMemo)(()=>Ke(h,n),[n,h]),et=(0,O.useMemo)(()=>Le(Me,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,Me,w?.path]),tt=(0,O.useCallback)(e=>Ie(e,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,w?.path]);(0,O.useEffect)(()=>{w?.path&&Ye(e=>Ve(e,ze(w.path)))},[w?.path]),(0,O.useEffect)(()=>{if(!o.path||C||h.length===0)return;let e=Fe(h,o.path);e&&(y(f(e.path||``)),r({href:N({cid:e.cid}),replace:!0}))},[C,r,h,o.path,y]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||P.current===t||!S)return;if(!p){let e=`${t}:auth`;je.current!==e&&(je.current=e,m());return}let n=re(t);if(!n){P.current=t,u(e(`note.chatDraft.missing`),`warning`),Y({},!0);return}P.current=t,at(n)},[u,S,o.chatDraft,e,p]);function Y(e={},t=!1){r({href:N(e),replace:t})}function nt(e){Y(Ee(e))}function rt(e){y(f(e.path||``)),Y({cid:e.cid})}function it(e){y(e.fullPath),Ye(t=>Be(t,e.fullPath))}function X(e){Y({cid:e.cid,mode:`edit`})}function Z(){return p?!0:(m(),!1)}async function at(t){if(p)try{let n=await x({name:ke(t.title,e(`note.chatDraft.defaultTitle`),e=>h.some(t=>f(t.path||``)===f(g)&&t.name===e)),path:g,content:t.content,isSecret:!1});ie(t.id),u(e(`note.chatDraft.created`),`success`),Y({cid:n,mode:`edit`},!0)}catch(t){P.current=``,u(De(t,e(`note.toast.createFailed`),e),`error`)}}function ot(){Y(w?{cid:w.cid}:{})}async function st(){if(!Z())return;if(!w){u(e(`note.toast.notFound`),`error`);return}let t=I(Pe);if(!t){u(e(`note.toast.nameRequired`),`warning`);return}q(!0);try{let n=c.current?.getMarkdown()??V,r=U?s(n,p.danger):n,i=await x({cid:w.cid,name:t,path:B,content:r,isSecret:U});H(n),Y({cid:i},!0),u(e(`note.toast.saved`),`success`)}catch(t){u(De(t,e(`note.toast.saveFailed`),e),`error`)}finally{q(!1)}}function ct(){Z()&&ve({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(Z())try{let n=await x({name:I(t),path:g,content:``,isSecret:!1});ve(null),u(e(`note.toast.created`),`success`),Y({cid:n,mode:`edit`})}catch(t){u(De(t,e(`note.toast.createFailed`),e),`error`)}}})}function lt(e){Z()&&M(e)}async function Q(t){if(j)try{me(Oe(j),t,j.name),M(null),u(e(`note.toast.moved`),`success`)}catch(t){u(De(t,e(`note.toast.moveFailed`),e),`error`)}}function $(t){if(!Z())return;let n=t.type===`directory`;A({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{pe(n?void 0:t.cid,t.path,t.name),A(null),u(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===C&&Y()}})}let ut=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:h.length})})]}),dt=(0,k.jsx)(`div`,{className:`note-theme-wrap`}),ft=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:ge,onChange:e=>_e(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ze.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(ge?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,k.jsx)(Ge,{nodes:Ze,searchQuery:ge,expandedPaths:Je,activeFileId:C,activeFolderPath:C?``:g,onToggleDirectory:it,onOpenFile:rt}),(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:ct,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]});return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:ft}),headerTitle:ut,headerRight:dt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${he?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(T?`note.editorLabel.edit`:`note.editorLabel.read`),children:he?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[T?(0,k.jsx)(`input`,{className:`note-title-input`,value:Pe,onChange:e=>z(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!w}):w?(0,k.jsx)(`h3`,{translate:`no`,children:F(w.name)}):(0,k.jsx)(`h3`,{children:e(`note.untitled`)}),w&&(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(T?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{children:J}),(0,k.jsx)(`span`,{children:t(w.updated_at)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:T?ot:()=>Y(),title:e(T?`common.cancel`:`common.close`),"aria-label":e(T?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),T?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{className:`btn btn-sm ${U?`btn-warning`:`btn-secondary`}`,onClick:()=>qe(!U),disabled:!w,children:[U?(0,k.jsx)(_,{size:16}):(0,k.jsx)(b,{size:16}),e(U?`note.privacy.secret`:`note.privacy.public`)]}),(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:st,disabled:K||!!W||!w,children:[(0,k.jsx)(ce,{size:16}),e(K?`note.action.saving`:`note.action.save`)]})]}):w&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>lt(w),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,k.jsx)(be,{size:16})}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>$(w),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,k.jsx)(oe,{size:16})}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>X(w),disabled:!!Ne,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]})]}),T?W?(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:W})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:c,content:V,onChange:H,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]}):Ne?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:Ne})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:et,readOnly:!0,onInternalNoteLinkOpen:nt,resolveWikiNoteLink:tt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:h.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`})]})})})}),E&&(0,k.jsx)(ue,{title:E.title,placeholder:E.placeholder,defaultValue:E.defaultValue,confirmText:E.confirmText,onConfirm:E.onConfirm,onClose:()=>ve(null)}),D&&(0,k.jsx)(ye,{title:D.title,message:D.message,confirmText:D.confirmText,danger:!0,onConfirm:D.onConfirm,onClose:()=>A(null)}),j&&(0,k.jsx)(Se,{target:j,targetLabel:Re(j),directories:$e,onMove:Q,onClose:()=>M(null)})]})}function K(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),s=(0,O.useRef)(null),c=d(e=>e.addToast),l=a(e=>e.wallet),m=a(e=>e.openLoginModal),g=o.file||``,y=!!g,b=y&&o.mode===`edit`,[x,me]=(0,O.useState)(null),[E,D]=(0,O.useState)([]),[A,j]=(0,O.useState)(``),[M,P]=(0,O.useState)(!0),[De,Me]=(0,O.useState)(``),[L,Ne]=(0,O.useState)(``),[R,Pe]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),[He,V]=(0,O.useState)(``),[qe,W]=(0,O.useState)(``),[G,K]=(0,O.useState)(!1),[q,Je]=(0,O.useState)(``),[Ye,Xe]=(0,O.useState)(!1),[Ze,Qe]=(0,O.useState)(()=>new Set(ze(A))),[J,$e]=(0,O.useState)(null),[et,tt]=(0,O.useState)(null),[Y,nt]=(0,O.useState)(null),rt=(0,O.useRef)(``),it=(0,O.useRef)(``),X=(0,O.useMemo)(()=>H(E),[E]),Z=X.find(e=>e.cid===g),at=(0,O.useMemo)(()=>Ke(X,n),[n,X]),ot=(0,O.useMemo)(()=>Ue(X,n),[n,X]),st=(0,O.useMemo)(()=>We(ot,L),[ot,L]),ct=(0,O.useMemo)(()=>Le(z?.content||``,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.content,z?.directory,Z?.path,X]),lt=(0,O.useCallback)(e=>Ie(e,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.directory,Z?.path,X]);(0,O.useEffect)(()=>{Z?.path&&Qe(e=>Ve(e,ze(Z.path)))},[Z?.path]),(0,O.useEffect)(()=>{if(!o.path||g||X.length===0)return;let e=Fe(X,o.path);e&&(j(f(e.path||``)),r({href:N({file:e.cid}),replace:!0}))},[g,r,o.path,X]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||rt.current===t||M)return;if(!l){let e=`${t}:auth`;it.current!==e&&(it.current=e,m());return}if(x?.configured!==!0){let n=`${t}:vault`;it.current!==n&&(it.current=n,c(e(`note.chatDraft.openVaultFirst`),`warning`));return}let n=re(t);if(!n){rt.current=t,c(e(`note.chatDraft.missing`),`warning`),$({},!0);return}rt.current=t,_t(n)},[c,o.chatDraft,e,M,x?.configured,l]);let Q=(0,O.useCallback)(async()=>{if(!l){me(null),D([]),Me(e(`note.vault.loginRequired`)),P(!1);return}P(!0),Me(``);try{let e=await ve();me(e),e.configured?D(await C()):D([])}catch(t){me(null),D([]),Me(await u(t,e(`note.vault.loadFailed`)))}finally{P(!1)}},[e,l]);(0,O.useEffect)(()=>{Q()},[Q]),(0,O.useEffect)(()=>{V(F(z?.name||Z?.name||``))},[z?.name,Z?.name]),(0,O.useEffect)(()=>{let t=!1;async function n(){if(!g){B(null),W(``),Je(``),K(!1);return}if(!l){B(null),W(``),Je(e(`note.vault.loginRequired`)),K(!1);return}if(x?.configured!==!0){B(null),W(``),Je(``),K(!1);return}K(!0),Je(``);try{let e=await ge(g);if(t)return;B(e),W(e.content)}catch(n){if(t)return;B(null),W(``),Je(await u(n,e(`note.error.notFound`)))}finally{t||K(!1)}}return n(),()=>{t=!0}},[g,e,x?.configured,l]);function $(e={},t=!1){r({href:N(e),replace:t})}function ut(e){$(Ee(e))}function dt(e){j(f(e.path||``)),$({file:e.cid})}function ft(e){j(e.fullPath),Qe(t=>Be(t,e.fullPath))}function pt(){g&&$({file:g,mode:`edit`})}function mt(){V(F(z?.name||Z?.name||``)),$(g?{file:g}:{})}async function ht(){if(!l){m();return}let t=window.electronAPI?.selectNoteVaultDirectory;if(!t){c(e(`note.vault.selectFailed`),`error`);return}Pe(!0);try{let n=await t();if(!n)return;await _e(n),await Q(),$({},!0),c(e(`note.vault.opened`),`success`)}catch(t){c(await u(t,e(`note.vault.selectFailed`)),`error`)}finally{Pe(!1)}}function gt(){return l?x?.configured===!0?!0:(c(e(`note.vault.emptyPrompt`),`warning`),!1):(m(),!1)}async function _t(t){if(gt())try{let n=ke(t.title,e(`note.chatDraft.defaultTitle`),e=>E.some(t=>f(t.directory)===f(A)&&t.name===e)),r=await S(f(A?`${A}/${n}`:n),t.content);ie(t.id),await Q(),c(e(`note.chatDraft.created`),`success`),$({file:r.path,mode:`edit`},!0)}catch(t){rt.current=``,c(await u(t,e(`note.toast.createFailed`)),`error`)}}function vt(){gt()&&$e({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(!gt())return;let n=U(A,t);if(!n){c(e(`note.toast.nameRequired`),`warning`);return}try{let t=await S(n,``);$e(null),await Q(),$({file:t.path,mode:`edit`}),c(e(`note.toast.created`),`success`)}catch(t){c(await u(t,e(`note.toast.createFailed`)),`error`)}}})}function yt(e){gt()&&nt(e)}async function bt(t){if(!(!Y||!gt()))try{let n=g;if(Y.type===`directory`){let e=Oe(Y),r=f(t?`${t}/${Y.name}`:Y.name),i=E.filter(t=>t.path.startsWith(`${e}/`));for(let t of i){let i=f(`${r}/${t.path.slice(e.length+1)}`);await w(t.path,i),g===t.path&&(n=i)}}else{let e=f(t?`${t}/${Y.name}`:Y.name),r=await w(Y.cid,e);g===Y.cid&&(n=r.path)}nt(null),await Q(),$(n?{file:n}:{},!0),c(e(`note.toast.moved`),`success`)}catch(t){c(await u(t,e(`note.toast.moveFailed`)),`error`)}}function xt(t){gt()&&tt({title:t.type===`directory`?e(`note.delete.folderTitle`):e(`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{try{if(t.type===`directory`){let e=Oe(t),n=E.filter(t=>t.path.startsWith(`${e}/`));for(let e of n)await he(e.path);g.startsWith(`${e}/`)&&$({},!0)}else await he(t.cid),g===t.cid&&$({},!0);tt(null),await Q(),c(e(`note.toast.deleted`),`success`)}catch(t){c(await u(t,e(`note.toast.deleteFailed`)),`error`)}}})}async function St(){if(!l){m();return}if(!g||!z){c(e(`note.toast.notFound`),`error`);return}let t=I(He);if(!t){c(e(`note.toast.nameRequired`),`warning`);return}Xe(!0);try{let n=s.current?.getMarkdown()??qe,r=z.path;if(t!==z.name){r=f(z.directory?`${z.directory}/${t}`:t);let e=await w(z.path,r);B(e),V(F(e.name)),r=e.path}let i=await T(r,n);B(i),V(F(i.name)),W(i.content),await Q(),$({file:i.path},!0),c(e(`note.toast.saved`),`success`)}catch(t){c(await u(t,e(`note.toast.saveFailed`)),`error`)}finally{Xe(!1)}}let Ct=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:E.length})})]}),wt=(0,k.jsx)(`div`,{className:`note-theme-wrap`,children:(0,k.jsxs)(`button`,{className:`btn btn-sm`,onClick:ht,disabled:R,title:e(`note.vault.open`),"aria-label":e(`note.vault.open`),children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})}),Tt=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:L,onChange:e=>Ne(e.target.value),placeholder:e(`note.search.placeholder`)})]}),M?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):De?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(_,{size:32}),(0,k.jsx)(`p`,{children:De})]}):x?.configured===!0?st.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(L?`note.empty.noMatches`:`note.vault.noFiles`)})]}):(0,k.jsx)(Ge,{nodes:st,searchQuery:L,expandedPaths:Ze,activeFileId:g,activeFolderPath:g?``:A,onToggleDirectory:ft,onOpenFile:dt,renderActions:t=>(0,k.jsx)(pe,{ariaLabel:e(`common.moreActions`),className:`note-list-actions-anchor`,placement:`bottom-end`,items:[{key:`move`,label:e(`note.action.move`),icon:(0,k.jsx)(be,{size:16}),onSelect:()=>yt(t)},{key:`delete`,label:e(`note.action.delete`),icon:(0,k.jsx)(oe,{size:16}),danger:!0,onSelect:()=>xt(t)}],renderTrigger:t=>(0,k.jsx)(`button`,{...t,className:`note-list-actions-trigger`,title:e(`common.moreActions`),"aria-label":e(`common.moreActions`),children:(0,k.jsx)(p,{size:16})})})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(h,{size:32}),(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]}),x?.configured===!0&&(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:vt,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]}),Et=z?.mtimeMs||Z?.updated_at||Date.now(),Dt=F(z?.name||Z?.name||``)||e(`note.untitled`);return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:Tt}),headerTitle:Ct,headerRight:wt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${y?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(b?`note.editorLabel.edit`:`note.editorLabel.read`),children:y?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[b&&z?(0,k.jsx)(`input`,{className:`note-title-input`,value:He,onChange:e=>V(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.currentTarget.blur();return}e.key===`Escape`&&(V(F(z.name)),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),translate:`no`}):(0,k.jsx)(`h3`,{translate:`no`,children:Dt}),(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(b?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{translate:`no`,children:je(g)}),(0,k.jsx)(`span`,{children:t(Et)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:b?mt:()=>$(),title:e(b?`common.cancel`:`common.close`),"aria-label":e(b?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),b?(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:St,disabled:Ye||!!q||!z,children:[(0,k.jsx)(ce,{size:16}),e(Ye?`note.action.saving`:`note.action.save`)]}):Z&&(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:pt,disabled:!!q||!z,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]}),G?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):q?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:q})]}):b?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:s,content:qe,onChange:W,className:`milkdown-editor`})}):z?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:ct,readOnly:!0,onInternalNoteLinkOpen:ut,resolveWikiNoteLink:lt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.error.notFound`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:x?.configured?e(`note.noOpen.title`):e(`note.vault.open`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:x?.configured?e(`note.noOpen.select`):e(`note.vault.emptyPrompt`)}),x?.configured?(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`}):(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]})})})}),J&&(0,k.jsx)(ue,{title:J.title,placeholder:J.placeholder,defaultValue:J.defaultValue,confirmText:J.confirmText,onConfirm:J.onConfirm,onClose:()=>$e(null)}),et&&(0,k.jsx)(ye,{title:et.title,message:et.message,confirmText:et.confirmText,danger:!0,onConfirm:et.onConfirm,onClose:()=>tt(null)}),Y&&(0,k.jsx)(Se,{target:Y,targetLabel:Re(Y),directories:at,onMove:bt,onClose:()=>nt(null)})]})}function q(){let{t:e}=te(),t=d(e=>e.hasBackend),n=a(e=>e.wallet),r=y(),i=t===!0&&qe(c()),o=W(i,n?.address||``),s=i&&(r||o);return(0,k.jsx)(O.Suspense,{fallback:(0,k.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:s?(0,k.jsx)(K,{}):(0,k.jsx)(G,{})})}var Je=o(`/note/`)({component:q});export{Je as Route};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-X9MUH_0q.js","assets/jsx-runtime-Bt-cYkS5.js","assets/i18n-DKsg67mH.js","assets/index-DJzLHA0V.js","assets/useAppStore-DNhyhD20.js","assets/useNavigate-DWlBD_-b.js","assets/index-FEwag7ej.css","assets/dist-CSyRxrry.js","assets/dist-RU_cpjXQ.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,C as i,E as a,H as o,M as s,d as c,j as l,o as u,t as d,w as f}from"./useAppStore-DNhyhD20.js";import{n as ee}from"./useNavigate-DWlBD_-b.js";import{a as te}from"./i18n-DKsg67mH.js";import{a as ne,i as re,n as ie,o as p}from"./chatNoteDraft-DTy6In5R.js";import{t as ae}from"./OpenSidebarButton-CXBAjjCE.js";import{n as m,t as oe}from"./trash-2-B9gno5q6.js";import{t as h}from"./folder-open-DOJ4bB58.js";import{t as g}from"./folder-6pYYnS2-.js";import{t as _}from"./lock-yG7M7GkB.js";import{t as se}from"./AppShell-CKP_dglR.js";import{t as v}from"./notebook-pen-Bcd3MrtD.js";import{t as ce}from"./save-CfYzXcxH.js";import{t as le}from"./search-DLBOUfny.js";import{C as ue,E as y,L as de,M as b,O as fe,P as x,S as pe,T as me,c as S,d as C,f as w,l as he,m as T,p as ge,s as _e,t as E,u as ve,w as ye}from"./index-DJzLHA0V.js";import{t as D}from"./AppTop-C03PsDr_.js";var be=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),xe=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),O=t(e(),1),k=n();function A(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function Se({target:e,targetLabel:t,directories:n,onMove:r,onClose:i}){let{t:a}=te(),o=f(e.path||``),s=A(e),c=n.filter(t=>e.type===`directory`?t.path!==s&&!t.path.startsWith(`${s}/`):!0),[l,u]=(0,O.useState)(o),[d,ee]=(0,O.useState)(``),[ne,re]=(0,O.useState)(new Set),ie=f(d),p=d.trim()?ie:l,ae=f(p)===o,oe=a(`note.move.rootDirectory`),h=new Map;for(let e of c){let t=h.get(e.parentPath)||[];t.push(e),h.set(e.parentPath,t)}let _=c.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>ne.has(t.slice(0,n+1).join(`/`)))}),se=[{label:oe,path:``},...l.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function v(e){u(f(e)),ee(``)}function ce(e){v(e),h.has(e)&&re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function le(){ae||r(p)}return(0,k.jsx)(me,{onClose:i,children:(0,k.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`modal-header`,children:[(0,k.jsx)(`h3`,{children:a(`note.move.title`)}),(0,k.jsx)(`button`,{className:`btn btn-icon`,onClick:i,children:(0,k.jsx)(fe,{size:18})})]}),(0,k.jsxs)(`div`,{className:`note-move-target`,children:[(0,k.jsx)(`span`,{children:a(`note.move.moving`)}),(0,k.jsx)(`strong`,{translate:`no`,children:t||e.name})]}),(0,k.jsx)(`div`,{className:`note-move-path`,children:se.map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`span`,{children:`/`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>v(e.path),children:(0,k.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,k.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${l===``?`selected`:``}`,onClick:()=>v(``),children:[(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{children:oe})]}),c.length===0?(0,k.jsx)(`p`,{className:`note-move-empty`,children:a(`note.move.noFolders`)}):_.map(e=>{let t=h.has(e.path),n=ne.has(e.path);return(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${l===e.path?`selected`:``}`,onClick:()=>ce(e.path),children:[t?n?(0,k.jsx)(x,{className:`note-move-expander`,size:14}):(0,k.jsx)(m,{className:`note-move-expander`,size:14}):(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,k.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,k.jsx)(`input`,{className:`input input-compact`,value:d,onChange:e=>ee(e.target.value),placeholder:a(`note.move.pathPlaceholder`),translate:`no`}),(0,k.jsxs)(`div`,{className:`note-move-destination`,children:[(0,k.jsx)(`span`,{children:a(`note.move.destinationLabel`)}),(0,k.jsx)(`span`,{translate:p?`no`:`yes`,children:p||oe})]}),(0,k.jsxs)(`div`,{className:`modal-actions`,children:[(0,k.jsx)(`button`,{className:`btn btn-secondary`,onClick:i,children:a(`common.cancel`)}),(0,k.jsx)(`button`,{className:`btn btn-primary`,onClick:le,disabled:ae,children:a(`note.action.move`)})]})]})})}function Ce({children:e}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(D,{}),e]})}var we=(0,O.lazy)(async()=>({default:(await E(()=>import(`./MilkdownEditor-X9MUH_0q.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).MilkdownEditor})),j=/\[\[([^\]\n]+?)\]\]/g,M=/(```[\s\S]*?```)/g;function Te(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,file:t.get(`file`)||void 0,path:t.get(`path`)||void 0,chatDraft:t.get(`chatDraft`)||void 0,mode:n===`edit`?`edit`:void 0}}function N(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.file&&t.set(`file`,e.file),e.path&&t.set(`path`,e.path),e.chatDraft&&t.set(`chatDraft`,e.chatDraft),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function Ee(e){let t=e.indexOf(`?`),n=t>=0?e.slice(t):``;if(typeof window>`u`)return Te(n);try{return Te(new URL(e,window.location.origin).search)}catch{return Te(n)}}var P={"note.error.nameRequired":`note.error.nameRequired`,"note.error.nameNoSlash":`note.error.nameNoSlash`,"note.error.nameNoBackslash":`note.error.nameNoBackslash`,"note.error.nameInvalid":`note.error.nameInvalid`,"note.error.nameConflict":`note.error.nameConflict`,"note.error.moveIntoSelf":`note.error.moveIntoSelf`};function De(e,t,n){let r=e instanceof Error?e.message:``,i=P[r];return i?n(i):r||t}function Oe(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function F(e=``){return String(e).trim().replace(/\.md$/i,``)}function I(e){let t=F(e);return t?`${t}.md`:``}function ke(e,t,n){let r=F(e)||t;for(let e=0;e<1e3;e+=1){let t=I(e===0?r:`${r} ${e+1}`);if(t&&!n(t))return t}return I(`${r} ${Date.now()}`)}function Ae(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=I(t[n]),t.join(`/`)}function je(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=F(t[n]),t.join(`/`)}function Me(e){return je(i(e))}function L(e){let t=e.trim().replace(/^\/+/,``),n=t.search(/[#^]/);return je(n>=0?t.slice(0,n):t)}function Ne(e,t){let n=t?.trim();if(n)return n;let r=e.split(`/`).filter(Boolean);return r[r.length-1]||e}function R(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function Pe(e,t){return`[${R(e)}](<${t.replace(/>/g,`%3E`)}>)`}function Fe(e,t,n=``){let r=L(t);if(!r)return null;let i=r.toLowerCase(),a=e=>Me(e).toLowerCase();if(r.includes(`/`))return e.find(e=>a(e)===i)||null;let o=f(n);if(o){let t=f(`${o}/${r}`).toLowerCase(),n=e.find(e=>a(e)===t);if(n)return n}return e.find(e=>F(e.name).toLowerCase()===i)||null}function Ie(e,t,n,r=``,i){let a=e.indexOf(`|`),o=a>=0?e.slice(0,a):e,s=a>=0?e.slice(a+1):void 0,c=L(o);if(!c)return null;let l=Fe(t,o,r),u=l?n(l):i?.(c);return u?{label:Ne(c,s),href:u}:null}function Le(e,t,n,r=``,i){return e.includes(`[[`)?e.split(M).map(e=>e.startsWith("```")?e:e.replace(j,(e,a)=>{let o=Ie(a,t,n,r,i);return o?Pe(o.label,o.href):e})).join(``):e}function z(e){return e.type===`file`?F(e.name):e.name}function B(e){return e.type===`file`?je(e.fullPath):e.fullPath}function Re(e){return e.type===`file`?F(e.name):e.name}function ze(e=``){let t=f(e).split(`/`).filter(Boolean);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function Be(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Ve(e,t){if(t.length===0)return e;let n=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),n=!0);return n?r:e}function He(e){return{name:e.name,cid:`__dir__${e.fullPath}`,path:e.path,type:`directory`,size:0,created_at:e.updatedAt,updated_at:e.updatedAt}}function Ue(e,t){let n=[],r=new Map;function a(e){return e&&r.get(e)?.children||n}function o(e,t,n){let i=f(t?`${t}/${e}`:e),o=r.get(i);if(o)return o.updatedAt=Math.max(o.updatedAt,n),o;let s={id:`directory:${i}`,type:`directory`,name:e,path:t,fullPath:i,updatedAt:n,children:[]};return r.set(i,s),a(t).push(s),s}for(let t of e){let e=f(t.path||``),n=e.split(`/`).filter(Boolean),r=t.updated_at||t.created_at||0,s=``;for(let e of n)s=o(e,s,r).fullPath;a(s).push({id:`file:${t.cid}:${i(t)}`,type:`file`,name:t.name,path:e,fullPath:i(t),updatedAt:r,note:t,children:[]})}function s(e){e.sort((e,n)=>{if(e.type!==n.type)return e.type===`directory`?-1:1;let r=t(z(e),z(n));return r===0?t(B(e),B(n)):r});for(let t of e)t.type===`directory`&&s(t.children)}return s(n),n}function We(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=z(e).toLowerCase(),r=B(e).toLowerCase(),i=t.includes(n)||r.includes(n);if(e.type===`file`)return i?[e]:[];let a=i?e.children:We(e.children,n);return!i&&a.length===0?[]:[{...e,children:a}]}):e}function Ge({nodes:e,searchQuery:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=t.trim().length>0;return(0,k.jsx)(`div`,{className:`note-tree`,role:`tree`,children:e.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:c,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})}function V({node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=e.type===`directory`,l=c&&(t||n.has(e.fullPath)),u=e.type===`file`&&e.note?.cid===r,d=c&&f(i)===e.fullPath,ee=c?He(e):e.note||null,te=ee&&s?s(ee):null;return(0,k.jsxs)(`div`,{className:`note-tree-node`,role:`none`,children:[(0,k.jsxs)(`div`,{className:`note-tree-row ${c?`is-directory`:`is-file`} ${u?`is-active`:``} ${d?`is-folder-active`:``} ${te?`has-actions`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-tree-item`,role:`treeitem`,"aria-expanded":c?l:void 0,onClick:()=>{if(c){a(e);return}e.note&&o(e.note)},children:[(0,k.jsx)(`span`,{className:`note-tree-toggle`,"aria-hidden":`true`,children:c?l?(0,k.jsx)(x,{size:16}):(0,k.jsx)(m,{size:16}):(0,k.jsx)(`span`,{className:`note-tree-toggle-placeholder`})}),(0,k.jsx)(`span`,{className:`note-tree-label`,translate:`no`,children:z(e)}),e.note?.isSecret&&(0,k.jsx)(_,{className:`note-tree-lock`,size:14,"aria-hidden":`true`})]}),te]}),c&&l&&e.children.length>0&&(0,k.jsx)(`div`,{className:`note-tree-children`,role:`group`,children:e.children.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})]})}function Ke(e,t){let n=new Set;for(let t of e){let e=f(t.path).split(`/`).filter(Boolean);for(let t=0;t<e.length;t+=1)n.add(e.slice(0,t+1).join(`/`))}return Array.from(n).sort(t).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function H(e){return e.map(e=>({name:e.name,cid:e.path,path:f(e.directory),content:``,size:e.size,type:`file`,created_at:Number(e.mtimeMs)||Date.now(),updated_at:Number(e.mtimeMs)||Date.now(),isSecret:!1}))}function U(e,t){let n=I(t);return f(e?`${e}/${n}`:n)}function qe(e){let t=e||typeof window<`u`&&window.location.origin||``;if(!t)return!1;try{let e=new URL(t).hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}catch{return!1}}function W(e,t=``){let[n,r]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{let n=!1;return!e||!t?(r(!1),()=>{n=!0}):(ve().then(e=>{n||r(e.configured===!0)}).catch(()=>{n||r(!1)}),()=>{n=!0})},[e,t]),n}function G(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),c=(0,O.useRef)(null),u=d(e=>e.addToast),p=a(e=>e.wallet),m=a(e=>e.openLoginModal),h=d(e=>e.notes),g=d(e=>e.notesPath),y=d(e=>e.setNotesPath),x=d(e=>e.saveNote),pe=d(e=>e.deleteNote),me=d(e=>e.renameNote),S=d(e=>e.localDataReady),C=o.cid||``,w=h.find(e=>e.cid===C),he=!!C,T=he&&o.mode===`edit`,[ge,_e]=(0,O.useState)(``),[E,ve]=(0,O.useState)(null),[D,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(null),P=(0,O.useRef)(``),je=(0,O.useRef)(``),[Me,L]=(0,O.useState)(``),[Ne,R]=(0,O.useState)(``),[Pe,z]=(0,O.useState)(``),[B,He]=(0,O.useState)(``),[V,H]=(0,O.useState)(``),[U,qe]=(0,O.useState)(!1),[W,G]=(0,O.useState)(``),[K,q]=(0,O.useState)(!1),[Je,Ye]=(0,O.useState)(()=>new Set(ze(g)));(0,O.useEffect)(()=>{if(!C){L(``),R(``);return}if(!w){L(``),R(S?e(`note.error.notFound`):``);return}if(w.content.startsWith(`mp://1`)){if(!p){L(``),R(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){L(``),R(e(`note.error.decryptFailed`));return}L(t),R(``);return}L(w.content||``),R(``)},[C,S,w,e,p]),(0,O.useEffect)(()=>{if(!T){q(!1);return}if(!C||!w){z(``),He(``),H(``),qe(!1),G(S?e(`note.error.notFound`):``);return}if(z(F(w.name)),He(w.path||``),qe(w.isSecret===!0||w.content.startsWith(`mp://1`)),w.content.startsWith(`mp://1`)){if(!p){H(``),G(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){H(``),G(e(`note.error.decryptFailed`));return}H(t),G(``);return}H(w.content||``),G(``)},[C,T,S,w,e,p]);let Xe=(0,O.useMemo)(()=>Ue(h,n),[n,h]),Ze=(0,O.useMemo)(()=>We(Xe,ge),[Xe,ge]),Qe=w?.isSecret===!0||w?.content.startsWith(`mp://1`)===!0,J=e(T?U?`note.privacy.secret`:`note.privacy.public`:Qe?`note.privacy.secret`:`note.privacy.public`),$e=(0,O.useMemo)(()=>Ke(h,n),[n,h]),et=(0,O.useMemo)(()=>Le(Me,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,Me,w?.path]),tt=(0,O.useCallback)(e=>Ie(e,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,w?.path]);(0,O.useEffect)(()=>{w?.path&&Ye(e=>Ve(e,ze(w.path)))},[w?.path]),(0,O.useEffect)(()=>{if(!o.path||C||h.length===0)return;let e=Fe(h,o.path);e&&(y(f(e.path||``)),r({href:N({cid:e.cid}),replace:!0}))},[C,r,h,o.path,y]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||P.current===t||!S)return;if(!p){let e=`${t}:auth`;je.current!==e&&(je.current=e,m());return}let n=re(t);if(!n){P.current=t,u(e(`note.chatDraft.missing`),`warning`),Y({},!0);return}P.current=t,at(n)},[u,S,o.chatDraft,e,p]);function Y(e={},t=!1){r({href:N(e),replace:t})}function nt(e){Y(Ee(e))}function rt(e){y(f(e.path||``)),Y({cid:e.cid})}function it(e){y(e.fullPath),Ye(t=>Be(t,e.fullPath))}function X(e){Y({cid:e.cid,mode:`edit`})}function Z(){return p?!0:(m(),!1)}async function at(t){if(p)try{let n=await x({name:ke(t.title,e(`note.chatDraft.defaultTitle`),e=>h.some(t=>f(t.path||``)===f(g)&&t.name===e)),path:g,content:t.content,isSecret:!1});ie(t.id),u(e(`note.chatDraft.created`),`success`),Y({cid:n,mode:`edit`},!0)}catch(t){P.current=``,u(De(t,e(`note.toast.createFailed`),e),`error`)}}function ot(){Y(w?{cid:w.cid}:{})}async function st(){if(!Z())return;if(!w){u(e(`note.toast.notFound`),`error`);return}let t=I(Pe);if(!t){u(e(`note.toast.nameRequired`),`warning`);return}q(!0);try{let n=c.current?.getMarkdown()??V,r=U?s(n,p.danger):n,i=await x({cid:w.cid,name:t,path:B,content:r,isSecret:U});H(n),Y({cid:i},!0),u(e(`note.toast.saved`),`success`)}catch(t){u(De(t,e(`note.toast.saveFailed`),e),`error`)}finally{q(!1)}}function ct(){Z()&&ve({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(Z())try{let n=await x({name:I(t),path:g,content:``,isSecret:!1});ve(null),u(e(`note.toast.created`),`success`),Y({cid:n,mode:`edit`})}catch(t){u(De(t,e(`note.toast.createFailed`),e),`error`)}}})}function lt(e){Z()&&M(e)}async function Q(t){if(j)try{me(Oe(j),t,j.name),M(null),u(e(`note.toast.moved`),`success`)}catch(t){u(De(t,e(`note.toast.moveFailed`),e),`error`)}}function $(t){if(!Z())return;let n=t.type===`directory`;A({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{pe(n?void 0:t.cid,t.path,t.name),A(null),u(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===C&&Y()}})}let ut=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:h.length})})]}),dt=(0,k.jsx)(`div`,{className:`note-theme-wrap`}),ft=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:ge,onChange:e=>_e(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ze.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(ge?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,k.jsx)(Ge,{nodes:Ze,searchQuery:ge,expandedPaths:Je,activeFileId:C,activeFolderPath:C?``:g,onToggleDirectory:it,onOpenFile:rt}),(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:ct,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]});return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:ft}),headerTitle:ut,headerRight:dt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${he?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(T?`note.editorLabel.edit`:`note.editorLabel.read`),children:he?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[T?(0,k.jsx)(`input`,{className:`note-title-input`,value:Pe,onChange:e=>z(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!w}):w?(0,k.jsx)(`h3`,{translate:`no`,children:F(w.name)}):(0,k.jsx)(`h3`,{children:e(`note.untitled`)}),w&&(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(T?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{children:J}),(0,k.jsx)(`span`,{children:t(w.updated_at)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:T?ot:()=>Y(),title:e(T?`common.cancel`:`common.close`),"aria-label":e(T?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),T?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{className:`btn btn-sm ${U?`btn-warning`:`btn-secondary`}`,onClick:()=>qe(!U),disabled:!w,children:[U?(0,k.jsx)(_,{size:16}):(0,k.jsx)(b,{size:16}),e(U?`note.privacy.secret`:`note.privacy.public`)]}),(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:st,disabled:K||!!W||!w,children:[(0,k.jsx)(ce,{size:16}),e(K?`note.action.saving`:`note.action.save`)]})]}):w&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>lt(w),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,k.jsx)(be,{size:16})}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>$(w),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,k.jsx)(oe,{size:16})}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>X(w),disabled:!!Ne,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]})]}),T?W?(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:W})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:c,content:V,onChange:H,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]}):Ne?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:Ne})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:et,readOnly:!0,onInternalNoteLinkOpen:nt,resolveWikiNoteLink:tt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:h.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`})]})})})}),E&&(0,k.jsx)(ue,{title:E.title,placeholder:E.placeholder,defaultValue:E.defaultValue,confirmText:E.confirmText,onConfirm:E.onConfirm,onClose:()=>ve(null)}),D&&(0,k.jsx)(ye,{title:D.title,message:D.message,confirmText:D.confirmText,danger:!0,onConfirm:D.onConfirm,onClose:()=>A(null)}),j&&(0,k.jsx)(Se,{target:j,targetLabel:Re(j),directories:$e,onMove:Q,onClose:()=>M(null)})]})}function K(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),s=(0,O.useRef)(null),c=d(e=>e.addToast),l=a(e=>e.wallet),m=a(e=>e.openLoginModal),g=o.file||``,y=!!g,b=y&&o.mode===`edit`,[x,me]=(0,O.useState)(null),[E,D]=(0,O.useState)([]),[A,j]=(0,O.useState)(``),[M,P]=(0,O.useState)(!0),[De,Me]=(0,O.useState)(``),[L,Ne]=(0,O.useState)(``),[R,Pe]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),[He,V]=(0,O.useState)(``),[qe,W]=(0,O.useState)(``),[G,K]=(0,O.useState)(!1),[q,Je]=(0,O.useState)(``),[Ye,Xe]=(0,O.useState)(!1),[Ze,Qe]=(0,O.useState)(()=>new Set(ze(A))),[J,$e]=(0,O.useState)(null),[et,tt]=(0,O.useState)(null),[Y,nt]=(0,O.useState)(null),rt=(0,O.useRef)(``),it=(0,O.useRef)(``),X=(0,O.useMemo)(()=>H(E),[E]),Z=X.find(e=>e.cid===g),at=(0,O.useMemo)(()=>Ke(X,n),[n,X]),ot=(0,O.useMemo)(()=>Ue(X,n),[n,X]),st=(0,O.useMemo)(()=>We(ot,L),[ot,L]),ct=(0,O.useMemo)(()=>Le(z?.content||``,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.content,z?.directory,Z?.path,X]),lt=(0,O.useCallback)(e=>Ie(e,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.directory,Z?.path,X]);(0,O.useEffect)(()=>{Z?.path&&Qe(e=>Ve(e,ze(Z.path)))},[Z?.path]),(0,O.useEffect)(()=>{if(!o.path||g||X.length===0)return;let e=Fe(X,o.path);e&&(j(f(e.path||``)),r({href:N({file:e.cid}),replace:!0}))},[g,r,o.path,X]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||rt.current===t||M)return;if(!l){let e=`${t}:auth`;it.current!==e&&(it.current=e,m());return}if(x?.configured!==!0){let n=`${t}:vault`;it.current!==n&&(it.current=n,c(e(`note.chatDraft.openVaultFirst`),`warning`));return}let n=re(t);if(!n){rt.current=t,c(e(`note.chatDraft.missing`),`warning`),$({},!0);return}rt.current=t,_t(n)},[c,o.chatDraft,e,M,x?.configured,l]);let Q=(0,O.useCallback)(async()=>{if(!l){me(null),D([]),Me(e(`note.vault.loginRequired`)),P(!1);return}P(!0),Me(``);try{let e=await ve();me(e),e.configured?D(await C()):D([])}catch(t){me(null),D([]),Me(await u(t,e(`note.vault.loadFailed`)))}finally{P(!1)}},[e,l]);(0,O.useEffect)(()=>{Q()},[Q]),(0,O.useEffect)(()=>{V(F(z?.name||Z?.name||``))},[z?.name,Z?.name]),(0,O.useEffect)(()=>{let t=!1;async function n(){if(!g){B(null),W(``),Je(``),K(!1);return}if(!l){B(null),W(``),Je(e(`note.vault.loginRequired`)),K(!1);return}if(x?.configured!==!0){B(null),W(``),Je(``),K(!1);return}K(!0),Je(``);try{let e=await ge(g);if(t)return;B(e),W(e.content)}catch(n){if(t)return;B(null),W(``),Je(await u(n,e(`note.error.notFound`)))}finally{t||K(!1)}}return n(),()=>{t=!0}},[g,e,x?.configured,l]);function $(e={},t=!1){r({href:N(e),replace:t})}function ut(e){$(Ee(e))}function dt(e){j(f(e.path||``)),$({file:e.cid})}function ft(e){j(e.fullPath),Qe(t=>Be(t,e.fullPath))}function pt(){g&&$({file:g,mode:`edit`})}function mt(){V(F(z?.name||Z?.name||``)),$(g?{file:g}:{})}async function ht(){if(!l){m();return}let t=window.electronAPI?.selectNoteVaultDirectory;if(!t){c(e(`note.vault.selectFailed`),`error`);return}Pe(!0);try{let n=await t();if(!n)return;await _e(n),await Q(),$({},!0),c(e(`note.vault.opened`),`success`)}catch(t){c(await u(t,e(`note.vault.selectFailed`)),`error`)}finally{Pe(!1)}}function gt(){return l?x?.configured===!0?!0:(c(e(`note.vault.emptyPrompt`),`warning`),!1):(m(),!1)}async function _t(t){if(gt())try{let n=ke(t.title,e(`note.chatDraft.defaultTitle`),e=>E.some(t=>f(t.directory)===f(A)&&t.name===e)),r=await S(f(A?`${A}/${n}`:n),t.content);ie(t.id),await Q(),c(e(`note.chatDraft.created`),`success`),$({file:r.path,mode:`edit`},!0)}catch(t){rt.current=``,c(await u(t,e(`note.toast.createFailed`)),`error`)}}function vt(){gt()&&$e({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(!gt())return;let n=U(A,t);if(!n){c(e(`note.toast.nameRequired`),`warning`);return}try{let t=await S(n,``);$e(null),await Q(),$({file:t.path,mode:`edit`}),c(e(`note.toast.created`),`success`)}catch(t){c(await u(t,e(`note.toast.createFailed`)),`error`)}}})}function yt(e){gt()&&nt(e)}async function bt(t){if(!(!Y||!gt()))try{let n=g;if(Y.type===`directory`){let e=Oe(Y),r=f(t?`${t}/${Y.name}`:Y.name),i=E.filter(t=>t.path.startsWith(`${e}/`));for(let t of i){let i=f(`${r}/${t.path.slice(e.length+1)}`);await w(t.path,i),g===t.path&&(n=i)}}else{let e=f(t?`${t}/${Y.name}`:Y.name),r=await w(Y.cid,e);g===Y.cid&&(n=r.path)}nt(null),await Q(),$(n?{file:n}:{},!0),c(e(`note.toast.moved`),`success`)}catch(t){c(await u(t,e(`note.toast.moveFailed`)),`error`)}}function xt(t){gt()&&tt({title:t.type===`directory`?e(`note.delete.folderTitle`):e(`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{try{if(t.type===`directory`){let e=Oe(t),n=E.filter(t=>t.path.startsWith(`${e}/`));for(let e of n)await he(e.path);g.startsWith(`${e}/`)&&$({},!0)}else await he(t.cid),g===t.cid&&$({},!0);tt(null),await Q(),c(e(`note.toast.deleted`),`success`)}catch(t){c(await u(t,e(`note.toast.deleteFailed`)),`error`)}}})}async function St(){if(!l){m();return}if(!g||!z){c(e(`note.toast.notFound`),`error`);return}let t=I(He);if(!t){c(e(`note.toast.nameRequired`),`warning`);return}Xe(!0);try{let n=s.current?.getMarkdown()??qe,r=z.path;if(t!==z.name){r=f(z.directory?`${z.directory}/${t}`:t);let e=await w(z.path,r);B(e),V(F(e.name)),r=e.path}let i=await T(r,n);B(i),V(F(i.name)),W(i.content),await Q(),$({file:i.path},!0),c(e(`note.toast.saved`),`success`)}catch(t){c(await u(t,e(`note.toast.saveFailed`)),`error`)}finally{Xe(!1)}}let Ct=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:E.length})})]}),wt=(0,k.jsx)(`div`,{className:`note-theme-wrap`,children:(0,k.jsxs)(`button`,{className:`btn btn-sm`,onClick:ht,disabled:R,title:e(`note.vault.open`),"aria-label":e(`note.vault.open`),children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})}),Tt=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:L,onChange:e=>Ne(e.target.value),placeholder:e(`note.search.placeholder`)})]}),M?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):De?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(_,{size:32}),(0,k.jsx)(`p`,{children:De})]}):x?.configured===!0?st.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(L?`note.empty.noMatches`:`note.vault.noFiles`)})]}):(0,k.jsx)(Ge,{nodes:st,searchQuery:L,expandedPaths:Ze,activeFileId:g,activeFolderPath:g?``:A,onToggleDirectory:ft,onOpenFile:dt,renderActions:t=>(0,k.jsx)(pe,{ariaLabel:e(`common.moreActions`),className:`note-list-actions-anchor`,placement:`bottom-end`,items:[{key:`move`,label:e(`note.action.move`),icon:(0,k.jsx)(be,{size:16}),onSelect:()=>yt(t)},{key:`delete`,label:e(`note.action.delete`),icon:(0,k.jsx)(oe,{size:16}),danger:!0,onSelect:()=>xt(t)}],renderTrigger:t=>(0,k.jsx)(`button`,{...t,className:`note-list-actions-trigger`,title:e(`common.moreActions`),"aria-label":e(`common.moreActions`),children:(0,k.jsx)(p,{size:16})})})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(h,{size:32}),(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]}),x?.configured===!0&&(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:vt,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]}),Et=z?.mtimeMs||Z?.updated_at||Date.now(),Dt=F(z?.name||Z?.name||``)||e(`note.untitled`);return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:Tt}),headerTitle:Ct,headerRight:wt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${y?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(b?`note.editorLabel.edit`:`note.editorLabel.read`),children:y?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[b&&z?(0,k.jsx)(`input`,{className:`note-title-input`,value:He,onChange:e=>V(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.currentTarget.blur();return}e.key===`Escape`&&(V(F(z.name)),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),translate:`no`}):(0,k.jsx)(`h3`,{translate:`no`,children:Dt}),(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(b?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{translate:`no`,children:je(g)}),(0,k.jsx)(`span`,{children:t(Et)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:b?mt:()=>$(),title:e(b?`common.cancel`:`common.close`),"aria-label":e(b?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),b?(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:St,disabled:Ye||!!q||!z,children:[(0,k.jsx)(ce,{size:16}),e(Ye?`note.action.saving`:`note.action.save`)]}):Z&&(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:pt,disabled:!!q||!z,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]}),G?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):q?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:q})]}):b?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:s,content:qe,onChange:W,className:`milkdown-editor`})}):z?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:ct,readOnly:!0,onInternalNoteLinkOpen:ut,resolveWikiNoteLink:lt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.error.notFound`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:x?.configured?e(`note.noOpen.title`):e(`note.vault.open`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:x?.configured?e(`note.noOpen.select`):e(`note.vault.emptyPrompt`)}),x?.configured?(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`}):(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]})})})}),J&&(0,k.jsx)(ue,{title:J.title,placeholder:J.placeholder,defaultValue:J.defaultValue,confirmText:J.confirmText,onConfirm:J.onConfirm,onClose:()=>$e(null)}),et&&(0,k.jsx)(ye,{title:et.title,message:et.message,confirmText:et.confirmText,danger:!0,onConfirm:et.onConfirm,onClose:()=>tt(null)}),Y&&(0,k.jsx)(Se,{target:Y,targetLabel:Re(Y),directories:at,onMove:bt,onClose:()=>nt(null)})]})}function q(){let{t:e}=te(),t=d(e=>e.hasBackend),n=a(e=>e.wallet),r=y(),i=t===!0&&qe(c()),o=W(i,n?.address||``),s=i&&(r||o);return(0,k.jsx)(O.Suspense,{fallback:(0,k.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:s?(0,k.jsx)(K,{}):(0,k.jsx)(G,{})})}var Je=o(`/note/`)({component:q});export{Je as Route};
@@ -1 +1 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,O as ee,W as o,n as te,o as ne,t as s}from"./useAppStore-DNhyhD20.js";import{a as c}from"./i18n-DKsg67mH.js";import{t as l}from"./fingerprint-pattern-BT73ASEB.js";import{t as u}from"./circle-alert-DXVkx8p8.js";import{a as d,i as f}from"./AccountMenu-B26qus-Q.js";import{t as re}from"./download-Cy2BlfKM.js";import{t as ie}from"./external-link-D_AQSgxW.js";import{n as ae,t as p}from"./CopyButton-BrEkzqEq.js";import{t as m}from"./loader-C4pED_QP.js";import{t as h}from"./save-CfYzXcxH.js";import{t as g}from"./shield-check-2-h_eEXp.js";import{t as _}from"./upload-BmufnMFu.js";import{I as v,O as y,T as b,_ as x,g as S,h as C,o as oe,v as w,w as se,y as T}from"./index-mjFWLwue.js";import{t as E}from"./MarketingLayout-Ch4sw5Qm.js";import{t as ce}from"./MarketingHeader-CJXpogPY.js";import{n as le}from"./mp-cEQteKUC.js";var ue=r(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),de=r(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),fe=r(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),pe=r(`wallet-cards`,[[`path`,{d:`M3 11h3.75a2 2 0 0 1 1.6.8l.45.6a4 4 0 0 0 6.4 0l.45-.6a2 2 0 0 1 1.6-.8H21`,key:`1vwh6y`}],[`path`,{d:`M3 7h18`,key:`1uiuf2`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),D=t(e(),1),O=n(),k=[{value:``,labelKey:`profile.avatar.address`},...C.map(e=>({value:x(e),labelKey:`profile.avatar.${e}`}))];function A(e){if(w(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function M({status:e,busy:t}){return t||e===`working`?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):e===`synced`?(0,O.jsx)(v,{size:16}):e===`error`?(0,O.jsx)(u,{size:16}):(0,O.jsx)(g,{size:16})}function N(){let{formatNumber:e,t}=c(),n=s(e=>e.addToast),r=s(e=>e.hasBackend),a=i(e=>e.identity),u=i(e=>e.openLoginModal),v=i(e=>e.setUserIdentity),x=i(e=>e.logoutUser),C=oe(),[w,N]=(0,D.useState)(``),[I,L]=(0,D.useState)(``),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null),W=(0,O.jsx)(ce,{});(0,D.useEffect)(()=>{if(!a){N(``),L(``),z(``);return}N(a.displayName||a.username),L(T(a.avatar)||a.avatar||``),z(``)},[a]),(0,D.useEffect)(()=>{a&&C.refreshBackupSummary()},[C.refreshBackupSummary,r,a]);let G=(0,D.useMemo)(()=>a?ee(a.danger):null,[a]),me=(0,D.useMemo)(()=>G?le(G.private_key,G.ed_public_key):``,[G]);if(!a)return(0,O.jsx)(E,{header:W,children:(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsx)(`div`,{className:`profile-container narrow`,children:(0,O.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,O.jsx)(`div`,{className:`profile-empty-icon`,children:(0,O.jsx)(f,{size:34})}),(0,O.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,O.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,children:[(0,O.jsx)(f,{size:16}),t(`account.signIn`)]})]})})})});let he=T(a.avatar)||a.avatar||``,ge=S(a.address,a.avatar),K=a.address.toLowerCase(),_e=I.trim().length>0,ve=j(C.status),q=C.action===`backup`,J=C.action===`restore`,Y=C.action===`export`,X=C.action===`import`,ye=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:C.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:C.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:C.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:C.backupSummary.channelsCount}];function be(){U({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{U(null),await C.backupToCloud()}})}function xe(){U({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{U(null),await C.restoreFromCloud({confirm:!1})}})}function Se(){return new Promise(e=>{let n=t=>{U(null),e(t)};U({title:t(`profile.backup.confirm.importTitle`),message:t(`profile.backup.confirm.restore`),confirmText:t(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function Z(){C.importLocalBackup({requestConfirm:Se})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(q?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:q?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(de,{size:16}),onClick:be},{key:`cloud-restore`,tone:`cloud-restore`,label:t(J?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:J?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(ue,{size:16}),onClick:xe},{key:`export-local`,tone:`export-local`,label:t(Y?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:Y?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(re,{size:16}),onClick:C.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(X?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:X?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(_,{size:16}),onClick:Z}];async function Q(e){if(r===!0)try{await te.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await ne(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!a)return;let r={...a,avatar:e||void 0,profileUpdatedAt:Date.now()};v(r),Q(r),z(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!a)return;let e=w.trim()||a.username,r={...a,displayName:e,profileUpdatedAt:Date.now()};v(r),Q(r),N(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=I.trim();if(!e){$(void 0);return}if(!A(e)){z(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){x(),V(!1)}return(0,O.jsxs)(E,{header:W,children:[(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsxs)(`div`,{className:`profile-container`,children:[(0,O.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,O.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,O.jsxs)(`span`,{className:`profile-backup-status ${ve}`,children:[(0,O.jsx)(M,{status:C.status,busy:C.busy}),C.statusLabel]})]}),(0,O.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ye.map(t=>(0,O.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,O.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?C.backupSummary.loading?`...`:`-`:e(t.value)}),(0,O.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,O.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:C.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,O.jsxs)(`header`,{className:`profile-header`,children:[(0,O.jsx)(`img`,{className:`profile-avatar-large`,src:ge,alt:``}),(0,O.jsxs)(`div`,{className:`profile-heading`,children:[(0,O.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,O.jsx)(`h1`,{children:a.displayName||a.username}),(0,O.jsxs)(`div`,{className:`profile-address-line`,children:[(0,O.jsx)(`code`,{translate:`no`,children:K}),(0,O.jsx)(p,{text:K}),(0,O.jsxs)(`a`,{href:`https://debank.com/profile/${a.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,O.jsx)(ie,{size:14}),t(`web3.action.view`)]})]})]}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>V(!0),children:[(0,O.jsx)(fe,{size:16}),t(`account.logout`)]})]}),(0,O.jsxs)(`div`,{className:`profile-grid`,children:[(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,O.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,O.jsxs)(`label`,{className:`profile-field`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{className:`input`,value:w,onChange:e=>N(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),(0,O.jsx)(`div`,{className:`profile-facts`,children:(0,O.jsx)(P,{label:t(`profile.label.username`),value:a.username})})]}),(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,O.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,O.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:k.map(e=>{let n=he===e.value;return(0,O.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>$(e.value),"aria-pressed":n,title:t(e.labelKey),children:[(0,O.jsx)(`img`,{src:S(a.address,e.value),alt:``,"aria-hidden":`true`}),(0,O.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,O.jsx)(`span`,{className:`profile-avatar-check`,children:(0,O.jsx)(d,{size:14})})]},e.value||`address`)})}),(0,O.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,O.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!_e,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),R&&(0,O.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,O.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,O.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,O.jsxs)(o,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,O.jsx)(pe,{size:16}),t(`profile.action.openWallet`)]})]}),(0,O.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(F,{title:t(`web3.label.ed25519Public`),icon:(0,O.jsx)(l,{size:18}),value:G.ed_public_key}),(0,O.jsx)(F,{title:t(`web3.label.x25519Public`),icon:(0,O.jsx)(ae,{size:18}),value:G.public_key})]}),(0,O.jsx)(F,{title:`IPNS ID`,icon:(0,O.jsx)(g,{size:18}),value:me||`-`})]})]})]})}),H&&(0,O.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:H.danger,onConfirm:H.onConfirm,onClose:H.onClose||(()=>U(null))}),B&&(0,O.jsx)(b,{className:`profile-logout-overlay`,onClose:()=>V(!1),children:(0,O.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`modal-header`,children:[(0,O.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>V(!1),"aria-label":t(`common.close`),children:(0,O.jsx)(y,{size:18})})]}),(0,O.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,O.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.backupToCloud(),children:t(`profile.backup.action.cloudBackup`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.exportLocalBackup(),children:t(`profile.backup.action.exportLocal`)})]}),(0,O.jsxs)(`div`,{className:`modal-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>V(!1),children:t(`common.cancel`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function P({label:e,value:t,copy:n=!1}){return(0,O.jsxs)(`div`,{className:`profile-fact`,children:[(0,O.jsx)(`span`,{children:e}),(0,O.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,O.jsx)(`code`,{translate:`no`,children:t}),n&&(0,O.jsx)(p,{text:t})]})]})}function F({title:e,icon:t,value:n}){return(0,O.jsxs)(`div`,{className:`profile-key-card`,children:[(0,O.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,O.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,O.jsx)(`span`,{children:e})]}),(0,O.jsxs)(`div`,{className:`mono-row`,children:[(0,O.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,O.jsx)(p,{text:n})]})]})}var I=a(`/profile/`)({component:N});export{I as Route};
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,O as ee,W as o,n as te,o as ne,t as s}from"./useAppStore-DNhyhD20.js";import{a as c}from"./i18n-DKsg67mH.js";import{t as l}from"./fingerprint-pattern-BT73ASEB.js";import{t as u}from"./circle-alert-DXVkx8p8.js";import{a as d,i as f}from"./AccountMenu-D_rcXDZr.js";import{t as re}from"./download-Cy2BlfKM.js";import{t as ie}from"./external-link-D_AQSgxW.js";import{n as ae,t as p}from"./CopyButton-ClwBN6Iy.js";import{t as m}from"./loader-C4pED_QP.js";import{t as h}from"./save-CfYzXcxH.js";import{t as g}from"./shield-check-2-h_eEXp.js";import{t as _}from"./upload-BmufnMFu.js";import{I as v,O as y,T as b,_ as x,g as S,h as C,o as oe,v as w,w as se,y as T}from"./index-DJzLHA0V.js";import{t as E}from"./MarketingLayout-hkPAtieL.js";import{t as ce}from"./MarketingHeader-ChTIIzXG.js";import{n as le}from"./mp-cEQteKUC.js";var ue=r(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),de=r(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),fe=r(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),pe=r(`wallet-cards`,[[`path`,{d:`M3 11h3.75a2 2 0 0 1 1.6.8l.45.6a4 4 0 0 0 6.4 0l.45-.6a2 2 0 0 1 1.6-.8H21`,key:`1vwh6y`}],[`path`,{d:`M3 7h18`,key:`1uiuf2`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),D=t(e(),1),O=n(),k=[{value:``,labelKey:`profile.avatar.address`},...C.map(e=>({value:x(e),labelKey:`profile.avatar.${e}`}))];function A(e){if(w(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function M({status:e,busy:t}){return t||e===`working`?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):e===`synced`?(0,O.jsx)(v,{size:16}):e===`error`?(0,O.jsx)(u,{size:16}):(0,O.jsx)(g,{size:16})}function N(){let{formatNumber:e,t}=c(),n=s(e=>e.addToast),r=s(e=>e.hasBackend),a=i(e=>e.identity),u=i(e=>e.openLoginModal),v=i(e=>e.setUserIdentity),x=i(e=>e.logoutUser),C=oe(),[w,N]=(0,D.useState)(``),[I,L]=(0,D.useState)(``),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null),W=(0,O.jsx)(ce,{});(0,D.useEffect)(()=>{if(!a){N(``),L(``),z(``);return}N(a.displayName||a.username),L(T(a.avatar)||a.avatar||``),z(``)},[a]),(0,D.useEffect)(()=>{a&&C.refreshBackupSummary()},[C.refreshBackupSummary,r,a]);let G=(0,D.useMemo)(()=>a?ee(a.danger):null,[a]),me=(0,D.useMemo)(()=>G?le(G.private_key,G.ed_public_key):``,[G]);if(!a)return(0,O.jsx)(E,{header:W,children:(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsx)(`div`,{className:`profile-container narrow`,children:(0,O.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,O.jsx)(`div`,{className:`profile-empty-icon`,children:(0,O.jsx)(f,{size:34})}),(0,O.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,O.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,children:[(0,O.jsx)(f,{size:16}),t(`account.signIn`)]})]})})})});let he=T(a.avatar)||a.avatar||``,ge=S(a.address,a.avatar),K=a.address.toLowerCase(),_e=I.trim().length>0,ve=j(C.status),q=C.action===`backup`,J=C.action===`restore`,Y=C.action===`export`,X=C.action===`import`,ye=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:C.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:C.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:C.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:C.backupSummary.channelsCount}];function be(){U({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{U(null),await C.backupToCloud()}})}function xe(){U({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{U(null),await C.restoreFromCloud({confirm:!1})}})}function Se(){return new Promise(e=>{let n=t=>{U(null),e(t)};U({title:t(`profile.backup.confirm.importTitle`),message:t(`profile.backup.confirm.restore`),confirmText:t(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function Z(){C.importLocalBackup({requestConfirm:Se})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(q?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:q?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(de,{size:16}),onClick:be},{key:`cloud-restore`,tone:`cloud-restore`,label:t(J?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:J?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(ue,{size:16}),onClick:xe},{key:`export-local`,tone:`export-local`,label:t(Y?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:Y?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(re,{size:16}),onClick:C.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(X?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:X?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(_,{size:16}),onClick:Z}];async function Q(e){if(r===!0)try{await te.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await ne(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!a)return;let r={...a,avatar:e||void 0,profileUpdatedAt:Date.now()};v(r),Q(r),z(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!a)return;let e=w.trim()||a.username,r={...a,displayName:e,profileUpdatedAt:Date.now()};v(r),Q(r),N(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=I.trim();if(!e){$(void 0);return}if(!A(e)){z(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){x(),V(!1)}return(0,O.jsxs)(E,{header:W,children:[(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsxs)(`div`,{className:`profile-container`,children:[(0,O.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,O.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,O.jsxs)(`span`,{className:`profile-backup-status ${ve}`,children:[(0,O.jsx)(M,{status:C.status,busy:C.busy}),C.statusLabel]})]}),(0,O.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ye.map(t=>(0,O.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,O.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?C.backupSummary.loading?`...`:`-`:e(t.value)}),(0,O.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,O.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:C.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,O.jsxs)(`header`,{className:`profile-header`,children:[(0,O.jsx)(`img`,{className:`profile-avatar-large`,src:ge,alt:``}),(0,O.jsxs)(`div`,{className:`profile-heading`,children:[(0,O.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,O.jsx)(`h1`,{children:a.displayName||a.username}),(0,O.jsxs)(`div`,{className:`profile-address-line`,children:[(0,O.jsx)(`code`,{translate:`no`,children:K}),(0,O.jsx)(p,{text:K}),(0,O.jsxs)(`a`,{href:`https://debank.com/profile/${a.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,O.jsx)(ie,{size:14}),t(`web3.action.view`)]})]})]}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>V(!0),children:[(0,O.jsx)(fe,{size:16}),t(`account.logout`)]})]}),(0,O.jsxs)(`div`,{className:`profile-grid`,children:[(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,O.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,O.jsxs)(`label`,{className:`profile-field`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{className:`input`,value:w,onChange:e=>N(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),(0,O.jsx)(`div`,{className:`profile-facts`,children:(0,O.jsx)(P,{label:t(`profile.label.username`),value:a.username})})]}),(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,O.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,O.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:k.map(e=>{let n=he===e.value;return(0,O.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>$(e.value),"aria-pressed":n,title:t(e.labelKey),children:[(0,O.jsx)(`img`,{src:S(a.address,e.value),alt:``,"aria-hidden":`true`}),(0,O.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,O.jsx)(`span`,{className:`profile-avatar-check`,children:(0,O.jsx)(d,{size:14})})]},e.value||`address`)})}),(0,O.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,O.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!_e,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),R&&(0,O.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,O.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,O.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,O.jsxs)(o,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,O.jsx)(pe,{size:16}),t(`profile.action.openWallet`)]})]}),(0,O.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(F,{title:t(`web3.label.ed25519Public`),icon:(0,O.jsx)(l,{size:18}),value:G.ed_public_key}),(0,O.jsx)(F,{title:t(`web3.label.x25519Public`),icon:(0,O.jsx)(ae,{size:18}),value:G.public_key})]}),(0,O.jsx)(F,{title:`IPNS ID`,icon:(0,O.jsx)(g,{size:18}),value:me||`-`})]})]})]})}),H&&(0,O.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:H.danger,onConfirm:H.onConfirm,onClose:H.onClose||(()=>U(null))}),B&&(0,O.jsx)(b,{className:`profile-logout-overlay`,onClose:()=>V(!1),children:(0,O.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`modal-header`,children:[(0,O.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>V(!1),"aria-label":t(`common.close`),children:(0,O.jsx)(y,{size:18})})]}),(0,O.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,O.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.backupToCloud(),children:t(`profile.backup.action.cloudBackup`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.exportLocalBackup(),children:t(`profile.backup.action.exportLocal`)})]}),(0,O.jsxs)(`div`,{className:`modal-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>V(!1),children:t(`common.cancel`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function P({label:e,value:t,copy:n=!1}){return(0,O.jsxs)(`div`,{className:`profile-fact`,children:[(0,O.jsx)(`span`,{children:e}),(0,O.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,O.jsx)(`code`,{translate:`no`,children:t}),n&&(0,O.jsx)(p,{text:t})]})]})}function F({title:e,icon:t,value:n}){return(0,O.jsxs)(`div`,{className:`profile-key-card`,children:[(0,O.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,O.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,O.jsx)(`span`,{children:e})]}),(0,O.jsxs)(`div`,{className:`mono-row`,children:[(0,O.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,O.jsx)(p,{text:n})]})]})}var I=a(`/profile/`)({component:N});export{I as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,c as o,o as s,t as c,u as l}from"./useAppStore-DNhyhD20.js";import{a as ee}from"./i18n-DKsg67mH.js";import{a as u}from"./AccountMenu-D_rcXDZr.js";import{t as te}from"./OpenSidebarButton-CXBAjjCE.js";import{a as d,i as f,n as ne,o as re,r as p,t as ie}from"./saveLocalFile-DTgdBgO9.js";import{t as ae}from"./arrow-up-down-DvLSz6Ma.js";import{n as oe,t as se}from"./trash-2-B9gno5q6.js";import{t as ce}from"./copy-OwXDsstV.js";import{t as le}from"./download-Cy2BlfKM.js";import{t as ue}from"./file-text-zvTER2mN.js";import{t as m}from"./folder-6pYYnS2-.js";import{t as de}from"./loader-C4pED_QP.js";import{r as fe,t as pe}from"./AppShell-CKP_dglR.js";import{t as h}from"./music-Br2x8TKX.js";import{t as me}from"./search-DLBOUfny.js";import{t as he}from"./upload-BmufnMFu.js";import{C as ge,O as g,T as _,w as _e}from"./index-DJzLHA0V.js";import{t as ve}from"./AppTop-C03PsDr_.js";import{t as ye}from"./format-CAKfypjK.js";import{a as be,i as xe,n as v,r as Se,t as Ce}from"./downloadValidation-Dd43i9_9.js";var we=r(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),Te=r(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Ee=r(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),y=t(e(),1);function De(e={}){let t=e.timeout??2e3,[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>{window.clearTimeout(o.current)},[]);let s=e=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>a(!1),t),a(e)};return{copy:e=>{`clipboard`in navigator?navigator.clipboard.writeText(e).then(()=>{r(null),s(!0)}).catch(e=>r(e)):r(Error(`useClipboard: navigator.clipboard is not supported`))},reset:()=>{a(!1),r(null),window.clearTimeout(o.current)},error:n,copied:i}}var b=n();function Oe(e){let t=e.lastIndexOf(`/`);return t===-1?{folder:``,name:e}:{folder:e.substring(0,t),name:e.substring(t+1)}}function ke({file:e,isSelected:t,onSelect:n,onPreview:r}){let i=p(e.fileName),a=(0,b.jsx)(ue,{size:24,color:`#fff`});return i===`image`?a=(0,b.jsx)(f,{size:24,color:`#fff`}):i===`video`?a=(0,b.jsx)(d,{size:24,color:`#fff`}):i===`audio`&&(a=(0,b.jsx)(h,{size:24,color:`#fff`})),(0,b.jsxs)(`div`,{"data-id":e.cid,onClick:()=>n(e.cid),onDoubleClick:()=>r(e),className:`card ${t?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon ${e.starred?`starred`:`file`}`,children:a}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:Oe(e.fileName).name})]})}function Ae({folder:e,onClick:t}){return(0,b.jsxs)(`div`,{onClick:t,className:`card`,children:[(0,b.jsx)(`div`,{className:`card-icon folder`,children:(0,b.jsx)(m,{size:28,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:e.name})]})}function x(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function je({items:e,allFolders:t,currentPath:n,onMove:r,onClose:i}){let[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(n),{t:l}=ee(),u=x(a,l(`move.root`));function te(){r(a||s.trim())}let d=t.filter(e=>{if(a===``)return!e.path.includes(`/`);let t=a+`/`;return e.path.startsWith(t)?!e.path.substring(t.length).includes(`/`):!1});return(0,b.jsx)(_,{onClose:i,children:(0,b.jsxs)(`div`,{className:`move-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:l(`move.title`)}),(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsx)(`p`,{className:`move-modal-desc`,children:l(`move.selectedCount`,{count:e.length})}),(0,b.jsx)(`div`,{className:`move-new-folder`,children:(0,b.jsx)(`input`,{type:`text`,className:`input`,value:s,onChange:e=>c(e.target.value),placeholder:l(`move.pathPlaceholder`),translate:`no`})}),(0,b.jsx)(`p`,{className:`move-modal-hint`,children:l(`move.pathExample`)}),(0,b.jsx)(`div`,{className:`move-breadcrumb`,children:u.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&(0,b.jsx)(`span`,{className:`breadcrumb-separator`,children:`/`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{o(e.path),c(e.path)},className:`move-breadcrumb-btn ${a===e.path&&!s?`active`:``}`,children:(0,b.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.name})})]},e.path))}),(0,b.jsxs)(`div`,{className:`move-folder-list`,children:[d.length===0&&(0,b.jsx)(`p`,{className:`move-modal-empty`,children:l(`move.noSubfolders`)}),d.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>o(e.path),className:`move-folder-item ${a===e.path&&!s?`selected`:``}`,children:[(0,b.jsx)(m,{size:16}),(0,b.jsx)(`span`,{translate:`no`,children:e.name})]},e.path))]}),(0,b.jsxs)(`div`,{className:`modal-actions`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-secondary`,children:l(`common.cancel`)}),(0,b.jsx)(`button`,{type:`button`,onClick:te,className:`btn btn-primary`,children:l(`move.action`)})]})]})})}var S=`https://most.box`;function C(e){return String(e||``).trim()}function Me(e,t){let n=C(t);return n?`most://${e}?filename=${encodeURIComponent(n)}`:`most://${e}`}function Ne(e,t){let n=C(t),r=`${S}/cid/${encodeURIComponent(e)}`;return n?`${r}?filename=${encodeURIComponent(n)}`:r}function w(e){return Oe(e)}function Pe(e){let t=new Set;return e.forEach(e=>{let{folder:n}=w(e.fileName),r=n.split(`/`).filter(Boolean),i=``;for(let e of r)i+=(i?`/`:``)+e,t.add(i)}),[...t].sort()}function Fe(e,t){let n=t?t+`/`:``;return e.filter(e=>{let t=e.toLowerCase().startsWith(n.toLowerCase()),r=e.substring(n.length);return t&&!r.includes(`/`)}).map(e=>({name:e.substring(n.length),path:e}))}function Ie(e,t,n){return{folders:Fe(t,n),files:e.filter(e=>w(e.fileName).folder===n)}}function Le(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function T(){let e=c(e=>e.addToast),t=c(e=>e.hasBackend),n=c(e=>e.openConnectModal),r=i(e=>e.identity),a=i(e=>e.openLoginModal),[d,f]=(0,y.useState)([]),[m,h]=(0,y.useState)([]),[Oe,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(`all`),[Fe,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)([]),[Re,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),[ze,Be]=fe(!1),[Ve,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(null),[P,He]=(0,y.useState)(!1),[Ue,F]=(0,y.useState)([]),[We,I]=fe(!1),[L,R]=(0,y.useState)(``),{copy:Ge,copied:Ke}=De({timeout:2e3}),{copy:qe,copied:Je}=De({timeout:2e3}),[Ye,Xe]=fe(!1),[z,B]=(0,y.useState)(null),[V,Ze]=(0,y.useState)(null),[Qe,$e]=(0,y.useState)(!1),{t:H,formatDate:et}=ee(),U=t===!0,tt=e=>e?et(e):``,W=Oe||``,nt=Pe(d),{folders:rt,files:it}=Ie(d,nt,W);function G(){return U?!0:(n(),!1)}function K(){return r?!0:(a(),!1)}let at=L?d.filter(e=>w(e.fileName).name.toLowerCase().includes(L.toLowerCase())):it,q=async()=>{if(!U||!r){f([]);return}try{f(await v.listPublishedFiles()||[])}catch{f([])}},J=async()=>{if(!U||!r){h([]);return}try{h(await v.listTrashFiles()||[])}catch{h([])}},ot=e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},st=async t=>{if(K()&&G())try{await v.restoreTrashFile(t),e(H(`app.toast.restored`),`success`),q(),J()}catch(t){e(await s(t,H(`app.toast.restoreFailed`)),`error`)}},ct=async()=>{K()&&G()&&B({title:H(`app.clearTrash.title`),message:H(`app.clearTrash.message`),confirmText:H(`app.clear`),danger:!0,onConfirm:async()=>{B(null);try{await v.emptyTrash(),e(H(`app.toast.trashEmptied`),`success`),J()}catch(t){e(await s(t,H(`app.toast.emptyFailed`)),`error`)}}})},lt=async t=>{if(K()&&G())try{let n=await v.toggleStar(t);f(e=>e.map(e=>e.cid===t?{...e,starred:n.starred}:e)),e(n.starred?H(`app.toast.favorited`):H(`app.toast.unfavorited`),`success`)}catch(t){e(await s(t,H(`app.toast.actionFailed`)),`error`)}},ut=async()=>{if(!K()||!G())return;let t=S===`trash`;B({title:H(t?`app.permanentDelete`:`app.batchDelete`),message:H(t?`app.deleteSelectedPermanent`:`app.deleteSelected`,{count:E.length}),confirmText:H(t?`app.permanentDelete`:`app.delete`),danger:!0,onConfirm:async()=>{B(null);try{for(let e of E)t?await v.permanentDeleteTrashFile(e):e.startsWith(`__`)||await v.deletePublishedFile(e);D([]),e(H(t?`app.toast.deletedPermanently`:`app.toast.deleted`),`success`),q(),J()}catch(t){e(await s(t,H(`app.toast.deleteFailed`)),`error`)}}})},dt=async t=>{if(K()&&G())try{for(let e of E){let n=d.find(t=>t.cid===e);if(!n)continue;let{name:r}=w(n.fileName),i=t?`${t}/${r}`:r;n.fileName!==i&&await v.moveFile(e,i)}D([]),Xe.close(),e(H(`app.toast.moved`),`success`),q()}catch(t){e(await s(t,H(`app.toast.moveFailed`)),`error`)}},ft=t=>{let n=!!t.path,r=n?t.name:w(t.fileName).name;Ze({title:H(n?`app.renameFolder`:`app.renameFile`),placeholder:H(`app.enterNewName`),defaultValue:r,confirmText:H(`app.rename`),onConfirm:async i=>{if(i!==r&&K()&&G()){$e(!0);try{if(n){let n=t.path.lastIndexOf(`/`),r=n===-1?``:t.path.substring(0,n),a=r?`${r}/${i}`:i;await v.renameFolder(t.path,a),e(H(`app.toast.renamed`),`success`),q(),Q(a)}else{let{folder:n}=w(t.fileName),r=n?`${n}/${i}`:i;await v.moveFile(t.cid,r),e(H(`app.toast.renamed`),`success`),q()}Ze(null)}catch(t){e(await s(t,H(`app.toast.renameFailed`)),`error`)}finally{$e(!1)}}}})},pt=async t=>{if(!r){a(),e(H(`app.toast.signInBeforePublish`),`warning`);return}if(!G())return;let n=W?W+`/`:``,i=[],o=await v.getNodePolicy().catch(()=>null),s=Array.from(t);for(let t of s){let r=n+t.name,a=be(t,o,H);if(a){e(a,`error`);continue}if(d.some(e=>e.fileName===r)){e(H(`app.fileAlreadyExists`,{fileName:t.name}),`warning`);continue}let s=`upload_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,c={id:s,fileName:t.name,progress:0,type:`upload`,status:`uploading`};i.push(c),F(e=>[...e,c]),i.length>0&&I.open();try{(await v.publishFile(t,r)).alreadyExists?(F(e=>e.map(e=>e.id===s?{...e,status:`completed`}:e)),e(H(`app.fileAlreadyExists`,{fileName:t.name}),`warning`)):F(e=>e.map(e=>e.id===s?{...e,progress:100,status:`completed`}:e))}catch(n){F(e=>e.map(e=>e.id===s?{...e,status:`error`}:e)),e(await xe(n,H(`app.publishFailedWithFile`,{fileName:t.name}),H,t.name),`error`)}}setTimeout(()=>{F(e=>e.filter(e=>e.status!==`completed`&&e.status!==`error`&&e.status!==`cancelled`))},3e3),q()},mt=k?Me(k.cid,k.fileName):``,ht=k?Ne(k.cid,k.fileName):``,gt=()=>{mt&&Ge(mt)},_t=()=>{ht&&qe(ht)},[Y,vt]=(0,y.useState)(!1),X=Ve.trim(),Z=M?.status===`success`&&M.link===X,yt=()=>{Be.close(),N(null)},bt=e=>{j(e.target.value),N(null)},xt=async()=>{let t=Ce(X,H);if(t){N({status:`error`,link:X,message:t}),e(t,`warning`);return}if(!(P||Y)&&K()&&G()){He(!0),N(null);try{let t=await v.checkDownload(X);N({status:`success`,link:X,message:t.alreadyExists?H(`app.fileAlreadyLocal`,{fileName:t.fileName}):H(`app.fileAvailable`,{fileName:t.fileName})}),e(t.alreadyExists?H(`app.fileAlreadyExists`,{fileName:t.fileName}):H(`app.toast.checkPassed`),t.alreadyExists?`warning`:`success`)}catch(t){let n=await Se(t);N({status:`error`,link:X,message:n}),e(n,`error`)}finally{He(!1)}}},St=async()=>{if(!r){a(),e(H(`app.toast.signInBeforeDownload`),`warning`);return}if(!G())return;let t=Ce(X,H);if(t){e(t,`warning`);return}if(!Z){e(H(`app.toast.checkLinkFirst`),`warning`);return}if(!Y){vt(!0);try{let t=await v.downloadFile(X);if(j(``),N(null),yt(),t.alreadyExists)e(H(`app.fileAlreadyExists`,{fileName:t.fileName}),`warning`);else if(t.localAvailable)q();else{let n={id:t.taskId,fileName:H(`app.downloadFallbackName`),progress:0,type:`download`,status:`downloading`};F(e=>[...e,n]),I.open(),e(H(`app.toast.downloadStarted`),`info`)}}catch(t){e(await s(t,H(`app.toast.downloadFailed`)),`error`)}finally{vt(!1)}}},Ct=async t=>{if(K()&&G()&&t.type===`download`&&t.status===`downloading`){F(e=>e.map(e=>e.id===t.id?{...e,status:`cancelling`}:e));try{await v.cancelDownload(t.id)}catch(n){F(e=>e.map(e=>e.id===t.id?{...e,status:`downloading`}:e)),e(await s(n,H(`app.toast.cancelFailed`)),`error`)}}},wt=async t=>{if(K()&&G()){if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}try{(await ie({cid:t.cid,fileName:t.fileName,getFileDownloadUrl:v.getFileDownloadUrl,getRequestHeaders:o,loadFailedMessage:H(`app.toast.getFileFailed`)})).method===`picker`?e(H(`app.toast.fileSaved`),`success`):e(H(`app.toast.fileDownloaded`),`success`)}catch(t){t.name!==`AbortError`&&e(H(`app.saveFailedWithError`,{error:t.message}),`error`)}}},Tt=async t=>{if(K()&&G())try{e(H(`app.toast.startPullLocal`),`info`),await v.cacheFile(t.cid),e(H(`app.toast.pulledAndSeeding`),`success`),q()}catch(t){e(await s(t,H(`app.toast.pullFailed`)),`error`)}},Q=e=>{x(e||null),D([])};(0,y.useEffect)(()=>{if(t!==!0)return;let n=null,r=!1;return(async()=>{if(n=new WebSocket(await l(`/ws`)),r){n.close();return}n.onmessage=t=>{try{let{event:n,data:r}=JSON.parse(t.data);if(n===`publish:success`||n===`download:success`){q();let t=r.taskId||r.fileName;F(e=>e.map(e=>e.id===t||e.fileName===r.fileName?{...e,progress:100,status:`completed`}:e)),n===`download:success`&&(r.alreadyExists?e(H(`app.fileAlreadyExists`,{fileName:r.fileName}),`warning`):e(H(`app.fileDownloadCompleted`,{fileName:r.fileName}),`success`),setTimeout(()=>{F(e=>e.filter(e=>!(e.id===t&&e.status===`completed`)))},3e3))}n===`publish:progress`&&F(e=>e.map(e=>{if(r.file&&e.fileName===r.file&&e.type===`upload`){let t=50;return r.stage===`calculating-cid`?t=25:r.stage===`uploading`?t=75:r.stage===`complete`&&(t=100),{...e,progress:t}}return e})),n===`download:progress`&&F(e=>e.map(e=>e.id===r.taskId?{...e,progress:r.percent||0,loaded:r.loaded,total:r.total}:e)),n===`download:error`&&(F(e=>e.map(e=>e.id===r.taskId?{...e,status:`error`}:e)),e(H(`app.downloadFailedWithError`,{error:r.error}),`error`)),n===`download:status`&&F(e=>e.map(e=>e.id===r.taskId?{...e,fileName:r.file||e.fileName}:e)),n===`download:cancelled`&&(F(e=>e.map(e=>e.id===r.taskId?{...e,status:`cancelled`}:e)),e(H(`app.toast.downloadCancelled`),`warning`)),n===`user:metadata:updated`&&(q(),J())}catch(e){console.warn(`[App WS] Failed to parse message:`,e.message)}}})(),()=>{r=!0,n?.close()}},[t,r?.address]),(0,y.useEffect)(()=>{if(t===!0&&r){q(),J();return}t===!1&&(f([]),h([]))},[t,r?.address]),(0,y.useEffect)(()=>{r||(D([]),O(null),A(null),j(``),N(null),F([]),R(``),x(null),C(`all`))},[r?.address]);let Et=H(S===`all`?`app.nav.local`:S===`starred`?`app.nav.favorites`:`app.nav.trash`),$=S===`all`?at:S===`starred`?d.filter(e=>e.starred&&w(e.fileName).name.toLowerCase().includes(L.toLowerCase())):m.filter(e=>w(e.fileName).name.toLowerCase().includes(L.toLowerCase())),Dt=S===`starred`?[]:rt.filter(e=>e.name.toLowerCase().includes(L.toLowerCase())),Ot=Le(W,H(`app.allContent`));return(0,b.jsxs)(pe,{sidebar:({closeSidebar:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ve,{onNavigate:e}),(0,b.jsx)(`nav`,{className:`sidebar-nav`,children:[{id:`all`,icon:(0,b.jsx)(we,{size:18}),label:H(`app.nav.local`)},{id:`starred`,icon:(0,b.jsx)(Ee,{size:18}),label:H(`app.nav.favorites`)},{id:`trash`,icon:(0,b.jsx)(se,{size:18}),label:H(`app.nav.trash`)}].map(t=>(0,b.jsxs)(`button`,{onClick:()=>{C(t.id),x(null),D([]),R(``),e()},className:`sidebar-nav-btn ${S===t.id?`active`:``}`,children:[t.icon,(0,b.jsx)(`span`,{children:t.label})]},t.id))})]}),headerTitle:(0,b.jsx)(`h2`,{className:`header-title`,children:Et}),headerRight:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`search-box`,children:[(0,b.jsx)(me,{size:14}),(0,b.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:H(`app.search.placeholder`)}),L&&(0,b.jsx)(`button`,{onClick:()=>R(``),children:(0,b.jsx)(g,{size:12})})]}),S===`trash`&&m.length>0&&(0,b.jsx)(`button`,{onClick:ct,className:`btn btn-sm btn-empty-trash`,children:H(`app.emptyTrash`)}),(0,b.jsx)(`button`,{onClick:()=>I.open(),className:`btn btn-icon`,children:(0,b.jsx)(ae,{size:16})})]}),children:[S===`all`&&(0,b.jsxs)(`div`,{className:`action-grid`,children:[(0,b.jsxs)(`div`,{className:`action-card upload ${Fe?`drag-over`:``}`,onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{e.preventDefault(),T(!1),!(!K()||!G())&&pt(e.dataTransfer.files)},children:[(0,b.jsx)(`input`,{type:`file`,multiple:!0,onClick:e=>{(!K()||!G())&&e.preventDefault()},onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,pt(t)},className:`action-card-input`}),(0,b.jsx)(he,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:H(`app.publishFile`)})]}),(0,b.jsxs)(`div`,{className:`action-card action-card-download`,onClick:()=>{!K()||!G()||Be.open()},children:[(0,b.jsx)(le,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:H(`app.downloadFile`)})]})]}),S===`all`&&(0,b.jsx)(`div`,{className:`breadcrumb`,children:W?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:()=>Q(``),children:H(`app.allContent`)}),Ot.slice(1).map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(oe,{size:12}),(0,b.jsx)(`button`,{onClick:()=>Q(e.path),className:t===Ot.length-2?`current`:``,children:(0,b.jsx)(`span`,{translate:`no`,children:e.name})}),t===Ot.length-2&&(0,b.jsx)(`button`,{onClick:()=>ft(e),className:`breadcrumb-edit-btn`,children:(0,b.jsx)(re,{size:12})})]},e.path))]}):null}),(0,b.jsxs)(`div`,{className:`content-grid`,children:[S===`trash`&&($.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:H(L?`app.noMatches`:`app.trashEmpty`)}),(0,b.jsx)(te,{label:H(`app.openFileNavigation`)})]}):(0,b.jsx)(`div`,{className:`file-grid`,children:$.map(e=>(0,b.jsxs)(`div`,{onClick:()=>D(t=>t.includes(e.cid)?t.filter(t=>t!==e.cid):[...t,e.cid]),onDoubleClick:()=>st(e.cid),className:`card ${E.includes(e.cid)?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon trash`,children:(0,b.jsx)(ue,{size:24,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:w(e.fileName).name}),(0,b.jsx)(`p`,{className:`card-date`,children:H(`app.deletedOn`,{date:tt(e.deletedAt)})})]},e.cid))})),S!==`trash`&&($.length===0&&Dt.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:H(L?`app.noMatches`:S===`starred`?`app.noFavorites`:`app.noLocalFiles`)}),(0,b.jsx)(te,{label:H(`app.openFileNavigation`)})]}):(0,b.jsxs)(`div`,{className:`file-grid`,children:[Dt.map(e=>(0,b.jsx)(Ae,{folder:e,onClick:()=>Q(e.path)},e.path)),$.map(t=>(0,b.jsx)(ke,{file:t,isSelected:E.includes(t.cid),onSelect:ot,onPreview:t=>{if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}O({...t,subtype:p(t.fileName)})}},t.cid))]}))]}),z&&(0,b.jsx)(_e,{title:z.title,message:z.message,confirmText:z.confirmText,danger:z.danger,onConfirm:z.onConfirm,onClose:()=>B(null)}),V&&(0,b.jsx)(ge,{title:V.title,placeholder:V.placeholder,defaultValue:V.defaultValue,confirmText:V.confirmText,isLoading:Qe,onConfirm:V.onConfirm,onClose:()=>Ze(null)}),Ye&&(0,b.jsx)(je,{items:E.map(e=>d.find(t=>t.cid===e)).filter(Boolean),allFolders:nt.map(e=>({path:e,name:e.split(`/`).pop()})),currentPath:W,onMove:dt,onClose:()=>Xe.close()}),k&&(0,b.jsx)(_,{onClose:()=>A(null),children:(0,b.jsxs)(`div`,{className:`share-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.shareLink`)}),(0,b.jsx)(`button`,{onClick:()=>A(null),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`share-link-list`,children:[(0,b.jsxs)(`div`,{className:`share-link-box`,children:[(0,b.jsxs)(`div`,{className:`share-link-content`,children:[(0,b.jsx)(`span`,{className:`share-link-label`,children:H(`app.shareMostLink`)}),(0,b.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:mt})]}),(0,b.jsx)(`button`,{type:`button`,"aria-label":H(`app.copyMostShareLink`),onClick:gt,className:`btn btn-circle btn-primary ${Ke?`copied`:``}`,children:Ke?(0,b.jsx)(u,{size:18}):(0,b.jsx)(ce,{size:18})})]}),(0,b.jsxs)(`div`,{className:`share-link-box`,children:[(0,b.jsxs)(`div`,{className:`share-link-content`,children:[(0,b.jsx)(`span`,{className:`share-link-label`,children:H(`app.shareWebLink`)}),(0,b.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:ht})]}),(0,b.jsx)(`button`,{type:`button`,"aria-label":H(`app.copyWebShareLink`),onClick:_t,className:`btn btn-circle btn-primary ${Je?`copied`:``}`,children:Je?(0,b.jsx)(u,{size:18}):(0,b.jsx)(ce,{size:18})})]})]}),(0,b.jsx)(`div`,{className:`share-storage-note`,children:(0,b.jsx)(`span`,{children:H(`app.shareSeedNote`)})})]})}),ze&&(0,b.jsx)(_,{onClose:yt,children:(0,b.jsxs)(`div`,{className:`download-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.downloadFile`)}),(0,b.jsx)(`button`,{onClick:yt,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`download-link-row`,children:[(0,b.jsx)(`input`,{type:`text`,className:`input`,value:Ve,onChange:bt,placeholder:H(`app.downloadLink.placeholder`)}),(0,b.jsxs)(`button`,{type:`button`,onClick:xt,disabled:!X||P||Y,className:`btn btn-secondary download-check-btn`,children:[P?(0,b.jsx)(de,{size:14,className:`spin`}):Z?(0,b.jsx)(u,{size:14}):(0,b.jsx)(me,{size:14}),H(P?`app.checking`:Z?`app.passed`:`app.check`)]})]}),M&&(0,b.jsxs)(`div`,{className:`download-check-status ${M.status}`,children:[M.status===`success`?(0,b.jsx)(u,{size:14}):(0,b.jsx)(Te,{size:14}),(0,b.jsx)(`span`,{children:M.message})]}),(0,b.jsxs)(`button`,{onClick:St,disabled:!Z||Y||P,className:`btn btn-info btn-full`,children:[Y?(0,b.jsx)(de,{size:14,className:`spin`}):(0,b.jsx)(le,{size:14}),H(Y?`app.downloading`:`app.startDownload`)]})]})}),Re&&(0,b.jsx)(ne,{item:Re,isBackendReady:U,getFileDownloadUrl:v.getFileDownloadUrl,onSaveAs:wt,onClose:()=>O(null)}),E.length>0&&(0,b.jsxs)(`div`,{className:`batch-bar`,children:[(0,b.jsx)(`span`,{className:`batch-info`,children:H(`app.selectedItems`,{count:E.length})}),(0,b.jsx)(`button`,{onClick:()=>D([]),className:`batch-dismiss`,children:(0,b.jsx)(g,{size:16})}),(0,b.jsx)(`div`,{className:`batch-divider`}),S===`trash`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:async()=>{K()&&G()&&(await Promise.all(E.map(e=>v.restoreTrashFile(e))),D([]),e(H(`app.toast.restored`),`success`),q(),J())},className:`btn btn-sm`,children:H(`app.restore`)}),(0,b.jsx)(`button`,{onClick:ut,className:`btn btn-sm btn-danger`,children:H(`app.permanentDelete`)})]}):(0,b.jsxs)(b.Fragment,{children:[E.length===1&&(()=>{let e=d.find(e=>e.cid===E[0]);return e&&p(e.fileName)!==`file`})()&&(0,b.jsx)(`button`,{onClick:()=>{let t=d.find(e=>e.cid===E[0]);if(t){if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}let n=p(t.fileName);O({...t,subtype:n})}},className:`btn btn-sm`,children:H(`app.preview`)}),(0,b.jsx)(`button`,{onClick:()=>{let e=E.some(e=>{let t=d.find(t=>t.cid===e);return t&&!t.starred});E.forEach(t=>{let n=d.find(e=>e.cid===t);n&&(e?!n.starred:n.starred)&&lt(t)})},className:`btn btn-sm btn-star`,children:H(`app.favorite`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&ft(e)},className:`btn btn-sm`,children:H(`app.rename`)}),(0,b.jsx)(`button`,{onClick:()=>Xe.open(),className:`btn btn-sm btn-move`,children:H(`app.move`)}),(0,b.jsx)(`button`,{onClick:ut,className:`btn btn-sm btn-danger`,children:H(`app.delete`)}),E.length===1&&(()=>{let e=d.find(e=>e.cid===E[0]);return e&&e.localAvailable===!1})()&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&Tt(e)},className:`btn btn-sm`,children:H(`app.pullToLocal`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>A(d.find(e=>e.cid===E[0])),className:`btn btn-sm`,children:H(`app.share`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&wt(e)},className:`btn btn-sm`,children:H(`app.saveAs`)})]})]}),We&&(0,b.jsx)(_,{onClose:()=>I.close(),children:(0,b.jsxs)(`div`,{className:`transfer-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.transfers`)}),(0,b.jsx)(`button`,{onClick:()=>I.close(),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),Ue.length===0?(0,b.jsx)(`div`,{className:`empty-transfer`,children:H(`app.noTransfers`)}):Ue.map(e=>(0,b.jsxs)(`div`,{className:`transfer-item`,children:[(0,b.jsxs)(`div`,{className:`transfer-item-header`,children:[e.type===`upload`?(0,b.jsx)(he,{size:14}):(0,b.jsx)(le,{size:14}),(0,b.jsx)(`span`,{className:`transfer-item-name`,translate:`no`,children:e.fileName}),e.status===`downloading`&&e.type===`download`&&(0,b.jsx)(`button`,{onClick:()=>Ct(e),className:`transfer-item-cancel`,children:(0,b.jsx)(g,{size:14})})]}),(0,b.jsxs)(`div`,{className:`transfer-progress-row`,children:[(0,b.jsx)(`progress`,{className:`transfer-progress-meter ${e.type===`download`?`download`:``} ${e.status===`error`?`error`:``} ${e.status===`cancelled`?`cancelled`:``}`,value:Math.max(0,Math.min(100,e.progress)),max:100,"aria-label":H(`app.transferProgress`,{fileName:e.fileName})}),(0,b.jsx)(`span`,{className:`transfer-progress-text`,children:e.status===`completed`?H(`app.completed`):e.status===`error`?H(`app.failed`):e.status===`cancelled`?H(`app.cancelled`):e.status===`cancelling`?H(`app.cancelling`):e.loaded&&e.total?`${ye(e.loaded)}/${ye(e.total)}`:`${e.progress}%`})]})]},e.id))]})})]})}var E=a(`/app/`)({component:T});export{E as Route};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,c as o,n as s,o as c,t as l}from"./useAppStore-DNhyhD20.js";import{a as u}from"./i18n-DKsg67mH.js";import{t as d}from"./circle-alert-DXVkx8p8.js";import{a as ee,o as f,r as p,t as te}from"./chatNoteDraft-DTy6In5R.js";import{t as ne}from"./OpenSidebarButton-CXBAjjCE.js";import{a as m,i as h,n as re,o as ie,r as ae,t as oe}from"./saveLocalFile-DTgdBgO9.js";import{t as g}from"./arrow-right-BsHzC0ZL.js";import{n as se,t as _}from"./trash-2-B9gno5q6.js";import{t as v}from"./download-Cy2BlfKM.js";import{t as ce}from"./external-link-D_AQSgxW.js";import{t as le}from"./file-text-zvTER2mN.js";import{t as y}from"./loader-C4pED_QP.js";import{r as ue,t as de}from"./AppShell-CKP_dglR.js";import{t as fe}from"./message-square-CfApq8Ou.js";import{t as pe}from"./music-Br2x8TKX.js";import{t as me}from"./search-DLBOUfny.js";import{A as he,C as ge,M as _e,O as ve,S as b,T as ye,g as be,j as xe,n as Se,r as Ce,w as we}from"./index-DJzLHA0V.js";import{t as Te}from"./AppTop-C03PsDr_.js";import{t as Ee}from"./LogoIcon-B2fFe0l1.js";import{t as De}from"./format-CAKfypjK.js";import{a as Oe,i as ke,n as x,o as Ae,t as je}from"./downloadValidation-Dd43i9_9.js";import{t as S}from"./channelApi-C5eHetoJ.js";import{n as Me,t as Ne}from"./useChannelMessages-BrqZa2SG.js";import{t as Pe}from"./ChatRestoringIndicator-CLV78gNW.js";var Fe=r(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Ie=r(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Le=r(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Re=r(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),ze=r(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),C=t(e(),1),w=n();function Be(e){return String(e||``).split(`/`).pop()||e}function Ve(e){return e===`image`?(0,w.jsx)(h,{size:20}):e===`video`?(0,w.jsx)(m,{size:20}):e===`audio`?(0,w.jsx)(pe,{size:20}):(0,w.jsx)(le,{size:20})}function He({attachment:e,status:t=`idle`,message:n,pending:r=!1,onOpen:i}){let{t:a}=u(),o=t===`checking`,s=t===`downloading`,c=r||o||s,l=`ui-file-action chat-attachment-action ${t===`error`?`error`:t===`available`?`available`:``}`.trim(),ee=Number.isFinite(e.size)&&e.size>0?De(e.size):a(`chat.mostboxFile`),f=r?a(`chat.sending`):n||ee,p=a(r?`chat.sending`:o?`chat.checking`:s?`chat.attachment.downloading`:t===`available`?`chat.attachment.preview`:t===`error`?`chat.attachment.retry`:`chat.attachment.download`);return(0,w.jsxs)(`button`,{type:`button`,className:`ui-file-card chat-attachment-card`,onClick:()=>i?.(e),disabled:c,title:e.link,translate:`no`,children:[(0,w.jsx)(`span`,{className:`ui-file-icon chat-attachment-icon ${e.kind}`,children:c?(0,w.jsx)(y,{size:20,className:`ui-spinner chat-attachment-spinner`}):Ve(e.kind)}),(0,w.jsxs)(`span`,{className:`ui-file-info chat-attachment-info`,children:[(0,w.jsx)(`span`,{className:`ui-file-name chat-attachment-name`,translate:`no`,children:Be(e.fileName)}),(0,w.jsx)(`span`,{className:`ui-file-meta chat-attachment-meta`,translate:`yes`,children:f})]}),(0,w.jsxs)(`span`,{className:l,translate:`yes`,children:[c?(0,w.jsx)(y,{size:15,className:`ui-spinner chat-attachment-spinner`}):t===`available`?(0,w.jsx)(_e,{size:16}):t===`error`?(0,w.jsx)(d,{size:17}):(0,w.jsx)(v,{size:16}),(0,w.jsx)(`span`,{className:`chat-attachment-action-label`,children:p})]})]})}var T=[{key:`image`,labelKey:`chat.attachment.image`,accept:`image/*`,icon:h},{key:`video`,labelKey:`chat.attachment.video`,accept:`video/*`,icon:m},{key:`file`,labelKey:`chat.attachment.file`,accept:``,icon:le}],Ue={key:`voice`,labelKey:`chat.voice.menu`,icon:xe},We=T.map(e=>e.accept).join(`,`);function Ge({children:e}){return(0,w.jsx)(`div`,{className:`message-bubble`,translate:`no`,children:e})}function Ke({children:e}){return(0,w.jsx)(`div`,{className:`message-bubble has-attachment`,children:e})}function qe({children:e}){return(0,w.jsx)(`div`,{className:`chat-system-message`,children:e})}function Je({variant:e,pending:t=!1,avatarSrc:n,isOnline:r=!1,author:i,time:a,children:o}){return(0,w.jsxs)(`div`,{className:[`chat-message`,e,t?`pending`:``].filter(Boolean).join(` `),children:[(0,w.jsxs)(`span`,{className:`chat-avatar-wrap`,children:[(0,w.jsx)(`img`,{className:`msg-avatar`,src:n,alt:`avatar`}),r&&(0,w.jsx)(`span`,{className:`chat-online-dot`,"aria-hidden":`true`})]}),(0,w.jsxs)(`div`,{className:`msg-content`,children:[(0,w.jsx)(`span`,{className:`message-header`,children:(0,w.jsx)(`span`,{className:`message-author`,translate:`no`,children:i})}),o,(0,w.jsx)(`span`,{className:`message-time`,children:a})]})]})}function Ye({active:e=!1,pinned:t=!1,unread:n=!1,title:r,menuClassName:i,onSelect:a,onTogglePin:o,onRename:s,onLeave:c}){let{t:l}=u(),d=!!(o||s||c);return(0,w.jsxs)(`div`,{className:[`sidebar-nav-btn`,e?`active`:``,t?`pinned`:``,n?`unread`:``].filter(Boolean).join(` `),onClick:a,role:`button`,tabIndex:0,onKeyDown:e=>{e.target===e.currentTarget&&e.key===`Enter`&&a?.()},children:[(0,w.jsxs)(`span`,{className:`chat-channel-icon-wrap`,children:[(0,w.jsx)(fe,{size:16}),n&&(0,w.jsx)(`span`,{className:`chat-channel-unread-dot`,title:l(`chat.unread`),"aria-hidden":`true`})]}),(0,w.jsx)(`span`,{className:`chat-channel-title`,children:(0,w.jsx)(`span`,{className:`chat-channel-title-text`,translate:`no`,children:r})}),d&&(0,w.jsx)(b,{ariaLabel:l(`chat.channelActions`),className:`channel-actions-anchor`,menuClassName:i,placement:`bottom-end`,items:[{key:`pin`,label:l(t?`chat.unpin`:`chat.pin`),icon:t?(0,w.jsx)(Le,{size:16}):(0,w.jsx)(Re,{size:16}),onSelect:()=>o?.()},{key:`rename`,label:l(`chat.rename`),icon:(0,w.jsx)(ie,{size:16}),onSelect:()=>s?.()},{key:`delete`,label:l(`chat.delete`),icon:(0,w.jsx)(_,{size:16}),onSelect:()=>c?.()}],renderTrigger:e=>(0,w.jsx)(`button`,{...e,className:`leave-channel-btn channel-actions-trigger`,title:l(`common.moreActions`),"aria-label":l(`common.moreActions`),children:(0,w.jsx)(f,{size:16})})})]})}function Xe({members:e}){let{t}=u();return e.length===0?(0,w.jsx)(`div`,{className:`ui-empty-inline channel-members-empty`,children:t(`chat.noMembers`)}):(0,w.jsx)(`div`,{className:`channel-members-grid`,children:e.map(e=>(0,w.jsxs)(`div`,{className:`channel-member`,children:[(0,w.jsxs)(`span`,{className:`channel-member-avatar-wrap`,children:[(0,w.jsx)(`img`,{className:`channel-member-avatar`,src:e.avatarSrc,alt:`avatar`}),e.online&&(0,w.jsx)(`span`,{className:`chat-online-dot`,"aria-hidden":`true`})]}),(0,w.jsx)(`span`,{className:`channel-member-name`,translate:`no`,children:e.name})]},e.id))})}function Ze({message:e,placeholder:t,disabled:n=!1,isPublishingAttachment:r=!1,attachmentButtonTitle:i,attachmentInputRef:a,attachmentMenuClassName:o,showVoiceRoom:s=!0,onMessageChange:c,onSend:l,onOpenVoiceRoom:d,onSelectAttachmentFiles:f}){let{t:p}=u(),te=n||r,ne=n||!e.trim(),m=i||p(`chat.attachment.add`);function h(e,t){let n=e.currentTarget.files?Array.from(e.currentTarget.files):null;t?.(n),e.currentTarget.value=``}function re(t){t.key===`Enter`&&(t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),e.trim()&&l()))}function ie(e){if(te)return;let t=a?.current;t&&(t.accept=e,t.click())}return(0,w.jsxs)(`div`,{className:`chat-input-area`,children:[(0,w.jsx)(`input`,{ref:a,type:`file`,accept:We,className:`chat-file-input`,onChange:e=>h(e,f)}),(0,w.jsx)(b,{ariaLabel:p(`chat.attachmentType`),placement:`top-start`,disabled:te,menuClassName:o,items:[...T.map(e=>{let t=e.icon;return{key:e.key,label:p(e.labelKey),icon:(0,w.jsx)(t,{size:16}),onSelect:()=>ie(e.accept)}}),...s?[{key:Ue.key,label:p(Ue.labelKey),icon:(0,w.jsx)(xe,{size:16}),onSelect:()=>d?.()}]:[]],renderTrigger:e=>(0,w.jsx)(`button`,{...e,className:`btn btn-circle chat-tool-btn`,"aria-label":m,children:r?(0,w.jsx)(y,{size:18,className:`ui-spinner chat-attachment-spinner`}):(0,w.jsx)(ee,{size:18})})}),(0,w.jsx)(`textarea`,{className:`textarea chat-composer-input`,placeholder:t,value:e,disabled:n,rows:1,onChange:e=>c(e.target.value),onKeyDown:re}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-circle btn-primary send-btn`,onClick:l,disabled:ne,title:p(`chat.sendMessage`),children:(0,w.jsx)(g,{size:18})})]})}var Qe=`mostbox.chat.lastReadAt`;function E(e){return Date.parse(e?.lastMessageAt||``)||Date.parse(e?.createdAt||``)||0}function $e(e){let t=String(e||``).trim().toLowerCase();return t?`${Qe}:${t}`:``}function et(e,t=Date.now()){let n=Number(e);return Math.max(0,Math.floor(Number.isFinite(n)&&n>0?n:t))}function tt(e,t=D()){if(!e||!t)return{};try{let n=t.getItem(e);if(!n)return{};let r=JSON.parse(n);return!r||typeof r!=`object`?{}:Object.entries(r).reduce((e,[t,n])=>{let r=Number(n);return t&&Number.isFinite(r)&&r>=0&&(e[t]=r),e},{})}catch{return{}}}function nt(e,t,n=D()){if(!(!e||!n))try{n.setItem(e,JSON.stringify(t))}catch{}}function rt(e,t,n=Date.now(),r=Date.now()){if(!t)return{changed:!1,value:e};let i=et(n,r);return(e[t]||0)>=i?{changed:!1,value:e}:{changed:!0,value:{...e,[t]:i}}}function it(e,t,n=Date.now()){let r=!1,i={...e};for(let e of t){let t=e?.channelKey||e?.name;!t||i[t]!==void 0||(i[t]=et(E(e),n),r=!0)}return{changed:r,value:r?i:e}}function at(e,{channelName:t,messageTime:n,activeChannelName:r=``,messageAuthor:i=``,userAddress:a=``,now:o=Date.now()}){if(!t)return{changed:!1,notify:!1,value:e};let s=et(n,o),c=t===r;if(String(i||``).toLowerCase()===String(a||``).toLowerCase())return{...rt(e,t,s,o),notify:!1};if(c)return{...rt(e,t,s,o),notify:!0};let l=e[t]||0;if(l<s)return{changed:!1,notify:!0,value:e};let u=Math.max(0,s-1);return l===u?{changed:!1,notify:!0,value:e}:{changed:!0,notify:!0,value:{...e,[t]:u}}}function ot(e,t){let n=e?.channelKey||e?.name;return E(e)>(t[n]||0)}function D(){if(!(typeof window>`u`))return window.localStorage}var st=3,ct=30,lt=/^[a-zA-Z0-9_-]+$/,ut=1e4,dt=12e3,ft=1200,pt=800;function O(e){return e?.channelKey||e?.name||``}function k(e){return e?.channelId||e?.name||``}function A(e){return e&&typeof e==`object`?e:{}}function mt(e){let t=A(e),n=new Set,r=e=>{let t=String(e||``).trim();t&&n.add(t)};return r(t.channelKey),r(t.channel),Array.isArray(t.channels)&&t.channels.forEach(e=>{let t=A(e);r(t.channelKey),r(t.channel),r(t.name)}),[...n]}function j(e){return e?.remark||k(e)}function ht(){return typeof window>`u`?``:(new URLSearchParams(window.location.search).get(`channel`)||``).trim()}function gt(e){let t=new Date(e||Date.now());return Number.isNaN(t.getTime())?String(Date.now()):t.toISOString().slice(0,16).replace(`T`,` `).replace(`:`,`-`)}function _t(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function vt(e,t){return`[${_t(e)}](<${t.replace(/>/g,`%3E`)}>)`}function yt(e){let t=String(e||``).trim().split(/\r?\n/);return t.length>0?t.map(e=>`> ${e}`).join(`
2
+ `):`> `}var bt=`chat-file`;function xt(e,t){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:e.type.startsWith(`audio/`)?`audio`:e.type.startsWith(`text/`)?`text`:ae(t)}function St(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:`Unknown`}function Ct(e){return/#[a-fA-F0-9]{4}$/.test(String(e||``).trim())}function M(e){return String(e||``).trim().toLowerCase()}function wt(){if(typeof window>`u`)return;let e=window;return e.AudioContext||e.webkitAudioContext}function Tt(){let e=l(e=>e.hasBackend),t=l(e=>e.isDarkMode),n=l(e=>e.addToast),r=l(e=>e.openConnectModal),a=i(e=>e.identity),d=i(e=>e.openLoginModal),[f,m]=(0,C.useState)([]),[h,g]=(0,C.useState)(null),[_,v]=(0,C.useState)(``),[le,y]=(0,C.useState)(!1),[pe,_e]=(0,C.useState)(``),[b,xe]=(0,C.useState)(``),[De,Le]=ue(!1),[Re,Ve]=(0,C.useState)(``),[T,Ue]=(0,C.useState)(!1),[We,Qe]=(0,C.useState)(!1),[et,D]=ue(!1),[A,_t]=(0,C.useState)(null),[Tt,Et]=(0,C.useState)(null),[Dt,N]=(0,C.useState)(!1),[Ot,kt]=(0,C.useState)(``),[At,jt]=(0,C.useState)(!1),[Mt,Nt]=(0,C.useState)(null),[Pt,Ft]=(0,C.useState)(!1),[It,P]=(0,C.useState)({}),[Lt,F]=(0,C.useState)(null),[Rt,zt]=(0,C.useState)(!1),[Bt,Vt]=(0,C.useState)(!1),[Ht,Ut]=(0,C.useState)(!1),[Wt,I]=(0,C.useState)({}),[Gt,Kt]=(0,C.useState)([]),L=a?.theme===`sparkbit`,qt=L&&a?.data?a.data:``,Jt=L&&a?.logo||``,Yt=L&&t&&a?.logo_dark||``,Xt=Yt||Jt,Zt=Yt&&Jt&&Yt!==Jt?Jt:``,Qt=Xt&&!Bt?Xt:Zt&&!Ht?Zt:``,$t=(0,C.useRef)(null),en=(0,C.useRef)(null),R=(0,C.useRef)(``),tn=(0,C.useRef)(new Set),nn=(0,C.useRef)(new Set),z=(0,C.useRef)(null),rn=(0,C.useRef)(!1),an=(0,C.useRef)(0),on=(0,C.useRef)(async()=>[]),sn=(0,C.useRef)(new Map),B=(0,C.useRef)(new Map),V=(0,C.useRef)(new Set),H=e===!0,{t:U,compareStrings:cn,formatDate:ln,formatTime:un}=u(),W=Se(),G=(0,C.useCallback)(async(e,t)=>{n(await c(e,t),`error`)},[n]),K=(0,C.useMemo)(()=>$e(a?.address),[a?.address]),dn=(0,C.useCallback)((e,t=Date.now())=>{e&&I(n=>{let r=rt(n,e,t);return r.changed?(nt(K,r.value),r.value):n})},[K]),q=(0,C.useCallback)(()=>{if(rn.current||typeof window>`u`)return;let e=wt();if(e)try{let t=z.current||new e;z.current=t,t.state===`suspended`&&t.resume().catch(()=>{}),rn.current=!0}catch{}},[]),fn=(0,C.useCallback)(()=>{if(!rn.current)return;let e=Date.now();if(e-an.current<ft)return;an.current=e;let t=wt();if(t)try{let e=z.current||new t;if(z.current=e,e.state===`suspended`){e.resume().catch(()=>{});return}let n=e.createGain();n.gain.setValueAtTime(1e-4,e.currentTime),n.gain.exponentialRampToValueAtTime(.08,e.currentTime+.015),n.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+.18),n.connect(e.destination),[740,980].forEach((t,r)=>{let i=e.createOscillator();i.type=`sine`,i.frequency.setValueAtTime(t,e.currentTime),i.connect(n),i.start(e.currentTime+r*.035),i.stop(e.currentTime+.16+r*.035)})}catch{}},[]),pn=(0,C.useCallback)(async(e=h)=>{let t=O(e);if(!t||!H){Kt([]);return}try{let e=await S.getChannelPresence(t);if(R.current!==t)return;Kt(e)}catch(e){console.warn(`[Chat] Failed to fetch channel presence:`,e instanceof Error?e.message:e)}},[h,H]),mn=(0,C.useCallback)((e=``)=>{let t=R.current;if(!e||e!==t||!H)return;let n=sn.current,r=n.get(e);r&&window.clearTimeout(r);let i=window.setTimeout(()=>{n.delete(e),on.current(e)},pt);n.set(e,i)},[H]);function hn(e,t){switch(e){case`channel:message`:{let e=t?.channelKey||t?.channel,n=t?.message,r=Number(n?.timestamp)||Date.now();if(e){m(t=>t.map(t=>O(t)===e?{...t,lastMessageAt:new Date(r).toISOString()}:t));let t=e===R.current;I(i=>{let o=at(i,{channelName:e,messageTime:r,activeChannelName:t?e:``,messageAuthor:n?.author,userAddress:a?.address});return o.changed&&nt(K,o.value),o.notify&&fn(),o.changed?o.value:i})}break}case`channel:peer:online`:case`channel:sync:available`:{let e=mt(t),n=R.current;$(),e.includes(n)&&(mn(n),h&&pn(h));break}case`channel:presence`:{let e=t?.channelKey||t?.channel;h&&(!e||e===O(h))&&pn(h);break}case`channel:joined`:case`channel:left`:$();break;case`user:metadata:updated`:t?.scope===`channels`&&$();break;case`download:success`:{let e=B.current.get(t.taskId);e&&(B.current.delete(t.taskId),V.current.delete(e.cid),P(t=>({...t,[e.cid]:{status:`available`,message:U(`chat.attachment.previewAvailable`)}})),n(U(`chat.attachment.downloadCompleted`,{fileName:t.fileName||Be(e.fileName)}),`success`),On(e,t.fileName||e.fileName));break}case`download:error`:case`download:cancelled`:{let r=B.current.get(t.taskId);r&&(B.current.delete(t.taskId),V.current.delete(r.cid),P(n=>({...n,[r.cid]:{status:`error`,message:e===`download:cancelled`?U(`chat.attachment.downloadCancelled`):t.error||U(`chat.attachment.downloadFailed`)}})),n(e===`download:cancelled`?U(`chat.attachment.downloadCancelled`):t.error||U(`chat.attachment.downloadFailed`),`error`));break}}}let gn=(0,C.useMemo)(()=>f.map(e=>O(e)),[f]),J=O(h),_n=(0,C.useMemo)(()=>a?{...Ce(a),profileUpdatedAt:a.profileUpdatedAt}:{},[a?.avatar,a?.displayName,a?.profileUpdatedAt,a?.username]),Y=(0,C.useMemo)(()=>!h||!J?null:{channelName:J,title:j(h)},[h,J]),{clearMessages:vn,messages:X,sendMessage:yn,syncedChannelName:bn,syncMessages:xn}=Ne({isReady:H,enabled:!!a,channelName:J,extraSubscribedChannelNames:gn,peerId:Re,waitForPeerId:!0,onSyncError:e=>G(e,U(`chat.error.messages`)),onSocketEvent:hn,onReconnect:()=>{$(),h&&pn(h)},presenceEnabled:!!(h&&a),presenceProfile:_n});(0,C.useEffect)(()=>{on.current=xn},[xn]),(0,C.useEffect)(()=>{let e=sn.current;return()=>{for(let t of e.values())window.clearTimeout(t);e.clear()}},[]);let Sn=(0,C.useMemo)(()=>{let e=new Map;return X.forEach((t,n)=>{let r=String(t.author||``).trim();if(!r)return;let i=r.toLowerCase(),a=Number(t.timestamp)||0,o=String(t.authorName||``).trim(),s=String(t.avatar||``).trim(),c=e.get(i);if(!c){e.set(i,{address:r,displayName:o,...s?{avatar:s}:{},firstSeenAt:a,lastSeenAt:a,index:n});return}a>=c.lastSeenAt&&(c.lastSeenAt=a,o&&(c.displayName=o),s&&(c.avatar=s))}),[...e.values()].sort((e,t)=>e.firstSeenAt-t.firstSeenAt||e.index-t.index)},[X]),Cn=(0,C.useMemo)(()=>new Map(Sn.map(e=>[M(e.address),e])),[Sn]),wn=(0,C.useMemo)(()=>{let e=new Map;return Gt.forEach(t=>{let n=M(t.address);!n||!t.online||e.set(n,t)}),e},[Gt]),Tn=(0,C.useMemo)(()=>{let e=new Map(Cn);return Gt.forEach((t,n)=>{let r=M(t.address);!r||e.has(r)||e.set(r,{address:t.address,displayName:t.displayName||``,...t.avatar?{avatar:t.avatar}:{},firstSeenAt:t.lastSeen||Date.now(),lastSeenAt:t.lastSeen||Date.now(),index:Sn.length+n})}),[...e.values()]},[Sn,Gt,Cn]),En=(0,C.useMemo)(()=>new Set(wn.keys()),[wn]);function Z(){return H?!0:(r(),!1)}function Q(){return a?!0:(d(),!1)}(0,C.useEffect)(()=>{let e=()=>{v(ht())};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,C.useEffect)(()=>{a&&v(ht())},[a?.address]),(0,C.useEffect)(()=>{Vt(!1),Ut(!1)},[Xt,Zt]),(0,C.useEffect)(()=>{R.current=O(h)},[h]),(0,C.useEffect)(()=>(W.setPreviewRoom(a&&Y?Y:null),()=>{W.setPreviewRoom(null)}),[Y,a,W.setPreviewRoom]),(0,C.useEffect)(()=>{I(tt(K))},[K]),(0,C.useEffect)(()=>{!K||f.length===0||I(e=>{let t=it(e,f);return t.changed&&nt(K,t.value),t.changed?t.value:e})},[K,f]),(0,C.useEffect)(()=>(window.addEventListener(`pointerdown`,q,{passive:!0}),window.addEventListener(`keydown`,q),()=>{window.removeEventListener(`pointerdown`,q),window.removeEventListener(`keydown`,q)}),[q]),(0,C.useEffect)(()=>()=>{z.current?.close().catch(()=>{}),z.current=null,rn.current=!1},[]),(0,C.useEffect)(()=>{$t.current?.scrollIntoView({behavior:`smooth`})},[X]),(0,C.useEffect)(()=>{if(!H){Ve(``);return}s.get(`/api/node-id`).json().then(e=>Ve(e.id)).catch(e=>{console.warn(`[Chat] Failed to fetch node ID:`,e.message),G(e,U(`chat.error.nodeId`))})},[H,G,U]),(0,C.useEffect)(()=>{H&&a?(y(!1),$()):y(!1)},[e,H,a?.address]),(0,C.useEffect)(()=>{if(h){if(H){let e=O(h);Kt([]),xn(e,{replace:!0}),pn(h)}}else Kt([])},[h,H,pn,xn]),(0,C.useEffect)(()=>{if(!_)return;if(!a){nn.current.has(_)||(nn.current.add(_),d());return}if(!H||!le)return;let e=f.find(e=>O(e)===_)||f.find(e=>k(e)===_);if(e&&(!h||O(h)!==O(e))){Nn(e);return}if(e&&h&&O(h)===O(e)&&(h.createdAt!==e.createdAt||h.coreKey!==e.coreKey||h.lastMessageAt!==e.lastMessageAt||h.pinned!==e.pinned||h.remark!==e.remark||h.type!==e.type)){g(e);return}if(e)return;let t=`${a.address}:${_}`;if(tn.current.has(t)||T)return;let r=Dn(_);if(tn.current.add(t),r){n(r,`error`);return}In(_)},[f,h,_,le,H,T,a?.address]),(0,C.useEffect)(()=>{a||(m([]),y(!1),g(null),v(ht()),Et(null),vn(),xe(``),Ve(``),N(!1),Nt(null),P({}),I({}),V.current.clear(),B.current.clear())},[vn,a?.address]);function Dn(e){return e.length<st?U(`chat.validation.nameMin`,{count:st}):e.length>ct?U(`chat.validation.nameMax`,{count:ct}):e.includes(`.`)?U(`chat.validation.dotReserved`):lt.test(e)?``:U(`chat.validation.allowedChars`)}async function $(){if(!H){y(!1);return}try{m(await S.getChannels()),y(!0)}catch(e){m([]),y(!1),await G(e,U(`chat.error.channelList`))}}function On(e,t=e.fileName){let n=ae(t);Nt({cid:e.cid,fileName:t,subtype:n===`file`?e.kind:n})}async function kn(e){if(Q()&&Z())try{n((await oe({cid:e.cid,fileName:e.fileName,getFileDownloadUrl:x.getFileDownloadUrl,getRequestHeaders:o,loadFailedMessage:U(`app.toast.getFileFailed`)})).method===`picker`?U(`app.toast.fileSaved`):U(`app.toast.fileDownloaded`),`success`)}catch(e){e.name!==`AbortError`&&n(U(`app.saveFailedWithError`,{error:e.message}),`error`)}}async function An(e){let t=je(e.link,U);if(t)return P(n=>({...n,[e.cid]:{status:`error`,message:t}})),!1;try{P(t=>({...t,[e.cid]:{status:`checking`}}));let t=await x.checkDownload(e.link,{timeout:ut,requestTimeout:dt});return P(n=>({...n,[e.cid]:{status:t.alreadyExists?`available`:`ready`,message:t.alreadyExists?U(`chat.attachment.localAvailable`):U(`chat.attachment.downloadAvailable`)}})),!0}catch{return P(t=>({...t,[e.cid]:{status:`error`,message:U(`chat.attachment.noSeedsTitle`)}})),!1}}async function jn(e){F(null),await An(e)&&await Mn(e)}async function Mn(e){if(!V.current.has(e.cid)){V.current.add(e.cid),P(t=>({...t,[e.cid]:{status:`downloading`,message:U(`chat.attachment.downloading`)}}));try{let t=await x.downloadFile(e.link);if(t.alreadyExists||t.fileName){V.current.delete(e.cid),P(t=>({...t,[e.cid]:{status:`available`,message:U(`chat.attachment.previewAvailable`)}})),On({...e,fileName:t.fileName||e.fileName},t.fileName||e.fileName);return}t.taskId&&(B.current.set(t.taskId,e),n(U(`chat.attachment.downloadStarted`),`success`))}catch{V.current.delete(e.cid),P(t=>({...t,[e.cid]:{status:`error`,message:U(`chat.attachment.noSeedsTitle`)}}))}}}async function Nn(e){if(!Q()||!Z())return;let t=O(e);dn(t,Math.max(E(e),Date.now())),g(e),v(t),window.history.pushState({},``,`?channel=${encodeURIComponent(t)}`)}async function Pn(e,t){if(t&&t.stopPropagation(),Q()&&Z()&&!We){Qe(!0);try{if(await S.leaveChannel(e),O(h)===e){g(null),v(``),vn();let e=new URL(window.location.href);e.searchParams.delete(`channel`),window.history.pushState({},``,e.pathname)}$(),D.close(),_t(null)}catch(e){await G(e,U(`chat.error.leave`))}finally{Qe(!1)}}}async function Fn(e){if(!Q()||!Z())return;let t=!e.pinned,n=O(e);try{let e=await S.setChannelPinned(n,t);m(t=>t.map(t=>O(t)===n?{...t,pinned:e.pinned}:t)),g(t=>t&&O(t)===n?{...t,pinned:e.pinned}:t)}catch(e){await G(e,U(t?`chat.error.pin`:`chat.error.unpin`))}}async function In(e){let t=e.trim();if(!t||T)return;let r=Dn(t);if(r){n(r,`error`);return}if(Q()&&Z()){Ue(!0);try{let e=await S.createChannel(t,`public`,Ce(a)),n=e.channelKey||e.key||e.name||t,r=f.find(e=>O(e)===n),i={...r,name:e.name||t,channelId:e.channelId||e.name||t,channelKey:e.channelKey||e.key||r?.channelKey,type:e.type||r?.type||`public`,createdAt:e.createdAt||r?.createdAt,coreKey:e.coreKey||e.key||r?.coreKey,localWriterCoreKey:e.localWriterCoreKey||r?.localWriterCoreKey,writerCoreKeys:e.writerCoreKeys||r?.writerCoreKeys,remark:e.remark||r?.remark},o=O(i);m(e=>e.some(e=>O(e)===o)?e.map(e=>O(e)===o?{...e,...i}:e):[...e,i]),Le.close(),await Nn(i),$()}catch(e){await G(e,U(`chat.error.join`))}finally{Ue(!1)}}}async function Ln(e,t){if(!e.trim()||!h||!Q()||!Z())return!1;let n=e.trim(),r=O(h);try{let e=await yn({channelName:r,content:n,attachment:t});return m(t=>t.map(t=>O(t)===r?{...t,lastMessageAt:new Date(Number(e?.timestamp)||Date.now()).toISOString()}:t)),e&&dn(r,Number(e.timestamp)||Date.now()),!0}catch(e){return await G(e,U(`chat.error.send`)),!1}}async function Rn(){if(!b.trim())return;let e=b.trim();xe(``),await Ln(e)}function zn(e,t){return`${bt}/${e}/${t}`}async function Bn(e){if(!e||e.length===0||!h||!Q()||!Z()||Pt)return;Ft(!0);let t=``;try{let r=await x.getNodePolicy().catch(()=>null);for(let i of Array.from(e)){t=i.name;let e=Oe(i,r,U);if(e){n(e,`error`);continue}let a=zn(k(h),i.name),o=await x.publishFile(i,a),s=o.fileName||a,c=o.link||Ae(o.cid,s);await Ln(c,{kind:xt(i,s),cid:o.cid,fileName:s,link:c,mimeType:i.type||void 0,size:i.size})}}catch(e){n(await ke(e,U(`chat.error.attachmentSend`),U,t),`error`)}finally{Ft(!1)}}async function Vn(e){if(!Q()||!Z())return;let t=It[e.cid];if(!(t?.status===`checking`||t?.status===`downloading`)){if(t?.status===`error`){F(e);return}if(t?.status===`ready`||t?.status===`available`){await Mn(e);return}if(!t){await An(e)&&await Mn(e);return}}}function Hn(e){let t=M(e.author),n=wn.get(t),r=Cn.get(t);return Zn(n?.displayName||r?.displayName||e.authorName,e.author)}function Un(e){return e.type!==`system`&&!e.pending&&(!!e.attachment||!!e.content.trim())}function Wn(e,t){let n=Hn(t),r=`${ln(t.timestamp)} ${un(t.timestamp)}`,i=t.content.trim();e.push(`## ${r} ${n}`,``),i&&(!t.attachment||i!==t.attachment.link)&&e.push(yt(i),``),t.attachment&&e.push(`**${U(`chat.noteDraft.attachment`)}**`,``,`- ${U(`chat.noteDraft.file`)}: ${vt(Be(t.attachment.fileName),t.attachment.link)}`,`- CID: \`${t.attachment.cid}\``,``)}function Gn(e){let t=h?j(h):``,n=`${ln(Date.now())} ${un(Date.now())}`,r=[`# ${U(`chat.noteDraft.heading`)}`,``,`- ${U(`chat.noteDraft.room`)}: ${t}`,`- ${U(`chat.noteDraft.exportedAt`)}: ${n}`,`- ${U(`chat.noteDraft.messageCount`)}: ${e.length}`,``];return e.forEach(e=>Wn(r,e)),`${r.join(`
3
+ `).trimEnd()}\n`}function Kn(){let e=X.filter(Un);if(e.length===0){n(U(`chat.noteDraft.empty`),`warning`);return}let t=te({title:U(`chat.noteDraft.historyTitle`,{room:h?j(h):U(`chat.title`),time:gt()}),content:Gn(e)});if(!t){n(U(`chat.noteDraft.saveFailed`),`error`);return}N(!1),window.location.assign(p(t.id))}async function qn(e,t){if(!Q()||!Z())return;let n=O(e),r=await S.setChannelRemark(n,t);return m(e=>e.map(e=>O(e)===n?{...e,remark:r.remark}:e)),g(e=>e&&O(e)===n?{...e,remark:r.remark}:e),r.remark}async function Jn(){if(h)try{await qn(h,Ot)}catch(e){await G(e,U(`chat.error.remark`))}}async function Yn(e){if(!(!Tt||At)){jt(!0);try{await qn(Tt,e),Et(null)}catch(e){await G(e,U(`chat.error.rename`))}finally{jt(!1)}}}function Xn(e){if(!e.attachment)return(0,w.jsx)(Ge,{children:e.content});let t=e.attachment,n=It[t.cid],r=n?.status;return(0,w.jsx)(Ke,{children:(0,w.jsx)(He,{attachment:t,status:r,message:n?.message,pending:e.pending,onOpen:Vn})})}function Zn(e,t){let n=String(e||``).trim();return n?Rt?Ct(n)?n:t?`${n}#${t.slice(-4).toUpperCase()}`:n:n.replace(/#[a-fA-F0-9]{4}$/,``):St(t)}function Qn(){return(0,w.jsx)(Xe,{members:Tn.map(e=>{let t=wn.get(M(e.address)),n=t?.displayName||e.displayName,r=t?.avatar||e.avatar;return{id:e.address,name:Zn(n,e.address),avatarSrc:be(e.address,r),online:En.has(M(e.address))}})})}let $n=L&&!!_&&(!h||!!(J&&J!==bn)),er=[`chat-app-layout`,L?`sparkbit-chat-layout`:``].filter(Boolean).join(` `),tr=L?`sparkbit-chat-action-menu`:void 0,nr=h?(0,w.jsx)(`h2`,{className:`header-title`,translate:`no`,children:j(h)}):(0,w.jsx)(`h2`,{className:`header-title`,children:U(`chat.title`)}),rr=!!(Y&&W.room?.channelName===Y.channelName),ir=W.participants.filter(e=>!e.local).length,ar=W.joined?ir:W.participants.length,or=!L&&rr&&(W.joined||W.participants.length>0),sr=W.joined?U(`chat.voice.bannerJoined`,{count:ar}):U(`chat.voice.bannerActive`,{count:ar});function cr(){Y&&W.openRoom(Y)}let lr=pe.trim().toLowerCase(),ur=(0,C.useMemo)(()=>[...f].sort((e,t)=>{let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n;let r=E(t)-E(e);return r===0?cn(j(e),j(t)):r}),[f,cn]),dr=lr?ur.filter(e=>[j(e),k(e),O(e)].some(e=>e.toLowerCase().includes(lr))):ur;return(0,w.jsxs)(de,{className:er,defaultHide:L,hideAccountMenu:L,languageTheme:L?`sparkbit`:void 0,sidebar:({closeSidebar:e})=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Te,{onNavigate:e}),(0,w.jsx)(`div`,{className:`chat-channel-search`,children:(0,w.jsxs)(`div`,{className:`ui-input-control`,children:[(0,w.jsx)(me,{className:`ui-input-icon`,size:15}),(0,w.jsx)(`input`,{type:`search`,className:`input input-compact`,placeholder:U(`chat.search.placeholder`),value:pe,onChange:e=>_e(e.target.value),"aria-label":U(`chat.search.placeholder`)})]})}),(0,w.jsx)(`nav`,{className:`sidebar-nav`,children:f.length===0?(0,w.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,w.jsx)(`p`,{children:U(`chat.empty.noChannels`)})}):dr.length===0?(0,w.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,w.jsx)(`p`,{children:U(`chat.empty.noMatches`)})}):dr.map(t=>(0,w.jsx)(Ye,{active:O(h)===O(t),pinned:!!t.pinned,unread:ot(t,Wt),title:j(t),menuClassName:tr,onSelect:()=>{Nn(t),e()},onTogglePin:()=>void Fn(t),onRename:()=>Et(t),onLeave:()=>{_t(t),D.open()}},O(t)))}),(0,w.jsxs)(`button`,{className:`ui-action-dashed create-channel-btn`,onClick:()=>{!Q()||!Z()||Le.open()},children:[(0,w.jsx)(ee,{size:16}),U(`chat.joinChannel`)]})]}),headerTitle:nr,sidebarToggleReplacement:L?(0,w.jsx)(`span`,{className:`sidebar-toggle-static-logo`,"aria-hidden":`true`,children:Qt?(0,w.jsx)(`img`,{className:`sidebar-toggle-static-logo-img`,src:Qt,alt:``,onError:()=>{if(Qt===Zt){Ut(!0);return}Vt(!0)}}):(0,w.jsx)(Ee,{size:18})}):void 0,headerRight:(0,w.jsx)(`div`,{className:`header-right-actions`,children:h&&(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>N(!0),title:U(`chat.channelSettings`),children:(0,w.jsx)(ze,{size:16})})}),children:[$n?(0,w.jsx)(Pe,{}):h?(0,w.jsxs)(w.Fragment,{children:[or&&(0,w.jsxs)(`button`,{type:`button`,className:`chat-voice-banner`,onClick:cr,title:U(`chat.voice.expand`),children:[(0,w.jsx)(`span`,{className:`chat-voice-banner-icon`,children:(0,w.jsx)(he,{size:18})}),(0,w.jsx)(`span`,{className:`chat-voice-banner-label`,children:sr}),(0,w.jsx)(se,{size:18})]}),(0,w.jsxs)(`div`,{className:`chat-messages`,children:[X.length===0?(0,w.jsxs)(`div`,{className:`ui-empty-state chat-messages-empty`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon empty-icon`,children:(0,w.jsx)(fe,{size:28})}),(0,w.jsx)(`p`,{children:U(`chat.empty.noMessages`)})]}):X.map(e=>{if(Me(e))return(0,w.jsx)(qe,{children:U(`chat.system.memberJoined`,{name:Hn(e)})},e.id||`${e.author}-${e.timestamp}`);let t=e.author?.toLowerCase()===a?.address.toLowerCase(),n=wn.get(M(e.author)),r=Cn.get(M(e.author)),i=En.has(M(e.author)),o=n?.avatar||r?.avatar||e.avatar||(t?a.avatar:void 0),s=Hn(e);return(0,w.jsx)(Je,{variant:t?`self`:`other`,pending:e.pending,isOnline:i,avatarSrc:be(e.author,o),author:s,time:un(e.timestamp),children:Xn(e)},e.id||`${e.author}-${e.timestamp}`)}),(0,w.jsx)(`div`,{ref:$t})]}),(0,w.jsx)(Ze,{message:b,placeholder:U(a?`chat.composer.placeholder`:`chat.composer.signInPlaceholder`),disabled:!a,isPublishingAttachment:Pt,attachmentInputRef:en,attachmentMenuClassName:tr,showVoiceRoom:!L,onMessageChange:xe,onSend:Rn,onOpenVoiceRoom:cr,onSelectAttachmentFiles:e=>{Bn(e)}})]}):(0,w.jsx)(w.Fragment,{children:(0,w.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,w.jsx)(fe,{size:36})}),(0,w.jsx)(`h2`,{className:`ui-empty-title`,children:U(`chat.select.title`)}),(0,w.jsx)(`p`,{className:`ui-empty-desc`,children:U(`chat.select.desc`)}),(0,w.jsx)(ne,{label:U(`chat.openChannelList`)})]})}),De&&(0,w.jsx)(ge,{title:U(`chat.joinChannel`),placeholder:U(`chat.join.placeholder`),confirmText:U(`chat.join.confirm`),validate:Dn,onConfirm:In,onClose:()=>Le.close(),isLoading:T,loadingText:U(`chat.join.joining`)}),Tt&&(0,w.jsx)(ge,{title:U(`chat.renameChannel`),placeholder:U(`chat.remark.placeholder`),defaultValue:Tt.remark||``,confirmText:U(`chat.remark.save`),onConfirm:Yn,onClose:()=>{At||Et(null)},isLoading:At,loadingText:U(`chat.remark.saving`),allowEmpty:!0,validate:e=>e.length>50?U(`chat.remark.tooLong`):``}),et&&A&&(0,w.jsx)(we,{title:U(`chat.leaveChannel`),message:U(`chat.leaveConfirm`,{channel:j(A)}),confirmText:U(We?`chat.leaving`:`chat.leaveChannel`),onConfirm:()=>Pn(O(A),void 0),danger:!0,onClose:()=>{D.close(),_t(null)}}),Lt&&(0,w.jsx)(ye,{onClose:()=>F(null),children:(0,w.jsxs)(`div`,{className:`confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(`div`,{className:`modal-header`,children:[(0,w.jsx)(`h3`,{children:U(`chat.attachment.noSeedsTitle`)}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>F(null),"aria-label":U(`common.close`),children:(0,w.jsx)(ve,{size:18})})]}),(0,w.jsx)(`p`,{children:U(`chat.attachment.noSeedsFallback`)}),(0,w.jsxs)(`div`,{className:`modal-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>F(null),children:U(`common.cancel`)}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>jn(Lt),disabled:It[Lt.cid]?.status===`checking`,children:It[Lt.cid]?.status===`checking`?U(`app.checking`):U(`chat.attachment.retryCheck`)})]})]})}),Mt&&(0,w.jsx)(re,{item:Mt,isBackendReady:H,getFileDownloadUrl:x.getFileDownloadUrl,onSaveAs:kn,onClose:()=>Nt(null)}),Dt&&h&&(0,w.jsx)(`div`,{className:`channel-detail-overlay`,onClick:()=>N(!1),children:(0,w.jsxs)(`div`,{className:`channel-detail-drawer`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(`div`,{className:`channel-detail-header`,children:[(0,w.jsx)(`h3`,{children:U(`chat.details.title`)}),(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>N(!1),children:(0,w.jsx)(ve,{size:18})})]}),(0,w.jsxs)(`div`,{className:`channel-detail-body`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-section channel-members-section`,children:[(0,w.jsx)(`div`,{className:`channel-detail-label`,children:(0,w.jsx)(`span`,{children:U(`chat.details.members`,{count:Tn.length})})}),Qn()]}),qt&&(0,w.jsx)(`div`,{className:`channel-detail-section`,children:(0,w.jsxs)(`a`,{className:`btn btn-primary btn-block`,href:qt,target:`_blank`,rel:`noreferrer`,children:[(0,w.jsx)(ce,{size:16}),U(`chat.ticket.create`)]})}),!L&&(0,w.jsx)(`div`,{className:`channel-detail-section`,children:(0,w.jsxs)(`label`,{className:`setting-switch`,children:[(0,w.jsx)(`span`,{children:U(`chat.details.showAddressSuffix`)}),(0,w.jsx)(`input`,{type:`checkbox`,checked:Rt,onChange:e=>zt(e.target.checked)})]})}),!L&&(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,w.jsx)(Ie,{size:14}),(0,w.jsx)(`span`,{children:U(`chat.details.channelId`)})]}),(0,w.jsx)(`div`,{className:`ui-meta-box channel-detail-value channel-detail-mono`,translate:`no`,children:k(h)})]}),!L&&(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,w.jsx)(ie,{size:14}),(0,w.jsx)(`span`,{children:U(`chat.remark.placeholder`)})]}),(0,w.jsx)(`input`,{type:`text`,className:`input input-compact`,placeholder:U(`chat.remark.placeholder`),value:Ot,onChange:e=>kt(e.target.value),onFocus:()=>kt(h.remark||``),onBlur:()=>Jn(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},maxLength:50})]}),(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,w.jsx)(Fe,{size:14}),(0,w.jsx)(`span`,{children:U(`chat.channel.createdAt`)})]}),(0,w.jsx)(`div`,{className:`ui-meta-box channel-detail-value`,children:h.createdAt?ln(h.createdAt):`-`})]}),!L&&(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsx)(`div`,{className:`channel-detail-label`,children:(0,w.jsx)(`span`,{children:U(`chat.noteDraft.settingsTitle`)})}),(0,w.jsx)(`p`,{className:`channel-detail-hint`,children:U(`chat.noteDraft.saveAllDesc`)}),(0,w.jsx)(`button`,{className:`btn btn-secondary btn-block`,onClick:Kn,children:U(`chat.noteDraft.saveAll`)})]})]}),!L&&(0,w.jsx)(`div`,{className:`channel-detail-footer`,children:(0,w.jsx)(`button`,{className:`btn btn-secondary btn-block`,onClick:()=>{N(!1),_t(h),D.open()},children:U(`chat.leaveChannel`)})})]})})]})}var Et=a(`/chat/`)({component:Tt});export{Et as Route};