most-box 0.3.1 → 0.3.2
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.
- package/README.md +15 -14
- package/electron/main.js +1 -1
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/AccountMenu-BgbcUc0m.js +1 -0
- package/out/assets/AppTop-DZFTO9-m.js +1 -0
- package/out/assets/CopyButton-B03fpFFc.js +1 -0
- package/out/assets/FilePreviewOverlay-CA04_Ved.js +1 -0
- package/out/assets/{MarketingHeader-7B-OT2XX.js → MarketingHeader-BVJy8hXd.js} +1 -1
- package/out/assets/MarketingLayout-Cltu-DRw.js +1 -0
- package/out/assets/{MilkdownEditor-WedhCoFH.js → MilkdownEditor-Dw_ze7EE.js} +92 -92
- package/out/assets/OpenSidebarButton-C2UJYXKh.js +1 -0
- package/out/assets/arrow-right-CXzRt0Fp.js +1 -0
- package/out/assets/chatJoinInvite-BcPz_IV5.js +1 -0
- package/out/assets/chatNoteDraft-CYbvcEvC.js +1 -0
- package/out/assets/check-iBCQl0yr.js +1 -0
- package/out/assets/circle-alert-dfN4T6Nq.js +1 -0
- package/out/assets/cobol-DHLQUbN7.js +1 -0
- package/out/assets/copy-B7pPZ2MP.js +1 -0
- package/out/assets/{dist-DCX0ws1K.js → dist-1jNICPWO.js} +1 -1
- package/out/assets/{dist-BAJKKN4w.js → dist-B3unnv5t.js} +1 -1
- package/out/assets/{dist-DJdv-Ma3.js → dist-B5MBMmGa.js} +1 -1
- package/out/assets/{dist-CMmmtl3f.js → dist-BAqJdUtV.js} +1 -1
- package/out/assets/{dist-C3lbe8SW.js → dist-BBJOmVU3.js} +1 -1
- package/out/assets/{dist-IN8WN7NI.js → dist-BV5CqsJD.js} +1 -1
- package/out/assets/{dist-DBnWo8ZP.js → dist-Ba7fxbV-.js} +1 -1
- package/out/assets/{dist-BzqqCPi2.js → dist-BxxtNKuo.js} +1 -1
- package/out/assets/{dist-DvWZsW-D.js → dist-C8Ue2rSs.js} +1 -1
- package/out/assets/{dist-C-Tg23jc.js → dist-CIn7Xx5U.js} +1 -1
- package/out/assets/{dist-CbTzBiwL.js → dist-CSyRxrry.js} +3 -3
- package/out/assets/{dist-DTL5jL08.js → dist-CZIuQqmV.js} +1 -1
- package/out/assets/{dist-8QDHqrPN.js → dist-CaaBTHCc.js} +1 -1
- package/out/assets/{dist-yZ96GF-e.js → dist-CgReC0ZE.js} +1 -1
- package/out/assets/{dist-D94V9Zlh.js → dist-Ct90qYA2.js} +1 -1
- package/out/assets/{dist-IGpXmkFm.js → dist-DIFFjNuO.js} +1 -1
- package/out/assets/{dist-CqQavSZV.js → dist-DUB2IhWu.js} +1 -1
- package/out/assets/{dist-B0JrbG7f.js → dist-DheA_Tyz.js} +1 -1
- package/out/assets/{dist-Br_5lLVO.js → dist-DyZh1ncm.js} +1 -1
- package/out/assets/{dist-BPs0Xns9.js → dist-E74uGTy3.js} +1 -1
- package/out/assets/{dist-BFSyuOuw.js → dist-K2s-Uj08.js} +1 -1
- package/out/assets/{dist-zyJb88Zz.js → dist-RU_cpjXQ.js} +1 -1
- package/out/assets/{dist-chOCTzB2.js → dist-eIeCvp_6.js} +1 -1
- package/out/assets/{dist-CfU9fwWz.js → dist-hEE2Ub__.js} +1 -1
- package/out/assets/download-COQOcPqI.js +1 -0
- package/out/assets/{downloadValidation-Ch966YTl.js → downloadValidation-Zvllo2SZ.js} +1 -1
- package/out/assets/external-link-D6tHlYgS.js +1 -0
- package/out/assets/file-text-DiyIGL1I.js +1 -0
- package/out/assets/folder-DAcox9xz.js +1 -0
- package/out/assets/folder-open-Di0oALaC.js +1 -0
- package/out/assets/hard-drive-Cqa7Rstj.js +1 -0
- package/out/assets/index-B6acG3-t.css +1 -0
- package/out/assets/index-DjBN7bZV.js +31 -0
- package/out/assets/index.lazy-BUODxlbz.js +1 -0
- package/out/assets/index.lazy-Ba2rqd32.js +3 -0
- package/out/assets/index.lazy-Bdh8QUOx.js +1 -0
- package/out/assets/index.lazy-BfAHB94y.js +1 -0
- package/out/assets/index.lazy-Bo0LfJNK.js +2 -0
- package/out/assets/index.lazy-C9-w4fAF.js +3 -0
- package/out/assets/index.lazy-CNQbNKyf.js +1 -0
- package/out/assets/index.lazy-Cd0znkpY.js +1 -0
- package/out/assets/index.lazy-CtUrBLS0.js +1 -0
- package/out/assets/index.lazy-CyNgk0ta.js +1 -0
- package/out/assets/index.lazy-D3HxQTg_.js +1 -0
- package/out/assets/index.lazy-DSsE3iyf.js +1 -0
- package/out/assets/index.lazy-DWXndrGa.js +1 -0
- package/out/assets/index.lazy-Dk7cmQ-j.js +2 -0
- package/out/assets/key-round-JR8M3aHl.js +1 -0
- package/out/assets/loader-CwyHYZdX.js +1 -0
- package/out/assets/lock-CuwwlXlx.js +1 -0
- package/out/assets/message-square-BgsNXPft.js +1 -0
- package/out/assets/mp-Dv12gDTx.js +1 -0
- package/out/assets/music-Dn9nm9Qb.js +1 -0
- package/out/assets/notebook-pen-SWT-zZ4v.js +1 -0
- package/out/assets/play-CvWKSMwY.js +1 -0
- package/out/assets/refresh-cw-D4BsHvhi.js +1 -0
- package/out/assets/save-B02sbO9Y.js +1 -0
- package/out/assets/scheme-tChLYBuY.js +1 -0
- package/out/assets/search-HW4oPOBP.js +1 -0
- package/out/assets/send-4dhnJGuS.js +1 -0
- package/out/assets/shield-check-Boae7Nc6.js +1 -0
- package/out/assets/smartphone-JXH-zQXB.js +1 -0
- package/out/assets/textile-CyzeGT9J.js +1 -0
- package/out/assets/trash-2-BLwoM0ME.js +1 -0
- package/out/assets/triangle-alert-B9sMiA9l.js +1 -0
- package/out/assets/upload-DVuXJt_o.js +1 -0
- package/out/assets/useAppStore-DOnk608w.js +4 -0
- package/out/assets/{useChannelMessages-Bs_RWgO4.js → useChannelMessages-CDvw-f_x.js} +1 -1
- package/out/assets/useGameRoom-B1_r6bc7.js +1 -0
- package/out/assets/userProfile-BZvkCuet.js +1 -0
- package/out/assets/wallet-D9Iw4YWE.js +1 -0
- package/out/assets/wifi-ljEI_ySA.js +1 -0
- package/out/chat/index.html +0 -0
- package/out/chat/join/demo/index.html +0 -0
- package/out/chat/join/index.html +0 -0
- package/out/download/index.html +2 -2
- package/out/game/gandengyan/index.html +0 -0
- package/out/game/index.html +0 -0
- package/out/game/zhajinhua/index.html +0 -0
- package/out/index.html +2 -2
- package/out/note/index.html +0 -0
- package/out/ping/index.html +2 -2
- package/out/profile/index.html +0 -0
- package/out/web3/index.html +0 -0
- package/package.json +27 -24
- package/server/index.js +3 -0
- package/server/src/config.js +0 -1
- package/server/src/core/gameRoom.js +12 -19
- package/server/src/http/routes/noteVaultRoutes.js +70 -0
- package/server/src/index.js +9 -0
- package/server/src/utils/accountBackup.js +8 -0
- package/server/src/utils/api.js +0 -14
- package/server/src/utils/auth.js +0 -7
- package/server/src/utils/avatar.js +6 -6
- package/server/src/utils/noteVault.js +197 -2
- package/out/assets/AccountMenu-NjOgag0d.js +0 -1
- package/out/assets/FilePreviewOverlay-CZp6F1s_.js +0 -1
- package/out/assets/MarketingLayout-CyiSCygk.js +0 -1
- package/out/assets/OpenSidebarButton-BoSmO8CY.js +0 -1
- package/out/assets/SidebarHomeLink-CkhGDvZ8.js +0 -1
- package/out/assets/arrow-right-DUxAoZqb.js +0 -1
- package/out/assets/avatar-BZwHW4ll.js +0 -4
- package/out/assets/circle-alert-DSZ0bG_3.js +0 -1
- package/out/assets/cobol-B_OZ4V-R.js +0 -1
- package/out/assets/copy-CK7HMulu.js +0 -1
- package/out/assets/download-Q1uCiwif.js +0 -1
- package/out/assets/external-link-DGzNJOqQ.js +0 -1
- package/out/assets/file-text-C3v0L_lQ.js +0 -1
- package/out/assets/folder-CwtLO09O.js +0 -1
- package/out/assets/hard-drive-B2V5USzR.js +0 -1
- package/out/assets/i18n-DZaOYCSO.js +0 -1
- package/out/assets/index-CBkHUp3F.css +0 -1
- package/out/assets/index-DluhgSHX.js +0 -31
- package/out/assets/index.lazy-B5TYRvFJ.js +0 -1
- package/out/assets/index.lazy-BeDctVci.js +0 -1
- package/out/assets/index.lazy-BjmAkVtV.js +0 -1
- package/out/assets/index.lazy-CHJbzlK6.js +0 -1
- package/out/assets/index.lazy-CITrkWMQ.js +0 -1
- package/out/assets/index.lazy-CTGE5fUt.js +0 -2
- package/out/assets/index.lazy-CUxcXUMy.js +0 -2
- package/out/assets/index.lazy-D84xQtPb.js +0 -3
- package/out/assets/index.lazy-DRqAgqpV.js +0 -1
- package/out/assets/index.lazy-DSAmY1q_.js +0 -1
- package/out/assets/index.lazy-DvbVQRSL.js +0 -1
- package/out/assets/index.lazy-gAJi-rJV.js +0 -1
- package/out/assets/index.lazy-rzyMd-Gz.js +0 -1
- package/out/assets/key-round-Dn5tud-4.js +0 -1
- package/out/assets/loader-CLoDCtNy.js +0 -1
- package/out/assets/lock-BEWKuIqK.js +0 -1
- package/out/assets/message-square-C8ZiYztG.js +0 -1
- package/out/assets/mp-CGBtY36n.js +0 -1
- package/out/assets/music-BsTA8b_M.js +0 -1
- package/out/assets/notebook-pen-DgWzxf2y.js +0 -1
- package/out/assets/play-CVkbAJJU.js +0 -1
- package/out/assets/plus-D1kCYb8G.js +0 -1
- package/out/assets/save-X5c7jlCg.js +0 -1
- package/out/assets/scheme-CyDdOh7e.js +0 -1
- package/out/assets/search-DAV9vDOq.js +0 -1
- package/out/assets/send-C5JjYo-A.js +0 -1
- package/out/assets/shield-check-DuD6OLde.js +0 -1
- package/out/assets/smartphone-gVFruyjO.js +0 -1
- package/out/assets/textile-DWBqthVk.js +0 -1
- package/out/assets/trash-2-CE-3Dc63.js +0 -1
- package/out/assets/triangle-alert-DnOxsFpB.js +0 -1
- package/out/assets/upload-CsnBv3pd.js +0 -1
- package/out/assets/useGameRoom-BxDxm3rp.js +0 -1
- package/out/assets/userProfile-UphvP_bG.js +0 -1
- package/out/assets/wallet-VDaoXwjI.js +0 -1
- package/out/assets/wifi-DfWbmlGE.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,Q as i,R as a,_ as o,c as s,f as c,s as l,tt as u,u as d,x as ee,y as te}from"./avatar-BZwHW4ll.js";import{a as ne}from"./i18n-DZaOYCSO.js";import{a as f}from"./AccountMenu-NjOgag0d.js";import{n as re,t as p}from"./folder-CwtLO09O.js";import{t as ie}from"./copy-CK7HMulu.js";import{t as ae}from"./download-Q1uCiwif.js";import{t as oe}from"./file-text-C3v0L_lQ.js";import{a as m,i as se,n as h,r as ce,t as le}from"./FilePreviewOverlay-CZp6F1s_.js";import{t as ue}from"./loader-CLoDCtNy.js";import{i as de,n as fe,t as pe}from"./SidebarHomeLink-CkhGDvZ8.js";import{t as g}from"./music-BsTA8b_M.js";import{t as me}from"./OpenSidebarButton-BoSmO8CY.js";import{t as he}from"./search-DAV9vDOq.js";import{t as ge}from"./trash-2-CE-3Dc63.js";import{t as _e}from"./upload-CsnBv3pd.js";import{t as ve}from"./format-CR8oUWq6.js";import{n as _,r as ye,t as be}from"./downloadValidation-Ch966YTl.js";var xe=r(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),Se=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`}]]),Ce=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`}]]),we=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`}]]),v=t(e(),1);function Te(e={}){let t=e.timeout??2e3,[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null);(0,v.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 y=n();function b(e){let t=e.lastIndexOf(`/`);return t===-1?{folder:``,name:e}:{folder:e.substring(0,t),name:e.substring(t+1)}}function Ee({file:e,isSelected:t,onSelect:n,onPreview:r}){let i=h(e.fileName),a=(0,y.jsx)(oe,{size:24,color:`#fff`});return i===`image`?a=(0,y.jsx)(se,{size:24,color:`#fff`}):i===`video`?a=(0,y.jsx)(m,{size:24,color:`#fff`}):i===`audio`&&(a=(0,y.jsx)(g,{size:24,color:`#fff`})),(0,y.jsxs)(`div`,{"data-id":e.cid,onClick:()=>n(e.cid),onDoubleClick:()=>r(e),className:`card ${t?`selected`:``}`,children:[(0,y.jsx)(`div`,{className:`card-icon ${e.starred?`starred`:`file`}`,children:a}),(0,y.jsx)(`p`,{className:`card-name`,translate:`no`,children:b(e.fileName).name})]})}function De({folder:e,onClick:t}){return(0,y.jsxs)(`div`,{onClick:t,className:`card`,children:[(0,y.jsx)(`div`,{className:`card-icon folder`,children:(0,y.jsx)(p,{size:28,color:`#fff`})}),(0,y.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 Oe({items:e,allFolders:t,currentPath:n,onMove:r,onClose:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(n),{t:u}=ne(),ee=x(o,u(`move.root`));function te(){r(o||c.trim())}let f=t.filter(e=>{if(o===``)return!e.path.includes(`/`);let t=o+`/`;return e.path.startsWith(t)?!e.path.substring(t.length).includes(`/`):!1});return(0,y.jsx)(d,{onClose:a,children:(0,y.jsxs)(`div`,{className:`move-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`modal-header`,children:[(0,y.jsx)(`h3`,{children:u(`move.title`)}),(0,y.jsx)(`button`,{type:`button`,onClick:a,className:`btn btn-icon`,children:(0,y.jsx)(i,{size:18})})]}),(0,y.jsx)(`p`,{className:`move-modal-desc`,children:u(`move.selectedCount`,{count:e.length})}),(0,y.jsx)(`div`,{className:`move-new-folder`,children:(0,y.jsx)(`input`,{type:`text`,className:`input`,value:c,onChange:e=>l(e.target.value),placeholder:u(`move.pathPlaceholder`),translate:`no`})}),(0,y.jsx)(`p`,{className:`move-modal-hint`,children:u(`move.pathExample`)}),(0,y.jsx)(`div`,{className:`move-breadcrumb`,children:ee.map((e,t)=>(0,y.jsxs)(v.Fragment,{children:[t>0&&(0,y.jsx)(`span`,{className:`breadcrumb-separator`,children:`/`}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>{s(e.path),l(e.path)},className:`move-breadcrumb-btn ${o===e.path&&!c?`active`:``}`,children:(0,y.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.name})})]},e.path))}),(0,y.jsxs)(`div`,{className:`move-folder-list`,children:[f.length===0&&(0,y.jsx)(`p`,{className:`move-modal-empty`,children:u(`move.noSubfolders`)}),f.map(e=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>s(e.path),className:`move-folder-item ${o===e.path&&!c?`selected`:``}`,children:[(0,y.jsx)(p,{size:16}),(0,y.jsx)(`span`,{translate:`no`,children:e.name})]},e.path))]}),(0,y.jsxs)(`div`,{className:`modal-actions`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:a,className:`btn btn-secondary`,children:u(`common.cancel`)}),(0,y.jsx)(`button`,{type:`button`,onClick:te,className:`btn btn-primary`,children:u(`move.action`)})]})]})})}var S=`https://most.box`;function ke(e,t){let n=String(t||``).trim(),r=`${S}/cid/${encodeURIComponent(e)}`;return n?`${r}?filename=${encodeURIComponent(n)}`:r}function C(e){return b(e)}function Ae(e){let t=new Set;return e.forEach(e=>{let{folder:n}=C(e.fileName),r=n.split(`/`).filter(Boolean),i=``;for(let e of r)i+=(i?`/`:``)+e,t.add(i)}),[...t].sort()}function w(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 je(e,t,n){return{folders:w(t,n),files:e.filter(e=>C(e.fileName).folder===n)}}function Me(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 Ne(){let e=c(e=>e.addToast),t=c(e=>e.hasBackend),n=c(e=>e.openConnectModal),r=a(e=>e.identity),u=a(e=>e.openLoginModal),[p,m]=(0,v.useState)([]),[se,g]=(0,v.useState)([]),[b,x]=(0,v.useState)(null),[S,w]=(0,v.useState)(`all`),[Ne,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)([]),[Pe,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(null),[Fe,Ie]=de(!1),[Le,Re]=(0,v.useState)(``),[j,M]=(0,v.useState)(null),[N,ze]=(0,v.useState)(!1),[Be,P]=(0,v.useState)([]),[Ve,F]=de(!1),[I,L]=(0,v.useState)(``),{copy:He,copied:Ue}=Te({timeout:2e3}),[We,Ge]=de(!1),[R,z]=(0,v.useState)(null),[B,Ke]=(0,v.useState)(null),[qe,Je]=(0,v.useState)(!1),{t:V,formatDate:Ye}=ne(),H=t===!0,Xe=e=>e?Ye(e):``,U=b||``,Ze=Ae(p),{folders:Qe,files:$e}=je(p,Ze,U);function W(){return H?!0:(n(),!1)}function G(){return r?!0:(u(),!1)}let et=I?p.filter(e=>C(e.fileName).name.toLowerCase().includes(I.toLowerCase())):$e,K=async()=>{if(!H||!r){m([]);return}try{m(await _.listPublishedFiles()||[])}catch{m([])}},q=async()=>{if(!H||!r){g([]);return}try{g(await _.listTrashFiles()||[])}catch{g([])}},tt=e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},nt=async t=>{if(G()&&W())try{await _.restoreTrashFile(t),e(V(`app.toast.restored`),`success`),K(),q()}catch(t){e(await o(t,V(`app.toast.restoreFailed`)),`error`)}},rt=async()=>{G()&&W()&&z({title:V(`app.clearTrash.title`),message:V(`app.clearTrash.message`),confirmText:V(`app.clear`),danger:!0,onConfirm:async()=>{z(null);try{await _.emptyTrash(),e(V(`app.toast.trashEmptied`),`success`),q()}catch(t){e(await o(t,V(`app.toast.emptyFailed`)),`error`)}}})},it=async t=>{if(G()&&W())try{let n=await _.toggleStar(t);m(e=>e.map(e=>e.cid===t?{...e,starred:n.starred}:e)),e(n.starred?V(`app.toast.favorited`):V(`app.toast.unfavorited`),`success`)}catch(t){e(await o(t,V(`app.toast.actionFailed`)),`error`)}},at=async()=>{if(!G()||!W())return;let t=S===`trash`;z({title:V(t?`app.permanentDelete`:`app.batchDelete`),message:V(t?`app.deleteSelectedPermanent`:`app.deleteSelected`,{count:E.length}),confirmText:V(t?`app.permanentDelete`:`app.delete`),danger:!0,onConfirm:async()=>{z(null);try{for(let e of E)t?await _.permanentDeleteTrashFile(e):e.startsWith(`__`)||await _.deletePublishedFile(e);D([]),e(V(t?`app.toast.deletedPermanently`:`app.toast.deleted`),`success`),K(),q()}catch(t){e(await o(t,V(`app.toast.deleteFailed`)),`error`)}}})},ot=async t=>{if(G()&&W())try{for(let e of E){let n=p.find(t=>t.cid===e);if(!n)continue;let{name:r}=C(n.fileName),i=t?`${t}/${r}`:r;n.fileName!==i&&await _.moveFile(e,i)}D([]),Ge.close(),e(V(`app.toast.moved`),`success`),K()}catch(t){e(await o(t,V(`app.toast.moveFailed`)),`error`)}},st=t=>{let n=!!t.path,r=n?t.name:C(t.fileName).name;Ke({title:V(n?`app.renameFolder`:`app.renameFile`),placeholder:V(`app.enterNewName`),defaultValue:r,confirmText:V(`app.rename`),onConfirm:async i=>{if(i!==r&&G()&&W()){Je(!0);try{if(n){let n=t.path.lastIndexOf(`/`),r=n===-1?``:t.path.substring(0,n),a=r?`${r}/${i}`:i;await _.renameFolder(t.path,a),e(V(`app.toast.renamed`),`success`),K(),Z(a)}else{let{folder:n}=C(t.fileName),r=n?`${n}/${i}`:i;await _.moveFile(t.cid,r),e(V(`app.toast.renamed`),`success`),K()}Ke(null)}catch(t){e(await o(t,V(`app.toast.renameFailed`)),`error`)}finally{Je(!1)}}}})},ct=async t=>{if(!r){u(),e(V(`app.toast.signInBeforePublish`),`warning`);return}if(!W())return;let n=U?U+`/`:``,i=[];for(let r of Array.from(t)){let t=n+r.name;if(p.some(e=>e.fileName===t)){e(V(`app.fileAlreadyExists`,{fileName:r.name}),`warning`);continue}let a=`upload_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,s={id:a,fileName:r.name,progress:0,type:`upload`,status:`uploading`};i.push(s),P(e=>[...e,s]),i.length>0&&F.open();try{(await _.publishFile(r,t)).alreadyExists?(P(e=>e.map(e=>e.id===a?{...e,status:`completed`}:e)),e(V(`app.fileAlreadyExists`,{fileName:r.name}),`warning`)):(P(e=>e.map(e=>e.id===a?{...e,progress:100,status:`completed`}:e)),e(V(`app.fileAddedLocal`,{fileName:r.name}),`success`))}catch(t){P(e=>e.map(e=>e.id===a?{...e,status:`error`}:e)),e(await o(t,V(`app.publishFailedWithFile`,{fileName:r.name})),`error`)}}setTimeout(()=>{P(e=>e.filter(e=>e.status!==`completed`&&e.status!==`error`&&e.status!==`cancelled`))},3e3),K()},lt=k?ke(k.cid,k.fileName):``,ut=()=>{lt&&He(lt)},[J,dt]=(0,v.useState)(!1),Y=Le.trim(),X=j?.status===`success`&&j.link===Y,ft=()=>{Ie.close(),M(null)},pt=e=>{Re(e.target.value),M(null)},mt=async()=>{let t=be(Y,V);if(t){M({status:`error`,link:Y,message:t}),e(t,`warning`);return}if(!(N||J)&&G()&&W()){ze(!0),M(null);try{let t=await _.checkDownload(Y);M({status:`success`,link:Y,message:t.alreadyExists?V(`app.fileAlreadyLocal`,{fileName:t.fileName}):V(`app.fileAvailable`,{fileName:t.fileName})}),e(t.alreadyExists?V(`app.fileAlreadyExists`,{fileName:t.fileName}):V(`app.toast.checkPassed`),t.alreadyExists?`warning`:`success`)}catch(t){let n=await ye(t);M({status:`error`,link:Y,message:n}),e(n,`error`)}finally{ze(!1)}}},ht=async()=>{if(!r){u(),e(V(`app.toast.signInBeforeDownload`),`warning`);return}if(!W())return;let t=be(Y,V);if(t){e(t,`warning`);return}if(!X){e(V(`app.toast.checkLinkFirst`),`warning`);return}if(!J){dt(!0);try{let t=await _.downloadFile(Y);if(Re(``),M(null),ft(),t.alreadyExists)e(V(`app.fileAlreadyExists`,{fileName:t.fileName}),`warning`);else{let n={id:t.taskId,fileName:V(`app.downloadFallbackName`),progress:0,type:`download`,status:`downloading`};P(e=>[...e,n]),F.open(),e(V(`app.toast.downloadStarted`),`info`)}}catch(t){e(await o(t,V(`app.toast.downloadFailed`)),`error`)}finally{dt(!1)}}},gt=async t=>{if(G()&&W()&&t.type===`download`&&t.status===`downloading`){P(e=>e.map(e=>e.id===t.id?{...e,status:`cancelling`}:e));try{await _.cancelDownload(t.id)}catch(n){P(e=>e.map(e=>e.id===t.id?{...e,status:`downloading`}:e)),e(await o(n,V(`app.toast.cancelFailed`)),`error`)}}},_t=async t=>{if(G()&&W()){if(t.localAvailable===!1){e(V(`app.toast.fileNotLocal`),`warning`);return}try{let n=await fetch(_.getFileDownloadUrl(t.cid),{headers:await te(`GET`,`/api/files/${t.cid}/download`)});if(!n.ok)throw Error(V(`app.toast.getFileFailed`));let r=await n.blob(),i=window.showSaveFilePicker;if(i){let n=await(await i({suggestedName:t.fileName})).createWritable();await n.write(r),await n.close(),e(V(`app.toast.fileSaved`),`success`)}else{let n=URL.createObjectURL(r),i=document.createElement(`a`);i.href=n,i.download=t.fileName,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(n),e(V(`app.toast.fileDownloaded`),`success`)}}catch(t){t.name!==`AbortError`&&e(V(`app.saveFailedWithError`,{error:t.message}),`error`)}}},vt=async t=>{if(G()&&W())try{e(V(`app.toast.startPullLocal`),`info`),await _.cacheFile(t.cid),e(V(`app.toast.pulledAndSeeding`),`success`),K()}catch(t){e(await o(t,V(`app.toast.pullFailed`)),`error`)}},Z=e=>{x(e||null),D([])};(0,v.useEffect)(()=>{if(t!==!0)return;let n=null,r=!1;return(async()=>{if(n=new WebSocket(await ee(`/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`){K();let t=r.taskId||r.fileName;P(e=>e.map(e=>e.id===t||e.fileName===r.fileName?{...e,progress:100,status:`completed`}:e)),n===`download:success`&&(r.alreadyExists?e(V(`app.fileAlreadyExists`,{fileName:r.fileName}),`warning`):e(V(`app.fileDownloadCompleted`,{fileName:r.fileName}),`success`),setTimeout(()=>{P(e=>e.filter(e=>!(e.id===t&&e.status===`completed`)))},3e3))}n===`publish:progress`&&P(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`&&P(e=>e.map(e=>e.id===r.taskId?{...e,progress:r.percent||0,loaded:r.loaded,total:r.total}:e)),n===`download:error`&&(P(e=>e.map(e=>e.id===r.taskId?{...e,status:`error`}:e)),e(V(`app.downloadFailedWithError`,{error:r.error}),`error`)),n===`download:status`&&P(e=>e.map(e=>e.id===r.taskId?{...e,fileName:r.file||e.fileName}:e)),n===`download:cancelled`&&(P(e=>e.map(e=>e.id===r.taskId?{...e,status:`cancelled`}:e)),e(V(`app.toast.downloadCancelled`),`warning`)),n===`user:metadata:updated`&&(K(),q())}catch(e){console.warn(`[App WS] Failed to parse message:`,e.message)}}})(),()=>{r=!0,n?.close()}},[t,r?.address]),(0,v.useEffect)(()=>{if(t===!0&&r){K(),q();return}t===!1&&(m([]),g([]))},[t,r?.address]),(0,v.useEffect)(()=>{r||(D([]),O(null),A(null),Re(``),M(null),P([]),L(``),x(null),w(`all`))},[r?.address]);let yt=V(S===`all`?`app.nav.local`:S===`starred`?`app.nav.favorites`:`app.nav.trash`),Q=S===`all`?et:S===`starred`?p.filter(e=>e.starred&&C(e.fileName).name.toLowerCase().includes(I.toLowerCase())):se.filter(e=>C(e.fileName).name.toLowerCase().includes(I.toLowerCase())),bt=S===`starred`?[]:Qe.filter(e=>e.name.toLowerCase().includes(I.toLowerCase())),$=Me(U,V(`app.allContent`));return(0,y.jsxs)(fe,{sidebar:({closeSidebar:e})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(pe,{onNavigate:e}),(0,y.jsx)(`nav`,{className:`sidebar-nav`,children:[{id:`all`,icon:(0,y.jsx)(Se,{size:18}),label:V(`app.nav.local`)},{id:`starred`,icon:(0,y.jsx)(we,{size:18}),label:V(`app.nav.favorites`)},{id:`trash`,icon:(0,y.jsx)(ge,{size:18}),label:V(`app.nav.trash`)}].map(t=>(0,y.jsxs)(`button`,{onClick:()=>{w(t.id),x(null),D([]),L(``),e()},className:`sidebar-nav-btn ${S===t.id?`active`:``}`,children:[t.icon,(0,y.jsx)(`span`,{children:t.label})]},t.id))})]}),headerTitle:(0,y.jsx)(`h2`,{className:`header-title`,children:yt}),headerRight:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`search-box`,children:[(0,y.jsx)(he,{size:14}),(0,y.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:V(`app.search.placeholder`)}),I&&(0,y.jsx)(`button`,{onClick:()=>L(``),children:(0,y.jsx)(i,{size:12})})]}),S===`trash`&&se.length>0&&(0,y.jsx)(`button`,{onClick:rt,className:`btn btn-sm btn-empty-trash`,children:V(`app.emptyTrash`)}),(0,y.jsx)(`button`,{onClick:()=>F.open(),className:`btn btn-icon`,children:(0,y.jsx)(xe,{size:16})})]}),children:[S===`all`&&(0,y.jsxs)(`div`,{className:`action-grid`,children:[(0,y.jsxs)(`div`,{className:`action-card upload ${Ne?`drag-over`:``}`,onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{e.preventDefault(),T(!1),!(!G()||!W())&&ct(e.dataTransfer.files)},children:[(0,y.jsx)(`input`,{type:`file`,multiple:!0,onClick:e=>{(!G()||!W())&&e.preventDefault()},onChange:e=>ct(e.target.files),className:`action-card-input`}),(0,y.jsx)(_e,{size:20,className:`action-grid-icon`}),(0,y.jsx)(`p`,{children:V(`app.publishFile`)})]}),(0,y.jsxs)(`div`,{className:`action-card action-card-download`,onClick:()=>{!G()||!W()||Ie.open()},children:[(0,y.jsx)(ae,{size:20,className:`action-grid-icon`}),(0,y.jsx)(`p`,{children:V(`app.downloadFile`)})]})]}),S===`all`&&(0,y.jsx)(`div`,{className:`breadcrumb`,children:U?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:()=>Z(``),children:V(`app.allContent`)}),$.slice(1).map((e,t)=>(0,y.jsxs)(v.Fragment,{children:[(0,y.jsx)(re,{size:12}),(0,y.jsx)(`button`,{onClick:()=>Z(e.path),className:t===$.length-2?`current`:``,children:(0,y.jsx)(`span`,{translate:`no`,children:e.name})}),t===$.length-2&&(0,y.jsx)(`button`,{onClick:()=>st(e),className:`breadcrumb-edit-btn`,children:(0,y.jsx)(ce,{size:12})})]},e.path))]}):null}),(0,y.jsxs)(`div`,{className:`content-grid`,children:[S===`trash`&&(Q.length===0?(0,y.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,y.jsx)(`p`,{children:V(I?`app.noMatches`:`app.trashEmpty`)}),(0,y.jsx)(me,{label:V(`app.openFileNavigation`)})]}):(0,y.jsx)(`div`,{className:`file-grid`,children:Q.map(e=>(0,y.jsxs)(`div`,{onClick:()=>D(t=>t.includes(e.cid)?t.filter(t=>t!==e.cid):[...t,e.cid]),onDoubleClick:()=>nt(e.cid),className:`card ${E.includes(e.cid)?`selected`:``}`,children:[(0,y.jsx)(`div`,{className:`card-icon trash`,children:(0,y.jsx)(oe,{size:24,color:`#fff`})}),(0,y.jsx)(`p`,{className:`card-name`,translate:`no`,children:C(e.fileName).name}),(0,y.jsx)(`p`,{className:`card-date`,children:V(`app.deletedOn`,{date:Xe(e.deletedAt)})})]},e.cid))})),S!==`trash`&&(Q.length===0&&bt.length===0?(0,y.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,y.jsx)(`p`,{children:V(I?`app.noMatches`:S===`starred`?`app.noFavorites`:`app.noLocalFiles`)}),(0,y.jsx)(me,{label:V(`app.openFileNavigation`)})]}):(0,y.jsxs)(`div`,{className:`file-grid`,children:[bt.map(e=>(0,y.jsx)(De,{folder:e,onClick:()=>Z(e.path)},e.path)),Q.map(t=>(0,y.jsx)(Ee,{file:t,isSelected:E.includes(t.cid),onSelect:tt,onPreview:t=>{if(t.localAvailable===!1){e(V(`app.toast.fileNotLocal`),`warning`);return}O({...t,subtype:h(t.fileName)})}},t.cid))]}))]}),R&&(0,y.jsx)(s,{title:R.title,message:R.message,confirmText:R.confirmText,danger:R.danger,onConfirm:R.onConfirm,onClose:()=>z(null)}),B&&(0,y.jsx)(l,{title:B.title,placeholder:B.placeholder,defaultValue:B.defaultValue,confirmText:B.confirmText,isLoading:qe,onConfirm:B.onConfirm,onClose:()=>Ke(null)}),We&&(0,y.jsx)(Oe,{items:E.map(e=>p.find(t=>t.cid===e)).filter(Boolean),allFolders:Ze.map(e=>({path:e,name:e.split(`/`).pop()})),currentPath:U,onMove:ot,onClose:()=>Ge.close()}),k&&(0,y.jsx)(d,{onClose:()=>A(null),children:(0,y.jsxs)(`div`,{className:`share-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`modal-header`,children:[(0,y.jsx)(`h3`,{children:V(`app.shareLink`)}),(0,y.jsx)(`button`,{onClick:()=>A(null),className:`btn btn-icon`,children:(0,y.jsx)(i,{size:18})})]}),(0,y.jsxs)(`div`,{className:`share-link-box`,children:[(0,y.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:lt}),(0,y.jsx)(`button`,{onClick:ut,className:`btn btn-circle btn-primary ${Ue?`copied`:``}`,children:Ue?(0,y.jsx)(f,{size:18}):(0,y.jsx)(ie,{size:18})})]}),(0,y.jsx)(`div`,{className:`share-storage-note`,children:(0,y.jsx)(`span`,{children:V(`app.shareSeedNote`)})})]})}),Fe&&(0,y.jsx)(d,{onClose:ft,children:(0,y.jsxs)(`div`,{className:`download-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`modal-header`,children:[(0,y.jsx)(`h3`,{children:V(`app.downloadFile`)}),(0,y.jsx)(`button`,{onClick:ft,className:`btn btn-icon`,children:(0,y.jsx)(i,{size:18})})]}),(0,y.jsxs)(`div`,{className:`download-link-row`,children:[(0,y.jsx)(`input`,{type:`text`,className:`input`,value:Le,onChange:pt,placeholder:V(`app.downloadLink.placeholder`)}),(0,y.jsxs)(`button`,{type:`button`,onClick:mt,disabled:!Y||N||J,className:`btn btn-secondary download-check-btn`,children:[N?(0,y.jsx)(ue,{size:14,className:`spin`}):X?(0,y.jsx)(f,{size:14}):(0,y.jsx)(he,{size:14}),V(N?`app.checking`:X?`app.passed`:`app.check`)]})]}),j&&(0,y.jsxs)(`div`,{className:`download-check-status ${j.status}`,children:[j.status===`success`?(0,y.jsx)(f,{size:14}):(0,y.jsx)(Ce,{size:14}),(0,y.jsx)(`span`,{children:j.message})]}),(0,y.jsxs)(`button`,{onClick:ht,disabled:!X||J||N,className:`btn btn-info btn-full`,children:[J?(0,y.jsx)(ue,{size:14,className:`spin`}):(0,y.jsx)(ae,{size:14}),V(J?`app.downloading`:`app.startDownload`)]})]})}),Pe&&(0,y.jsx)(le,{item:Pe,isBackendReady:H,getFileDownloadUrl:_.getFileDownloadUrl,onClose:()=>O(null)}),E.length>0&&(0,y.jsxs)(`div`,{className:`batch-bar`,children:[(0,y.jsx)(`span`,{className:`batch-info`,children:V(`app.selectedItems`,{count:E.length})}),(0,y.jsx)(`button`,{onClick:()=>D([]),className:`batch-dismiss`,children:(0,y.jsx)(i,{size:16})}),(0,y.jsx)(`div`,{className:`batch-divider`}),S===`trash`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:async()=>{G()&&W()&&(await Promise.all(E.map(e=>_.restoreTrashFile(e))),D([]),e(V(`app.toast.restored`),`success`),K(),q())},className:`btn btn-sm`,children:V(`app.restore`)}),(0,y.jsx)(`button`,{onClick:at,className:`btn btn-sm btn-danger`,children:V(`app.permanentDelete`)})]}):(0,y.jsxs)(y.Fragment,{children:[E.length===1&&(()=>{let e=p.find(e=>e.cid===E[0]);return e&&h(e.fileName)!==`file`})()&&(0,y.jsx)(`button`,{onClick:()=>{let t=p.find(e=>e.cid===E[0]);if(t){if(t.localAvailable===!1){e(V(`app.toast.fileNotLocal`),`warning`);return}let n=h(t.fileName);O({...t,subtype:n})}},className:`btn btn-sm`,children:V(`app.preview`)}),(0,y.jsx)(`button`,{onClick:()=>{let e=E.some(e=>{let t=p.find(t=>t.cid===e);return t&&!t.starred});E.forEach(t=>{let n=p.find(e=>e.cid===t);n&&(e?!n.starred:n.starred)&&it(t)})},className:`btn btn-sm btn-star`,children:V(`app.favorite`)}),E.length===1&&(0,y.jsx)(`button`,{onClick:()=>{let e=p.find(e=>e.cid===E[0]);e&&st(e)},className:`btn btn-sm`,children:V(`app.rename`)}),(0,y.jsx)(`button`,{onClick:()=>Ge.open(),className:`btn btn-sm btn-move`,children:V(`app.move`)}),(0,y.jsx)(`button`,{onClick:at,className:`btn btn-sm btn-danger`,children:V(`app.delete`)}),E.length===1&&(()=>{let e=p.find(e=>e.cid===E[0]);return e&&e.localAvailable===!1})()&&(0,y.jsx)(`button`,{onClick:()=>{let e=p.find(e=>e.cid===E[0]);e&&vt(e)},className:`btn btn-sm`,children:V(`app.pullToLocal`)}),E.length===1&&(0,y.jsx)(`button`,{onClick:()=>A(p.find(e=>e.cid===E[0])),className:`btn btn-sm`,children:V(`app.share`)}),E.length===1&&(0,y.jsx)(`button`,{onClick:()=>{let e=p.find(e=>e.cid===E[0]);e&&_t(e)},className:`btn btn-sm`,children:V(`app.saveAs`)})]})]}),Ve&&(0,y.jsx)(d,{onClose:()=>F.close(),children:(0,y.jsxs)(`div`,{className:`transfer-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`modal-header`,children:[(0,y.jsx)(`h3`,{children:V(`app.transfers`)}),(0,y.jsx)(`button`,{onClick:()=>F.close(),className:`btn btn-icon`,children:(0,y.jsx)(i,{size:18})})]}),Be.length===0?(0,y.jsx)(`div`,{className:`empty-transfer`,children:V(`app.noTransfers`)}):Be.map(e=>(0,y.jsxs)(`div`,{className:`transfer-item`,children:[(0,y.jsxs)(`div`,{className:`transfer-item-header`,children:[e.type===`upload`?(0,y.jsx)(_e,{size:14}):(0,y.jsx)(ae,{size:14}),(0,y.jsx)(`span`,{className:`transfer-item-name`,translate:`no`,children:e.fileName}),e.status===`downloading`&&e.type===`download`&&(0,y.jsx)(`button`,{onClick:()=>gt(e),className:`transfer-item-cancel`,children:(0,y.jsx)(i,{size:14})})]}),(0,y.jsxs)(`div`,{className:`transfer-progress-row`,children:[(0,y.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":V(`app.transferProgress`,{fileName:e.fileName})}),(0,y.jsx)(`span`,{className:`transfer-progress-text`,children:e.status===`completed`?V(`app.completed`):e.status===`error`?V(`app.failed`):e.status===`cancelled`?V(`app.cancelled`):e.status===`cancelling`?V(`app.cancelling`):e.loaded&&e.total?`${ve(e.loaded)}/${ve(e.total)}`:`${e.progress}%`})]})]},e.id))]})})]})}var T=u(`/app/`)({component:Ne});export{T as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,d as i,f as a,rt as o,tt as s}from"./avatar-BZwHW4ll.js";import{a as c}from"./i18n-DZaOYCSO.js";import{t as l}from"./arrow-right-DUxAoZqb.js";import{a as u}from"./AccountMenu-NjOgag0d.js";import{t as d}from"./download-Q1uCiwif.js";import{t as f}from"./external-link-DGzNJOqQ.js";import{n as p,t as m}from"./notebook-pen-DgWzxf2y.js";import{t as h}from"./hard-drive-B2V5USzR.js";import{t as g}from"./message-square-C8ZiYztG.js";import{t as _}from"./wallet-VDaoXwjI.js";import{i as v}from"./index-DluhgSHX.js";import{t as y}from"./MarketingLayout-CyiSCygk.js";var b=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),x=r(`gamepad-2`,[[`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`,key:`1gktln`}],[`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`,key:`qnk9ow`}],[`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`,key:`krot7o`}],[`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`,key:`1lcuu1`}],[`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`,key:`mfqc10`}]]),S=t(e(),1),C=n(),w=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,C.jsx)(p,{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)(g,{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)(m,{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)(x,{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`}]}];function T(){let e=a(e=>e.hasBackend),t=a(e=>e.openConnectModal),[n,r]=(0,S.useState)(`app`),{t:s}=c(),p=i(),m=w.find(e=>e.id===n)||w[0],g=s(m.titleKey),_=m.steps.filter(e=>!(p&&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:s(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:s(`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:w.map(t=>{let i=n===t.id,a=t.requiresBackend,c=a?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=s(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${i?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(o,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:s(`portal.openFeature`,{title:l}),children:(0,C.jsx)(b,{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:s(t.subtitleKey)}),a?(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`}),s(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),s(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),s(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),s(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":s(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(v,{size:16}),s(`portal.webConnectNode`)]}),(0,C.jsxs)(o,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(h,{size:16}),s(`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:s(m.heroKey)}),(0,C.jsx)(`p`,{children:s(m.descKey)})]}),(0,C.jsx)(`div`,{className:`portal-marketing-features`,children:m.featureKeys.map(e=>(0,C.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,C.jsx)(`span`,{className:`portal-feature-icon`,children:(0,C.jsx)(u,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:s(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:s(e.titleKey)}),(0,C.jsx)(`p`,{children:s(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)(o,{to:e.link,children:[s(e.linkTextKey),` `,(0,C.jsx)(f,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(o,{to:m.path,className:`btn btn-primary`,children:[s(`portal.enterFeature`,{title:g}),(0,C.jsx)(l,{size:16})]}),m.requiresBackend&&e===!1&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(v,{size:16}),s(`portal.webConnectNode`)]}),!p&&(0,C.jsxs)(o,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(d,{size:16}),s(`nav.downloadClient`)]})]})]})]})})})]})}function E(){return(0,C.jsx)(y,{children:(0,C.jsx)(T,{})})}var D=s(`/`)({component:E});export{D as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,B as i,Q as ee,R as a,_ as o,a as s,c as te,f as c,i as l,n as u,p as ne,r as d,rt as f,t as p,tt as m,u as re}from"./avatar-BZwHW4ll.js";import{a as ie}from"./i18n-DZaOYCSO.js";import{a as ae,i as h}from"./AccountMenu-NjOgag0d.js";import{t as g}from"./circle-alert-DSZ0bG_3.js";import{t as _}from"./download-Q1uCiwif.js";import{t as v}from"./external-link-DGzNJOqQ.js";import{i as y,n as b,r as x}from"./mp-CGBtY36n.js";import{t as S}from"./key-round-Dn5tud-4.js";import{t as C}from"./loader-CLoDCtNy.js";import{t as w}from"./save-X5c7jlCg.js";import{t as T}from"./shield-check-DuD6OLde.js";import{t as oe}from"./upload-CsnBv3pd.js";import{n as se,s as E}from"./index-DluhgSHX.js";import{t as ce}from"./MarketingHeader-7B-OT2XX.js";import{t as D}from"./MarketingLayout-CyiSCygk.js";var le=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`}]]),O=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`}]]),ue=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`}]]),de=r(`wallet-cards`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2`,key:`4125el`}],[`path`,{d:`M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21`,key:`1dpki6`}]]),k=t(e(),1),A=n(),fe=[{value:``,labelKey:`profile.avatar.address`},...p.map(e=>({value:d(e),labelKey:`profile.avatar.${e}`}))];function j(e){if(l(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function M(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function N({status:e,busy:t}){return t||e===`working`?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):e===`synced`?(0,A.jsx)(E,{size:16}):e===`error`?(0,A.jsx)(g,{size:16}):(0,A.jsx)(T,{size:16})}function P(){let{formatNumber:e,t}=ie(),n=c(e=>e.addToast),r=c(e=>e.hasBackend),l=a(e=>e.identity),d=a(e=>e.openLoginModal),p=a(e=>e.setUserIdentity),m=a(e=>e.logoutUser),g=se(),[E,P]=(0,k.useState)(``),[L,R]=(0,k.useState)(``),[z,B]=(0,k.useState)(``),[V,H]=(0,k.useState)(!1),[U,W]=(0,k.useState)(null),G=(0,A.jsx)(ce,{});(0,k.useEffect)(()=>{if(!l){P(``),R(``),B(``);return}P(l.displayName||l.username),R(s(l.avatar)||l.avatar||``),B(``)},[l]),(0,k.useEffect)(()=>{l&&g.refreshBackupSummary()},[g.refreshBackupSummary,r,l]);let K=(0,k.useMemo)(()=>l?i(l.danger):null,[l]),pe=(0,k.useMemo)(()=>K?b(K.private_key,K.ed_public_key):``,[K]);if(!l)return(0,A.jsx)(D,{header:G,children:(0,A.jsx)(`section`,{className:`profile-page`,children:(0,A.jsx)(`div`,{className:`profile-container narrow`,children:(0,A.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,A.jsx)(`div`,{className:`profile-empty-icon`,children:(0,A.jsx)(h,{size:34})}),(0,A.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,A.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:d,children:[(0,A.jsx)(h,{size:16}),t(`account.signIn`)]})]})})})});let me=s(l.avatar)||l.avatar||``,he=u(l.address,l.avatar),q=l.address.toLowerCase(),ge=L.trim().length>0,_e=M(g.status),J=g.action===`backup`,Y=g.action===`restore`,X=g.action===`export`,Z=g.action===`import`,ve=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:g.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:g.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:g.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:g.backupSummary.channelsCount}];function ye(){W({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{W(null),await g.backupToCloud()}})}function be(){W({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{W(null),await g.restoreFromCloud({confirm:!1})}})}function xe(){return new Promise(e=>{let n=t=>{W(null),e(t)};W({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 Se(){g.importLocalBackup({requestConfirm:xe})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(J?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:J?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):(0,A.jsx)(O,{size:16}),onClick:ye},{key:`cloud-restore`,tone:`cloud-restore`,label:t(Y?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:Y?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):(0,A.jsx)(le,{size:16}),onClick:be},{key:`export-local`,tone:`export-local`,label:t(X?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:X?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):(0,A.jsx)(_,{size:16}),onClick:g.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(Z?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:Z?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):(0,A.jsx)(oe,{size:16}),onClick:Se}];async function Q(e){if(r===!0)try{await ne.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await o(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!l)return;let r={...l,avatar:e||void 0,profileUpdatedAt:Date.now()};p(r),Q(r),B(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!l)return;let e=E.trim()||l.username,r={...l,displayName:e,profileUpdatedAt:Date.now()};p(r),Q(r),P(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=L.trim();if(!e){$(void 0);return}if(!j(e)){B(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){m(),H(!1)}return(0,A.jsxs)(D,{header:G,children:[(0,A.jsx)(`section`,{className:`profile-page`,children:(0,A.jsxs)(`div`,{className:`profile-container`,children:[(0,A.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,A.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,A.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,A.jsxs)(`span`,{className:`profile-backup-status ${_e}`,children:[(0,A.jsx)(N,{status:g.status,busy:g.busy}),g.statusLabel]})]}),(0,A.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ve.map(t=>(0,A.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,A.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?g.backupSummary.loading?`...`:`-`:e(t.value)}),(0,A.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,A.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,A.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:g.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,A.jsxs)(`header`,{className:`profile-header`,children:[(0,A.jsx)(`img`,{className:`profile-avatar-large`,src:he,alt:``}),(0,A.jsxs)(`div`,{className:`profile-heading`,children:[(0,A.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,A.jsx)(`h1`,{children:l.displayName||l.username}),(0,A.jsxs)(`div`,{className:`profile-address-line`,children:[(0,A.jsx)(`code`,{translate:`no`,children:q}),(0,A.jsx)(x,{text:q}),(0,A.jsxs)(`a`,{href:`https://debank.com/profile/${l.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,A.jsx)(v,{size:14}),t(`web3.action.view`)]})]})]}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>H(!0),children:[(0,A.jsx)(ue,{size:16}),t(`account.logout`)]})]}),(0,A.jsxs)(`div`,{className:`profile-grid`,children:[(0,A.jsxs)(`section`,{className:`profile-panel`,children:[(0,A.jsx)(`div`,{className:`profile-panel-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,A.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,A.jsxs)(`label`,{className:`profile-field`,children:[(0,A.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,A.jsxs)(`div`,{className:`profile-field-row`,children:[(0,A.jsx)(`input`,{className:`input`,value:E,onChange:e=>P(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,A.jsx)(w,{size:16}),t(`profile.action.save`)]})]})]}),(0,A.jsx)(`div`,{className:`profile-facts`,children:(0,A.jsx)(F,{label:t(`profile.label.username`),value:l.username})})]}),(0,A.jsxs)(`section`,{className:`profile-panel`,children:[(0,A.jsx)(`div`,{className:`profile-panel-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,A.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,A.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:fe.map(e=>{let n=me===e.value;return(0,A.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,A.jsx)(`img`,{src:u(l.address,e.value),alt:``,"aria-hidden":`true`}),(0,A.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,A.jsx)(`span`,{className:`profile-avatar-check`,children:(0,A.jsx)(ae,{size:14})})]},e.value||`address`)})}),(0,A.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,A.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,A.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,A.jsxs)(`div`,{className:`profile-field-row`,children:[(0,A.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:L,onChange:e=>{R(e.target.value),B(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!ge,children:[(0,A.jsx)(w,{size:16}),t(`profile.action.save`)]})]})]}),z&&(0,A.jsx)(`p`,{className:`profile-error`,children:z})]})]})]}),(0,A.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,A.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,A.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,A.jsxs)(f,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,A.jsx)(de,{size:16}),t(`profile.action.openWallet`)]})]}),(0,A.jsxs)(`div`,{className:`profile-key-grid`,children:[K&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(I,{title:t(`web3.label.ed25519Public`),icon:(0,A.jsx)(y,{size:18}),value:K.ed_public_key}),(0,A.jsx)(I,{title:t(`web3.label.x25519Public`),icon:(0,A.jsx)(S,{size:18}),value:K.public_key})]}),(0,A.jsx)(I,{title:`IPNS ID`,icon:(0,A.jsx)(T,{size:18}),value:pe||`-`})]})]})]})}),U&&(0,A.jsx)(te,{title:U.title,message:U.message,confirmText:U.confirmText,danger:U.danger,onConfirm:U.onConfirm,onClose:U.onClose||(()=>W(null))}),V&&(0,A.jsx)(re,{className:`profile-logout-overlay`,onClose:()=>H(!1),children:(0,A.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`modal-header`,children:[(0,A.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,A.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>H(!1),"aria-label":t(`common.close`),children:(0,A.jsx)(ee,{size:18})})]}),(0,A.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,A.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:g.busy,onClick:()=>void g.backupToCloud(),children:[g.action===`backup`?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):(0,A.jsx)(O,{size:16}),t(`profile.backup.action.cloudBackup`)]}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:g.busy,onClick:()=>void g.exportLocalBackup(),children:[g.action===`export`?(0,A.jsx)(C,{size:16,className:`ui-spinner`}):(0,A.jsx)(_,{size:16}),t(`profile.backup.action.exportLocal`)]})]}),(0,A.jsxs)(`div`,{className:`modal-actions`,children:[(0,A.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>H(!1),children:t(`common.cancel`)}),(0,A.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function F({label:e,value:t,copy:n=!1}){return(0,A.jsxs)(`div`,{className:`profile-fact`,children:[(0,A.jsx)(`span`,{children:e}),(0,A.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,A.jsx)(`code`,{translate:`no`,children:t}),n&&(0,A.jsx)(x,{text:t})]})]})}function I({title:e,icon:t,value:n}){return(0,A.jsxs)(`div`,{className:`profile-key-card`,children:[(0,A.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,A.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,A.jsx)(`span`,{children:e})]}),(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,A.jsx)(x,{text:n})]})]})}var L=m(`/profile/`)({component:P});export{L as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,tt as i}from"./avatar-BZwHW4ll.js";import{a}from"./i18n-DZaOYCSO.js";import{n as o,t as s}from"./smartphone-gVFruyjO.js";import{t as c}from"./message-square-C8ZiYztG.js";import{t as l}from"./music-BsTA8b_M.js";import{t as u}from"./play-CVkbAJJU.js";import{t as d}from"./search-DAV9vDOq.js";import{t as f}from"./send-C5JjYo-A.js";import{t as p}from"./wifi-DfWbmlGE.js";import{t as m}from"./MarketingLayout-CyiSCygk.js";var h=r(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),g=r(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),_=r(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),v=r(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),y=r(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),b=r(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),x=r(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),ee=r(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),te=r(`triangle`,[[`path`,{d:`M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z`,key:`14u9p9`}]]),S=t(e(),1);function ne(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}var re=Object.freeze({left:0,top:0,width:16,height:16}),C=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),w=Object.freeze({...re,...C}),T=Object.freeze({...w,body:``,hidden:!1});function ie(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function E(e,t){let n=ie(e,t);for(let r in T)r in C?r in e&&!(r in n)&&(n[r]=C[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function ae(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=E(r[e]||i[e],a)}return o(t),n.forEach(o),E(e,a)}function oe(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=ne(e);for(let i in r){let a=r[i];a&&(t(i,ae(e,i,a)),n.push(i))}return n}var se={provider:``,aliases:{},not_found:{},...re};function D(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function O(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!D(e,se))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!D(t,T))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!D(t,T))return null}return t}var k=Object.create(null);function ce(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function A(e,t){let n=k[e]||(k[e]=Object.create(null));return n[t]||(n[t]=ce(e,t))}function le(e,t){return O(t)?oe(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function ue(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var de=/^[a-z0-9]+(-[a-z0-9]+)*$/,j=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!M(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!M(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!M(e,n)?null:e}return null},M=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1,N=!1;function P(e){return typeof e==`boolean`&&(N=e),N}function F(e){let t=typeof e==`string`?j(e,!0,N):e;if(t){let e=A(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function fe(e,t){let n=j(e,!0,N);if(!n)return!1;let r=A(n.provider,n.prefix);return t?ue(r,n.name,t):(r.missing.add(n.name),!0)}function pe(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),N&&!t&&!e.prefix){let t=!1;return O(e)&&(e.prefix=``,oe(e,(e,n)=>{fe(e,n)&&(t=!0)})),t}let n=e.prefix;return M({prefix:n,name:`a`})?!!le(A(t,n),e):!1}var I=Object.freeze({width:null,height:null}),L=Object.freeze({...I,...C}),me=/(-?[0-9.]*[0-9]+[0-9.]*)/g,he=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function R(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(me);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=he.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function ge(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function _e(e,t){return e?`<defs>`+e+`</defs>`+t:t}function ve(e,t,n){let r=ge(e);return _e(r.defs,t+r.content+n)}var ye=e=>e===`unset`||e===`undefined`||e===`none`;function be(e,t){let n={...w,...e},r={...L,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`);break}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=ve(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=R(d,c/l)):(u=o===`auto`?c:o,d=s===null?R(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{ye(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var xe=/\sid="(\S+)"/g,Se=`IconifyId`+Date.now().toString(16)+(Math.random()*16777216|0).toString(16),Ce=0;function we(e,t=Se){let n=[],r;for(;r=xe.exec(e);)n.push(r[1]);if(!n.length)return e;let i=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(n=>{let r=typeof t==`function`?t(n):t+(Ce++).toString(),a=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+a+`)([")]|\\.[a-z])`,`g`),`$1`+r+i+`$3`)}),e=e.replace(new RegExp(i,`g`),``),e}var z=Object.create(null);function Te(e,t){z[e]=t}function B(e){return z[e]||z[``]}function V(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}for(var H=Object.create(null),U=[`https://api.simplesvg.com`,`https://api.unisvg.com`],W=[];U.length>0;)U.length===1||Math.random()>.5?W.push(U.shift()):W.push(U.pop());H[``]=V({resources:[`https://api.iconify.design`].concat(W)});function Ee(e,t){let n=V(t);return n===null?!1:(H[e]=n,!0)}function G(e){return H[e]}var K=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function De(e,t){let n=G(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{e=Math.max(e,t.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function Oe(e){return e===404}var ke=(e,t,n)=>{let r=[],i=De(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function Ae(e){if(typeof e==`string`){let t=G(e);if(t)return t.path}return`/`}var je={prepare:ke,send:(e,t,n)=>{if(!K){n(`abort`,424);return}let r=Ae(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;K(e+r).then(e=>{let t=e.status;if(t!==200){setTimeout(()=>{n(Oe(t)?`abort`:`next`,t)});return}return i=501,e.json()}).then(e=>{if(typeof e!=`object`||!e){setTimeout(()=>{e===404?n(`abort`,e):n(`next`,i)});return}setTimeout(()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function q(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function Me(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||q([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var Ne=0;function Pe(e,t,n){let r=Ne++,i=q.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function Fe(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=A(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function Ie(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?j(e,t,n):e;i&&r.push(i)}),r}var Le={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Re(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function g(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function _(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:g,abort:h}}function v(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function y(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function b(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`){u=r,v();return}if(i){u=r,f.length||(o.length?x():v());return}if(m(),y(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}function x(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(y(),v())},e.timeout);return}v();return}let i={status:`pending`,resource:r,callback:(e,t)=>{b(i,e,t)}};f.push(i),l++,d=setTimeout(x,e.rotate),n(r,t,i.callback)}return setTimeout(x),_}function ze(e){let t={...Le,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=Re(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function Be(){}var J=Object.create(null);function Ve(e){if(!J[e]){let t=G(e);if(!t)return;J[e]={config:t,redundancy:ze(t)}}return J[e]}function He(e,t,n){let r,i;if(typeof e==`string`){let t=B(e);if(!t)return n(void 0,424),Be;i=t.send;let a=Ve(e);a&&(r=a.redundancy)}else{let t=V(e);if(t){r=ze(t);let n=B(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),Be):r.query(t,i,n)().abort}function Ue(){}function We(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Me(e)}))}function Ge(e){let t=[],n=[];return e.forEach(e=>{(e.match(de)?t:n).push(e)}),{valid:t,invalid:n}}function Y(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!le(e,n).length){r();return}}catch(e){console.error(e)}r(),We(e)}function Ke(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function qe(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){Ke(e.loadIcons(r,n,t),t=>{Y(e,r,t)});return}if(i){r.forEach(r=>{Ke(i(r,n,t),t=>{Y(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=Ge(r);if(o.length&&Y(e,o,null),!a.length)return;let s=n.match(de)?B(t):null;if(!s){Y(e,a,null);return}s.prepare(t,n,a).forEach(n=>{He(t,n,t=>{Y(e,n.icons,t)})})}))}var Je=(e,t)=>{let n=Fe(Ie(e,!0,P()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Ue)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(A(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=A(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&qe(e,t)}),t?Pe(t,n,i):Ue};function Ye(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in I?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var Xe=/[\s,]+/;function Ze(e,t){t.split(Xe).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0;break}})}function Qe(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}else if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function $e(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function et(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `)}function tt(e){return`data:image/svg+xml,`+et(e)}function nt(e){return`url("`+tt(e)+`")`}var X;function rt(){try{X=window.trustedTypes.createPolicy(`iconify`,{createHTML:e=>e})}catch{X=null}}function it(e){return X===void 0&&rt(),X?X.createHTML(e):e}var at={...L,inline:!1},ot={xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},st={display:`inline-block`},Z={backgroundColor:`currentColor`},ct={backgroundColor:`transparent`},lt={Image:`var(--svg)`,Repeat:`no-repeat`,Size:`100% 100%`},ut={WebkitMask:Z,mask:Z,background:ct};for(let e in ut){let t=ut[e];for(let n in lt)t[e+n]=lt[n]}var dt={...at,inline:!0};function ft(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}var pt=(e,t,n)=>{let r=t.inline?dt:at,i=Ye(r,t),a=t.mode||`svg`,o={},s=t.style||{},c={...a===`svg`?ot:{}};if(n){let e=j(n,!1,!0);if(e){let t=[`iconify`];for(let n of[`provider`,`prefix`])e[n]&&t.push(`iconify--`+e[n]);c.className=t.join(` `)}}for(let e in t){let n=t[e];if(n!==void 0)switch(e){case`icon`:case`style`:case`children`:case`onLoad`:case`mode`:case`ssr`:case`fallback`:break;case`_ref`:c.ref=n;break;case`className`:c[e]=(c[e]?c[e]+` `:``)+n;break;case`inline`:case`hFlip`:case`vFlip`:i[e]=n===!0||n===`true`||n===1;break;case`flip`:typeof n==`string`&&Ze(i,n);break;case`color`:o.color=n;break;case`rotate`:typeof n==`string`?i[e]=Qe(n):typeof n==`number`&&(i[e]=n);break;case`ariaHidden`:case`aria-hidden`:n!==!0&&n!==`true`&&delete c[`aria-hidden`];break;default:r[e]===void 0&&(c[e]=n)}}let l=be(e,i),u=l.attributes;if(i.inline&&(o.verticalAlign=`-0.125em`),a===`svg`){c.style={...o,...s},Object.assign(c,u);let e=0,n=t.id;return typeof n==`string`&&(n=n.replace(/-/g,`_`)),c.dangerouslySetInnerHTML={__html:it(we(l.body,n?()=>n+`ID`+ e++:`iconifyReact`))},(0,S.createElement)(`svg`,c)}let{body:d,width:f,height:p}=e,m=a===`mask`||(a===`bg`?!1:d.indexOf(`currentColor`)!==-1),h=$e(d,{...u,width:f+``,height:p+``});return c.style={...o,"--svg":nt(h),width:ft(u.width),height:ft(u.height),...st,...m?Z:ct,...s},(0,S.createElement)(`span`,c)};if(P(!0),Te(``,je),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!pe(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;Ee(e,r)||console.error(n)}catch{console.error(n)}}}}function mt(e){let[t,n]=(0,S.useState)(!!e.ssr),[r,i]=(0,S.useState)({});function a(t){if(t){let t=e.icon;if(typeof t==`object`)return{name:``,data:t};let n=F(t);if(n)return{name:t,data:n}}return{name:``}}let[o,s]=(0,S.useState)(a(!!e.ssr));function c(){let e=r.callback;e&&(e(),i({}))}function l(e){if(JSON.stringify(o)!==JSON.stringify(e))return c(),s(e),!0}function u(){var t;let n=e.icon;if(typeof n==`object`){l({name:``,data:n});return}let r=F(n);l({name:n,data:r})&&(r===void 0?i({callback:Je([n],u)}):r&&((t=e.onLoad)==null||t.call(e,n)))}(0,S.useEffect)(()=>(n(!0),c),[]),(0,S.useEffect)(()=>{t&&u()},[e.icon,t]);let{name:d,data:f}=o;return f?pt({...w,...f},e,d):e.children?e.children:e.fallback?e.fallback:(0,S.createElement)(`span`,{})}var ht=(0,S.forwardRef)((e,t)=>mt({...e,_ref:t}));(0,S.forwardRef)((e,t)=>mt({inline:!0,...e,_ref:t}));var Q=n(),$=[{name:`Google`,host:`google.com`,icon:`simple-icons:google`,fallback:(0,Q.jsx)(d,{size:20})},{name:`Cloudflare`,host:`cloudflare.com`,icon:`simple-icons:cloudflare`,fallback:(0,Q.jsx)(o,{size:20})},{name:`YouTube`,host:`youtube.com`,icon:`simple-icons:youtube`,fallback:(0,Q.jsx)(u,{size:20})},{name:`GitHub`,host:`github.com`,icon:`simple-icons:github`,fallback:(0,Q.jsx)(ee,{size:20})},{name:`ChatGPT`,host:`chatgpt.com`,icon:`simple-icons:openai`,fallback:(0,Q.jsx)(_,{size:20})},{name:`X`,host:`x.com`,icon:`simple-icons:x`,fallback:(0,Q.jsx)(h,{size:20})},{name:`Instagram`,host:`instagram.com`,icon:`simple-icons:instagram`,fallback:(0,Q.jsx)(v,{size:20})},{name:`Reddit`,host:`reddit.com`,icon:`simple-icons:reddit`,fallback:(0,Q.jsx)(c,{size:20})},{name:`Wikipedia`,host:`wikipedia.org`,icon:`simple-icons:wikipedia`,fallback:(0,Q.jsx)(g,{size:20})},{name:`Apple`,host:`apple.com`,icon:`simple-icons:apple`,fallback:(0,Q.jsx)(s,{size:20})},{name:`Telegram`,host:`telegram.org`,icon:`simple-icons:telegram`,fallback:(0,Q.jsx)(f,{size:20})},{name:`Discord`,host:`discord.com`,icon:`simple-icons:discord`,fallback:(0,Q.jsx)(y,{size:20})},{name:`TikTok`,host:`tiktok.com`,icon:`simple-icons:tiktok`,fallback:(0,Q.jsx)(l,{size:20})},{name:`npm`,host:`npmjs.com`,icon:`simple-icons:npm`,fallback:(0,Q.jsx)(b,{size:20})},{name:`Vercel`,host:`vercel.com`,icon:`simple-icons:vercel`,fallback:(0,Q.jsx)(te,{size:20})}],gt=5e3;function _t({icon:e,fallback:t}){let[n,r]=(0,S.useState)(!1);return(0,S.useEffect)(()=>{let t=new Image;t.onload=()=>r(!0),t.onerror=()=>r(!1),t.src=`https://api.iconify.design/${e.replace(`:`,`/`)}.svg`},[e]),(0,Q.jsxs)(`span`,{className:`brand-icon-wrap`,children:[(0,Q.jsx)(`span`,{className:`brand-icon-fallback ${n?`hidden`:``}`,children:t}),(0,Q.jsx)(`span`,{className:`brand-icon-real ${n?`visible`:``}`,children:(0,Q.jsx)(ht,{icon:e,width:20,height:20})})]})}function vt(){let{t:e,formatNumber:t}=a(),[n,r]=(0,S.useState)(new Map),[i,o]=(0,S.useState)(!1),s=(0,S.useRef)(new Map);(0,S.useEffect)(()=>{document.title=e(`ping.meta.title`)},[e]);let c=(0,S.useCallback)(e=>{r(t=>{let n=new Map(t);return n.set(e,{status:`pending`,latency:0}),n});let t=new AbortController;s.current.set(e,t);let n=performance.now(),i=(t,n)=>{r(r=>{let i=new Map(r);return i.set(e,{status:t,latency:n}),i})},a=setTimeout(()=>{t.abort()},gt);fetch(`https://${e}/`,{method:`HEAD`,mode:`no-cors`,cache:`no-store`,signal:t.signal}).then(()=>{clearTimeout(a),i(`ok`,Math.round(performance.now()-n))}).catch(()=>{clearTimeout(a),i(`timeout`,0)})},[]),l=(0,S.useCallback)(()=>{o(!0);let e=new Map;$.forEach(t=>{e.set(t.host,{status:`pending`,latency:0})}),r(e);let t=new Set($.map(e=>e.host));$.forEach(e=>{let n=new AbortController;s.current.set(e.host,n);let i=performance.now(),a=(n,i)=>{t.has(e.host)&&(t.delete(e.host),r(t=>{let r=new Map(t);return r.set(e.host,{status:n,latency:i}),r}),t.size===0&&o(!1))},c=setTimeout(()=>{n.abort()},gt);fetch(`https://${e.host}/`,{method:`HEAD`,mode:`no-cors`,cache:`no-store`,signal:n.signal}).then(()=>{clearTimeout(c),a(`ok`,Math.round(performance.now()-i))}).catch(()=>{clearTimeout(c),a(`timeout`,0)})})},[]);return(0,S.useEffect)(()=>(l(),()=>{s.current.forEach(e=>e.abort()),s.current.clear()}),[l]),(0,Q.jsxs)(`div`,{className:`ping-page`,children:[(0,Q.jsxs)(`div`,{className:`ping-header`,children:[(0,Q.jsxs)(`div`,{className:`ping-title-wrap`,children:[(0,Q.jsx)(p,{size:28,className:`ping-title-icon`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`ping-title`,children:e(`ping.title`)}),(0,Q.jsx)(`p`,{className:`ping-subtitle`,children:e(`ping.subtitle`)})]})]}),(0,Q.jsx)(`button`,{className:`btn btn-icon`,onClick:l,disabled:i,"aria-label":e(`ping.retryAll`),title:e(`ping.retryAll`),children:(0,Q.jsx)(x,{size:18,className:i?`ping-spin`:``})})]}),(0,Q.jsx)(`div`,{className:`ping-grid`,children:$.map(r=>{let i=n.get(r.host),a=!i||i.status===`pending`,o=i?.status===`timeout`;return(0,Q.jsxs)(`div`,{className:`ping-card ${a?`pending`:``}`,children:[(0,Q.jsxs)(`div`,{className:`ping-card-top`,children:[(0,Q.jsx)(`span`,{className:`ping-card-icon`,children:(0,Q.jsx)(_t,{icon:r.icon,fallback:r.fallback})}),(0,Q.jsx)(`a`,{href:`https://${r.host}`,target:`_blank`,rel:`noreferrer`,className:`ping-card-name`,children:r.name}),(0,Q.jsx)(`button`,{className:`ping-card-refresh`,onClick:()=>c(r.host),disabled:a,"aria-label":e(`ping.retryOne`,{name:r.name}),title:e(`ping.retry`),children:(0,Q.jsx)(x,{size:13,className:a?`ping-spin`:``})})]}),(0,Q.jsxs)(`div`,{className:`ping-card-bottom`,children:[a?(0,Q.jsx)(`span`,{className:`ping-pulse-dot`}):(0,Q.jsx)(`span`,{className:`ping-status-label ${o?`is-error`:`is-success`}`,children:e(o?`ping.unavailable`:`ping.available`)}),(0,Q.jsx)(`span`,{className:`ping-latency ${a?`is-muted`:o?`is-error`:`is-success`}`,children:a?`--`:o?e(`ping.timeout`):`${t(i.latency)} ms`})]})]},r.host)})})]})}function yt(){return(0,Q.jsx)(m,{children:(0,Q.jsx)(vt,{})})}var bt=i(`/ping/`)({component:yt});export{bt as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,D as i,O as a,R as o,f as s,n as c,tt as l}from"./avatar-BZwHW4ll.js";import{a as ee}from"./i18n-DZaOYCSO.js";import{t as te}from"./copy-CK7HMulu.js";import{n as ne}from"./SidebarHomeLink-CkhGDvZ8.js";import{t as u}from"./play-CVkbAJJU.js";import{t as re}from"./send-C5JjYo-A.js";import{i as ie,n as ae,r as oe,t as se}from"./useGameRoom-BxDxm3rp.js";var ce=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),d=t(e(),1),f=[`S`,`H`,`C`,`D`],p=[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`,`2`],m=p.filter(e=>e!==`2`),h=new Map(p.map((e,t)=>[e,t+3])),g=5,_=20,v=1e3;function le({roomCode:e,ownerAddress:t,ownerName:n,players:r=[],random:o=Math.random}){let s=E(r);return s.some(e=>e.address===i(t))||s.unshift({address:i(t),name:q(n),avatar:``}),y({id:String(e||``).toUpperCase(),ownerAddress:i(t),status:`lobby`,seq:1,players:s.slice(0,6).map((e,t)=>({address:e.address,name:q(e.name),avatar:a(e.avatar),seat:t,hand:[],handCount:0,score:v,playedCards:0})),deck:[],discard:[],table:null,currentSeat:0,lastWinnerSeat:null,previousWinnerSeat:null,passSeats:[],baseScore:1,bombCount:0,diceRolls:[],roundResult:null,log:[`房间已创建`],winnerSeat:null,random:o})}function ue(e,t=[]){let n=b(e);if(!n||n.status!==`lobby`)return n;let r=new Map(n.players.map(e=>[e.address,e.score]));return n.players=E(t).slice(0,6).map((e,t)=>({address:e.address,name:q(e.name),avatar:a(e.avatar),seat:t,hand:[],handCount:0,score:r.get(e.address)??v,playedCards:0})),n.seq+=1,y(n)}function de(e,t=Math.random){let n=b(e);if(!n||n.players.length<2)throw Error(`至少需要 2 名玩家`);n.deck=N(M(),t),n.discard=[],n.table=null,n.passSeats=[],n.winnerSeat=null,n.roundResult=null,n.baseScore=1,n.bombCount=0,n.status=`playing`;for(let e of R(n))e.hand=P(n,g),e.handCount=e.hand.length,e.playedCards=0,F(e.hand);let r=k(n,t);return n.currentSeat=r.seat,n.lastWinnerSeat=null,n.log=[`新一局开始,${r.name} 先出牌`],n.diceRolls.length>0&&n.log.unshift(`骰子结果:${n.diceRolls.map(e=>`${e.name} ${e.value}`).join(`,`)}`),n.seq+=1,y(n)}function fe(e,t,n){let r=b(e),a=I(r),o=i(t);if(!a||a.address!==o)return{ok:!1,error:`还没轮到你`,state:y(r)};let s=n.map(e=>a.hand.find(t=>t.id===e));if(s.length===0||s.some(e=>!e))return{ok:!1,error:`手牌不存在`,state:y(r)};let c=he(s);return c?T(c,r.table?.combo)?(s.sort(H),a.hand=a.hand.filter(e=>!n.includes(e.id)),a.handCount=a.hand.length,a.playedCards+=s.length,r.discard.push(...s),r.table={seat:a.seat,playerName:a.name,cards:s,combo:c},r.passSeats=[],r.lastWinnerSeat=a.seat,c.type===`bomb`&&(r.bombCount+=1,r.baseScore*=2),r.log.unshift(`${a.name} 出 ${c.label} ${s.map(K).join(` `)}${c.type===`bomb`?`,底分 ${r.baseScore}`:``}`),a.hand.length===0?A(r,a):z(r),r.seq+=1,{ok:!0,state:y(r)}):{ok:!1,error:`出的牌压不过上一手`,state:y(r)}:{ok:!1,error:`这个牌型不合法`,state:y(r)}}function pe(e,t){let n=b(e),r=I(n),a=i(t);return!r||r.address!==a?{ok:!1,error:`还没轮到你`,state:y(n)}:n.table?(n.passSeats.includes(r.seat)||n.passSeats.push(r.seat),n.log.unshift(`${r.name} 不要`),L(n).map(e=>e.seat).filter(e=>e!==n.lastWinnerSeat).every(e=>n.passSeats.includes(e))?(j(n),n.currentSeat=n.lastWinnerSeat,n.table=null,n.passSeats=[],n.log.unshift(`本轮结束,所有玩家各补 1 张,重新领出`)):z(n),n.seq+=1,{ok:!0,state:y(n)}):{ok:!1,error:`领出时不能不要`,state:y(n)}}function me(e,t){let n=b(e);if(!n)return null;let r=i(t),a=n.players.findIndex(e=>e.address===r);if(a===-1)return y(n);let o=n.players[a],s=n.currentSeat===o.seat,c=n.lastWinnerSeat===o.seat;n.players.splice(a,1),n.passSeats=n.passSeats.filter(e=>e!==o.seat),n.log.unshift(`${o.name} 已退出房间`);let l=R(n);if(n.status===`playing`)if(l.length<=1)l.length===1?A(n,l[0]):(n.status=`finished`,n.log.unshift(`玩家不足,本局结束`));else{if(s){let e=L(n);if(e.length>0){let t=e.findIndex(e=>e.seat>o.seat);n.currentSeat=e[t>=0?t:0].seat}}c&&n.table&&(n.table=null,n.passSeats=[])}return n.seq+=1,y(n)}function y(e){return e?{id:e.id,ownerAddress:e.ownerAddress,status:e.status,seq:Number(e.seq||1),deck:Array.isArray(e.deck)?e.deck.map(G):[],deckCount:e.deck?.length||Number(e.deckCount||0),discard:Array.isArray(e.discard)?e.discard.map(G):[],discardCount:e.discard?.length||Number(e.discardCount||0),currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,table:e.table?{...e.table,cards:e.table.cards.map(G)}:null,passSeats:Array.isArray(e.passSeats)?e.passSeats:[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat),log:Array.isArray(e.log)?e.log.slice(0,18):[],players:R(e).map(e=>({address:e.address,name:e.name,avatar:a(e.avatar),seat:e.seat,handCount:e.hand?.length??e.handCount??0,score:Number(e.score??v),playedCards:Number(e.playedCards||0),hand:Array.isArray(e.hand)?e.hand.map(G):[]}))}:null}function b(e){return!e||typeof e!=`object`?null:{id:String(e.id||``).toUpperCase(),ownerAddress:i(e.ownerAddress),status:e.status===`playing`||e.status===`finished`?e.status:`lobby`,seq:Number(e.seq||1),players:Array.isArray(e.players)?e.players.map(D).filter(Boolean):[],deck:Array.isArray(e.deck)?e.deck.map(_e).filter(Boolean):[],discard:Array.isArray(e.discard)?e.discard.map(O).filter(Boolean):[],table:e.table&&typeof e.table==`object`?{...e.table,cards:Array.isArray(e.table.cards)?e.table.cards.map(O).filter(Boolean):[]}:null,currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),passSeats:Array.isArray(e.passSeats)?e.passSeats.map(Number):[],baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,log:Array.isArray(e.log)?e.log.map(String):[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat)}}function he(e){if(!e?.length)return null;e=[...e].sort(H);let t=e.filter(W).length,n=e.filter(e=>!W(e));if(n.length===0)return null;let r=x(e,n,t);if(r)return r;if(e.length===1&&t===0)return w(`single`,U(e[0]),1,[U(e[0])]);if(e.length===2&&B(n,t)){let e=V(n);return w(`pair`,e,2,[e,e])}return S(e)||C(e)}function x(e,t,n){if(e.length<3||!B(t,n))return null;let r=V(t);return w(`bomb`,r,e.length,Array(e.length).fill(r),n===0)}function S(e){if(e.length<3)return null;let t=e.filter(W).length,n=e.filter(e=>!W(e));for(let r=0;r<=m.length-e.length;r+=1){let i=m.slice(r,r+e.length).map(e=>h.get(e)),a=[...i],o=0;for(let e of n){let t=a.indexOf(U(e));t!==-1&&(a.splice(t,1),o+=1)}if(o+t===e.length&&a.length===t)return w(`straight`,i.at(-1),e.length,i)}return null}function C(e){if(e.length<4||e.length%2!=0)return null;let t=e.length/2,n=e.filter(W).length,r=e.filter(e=>!W(e));for(let i=0;i<=m.length-t;i+=1){let a=m.slice(i,i+t).map(e=>h.get(e)),o=a.flatMap(e=>[e,e]),s=0;for(let e of r){let t=o.indexOf(U(e));t!==-1&&(o.splice(t,1),s+=1)}if(s+n===e.length&&o.length===n){let t=a.flatMap(e=>[e,e]);return w(`pairStraight`,a.at(-1),e.length,t)}}return null}function w(e,t,n,r,i=!0){return{type:e,value:t,length:n,resolvedValues:r,pure:i,label:be({type:e,value:t,length:n,resolvedValues:r,pure:i})}}function T(e,t){return e?!t||e.type===`bomb`&&t.type!==`bomb`?!0:e.type===t.type?e.type===`bomb`?e.length===t.length?e.value===t.value?e.pure&&!t.pure:e.value>t.value:e.length>t.length:e.length===t.length?e.type===`single`||e.type===`pair`?e.value===Se(t.value)||e.value===h.get(`2`)&&t.value!==h.get(`2`):e.value===Se(t.value):!1:!1:!1}function E(e){let t=new Set;return e.map(e=>({address:i(e.address),name:q(e.name),avatar:a(e.avatar),publicKey:String(e.publicKey||``)})).filter(e=>!e.address||t.has(e.address)?!1:(t.add(e.address),!0))}function D(e){let t=i(e.address);return t?{address:t,name:q(e.name),avatar:a(e.avatar),seat:Number(e.seat||0),hand:Array.isArray(e.hand)?e.hand.map(O).filter(Boolean):[],handCount:Number(e.handCount||0),score:Number(e.score??v),playedCards:Number(e.playedCards||0)}:null}function O(e){if(!e||typeof e!=`object`)return null;let t=String(e.rank||``),n=String(e.suit||``);return!h.has(t)&&t!==`SJ`&&t!==`BJ`||!f.includes(n)&&n!==`Joker`?null:{id:String(e.id||`${n}-${t}`),suit:n,rank:t,label:e.label||K({suit:n,rank:t}),color:e.color||ye({suit:n,rank:t})}}function k(e,t){if(e.previousWinnerSeat!==null)return e.diceRolls=[],R(e).find(t=>t.seat===e.previousWinnerSeat)||R(e)[0];let n=R(e),r=[];for(;n.length>1;){r=n.map(e=>({seat:e.seat,name:e.name,value:Ce(t)}));let i=Math.max(...r.map(e=>e.value)),a=r.filter(e=>e.value===i);if(a.length===1)return e.diceRolls=r,n.find(e=>e.seat===a[0].seat);n=n.filter(e=>a.some(t=>t.seat===e.seat))}return e.diceRolls=r,n[0]}function A(e,t){e.status=`finished`,e.winnerSeat=t.seat,e.previousWinnerSeat=t.seat;let n=[],r=0;for(let i of R(e)){if(i.seat===t.seat)continue;let a=i.playedCards===0,o=a?_:i.hand.length*e.baseScore*.5;i.score-=o,r+=o,n.push({seat:i.seat,name:i.name,loss:o,sealed:a,cardsLeft:i.hand.length})}t.score+=r,e.roundResult={winnerSeat:t.seat,winnerName:t.name,winnerGain:r,baseScore:e.baseScore,bombCount:e.bombCount,losers:n},e.log.unshift(`${t.name} 获胜,赢 ${r} 分`)}function j(e){for(let t of L(e)){if(e.deck.length===0)break;t.hand.push(...P(e,1)),t.handCount=t.hand.length,F(t.hand)}}function M(){let e=[];for(let t of f)for(let n of p)e.push({id:`${t}-${n}`,suit:t,rank:n});return e.push({id:`SJ`,suit:`Joker`,rank:`SJ`}),e.push({id:`BJ`,suit:`Joker`,rank:`BJ`}),e.map(G)}function N(e,t){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function P(e,t){return e.deck.splice(0,t)}function F(e){e.sort(H)}function I(e){return e.players.find(t=>t.seat===e.currentSeat)}function L(e){return R(e).filter(e=>e.hand.length>0)}function R(e){return[...e?.players||[]].sort((e,t)=>e.seat-t.seat)}function z(e){let t=L(e).map(e=>e.seat);e.currentSeat=t[(t.indexOf(e.currentSeat)+1)%t.length]}function B(e,t=0){if(e.length===0)return!1;let n=e[0].rank;return e.every(e=>e.rank===n)&&e.length+t>=2}function V(e){return U(e[0])}function H(e,t){return U(e)-U(t)||ge(e.suit)-ge(t.suit)}function U(e){return h.get(e.rank)||99}function W(e){return e.rank===`SJ`||e.rank===`BJ`}function ge(e){return{D:0,C:1,H:2,S:3,Joker:4}[e]||0}function _e(e){if(typeof e==`string`){let[t,n]=e.split(`-`);return O({id:e,suit:t,rank:n})}return O(e)}function G(e){return{id:e.id,suit:e.suit,rank:e.rank,label:K(e),color:ye(e)}}function K(e){return e.rank===`SJ`?`小王`:e.rank===`BJ`?`大王`:`${ve(e.suit)}${e.rank}`}function ve(e){return{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[e]||``}function ye(e){return e.suit===`H`||e.suit===`D`||e.rank===`BJ`?`red`:`black`}function be(e){let t=e.resolvedValues?.length?`(${e.resolvedValues.map(xe).join(` `)})`:``;return`${{single:`单张`,pair:`对子`,straight:`顺子`,pairStraight:`连对`,bomb:e.pure?`纯炸弹`:`带王炸弹`}[e.type]}${t}`}function xe(e){return p.find(t=>h.get(t)===e)||String(e)}function Se(e){let t=p.findIndex(t=>h.get(t)===e);return t===-1||t>=p.length-1?null:h.get(p[t+1])}function Ce(e){return Math.floor(e()*6)+1}function q(e){return String(e||`玩家`).trim().slice(0,16)||`玩家`}var J={page:`_page_1c8jk_1`,headerActions:`_headerActions_1c8jk_7`,entry:`_entry_1c8jk_13`,entryBrand:`_entryBrand_1c8jk_23`,cardMark:`_cardMark_1c8jk_29`,entryPanel:`_entryPanel_1c8jk_59`,panel:`_panel_1c8jk_60`,handPanel:`_handPanel_1c8jk_61`,accountLine:`_accountLine_1c8jk_74`,scoreMeta:`_scoreMeta_1c8jk_75`,roomBar:`_roomBar_1c8jk_76`,badges:`_badges_1c8jk_77`,actions:`_actions_1c8jk_78`,joinForm:`_joinForm_1c8jk_98`,status:`_status_1c8jk_119`,gameGrid:`_gameGrid_1c8jk_125`,tablePanel:`_tablePanel_1c8jk_136`,seats:`_seats_1c8jk_170`,player:`_player_1c8jk_176`,active:`_active_1c8jk_193`,winner:`_winner_1c8jk_197`,avatar:`_avatar_1c8jk_201`,avatarOffline:`_avatarOffline_1c8jk_222`,onlineDot:`_onlineDot_1c8jk_227`,centerTable:`_centerTable_1c8jk_253`,deckBox:`_deckBox_1c8jk_260`,playedBox:`_playedBox_1c8jk_261`,playedCards:`_playedCards_1c8jk_289`,notice:`_notice_1c8jk_297`,resultDetail:`_resultDetail_1c8jk_305`,sidePanel:`_sidePanel_1c8jk_316`,scoreRow:`_scoreRow_1c8jk_341`,logPanel:`_logPanel_1c8jk_349`,hand:`_hand_1c8jk_61`,cardButton:`_cardButton_1c8jk_376`,picked:`_picked_1c8jk_386`,card:`_card_1c8jk_29`,red:`_red_1c8jk_417`,black:`_black_1c8jk_421`,small:`_small_1c8jk_425`,preview:`_preview_1c8jk_443`,valid:`_valid_1c8jk_466`},Y=n(),X=`gandengyan`;function Z(...e){return e.filter(Boolean).join(` `)}function we(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function Te(e,t){if(typeof window>`u`||!(`speechSynthesis`in window)||!e)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1.1,window.speechSynthesis.speak(n)}function Ee(){let{t:e,locale:t}=ee(),n=s(e=>e.addToast),r=o(e=>e.initializeUser),[i,a]=(0,d.useState)(``),[c,l]=(0,d.useState)([]),[f,p]=(0,d.useState)(!1),m=(0,d.useRef)(``),h=(0,d.useRef)(!1),g=se({gameId:X,onError:e=>n(e,`error`)});(0,d.useEffect)(()=>{r()},[r]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(a(e),m.current=e)},[]),(0,d.useEffect)(()=>{let t=m.current;!t||h.current||!g.isBackendReady||!g.userIdentity||(h.current=!0,m.current=``,g.joinRoom(t).then(t=>{t&&n(e(`game.toast.joinedRoom`),`success`)}))},[g.isBackendReady,g.userIdentity,g.joinRoom,n,e]),(0,d.useEffect)(()=>{if(!g.roomCode)return;let e=`/game/gandengyan?room=${g.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[g.roomCode]);let _=(0,d.useMemo)(()=>ae(g.messages,g.roomCode?{gameId:X,roomCode:g.roomCode}:{gameId:X}),[g.messages,g.roomCode]),v=(0,d.useMemo)(()=>oe(g.messages,{gameId:X,roomCode:g.roomCode}),[g.messages,g.roomCode]),y=v?.payload?.state,b=y?.players.find(e=>we(e.address,g.userIdentity?.address)),x=we(y?.ownerAddress||_.hostAddress,g.userIdentity?.address),S=y?.status===`playing`&&y.currentSeat===b?.seat,C=(0,d.useMemo)(()=>c.map(e=>b?.hand.find(t=>t.id===e)).filter(Boolean),[c,b]),w=(0,d.useMemo)(()=>he(C),[C]),T=g.roomCode&&typeof window<`u`?`${window.location.origin}/game/gandengyan?room=${g.roomCode}`:``,E=(0,d.useRef)(-1),D=(0,d.useRef)(!1);(0,d.useEffect)(()=>{l([])},[y?.seq]),(0,d.useEffect)(()=>{if(!y)return;let n=y.seq;if(E.current<0){E.current=n;return}if(n!==E.current&&(E.current=n,y.status!==`finished`&&(D.current=!1),y.status===`finished`&&y.winnerSeat!==null)){D.current||(D.current=!0,Te(e(`game.gandengyan.speech.gameOver`),t));return}},[t,y?.seq,e]),(0,d.useEffect)(()=>{if(!x||!g.roomCode||!g.userIdentity||v||_.players.length===0)return;let e=le({roomCode:g.roomCode,ownerAddress:g.userIdentity.address,ownerName:g.userIdentity.displayName||g.userIdentity.username,players:_.players});g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[g,x,v,_.players]),(0,d.useEffect)(()=>{if(!y||!x||y.status!==`lobby`)return;let e=ue(y,_.players);e&&Oe(y.players,e.players)&&g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[g,x,_.players,y]);let O=(0,d.useRef)(0),k=(0,d.useMemo)(()=>g.roomEvents.filter(e=>e.event?.event===`player:leave`),[g.roomEvents]);(0,d.useEffect)(()=>{if(k.length<=O.current)return;let t=k.slice(O.current);O.current=k.length;for(let r of t)n(e(`game.toast.playerLeft`,{player:r.event?.payload?.player?.name||e(`game.player`)}),`info`)},[k,n,e]),(0,d.useEffect)(()=>{if(!y||!x||y.status!==`playing`)return;let e=new Set(_.players.map(e=>e.address.toLowerCase())),t=y.players.find(t=>!e.has(t.address.toLowerCase()));if(!t)return;let n=me(y,t.address);n&&N(n)},[g,x,_.players,y]);async function A(){await g.createRoom()&&n(e(`game.toast.roomCreated`),`success`)}async function j(t){t.preventDefault(),await g.joinRoom(i)&&n(e(`game.toast.joinedRoom`),`success`)}async function M(){T&&(await navigator.clipboard.writeText(T),p(!0),setTimeout(()=>p(!1),1400))}async function N(e){await g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})}async function P(){if(!(!y||!x))try{await N(de(y))}catch(t){n(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function F(){await P()}async function I(){if(!y||!g.userIdentity)return;let t=fe(y,g.userIdentity.address,c);if(!t.ok){n(t.error||e(`game.gandengyan.error.playFailed`),`error`);return}await N(t.state)}async function L(){if(!y||!g.userIdentity)return;let t=pe(y,g.userIdentity.address);if(!t.ok){n(t.error||e(`game.gandengyan.error.actionFailed`),`error`);return}await N(t.state)}function R(e){l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,Y.jsx)(ne,{sidebar:({closeSidebar:e})=>(0,Y.jsx)(ie,{activeGame:`gandengyan`,closeSidebar:e}),headerTitle:(0,Y.jsx)(`h2`,{className:`header-title`,children:e(`game.gandengyan.title`)}),headerRight:(0,Y.jsx)(`div`,{className:J.headerActions,children:y&&(0,Y.jsxs)(`button`,{className:`btn btn-sm`,onClick:M,children:[(0,Y.jsx)(te,{size:14}),e(f?`common.copied`:`game.action.shareRoom`)]})}),children:(0,Y.jsx)(`main`,{className:J.page,children:y?(0,Y.jsxs)(`section`,{className:J.gameGrid,children:[(0,Y.jsxs)(`div`,{className:J.tablePanel,children:[(0,Y.jsxs)(`div`,{className:J.roomBar,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{translate:`no`,children:e(`game.roomLabel`,{room:y.id})}),(0,Y.jsx)(`span`,{children:y.status===`lobby`?e(`game.status.waitingStart`):y.status===`finished`?e(`game.status.finished`):e(`game.status.playing`)})]}),(0,Y.jsx)(`div`,{className:J.badges,children:(0,Y.jsx)(`span`,{children:g.connected?e(`game.status.online`):e(`game.status.offline`)})})]}),(0,Y.jsx)(`div`,{className:J.seats,children:y.players.map(t=>(0,Y.jsx)(De,{player:t,active:y.currentSeat===t.seat,winner:y.winnerSeat===t.seat,relation:Me(b,t,y.players.length,e),presenceByAddress:g.presenceByAddress,onlineAddresses:g.onlineAddresses},t.seat))}),(0,Y.jsxs)(`div`,{className:J.centerTable,children:[(0,Y.jsxs)(`div`,{className:J.deckBox,children:[(0,Y.jsx)(`span`,{children:e(`game.gandengyan.deck`)}),(0,Y.jsx)(`strong`,{children:y.deckCount})]}),(0,Y.jsx)(`div`,{className:J.playedBox,children:y.table?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`strong`,{children:e(`game.gandengyan.tablePlay`,{player:$(y.players.find(e=>e.seat===y.table?.seat),g.presenceByAddress)||y.table.playerName,combo:y.table.combo?.label||e(`game.card`)})}),(0,Y.jsx)(`div`,{className:J.playedCards,children:y.table.cards.map(e=>(0,Y.jsx)(je,{card:e,small:!0},e.id))})]}):(0,Y.jsx)(`span`,{children:e(`game.gandengyan.waitingLead`)})}),(0,Y.jsxs)(`div`,{className:J.deckBox,children:[(0,Y.jsx)(`span`,{children:e(`game.gandengyan.baseScore`)}),(0,Y.jsx)(`strong`,{children:y.baseScore})]})]}),(0,Y.jsx)(`div`,{className:J.notice,children:y.status===`finished`?y.roundResult?(0,Y.jsxs)(`div`,{className:J.resultDetail,children:[(0,Y.jsxs)(`p`,{children:[e(`game.gandengyan.result.winnerGain`,{player:y.roundResult.winnerName,score:y.roundResult.winnerGain}),y.roundResult.bombCount>0&&e(`game.gandengyan.result.bombCount`,{count:y.roundResult.bombCount})]}),y.roundResult.losers.map(t=>(0,Y.jsx)(`p`,{children:t.sealed?e(`game.gandengyan.result.sealedLoss`,{player:t.name,loss:20}):e(`game.gandengyan.result.cardsLeftLoss`,{player:t.name,cards:t.cardsLeft,loss:t.loss})},t.seat))]}):e(`game.gandengyan.result.winner`,{player:$(y.players.find(e=>e.seat===y.winnerSeat),g.presenceByAddress)||e(`game.player`)}):S?e(`game.gandengyan.status.yourTurn`):e(`game.zhajinhua.status.waitingPlayer`,{player:$(y.players.find(e=>e.seat===y.currentSeat),g.presenceByAddress)||e(`game.player`)})})]}),(0,Y.jsxs)(`aside`,{className:J.sidePanel,children:[(0,Y.jsxs)(`section`,{className:J.panel,children:[(0,Y.jsx)(`h3`,{children:e(`game.gandengyan.roundPanel`)}),x&&y.status===`lobby`&&(0,Y.jsxs)(`button`,{className:`btn btn-primary`,disabled:y.players.length<2,onClick:P,children:[(0,Y.jsx)(u,{size:16}),e(`game.action.startRound`)]}),x&&y.status===`finished`&&(0,Y.jsxs)(`button`,{className:`btn btn-primary`,onClick:F,children:[(0,Y.jsx)(ce,{size:16}),e(`game.action.nextRound`)]}),!x&&(0,Y.jsx)(`p`,{className:J.status,children:e(`game.waitingHost`)})]}),(0,Y.jsxs)(`section`,{className:J.panel,children:[(0,Y.jsx)(`h3`,{children:e(`game.gandengyan.score`)}),(0,Y.jsxs)(`div`,{className:J.scoreMeta,children:[(0,Y.jsx)(`span`,{children:e(`game.gandengyan.bombCount`,{count:y.bombCount})}),(0,Y.jsx)(`span`,{children:e(`game.gandengyan.discardCount`,{count:y.discardCount})})]}),y.players.map(e=>(0,Y.jsxs)(`div`,{className:J.scoreRow,children:[(0,Y.jsx)(`span`,{translate:`no`,children:$(e,g.presenceByAddress)}),(0,Y.jsx)(`strong`,{children:e.score})]},e.seat))]}),(0,Y.jsxs)(`section`,{className:Z(J.panel,J.logPanel),children:[(0,Y.jsx)(`h3`,{children:e(`game.gandengyan.log`)}),y.log.map((e,t)=>(0,Y.jsx)(`p`,{translate:`no`,children:e},`${e}-${t}`))]})]}),(0,Y.jsxs)(`div`,{className:J.handPanel,children:[(0,Y.jsx)(De,{player:b,active:S,winner:y.winnerSeat===b?.seat,presenceByAddress:g.presenceByAddress,onlineAddresses:g.onlineAddresses}),(0,Y.jsx)(`div`,{className:J.hand,children:b?.hand.map(e=>(0,Y.jsx)(`button`,{className:Z(J.cardButton,c.includes(e.id)&&J.picked),onClick:()=>R(e.id),children:(0,Y.jsx)(je,{card:e})},e.id))}),(0,Y.jsxs)(`div`,{className:J.actions,children:[(0,Y.jsxs)(`div`,{className:Z(J.preview,w&&J.valid),children:[(0,Y.jsx)(`strong`,{children:w?w.label:c.length?e(`game.gandengyan.invalidCombo`):e(`game.gandengyan.selectCards`)}),(0,Y.jsx)(`span`,{children:C.map(e=>e.label).join(` `)||e(`game.gandengyan.jokerOrderHint`)})]}),(0,Y.jsxs)(`button`,{className:`btn btn-primary`,disabled:!S||c.length===0||!w,onClick:I,children:[(0,Y.jsx)(re,{size:16}),e(`game.gandengyan.action.play`)]}),(0,Y.jsx)(`button`,{className:`btn`,disabled:!S||!y.table,onClick:L,children:e(`game.gandengyan.action.pass`)})]})]})]}):(0,Y.jsxs)(`section`,{className:J.entry,children:[(0,Y.jsxs)(`div`,{className:J.entryBrand,children:[(0,Y.jsx)(`div`,{className:J.cardMark,children:e(`game.gandengyan.mark`)}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{children:e(`game.gandengyan.hero.title`)}),(0,Y.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,Y.jsxs)(`div`,{className:J.entryPanel,children:[(0,Y.jsxs)(`div`,{className:J.accountLine,children:[(0,Y.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,Y.jsx)(`strong`,{translate:`no`,children:g.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,Y.jsxs)(`button`,{className:`btn btn-primary`,disabled:g.joining,onClick:A,children:[(0,Y.jsx)(u,{size:16}),e(`game.action.createRoom`)]}),(0,Y.jsxs)(`form`,{onSubmit:j,className:J.joinForm,children:[(0,Y.jsxs)(`label`,{children:[e(`game.roomCode`),(0,Y.jsx)(`input`,{value:i,maxLength:8,onChange:e=>a(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,Y.jsx)(`button`,{className:`btn`,disabled:g.joining||!i,children:e(`game.action.joinRoom`)})]}),(0,Y.jsx)(`p`,{className:J.status,children:g.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function De({player:e,active:t,winner:n,relation:r=``,presenceByAddress:i,onlineAddresses:a}){let{t:o}=ee();if(!e)return null;let s=Ae(e,i,a);return(0,Y.jsxs)(`div`,{className:Z(J.player,t&&J.active,n&&J.winner),children:[(0,Y.jsxs)(`div`,{className:Z(J.avatar,!s.online&&J.avatarOffline),translate:`no`,children:[(0,Y.jsx)(`img`,{src:c(e.address,s.avatar),alt:``}),s.online&&(0,Y.jsx)(`span`,{className:J.onlineDot})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{translate:`no`,children:s.name}),(0,Y.jsxs)(`span`,{children:[r,r?` · `:``,o(`game.gandengyan.handCount`,{count:e.handCount})]})]})]})}function Oe(e,t){return e.length===t.length?t.some((t,n)=>{let r=e[n];return Q(r?.address)!==Q(t.address)||r?.name!==t.name||(r?.avatar||``)!==(t.avatar||``)}):!0}function Q(e=``){return String(e||``).trim().toLowerCase()}function ke(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function $(e,t){if(!e)return``;let n=Q(e.address),r=t.get(n)?.displayName||e.name;return String(r||ke(e.address)).trim()}function Ae(e,t,n){let r=Q(e.address),i=t.get(r);return{name:$(e,t),avatar:i?.avatar||e.avatar||``,online:r?n.has(r):!1}}function je({card:e,small:t=!1}){return(0,Y.jsxs)(`div`,{className:Z(J.card,J[e.color],t&&J.small),children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`i`,{children:e.suit===`Joker`?`*`:e.label.slice(0,1)})]})}function Me(e,t,n,r){if(!e)return r(`game.gandengyan.position.seat`,{seat:t.seat+1});let i=(t.seat-e.seat+n)%n;return i===0?r(`game.gandengyan.position.me`):n===2?r(`game.gandengyan.position.opponent`):n===3?r(i===1?`game.gandengyan.position.nextOpponent`:`game.gandengyan.position.prevOpponent`):n===4?r(i===1?`game.gandengyan.position.nextOpponent`:i===2?`game.gandengyan.position.partner`:`game.gandengyan.position.prevOpponent`):i%2==0?r(`game.gandengyan.position.seatPartner`,{seat:t.seat+1}):r(`game.gandengyan.position.seatOpponent`,{seat:t.seat+1})}var Ne=l(`/game/gandengyan/`)({component:Ee});export{Ne as Route};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-WedhCoFH.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-DluhgSHX.js","assets/avatar-BZwHW4ll.js","assets/useNavigate-DWlBD_-b.js","assets/i18n-DZaOYCSO.js","assets/index-CBkHUp3F.css","assets/dist-zyJb88Zz.js","assets/dist-CbTzBiwL.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,F as i,I as a,P as ee,Q as te,R as o,S as s,U as c,W as l,_ as u,c as d,d as f,f as p,p as m,s as h,tt as g,u as _}from"./avatar-BZwHW4ll.js";import{n as v}from"./useNavigate-DWlBD_-b.js";import{a as ne}from"./i18n-DZaOYCSO.js";import{n as y,t as b}from"./lock-BEWKuIqK.js";import{n as x,t as re}from"./folder-CwtLO09O.js";import{t as ie}from"./file-text-C3v0L_lQ.js";import{n as S,t as C}from"./notebook-pen-DgWzxf2y.js";import{n as ae,t as w}from"./SidebarHomeLink-CkhGDvZ8.js";import{t as oe}from"./OpenSidebarButton-BoSmO8CY.js";import{t as se}from"./plus-D1kCYb8G.js";import{t as ce}from"./save-X5c7jlCg.js";import{t as le}from"./search-DAV9vDOq.js";import{t as ue}from"./trash-2-CE-3Dc63.js";import{a as de,l as fe,t as pe}from"./index-DluhgSHX.js";var me=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`}]]),he=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`}]]),T=t(e(),1),E=n();function D(e){return e.type===`directory`?a(e.path?`${e.path}/${e.name}`:e.name):i(e)}function ge({target:e,directories:t,onMove:n,onClose:r}){let{t:i}=ne(),ee=a(e.path||``),o=D(e),s=t.filter(t=>e.type===`directory`?t.path!==o&&!t.path.startsWith(`${o}/`):!0),[c,l]=(0,T.useState)(ee),[u,d]=(0,T.useState)(``),[f,p]=(0,T.useState)(new Set),m=a(u),h=u.trim()?m:c,g=a(h)===ee,v=new Map;for(let e of s){let t=v.get(e.parentPath)||[];t.push(e),v.set(e.parentPath,t)}let b=s.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>f.has(t.slice(0,n+1).join(`/`)))}),ie=[{label:i(`note.root`),path:``},...c.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function S(e){l(a(e)),d(``)}function C(e){S(e),v.has(e)&&p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ae(){g||n(h)}return(0,E.jsx)(_,{onClose:r,children:(0,E.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`modal-header`,children:[(0,E.jsx)(`h3`,{children:i(`note.move.title`)}),(0,E.jsx)(`button`,{className:`btn btn-icon`,onClick:r,children:(0,E.jsx)(te,{size:18})})]}),(0,E.jsxs)(`div`,{className:`note-move-target`,children:[(0,E.jsx)(`span`,{children:i(`note.move.moving`)}),(0,E.jsx)(`strong`,{translate:`no`,children:e.name})]}),(0,E.jsx)(`div`,{className:`note-move-path`,children:ie.map((e,t)=>(0,E.jsxs)(T.Fragment,{children:[t>0&&(0,E.jsx)(`span`,{children:`/`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>S(e.path),children:(0,E.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,E.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${c===``?`selected`:``}`,onClick:()=>S(``),children:[(0,E.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,E.jsx)(re,{className:`note-move-folder-icon`,size:16}),(0,E.jsx)(`span`,{children:i(`note.root`)})]}),s.length===0?(0,E.jsx)(`p`,{className:`note-move-empty`,children:i(`note.move.noFolders`)}):b.map(e=>{let t=v.has(e.path),n=f.has(e.path);return(0,E.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${c===e.path?`selected`:``}`,onClick:()=>C(e.path),children:[t?n?(0,E.jsx)(y,{className:`note-move-expander`,size:14}):(0,E.jsx)(x,{className:`note-move-expander`,size:14}):(0,E.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,E.jsx)(re,{className:`note-move-folder-icon`,size:16}),(0,E.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,E.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,E.jsx)(`input`,{className:`input input-compact`,value:u,onChange:e=>d(e.target.value),placeholder:i(`note.move.pathPlaceholder`),translate:`no`}),(0,E.jsxs)(`div`,{className:`note-move-destination`,children:[(0,E.jsx)(`span`,{children:i(`note.move.destinationLabel`)}),(0,E.jsx)(`span`,{translate:h?`no`:`yes`,children:h||i(`note.root`)})]}),(0,E.jsxs)(`div`,{className:`modal-actions`,children:[(0,E.jsx)(`button`,{className:`btn btn-secondary`,onClick:r,children:i(`common.cancel`)}),(0,E.jsx)(`button`,{className:`btn btn-primary`,onClick:ae,disabled:g,children:i(`note.action.move`)})]})]})})}function _e({children:e}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(w,{}),e]})}async function O(){return m.get(`/api/note-vault/status`).json()}async function k(e){return m.post(`/api/note-vault/config`,{json:{path:e}}).json()}async function A(){let e=await m.get(`/api/note-vault/files`).json();return Array.isArray(e.files)?e.files:[]}async function ve(e){return m.get(`/api/note-vault/file`,{searchParams:{path:e}}).json()}async function j(e,t){return(await m.put(`/api/note-vault/file`,{json:{path:e,content:t}}).json()).file}var ye=(0,T.lazy)(async()=>({default:(await pe(()=>import(`./MilkdownEditor-WedhCoFH.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).MilkdownEditor}));function be(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,file:t.get(`file`)||void 0,mode:n===`edit`?`edit`:void 0}}function xe(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.file&&t.set(`file`,e.file),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function M(e,t){return e.isSecret||e.content.startsWith(`mp://1`)?t(`note.preview.encrypted`):String(e.content||``).replace(/```[\s\S]*?```/g,` `).replace(/!\[[^\]]*]\([^)]*\)/g,` `).replace(/\[([^\]]+)]\([^)]*\)/g,`$1`).replace(/[#>*_`~|-]/g,` `).replace(/\s+/g,` `).trim()||t(`note.preview.empty`)}var N={"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 P(e,t,n){let r=e instanceof Error?e.message:``,i=N[r];return i?n(i):r||t}function Se(e){return e.type===`directory`?a(e.path?`${e.path}/${e.name}`:e.name):i(e)}function F(e,t){let n=new Set;for(let t of e){let e=a(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 Ce(e){return e.map(e=>({name:e.name,cid:e.path,path:a(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 I(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 L(){let{t:e,formatDate:t,compareStrings:n}=ne(),r=v(),s=fe({select:e=>e.searchStr}),u=(0,T.useMemo)(()=>be(s),[s]),f=(0,T.useRef)(null),m=p(e=>e.addToast),g=o(e=>e.wallet),_=o(e=>e.openLoginModal),y=p(e=>e.notes),x=p(e=>e.notesPath),S=p(e=>e.setNotesPath),w=p(e=>e.saveNote),pe=p(e=>e.deleteNote),D=p(e=>e.renameNote),O=p(e=>e.localDataReady),k=u.cid||``,A=y.find(e=>e.cid===k),ve=!!k,j=ve&&u.mode===`edit`,[N,Ce]=(0,T.useState)(``),[I,L]=(0,T.useState)(null),[R,z]=(0,T.useState)(null),[B,V]=(0,T.useState)(null),[we,H]=(0,T.useState)(``),[U,W]=(0,T.useState)(``),[G,K]=(0,T.useState)(``),[Te,q]=(0,T.useState)(``),[J,Ee]=(0,T.useState)(``),[De,Y]=(0,T.useState)(``),[X,Oe]=(0,T.useState)(!1),[ke,Z]=(0,T.useState)(``),[Ae,je]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(!k){H(``),W(``);return}if(!A){H(``),W(O?e(`note.error.notFound`):``);return}if(A.content.startsWith(`mp://1`)){if(!g){H(``),W(e(`note.error.loginToDecrypt`));return}let t=c(A.content,g.danger);if(!t){H(``),W(e(`note.error.decryptFailed`));return}H(t),W(``);return}H(A.content||``),W(``)},[k,O,A,e,g]),(0,T.useEffect)(()=>{if(!j){je(!1);return}if(!k||!A){q(``),Ee(``),Y(``),Oe(!1),Z(O?e(`note.error.notFound`):``);return}if(q(A.name),Ee(A.path||``),Oe(A.isSecret===!0||A.content.startsWith(`mp://1`)),A.content.startsWith(`mp://1`)){if(!g){Y(``),Z(e(`note.error.loginToDecrypt`));return}let t=c(A.content,g.danger);if(!t){Y(``),Z(e(`note.error.decryptFailed`));return}Y(t),Z(``);return}Y(A.content||``),Z(``)},[k,j,O,A,e,g]),(0,T.useEffect)(()=>{K(A?.name||``)},[A?.cid,A?.name]);let Me=(0,T.useMemo)(()=>ee(y,x,N),[y,x,N]),Ne=Me.filter(e=>e.type===`file`).length,Pe=A?.isSecret===!0||A?.content.startsWith(`mp://1`)===!0,Fe=e(j?X?`note.privacy.secret`:`note.privacy.public`:Pe?`note.privacy.secret`:`note.privacy.public`),Ie=(0,T.useMemo)(()=>{let t=x.split(`/`).filter(Boolean);return[{label:e(`note.root`),path:``},...t.map((e,n)=>({label:e,path:t.slice(0,n+1).join(`/`)}))]},[x,e]),Le=(0,T.useMemo)(()=>F(y,n),[n,y]);function Q(e={},t=!1){r({href:xe(e),replace:t})}function Re(e){Q({cid:e.cid})}function ze(e){Q({cid:e.cid,mode:`edit`})}function $(){return g?!0:(_(),!1)}function Be(){Q(A?{cid:A.cid}:{})}async function Ve(){if($()){if(!A){m(e(`note.toast.notFound`),`error`);return}if(!Te.trim()){m(e(`note.toast.nameRequired`),`warning`);return}je(!0);try{let t=f.current?.getMarkdown()??De,n=X?l(t,g.danger):t,r=await w({cid:A.cid,name:Te,path:J,content:n,isSecret:X});Y(t),Q({cid:r},!0),m(e(`note.toast.saved`),`success`)}catch(t){m(P(t,e(`note.toast.saveFailed`),e),`error`)}finally{je(!1)}}}function He(){$()&&L({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if($())try{let n=await w({name:t,path:x,content:``,isSecret:!1});L(null),m(e(`note.toast.created`),`success`),Q({cid:n,mode:`edit`})}catch(t){m(P(t,e(`note.toast.createFailed`),e),`error`)}}})}async function Ue(){if(!$()||!A)return;let t=G.trim();if(!t){K(A.name),m(e(`note.toast.nameRequired`),`warning`);return}if(t!==A.name)try{D(i(A),A.path,t),m(e(`note.toast.renamed`),`success`)}catch(t){K(A.name),m(P(t,e(`note.toast.renameFailed`),e),`error`)}}function We(e){$()&&V(e)}async function Ge(t){if(B)try{D(Se(B),t,B.name),V(null),m(e(`note.toast.moved`),`success`)}catch(t){m(P(t,e(`note.toast.moveFailed`),e),`error`)}}function Ke(t){if(!$())return;let n=t.type===`directory`;z({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:t.name}),confirmText:e(`note.action.delete`),onConfirm:async()=>{pe(n?void 0:t.cid,t.path,t.name),z(null),m(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===k&&Q()}})}let qe=(0,E.jsxs)(`div`,{className:`note-header-title`,children:[(0,E.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,E.jsx)(`span`,{children:e(`note.count`,{count:y.length})})]}),Je=(0,E.jsx)(`div`,{className:`note-theme-wrap`}),Ye=(0,E.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,E.jsxs)(`div`,{className:`note-list-header`,children:[(0,E.jsx)(`div`,{className:`note-current-location`,children:(0,E.jsx)(`div`,{className:`note-breadcrumbs`,children:Ie.map((e,t)=>(0,E.jsxs)(T.Fragment,{children:[t>0&&(0,E.jsx)(`span`,{children:`/`}),(0,E.jsx)(`button`,{onClick:()=>S(e.path),children:(0,E.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))})}),(0,E.jsx)(`span`,{className:`note-count`,children:e(`note.count`,{count:Ne})})]}),(0,E.jsxs)(`div`,{className:`note-search`,children:[(0,E.jsx)(le,{size:16}),(0,E.jsx)(`input`,{className:`input input-flex`,value:N,onChange:e=>Ce(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Me.length===0?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,E.jsx)(C,{size:32}),(0,E.jsx)(`p`,{children:e(N?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,E.jsx)(`div`,{className:`note-list`,children:Me.map(n=>(0,E.jsx)(`article`,{className:`ui-list-item note-list-item ${n.type===`file`&&n.cid===k?`active`:``}`,children:(0,E.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${n.type===`directory`?`folder`:``}`,onClick:()=>{n.type===`directory`?S(a(n.path?`${n.path}/${n.name}`:n.name)):Re(n)},children:[(0,E.jsx)(`span`,{className:`ui-list-icon note-list-icon ${n.type===`directory`?`warning`:``}`,children:n.type===`directory`?(0,E.jsx)(re,{size:18}):n.isSecret?(0,E.jsx)(b,{size:18}):(0,E.jsx)(ie,{size:18})}),(0,E.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,E.jsx)(`span`,{className:`ui-list-title note-list-name`,translate:`no`,children:n.name}),n.type===`file`?(0,E.jsx)(`span`,{className:`ui-list-desc note-list-preview`,translate:`no`,children:M(n,e)}):(0,E.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:e(`note.folder`)})]}),n.type===`file`&&(0,E.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:t(n.updated_at)})]})},`${n.cid}:${n.path}:${n.name}`))}),(0,E.jsx)(`div`,{className:`note-create-btn`,children:(0,E.jsxs)(`button`,{className:`btn`,onClick:He,children:[(0,E.jsx)(se,{size:16}),e(`note.newNote`)]})})]});return(0,E.jsxs)(ae,{sidebar:()=>(0,E.jsx)(_e,{children:Ye}),headerTitle:qe,headerRight:Je,children:[(0,E.jsx)(`main`,{className:`note-page note-browser-page ${ve?`has-editor`:``}`,children:(0,E.jsx)(`section`,{className:`note-workspace`,children:(0,E.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(j?`note.editorLabel.edit`:`note.editorLabel.read`),children:ve?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,E.jsxs)(`div`,{className:`note-editor-title-area`,children:[j?(0,E.jsx)(`input`,{className:`note-title-input`,value:Te,onChange:e=>q(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!A}):A?(0,E.jsx)(`input`,{className:`note-title-input`,value:G,onBlur:Ue,onChange:e=>K(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(K(A.name),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),title:e(`app.rename`),translate:`no`}):(0,E.jsx)(`h3`,{children:e(`note.untitled`)}),A&&(0,E.jsxs)(`div`,{className:`note-editor-info`,children:[(0,E.jsx)(`span`,{children:e(j?`note.mode.edit`:`note.mode.read`)}),(0,E.jsx)(`span`,{children:Fe}),(0,E.jsx)(`span`,{children:t(A.updated_at)})]})]}),(0,E.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,E.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:j?Be:()=>Q(),title:e(j?`common.cancel`:`common.close`),"aria-label":e(j?`common.cancel`:`common.close`),children:(0,E.jsx)(te,{size:16})}),j?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{className:`btn btn-sm ${X?`btn-warning`:`btn-secondary`}`,onClick:()=>Oe(!X),disabled:!A,children:[X?(0,E.jsx)(b,{size:16}):(0,E.jsx)(de,{size:16}),e(X?`note.privacy.secret`:`note.privacy.public`)]}),(0,E.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Ve,disabled:Ae||!!ke||!A,children:[(0,E.jsx)(ce,{size:16}),e(Ae?`note.action.saving`:`note.action.save`)]})]}):A&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>We(A),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,E.jsx)(me,{size:16})}),(0,E.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>Ke(A),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,E.jsx)(ue,{size:16})}),(0,E.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>ze(A),disabled:!!U,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,E.jsx)(he,{size:16}),e(`note.action.edit`)]})]})]})]}),j?ke?(0,E.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,E.jsx)(b,{size:36}),(0,E.jsx)(`p`,{children:ke})]}):A?(0,E.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,E.jsx)(ye,{ref:f,content:De,onChange:Y,className:`milkdown-editor`})}):(0,E.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,E.jsx)(C,{size:36}),(0,E.jsx)(`p`,{children:e(O?`note.error.notFound`:`note.loading`)})]}):U?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,E.jsx)(b,{size:36}),(0,E.jsx)(`p`,{children:U})]}):A?(0,E.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,E.jsx)(ye,{content:we,readOnly:!0,className:`milkdown-editor`})}):(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,E.jsx)(C,{size:36}),(0,E.jsx)(`p`,{children:e(O?`note.error.notFound`:`note.loading`)})]})]}):(0,E.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,E.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,E.jsx)(C,{size:32})}),(0,E.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,E.jsx)(`p`,{className:`ui-empty-desc`,children:y.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,E.jsx)(oe,{label:e(`note.openList`),variant:`default`})]})})})}),I&&(0,E.jsx)(h,{title:I.title,placeholder:I.placeholder,defaultValue:I.defaultValue,confirmText:I.confirmText,onConfirm:I.onConfirm,onClose:()=>L(null)}),R&&(0,E.jsx)(d,{title:R.title,message:R.message,confirmText:R.confirmText,danger:!0,onConfirm:R.onConfirm,onClose:()=>z(null)}),B&&(0,E.jsx)(ge,{target:B,directories:Le,onMove:Ge,onClose:()=>V(null)})]})}function R(){let{t:e,formatDate:t}=ne(),n=v(),r=fe({select:e=>e.searchStr}),i=(0,T.useMemo)(()=>be(r),[r]),s=(0,T.useRef)(null),c=p(e=>e.addToast),l=o(e=>e.wallet),d=o(e=>e.openLoginModal),f=i.file||``,m=!!f,h=m&&i.mode===`edit`,[g,_]=(0,T.useState)(null),[y,x]=(0,T.useState)([]),[w,se]=(0,T.useState)(``),[ue,de]=(0,T.useState)(!0),[pe,me]=(0,T.useState)(``),[D,ge]=(0,T.useState)(``),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(``),[R,z]=(0,T.useState)(!1),[B,V]=(0,T.useState)(``),[we,H]=(0,T.useState)(!1),U=(0,T.useMemo)(()=>Ce(y),[y]),W=U.find(e=>e.cid===f),G=(0,T.useMemo)(()=>ee(U,w,D),[w,D,U]),K=G.filter(e=>e.type===`file`).length,Te=(0,T.useMemo)(()=>{let t=w.split(`/`).filter(Boolean);return[{label:e(`note.root`),path:``},...t.map((e,n)=>({label:e,path:t.slice(0,n+1).join(`/`)}))]},[w,e]),q=(0,T.useCallback)(async()=>{if(!l){_(null),x([]),me(e(`note.vault.loginRequired`)),de(!1);return}de(!0),me(``);try{let e=await O();_(e),e.configured?x(await A()):x([])}catch(t){_(null),x([]),me(await u(t,e(`note.vault.loadFailed`)))}finally{de(!1)}},[e,l]);(0,T.useEffect)(()=>{q()},[q]),(0,T.useEffect)(()=>{let t=!1;async function n(){if(!f){F(null),L(``),V(``),z(!1);return}if(!l){F(null),L(``),V(e(`note.vault.loginRequired`)),z(!1);return}if(g?.configured!==!0){F(null),L(``),V(``),z(!1);return}z(!0),V(``);try{let e=await ve(f);if(t)return;F(e),L(e.content)}catch(n){if(t)return;F(null),L(``),V(await u(n,e(`note.error.notFound`)))}finally{t||z(!1)}}return n(),()=>{t=!0}},[f,e,g?.configured,l]);function J(e={},t=!1){n({href:xe(e),replace:t})}function Ee(e){J({file:e.cid})}function De(){f&&J({file:f,mode:`edit`})}function Y(){J(f?{file:f}:{})}async function X(){if(!l){d();return}let t=window.electronAPI?.selectNoteVaultDirectory;if(!t){c(e(`note.vault.selectFailed`),`error`);return}N(!0);try{let n=await t();if(!n)return;await k(n),await q(),J({},!0),c(e(`note.vault.opened`),`success`)}catch(t){c(await u(t,e(`note.vault.selectFailed`)),`error`)}finally{N(!1)}}async function Oe(){if(!l){d();return}if(!f){c(e(`note.toast.notFound`),`error`);return}H(!0);try{let t=await j(f,s.current?.getMarkdown()??I);F(t),L(t.content),await q(),J({file:t.path},!0),c(e(`note.toast.saved`),`success`)}catch(t){c(await u(t,e(`note.toast.saveFailed`)),`error`)}finally{H(!1)}}let ke=(0,E.jsxs)(`div`,{className:`note-header-title`,children:[(0,E.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,E.jsx)(`span`,{children:e(`note.count`,{count:y.length})})]}),Z=(0,E.jsx)(`div`,{className:`note-theme-wrap`,children:(0,E.jsxs)(`button`,{className:`btn btn-sm`,onClick:X,disabled:M,title:e(`note.vault.open`),"aria-label":e(`note.vault.open`),children:[(0,E.jsx)(S,{size:16}),e(M?`note.vault.opening`:`note.vault.open`)]})}),Ae=(0,E.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,E.jsxs)(`div`,{className:`note-list-header`,children:[(0,E.jsx)(`div`,{className:`note-current-location`,children:(0,E.jsx)(`div`,{className:`note-breadcrumbs`,children:Te.map((e,t)=>(0,E.jsxs)(T.Fragment,{children:[t>0&&(0,E.jsx)(`span`,{children:`/`}),(0,E.jsx)(`button`,{onClick:()=>se(e.path),children:(0,E.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))})}),(0,E.jsx)(`span`,{className:`note-count`,children:e(`note.count`,{count:K})})]}),(0,E.jsxs)(`div`,{className:`note-search`,children:[(0,E.jsx)(le,{size:16}),(0,E.jsx)(`input`,{className:`input input-flex`,value:D,onChange:e=>ge(e.target.value),placeholder:e(`note.search.placeholder`)})]}),ue?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,E.jsx)(C,{size:32}),(0,E.jsx)(`p`,{children:e(`note.loading`)})]}):pe?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,E.jsx)(b,{size:32}),(0,E.jsx)(`p`,{children:pe})]}):g?.configured===!0?G.length===0?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,E.jsx)(C,{size:32}),(0,E.jsx)(`p`,{children:e(D?`note.empty.noMatches`:`note.vault.noFiles`)})]}):(0,E.jsx)(`div`,{className:`note-list`,children:G.map(n=>(0,E.jsx)(`article`,{className:`ui-list-item note-list-item ${n.type===`file`&&n.cid===f?`active`:``}`,children:(0,E.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${n.type===`directory`?`folder`:``}`,onClick:()=>{n.type===`directory`?se(a(n.path?`${n.path}/${n.name}`:n.name)):Ee(n)},children:[(0,E.jsx)(`span`,{className:`ui-list-icon note-list-icon ${n.type===`directory`?`warning`:``}`,children:n.type===`directory`?(0,E.jsx)(re,{size:18}):(0,E.jsx)(ie,{size:18})}),(0,E.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,E.jsx)(`span`,{className:`ui-list-title note-list-name`,translate:`no`,children:n.name}),(0,E.jsx)(`span`,{className:`ui-list-desc note-list-preview`,translate:`no`,children:n.type===`file`?n.cid:e(`note.folder`)})]}),n.type===`file`&&(0,E.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:t(n.updated_at)})]})},`${n.type}:${n.cid||Se(n)}`))}):(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,E.jsx)(S,{size:32}),(0,E.jsxs)(`button`,{className:`btn btn-primary`,onClick:X,disabled:M,children:[(0,E.jsx)(S,{size:16}),e(M?`note.vault.opening`:`note.vault.open`)]})]})]}),je=P?.mtimeMs||W?.updated_at||Date.now(),Me=P?.name||W?.name||e(`note.untitled`);return(0,E.jsx)(ae,{sidebar:()=>(0,E.jsx)(_e,{children:Ae}),headerTitle:ke,headerRight:Z,children:(0,E.jsx)(`main`,{className:`note-page note-browser-page ${m?`has-editor`:``}`,children:(0,E.jsx)(`section`,{className:`note-workspace`,children:(0,E.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(h?`note.editorLabel.edit`:`note.editorLabel.read`),children:m?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,E.jsxs)(`div`,{className:`note-editor-title-area`,children:[(0,E.jsx)(`h3`,{translate:`no`,children:Me}),(0,E.jsxs)(`div`,{className:`note-editor-info`,children:[(0,E.jsx)(`span`,{children:e(h?`note.mode.edit`:`note.mode.read`)}),(0,E.jsx)(`span`,{translate:`no`,children:f}),(0,E.jsx)(`span`,{children:t(je)})]})]}),(0,E.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,E.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:h?Y:()=>J(),title:e(h?`common.cancel`:`common.close`),"aria-label":e(h?`common.cancel`:`common.close`),children:(0,E.jsx)(te,{size:16})}),h?(0,E.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Oe,disabled:we||!!B||!P,children:[(0,E.jsx)(ce,{size:16}),e(we?`note.action.saving`:`note.action.save`)]}):(0,E.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:De,disabled:!!B||!P,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,E.jsx)(he,{size:16}),e(`note.action.edit`)]})]})]}),R?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,E.jsx)(C,{size:36}),(0,E.jsx)(`p`,{children:e(`note.loading`)})]}):B?(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,E.jsx)(b,{size:36}),(0,E.jsx)(`p`,{children:B})]}):h?(0,E.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,E.jsx)(ye,{ref:s,content:I,onChange:L,className:`milkdown-editor`})}):P?(0,E.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,E.jsx)(ye,{content:P.content,readOnly:!0,className:`milkdown-editor`})}):(0,E.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,E.jsx)(C,{size:36}),(0,E.jsx)(`p`,{children:e(`note.error.notFound`)})]})]}):(0,E.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,E.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,E.jsx)(C,{size:32})}),(0,E.jsx)(`h3`,{className:`ui-empty-title`,children:g?.configured?e(`note.noOpen.title`):e(`note.vault.open`)}),(0,E.jsx)(`p`,{className:`ui-empty-desc`,children:g?.configured?e(`note.noOpen.select`):e(`note.vault.emptyPrompt`)}),g?.configured?(0,E.jsx)(oe,{label:e(`note.openList`),variant:`default`}):(0,E.jsxs)(`button`,{className:`btn btn-primary`,onClick:X,disabled:M,children:[(0,E.jsx)(S,{size:16}),e(M?`note.vault.opening`:`note.vault.open`)]})]})})})})})}function z(){let{t:e}=ne(),t=p(e=>e.hasBackend),n=f()&&t===!0&&I(s());return(0,E.jsx)(T.Suspense,{fallback:(0,E.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:n?(0,E.jsx)(R,{}):(0,E.jsx)(L,{})})}var B=g(`/note/`)({component:z});export{B as Route};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,r as n,t as r}from"./jsx-runtime-Bt-cYkS5.js";import{$ as i,S as a,_ as o,f as s,p as c,tt as l,x as u}from"./avatar-BZwHW4ll.js";import{a as d}from"./i18n-DZaOYCSO.js";import{t as f}from"./download-Q1uCiwif.js";import{t as p}from"./file-text-C3v0L_lQ.js";import{t as m}from"./hard-drive-B2V5USzR.js";import{n as h,t as g}from"./triangle-alert-DnOxsFpB.js";import{t as _}from"./save-X5c7jlCg.js";import{t as v}from"./shield-check-DuD6OLde.js";import{t as y}from"./trash-2-CE-3Dc63.js";import{t as ee}from"./wifi-DfWbmlGE.js";import{i as b,s as te}from"./index-DluhgSHX.js";import{t as x}from"./dayjs.min-Dcc0B6Je.js";import{t as ne}from"./MarketingHeader-7B-OT2XX.js";import{t as S}from"./format-CR8oUWq6.js";var re=i(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ie=i(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),C=i(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),w=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_relativeTime=r()})(e,(function(){return function(e,t,n){e||={};var r=t.prototype,i={future:`in %s`,past:`%s ago`,s:`a few seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function a(e,t,n,i){return r.fromToBase(e,t,n,i)}n.en.relativeTime=i,r.fromToBase=function(t,r,a,o,s){for(var c,l,u,d=a.$locale().relativeTime||i,f=e.thresholds||[{l:`s`,r:44,d:`second`},{l:`m`,r:89},{l:`mm`,r:44,d:`minute`},{l:`h`,r:89},{l:`hh`,r:21,d:`hour`},{l:`d`,r:35},{l:`dd`,r:25,d:`day`},{l:`M`,r:45},{l:`MM`,r:10,d:`month`},{l:`y`,r:17},{l:`yy`,d:`year`}],p=f.length,m=0;m<p;m+=1){var h=f[m];h.d&&(c=o?n(t).diff(a,h.d,!0):a.diff(t,h.d,!0));var g=(e.rounding||Math.round)(Math.abs(c));if(u=c>0,g<=h.r||!h.r){g<=1&&m>0&&(h=f[m-1]);var _=d[h.l];s&&(g=s(``+g)),l=typeof _==`string`?_.replace(`%d`,g):_(g,r,h.l,u);break}}if(r)return l;var v=u?d.future:d.past;return typeof v==`function`?v(l):v.replace(`%s`,l)},r.to=function(e,t){return a(e,t,this,!0)},r.from=function(e,t){return a(e,t,this)};var o=function(e){return e.$u?n.utc():n()};r.toNow=function(e){return this.to(o(this),e)},r.fromNow=function(e){return this.from(o(this),e)}}}))})),T=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r(x()):typeof define==`function`&&define.amd?define([`dayjs`],r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_locale_zh_cn=r(n.dayjs)})(e,(function(e){function t(e){return e&&typeof e==`object`&&`default`in e?e:{default:e}}var n=t(e),r={name:`zh-cn`,weekdays:`星期日_星期一_星期二_星期三_星期四_星期五_星期六`.split(`_`),weekdaysShort:`周日_周一_周二_周三_周四_周五_周六`.split(`_`),weekdaysMin:`日_一_二_三_四_五_六`.split(`_`),months:`一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月`.split(`_`),monthsShort:`1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月`.split(`_`),ordinal:function(e,t){return t===`W`?e+`周`:e+`日`},weekStart:1,yearStart:4,formats:{LT:`HH:mm`,LTS:`HH:mm:ss`,L:`YYYY/MM/DD`,LL:`YYYY年M月D日`,LLL:`YYYY年M月D日Ah点mm分`,LLLL:`YYYY年M月D日ddddAh点mm分`,l:`YYYY/M/D`,ll:`YYYY年M月D日`,lll:`YYYY年M月D日 HH:mm`,llll:`YYYY年M月D日dddd HH:mm`},relativeTime:{future:`%s内`,past:`%s前`,s:`几秒`,m:`1 分钟`,mm:`%d 分钟`,h:`1 小时`,hh:`%d 小时`,d:`1 天`,dd:`%d 天`,M:`1 个月`,MM:`%d 个月`,y:`1 年`,yy:`%d 年`},meridiem:function(e,t){var n=100*e+t;return n<600?`凌晨`:n<900?`早上`:n<1100?`上午`:n<1300?`中午`:n<1800?`下午`:`晚上`}};return n.default.locale(r,null,!0),r}))})),E=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r(x()):typeof define==`function`&&define.amd?define([`dayjs`],r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_locale_zh_tw=r(n.dayjs)})(e,(function(e){function t(e){return e&&typeof e==`object`&&`default`in e?e:{default:e}}var n=t(e),r={name:`zh-tw`,weekdays:`星期日_星期一_星期二_星期三_星期四_星期五_星期六`.split(`_`),weekdaysShort:`週日_週一_週二_週三_週四_週五_週六`.split(`_`),weekdaysMin:`日_一_二_三_四_五_六`.split(`_`),months:`一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月`.split(`_`),monthsShort:`1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月`.split(`_`),ordinal:function(e,t){return t===`W`?e+`週`:e+`日`},formats:{LT:`HH:mm`,LTS:`HH:mm:ss`,L:`YYYY/MM/DD`,LL:`YYYY年M月D日`,LLL:`YYYY年M月D日 HH:mm`,LLLL:`YYYY年M月D日dddd HH:mm`,l:`YYYY/M/D`,ll:`YYYY年M月D日`,lll:`YYYY年M月D日 HH:mm`,llll:`YYYY年M月D日dddd HH:mm`},relativeTime:{future:`%s內`,past:`%s前`,s:`幾秒`,m:`1 分鐘`,mm:`%d 分鐘`,h:`1 小時`,hh:`%d 小時`,d:`1 天`,dd:`%d 天`,M:`1 個月`,MM:`%d 個月`,y:`1 年`,yy:`%d 年`},meridiem:function(e,t){var n=100*e+t;return n<600?`凌晨`:n<900?`早上`:n<1100?`上午`:n<1300?`中午`:n<1800?`下午`:`晚上`}};return n.default.locale(r,null,!0),r}))})),D=t(e(),1),O=t(x(),1),k=t(w(),1);T(),E();var A=r();O.default.extend(k.default);var ae=null;function oe(e,t){let n=Math.max(0,Number(e)||0),r=Math.floor(n/86400),i=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return r>0?t(`admin.uptime.daysHours`,{days:r,hours:i}):i>0?t(`admin.uptime.hoursMinutes`,{hours:i,minutes:a}):t(`admin.uptime.minutes`,{minutes:a})}function j(e){return Number.isFinite(e)?String(Math.round(e/(1024*1024*1024)*100)/100):`0`}function M(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:Math.round(t*1024*1024*1024)}function se(e){return Array.from(new Set(String(e||``).split(/[\n,]/).map(e=>e.trim()).filter(Boolean)))}function N(e,t=12,n=8){return e?e.length<=t+n+3?e:`${e.slice(0,t)}...${e.slice(-n)}`:`-`}function ce(e,t){switch(e.seedStatus){case`queued`:return t(`admin.seedStatus.queued`);case`joining`:return t(`admin.seedStatus.joining`);case`active`:return t(`admin.seedStatus.active`);case`paused`:return t(`admin.seedStatus.paused`);case`error`:return e.seedError?t(`admin.seedStatus.errorWithMessage`,{message:e.seedError}):t(`admin.seedStatus.error`);default:return e.joined?t(`admin.seedStatus.active`):t(`admin.seedStatus.notJoined`)}}function P(e){return{"zh-CN":`zh-cn`,"zh-TW":`zh-tw`,en:`en`}[e]}function le(e,t,n){if(!e)return t(`admin.time.never`);let r=(0,O.default)(e);if(!r.isValid())return t(`admin.time.never`);if(r.isAfter((0,O.default)()))return t(`admin.time.justNow`);let i=P(n);return r.locale(i).from((0,O.default)().locale(i))}var ue=[{labelKey:`admin.seedHelp.active.label`,tone:`active`,descKey:`admin.seedHelp.active.desc`},{labelKey:`admin.seedHelp.pending.label`,tone:`pending`,descKey:`admin.seedHelp.pending.desc`},{labelKey:`admin.seedHelp.paused.label`,tone:`muted`,descKey:`admin.seedHelp.paused.desc`},{labelKey:`admin.seedHelp.error.label`,tone:`error`,descKey:`admin.seedHelp.error.desc`}],de=[{value:`all`,labelKey:`admin.logFilter.all`},{value:`join`,labelKey:`admin.logFilter.join`},{value:`pull`,labelKey:`admin.logFilter.pull`},{value:`verify`,labelKey:`admin.logFilter.verify`},{value:`serve`,labelKey:`admin.logFilter.serve`},{value:`error`,labelKey:`admin.logFilter.error`}],F={join:[`join`,`joined`,`topic`],pull:[`pull`,`p2p`],verify:[`verify`,`verified`,`integrity`,`download:success`],serve:[`seed`,`seeding`,`holding`,`publish:success`,`topic:joined`],error:[`error`,`failed`,`fail`]};function I(e){let t=``;try{t=JSON.stringify(e.data||{})}catch{}return[e.level,e.event,e.message,t].map(e=>String(e||``).toLowerCase()).join(` `)}function fe(e,t){let n=String(t||`all`).trim().toLowerCase();if(!n||n===`all`)return!0;let r=I(e);return n===`error`?e.level===`error`||F.error.some(e=>r.includes(e)):(F[n]||[n]).some(e=>r.includes(e))}function L(){let{t:e,locale:t,formatNumber:n,formatTime:r}=d(),i=s(e=>e.hasBackend),l=s(e=>e.addToast),[x,w]=(0,D.useState)(ae),[T,E]=(0,D.useState)([]),[O,k]=(0,D.useState)(``),[P,F]=(0,D.useState)(!1),[I,L]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,pe]=(0,D.useState)(`all`),[V,me]=(0,D.useState)([]),[he,H]=(0,D.useState)(``),[U,W]=(0,D.useState)({dataPath:``,capacityGiB:`100`,maxFileSizeGiB:`10`,remoteInvites:``}),G=i===!0;function K(){return G?!0:(l(e(i===null?`admin.toast.backendChecking`:`admin.toast.backendDisconnected`),`warning`),!1)}let q=(0,D.useMemo)(()=>!x||x.capacity.configuredBytes<=0?0:Math.min(100,Math.round(x.capacity.usedBytes/x.capacity.configuredBytes*100)),[x]),ge=(0,D.useMemo)(()=>(x?.holdings||[]).slice(0,100),[x]),J=Math.max(0,(x?.holdings.length||0)-100),Y=a(),X=!!Y&&!Y.includes(`localhost`)&&!Y.includes(`127.0.0.1`),Z=async()=>{if(!G)return!1;try{let e=await c.get(`/api/node/status`).json(),t=await c.get(`/api/node/config`).json();return w(e),W({dataPath:t.dataPath||e.dataPath||``,capacityGiB:j(t.capacityBytes),maxFileSizeGiB:j(t.maxFileSizeBytes),remoteInvites:(t.remoteInvites||[]).join(`
|
|
2
|
-
`)}),k(``),!0}catch(t){let n=await o(t,e(`admin.error.readStatus`));return k(n),l(n,`error`),!1}},_e=async()=>{K()&&await Z()&&l(e(`admin.toast.statusRefreshed`),`success`)},Q=async(e=B)=>{if(G)try{let t=new URLSearchParams({limit:`80`,filter:e});E((await c.get(`/api/node/logs?${t.toString()}`).json()).logs||[])}catch{}},$=async()=>{if(G)try{me((await c.get(`/api/admin/users`).json()).users||[])}catch{}},ve=async()=>{if(K()){F(!0);try{await c.post(`/api/node/config`,{json:{dataPath:U.dataPath,capacityBytes:M(U.capacityGiB),maxFileSizeBytes:M(U.maxFileSizeGiB),remoteInvites:se(U.remoteInvites)}}).json(),l(U.dataPath===(x?.dataPath||``)?e(`admin.toast.configSaved`):e(`admin.toast.configSavedRestart`),`success`),await Z(),await Q()}catch(t){let n=await o(t,e(`admin.error.saveConfig`));l(n,`error`),k(n)}finally{F(!1)}}},ye=async()=>{x?.nodeId&&(await navigator.clipboard.writeText(x.nodeId),l(e(`admin.toast.nodeIdCopied`),`success`))},be=async()=>{if(K()){L(!0);try{await c.delete(`/api/node/logs`).json(),E([]),l(e(`admin.toast.logsCleared`),`success`)}catch(t){let n=await o(t,e(`admin.error.clearLogs`));l(n,`error`),k(n)}finally{L(!1)}}},xe=async()=>{if(K()){z(!0);try{let t=await c.get(`/api/node/diagnostics`).json(),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`),a=new Date().toISOString().replace(/[:.]/g,`-`);i.href=r,i.download=`mostbox-diagnostics-${a}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),l(e(`admin.toast.diagnosticsExported`),`success`)}catch(t){let n=await o(t,e(`admin.error.exportDiagnostics`));l(n,`error`),k(n)}finally{z(!1)}}},Se=async t=>{if(K()&&window.confirm(e(`admin.confirm.clearUserData`,{address:`${t.slice(0,6)}...${t.slice(-4)}`}))){H(t);try{await c.delete(`/api/admin/users/${t}/data`).json(),l(e(`admin.toast.userDataCleared`),`success`),await $(),await Z()}catch(t){let n=await o(t,e(`admin.error.clearUserData`));l(n,`error`),k(n)}finally{H(``)}}};return(0,D.useEffect)(()=>{if(!G||X)return;Z(),Q(),$();let e=null,t=!1;return(async()=>{if(e=new WebSocket(await u(`/ws`)),t){e.close();return}e.onmessage=e=>{try{let t=JSON.parse(e.data);t.event===`node:status`&&w(t.data),t.event===`node:log`&&fe(t.data,B)&&E(e=>[t.data,...e].slice(0,80)),t.event===`node:logs:cleared`&&E([]),(t.event===`publish:success`||t.event===`download:success`||t.event===`network:status`)&&Z()}catch{}}})(),()=>{t=!0,e?.close()}},[G,X,B]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ne,{}),(0,A.jsxs)(`main`,{className:`admin-page`,children:[(0,A.jsxs)(`header`,{className:`admin-topbar`,children:[(0,A.jsx)(`div`,{className:`admin-title-group`,children:(0,A.jsx)(`h1`,{children:e(`admin.title`)})}),(0,A.jsxs)(`div`,{className:`admin-topbar-actions`,children:[(0,A.jsxs)(`span`,{className:`admin-status-pill ${x?.status===`online`?`online`:``}`,children:[(0,A.jsx)(re,{size:14}),x?.status===`online`?e(`admin.status.online`):e(`admin.status.waiting`)]}),(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:_e,children:[(0,A.jsx)(h,{size:16}),e(`admin.action.refresh`)]})]})]}),i===!1&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(b,{size:20}),(0,A.jsx)(`span`,{children:e(`admin.error.localDaemonDisconnected`)})]}),X&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(g,{size:18}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:e(`admin.remoteUnavailable.title`)}),(0,A.jsx)(`p`,{children:e(`admin.remoteUnavailable.desc`)})]})]}),!X&&O&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(p,{size:20}),(0,A.jsx)(`span`,{children:O})]}),!X&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`admin-overview`,children:[(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(v,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.nodeId`)}),(0,A.jsx)(`strong`,{translate:`no`,children:N(x?.nodeId||``)})]}),(0,A.jsx)(`button`,{className:`btn btn-icon admin-metric-action`,onClick:ye,"aria-label":e(`admin.action.copyNodeId`),children:(0,A.jsx)(ie,{size:15})})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(ee,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.connections`)}),(0,A.jsx)(`strong`,{children:x?e(`admin.metric.peers`,{count:x.network.peers}):`-`})]})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(m,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.capacity`)}),(0,A.jsxs)(`strong`,{children:[q,`%`]})]})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(b,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.uptime`)}),(0,A.jsx)(`strong`,{children:x?oe(x.uptimeSeconds,e):`-`})]})]})]}),(0,A.jsxs)(`section`,{className:`admin-grid`,children:[(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.nodeStatus.title`)})}),(0,A.jsx)(te,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-status-grid`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.version`)}),(0,A.jsx)(`strong`,{translate:`no`,children:x?.version||`-`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.listen`)}),(0,A.jsx)(`strong`,{translate:`no`,children:x?`${x.host}:${x.port}`:`-`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.dataPath`)}),(0,A.jsx)(`strong`,{translate:`no`,children:x?.dataPath||`-`})]})]}),(0,A.jsx)(`div`,{className:`admin-address-list`,children:(x?.listen.addresses||[]).map(e=>(0,A.jsxs)(`span`,{translate:`no`,children:[e.label,`: `,e.ip,`:`,x?.port]},`${e.type}-${e.ip}`))})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.userData.title`)})}),(0,A.jsx)(C,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-table`,children:[(0,A.jsxs)(`div`,{className:`admin-table-row admin-table-head`,children:[(0,A.jsx)(`span`,{children:e(`admin.userData.user`)}),(0,A.jsx)(`span`,{children:e(`admin.userData.files`)}),(0,A.jsx)(`span`,{children:e(`admin.userData.trash`)}),(0,A.jsx)(`span`,{children:e(`admin.userData.actions`)})]}),V.map(t=>(0,A.jsxs)(`div`,{className:`admin-table-row`,children:[(0,A.jsx)(`span`,{title:t.address,translate:`no`,children:N(t.address)}),(0,A.jsx)(`span`,{children:n(t.fileCount)}),(0,A.jsx)(`span`,{children:n(t.trashCount)}),(0,A.jsx)(`span`,{children:(0,A.jsxs)(`button`,{className:`btn btn-ghost`,onClick:()=>Se(t.address),disabled:he===t.address,children:[(0,A.jsx)(y,{size:16}),e(`admin.action.clear`)]})})]},t.address)),V.length===0&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.userData.empty`)})]})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.settings.title`)})}),(0,A.jsx)(C,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-settings-fields`,children:[(0,A.jsxs)(`label`,{className:`admin-field admin-field-wide`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.dataPath`)}),(0,A.jsx)(`input`,{className:`input`,value:U.dataPath,onChange:e=>W(t=>({...t,dataPath:e.target.value}))})]}),(0,A.jsxs)(`label`,{className:`admin-field`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.capacityGiB`)}),(0,A.jsx)(`input`,{className:`input`,type:`number`,min:`0`,step:`1`,value:U.capacityGiB,onChange:e=>W(t=>({...t,capacityGiB:e.target.value}))})]}),(0,A.jsxs)(`label`,{className:`admin-field`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.maxFileSizeGiB`)}),(0,A.jsx)(`input`,{className:`input`,type:`number`,min:`0`,step:`1`,value:U.maxFileSizeGiB,onChange:e=>W(t=>({...t,maxFileSizeGiB:e.target.value}))})]}),(0,A.jsxs)(`label`,{className:`admin-field admin-field-wide`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.remoteInvites`)}),(0,A.jsx)(`textarea`,{className:`input admin-textarea`,value:U.remoteInvites,placeholder:e(`admin.settings.remoteInvitesPlaceholder`),onChange:e=>W(t=>({...t,remoteInvites:e.target.value}))})]})]}),(0,A.jsx)(`p`,{className:`admin-field-hint`,children:e(`admin.settings.hint`)}),(0,A.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:ve,disabled:P,children:[(0,A.jsx)(_,{size:16}),e(`admin.action.saveConfig`)]})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.holdings.title`)})}),(0,A.jsx)(m,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-capacity-row`,children:[(0,A.jsx)(`progress`,{value:q,max:`100`}),(0,A.jsxs)(`span`,{children:[S(x?.capacity.usedBytes||0),` /`,` `,S(x?.capacity.configuredBytes||0)]})]}),(0,A.jsx)(`div`,{className:`admin-seed-help`,"aria-label":e(`admin.seedHelp.label`),children:ue.map(t=>(0,A.jsxs)(`div`,{className:`admin-seed-help-item`,children:[(0,A.jsx)(`span`,{className:`admin-seed-dot ${t.tone}`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`strong`,{children:e(t.labelKey)}),(0,A.jsx)(`span`,{children:e(t.descKey)})]})]},t.labelKey))}),J>0&&(0,A.jsx)(`p`,{className:`admin-table-note`,children:e(`admin.holdings.hiddenCount`,{count:n(J)})}),(0,A.jsxs)(`div`,{className:`admin-table`,children:[(0,A.jsxs)(`div`,{className:`admin-table-row admin-table-head admin-holdings-row`,children:[(0,A.jsx)(`span`,{children:e(`admin.holdings.file`)}),(0,A.jsx)(`span`,{children:`CID`}),(0,A.jsx)(`span`,{children:e(`admin.holdings.size`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.peers`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.topicJoined`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.lastServed`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.totalServed`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.status`)})]}),ge.map(r=>(0,A.jsxs)(`div`,{className:`admin-table-row admin-holdings-row`,children:[(0,A.jsx)(`span`,{translate:`no`,children:r.fileName||`-`}),(0,A.jsx)(`span`,{title:r.cid,translate:`no`,children:N(r.cid)}),(0,A.jsx)(`span`,{children:S(r.size)}),(0,A.jsx)(`span`,{children:n(r.peerCount??0)}),(0,A.jsx)(`span`,{className:`admin-seed-pill ${r.joined?`active`:``}`,children:r.joined?e(`admin.holdings.joinedYes`):e(`admin.holdings.joinedNo`)}),(0,A.jsx)(`span`,{title:r.lastServedAt||``,children:le(r.lastServedAt,e,t)}),(0,A.jsx)(`span`,{children:S(r.totalServedBytes||0)}),(0,A.jsx)(`span`,{className:`admin-seed-pill ${r.seedStatus===`error`?`error`:r.seedStatus===`active`||r.joined?`active`:``}`,children:ce(r,e)})]},r.cid)),(!x||x.holdings.length===0)&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.holdings.empty`)})]})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.logs.title`)})}),(0,A.jsxs)(`div`,{className:`admin-panel-actions`,children:[(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:xe,disabled:R,children:[(0,A.jsx)(f,{size:16}),e(`admin.action.exportDiagnostics`)]}),(0,A.jsxs)(`button`,{className:`btn btn-ghost`,onClick:be,disabled:I||T.length===0,children:[(0,A.jsx)(y,{size:16}),e(`admin.action.clearLogs`)]}),(0,A.jsx)(p,{size:18})]})]}),(0,A.jsx)(`div`,{className:`admin-log-filter`,"aria-label":e(`admin.logs.filterLabel`),children:de.map(t=>(0,A.jsx)(`button`,{type:`button`,className:B===t.value?`active`:``,onClick:()=>{pe(t.value),Q(t.value)},children:e(t.labelKey)},t.value))}),(0,A.jsxs)(`div`,{className:`admin-log-list`,children:[T.map(e=>(0,A.jsxs)(`div`,{className:`admin-log-row`,children:[(0,A.jsx)(`time`,{children:r(e.ts)}),(0,A.jsx)(`span`,{className:`admin-log-level ${e.level}`,translate:`no`,children:e.level}),(0,A.jsx)(`strong`,{translate:`no`,children:e.event}),(0,A.jsx)(`span`,{translate:`no`,children:e.message})]},e.id)),T.length===0&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.logs.empty`)})]})]})]})]})]})]})}var R=l(`/admin/`)({component:L});export{R as Route};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,B as i,G as a,H as o,J as s,R as c,V as l,X as u,f as d,n as f,q as p,tt as m}from"./avatar-BZwHW4ll.js";import{a as h}from"./i18n-DZaOYCSO.js";import{i as g}from"./AccountMenu-NjOgag0d.js";import{n as _,t as v}from"./lock-BEWKuIqK.js";import{t as y}from"./download-Q1uCiwif.js";import{t as b}from"./external-link-DGzNJOqQ.js";import{i as x,n as S,r as C,t as w}from"./mp-CGBtY36n.js";import{t as T}from"./key-round-Dn5tud-4.js";import{n as ee,t as te}from"./SidebarHomeLink-CkhGDvZ8.js";import{t as ne}from"./wallet-VDaoXwjI.js";import{a as E,o as D}from"./index-DluhgSHX.js";var re=r(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ie=r(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ae=r(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),oe=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),se=r(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),O=t(e()),k=n();function ce(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function le({title:e,username:t,password:n,showPassword:r,showPrivateKey:i,account:a,onUsernameChange:o,onPasswordChange:s,onTogglePassword:c,onTogglePrivateKey:l,onGenerate:u}){let{t:d}=h();return(0,k.jsxs)(`div`,{className:`web3-box-account`,children:[(0,k.jsx)(`div`,{className:`web3-box-account-header`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:e}),(0,k.jsx)(`p`,{children:d(`web3.box.account.desc`)})]})}),(0,k.jsxs)(`div`,{className:`web3-box-login`,children:[(0,k.jsx)(`input`,{type:`text`,placeholder:d(`login.username.placeholder`),value:t,onChange:e=>o(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsxs)(`div`,{className:`input-wrap`,children:[(0,k.jsx)(`input`,{type:r?`text`:`password`,placeholder:d(`web3.login.passwordOptional`),value:n,onChange:e=>s(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsx)(`button`,{className:`input-eye`,onClick:c,type:`button`,children:r?(0,k.jsx)(D,{size:16}):(0,k.jsx)(E,{size:16})})]}),(0,k.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:u,disabled:!t.trim(),type:`button`,children:[(0,k.jsx)(T,{size:16}),d(`web3.box.account.generate`)]})]}),a?(0,k.jsxs)(`div`,{className:`web3-box-key-list`,children:[(0,k.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,k.jsx)(`span`,{children:d(`web3.label.address`)}),(0,k.jsxs)(`div`,{className:`mono-row`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:a.address.toLowerCase()}),(0,k.jsx)(C,{text:a.address.toLowerCase()})]})]}),(0,k.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,k.jsx)(`span`,{children:d(`web3.label.x25519Public`)}),(0,k.jsxs)(`div`,{className:`mono-row`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:a.publicKey}),(0,k.jsx)(C,{text:a.publicKey})]})]}),(0,k.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,k.jsx)(`span`,{children:d(`web3.label.x25519Private`)}),(0,k.jsxs)(`div`,{className:`mono-row danger`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:i?a.privateKey:ce(a.privateKey)}),(0,k.jsx)(`button`,{className:`btn btn-icon`,onClick:l,title:d(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,k.jsx)(E,{size:14}):(0,k.jsx)(D,{size:14})})]})]})]}):null]})}function ue(e,t){return Number.isFinite(e)?t(e):`-`}function A({title:e,description:t,message:n,cipherText:r,decryptedText:i,error:a,encryptLabel:o,decryptLabel:c,messagePlaceholder:l,cipherPlaceholder:u,onMessageChange:d,onCipherTextChange:f,onEncrypt:p,onDecrypt:m}){let{t:g,formatDateTime:_}=h(),y=`box-message-${e.replaceAll(/\s+/g,`-`)}`,b=s(r);return(0,k.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,k.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:e}),(0,k.jsx)(`p`,{children:t})]})}),(0,k.jsx)(`label`,{className:`web3-box-label`,htmlFor:y,children:g(`web3.box.plaintext`)}),(0,k.jsx)(`textarea`,{id:y,className:`textarea`,value:n,onChange:e=>d(e.target.value),rows:4,placeholder:l,translate:`no`}),(0,k.jsxs)(`div`,{className:`web3-box-actions`,children:[(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:p,type:`button`,children:[(0,k.jsx)(v,{size:16}),o]}),(0,k.jsxs)(`button`,{className:`btn btn-secondary`,onClick:m,type:`button`,children:[(0,k.jsx)(T,{size:16}),c]})]}),a&&(0,k.jsx)(`p`,{className:`web3-tools-danger`,children:a}),(0,k.jsxs)(`div`,{className:`web3-box-result-grid`,children:[(0,k.jsxs)(`div`,{className:`web3-box-result`,children:[(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:g(`web3.box.ciphertext`)})}),(0,k.jsx)(`textarea`,{className:`textarea mono`,value:r,onChange:e=>f(e.target.value),rows:5,placeholder:u,translate:`no`})]}),(0,k.jsxs)(`div`,{className:`web3-box-result`,children:[(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:g(`web3.box.decryptResult`)})}),(0,k.jsx)(`textarea`,{className:`textarea mono`,value:i,readOnly:!0,rows:5,placeholder:g(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]}),b&&(0,k.jsxs)(`div`,{className:`web3-box-token-meta`,children:[(0,k.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,k.jsx)(`span`,{children:g(`web3.box.timestamp`)}),(0,k.jsx)(`code`,{translate:`no`,children:ue(b.timestampMs,_)})]}),(0,k.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,k.jsx)(`span`,{children:g(`web3.box.nonce`)}),(0,k.jsx)(`code`,{translate:`no`,children:b.nonce})]})]})]})}function de(e){let{t}=h();return(0,k.jsxs)(`div`,{className:`web3-box-workspace`,children:[(0,k.jsxs)(`div`,{className:`web3-box-grid`,children:[(0,k.jsx)(le,{title:t(`web3.box.accountA`),username:e.boxAUsername,password:e.boxAPassword,showPassword:e.boxAShowPassword,showPrivateKey:e.boxAShowPrivateKey,account:e.boxAAccount,onUsernameChange:e.onBoxAUsernameChange,onPasswordChange:e.onBoxAPasswordChange,onTogglePassword:e.onBoxAShowPasswordToggle,onTogglePrivateKey:e.onBoxAShowPrivateKeyToggle,onGenerate:e.onGenerateBoxA}),(0,k.jsx)(le,{title:t(`web3.box.accountB`),username:e.boxBUsername,password:e.boxBPassword,showPassword:e.boxBShowPassword,showPrivateKey:e.boxBShowPrivateKey,account:e.boxBAccount,onUsernameChange:e.onBoxBUsernameChange,onPasswordChange:e.onBoxBPasswordChange,onTogglePassword:e.onBoxBShowPasswordToggle,onTogglePrivateKey:e.onBoxBShowPrivateKeyToggle,onGenerate:e.onGenerateBoxB})]}),(0,k.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,k.jsx)(A,{title:`A → B`,description:t(`web3.box.flowAB.desc`),message:e.boxABMessage,cipherText:e.boxABCipherText,decryptedText:e.boxABDecryptedText,error:e.boxABError,encryptLabel:t(`web3.box.flowAB.encrypt`),decryptLabel:t(`web3.box.flowAB.decrypt`),messagePlaceholder:t(`web3.box.flowAB.messagePlaceholder`),cipherPlaceholder:t(`web3.box.cipherPlaceholder`),onMessageChange:e.onBoxABMessageChange,onCipherTextChange:e.onBoxABCipherTextChange,onEncrypt:e.onEncryptBoxAB,onDecrypt:e.onDecryptBoxAB}),(0,k.jsx)(A,{title:`B → A`,description:t(`web3.box.flowBA.desc`),message:e.boxBAMessage,cipherText:e.boxBACipherText,decryptedText:e.boxBADecryptedText,error:e.boxBAError,encryptLabel:t(`web3.box.flowBA.encrypt`),decryptLabel:t(`web3.box.flowBA.decrypt`),messagePlaceholder:t(`web3.box.flowBA.messagePlaceholder`),cipherPlaceholder:t(`web3.box.cipherPlaceholder`),onMessageChange:e.onBoxBAMessageChange,onCipherTextChange:e.onBoxBACipherTextChange,onEncrypt:e.onEncryptBoxBA,onDecrypt:e.onDecryptBoxBA})]}),(0,k.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,k.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,k.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:t(`web3.box.encryptTitle`)}),(0,k.jsx)(`p`,{children:t(`web3.box.encryptDesc`)})]})}),(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,k.jsxs)(`div`,{className:`input-wrap`,children:[(0,k.jsx)(`input`,{type:e.boxEncryptShowPrivateKey?`text`:`password`,placeholder:t(`web3.box.senderPrivatePlaceholder`),value:e.boxEncryptSenderPrivateKey,onChange:t=>e.onBoxEncryptSenderPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxEncryptShowPrivateKeyToggle,type:`button`,children:e.boxEncryptShowPrivateKey?(0,k.jsx)(D,{size:16}):(0,k.jsx)(E,{size:16})})]}),(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,k.jsx)(`input`,{type:`text`,placeholder:t(`web3.box.recipientPublicPlaceholder`),value:e.boxEncryptRecipientPublicKey,onChange:t=>e.onBoxEncryptRecipientPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.plaintext`)})}),(0,k.jsx)(`textarea`,{className:`textarea`,value:e.boxEncryptMessage,onChange:t=>e.onBoxEncryptMessageChange(t.target.value),rows:4,placeholder:t(`web3.box.messagePlaceholder`),translate:`no`}),(0,k.jsx)(`div`,{className:`web3-box-actions`,children:(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:e.onEncryptOnly,type:`button`,children:[(0,k.jsx)(v,{size:16}),t(`web3.box.encryptTitle`)]})}),e.boxEncryptError&&(0,k.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxEncryptError}),(0,k.jsxs)(`div`,{className:`web3-box-result`,children:[(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,k.jsx)(`textarea`,{className:`textarea mono`,value:e.boxEncryptCipherText,readOnly:!0,rows:5,placeholder:t(`web3.box.encryptResultPlaceholder`),translate:`no`})]})]}),(0,k.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,k.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:t(`web3.box.decryptTitle`)}),(0,k.jsx)(`p`,{children:t(`web3.box.decryptDesc`)})]})}),(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,k.jsx)(`input`,{type:`text`,placeholder:t(`web3.box.senderPublicPlaceholder`),value:e.boxDecryptSenderPublicKey,onChange:t=>e.onBoxDecryptSenderPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,k.jsxs)(`div`,{className:`input-wrap`,children:[(0,k.jsx)(`input`,{type:e.boxDecryptShowPrivateKey?`text`:`password`,placeholder:t(`web3.box.recipientPrivatePlaceholder`),value:e.boxDecryptRecipientPrivateKey,onChange:t=>e.onBoxDecryptRecipientPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxDecryptShowPrivateKeyToggle,type:`button`,children:e.boxDecryptShowPrivateKey?(0,k.jsx)(D,{size:16}):(0,k.jsx)(E,{size:16})})]}),(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,k.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptCipherText,onChange:t=>e.onBoxDecryptCipherTextChange(t.target.value),rows:5,placeholder:t(`web3.box.cipherDecryptPlaceholder`),translate:`no`}),(0,k.jsx)(`div`,{className:`web3-box-actions`,children:(0,k.jsxs)(`button`,{className:`btn btn-secondary`,onClick:e.onDecryptOnly,type:`button`,children:[(0,k.jsx)(T,{size:16}),t(`web3.box.decryptTitle`)]})}),e.boxDecryptError&&(0,k.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxDecryptError}),(0,k.jsxs)(`div`,{className:`web3-box-result`,children:[(0,k.jsx)(`label`,{className:`web3-box-result-header`,children:(0,k.jsx)(`span`,{children:t(`web3.box.decryptResult`)})}),(0,k.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptResult,readOnly:!0,rows:5,placeholder:t(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]})]})]})}function j({icon:e,message:t,className:n=`empty-state glass`}){return(0,k.jsxs)(`div`,{className:n,children:[(0,k.jsx)(`div`,{className:`empty-state-icon`,children:e}),(0,k.jsx)(`p`,{children:t})]})}function fe({label:e,pem:t,filename:n}){let{t:r}=h();function i(){let e=new Blob([t],{type:`text/plain`}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),URL.revokeObjectURL(r)}return(0,k.jsxs)(`div`,{className:`web3-pem-block`,children:[(0,k.jsxs)(`div`,{className:`web3-pem-header`,children:[(0,k.jsx)(`span`,{className:`web3-pem-label`,children:e}),(0,k.jsxs)(`div`,{className:`web3-pem-actions`,children:[(0,k.jsx)(C,{text:t,label:r(`common.copy`),className:`btn btn-sm`,iconSize:14}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:i,title:r(`common.download`),children:[(0,k.jsx)(y,{size:14}),r(`common.download`)]})]})]}),(0,k.jsx)(`textarea`,{className:`textarea mono`,value:t,readOnly:!0,rows:6,translate:`no`})]})}function pe({walletResult:e,publicPem:t,privatePem:n}){let{t:r}=h();if(!t||!n)return(0,k.jsx)(j,{icon:(0,k.jsx)(v,{size:36}),message:r(`web3.empty.pem`)});let i=e?.username||`wallet`;return(0,k.jsxs)(`div`,{className:`web3-pem-list`,children:[(0,k.jsx)(fe,{label:`${i}.pub`,pem:t,filename:`${i}.pub`}),(0,k.jsx)(fe,{label:`${i}.pem`,pem:n,filename:`${i}.pem`})]})}var me=Object.defineProperty,M=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,he=(e,t,n)=>t in e?me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t)=>{for(var n in t||={})N.call(t,n)&&he(e,n,t[n]);if(M)for(var n of M(t))P.call(t,n)&&he(e,n,t[n]);return e},I=(e,t)=>{var n={};for(var r in e)N.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&M)for(var r of M(e))t.indexOf(r)<0&&P.call(e,r)&&(n[r]=e[r]);return n},L;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(L||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(L||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(L||={});var R=L,ge={L:R.QrCode.Ecc.LOW,M:R.QrCode.Ecc.MEDIUM,Q:R.QrCode.Ecc.QUARTILE,H:R.QrCode.Ecc.HIGH},z=128,B=`L`,V=`#FFFFFF`,H=`#000000`,U=!1,W=1,_e=4,ve=0,ye=.1;function G(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function be(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function xe(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ye),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function Se(e,t){return t==null?e?_e:ve:Math.max(Math.floor(t),0)}function K({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=O.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...R.QrSegment.makeSegments(t)),e),[]);return R.QrCode.encodeSegments(r,ge[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=O.useMemo(()=>{let e=c.getModules(),t=Se(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:xe(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Ce=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),we=O.forwardRef(function(e,t){let n=e,{value:r,size:i=z,level:a=B,bgColor:o=V,fgColor:s=H,includeMargin:c=U,minVersion:l=W,boostLevel:u,marginSize:d,imageSettings:f}=n,p=I(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=I(p,[`style`]),g=f?.src,_=O.useRef(null),v=O.useRef(null),y=O.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=O.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=K({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});O.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=be(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,Ce?t.fill(new Path2D(G(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),O.useEffect(()=>{x(!1)},[g]);let ee=F({height:i,width:i},m),te=null;return g!=null&&(te=O.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),O.createElement(O.Fragment,null,O.createElement(`canvas`,F({style:ee,height:i,width:i,ref:y,role:`img`},h)),te)});we.displayName=`QRCodeCanvas`;var q=O.forwardRef(function(e,t){let n=e,{value:r,size:i=z,level:a=B,bgColor:o=V,fgColor:s=H,includeMargin:c=U,minVersion:l=W,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=I(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=K({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=be(g,v.excavation)),b=O.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=G(y,h);return O.createElement(`svg`,F({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&O.createElement(`title`,null,d),O.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),O.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});q.displayName=`QRCodeSVG`;function Te({walletResult:e,mnemonicPhrase:t,deriveBatch:n,deriveList:r,deriveShowIndex:i,deriveShowAddress:a,deriveShowPrivateKey:o,showAddressQr:s,showMnemonicReveal:c,showMnemonicQr:l,onToggleAddressQr:u,onToggleMnemonicReveal:d,onToggleMnemonicQr:f,onToggleDeriveIndex:p,onToggleDeriveAddress:m,onToggleDerivePrivateKey:g,onDerive:v}){let{t:y}=h(),b=e?.address||``;return!e||!b?(0,k.jsx)(j,{icon:(0,k.jsx)(ne,{size:36}),message:y(`web3.empty.walletTools`)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,k.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:u,children:[(0,k.jsx)(ae,{size:14}),y(s?`web3.action.hideAddressQr`:`web3.action.showAddressQr`),s?(0,k.jsx)(re,{size:14}):(0,k.jsx)(_,{size:14})]}),s&&(0,k.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,k.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,k.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:b}),(0,k.jsx)(C,{text:b})]}),(0,k.jsx)(`div`,{className:`qr-wrap`,children:(0,k.jsx)(q,{value:b,size:200})})]})]}),t&&(0,k.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,k.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:d,children:[(0,k.jsx)(T,{size:14}),y(c?`web3.action.hideMnemonic`:`web3.action.showMnemonic`),c?(0,k.jsx)(re,{size:14}):(0,k.jsx)(_,{size:14})]}),c&&(0,k.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,k.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,k.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:t}),(0,k.jsx)(C,{text:t})]}),(0,k.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,k.jsx)(oe,{size:14}),y(`web3.warning.mnemonic`)]}),(0,k.jsx)(`button`,{className:`web3-tools-toggle`,onClick:f,children:y(l?`web3.action.hideMnemonicQr`:`web3.action.showMnemonicQr`)}),l&&(0,k.jsx)(`div`,{className:`qr-wrap`,children:(0,k.jsx)(q,{value:t,size:260})})]})]}),t&&(0,k.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,k.jsx)(`div`,{children:(0,k.jsx)(`button`,{className:`btn btn-primary`,onClick:v,children:y(`web3.action.deriveAddresses`,{count:n})})}),(0,k.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,k.jsx)(oe,{size:14}),y(`web3.warning.privateKey`)]}),r.length>0&&(0,k.jsx)(`div`,{className:`web3-derive-table-wrap`,children:(0,k.jsxs)(`table`,{className:`web3-derive-table`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{onClick:p,className:`web3-derive-th`,children:y(`web3.label.account`)}),(0,k.jsx)(`th`,{onClick:m,className:`web3-derive-th`,children:y(`web3.label.address`)}),(0,k.jsx)(`th`,{onClick:g,className:`web3-derive-th danger`,children:y(`web3.label.privateKeyToggle`,{action:y(o?`web3.action.hide`:`web3.action.show`)})})]})}),(0,k.jsx)(`tbody`,{children:r.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:i?e.index+1:``}),(0,k.jsx)(`td`,{translate:`no`,children:a?e.address:``}),(0,k.jsx)(`td`,{className:`danger`,children:(0,k.jsx)(`span`,{translate:`no`,children:o?e.privateKey:``})})]},e.index))})]})})]})]})}function J({title:e,icon:t,children:n,accent:r=!1}){return(0,k.jsxs)(`div`,{className:`web3-key-card ${r?`accent`:``}`,children:[(0,k.jsxs)(`div`,{className:`web3-key-card-header`,children:[(0,k.jsx)(`span`,{className:`web3-key-card-icon`,children:t}),(0,k.jsx)(`span`,{className:`web3-key-card-title`,children:e})]}),(0,k.jsx)(`div`,{className:`web3-key-card-body`,translate:`no`,children:n})]})}function Ee(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function De({walletResult:e,keys:t,ipns:n,avatarSrc:r,showPrivateKey:i,onTogglePrivateKey:a}){let{t:o}=h(),s=e?.address||``;return!e||!s?(0,k.jsx)(j,{icon:(0,k.jsx)(g,{size:36}),message:o(`web3.empty.identity`)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`web3-identity-card`,children:[(0,k.jsx)(`img`,{src:r,alt:`avatar`,className:`web3-identity-avatar`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`web3-identity-name`,children:e.username||o(`web3.notSignedIn`)}),(0,k.jsxs)(`div`,{className:`web3-identity-address`,children:[(0,k.jsx)(`code`,{translate:`no`,children:s.toLowerCase()}),(0,k.jsx)(C,{text:s.toLowerCase()}),(0,k.jsxs)(`a`,{href:`https://debank.com/profile/${s}`,target:`_blank`,rel:`noopener noreferrer`,className:`link`,children:[(0,k.jsx)(b,{size:14}),o(`web3.action.view`)]})]})]})]}),t&&(0,k.jsxs)(`div`,{className:`web3-key-grid`,children:[(0,k.jsx)(J,{title:o(`web3.label.ed25519Public`),icon:(0,k.jsx)(x,{size:18}),children:(0,k.jsxs)(`div`,{className:`mono-row`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:t.ed_public_key}),(0,k.jsx)(C,{text:t.ed_public_key})]})}),(0,k.jsx)(J,{title:o(`web3.label.x25519Public`),icon:(0,k.jsx)(T,{size:18}),children:(0,k.jsxs)(`div`,{className:`mono-row`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:t.public_key}),(0,k.jsx)(C,{text:t.public_key})]})}),(0,k.jsx)(J,{title:o(`web3.label.combinedPrivate`),icon:(0,k.jsx)(se,{size:18}),accent:!0,children:(0,k.jsxs)(`div`,{className:`mono-row danger`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:i?t.private_key:Ee(t.private_key)}),(0,k.jsx)(`button`,{className:`btn btn-icon`,onClick:a,title:o(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,k.jsx)(E,{size:14}):(0,k.jsx)(D,{size:14})})]})}),(0,k.jsx)(J,{title:`IPNS ID`,icon:(0,k.jsx)(ie,{size:18}),children:(0,k.jsxs)(`div`,{className:`mono-row`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,k.jsx)(C,{text:n})]})})]})]})}function Oe({username:e,password:t,showPassword:n,generating:r,onUsernameChange:i,onPasswordChange:a,onTogglePassword:o,onGenerate:s}){let{t:c}=h();return(0,k.jsxs)(`div`,{className:`input-panel`,children:[(0,k.jsxs)(`div`,{className:`web3-tools-inputs`,children:[(0,k.jsx)(`input`,{type:`text`,placeholder:c(`login.username.placeholder`),value:e,onChange:e=>i(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsxs)(`div`,{className:`input-wrap`,children:[(0,k.jsx)(`input`,{type:n?`text`:`password`,placeholder:c(`web3.login.passwordOptional`),value:t,onChange:e=>a(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,k.jsx)(`button`,{className:`input-eye`,onClick:o,type:`button`,children:n?(0,k.jsx)(D,{size:16}):(0,k.jsx)(E,{size:16})})]})]}),(0,k.jsx)(`button`,{className:`btn btn-primary btn-full`,onClick:s,disabled:!e.trim()||r,type:`button`,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`spinner`}),c(`web3.login.generating`)]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ne,{size:16}),c(`web3.login.generateAndSignIn`)]})})]})}var Y=e=>btoa(String.fromCharCode(...e)),ke=e=>{let t=new Uint8Array([48,5,6,3,43,101,112]),n=new Uint8Array([4,34,4,32,...e.slice(0,32)]),r=new Uint8Array([2,1,0]),i=r.length+t.length+n.length,a=new Uint8Array(2+i);a[0]=48,a[1]=i;let o=2;return a.set(r,o),o+=r.length,a.set(t,o),o+=t.length,a.set(n,o),`-----BEGIN PRIVATE KEY-----\n${Y(a).match(/.{1,64}/g)?.join(`
|
|
2
|
-
`)}\n-----END PRIVATE KEY-----`},Ae=e=>{let t=new Uint8Array([48,5,6,3,43,101,112]),n=new Uint8Array([3,33,0,...e]),r=t.length+n.length,i=new Uint8Array(2+r);i[0]=48,i[1]=r;let a=2;return i.set(t,a),a+=t.length,i.set(n,a),`-----BEGIN PUBLIC KEY-----\n${Y(i).match(/.{1,64}/g)?.join(`
|
|
3
|
-
`)}\n-----END PUBLIC KEY-----`},je=[`wallet`,`pem`,`export`,`EA`];function Me(){let e=window.location.hash.replace(`#`,``);return je.includes(e)?e:`wallet`}function Ne(){let{t:e}=h(),t=d(e=>e.addToast),n=c(e=>e.setUserIdentity),[r,s]=(0,O.useState)(`wallet`),[m,_]=(0,O.useState)(``),[y,b]=(0,O.useState)(``),[x,C]=(0,O.useState)(!1),[E,D]=(0,O.useState)(null),[re,ie]=(0,O.useState)(null),[ae,oe]=(0,O.useState)(``),[se,ce]=(0,O.useState)(``),[le,ue]=(0,O.useState)(``),[A,j]=(0,O.useState)(``),[fe,me]=(0,O.useState)([]),[M,N]=(0,O.useState)(0),[P,he]=(0,O.useState)(!0),[F,I]=(0,O.useState)(!0),[L,R]=(0,O.useState)(!1),[ge,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(!1),[W,_e]=(0,O.useState)(!1),[ve,ye]=(0,O.useState)(!1),[G,be]=(0,O.useState)(``),[xe,Se]=(0,O.useState)(``),[K,Ce]=(0,O.useState)(!1),[we,q]=(0,O.useState)(!1),[J,Ee]=(0,O.useState)(null),[Y,je]=(0,O.useState)(``),[Ne,Pe]=(0,O.useState)(``),[Fe,Ie]=(0,O.useState)(!1),[Le,Re]=(0,O.useState)(!1),[X,ze]=(0,O.useState)(null),[Be,Ve]=(0,O.useState)(`Hello B. This is from A.`),[He,Ue]=(0,O.useState)(``),[We,Ge]=(0,O.useState)(``),[Ke,qe]=(0,O.useState)(``),[Je,Ye]=(0,O.useState)(`Hello A. This is from B.`),[Xe,Ze]=(0,O.useState)(``),[Qe,$e]=(0,O.useState)(``),[et,tt]=(0,O.useState)(``),[nt,rt]=(0,O.useState)(``),[it,at]=(0,O.useState)(``),[ot,st]=(0,O.useState)(``),[ct,lt]=(0,O.useState)(``),[ut,Z]=(0,O.useState)(``),[dt,ft]=(0,O.useState)(!1),[Q,pt]=(0,O.useState)(``),[mt,ht]=(0,O.useState)(``),[gt,_t]=(0,O.useState)(``),[vt,yt]=(0,O.useState)(``),[bt,$]=(0,O.useState)(``),[xt,St]=(0,O.useState)(!1);(0,O.useEffect)(()=>{s(Me());let e=()=>s(Me());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let Ct=e=>{s(e),window.location.hash=e},wt=(0,O.useCallback)(async()=>{if(!m.trim())return;ye(!0),await new Promise(e=>setTimeout(e,0));let r=p(m.trim(),y),o=`${r.username}#${r.address.slice(-4).toUpperCase()}`;D(r),n({...r,displayName:o}),t(e(`login.toast.signedIn`,{username:r.username}),`success`),j(a(r.danger));let s=i(r.danger);ie(s),oe(S(s.private_key,s.ed_public_key));let c=w(s.private_key,s.ed_public_key);ce(ke(c.secretKey)),ue(Ae(c.publicKey)),me([]),N(0),z(!1),V(!1),U(!1),_e(!1),ye(!1)},[t,y,n,e,m]);function Tt(n,r,a){let o=n.trim();if(!o)return;let s=p(o,r),c=i(s.danger);a({username:s.username,address:s.address,publicKey:c.public_key,privateKey:c.private_key}),Ge(``),qe(``),$e(``),tt(``),t(e(`web3.toast.accountGenerated`),`success`)}function Et({senderAccount:t,recipientAccount:n,message:r,setCipherText:i,setDecryptedText:a,setError:s}){if(!t||!n){s(e(`web3.error.accountsRequired`));return}if(!r.trim()){s(e(`web3.error.messageRequired`));return}i(o(r,{senderPrivateKey:t.privateKey,recipientPublicKey:n.publicKey})),a(``),s(``)}function Dt({senderAccount:t,recipientAccount:n,cipherText:r,setDecryptedText:i,setError:a}){if(!t||!n){a(e(`web3.error.accountsRequired`));return}if(!r.trim()){a(e(`web3.error.cipherRequired`));return}let o=l(r,{senderPublicKey:t.publicKey,recipientPrivateKey:n.privateKey});if(!o){a(e(`web3.error.decryptFailed`)),i(``);return}i(o),a(``)}function Ot(){if(!nt.trim()){Z(e(`web3.error.senderPublicRequired`));return}if(!it.trim()){Z(e(`web3.error.recipientPrivateRequired`));return}if(!ot.trim()){Z(e(`web3.error.cipherRequired`));return}let t=l(ot,{senderPublicKey:nt.trim(),recipientPrivateKey:it.trim()});if(!t){Z(e(`web3.error.decryptFailed`)),lt(``);return}lt(t),Z(``)}function kt(){if(!Q.trim()){$(e(`web3.error.senderPrivateRequired`));return}if(!mt.trim()){$(e(`web3.error.recipientPublicRequired`));return}if(!gt.trim()){$(e(`web3.error.messageRequired`));return}yt(o(gt,{senderPrivateKey:Q.trim(),recipientPublicKey:mt.trim()})),$(``)}let At=()=>{if(!A)return;let e=[];for(let t=M;t<M+10;t++){let n=`m/44'/60'/0'/0/${t}`,r=u.fromPhrase(A,void 0,n);e.push({index:t,address:r.address,privateKey:r.privateKey})}me(t=>[...t,...e]),N(e=>e+10)},jt=f(E?.address||void 0),Mt=r===`wallet`?`web3.view.wallet`:r===`pem`?`web3.view.pem`:r===`EA`?`web3.view.asymmetric`:`web3.view.export`,Nt=[{id:`wallet`,icon:(0,k.jsx)(g,{size:16}),labelKey:`web3.view.wallet`},{id:`pem`,icon:(0,k.jsx)(v,{size:16}),labelKey:`web3.view.pem`},{id:`export`,icon:(0,k.jsx)(ne,{size:16}),labelKey:`web3.view.export`},{id:`EA`,icon:(0,k.jsx)(T,{size:16}),labelKey:`web3.view.asymmetric`}],Pt=r!==`EA`;return(0,k.jsx)(ee,{sidebar:({closeSidebar:t})=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(te,{onNavigate:t}),(0,k.jsx)(`nav`,{className:`sidebar-nav`,children:Nt.map(n=>(0,k.jsxs)(`button`,{onClick:()=>{Ct(n.id),t()},className:`sidebar-nav-btn ${r===n.id?`active`:``}`,children:[n.icon,(0,k.jsx)(`span`,{children:e(n.labelKey)})]},n.id))})]}),headerTitle:(0,k.jsx)(`h2`,{className:`header-title`,children:e(Mt)}),children:(0,k.jsx)(`div`,{className:`web3-page`,children:(0,k.jsxs)(`div`,{className:`web3-container ${r===`EA`?`wide`:``}`,children:[Pt&&(0,k.jsx)(Oe,{username:m,password:y,showPassword:x,generating:ve,onUsernameChange:_,onPasswordChange:b,onTogglePassword:()=>C(!x),onGenerate:wt}),r===`wallet`&&(0,k.jsx)(De,{walletResult:E,keys:re,ipns:ae,avatarSrc:jt,showPrivateKey:W,onTogglePrivateKey:()=>_e(!W)}),r===`pem`&&(0,k.jsx)(pe,{walletResult:E,publicPem:le,privatePem:se}),r===`export`&&(0,k.jsx)(Te,{walletResult:E,mnemonicPhrase:A,deriveBatch:10,deriveList:fe,deriveShowIndex:P,deriveShowAddress:F,deriveShowPrivateKey:L,showAddressQr:ge,showMnemonicReveal:B,showMnemonicQr:H,onToggleAddressQr:()=>z(!ge),onToggleMnemonicReveal:()=>V(!B),onToggleMnemonicQr:()=>U(!H),onToggleDeriveIndex:()=>he(!P),onToggleDeriveAddress:()=>I(!F),onToggleDerivePrivateKey:()=>R(!L),onDerive:At}),r===`EA`&&(0,k.jsx)(de,{boxAUsername:G,boxAPassword:xe,boxAShowPassword:K,boxAShowPrivateKey:we,boxAAccount:J,boxBUsername:Y,boxBPassword:Ne,boxBShowPassword:Fe,boxBShowPrivateKey:Le,boxBAccount:X,boxABMessage:Be,boxABCipherText:He,boxABDecryptedText:We,boxABError:Ke,boxBAMessage:Je,boxBACipherText:Xe,boxBADecryptedText:Qe,boxBAError:et,boxEncryptSenderPrivateKey:Q,boxEncryptRecipientPublicKey:mt,boxEncryptMessage:gt,boxEncryptCipherText:vt,boxEncryptError:bt,boxEncryptShowPrivateKey:xt,boxDecryptSenderPublicKey:nt,boxDecryptRecipientPrivateKey:it,boxDecryptCipherText:ot,boxDecryptResult:ct,boxDecryptError:ut,boxDecryptShowPrivateKey:dt,onBoxAUsernameChange:be,onBoxAPasswordChange:Se,onBoxAShowPasswordToggle:()=>Ce(!K),onBoxAShowPrivateKeyToggle:()=>q(!we),onGenerateBoxA:()=>Tt(G,xe,Ee),onBoxBUsernameChange:je,onBoxBPasswordChange:Pe,onBoxBShowPasswordToggle:()=>Ie(!Fe),onBoxBShowPrivateKeyToggle:()=>Re(!Le),onGenerateBoxB:()=>Tt(Y,Ne,ze),onBoxABMessageChange:Ve,onBoxABCipherTextChange:Ue,onEncryptBoxAB:()=>Et({senderAccount:J,recipientAccount:X,message:Be,setCipherText:Ue,setDecryptedText:Ge,setError:qe}),onDecryptBoxAB:()=>Dt({senderAccount:J,recipientAccount:X,cipherText:He,setDecryptedText:Ge,setError:qe}),onBoxBAMessageChange:Ye,onBoxBACipherTextChange:Ze,onEncryptBoxBA:()=>Et({senderAccount:X,recipientAccount:J,message:Je,setCipherText:Ze,setDecryptedText:$e,setError:tt}),onDecryptBoxBA:()=>Dt({senderAccount:X,recipientAccount:J,cipherText:Xe,setDecryptedText:$e,setError:tt}),onBoxEncryptSenderPrivateKeyChange:pt,onBoxEncryptRecipientPublicKeyChange:ht,onBoxEncryptMessageChange:_t,onBoxEncryptShowPrivateKeyToggle:()=>St(!xt),onEncryptOnly:kt,onBoxDecryptSenderPublicKeyChange:rt,onBoxDecryptRecipientPrivateKeyChange:at,onBoxDecryptCipherTextChange:st,onBoxDecryptShowPrivateKeyToggle:()=>ft(!dt),onDecryptOnly:Ot})]})})})}var Pe=m(`/web3/`)({component:Ne});export{Pe as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,R as i,_ as a,f as o,it as s,rt as c,tt as l,x as u}from"./avatar-BZwHW4ll.js";import{a as d}from"./i18n-DZaOYCSO.js";import{t as f}from"./download-Q1uCiwif.js";import{t as ee}from"./external-link-DGzNJOqQ.js";import{t as te}from"./file-text-C3v0L_lQ.js";import{t as ne}from"./hard-drive-B2V5USzR.js";import{n as p,t as m}from"./triangle-alert-DnOxsFpB.js";import{l as re,s as h}from"./index-DluhgSHX.js";import{t as ie}from"./MarketingHeader-7B-OT2XX.js";import{t as g}from"./format-CR8oUWq6.js";import{i as ae,n as _,r as oe,t as v}from"./downloadValidation-Ch966YTl.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}=d(),{cid:t}=s({from:`/cid/$cid/`}),n=re({select:e=>e.searchStr}),r=o(e=>e.hasBackend),l=o(e=>e.addToast),h=o(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)(()=>ae(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 oe(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 u(`/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})}),l(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),l(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),l(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[l,Y,e,L,T]);let ge=async()=>{if(!T){E();return}if(r!==!0){h();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})}),l(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),l(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await a(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),l(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)(ee,{size:16}),e(`cid.handoff.action`)]})]}),me&&(0,C.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,C.jsx)(m,{size:18}),(0,C.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,C.jsxs)(c,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(f,{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)(te,{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)(ne,{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:h,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)(f,{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)(c,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})]})}function ue(e,t){return t===`completed`?(0,C.jsx)(h,{size:28}):t===`error`||e===`error`?(0,C.jsx)(m,{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)(h,{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=l(`/cid/$cid/`)({component:O});export{k as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,Q as i,R as a,_ as o,c as s,f as c,n as l,o as u,p as d,s as ee,tt as f,u as te}from"./avatar-BZwHW4ll.js";import{a as p}from"./i18n-DZaOYCSO.js";import{t as m}from"./arrow-right-DUxAoZqb.js";import{t as h}from"./circle-alert-DSZ0bG_3.js";import{t as g}from"./download-Q1uCiwif.js";import{t as _}from"./file-text-C3v0L_lQ.js";import{a as v,i as ne,n as re,r as ie,t as ae}from"./FilePreviewOverlay-CZp6F1s_.js";import{t as oe}from"./loader-CLoDCtNy.js";import{i as se,n as ce,t as le}from"./SidebarHomeLink-CkhGDvZ8.js";import{t as ue}from"./message-square-C8ZiYztG.js";import{t as y}from"./music-BsTA8b_M.js";import{t as de}from"./OpenSidebarButton-BoSmO8CY.js";import{t as fe}from"./plus-D1kCYb8G.js";import{t as pe}from"./search-DAV9vDOq.js";import{t as me}from"./trash-2-CE-3Dc63.js";import{a as he}from"./index-DluhgSHX.js";import{t as ge}from"./format-CR8oUWq6.js";import{n as _e,r as ve,t as ye}from"./downloadValidation-Ch966YTl.js";import{t as be}from"./LogoIcon-B2fFe0l1.js";import{i as b,t as xe}from"./userProfile-UphvP_bG.js";import{t as Se}from"./useChannelMessages-Bs_RWgO4.js";var Ce=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`}]]),we=r(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Te=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`}]]),Ee=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`}]]),De=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`}]]),Oe=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`}]]),x=t(e(),1),S=n();function ke(e){return String(e||``).split(`/`).pop()||e}function Ae(e){return e===`image`?(0,S.jsx)(ne,{size:20}):e===`video`?(0,S.jsx)(v,{size:20}):e===`audio`?(0,S.jsx)(y,{size:20}):(0,S.jsx)(_,{size:20})}function je({attachment:e,status:t=`idle`,pending:n=!1,onOpen:r}){let{t:i}=p(),a=t===`checking`,o=`ui-file-action chat-attachment-action ${t===`error`?`error`:t===`available`?`available`:``}`.trim(),s=Number.isFinite(e.size)&&e.size>0?ge(e.size):i(`chat.mostboxFile`);return(0,S.jsxs)(`button`,{type:`button`,className:`ui-file-card chat-attachment-card`,onClick:()=>r?.(e),disabled:n||a,title:e.link,translate:`no`,children:[(0,S.jsx)(`span`,{className:`ui-file-icon chat-attachment-icon ${e.kind}`,children:a?(0,S.jsx)(oe,{size:20,className:`ui-spinner chat-attachment-spinner`}):Ae(e.kind)}),(0,S.jsxs)(`span`,{className:`ui-file-info chat-attachment-info`,children:[(0,S.jsx)(`span`,{className:`ui-file-name chat-attachment-name`,translate:`no`,children:ke(e.fileName)}),(0,S.jsx)(`span`,{className:`ui-file-meta chat-attachment-meta`,translate:`yes`,children:n?i(`chat.sending`):s})]}),(0,S.jsx)(`span`,{className:o,translate:`yes`,children:a?i(`chat.checking`):t===`available`?(0,S.jsx)(he,{size:16}):t===`error`?(0,S.jsx)(h,{size:17}):(0,S.jsx)(g,{size:16})})]})}var C=[{key:`image`,labelKey:`chat.attachment.image`,accept:`image/*`,icon:ne},{key:`video`,labelKey:`chat.attachment.video`,accept:`video/*`,icon:v},{key:`file`,labelKey:`chat.attachment.file`,accept:``,icon:_}],w=C.map(e=>e.accept).join(`,`);function Me({children:e}){return(0,S.jsx)(`div`,{className:`message-bubble`,translate:`no`,children:e})}function Ne({children:e}){return(0,S.jsx)(`div`,{className:`message-bubble has-attachment`,children:e})}function Pe({variant:e,pending:t=!1,avatarSrc:n,isOnline:r=!1,author:i,time:a,children:o}){return(0,S.jsxs)(`div`,{className:[`chat-message`,e,t?`pending`:``].filter(Boolean).join(` `),children:[(0,S.jsxs)(`span`,{className:`chat-avatar-wrap`,children:[(0,S.jsx)(`img`,{className:`msg-avatar`,src:n,alt:`avatar`}),r&&(0,S.jsx)(`span`,{className:`chat-online-dot`,"aria-hidden":`true`})]}),(0,S.jsxs)(`div`,{className:`msg-content`,children:[(0,S.jsx)(`span`,{className:`message-author`,translate:`no`,children:i}),o,(0,S.jsx)(`span`,{className:`message-time`,children:a})]})]})}function Fe({active:e=!1,pinned:t=!1,unread:n=!1,title:r,onSelect:i,onTogglePin:a,onRename:o,onLeave:s}){let{t:c}=p(),l=!!(a||o||s);return(0,S.jsxs)(`div`,{className:[`sidebar-nav-btn`,e?`active`:``,t?`pinned`:``,n?`unread`:``].filter(Boolean).join(` `),onClick:i,role:`button`,tabIndex:0,onKeyDown:e=>{e.target===e.currentTarget&&e.key===`Enter`&&i?.()},children:[(0,S.jsxs)(`span`,{className:`chat-channel-icon-wrap`,children:[(0,S.jsx)(ue,{size:16}),n&&(0,S.jsx)(`span`,{className:`chat-channel-unread-dot`,title:c(`chat.unread`),"aria-hidden":`true`})]}),(0,S.jsx)(`span`,{className:`chat-channel-title`,children:(0,S.jsx)(`span`,{className:`chat-channel-title-text`,translate:`no`,children:r})}),l&&(0,S.jsx)(u,{ariaLabel:c(`chat.channelActions`),className:`channel-actions-anchor`,placement:`bottom-end`,items:[{key:`pin`,label:c(t?`chat.unpin`:`chat.pin`),icon:t?(0,S.jsx)(De,{size:16}):(0,S.jsx)(Ee,{size:16}),onSelect:()=>a?.()},{key:`rename`,label:c(`chat.rename`),icon:(0,S.jsx)(ie,{size:16}),onSelect:()=>o?.()},{key:`delete`,label:c(`chat.delete`),icon:(0,S.jsx)(me,{size:16}),onSelect:()=>s?.()}],renderTrigger:e=>(0,S.jsx)(`button`,{...e,className:`leave-channel-btn channel-actions-trigger`,title:c(`common.moreActions`),"aria-label":c(`common.moreActions`),children:(0,S.jsx)(we,{size:16})})})]})}function Ie({members:e}){let{t}=p();return e.length===0?(0,S.jsx)(`div`,{className:`ui-empty-inline channel-members-empty`,children:t(`chat.noMembers`)}):(0,S.jsx)(`div`,{className:`channel-members-grid`,children:e.map(e=>(0,S.jsxs)(`div`,{className:`channel-member`,children:[(0,S.jsxs)(`span`,{className:`channel-member-avatar-wrap`,children:[(0,S.jsx)(`img`,{className:`channel-member-avatar`,src:e.avatarSrc,alt:`avatar`}),e.online&&(0,S.jsx)(`span`,{className:`chat-online-dot`,"aria-hidden":`true`})]}),(0,S.jsx)(`span`,{className:`channel-member-name`,translate:`no`,children:e.name})]},e.id))})}function Le({message:e,placeholder:t,disabled:n=!1,isPublishingAttachment:r=!1,attachmentButtonTitle:i,attachmentInputRef:a,onMessageChange:o,onSend:s,onSelectAttachmentFiles:c}){let{t:l}=p(),d=n||r,ee=n||!e.trim(),f=i||l(`chat.attachment.add`);function te(e,t){t?.(e.currentTarget.files),e.currentTarget.value=``}function h(t){t.key===`Enter`&&e.trim()&&s()}function g(e){if(d)return;let t=a?.current;t&&(t.accept=e,t.click())}return(0,S.jsxs)(`div`,{className:`chat-input-area`,children:[(0,S.jsx)(`input`,{ref:a,type:`file`,accept:w,className:`chat-file-input`,onChange:e=>te(e,c)}),(0,S.jsx)(u,{ariaLabel:l(`chat.attachmentType`),placement:`top-start`,disabled:d,items:C.map(e=>{let t=e.icon;return{key:e.key,label:l(e.labelKey),icon:(0,S.jsx)(t,{size:16}),onSelect:()=>g(e.accept)}}),renderTrigger:e=>(0,S.jsx)(`button`,{...e,className:`btn btn-circle chat-tool-btn`,"aria-label":f,children:r?(0,S.jsx)(oe,{size:18,className:`ui-spinner chat-attachment-spinner`}):(0,S.jsx)(fe,{size:18})})}),(0,S.jsx)(`input`,{type:`text`,className:`input input-pill`,placeholder:t,value:e,disabled:n,onChange:e=>o(e.target.value),onKeyDown:h}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-circle btn-primary send-btn`,onClick:s,disabled:ee,title:l(`chat.sendMessage`),children:(0,S.jsx)(m,{size:18})})]})}var Re=`mostbox.chat.lastReadAt`;function T(e){return Date.parse(e?.lastMessageAt||``)||Date.parse(e?.createdAt||``)||0}function ze(e){let t=String(e||``).trim().toLowerCase();return t?`${Re}:${t}`:``}function E(e,t=Date.now()){let n=Number(e);return Math.max(0,Math.floor(Number.isFinite(n)&&n>0?n:t))}function Be(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 Ve(e,t,n=D()){if(!(!e||!n))try{n.setItem(e,JSON.stringify(t))}catch{}}function He(e,t,n=Date.now(),r=Date.now()){if(!t)return{changed:!1,value:e};let i=E(n,r);return(e[t]||0)>=i?{changed:!1,value:e}:{changed:!0,value:{...e,[t]:i}}}function Ue(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]=E(T(e),n),r=!0)}return{changed:r,value:r?i:e}}function We(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=E(n,o),c=t===r,l=String(i||``).toLowerCase()===String(a||``).toLowerCase();if(c||l)return{...He(e,t,s,o),notify:!1};let u=e[t]||0;if(u<s)return{changed:!1,notify:!0,value:e};let d=Math.max(0,s-1);return u===d?{changed:!1,notify:!0,value:e}:{changed:!0,notify:!0,value:{...e,[t]:d}}}function Ge(e,t){let n=e?.channelKey||e?.name;return T(e)>(t[n]||0)}function D(){if(!(typeof window>`u`))return window.localStorage}var Ke=3,qe=30,Je=/^[a-zA-Z0-9_-]+$/,Ye=1e4,Xe=12e3,Ze=1200;function O(e){return e?.channelKey||e?.name||``}function k(e){return e?.channelId||e?.name||``}function A(e){return e?.remark||k(e)}function Qe(){return typeof window>`u`?``:(new URLSearchParams(window.location.search).get(`channel`)||``).trim()}var $e=`chat-file`;function et(e,t){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:e.type.startsWith(`audio/`)?`audio`:e.type.startsWith(`text/`)?`text`:re(t)}function tt(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:`Unknown`}function nt(e){return/#[a-fA-F0-9]{4}$/.test(String(e||``).trim())}function j(e){return String(e||``).trim().toLowerCase()}function rt(){if(typeof window>`u`)return;let e=window;return e.AudioContext||e.webkitAudioContext}function it(){let e=c(e=>e.hasBackend),t=c(e=>e.addToast),n=c(e=>e.openConnectModal),r=a(e=>e.identity),u=a(e=>e.openLoginModal),[f,m]=(0,x.useState)([]),[h,g]=(0,x.useState)(null),[_,v]=(0,x.useState)(``),[ne,y]=(0,x.useState)(!1),[me,he]=(0,x.useState)(``),[ge,we]=(0,x.useState)(``),[Ee,De]=se(!1),[Ae,C]=(0,x.useState)(``),[w,Re]=(0,x.useState)(!1),[E,D]=(0,x.useState)(!1),[it,M]=se(!1),[at,N]=(0,x.useState)(null),[P,ot]=(0,x.useState)(null),[st,F]=(0,x.useState)(!1),[ct,lt]=(0,x.useState)(``),[ut,dt]=(0,x.useState)(!1),[ft,pt]=(0,x.useState)(null),[mt,ht]=(0,x.useState)(!1),[I,L]=(0,x.useState)({}),[R,z]=(0,x.useState)(null),[gt,_t]=(0,x.useState)(!1),[vt,yt]=(0,x.useState)(!1),[bt,B]=(0,x.useState)({}),[xt,St]=(0,x.useState)([]),V=r?.identity===`user`,Ct=V&&!vt?r.logo:``,wt=(0,x.useRef)(null),Tt=(0,x.useRef)(null),Et=(0,x.useRef)(``),Dt=(0,x.useRef)(new Set),Ot=(0,x.useRef)(new Set),H=(0,x.useRef)(null),kt=(0,x.useRef)(!1),At=(0,x.useRef)(0),U=(0,x.useRef)(new Map),W=(0,x.useRef)(new Set),G=e===!0,{t:K,compareStrings:jt,formatDate:Mt,formatTime:Nt}=p(),q=(0,x.useCallback)(async(e,n)=>{t(await o(e,n),`error`)},[t]),J=(0,x.useMemo)(()=>ze(r?.address),[r?.address]),Pt=(0,x.useCallback)((e,t=Date.now())=>{e&&B(n=>{let r=He(n,e,t);return r.changed?(Ve(J,r.value),r.value):n})},[J]),Y=(0,x.useCallback)(()=>{if(kt.current||typeof window>`u`)return;let e=rt();if(e)try{let t=H.current||new e;H.current=t,t.state===`suspended`&&t.resume().catch(()=>{}),kt.current=!0}catch{}},[]),Ft=(0,x.useCallback)(()=>{if(!kt.current)return;let e=Date.now();if(e-At.current<Ze)return;At.current=e;let t=rt();if(t)try{let e=H.current||new t;if(H.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{}},[]),It=(0,x.useCallback)(async(e=h)=>{let t=O(e);if(!t||!G){St([]);return}try{let e=await b.getChannelPresence(t);if(Et.current!==t)return;St(e)}catch(e){console.warn(`[Chat] Failed to fetch channel presence:`,e instanceof Error?e.message:e)}},[h,G]);function Lt(e,n){switch(e){case`channel:message`:{let e=n?.channelKey||n?.channel,t=n?.message,i=Number(t?.timestamp)||Date.now();if(e){m(t=>t.map(t=>O(t)===e?{...t,lastMessageAt:new Date(i).toISOString()}:t));let n=e===Et.current;B(a=>{let o=We(a,{channelName:e,messageTime:i,activeChannelName:n?e:``,messageAuthor:t?.author,userAddress:r?.address});return o.changed&&Ve(J,o.value),o.notify&&Ft(),o.changed?o.value:a})}break}case`channel:presence`:{let e=n?.channelKey||n?.channel;h&&(!e||e===O(h))&&It(h);break}case`channel:joined`:case`channel:left`:$();break;case`user:metadata:updated`:n?.scope===`channels`&&$();break;case`download:success`:{let e=U.current.get(n.taskId);e&&(U.current.delete(n.taskId),W.current.delete(e.cid),L(t=>({...t,[e.cid]:{status:`available`}})),t(K(`chat.attachment.downloadCompleted`,{fileName:n.fileName||ke(e.fileName)}),`success`),Yt(e,n.fileName||e.fileName));break}case`download:error`:case`download:cancelled`:{let r=U.current.get(n.taskId);r&&(U.current.delete(n.taskId),W.current.delete(r.cid),L(t=>({...t,[r.cid]:{status:`error`,message:e===`download:cancelled`?K(`chat.attachment.downloadCancelled`):n.error||K(`chat.attachment.downloadFailed`)}})),t(e===`download:cancelled`?K(`chat.attachment.downloadCancelled`):n.error||K(`chat.attachment.downloadFailed`),`error`));break}}}let Rt=(0,x.useMemo)(()=>f.map(e=>O(e)),[f]),zt=(0,x.useMemo)(()=>r?{...xe(r),profileUpdatedAt:r.profileUpdatedAt}:{},[r?.avatar,r?.displayName,r?.profileUpdatedAt,r?.username]),{clearMessages:Bt,messages:X,sendMessage:Vt,syncMessages:Ht}=Se({isReady:G,enabled:!!r,channelName:O(h),extraSubscribedChannelNames:Rt,peerId:Ae,waitForPeerId:!0,onSyncError:e=>q(e,K(`chat.error.messages`)),onSocketEvent:Lt,onReconnect:()=>{$(),h&&It(h)},presenceEnabled:!!(h&&r),presenceProfile:zt}),Ut=(0,x.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]),Wt=(0,x.useMemo)(()=>new Map(Ut.map(e=>[j(e.address),e])),[Ut]),Gt=(0,x.useMemo)(()=>{let e=new Map;return xt.forEach(t=>{let n=j(t.address);!n||!t.online||e.set(n,t)}),e},[xt]),Kt=(0,x.useMemo)(()=>{let e=new Map(Wt);return xt.forEach((t,n)=>{let r=j(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:Ut.length+n})}),[...e.values()]},[Ut,xt,Wt]),qt=(0,x.useMemo)(()=>new Set(Gt.keys()),[Gt]);function Z(){return G?!0:(n(),!1)}function Q(){return r?!0:(u(),!1)}(0,x.useEffect)(()=>{let e=()=>{v(Qe())};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,x.useEffect)(()=>{r&&v(Qe())},[r?.address]),(0,x.useEffect)(()=>{yt(!1)},[r?.logo]),(0,x.useEffect)(()=>{Et.current=O(h)},[h]),(0,x.useEffect)(()=>{B(Be(J))},[J]),(0,x.useEffect)(()=>{!J||f.length===0||B(e=>{let t=Ue(e,f);return t.changed&&Ve(J,t.value),t.changed?t.value:e})},[J,f]),(0,x.useEffect)(()=>(window.addEventListener(`pointerdown`,Y,{passive:!0}),window.addEventListener(`keydown`,Y),()=>{window.removeEventListener(`pointerdown`,Y),window.removeEventListener(`keydown`,Y)}),[Y]),(0,x.useEffect)(()=>()=>{H.current?.close().catch(()=>{}),H.current=null,kt.current=!1},[]),(0,x.useEffect)(()=>{wt.current?.scrollIntoView({behavior:`smooth`})},[X]),(0,x.useEffect)(()=>{if(!G){C(``);return}d.get(`/api/node-id`).json().then(e=>C(e.id)).catch(e=>{console.warn(`[Chat] Failed to fetch node ID:`,e.message),q(e,K(`chat.error.nodeId`))})},[G,q,K]),(0,x.useEffect)(()=>{G&&r?(y(!1),$()):y(!1)},[e,G,r?.address]),(0,x.useEffect)(()=>{if(h){if(G){let e=O(h);St([]),Ht(e,{replace:!0}),It(h)}}else St([])},[h,G,It,Ht]),(0,x.useEffect)(()=>{if(!_)return;if(!r){Ot.current.has(_)||(Ot.current.add(_),u());return}if(!G||!ne)return;let e=f.find(e=>O(e)===_)||f.find(e=>k(e)===_);if(e&&(!h||O(h)!==O(e))){$t(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 n=`${r.address}:${_}`;if(Dt.current.has(n)||w)return;let i=Jt(_);if(Dt.current.add(n),i){t(i,`error`);return}nn(_)},[f,h,_,ne,G,w,r?.address]),(0,x.useEffect)(()=>{r||(m([]),y(!1),g(null),v(Qe()),ot(null),Bt(),we(``),C(``),F(!1),pt(null),L({}),B({}),W.current.clear(),U.current.clear())},[Bt,r?.address]);function Jt(e){return e.length<Ke?K(`chat.validation.nameMin`,{count:Ke}):e.length>qe?K(`chat.validation.nameMax`,{count:qe}):e.includes(`.`)?K(`chat.validation.dotReserved`):Je.test(e)?``:K(`chat.validation.allowedChars`)}async function $(){if(!G){y(!1);return}try{m(await b.getChannels()),y(!0)}catch(e){m([]),y(!1),await q(e,K(`chat.error.channelList`))}}function Yt(e,t=e.fileName){let n=re(t);pt({cid:e.cid,fileName:t,subtype:n===`file`?e.kind:n})}async function Xt(e){let t=ye(e.link,K);if(t)return L(n=>({...n,[e.cid]:{status:`error`,message:t}})),!1;try{L(t=>({...t,[e.cid]:{status:`checking`}}));let t=await _e.checkDownload(e.link,{timeout:Ye,requestTimeout:Xe});return L(n=>({...n,[e.cid]:{status:`available`,message:t.alreadyExists?K(`chat.attachment.localAvailable`):K(`chat.attachment.previewAvailable`)}})),!0}catch(t){let n=await ve(t);return L(t=>({...t,[e.cid]:{status:`error`,message:n}})),!1}}async function Zt(e){z(null),await Xt(e)&&await Qt(e)}async function Qt(e){if(!W.current.has(e.cid)){W.current.add(e.cid),L(t=>({...t,[e.cid]:{status:`available`}}));try{let n=await _e.downloadFile(e.link);if(n.alreadyExists||n.fileName){W.current.delete(e.cid),L(t=>({...t,[e.cid]:{status:`available`}})),Yt({...e,fileName:n.fileName||e.fileName},n.fileName||e.fileName);return}n.taskId&&(U.current.set(n.taskId,e),t(K(`chat.attachment.downloadStarted`),`success`))}catch(t){let n=await ve(t);W.current.delete(e.cid),L(t=>({...t,[e.cid]:{status:`error`,message:n}}))}}}async function $t(e){if(!Q()||!Z())return;let t=O(e);Pt(t,Math.max(T(e),Date.now())),g(e),v(t),window.history.pushState({},``,`?channel=${encodeURIComponent(t)}`)}async function en(e,t){if(t&&t.stopPropagation(),Q()&&Z()&&!E){D(!0);try{if(await b.leaveChannel(e),O(h)===e){g(null),v(``),Bt();let e=new URL(window.location.href);e.searchParams.delete(`channel`),window.history.pushState({},``,e.pathname)}$(),M.close(),N(null)}catch(e){await q(e,K(`chat.error.leave`))}finally{D(!1)}}}async function tn(e){if(!Q()||!Z())return;let t=!e.pinned,n=O(e);try{let e=await b.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 q(e,K(t?`chat.error.pin`:`chat.error.unpin`))}}async function nn(e){let n=e.trim();if(!n||w)return;let i=Jt(n);if(i){t(i,`error`);return}if(Q()&&Z()){Re(!0);try{let e=await b.createChannel(n,`public`,xe(r)),t=e.channelKey||e.key||e.name||n,i=f.find(e=>O(e)===t),a={...i,name:e.name||n,channelId:e.channelId||e.name||n,channelKey:e.channelKey||e.key||i?.channelKey,type:e.type||i?.type||`public`,createdAt:e.createdAt||i?.createdAt,coreKey:e.coreKey||e.key||i?.coreKey,localWriterCoreKey:e.localWriterCoreKey||i?.localWriterCoreKey,writerCoreKeys:e.writerCoreKeys||i?.writerCoreKeys,remark:e.remark||i?.remark},o=O(a);m(e=>e.some(e=>O(e)===o)?e.map(e=>O(e)===o?{...e,...a}:e):[...e,a]),De.close(),await $t(a),$()}catch(e){await q(e,K(`chat.error.join`))}finally{Re(!1)}}}async function rn(e,t){if(!e.trim()||!h||!Q()||!Z())return!1;let n=e.trim(),r=O(h);try{let e=await Vt({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&&Pt(r,Number(e.timestamp)||Date.now()),!0}catch(e){return await q(e,K(`chat.error.send`)),!1}}async function an(){if(!ge.trim())return;let e=ge.trim();we(``),await rn(e)}function on(e,t){return`${$e}/${e}/${t}`}async function sn(e){if(!(!e||e.length===0||!h)&&Q()&&Z()&&!mt){ht(!0);try{for(let n of Array.from(e)){let e=on(k(h),n.name),r=await _e.publishFile(n,e),i=r.fileName||e,a=r.link||`most://${r.cid}?filename=${encodeURIComponent(i)}`;await rn(a,{kind:et(n,i),cid:r.cid,fileName:i,link:a,mimeType:n.type||void 0,size:n.size})&&t(K(`chat.attachment.published`,{fileName:ke(i)}),`success`)}}catch(e){await q(e,K(`chat.error.attachmentSend`))}finally{ht(!1)}}}async function cn(e){if(!Q()||!Z())return;let t=I[e.cid];if(t?.status!==`checking`){if(t?.status===`error`){z(e);return}if(t?.status!==`available`){await Xt(e)&&await Qt(e);return}await Qt(e)}}async function ln(e,t){if(!Q()||!Z())return;let n=O(e),r=await b.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 un(){if(h)try{await ln(h,ct)}catch(e){await q(e,K(`chat.error.remark`))}}async function dn(e){if(!(!P||ut)){dt(!0);try{await ln(P,e),ot(null)}catch(e){await q(e,K(`chat.error.rename`))}finally{dt(!1)}}}function fn(e){if(!e.attachment)return(0,S.jsx)(Me,{children:e.content});let t=e.attachment,n=I[t.cid]?.status;return(0,S.jsx)(Ne,{children:(0,S.jsx)(je,{attachment:t,status:n,pending:e.pending,onOpen:cn})})}function pn(e,t){let n=String(e||``).trim();return n?gt?nt(n)?n:t?`${n}#${t.slice(-4).toUpperCase()}`:n:n.replace(/#[a-fA-F0-9]{4}$/,``):tt(t)}function mn(){return(0,S.jsx)(Ie,{members:Kt.map(e=>{let t=Gt.get(j(e.address)),n=t?.displayName||e.displayName,r=t?.avatar||e.avatar;return{id:e.address,name:pn(n,e.address),avatarSrc:l(e.address,r),online:qt.has(j(e.address))}})})}let hn=V&&!!_&&!h,gn=h?(0,S.jsx)(`h2`,{className:`header-title`,translate:`no`,children:A(h)}):(0,S.jsx)(`h2`,{className:`header-title`,children:K(`chat.title`)}),_n=me.trim().toLowerCase(),vn=(0,x.useMemo)(()=>[...f].sort((e,t)=>{let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n;let r=T(t)-T(e);return r===0?jt(A(e),A(t)):r}),[f,jt]),yn=_n?vn.filter(e=>[A(e),k(e),O(e)].some(e=>e.toLowerCase().includes(_n))):vn;return(0,S.jsxs)(ce,{className:`chat-app-layout`,defaultHide:V,sidebar:({closeSidebar:e})=>(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(le,{onNavigate:e}),(0,S.jsx)(`div`,{className:`chat-channel-search`,children:(0,S.jsxs)(`div`,{className:`ui-input-control`,children:[(0,S.jsx)(pe,{className:`ui-input-icon`,size:15}),(0,S.jsx)(`input`,{type:`search`,className:`input input-compact`,placeholder:K(`chat.search.placeholder`),value:me,onChange:e=>he(e.target.value),"aria-label":K(`chat.search.placeholder`)})]})}),(0,S.jsx)(`nav`,{className:`sidebar-nav`,children:f.length===0?(0,S.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,S.jsx)(`p`,{children:K(`chat.empty.noChannels`)})}):yn.length===0?(0,S.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,S.jsx)(`p`,{children:K(`chat.empty.noMatches`)})}):yn.map(t=>(0,S.jsx)(Fe,{active:O(h)===O(t),pinned:!!t.pinned,unread:Ge(t,bt),title:A(t),onSelect:()=>{$t(t),e()},onTogglePin:()=>void tn(t),onRename:()=>ot(t),onLeave:()=>{N(t),M.open()}},O(t)))}),(0,S.jsxs)(`button`,{className:`ui-action-dashed create-channel-btn`,onClick:()=>{!Q()||!Z()||De.open()},children:[(0,S.jsx)(fe,{size:16}),K(`chat.joinChannel`)]})]}),headerTitle:gn,sidebarToggleReplacement:V?(0,S.jsx)(`span`,{className:`sidebar-toggle-static-logo`,"aria-hidden":`true`,children:Ct?(0,S.jsx)(`img`,{className:`sidebar-toggle-static-logo-img`,src:Ct,alt:``,onError:()=>yt(!0)}):(0,S.jsx)(be,{size:18})}):void 0,headerRight:(0,S.jsx)(`div`,{className:`header-right-actions`,children:h&&(0,S.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>F(!0),title:K(`chat.channelSettings`),children:(0,S.jsx)(Oe,{size:16})})}),children:[h?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`chat-messages`,children:[X.length===0?(0,S.jsxs)(`div`,{className:`ui-empty-state chat-messages-empty`,children:[(0,S.jsx)(`div`,{className:`ui-empty-icon empty-icon`,children:(0,S.jsx)(ue,{size:28})}),(0,S.jsx)(`p`,{children:K(`chat.empty.noMessages`)})]}):X.map(e=>{let t=e.author?.toLowerCase()===r?.address.toLowerCase(),n=Gt.get(j(e.author)),i=Wt.get(j(e.author)),a=qt.has(j(e.author)),o=n?.displayName||i?.displayName||e.authorName,s=n?.avatar||i?.avatar||e.avatar||(t?r.avatar:void 0);return(0,S.jsx)(Pe,{variant:t?`self`:`other`,pending:e.pending,isOnline:a,avatarSrc:l(e.author,s),author:pn(o,e.author),time:Nt(e.timestamp),children:fn(e)},e.id||`${e.author}-${e.timestamp}`)}),(0,S.jsx)(`div`,{ref:wt})]}),(0,S.jsx)(Le,{message:ge,placeholder:K(r?`chat.composer.placeholder`:`chat.composer.signInPlaceholder`),disabled:!r,isPublishingAttachment:mt,attachmentInputRef:Tt,onMessageChange:we,onSend:an,onSelectAttachmentFiles:e=>{sn(e)}})]}):hn?(0,S.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,S.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,S.jsx)(oe,{size:36,className:`ui-spinner`})}),(0,S.jsx)(`h2`,{className:`ui-empty-title`,children:K(`chat.restoring.title`)}),(0,S.jsx)(`p`,{className:`ui-empty-desc`,children:K(`chat.restoring.desc`)})]}):(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,S.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,S.jsx)(ue,{size:36})}),(0,S.jsx)(`h2`,{className:`ui-empty-title`,children:K(`chat.select.title`)}),(0,S.jsx)(`p`,{className:`ui-empty-desc`,children:K(`chat.select.desc`)}),(0,S.jsx)(de,{label:K(`chat.openChannelList`)})]})}),Ee&&(0,S.jsx)(ee,{title:K(`chat.joinChannel`),placeholder:K(`chat.join.placeholder`),confirmText:K(`chat.join.confirm`),validate:Jt,onConfirm:nn,onClose:()=>De.close(),isLoading:w,loadingText:K(`chat.join.joining`)}),P&&(0,S.jsx)(ee,{title:K(`chat.renameChannel`),placeholder:K(`chat.remark.placeholder`),defaultValue:P.remark||``,confirmText:K(`chat.remark.save`),onConfirm:dn,onClose:()=>{ut||ot(null)},isLoading:ut,loadingText:K(`chat.remark.saving`),allowEmpty:!0,validate:e=>e.length>50?K(`chat.remark.tooLong`):``}),it&&at&&(0,S.jsx)(s,{title:K(`chat.leaveChannel`),message:K(`chat.leaveConfirm`,{channel:A(at)}),confirmText:K(E?`chat.leaving`:`chat.leaveChannel`),onConfirm:()=>en(O(at),void 0),danger:!0,onClose:()=>{M.close(),N(null)}}),R&&(0,S.jsx)(te,{onClose:()=>z(null),children:(0,S.jsxs)(`div`,{className:`confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`modal-header`,children:[(0,S.jsx)(`h3`,{children:K(`chat.attachment.noSeedsTitle`)}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>z(null),"aria-label":K(`common.close`),children:(0,S.jsx)(i,{size:18})})]}),(0,S.jsx)(`p`,{children:I[R.cid]?.message||K(`chat.attachment.noSeedsFallback`)}),(0,S.jsxs)(`div`,{className:`modal-actions`,children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>z(null),children:K(`common.cancel`)}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>Zt(R),disabled:I[R.cid]?.status===`checking`,children:I[R.cid]?.status===`checking`?K(`app.checking`):K(`chat.attachment.retryCheck`)})]})]})}),ft&&(0,S.jsx)(ae,{item:ft,isBackendReady:G,getFileDownloadUrl:_e.getFileDownloadUrl,onClose:()=>pt(null)}),st&&h&&(0,S.jsx)(`div`,{className:`channel-detail-overlay`,onClick:()=>F(!1),children:(0,S.jsxs)(`div`,{className:`channel-detail-drawer`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`channel-detail-header`,children:[(0,S.jsx)(`h3`,{children:K(`chat.details.title`)}),(0,S.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>F(!1),children:(0,S.jsx)(i,{size:18})})]}),(0,S.jsxs)(`div`,{className:`channel-detail-body`,children:[(0,S.jsxs)(`div`,{className:`channel-detail-section channel-members-section`,children:[(0,S.jsx)(`div`,{className:`channel-detail-label`,children:(0,S.jsx)(`span`,{children:K(`chat.details.members`,{count:Kt.length})})}),mn()]}),!V&&(0,S.jsx)(`div`,{className:`channel-detail-section`,children:(0,S.jsxs)(`label`,{className:`setting-switch`,children:[(0,S.jsx)(`span`,{children:K(`chat.details.showAddressSuffix`)}),(0,S.jsx)(`input`,{type:`checkbox`,checked:gt,onChange:e=>_t(e.target.checked)})]})}),!V&&(0,S.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,S.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,S.jsx)(Te,{size:14}),(0,S.jsx)(`span`,{children:K(`chat.details.channelId`)})]}),(0,S.jsx)(`div`,{className:`ui-meta-box channel-detail-value channel-detail-mono`,translate:`no`,children:k(h)})]}),(0,S.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,S.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,S.jsx)(ie,{size:14}),(0,S.jsx)(`span`,{children:K(`chat.remark.placeholder`)})]}),(0,S.jsx)(`input`,{type:`text`,className:`input input-compact`,placeholder:K(`chat.remark.placeholder`),value:ct,onChange:e=>lt(e.target.value),onFocus:()=>lt(h.remark||``),onBlur:()=>un(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},maxLength:50})]}),(0,S.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,S.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,S.jsx)(Ce,{size:14}),(0,S.jsx)(`span`,{children:K(`chat.channel.createdAt`)})]}),(0,S.jsx)(`div`,{className:`ui-meta-box channel-detail-value`,children:h.createdAt?Mt(h.createdAt):`-`})]})]}),!V&&(0,S.jsx)(`div`,{className:`channel-detail-footer`,children:(0,S.jsx)(`button`,{className:`btn btn-secondary btn-block`,onClick:()=>{F(!1),N(h),M.open()},children:K(`chat.leaveChannel`)})})]})})]})}var M=f(`/chat/`)({component:it});export{M as Route};
|