most-box 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +16 -3
  2. package/out/admin/index.html +0 -0
  3. package/out/app/index.html +0 -0
  4. package/out/assets/AppShell-CQhg6DJU.js +1 -0
  5. package/out/assets/ChatUi-BepWs-ZU.js +1 -0
  6. package/out/assets/LanguageToggle-CtzCCAYv.js +1 -0
  7. package/out/assets/{LogoIcon-CYQ7cHd5.js → LogoIcon-Dxto3Sb4.js} +1 -1
  8. package/out/assets/{MarketingLayout-BTIbv4fW.js → MarketingLayout-BQw0IS2i.js} +1 -1
  9. package/out/assets/MarketingThemeToggle-DBaC9bjz.js +1 -0
  10. package/out/assets/MilkdownEditor-BqJzntYE.js +1054 -0
  11. package/out/assets/MoveModal-4D9n11Kw.js +1 -0
  12. package/out/assets/Nav-9MDdvgNs.js +1 -0
  13. package/out/assets/NoteSidebar-C-rIt32H.js +1 -0
  14. package/out/assets/OpenSidebarButton-Dd0JmKuE.js +1 -0
  15. package/out/assets/PemBlock-C8dEIzu-.js +1 -0
  16. package/out/assets/SidebarAccount-ClS-N0lq.js +1 -0
  17. package/out/assets/arrow-right-urE9Rd7j.js +1 -0
  18. package/out/assets/channelApi-BwQU0-h1.js +1 -0
  19. package/out/assets/check-DUNsD2t6.js +1 -0
  20. package/out/assets/chevron-down-D6mpsfv4.js +1 -0
  21. package/out/assets/{circle-alert-CqEQz6P4.js → circle-alert-W0iyN4sC.js} +1 -1
  22. package/out/assets/cloud-BMyOoC2x.js +1 -0
  23. package/out/assets/code-B1Cb_Icm.js +1 -0
  24. package/out/assets/{copy-CM-qWlbv.js → copy-C1MttOli.js} +1 -1
  25. package/out/assets/{dist-CvatM4u8.js → dist-8QDHqrPN.js} +1 -1
  26. package/out/assets/{dist-BmtYO1GG.js → dist-B0JrbG7f.js} +5 -5
  27. package/out/assets/{dist-DBpw-A8y.js → dist-BFSyuOuw.js} +1 -1
  28. package/out/assets/{dist-D5Cf0hK8.js → dist-BPs0Xns9.js} +2 -2
  29. package/out/assets/{dist-BQV5zYG_.js → dist-Br_5lLVO.js} +9 -9
  30. package/out/assets/{dist-CrzjJUOw.js → dist-BzqqCPi2.js} +1 -1
  31. package/out/assets/dist-C3lbe8SW.js +9 -0
  32. package/out/assets/{dist-CWJ3323z.js → dist-CfU9fwWz.js} +1 -1
  33. package/out/assets/{dist-BdmTLuCI.js → dist-DCX0ws1K.js} +1 -1
  34. package/out/assets/{dist-DrumcFOX.js → dist-DJdv-Ma3.js} +1 -1
  35. package/out/assets/{dist-C5HibLEW.js → dist-chOCTzB2.js} +1 -1
  36. package/out/assets/{download-0rM8xVCe.js → download-y7SZXu6E.js} +1 -1
  37. package/out/assets/downloadValidation-B0p9Ai_9.js +1 -0
  38. package/out/assets/filePreview-UI9NH34f.js +1 -0
  39. package/out/assets/format-CR8oUWq6.js +1 -0
  40. package/out/assets/game-CdU3xnZo.js +1 -0
  41. package/out/assets/{hard-drive-CCdIvSap.js → hard-drive-D13Qbobu.js} +1 -1
  42. package/out/assets/image-DJCA16l_.js +1 -0
  43. package/out/assets/index-BdaFEQG-.css +1 -0
  44. package/out/assets/index-QxXZzOUL.js +33 -0
  45. package/out/assets/index.lazy-BBTTFanX.js +1 -0
  46. package/out/assets/index.lazy-BG4ZylHD.js +2 -0
  47. package/out/assets/index.lazy-Bi-6ZXZX.js +1 -0
  48. package/out/assets/index.lazy-BixWVr0B.js +1 -0
  49. package/out/assets/index.lazy-BjFwNYy5.js +3 -0
  50. package/out/assets/index.lazy-C8EIQsXY.js +2 -0
  51. package/out/assets/index.lazy-CarNe2uu.js +1 -0
  52. package/out/assets/index.lazy-DEuGu3H3.js +1 -0
  53. package/out/assets/index.lazy-GPyILCA7.js +3 -0
  54. package/out/assets/index.lazy-I8ofndXl.js +1 -0
  55. package/out/assets/index.lazy-TxhWsA7y.js +1 -0
  56. package/out/assets/index.lazy-azfky8k7.js +1 -0
  57. package/out/assets/{key-round-tIqGrtt_.js → key-round-CZniN9lv.js} +1 -1
  58. package/out/assets/lock-D5OSNhep.js +1 -0
  59. package/out/assets/log-out-B6phyZ5z.js +1 -0
  60. package/out/assets/{music-BkZKq879.js → music-CbUskKgg.js} +1 -1
  61. package/out/assets/{notebook-pen-B4VSbweh.js → notebook-pen-DqKDQ6MJ.js} +1 -1
  62. package/out/assets/play-BIl8q9eU.js +1 -0
  63. package/out/assets/plus-BxxbpH6Q.js +1 -0
  64. package/out/assets/{save-BzjzC3eV.js → save-DkH1n_Ov.js} +1 -1
  65. package/out/assets/search-BQi5Z0E-.js +1 -0
  66. package/out/assets/{send-DtQInX0y.js → send-Cl6NtD2T.js} +1 -1
  67. package/out/assets/{trash-2-BhMrUgGM.js → trash-2-BBjpgK_f.js} +1 -1
  68. package/out/assets/triangle-alert-l98G8u9O.js +1 -0
  69. package/out/assets/upload-ByP6Ydde.js +1 -0
  70. package/out/assets/{useChannelMessages-Bs1hEJyd.js → useChannelMessages-BgbYfF2c.js} +2 -2
  71. package/out/assets/useGameRoom-DPmweWwe.js +1 -0
  72. package/out/assets/{wallet-YxbxCi7C.js → wallet-c7zIhNSM.js} +1 -1
  73. package/out/assets/{wifi-v3JpPCNm.js → wifi-Bm4biAjc.js} +1 -1
  74. package/out/chat/index.html +0 -0
  75. package/out/chat/join/index.html +0 -0
  76. package/out/demo/index.html +0 -0
  77. package/out/download/index.html +6 -2
  78. package/out/game/gandengyan/index.html +0 -0
  79. package/out/game/index.html +0 -0
  80. package/out/game/zhajinhua/index.html +0 -0
  81. package/out/index.html +6 -2
  82. package/out/note/index.html +0 -0
  83. package/out/ping/index.html +6 -2
  84. package/out/web3/index.html +0 -0
  85. package/package.json +2 -2
  86. package/server/index.js +9 -0
  87. package/server/src/core/channelAttachment.js +7 -3
  88. package/server/src/core/channelIdentity.js +50 -0
  89. package/server/src/core/cid.js +6 -1
  90. package/server/src/core/cidTopic.js +18 -4
  91. package/server/src/core/displayPath.js +10 -0
  92. package/server/src/core/gameRoom.js +2 -2
  93. package/server/src/core/mostLink.js +45 -25
  94. package/server/src/core/ownerMetadata.js +34 -0
  95. package/server/src/core/userSyncKeys.js +36 -0
  96. package/server/src/http/app.js +71 -149
  97. package/server/src/http/dataPath.js +26 -0
  98. package/server/src/http/errors.js +8 -4
  99. package/server/src/http/nodeStatus.js +13 -13
  100. package/server/src/http/rateLimit.js +39 -0
  101. package/server/src/http/routePolicy.js +43 -0
  102. package/server/src/index.js +1909 -759
  103. package/server/src/node/offlineSwarm.js +20 -0
  104. package/server/src/utils/api.js +1 -15
  105. package/server/src/utils/downloadMessages.js +17 -18
  106. package/server/src/utils/errors.js +3 -1
  107. package/server/src/utils/noteUtils.js +27 -3
  108. package/out/assets/AppShell-DmZQwVA9.js +0 -1
  109. package/out/assets/ChatUi-CVGqjFdx.js +0 -1
  110. package/out/assets/MilkdownEditor-BL8xE7u9.js +0 -1054
  111. package/out/assets/MoveModal-BKkVBvrS.js +0 -1
  112. package/out/assets/Nav-BDGeJnbC.js +0 -1
  113. package/out/assets/NoteSidebar-BIJ8_m5K.js +0 -1
  114. package/out/assets/OpenSidebarButton-Di62DGiu.js +0 -1
  115. package/out/assets/PemBlock-Dxx6k9MH.js +0 -1
  116. package/out/assets/SidebarAccount-CCHZLGdP.js +0 -1
  117. package/out/assets/admin-BepWGXWG.js +0 -2
  118. package/out/assets/app-3D79fY3w.js +0 -1
  119. package/out/assets/arrow-right-D0sGC8QA.js +0 -1
  120. package/out/assets/channelApi-CL7YsIQ-.js +0 -1
  121. package/out/assets/chat-B56sk6od.js +0 -1
  122. package/out/assets/check-DdfnsLKm.js +0 -1
  123. package/out/assets/chevron-down-Xlb3wTxd.js +0 -1
  124. package/out/assets/circle-check-CwAH4dgJ.js +0 -1
  125. package/out/assets/cloud-CcPRoob1.js +0 -1
  126. package/out/assets/code-Dr6STnCn.js +0 -1
  127. package/out/assets/database-DQ7ZtUT9.js +0 -1
  128. package/out/assets/dateTime-D1koKRQU.js +0 -1
  129. package/out/assets/demo-B_6rlIjn.js +0 -3
  130. package/out/assets/dist-BGtXa07s.js +0 -9
  131. package/out/assets/download-BLPU-Kzq.js +0 -1
  132. package/out/assets/downloadMessages-7Xbd-HhS.js +0 -1
  133. package/out/assets/ed25519-BEctXF0E.js +0 -1
  134. package/out/assets/filePreview-BvbHWUTG.js +0 -1
  135. package/out/assets/folder-CcbCxm-k.js +0 -1
  136. package/out/assets/game-B0zuqnOh.js +0 -1
  137. package/out/assets/gandengyan-DbQC7hCK.js +0 -1
  138. package/out/assets/index-BLhmAher.css +0 -1
  139. package/out/assets/index-Cf23WD2V.js +0 -29
  140. package/out/assets/join-DQHXjlfH.js +0 -1
  141. package/out/assets/note-DmWqGSS2.js +0 -2
  142. package/out/assets/ping-JILckfMu.js +0 -1
  143. package/out/assets/play-BIl5vwqS.js +0 -1
  144. package/out/assets/plus-DHvLpuuw.js +0 -1
  145. package/out/assets/routes-Dyckj88f.js +0 -1
  146. package/out/assets/search-C-EpsDNl.js +0 -1
  147. package/out/assets/sun-C3IUQTpa.js +0 -1
  148. package/out/assets/tools-BEctXF0E.js +0 -1
  149. package/out/assets/triangle-alert-DUODU79n.js +0 -1
  150. package/out/assets/upload-CpDM23UH.js +0 -1
  151. package/out/assets/useGameRoom-C6UgmIGG.js +0 -1
  152. package/out/assets/web3-CRX1YFmw.js +0 -3
  153. package/out/assets/zhajinhua-QDmSZbOp.js +0 -1
  154. package/out/web3/ed25519/index.html +0 -0
  155. package/out/web3/tools/index.html +0 -0
  156. /package/out/assets/{gandengyan-8eWJAjpY.css → index-8eWJAjpY.css} +0 -0
  157. /package/out/assets/{zhajinhua-BZc4blbW.css → index-BZc4blbW.css} +0 -0
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./cloud-BMyOoC2x.js";import{t as i}from"./code-B1Cb_Icm.js";import{t as a}from"./download-y7SZXu6E.js";import{t as o}from"./LanguageToggle-CtzCCAYv.js";import{G as s,J as c,U as l,W as u,Y as d}from"./index-QxXZzOUL.js";import{n as f}from"./format-CR8oUWq6.js";import{t as p}from"./MarketingThemeToggle-DBaC9bjz.js";var m=u(`apple`,[[`path`,{d:`M12 6.528V3a1 1 0 0 1 1-1h0`,key:`11qiee`}],[`path`,{d:`M18.237 21A15 15 0 0 0 22 11a6 6 0 0 0-10-4.472A6 6 0 0 0 2 11a15.1 15.1 0 0 0 3.763 10 3 3 0 0 0 3.648.648 5.5 5.5 0 0 1 5.178 0A3 3 0 0 0 18.237 21`,key:`110c12`}]]),h=u(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),g=u(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),_=t(e(),1),v=n(),y=`https://github.com/most-people/most/releases/latest`,b=`${`https://download.most.box`.replace(/\/+$/,``)}/releases/latest.json`,x=[{platform:`windows`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:y},{platform:`windows`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:y},{platform:`macos`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:y},{platform:`macos`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:y},{platform:`linux`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:y},{platform:`linux`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:y}],S={windows:{name:`Windows`,ext:`.exe`,descKey:`download.platform.windows.desc`,icon:g},macos:{name:`macOS`,ext:`.dmg`,descKey:`download.platform.macos.desc`,icon:m},linux:{name:`Linux`,ext:`.AppImage`,descKey:`download.platform.linux.desc`,icon:h}};function C(e){return typeof e==`object`&&!!e}function w(e){return C(e)?[`windows`,`macos`,`linux`].includes(String(e.platform))&&[`x64`,`arm64`].includes(String(e.arch))&&e.kind===`installer`&&typeof e.filename==`string`&&typeof e.githubUrl==`string`&&(typeof e.r2Url==`string`||e.r2Url===void 0):!1}function T(e){return!C(e)||typeof e.version!=`string`||typeof e.publishedAt!=`string`||!Array.isArray(e.assets)?!1:e.assets.every(w)}function E(){return[navigator.userAgentData?.platform,navigator.platform,navigator.userAgent].filter(Boolean).join(` `).toLowerCase()}function D(){if(typeof navigator>`u`)return`windows:x64`;let e=E(),t=/arm|aarch64/.test(e)?`arm64`:`x64`;return/mac|darwin/.test(e)?`macos:${t}`:/linux/.test(e)?`linux:${t}`:`windows:${t}`}function O(){let{t:e}=s(),[t,n]=(0,_.useState)(null),[o,c]=(0,_.useState)(b?`loading`:`fallback`),[l,u]=(0,_.useState)(`windows:x64`),[d,p]=(0,_.useState)(`r2`);(0,_.useEffect)(()=>{u(D())},[]),(0,_.useEffect)(()=>{if(!b)return;let e=new AbortController;return fetch(b,{cache:`no-store`,signal:e.signal}).then(e=>{if(!e.ok)throw Error(`Manifest request failed: ${e.status}`);return e.json()}).then(e=>{if(!T(e))throw Error(`Invalid download manifest`);n(e),c(`ready`)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(n(null),c(`fallback`))}),()=>e.abort()},[]),(0,_.useEffect)(()=>{o===`fallback`&&p(`github`)},[o]);let m=t?.assets.length?t.assets:x,h=m.some(e=>e.r2Url),g=d===`r2`&&h?`r2`:`github`;return(0,v.jsxs)(`div`,{className:`download-options`,children:[(0,v.jsxs)(`div`,{className:`ui-segmented-control download-source-tabs`,role:`tablist`,"aria-label":e(`download.source.label`),children:[(0,v.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`r2`,disabled:!h,className:g===`r2`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,onClick:()=>p(`r2`),children:[(0,v.jsx)(r,{size:15}),`Cloudflare R2`]}),(0,v.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`github`,className:g===`github`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,onClick:()=>p(`github`),children:[(0,v.jsx)(i,{size:15}),`GitHub Releases`]})]}),(0,v.jsx)(`p`,{className:`download-source-note`,children:o===`loading`?e(`download.source.loading`):o===`ready`&&t?e(`download.source.ready`,{version:t.version}):e(`download.source.fallback`)}),(0,v.jsx)(`div`,{className:`download-platform-grid`,children:m.map(t=>{let n=S[t.platform],r=n.icon,i=`${t.platform}:${t.arch}`,o=g===`r2`&&t.r2Url?t.r2Url:t.githubUrl,s=i===l;return(0,v.jsxs)(`article`,{className:s?`download-platform-card is-recommended`:`download-platform-card`,children:[(0,v.jsx)(`div`,{className:`download-platform-icon`,children:(0,v.jsx)(r,{size:32})}),(0,v.jsxs)(`div`,{className:`download-platform-content`,children:[(0,v.jsxs)(`div`,{className:`download-platform-heading`,children:[(0,v.jsx)(`h3`,{children:n.name}),(0,v.jsx)(`span`,{children:t.arch})]}),(0,v.jsx)(`p`,{children:e(n.descKey)}),(0,v.jsxs)(`dl`,{className:`download-platform-meta`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:e(`download.platform.source`)}),(0,v.jsx)(`dd`,{children:g===`r2`&&t.r2Url?e(`download.source.r2Mirror`):`GitHub Releases`})]}),t.size?(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:e(`download.platform.size`)}),(0,v.jsx)(`dd`,{children:f(t.size)})]}):null,t.sha256?(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:`SHA256`}),(0,v.jsx)(`dd`,{children:t.sha256.slice(0,12)})]}):null]}),(0,v.jsx)(`div`,{className:`download-platform-actions`,children:(0,v.jsxs)(`a`,{href:o,className:`btn btn-primary`,children:[(0,v.jsx)(a,{size:16}),e(`download.platform.action`,{ext:n.ext})]})})]}),s?(0,v.jsx)(`span`,{className:`download-recommended-badge`,children:e(`download.platform.current`)}):null]},i)})})]})}var k=[{featureKey:`download.comparison.node`,webKey:`download.comparison.webConnectsNode`,desktopKey:`download.comparison.desktopBuiltinNode`},{featureKey:`download.comparison.fileSharing`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopFull`},{featureKey:`download.comparison.verification`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopFull`},{featureKey:`download.comparison.seeding`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopDefaultOn`},{featureKey:`download.comparison.largeFiles`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktop10gb`}];function A(){let{t:e}=s();return(0,_.useEffect)(()=>{document.title=e(`download.meta.title`)},[e]),(0,v.jsxs)(`div`,{className:`download-page`,children:[(0,v.jsx)(`nav`,{className:`mkt-nav`,children:(0,v.jsxs)(`div`,{className:`mkt-nav-inner`,children:[(0,v.jsxs)(d,{to:`/`,className:`mkt-nav-logo`,children:[(0,v.jsx)(l,{size:18}),(0,v.jsx)(`span`,{children:`MOST PEOPLE`})]}),(0,v.jsxs)(`div`,{className:`mkt-nav-cta`,children:[(0,v.jsx)(p,{}),(0,v.jsx)(o,{className:`mkt-theme-toggle`})]})]})}),(0,v.jsx)(`section`,{className:`download-hero`,children:(0,v.jsxs)(`div`,{className:`mkt-container`,children:[(0,v.jsx)(`div`,{className:`download-hero-icon`,children:(0,v.jsx)(a,{size:40})}),(0,v.jsx)(`h1`,{className:`download-hero-title`,children:e(`download.hero.title`)}),(0,v.jsx)(`p`,{className:`download-hero-desc`,children:e(`download.hero.desc`)})]})}),(0,v.jsx)(`section`,{className:`download-platforms`,children:(0,v.jsxs)(`div`,{className:`mkt-container`,children:[(0,v.jsx)(`h2`,{className:`download-section-title`,children:e(`download.platforms.title`)}),(0,v.jsx)(O,{})]})}),(0,v.jsx)(`section`,{className:`download-comparison`,children:(0,v.jsxs)(`div`,{className:`mkt-container`,children:[(0,v.jsx)(`h2`,{className:`download-section-title`,children:e(`download.comparison.title`)}),(0,v.jsx)(`div`,{className:`download-table-wrap`,children:(0,v.jsxs)(`table`,{className:`download-table`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:e(`download.comparison.feature`)}),(0,v.jsx)(`th`,{children:e(`download.comparison.web`)}),(0,v.jsx)(`th`,{children:e(`download.comparison.desktop`)})]})}),(0,v.jsx)(`tbody`,{children:k.map(t=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:e(t.featureKey)}),(0,v.jsx)(`td`,{className:`col-web`,children:e(t.webKey)}),(0,v.jsx)(`td`,{className:`col-desktop`,children:e(t.desktopKey)})]},t.featureKey))})]})})]})}),(0,v.jsx)(`section`,{className:`download-cta`,children:(0,v.jsx)(`div`,{className:`mkt-container`,children:(0,v.jsx)(`p`,{className:`download-hero-desc`,children:e(`download.npmNote`)})})}),(0,v.jsx)(`section`,{className:`download-cta`,children:(0,v.jsx)(`div`,{className:`mkt-container`,children:(0,v.jsx)(d,{to:`/`,className:`btn btn-primary`,children:e(`common.backHome`)})})}),(0,v.jsx)(`footer`,{className:`mkt-footer`,children:(0,v.jsx)(`div`,{className:`mkt-container`,children:(0,v.jsx)(`div`,{className:`mkt-footer-inner`,children:(0,v.jsx)(`p`,{className:`mkt-footer-copy`,children:`MostBox`})})})})]})}var j=c(`/download/`)({component:A});export{j as Route};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t,r as n,t as r}from"./jsx-runtime-Bt-cYkS5.js";import{n as i,t as a}from"./triangle-alert-l98G8u9O.js";import{t as o}from"./download-y7SZXu6E.js";import{n as s,t as c}from"./trash-2-BBjpgK_f.js";import{t as l}from"./hard-drive-D13Qbobu.js";import{t as u}from"./save-DkH1n_Ov.js";import{t as d}from"./wifi-Bm4biAjc.js";import{B as f,G as p,J as m,U as h,W as g,Y as _,b as v,f as y,g as b,p as x,x as ee}from"./index-QxXZzOUL.js";import{t as S}from"./dayjs.min-Dcc0B6Je.js";import{t as C}from"./format-CR8oUWq6.js";var te=g(`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`}]]),ne=g(`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`}]]),w=g(`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`}]]),re=g(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ie=g(`shield-check`,[[`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:`m9 12 2 2 4-4`,key:`dzmm74`}]]),T=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)}}}))})),E=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r(S()):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}))})),D=t(e(),1),O=t(S(),1),k=t(T(),1);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 e===`zh-CN`?`zh-cn`:`en`}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}=p(),m=y(e=>e.hasBackend),g=y(e=>e.addToast),[S,T]=(0,D.useState)(ae),[E,O]=(0,D.useState)([]),[k,P]=(0,D.useState)(``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(!1),[pe,z]=(0,D.useState)(!1),[B,me]=(0,D.useState)(`all`),[V,he]=(0,D.useState)([]),[ge,H]=(0,D.useState)(``),[U,W]=(0,D.useState)({dataPath:``,capacityGiB:`100`,maxFileSizeGiB:`10`,remoteInvites:``}),G=m===!0;function K(){return G?!0:(g(e(m===null?`admin.toast.backendChecking`:`admin.toast.backendDisconnected`),`warning`),!1)}let q=(0,D.useMemo)(()=>!S||S.capacity.configuredBytes<=0?0:Math.min(100,Math.round(S.capacity.usedBytes/S.capacity.configuredBytes*100)),[S]),_e=(0,D.useMemo)(()=>(S?.holdings||[]).slice(0,100),[S]),J=Math.max(0,(S?.holdings.length||0)-100),Y=ee(),X=!!Y&&!Y.includes(`localhost`)&&!Y.includes(`127.0.0.1`),Z=async()=>{if(!G)return!1;try{let e=await x.get(`/api/node/status`).json(),t=await x.get(`/api/node/config`).json();return T(e),W({dataPath:t.dataPath||e.dataPath||``,capacityGiB:j(t.capacityBytes),maxFileSizeGiB:j(t.maxFileSizeBytes),remoteInvites:(t.remoteInvites||[]).join(`
2
+ `)}),P(``),!0}catch(t){let n=await b(t,e(`admin.error.readStatus`));return P(n),g(n,`error`),!1}},ve=async()=>{K()&&await Z()&&g(e(`admin.toast.statusRefreshed`),`success`)},Q=async(e=B)=>{if(G)try{let t=new URLSearchParams({limit:`80`,filter:e});O((await x.get(`/api/node/logs?${t.toString()}`).json()).logs||[])}catch{}},$=async()=>{if(G)try{he((await x.get(`/api/admin/users`).json()).users||[])}catch{}},ye=async()=>{if(K()){I(!0);try{await x.post(`/api/node/config`,{json:{dataPath:U.dataPath,capacityBytes:M(U.capacityGiB),maxFileSizeBytes:M(U.maxFileSizeGiB),remoteInvites:se(U.remoteInvites)}}).json(),g(U.dataPath===(S?.dataPath||``)?e(`admin.toast.configSaved`):e(`admin.toast.configSavedRestart`),`success`),await Z(),await Q()}catch(t){let n=await b(t,e(`admin.error.saveConfig`));g(n,`error`),P(n)}finally{I(!1)}}},be=async()=>{S?.nodeId&&(await navigator.clipboard.writeText(S.nodeId),g(e(`admin.toast.nodeIdCopied`),`success`))},xe=async()=>{if(K()){R(!0);try{await x.delete(`/api/node/logs`).json(),O([]),g(e(`admin.toast.logsCleared`),`success`)}catch(t){let n=await b(t,e(`admin.error.clearLogs`));g(n,`error`),P(n)}finally{R(!1)}}},Se=async()=>{if(K()){z(!0);try{let t=await x.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),g(e(`admin.toast.diagnosticsExported`),`success`)}catch(t){let n=await b(t,e(`admin.error.exportDiagnostics`));g(n,`error`),P(n)}finally{z(!1)}}},Ce=async t=>{if(K()&&window.confirm(e(`admin.confirm.clearUserData`,{address:`${t.slice(0,6)}...${t.slice(-4)}`}))){H(t);try{await x.delete(`/api/admin/users/${t}/data`).json(),g(e(`admin.toast.userDataCleared`),`success`),await $(),await Z()}catch(t){let n=await b(t,e(`admin.error.clearUserData`));g(n,`error`),P(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 v(`/ws`)),t){e.close();return}e.onmessage=e=>{try{let t=JSON.parse(e.data);t.event===`node:status`&&T(t.data),t.event===`node:log`&&fe(t.data,B)&&O(e=>[t.data,...e].slice(0,80)),t.event===`node:logs:cleared`&&O([]),(t.event===`publish:success`||t.event===`download:success`||t.event===`network:status`)&&Z()}catch{}}})(),()=>{t=!0,e?.close()}},[G,X,B]),(0,A.jsxs)(`main`,{className:`admin-page`,children:[(0,A.jsxs)(`header`,{className:`admin-topbar`,children:[(0,A.jsxs)(`div`,{className:`admin-title-group`,children:[(0,A.jsx)(_,{to:`/`,className:`btn btn-icon`,"aria-label":e(`common.backHome`),children:(0,A.jsx)(h,{size:16})}),(0,A.jsx)(`div`,{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 ${S?.status===`online`?`online`:``}`,children:[(0,A.jsx)(te,{size:14}),S?.status===`online`?e(`admin.status.online`):e(`admin.status.waiting`)]}),(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ve,children:[(0,A.jsx)(re,{size:16}),e(`admin.action.refresh`)]})]})]}),m===!1&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(f,{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)(a,{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&&k&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(s,{size:20}),(0,A.jsx)(`span`,{children:k})]}),!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)(ie,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.nodeId`)}),(0,A.jsx)(`strong`,{translate:`no`,children:N(S?.nodeId||``)})]}),(0,A.jsx)(`button`,{className:`btn btn-icon admin-metric-action`,onClick:be,"aria-label":e(`admin.action.copyNodeId`),children:(0,A.jsx)(ne,{size:15})})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(d,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.connections`)}),(0,A.jsx)(`strong`,{children:S?e(`admin.metric.peers`,{count:S.network.peers}):`-`})]})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(l,{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)(f,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.uptime`)}),(0,A.jsx)(`strong`,{children:S?oe(S.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)(i,{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:S?.version||`-`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.listen`)}),(0,A.jsx)(`strong`,{translate:`no`,children:S?`${S.host}:${S.port}`:`-`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.dataPath`)}),(0,A.jsx)(`strong`,{translate:`no`,children:S?.dataPath||`-`})]})]}),(0,A.jsx)(`div`,{className:`admin-address-list`,children:(S?.listen.addresses||[]).map(e=>(0,A.jsxs)(`span`,{translate:`no`,children:[e.label,`: `,e.ip,`:`,S?.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)(w,{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:()=>Ce(t.address),disabled:ge===t.address,children:[(0,A.jsx)(c,{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)(w,{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:ye,disabled:F,children:[(0,A.jsx)(u,{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)(l,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-capacity-row`,children:[(0,A.jsx)(`progress`,{value:q,max:`100`}),(0,A.jsxs)(`span`,{children:[C(S?.capacity.usedBytes||0),` /`,` `,C(S?.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`,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:`Peer`}),(0,A.jsx)(`span`,{children:e(`admin.holdings.lastServed`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.status`)})]}),_e.map(n=>(0,A.jsxs)(`div`,{className:`admin-table-row`,children:[(0,A.jsx)(`span`,{translate:`no`,children:n.fileName||`-`}),(0,A.jsx)(`span`,{title:n.cid,translate:`no`,children:N(n.cid)}),(0,A.jsx)(`span`,{children:C(n.size)}),(0,A.jsx)(`span`,{children:n.peerCount??0}),(0,A.jsx)(`span`,{title:n.lastServedAt||``,children:le(n.lastServedAt,e,t)}),(0,A.jsx)(`span`,{className:`admin-seed-pill ${n.seedStatus===`error`?`error`:n.seedStatus===`active`||n.joined?`active`:``}`,children:ce(n,e)})]},n.cid)),(!S||S.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:Se,disabled:pe,children:[(0,A.jsx)(o,{size:16}),e(`admin.action.exportDiagnostics`)]}),(0,A.jsxs)(`button`,{className:`btn btn-ghost`,onClick:xe,disabled:L||E.length===0,children:[(0,A.jsx)(c,{size:16}),e(`admin.action.clearLogs`)]}),(0,A.jsx)(s,{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:()=>{me(t.value),Q(t.value)},children:e(t.labelKey)},t.value))}),(0,A.jsxs)(`div`,{className:`admin-log-list`,children:[E.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)),E.length===0&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.logs.empty`)})]})]})]})]})]})}var R=m(`/admin/`)({component:L});export{R as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./copy-C1MttOli.js";import{n as i,r as a}from"./LanguageToggle-CtzCCAYv.js";import{t as o}from"./AppShell-CQhg6DJU.js";import{t as s}from"./play-BIl8q9eU.js";import{t as c}from"./send-Cl6NtD2T.js";import{i as ee,n as te,r as ne,t as re}from"./useGameRoom-DPmweWwe.js";import{G as ie,J as l,W as u,f as d,u as ae}from"./index-QxXZzOUL.js";var oe=u(`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`}]]),f=t(e(),1),p=[`S`,`H`,`C`,`D`],m=[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`,`2`],h=m.filter(e=>e!==`2`),g=new Map(m.map((e,t)=>[e,t+3])),_=5,se=20,v=1e3;function ce({roomCode:e,ownerAddress:t,ownerName:n,players:r=[],random:i=Math.random}){let a=E(r);return a.some(e=>e.address===q(t))||a.unshift({address:q(t),name:J(n)}),y({id:String(e||``).toUpperCase(),ownerAddress:q(t),status:`lobby`,seq:1,players:a.slice(0,6).map((e,t)=>({address:e.address,name:J(e.name),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:i})}function le(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:J(e.name),seat:t,hand:[],handCount:0,score:r.get(e.address)??v,playedCards:0})),n.seq+=1,y(n)}function ue(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,_),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 de(e,t,n){let r=b(e),i=I(r),a=q(t);if(!i||i.address!==a)return{ok:!1,error:`还没轮到你`,state:y(r)};let o=n.map(e=>i.hand.find(t=>t.id===e));if(o.length===0||o.some(e=>!e))return{ok:!1,error:`手牌不存在`,state:y(r)};let s=me(o);return s?T(s,r.table?.combo)?(o.sort(H),i.hand=i.hand.filter(e=>!n.includes(e.id)),i.handCount=i.hand.length,i.playedCards+=o.length,r.discard.push(...o),r.table={seat:i.seat,playerName:i.name,cards:o,combo:s},r.passSeats=[],r.lastWinnerSeat=i.seat,s.type===`bomb`&&(r.bombCount+=1,r.baseScore*=2),r.log.unshift(`${i.name} 出 ${s.label} ${o.map(K).join(` `)}${s.type===`bomb`?`,底分 ${r.baseScore}`:``}`),i.hand.length===0?A(r,i):z(r),r.seq+=1,{ok:!0,state:y(r)}):{ok:!1,error:`出的牌压不过上一手`,state:y(r)}:{ok:!1,error:`这个牌型不合法`,state:y(r)}}function fe(e,t){let n=b(e),r=I(n),i=q(t);return!r||r.address!==i?{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 pe(e,t){let n=b(e);if(!n)return null;let r=q(t),i=n.players.findIndex(e=>e.address===r);if(i===-1)return y(n);let a=n.players[i],o=n.currentSeat===a.seat,s=n.lastWinnerSeat===a.seat;n.players.splice(i,1),n.passSeats=n.passSeats.filter(e=>e!==a.seat),n.log.unshift(`${a.name} 已退出房间`);let c=R(n);if(n.status===`playing`)if(c.length<=1)c.length===1?A(n,c[0]):(n.status=`finished`,n.log.unshift(`玩家不足,本局结束`));else{if(o){let e=L(n);if(e.length>0){let t=e.findIndex(e=>e.seat>a.seat);n.currentSeat=e[t>=0?t:0].seat}}s&&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,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:q(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(ge).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 me(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<=h.length-e.length;r+=1){let i=h.slice(r,r+e.length).map(e=>g.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<=h.length-t;i+=1){let a=h.slice(i,i+t).map(e=>g.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:ye({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===xe(t.value)||e.value===g.get(`2`)&&t.value!==g.get(`2`):e.value===xe(t.value):!1:!1:!1}function E(e){let t=new Set;return e.map(e=>({address:q(e.address),name:J(e.name),publicKey:String(e.publicKey||``)})).filter(e=>!e.address||t.has(e.address)?!1:(t.add(e.address),!0))}function D(e){let t=q(e.address);return t?{address:t,name:J(e.name),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!g.has(t)&&t!==`SJ`&&t!==`BJ`||!p.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||ve({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:Se(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?se: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 p)for(let n of m)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)||he(e.suit)-he(t.suit)}function U(e){return g.get(e.rank)||99}function W(e){return e.rank===`SJ`||e.rank===`BJ`}function he(e){return{D:0,C:1,H:2,S:3,Joker:4}[e]||0}function ge(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:ve(e)}}function K(e){return e.rank===`SJ`?`小王`:e.rank===`BJ`?`大王`:`${_e(e.suit)}${e.rank}`}function _e(e){return{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[e]||``}function ve(e){return e.suit===`H`||e.suit===`D`||e.rank===`BJ`?`red`:`black`}function ye(e){let t=e.resolvedValues?.length?`(${e.resolvedValues.map(be).join(` `)})`:``;return`${{single:`单张`,pair:`对子`,straight:`顺子`,pairStraight:`连对`,bomb:e.pure?`纯炸弹`:`带王炸弹`}[e.type]}${t}`}function be(e){return m.find(t=>g.get(t)===e)||String(e)}function xe(e){let t=m.findIndex(t=>g.get(t)===e);return t===-1||t>=m.length-1?null:g.get(m[t+1])}function Se(e){return Math.floor(e()*6)+1}function q(e){let t=String(e||``).trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():``}function J(e){return String(e||`玩家`).trim().slice(0,16)||`玩家`}var Y={page:`_page_4biq6_1`,headerActions:`_headerActions_4biq6_7`,entry:`_entry_4biq6_13`,entryBrand:`_entryBrand_4biq6_23`,cardMark:`_cardMark_4biq6_29`,entryPanel:`_entryPanel_4biq6_59`,panel:`_panel_4biq6_60`,handPanel:`_handPanel_4biq6_61`,accountLine:`_accountLine_4biq6_74`,scoreMeta:`_scoreMeta_4biq6_75`,roomBar:`_roomBar_4biq6_76`,badges:`_badges_4biq6_77`,actions:`_actions_4biq6_78`,joinForm:`_joinForm_4biq6_98`,status:`_status_4biq6_119`,gameGrid:`_gameGrid_4biq6_125`,tablePanel:`_tablePanel_4biq6_136`,seats:`_seats_4biq6_170`,player:`_player_4biq6_176`,active:`_active_4biq6_193`,winner:`_winner_4biq6_197`,avatar:`_avatar_4biq6_201`,centerTable:`_centerTable_4biq6_228`,deckBox:`_deckBox_4biq6_235`,playedBox:`_playedBox_4biq6_236`,playedCards:`_playedCards_4biq6_264`,notice:`_notice_4biq6_272`,resultDetail:`_resultDetail_4biq6_280`,sidePanel:`_sidePanel_4biq6_291`,scoreRow:`_scoreRow_4biq6_316`,logPanel:`_logPanel_4biq6_324`,hand:`_hand_4biq6_61`,cardButton:`_cardButton_4biq6_351`,picked:`_picked_4biq6_361`,card:`_card_4biq6_29`,red:`_red_4biq6_392`,black:`_black_4biq6_396`,small:`_small_4biq6_400`,preview:`_preview_4biq6_418`,valid:`_valid_4biq6_441`},X=n(),Z=`gandengyan`;function Q(...e){return e.filter(Boolean).join(` `)}function Ce(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function we(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 Te(){let{t:e,locale:t}=ie(),n=d(e=>e.isDarkMode),l=d(e=>e.setIsDarkMode),u=d(e=>e.addToast),p=ae(e=>e.initializeUser),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)([]),[se,v]=(0,f.useState)(!1),y=(0,f.useRef)(``),b=(0,f.useRef)(!1),x=re({gameId:Z,onError:e=>u(e,`error`)});(0,f.useEffect)(()=>{p()},[p]),(0,f.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(h(e),y.current=e)},[]),(0,f.useEffect)(()=>{let t=y.current;!t||b.current||!x.isBackendReady||!x.userIdentity||(b.current=!0,y.current=``,x.joinRoom(t).then(t=>{t&&u(e(`game.toast.joinedRoom`),`success`)}))},[x.isBackendReady,x.userIdentity,x.joinRoom,u,e]),(0,f.useEffect)(()=>{if(!x.roomCode)return;let e=`/game/gandengyan?room=${x.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[x.roomCode]);let S=(0,f.useMemo)(()=>te(x.messages,x.roomCode?{gameId:Z,roomCode:x.roomCode}:{gameId:Z}),[x.messages,x.roomCode]),C=(0,f.useMemo)(()=>ne(x.messages,{gameId:Z,roomCode:x.roomCode}),[x.messages,x.roomCode]),w=C?.payload?.state,T=w?.players.find(e=>Ce(e.address,x.userIdentity?.address)),E=Ce(w?.ownerAddress||S.hostAddress,x.userIdentity?.address),D=w?.status===`playing`&&w.currentSeat===T?.seat,O=(0,f.useMemo)(()=>g.map(e=>T?.hand.find(t=>t.id===e)).filter(Boolean),[g,T]),k=(0,f.useMemo)(()=>me(O),[O]),A=x.roomCode&&typeof window<`u`?`${window.location.origin}/game/gandengyan?room=${x.roomCode}`:``,j=(0,f.useRef)(-1),M=(0,f.useRef)(!1);(0,f.useEffect)(()=>{_([])},[w?.seq]),(0,f.useEffect)(()=>{if(!w)return;let n=w.seq;if(j.current<0){j.current=n;return}if(n!==j.current&&(j.current=n,w.status!==`finished`&&(M.current=!1),w.status===`finished`&&w.winnerSeat!==null)){M.current||(M.current=!0,we(e(`game.gandengyan.speech.gameOver`),t));return}},[t,w?.seq,e]),(0,f.useEffect)(()=>{if(!E||!x.roomCode||!x.userIdentity||C||S.players.length===0)return;let e=ce({roomCode:x.roomCode,ownerAddress:x.userIdentity.address,ownerName:x.userIdentity.displayName||x.userIdentity.username,players:S.players});x.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[x,E,C,S.players]),(0,f.useEffect)(()=>{if(!w||!E||w.status!==`lobby`)return;let e=le(w,S.players);e&&e.players.length!==w.players.length&&x.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[x,E,S.players,w]);let N=(0,f.useRef)(0),P=(0,f.useMemo)(()=>x.roomEvents.filter(e=>e.event?.event===`player:leave`),[x.roomEvents]);(0,f.useEffect)(()=>{if(P.length<=N.current)return;let t=P.slice(N.current);N.current=P.length;for(let n of t)u(e(`game.toast.playerLeft`,{player:n.event?.payload?.player?.name||e(`game.player`)}),`info`)},[P,u,e]),(0,f.useEffect)(()=>{if(!w||!E||w.status!==`playing`)return;let e=new Set(S.players.map(e=>e.address.toLowerCase())),t=w.players.find(t=>!e.has(t.address.toLowerCase()));if(!t)return;let n=pe(w,t.address);n&&R(n)},[x,E,S.players,w]);async function F(){await x.createRoom()&&u(e(`game.toast.roomCreated`),`success`)}async function I(t){t.preventDefault(),await x.joinRoom(m)&&u(e(`game.toast.joinedRoom`),`success`)}async function L(){A&&(await navigator.clipboard.writeText(A),v(!0),setTimeout(()=>v(!1),1400))}async function R(e){await x.sendRoomEvent(`room:state`,{state:e,seq:e.seq})}async function z(){if(!(!w||!E))try{await R(ue(w))}catch(t){u(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function B(){await z()}async function V(){if(!w||!x.userIdentity)return;let t=de(w,x.userIdentity.address,g);if(!t.ok){u(t.error||e(`game.gandengyan.error.playFailed`),`error`);return}await R(t.state)}async function H(){if(!w||!x.userIdentity)return;let t=fe(w,x.userIdentity.address);if(!t.ok){u(t.error||e(`game.gandengyan.error.actionFailed`),`error`);return}await R(t.state)}function U(e){_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,X.jsx)(o,{sidebar:({closeSidebar:e})=>(0,X.jsx)(ee,{activeGame:`gandengyan`,closeSidebar:e}),headerTitle:(0,X.jsx)(`h2`,{className:`header-title`,children:e(`game.gandengyan.title`)}),headerRight:(0,X.jsxs)(`div`,{className:Y.headerActions,children:[w&&(0,X.jsxs)(`button`,{className:`btn btn-sm`,onClick:L,children:[(0,X.jsx)(r,{size:14}),e(se?`common.copied`:`game.action.shareRoom`)]}),(0,X.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>l(!n),title:e(`common.theme.toggle`),children:n?(0,X.jsx)(i,{size:16}):(0,X.jsx)(a,{size:16})})]}),children:(0,X.jsx)(`main`,{className:Y.page,children:w?(0,X.jsxs)(`section`,{className:Y.gameGrid,children:[(0,X.jsxs)(`div`,{className:Y.tablePanel,children:[(0,X.jsxs)(`div`,{className:Y.roomBar,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{translate:`no`,children:e(`game.roomLabel`,{room:w.id})}),(0,X.jsx)(`span`,{children:w.status===`lobby`?e(`game.status.waitingStart`):w.status===`finished`?e(`game.status.finished`):e(`game.status.playing`)})]}),(0,X.jsx)(`div`,{className:Y.badges,children:(0,X.jsx)(`span`,{children:x.connected?e(`game.status.online`):e(`game.status.offline`)})})]}),(0,X.jsx)(`div`,{className:Y.seats,children:w.players.map(t=>(0,X.jsx)(Ee,{player:t,active:w.currentSeat===t.seat,winner:w.winnerSeat===t.seat,relation:De(T,t,w.players.length,e)},t.seat))}),(0,X.jsxs)(`div`,{className:Y.centerTable,children:[(0,X.jsxs)(`div`,{className:Y.deckBox,children:[(0,X.jsx)(`span`,{children:e(`game.gandengyan.deck`)}),(0,X.jsx)(`strong`,{children:w.deckCount})]}),(0,X.jsx)(`div`,{className:Y.playedBox,children:w.table?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`strong`,{children:e(`game.gandengyan.tablePlay`,{player:w.table.playerName,combo:w.table.combo?.label||e(`game.card`)})}),(0,X.jsx)(`div`,{className:Y.playedCards,children:w.table.cards.map(e=>(0,X.jsx)($,{card:e,small:!0},e.id))})]}):(0,X.jsx)(`span`,{children:e(`game.gandengyan.waitingLead`)})}),(0,X.jsxs)(`div`,{className:Y.deckBox,children:[(0,X.jsx)(`span`,{children:e(`game.gandengyan.baseScore`)}),(0,X.jsx)(`strong`,{children:w.baseScore})]})]}),(0,X.jsx)(`div`,{className:Y.notice,children:w.status===`finished`?w.roundResult?(0,X.jsxs)(`div`,{className:Y.resultDetail,children:[(0,X.jsxs)(`p`,{children:[e(`game.gandengyan.result.winnerGain`,{player:w.roundResult.winnerName,score:w.roundResult.winnerGain}),w.roundResult.bombCount>0&&e(`game.gandengyan.result.bombCount`,{count:w.roundResult.bombCount})]}),w.roundResult.losers.map(t=>(0,X.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:w.players.find(e=>e.seat===w.winnerSeat)?.name||e(`game.player`)}):D?e(`game.gandengyan.status.yourTurn`):e(`game.zhajinhua.status.waitingPlayer`,{player:w.players.find(e=>e.seat===w.currentSeat)?.name||e(`game.player`)})})]}),(0,X.jsxs)(`aside`,{className:Y.sidePanel,children:[(0,X.jsxs)(`section`,{className:Y.panel,children:[(0,X.jsx)(`h3`,{children:e(`game.gandengyan.roundPanel`)}),E&&w.status===`lobby`&&(0,X.jsxs)(`button`,{className:`btn btn-primary`,disabled:w.players.length<2,onClick:z,children:[(0,X.jsx)(s,{size:16}),e(`game.action.startRound`)]}),E&&w.status===`finished`&&(0,X.jsxs)(`button`,{className:`btn btn-primary`,onClick:B,children:[(0,X.jsx)(oe,{size:16}),e(`game.action.nextRound`)]}),!E&&(0,X.jsx)(`p`,{className:Y.status,children:e(`game.waitingHost`)})]}),(0,X.jsxs)(`section`,{className:Y.panel,children:[(0,X.jsx)(`h3`,{children:e(`game.gandengyan.score`)}),(0,X.jsxs)(`div`,{className:Y.scoreMeta,children:[(0,X.jsx)(`span`,{children:e(`game.gandengyan.bombCount`,{count:w.bombCount})}),(0,X.jsx)(`span`,{children:e(`game.gandengyan.discardCount`,{count:w.discardCount})})]}),w.players.map(e=>(0,X.jsxs)(`div`,{className:Y.scoreRow,children:[(0,X.jsx)(`span`,{translate:`no`,children:e.name}),(0,X.jsx)(`strong`,{children:e.score})]},e.seat))]}),(0,X.jsxs)(`section`,{className:Q(Y.panel,Y.logPanel),children:[(0,X.jsx)(`h3`,{children:e(`game.gandengyan.log`)}),w.log.map((e,t)=>(0,X.jsx)(`p`,{translate:`no`,children:e},`${e}-${t}`))]})]}),(0,X.jsxs)(`div`,{className:Y.handPanel,children:[(0,X.jsx)(Ee,{player:T,active:D,winner:w.winnerSeat===T?.seat}),(0,X.jsx)(`div`,{className:Y.hand,children:T?.hand.map(e=>(0,X.jsx)(`button`,{className:Q(Y.cardButton,g.includes(e.id)&&Y.picked),onClick:()=>U(e.id),children:(0,X.jsx)($,{card:e})},e.id))}),(0,X.jsxs)(`div`,{className:Y.actions,children:[(0,X.jsxs)(`div`,{className:Q(Y.preview,k&&Y.valid),children:[(0,X.jsx)(`strong`,{children:k?k.label:g.length?e(`game.gandengyan.invalidCombo`):e(`game.gandengyan.selectCards`)}),(0,X.jsx)(`span`,{children:O.map(e=>e.label).join(` `)||e(`game.gandengyan.jokerOrderHint`)})]}),(0,X.jsxs)(`button`,{className:`btn btn-primary`,disabled:!D||g.length===0||!k,onClick:V,children:[(0,X.jsx)(c,{size:16}),e(`game.gandengyan.action.play`)]}),(0,X.jsx)(`button`,{className:`btn`,disabled:!D||!w.table,onClick:H,children:e(`game.gandengyan.action.pass`)})]})]})]}):(0,X.jsxs)(`section`,{className:Y.entry,children:[(0,X.jsxs)(`div`,{className:Y.entryBrand,children:[(0,X.jsx)(`div`,{className:Y.cardMark,children:e(`game.gandengyan.mark`)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{children:e(`game.gandengyan.hero.title`)}),(0,X.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,X.jsxs)(`div`,{className:Y.entryPanel,children:[(0,X.jsxs)(`div`,{className:Y.accountLine,children:[(0,X.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,X.jsx)(`strong`,{translate:`no`,children:x.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,X.jsxs)(`button`,{className:`btn btn-primary`,disabled:x.joining,onClick:F,children:[(0,X.jsx)(s,{size:16}),e(`game.action.createRoom`)]}),(0,X.jsxs)(`form`,{onSubmit:I,className:Y.joinForm,children:[(0,X.jsxs)(`label`,{children:[e(`game.roomCode`),(0,X.jsx)(`input`,{value:m,maxLength:8,onChange:e=>h(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,X.jsx)(`button`,{className:`btn`,disabled:x.joining||!m,children:e(`game.action.joinRoom`)})]}),(0,X.jsx)(`p`,{className:Y.status,children:x.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Ee({player:e,active:t,winner:n,relation:r=``}){let{t:i}=ie();return e?(0,X.jsxs)(`div`,{className:Q(Y.player,t&&Y.active,n&&Y.winner),children:[(0,X.jsx)(`div`,{className:Y.avatar,translate:`no`,children:e.name.slice(0,1)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{translate:`no`,children:e.name}),(0,X.jsxs)(`span`,{children:[r,r?` · `:``,i(`game.gandengyan.handCount`,{count:e.handCount})]})]})]}):null}function $({card:e,small:t=!1}){return(0,X.jsxs)(`div`,{className:Q(Y.card,Y[e.color],t&&Y.small),children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`i`,{children:e.suit===`Joker`?`*`:e.label.slice(0,1)})]})}function De(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 Oe=l(`/game/gandengyan/`)({component:Te});export{Oe as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./check-DUNsD2t6.js";import{t as i}from"./circle-alert-W0iyN4sC.js";import{t as a}from"./key-round-CZniN9lv.js";import{n as o,r as s}from"./LanguageToggle-CtzCCAYv.js";import{t as c}from"./AppShell-CQhg6DJU.js";import{G as l,J as u,U as d,W as f,d as p,f as m,h,m as g,q as _,u as v}from"./index-QxXZzOUL.js";import{t as y}from"./channelApi-BwQU0-h1.js";var b=f(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),x=t(e(),1),S=[{name:`node_url`,required:!1,descriptionKey:`chatJoin.field.nodeUrl`},{name:`node_invite`,required:!1,descriptionKey:`chatJoin.field.nodeInvite`},{name:`uid`,required:!0,descriptionKey:`chatJoin.field.uid`},{name:`identity`,required:!1,descriptionKey:`chatJoin.field.identity`},{name:`logo`,required:!1,descriptionKey:`chatJoin.field.logo`},{name:`avatar`,required:!1,descriptionKey:`chatJoin.field.avatar`},{name:`name`,required:!1,descriptionKey:`chatJoin.field.name`},{name:`locale`,required:!1,descriptionKey:`chatJoin.field.locale`},{name:`channels[].id`,required:!0,descriptionKey:`chatJoin.field.channelId`},{name:`channels[].name`,required:!1,descriptionKey:`chatJoin.field.channelName`}],C=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"%3E%3Crect width="64" height="64" rx="16" fill="%232f7dd1"/%3E%3Ccircle cx="32" cy="25" r="11" fill="%23f8fbff"/%3E%3Cpath d="M14 56c3-12 12-18 18-18s15 6 18 18" fill="%23f8fbff"/%3E%3C/svg%3E`,w=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"%3E%3Crect width="64" height="64" rx="16" fill="%230f9f7a"/%3E%3Cpath d="M18 20h28v22H18z" rx="6" fill="%23f7fff9"/%3E%3Ccircle cx="27" cy="31" r="3" fill="%230f9f7a"/%3E%3Ccircle cx="37" cy="31" r="3" fill="%230f9f7a"/%3E%3Cpath d="M29 39h6" stroke="%230f9f7a" stroke-width="4" stroke-linecap="round"/%3E%3Cpath d="M32 12v8" stroke="%23f7fff9" stroke-width="5" stroke-linecap="round"/%3E%3C/svg%3E`,T=Object.freeze({id:`chatjoin_support`,name:`User / Service 测试频道`}),E=Object.freeze([Object.freeze({uid:`user`,identity:`user`,name:`测试用户`,avatar:C}),Object.freeze({uid:`service`,identity:`service`,name:`测试客服`,avatar:w})]),D=Object.freeze(E.map(e=>Object.freeze({locale:`zh-CN`,uid:e.uid,identity:e.identity,avatar:e.avatar,name:e.name,channels:[T]})));function O(e){let t=String(e||``).trim();return D.find(e=>e.uid===t)||null}function k(e){return JSON.stringify(e,null,2)}var A=n(),j=`0x955fe80bdb8312165471fcacd6a8f83df88a770dda6f38657ca4e62ec28d5b54`,M=50,N=`https://api.most.box`;function P(e){try{return JSON.parse(e)}catch{return null}}function F(e){return typeof e==`string`?P(e):e}function I(e,t){return t===null?e:JSON.stringify(t,null,2)}function L(e,t,n){if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`)return e}return e||n}function R(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function z(e){return typeof e==`string`?e.trim():``}function B(e){let t=z(e);return t===`user`||t===`service`||t===`service_ai`?t:void 0}function V(e){let t=F(e);if(!R(t))return null;let n=z(t.uid),r=(Array.isArray(t.channels)?t.channels:[]).filter(R).map(e=>({id:z(e.id),name:z(e.name)||void 0})).filter(e=>e.id);return!n||r.length===0?null:{node_url:z(t.node_url)||void 0,node_invite:z(t.node_invite)||void 0,locale:z(t.locale)||void 0,uid:n,identity:B(t.identity),logo:z(t.logo)||void 0,avatar:z(t.avatar)||void 0,name:z(t.name)||void 0,channels:r}}function H(e){return`/chat?channel=${encodeURIComponent(e)}`}function U(e){return String(e||``).trim().slice(0,M)}function W(){let{t:e}=l(),t=_({select:e=>e.searchStr}),{token:n,pub:u,fixture:f}=(0,x.useMemo)(()=>{let e=new URLSearchParams(t);return{token:e.get(`token`)||``,pub:e.get(`pub`)||``,fixture:e.get(`fixture`)||``}},[t]),C=m(e=>e.isDarkMode),w=m(e=>e.setIsDarkMode),T=m(e=>e.hasBackend),E=v(e=>e.setUserIdentity),[M,F]=(0,x.useState)(``),[R,z]=(0,x.useState)(``),[B,W]=(0,x.useState)(!0),[G,K]=(0,x.useState)(``),q=(0,x.useRef)(``);return(0,x.useEffect)(()=>{let t=O(f);if(f&&!t){z(e(`chatJoin.error.unknownFixture`,{fixture:f})),W(!1);return}if(!t&&!n){z(e(`chatJoin.error.missingToken`)),W(!1);return}if(!t&&!u){z(e(`chatJoin.error.missingPub`)),W(!1);return}if(T===null){K(e(`chatJoin.status.checkingBackend`));return}let r=t?`fixture:${f}`:`${n}:${u}`;if(q.current===r)return;q.current=r;async function i(t){if(t.node_url){if(K(e(`chatJoin.status.connectingRemote`)),!(await g({url:t.node_url,invite:t.node_invite||``})).ok)throw Error(e(`chatJoin.error.remoteConnectFailed`));h({url:t.node_url,invite:t.node_invite||``}),m.setState({hasBackend:!0})}else if(!T)throw Error(e(`chatJoin.error.noBackend`));K(e(`chatJoin.status.signingIn`));let n=p(t.uid,``);E({...n,identity:t.identity,displayName:t.name||n.displayName,logo:t.logo,avatar:t.avatar}),K(e(`chatJoin.status.joiningChannel`));let r=``;for(let i of t.channels){let a=await y.createChannel(i.id,`public`,{displayName:t.name||n.displayName,avatar:t.avatar});if(a.conflict)throw Error(e(`chatJoin.error.channelConflict`,{channel:i.id}));let o=a.channelKey||a.key||i.id;r||=o;let s=U(i.name);s&&await y.setChannelRemark(o,s)}let i=t.channels[0];K(e(`chatJoin.status.openingChannel`)),window.location.href=H(r||i.id)}async function a(){try{if(t){K(e(`chatJoin.status.loadingFixture`,{name:t.name||f})),F(k(t)),await i(t);return}K(e(`chatJoin.status.decryptingInvite`));let r=await fetch(`${N}/api/chat.join.decrypt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:n,pub:u})}),a=await r.text(),o=P(a);if(!r.ok)z(L(a,o,e(`chatJoin.error.decrypt`)));else{F(I(a,o));let t=V(o);if(!t){z(e(`chatJoin.error.invalidInvite`));return}await i(t)}}catch(t){z(e(`chatJoin.error.request`,{message:t instanceof Error?t.message:String(t)}))}finally{W(!1)}}a()},[f,T,u,E,e,n]),(0,A.jsx)(c,{sidebar:()=>(0,A.jsxs)(`div`,{className:`sidebar-header sidebar-header-link`,onClick:()=>window.location.href=`/chat`,children:[(0,A.jsx)(d,{size:18}),(0,A.jsx)(`h1`,{children:`MOST PEOPLE`})]}),headerTitle:(0,A.jsx)(`h2`,{className:`header-title`,children:e(`chatJoin.title`)}),headerRight:(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>w(!C),title:e(`common.theme.toggle`),children:C?(0,A.jsx)(o,{size:16}):(0,A.jsx)(s,{size:16})}),children:(0,A.jsx)(`div`,{className:`chat-join-container`,children:(0,A.jsxs)(`div`,{className:`chat-join-panel`,children:[B?(0,A.jsxs)(`div`,{className:`chat-join-loading`,children:[(0,A.jsx)(a,{size:32}),(0,A.jsx)(`p`,{children:G||e(`chatJoin.status.decrypting`)})]}):R?(0,A.jsxs)(`div`,{className:`chat-join-error`,children:[(0,A.jsx)(i,{size:32}),(0,A.jsx)(`p`,{children:R}),G&&(0,A.jsx)(`p`,{className:`chat-join-status`,children:G}),M&&(0,A.jsx)(`pre`,{className:`chat-join-result`,translate:`no`,children:M})]}):(0,A.jsxs)(`div`,{className:`chat-join-success`,children:[(0,A.jsx)(r,{size:32}),(0,A.jsx)(`p`,{children:G||e(`chatJoin.status.decryptSuccess`)}),(0,A.jsx)(`pre`,{className:`chat-join-result`,translate:`no`,children:M})]}),(0,A.jsxs)(`section`,{className:`chat-join-spec`,"aria-labelledby":`chat-join-spec-title`,children:[(0,A.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,A.jsx)(a,{size:18}),(0,A.jsx)(`h3`,{id:`chat-join-spec-title`,children:e(`chatJoin.specTitle`)})]}),(0,A.jsx)(`div`,{className:`chat-join-field-list`,children:S.map(t=>(0,A.jsxs)(`div`,{className:`chat-join-field`,children:[(0,A.jsxs)(`div`,{className:`chat-join-field-meta`,children:[(0,A.jsx)(`code`,{className:`chat-join-field-name`,children:t.name}),(0,A.jsx)(`span`,{children:t.required?e(`chatJoin.field.required`):e(`chatJoin.field.optional`)})]}),(0,A.jsx)(`p`,{children:e(t.descriptionKey)})]},t.name))})]}),(0,A.jsxs)(`section`,{className:`chat-join-helper`,"aria-labelledby":`ea-test-title`,children:[(0,A.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,A.jsx)(a,{size:18}),(0,A.jsx)(`h3`,{id:`ea-test-title`,children:e(`chatJoin.testPublicKey`)})]}),(0,A.jsx)(`code`,{className:`ui-code-box chat-join-public-key`,translate:`no`,children:j}),(0,A.jsx)(`a`,{className:`btn`,href:`/web3/#EA`,target:`_blank`,children:e(`chatJoin.openWeb3`)})]}),(0,A.jsxs)(`section`,{className:`chat-join-helper`,"aria-labelledby":`chat-join-test-title`,children:[(0,A.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,A.jsx)(b,{size:18}),(0,A.jsx)(`h3`,{id:`chat-join-test-title`,children:e(`chatJoin.testAccounts`)})]}),(0,A.jsx)(`div`,{className:`chat-join-test-account-list`,children:D.map(t=>(0,A.jsxs)(`div`,{className:`chat-join-test-account`,children:[(0,A.jsx)(`img`,{className:`chat-join-test-avatar`,src:t.avatar,alt:``}),(0,A.jsxs)(`div`,{className:`chat-join-test-account-main`,children:[(0,A.jsxs)(`div`,{className:`chat-join-test-account-head`,children:[(0,A.jsx)(`strong`,{translate:`no`,children:t.name}),(0,A.jsx)(`span`,{translate:`no`,children:t.identity})]}),(0,A.jsx)(`code`,{translate:`no`,children:t.uid}),(0,A.jsx)(`p`,{translate:`no`,children:t.channels[0]?.name||t.channels[0]?.id})]}),(0,A.jsx)(`a`,{className:`btn btn-secondary`,href:`/chat/join?fixture=${t.uid}`,children:e(`chatJoin.join`)})]},t.uid))})]})]})})})}function G(){return(0,A.jsx)(x.Suspense,{children:(0,A.jsx)(W,{})})}var K=u(`/chat/join/`)({component:G});export{K as Route};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{n as r}from"./upload-ByP6Ydde.js";import{n as i,t as a}from"./triangle-alert-l98G8u9O.js";import{t as o}from"./cloud-BMyOoC2x.js";import{t as s}from"./code-B1Cb_Icm.js";import{n as c}from"./trash-2-BBjpgK_f.js";import{a as l,n as ee,r as te,t as ne}from"./MoveModal-4D9n11Kw.js";import{t as re}from"./LanguageToggle-CtzCCAYv.js";import{n as u,t as d}from"./LogoIcon-Dxto3Sb4.js";import{n as f,t as ie}from"./Nav-9MDdvgNs.js";import{a as p,i as ae,n as oe,o as m,r as h,s as g,t as se}from"./ChatUi-BepWs-ZU.js";import{t as _}from"./plus-BxxbpH6Q.js";import{t as ce}from"./search-BQi5Z0E-.js";import{a as v,i as le,n as y,r as b,t as ue}from"./PemBlock-C8dEIzu-.js";import{t as de}from"./wifi-Bm4biAjc.js";import{B as fe,J as x,U as pe,V as me,W as S,c as C,f as w,i as T,l as E,n as D,o as O,r as k,s as A,u as j}from"./index-QxXZzOUL.js";import{t as M}from"./MarketingThemeToggle-DBaC9bjz.js";import{n as N,r as P,t as F}from"./NoteSidebar-C-rIt32H.js";var I=S(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),L=S(`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`}]]),R=S(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),z=S(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),B=S(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),V=S(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),H=t(e(),1),U=n(),he={name:`产品计划.md`,cid:`bafy-demo-note`,path:`产品/计划`,content:`# MostBox Demo`,size:2048,type:`file`,created_at:17645472e5,updated_at:17645472e5},ge=[{path:`产品`,name:`产品`,parentPath:``,depth:0},{path:`产品/计划`,name:`计划`,parentPath:`产品`,depth:1},{path:`产品/摘录`,name:`摘录`,parentPath:`产品`,depth:1},{path:`灵感`,name:`灵感`,parentPath:``,depth:0}];function W({id:e,icon:t,eyebrow:n,title:r,description:i,children:a}){return(0,U.jsxs)(`section`,{className:`demo-section`,id:e,children:[(0,U.jsxs)(`div`,{className:`demo-section-heading`,children:[(0,U.jsx)(`div`,{className:`demo-section-icon`,children:t}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`demo-eyebrow`,children:n}),(0,U.jsx)(`h2`,{children:r}),(0,U.jsx)(`p`,{children:i})]})]}),a]})}function G({title:e,children:t,className:n=``}){return(0,U.jsxs)(`article`,{className:n?`demo-surface ${n}`:`demo-surface`,children:[(0,U.jsx)(`h3`,{children:e}),t]})}function K(){let[e,t]=(0,H.useState)(`r2`),[n,x]=(0,H.useState)(`今晚同步频道状态`),[S,K]=(0,H.useState)(!1),[q,J]=(0,H.useState)(!1),[_e,Y]=(0,H.useState)(!1),[ve,X]=(0,H.useState)(!1),[ye,Z]=(0,H.useState)(!1),[be,Q]=(0,H.useState)([]),xe=w(e=>e.openConnectModal),Se=j(e=>e.openLoginModal);function $(e,t){Q(n=>[...n.slice(-4),{id:Date.now(),type:e,message:t}])}function Ce(e){Q(t=>t.filter(t=>t.id!==e))}return(0,U.jsxs)(`main`,{className:`demo-page`,children:[(0,U.jsxs)(`header`,{className:`demo-topbar`,children:[(0,U.jsxs)(`a`,{className:`mkt-nav-logo`,href:`/`,children:[(0,U.jsx)(pe,{size:18}),(0,U.jsx)(`span`,{children:`MOST PEOPLE`})]}),(0,U.jsxs)(`div`,{className:`mkt-nav-cta`,children:[(0,U.jsx)(M,{}),(0,U.jsx)(re,{className:`mkt-theme-toggle`})]})]}),(0,U.jsx)(`section`,{className:`demo-hero`,children:(0,U.jsxs)(`div`,{className:`demo-hero-copy`,children:[(0,U.jsx)(`p`,{className:`demo-eyebrow`,children:`Shared Component Library`}),(0,U.jsx)(`h1`,{children:`共享组件检查页`}),(0,U.jsx)(`p`,{children:`把基础样式、全局 UI 片段和已迁入 components 的共享组件按用途集中展示, 方便以后改 UI 时直接从这里检查联动效果。`})]})}),(0,U.jsx)(W,{id:`foundation`,icon:(0,U.jsx)(z,{size:18}),eyebrow:`Foundation`,title:`基础样式`,description:`全局按钮、输入框、开关、分段控件和状态反馈。`,children:(0,U.jsxs)(`div`,{className:`demo-grid demo-grid-two`,children:[(0,U.jsx)(G,{title:`默认按钮`,children:(0,U.jsxs)(`div`,{className:`demo-control-row`,children:[(0,U.jsxs)(`button`,{className:`btn btn-primary`,children:[(0,U.jsx)(i,{size:16}),`Primary`]}),(0,U.jsxs)(`button`,{className:`btn btn-secondary`,children:[(0,U.jsx)(l,{size:16}),`Secondary`]}),(0,U.jsxs)(`button`,{className:`btn btn-ghost`,children:[(0,U.jsx)(B,{size:16}),`Ghost`]}),(0,U.jsxs)(`button`,{className:`btn btn-danger`,children:[(0,U.jsx)(v,{size:16}),`Danger`]}),(0,U.jsx)(`button`,{className:`btn btn-primary`,disabled:!0,children:`Disabled`}),(0,U.jsxs)(`button`,{type:`button`,className:`ui-action-dashed`,children:[(0,U.jsx)(_,{size:16}),`Dashed`]})]})}),(0,U.jsx)(G,{title:`小号按钮`,children:(0,U.jsxs)(`div`,{className:`demo-control-row`,children:[(0,U.jsxs)(`button`,{className:`btn btn-sm btn-primary`,children:[(0,U.jsx)(i,{size:14}),`Primary`]}),(0,U.jsxs)(`button`,{className:`btn btn-sm btn-secondary`,children:[(0,U.jsx)(l,{size:14}),`Secondary`]}),(0,U.jsxs)(`button`,{className:`btn btn-sm btn-ghost`,children:[(0,U.jsx)(B,{size:14}),`Ghost`]}),(0,U.jsxs)(`button`,{className:`btn btn-sm btn-danger`,children:[(0,U.jsx)(v,{size:14}),`Danger`]}),(0,U.jsx)(`button`,{className:`btn btn-sm btn-icon`,"aria-label":`小号图标按钮`,children:(0,U.jsx)(I,{size:14})}),(0,U.jsx)(`button`,{className:`btn btn-sm btn-primary`,disabled:!0,children:`Disabled`}),(0,U.jsxs)(`button`,{type:`button`,className:`ui-action-dashed ui-action-dashed-sm`,children:[(0,U.jsx)(_,{size:14}),`Dashed`]})]})}),(0,U.jsx)(G,{title:`输入控件`,children:(0,U.jsxs)(`div`,{className:`demo-input-grid`,children:[(0,U.jsx)(`input`,{className:`input`,value:`标准输入框`,readOnly:!0}),(0,U.jsx)(`input`,{className:`input input-compact`,value:`紧凑输入框`,readOnly:!0}),(0,U.jsx)(`input`,{className:`input input-pill`,value:`胶囊输入框`,readOnly:!0}),(0,U.jsx)(`textarea`,{className:`textarea`,value:`多行输入框`,rows:3,readOnly:!0}),(0,U.jsxs)(`div`,{className:`ui-input-control`,children:[(0,U.jsx)(ce,{className:`ui-input-icon`,size:15}),(0,U.jsx)(`input`,{className:`input input-compact`,placeholder:`带图标搜索`,readOnly:!0})]})]})}),(0,U.jsx)(G,{title:`开关、分段与徽标`,children:(0,U.jsxs)(`div`,{className:`demo-stack`,children:[(0,U.jsxs)(`label`,{className:`setting-switch`,children:[(0,U.jsx)(`span`,{children:`显示 #地址后四位`}),(0,U.jsx)(`input`,{type:`checkbox`,defaultChecked:!0})]}),(0,U.jsxs)(`label`,{className:`setting-switch`,children:[(0,U.jsx)(`span`,{children:`自动同步`}),(0,U.jsx)(`input`,{type:`checkbox`})]}),(0,U.jsxs)(`div`,{className:`ui-segmented-control download-source-tabs demo-download-source-tabs`,role:`tablist`,"aria-label":`下载来源`,children:[(0,U.jsxs)(`button`,{type:`button`,className:e===`r2`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,role:`tab`,"aria-selected":e===`r2`,onClick:()=>t(`r2`),children:[(0,U.jsx)(o,{size:15}),`R2`]}),(0,U.jsxs)(`button`,{type:`button`,className:e===`github`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,role:`tab`,"aria-selected":e===`github`,onClick:()=>t(`github`),children:[(0,U.jsx)(s,{size:15}),`GitHub`]})]}),(0,U.jsxs)(`div`,{className:`demo-control-row`,children:[(0,U.jsxs)(`span`,{className:`ui-badge success`,children:[(0,U.jsx)(`span`,{className:`status-dot success`}),`已连接`]}),(0,U.jsxs)(`span`,{className:`ui-badge warning`,children:[(0,U.jsx)(`span`,{className:`status-dot warning`}),`检测中`]}),(0,U.jsxs)(`span`,{className:`ui-badge danger`,children:[(0,U.jsx)(`span`,{className:`status-dot danger`}),`不可用`]}),(0,U.jsxs)(`span`,{className:`ui-badge info`,children:[(0,U.jsx)(`span`,{className:`status-dot info`}),`已就绪`]})]})]})})]})}),(0,U.jsx)(W,{id:`brand`,icon:(0,U.jsx)(V,{size:18}),eyebrow:`Brand`,title:`品牌与导航`,description:`Logo、营销导航和页脚放在独立预览面板里,避免和 demo 容器互相挤压。`,children:(0,U.jsxs)(`div`,{className:`demo-grid demo-brand-grid`,children:[(0,U.jsx)(G,{title:`LogoIcon`,children:(0,U.jsxs)(`div`,{className:`demo-logo-row`,children:[(0,U.jsx)(d,{size:24}),(0,U.jsx)(d,{size:36}),(0,U.jsx)(d,{size:52})]})}),(0,U.jsx)(G,{title:`Nav`,className:`demo-nav-preview`,children:(0,U.jsx)(ie,{})}),(0,U.jsx)(G,{title:`Footer`,className:`demo-footer-preview`,children:(0,U.jsx)(f,{})})]})}),(0,U.jsx)(W,{id:`feedback`,icon:(0,U.jsx)(R,{size:18}),eyebrow:`Feedback`,title:`弹窗与反馈`,description:`弹窗、Toast、连接和登录入口都使用按钮触发,页面加载时不主动打开。`,children:(0,U.jsx)(G,{title:`触发式组件`,children:(0,U.jsxs)(`div`,{className:`demo-control-row`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>K(!0),children:[(0,U.jsx)(me,{size:16}),`ModalOverlay`]}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>J(!0),children:[(0,U.jsx)(v,{size:16}),`ConfirmModal`]}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>Y(!0),children:[(0,U.jsx)(V,{size:16}),`InputModal`]}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>$(`info`,`这是一条本地 demo toast`),children:[(0,U.jsx)(I,{size:16}),`Toast`]}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:xe,children:[(0,U.jsx)(fe,{size:16}),`ConnectModal`]}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Se,children:[(0,U.jsx)(L,{size:16}),`UserLoginModal`]})]})})}),(0,U.jsx)(W,{id:`patterns`,icon:(0,U.jsx)(B,{size:18}),eyebrow:`Patterns`,title:`全局样式片段`,description:`页面里反复复用的全局 class 和组合形态。`,children:(0,U.jsxs)(`div`,{className:`demo-grid demo-grid-two`,children:[(0,U.jsx)(G,{title:`文件行`,children:(0,U.jsxs)(`div`,{className:`demo-stack`,children:[(0,U.jsx)(g,{attachment:{kind:`text`,cid:`bafy-demo-text`,fileName:`demo-preview.txt`,link:`most://bafy-demo-text?filename=demo-preview.txt`,size:12697},status:`available`}),(0,U.jsx)(g,{attachment:{kind:`video`,cid:`bafy-demo-video`,fileName:`movie-sample.mp4`,link:`most://bafy-demo-video?filename=movie-sample.mp4`,size:0},status:`checking`})]})}),(0,U.jsx)(G,{title:`空状态`,children:(0,U.jsxs)(`div`,{className:`ui-empty-state demo-empty-preview`,children:[(0,U.jsx)(`div`,{className:`ui-empty-icon`,children:(0,U.jsx)(u,{size:28})}),(0,U.jsx)(`h4`,{className:`ui-empty-title`,children:`暂无消息`}),(0,U.jsx)(`p`,{className:`ui-empty-desc`,children:`开始聊天或选择一个频道。`})]})}),(0,U.jsx)(G,{title:`列表与元信息`,children:(0,U.jsxs)(`div`,{className:`demo-stack`,children:[(0,U.jsx)(`article`,{className:`ui-list-item active`,children:(0,U.jsxs)(`button`,{type:`button`,className:`ui-list-item-main`,children:[(0,U.jsx)(`span`,{className:`ui-list-icon`,children:(0,U.jsx)(c,{size:18})}),(0,U.jsxs)(`span`,{className:`ui-list-copy`,children:[(0,U.jsx)(`span`,{className:`ui-list-title`,children:`产品计划.md`}),(0,U.jsx)(`span`,{className:`ui-list-desc`,children:`CID、下载和做种说明`})]}),(0,U.jsx)(`span`,{className:`ui-list-meta`,children:`今天`})]})}),(0,U.jsx)(`article`,{className:`ui-list-item`,children:(0,U.jsxs)(`button`,{type:`button`,className:`ui-list-item-main`,children:[(0,U.jsx)(`span`,{className:`ui-list-icon warning`,children:(0,U.jsx)(r,{size:18})}),(0,U.jsxs)(`span`,{className:`ui-list-copy`,children:[(0,U.jsx)(`span`,{className:`ui-list-title`,children:`归档`}),(0,U.jsx)(`span`,{className:`ui-list-desc`,children:`文件夹`})]}),(0,U.jsx)(`span`,{className:`ui-list-meta`,children:`12 篇`})]})}),(0,U.jsx)(`div`,{className:`ui-meta-box`,children:`频道 ID:general`}),(0,U.jsx)(`div`,{className:`ui-empty-inline`,children:`暂无成员`})]})}),(0,U.jsx)(G,{title:`通知、标签与代码`,children:(0,U.jsxs)(`div`,{className:`demo-stack`,children:[(0,U.jsxs)(`p`,{className:`ui-notice success`,children:[(0,U.jsx)(i,{size:14}),`同步完成,所有内容已更新。`]}),(0,U.jsxs)(`p`,{className:`ui-notice warning`,children:[(0,U.jsx)(a,{size:14}),`节点正在检测中,请稍候。`]}),(0,U.jsxs)(`ul`,{className:`ui-chip-list demo-chip-preview`,children:[(0,U.jsx)(`li`,{className:`ui-chip`,children:`MostBox`}),(0,U.jsx)(`li`,{className:`ui-chip`,children:`P2P`}),(0,U.jsx)(`li`,{className:`ui-chip`,children:`CID`}),(0,U.jsx)(`li`,{className:`ui-chip`,children:`Hyperdrive`})]}),(0,U.jsx)(`code`,{className:`ui-code-box`,children:`most://bafy-demo-cid?filename=demo.txt`}),(0,U.jsxs)(`div`,{className:`ui-peer-info demo-peer-info`,children:[(0,U.jsx)(`span`,{className:`peer-dot`}),(0,U.jsx)(`span`,{className:`peer-id`,children:`12D3KooW...demo`}),(0,U.jsx)(de,{size:14})]})]})})]})}),(0,U.jsx)(W,{id:`p2p-chat`,icon:(0,U.jsx)(u,{size:18}),eyebrow:`P2P Chat`,title:`P2P 聊天控件`,description:`频道列表、消息气泡、附件消息、输入栏和成员网格都与真实聊天页共用组件。`,children:(0,U.jsxs)(`div`,{className:`demo-grid demo-grid-two`,children:[(0,U.jsx)(G,{title:`频道列表项`,children:(0,U.jsxs)(`div`,{className:`demo-chat-sidebar-preview`,children:[(0,U.jsx)(h,{active:!0,title:`general`}),(0,U.jsx)(h,{title:`design-review`}),(0,U.jsx)(h,{title:`launch-room`,onLeave:()=>$(`info`,`退出频道控件示例`)}),(0,U.jsxs)(`button`,{type:`button`,className:`ui-action-dashed`,children:[(0,U.jsx)(_,{size:16}),`加入频道`]})]})}),(0,U.jsx)(G,{title:`消息气泡`,children:(0,U.jsxs)(`div`,{className:`chat-messages demo-chat-messages-preview`,children:[(0,U.jsx)(p,{variant:`other`,avatarSrc:T(`peer-demo`),author:`Most Peer`,time:`20:16`,children:(0,U.jsx)(m,{children:`节点已在线,可以开始同步频道消息。`})}),(0,U.jsx)(p,{variant:`self`,avatarSrc:T(`self-demo`),author:`Raina`,time:`20:18`,children:(0,U.jsx)(m,{children:`收到,我把控件收进 demo。`})}),(0,U.jsx)(p,{variant:`other`,avatarSrc:T(`file-demo`),author:`Most Peer`,time:`20:19`,children:(0,U.jsx)(oe,{children:(0,U.jsx)(g,{attachment:{kind:`image`,cid:`bafy-chat-demo-image`,fileName:`chat-assets/channel-preview.png`,link:`most://bafy-chat-demo-image?filename=channel-preview.png`,size:186420},status:`available`})})})]})}),(0,U.jsx)(G,{title:`消息输入栏`,className:`demo-chat-composer-card`,children:(0,U.jsx)(ae,{message:n,placeholder:`输入消息...`,onMessageChange:x,onSend:()=>$(`success`,`发送:${n}`),onSelectAttachmentFiles:()=>$(`info`,`图片、视频和文件选择控件示例`)})}),(0,U.jsx)(G,{title:`频道成员`,children:(0,U.jsxs)(`div`,{className:`demo-stack`,children:[(0,U.jsx)(se,{members:[{id:`raina-demo`,name:`Raina`,avatarSrc:T(`raina-demo`)},{id:`peer-a-demo`,name:`Alice#1A2B`,avatarSrc:T(`peer-a-demo`)},{id:`peer-b-demo`,name:`Bob#3C4D`,avatarSrc:T(`peer-b-demo`)}]}),(0,U.jsx)(`div`,{className:`ui-meta-box channel-detail-value channel-detail-mono`,children:`8acdf33076e075168bf889b21d21665b`})]})})]})}),(0,U.jsx)(W,{id:`shared`,icon:(0,U.jsx)(c,{size:18}),eyebrow:`Shared Components`,title:`共享组件`,description:`已迁入 components 的页面组件,只展示外观和轻交互。`,children:(0,U.jsxs)(`div`,{className:`demo-grid demo-grid-two`,children:[(0,U.jsx)(G,{title:`Web3 小组件`,children:(0,U.jsxs)(`div`,{className:`demo-stack`,children:[(0,U.jsx)(y,{title:`Ed25519 公钥`,icon:(0,U.jsx)(v,{size:18}),children:(0,U.jsxs)(`div`,{className:`mono-row`,children:[(0,U.jsx)(`code`,{className:`mono`,children:`ed25519-demo-public-key`}),(0,U.jsx)(le,{text:`ed25519-demo-public-key`})]})}),(0,U.jsx)(b,{icon:(0,U.jsx)(L,{size:32}),message:`请输入用户名和密码以查看身份信息`})]})}),(0,U.jsx)(G,{title:`PEM 与复制`,className:`demo-pem-preview`,children:(0,U.jsx)(ue,{label:`demo.pub`,filename:`demo.pub`,pem:`-----BEGIN PUBLIC KEY-----
2
+ MOSTBOXDEMO
3
+ -----END PUBLIC KEY-----`})}),(0,U.jsxs)(G,{title:`文件管理卡片`,children:[(0,U.jsxs)(`div`,{className:`demo-app-card-grid`,children:[(0,U.jsx)(te,{folder:{name:`图片`,path:`图片`},onClick:()=>$(`info`,`FolderCard demo`)}),(0,U.jsx)(ee,{file:{cid:`bafy-demo-file`,fileName:`图片/demo.png`,starred:!0},isSelected:!0,onSelect:()=>$(`info`,`FileCard select`),onPreview:()=>$(`info`,`FileCard preview`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary demo-move-trigger`,onClick:()=>X(!0),children:[(0,U.jsx)(r,{size:16}),`MoveModal`]})]}),(0,U.jsx)(G,{title:`笔记组件`,children:(0,U.jsxs)(`div`,{className:`demo-note-shell`,children:[(0,U.jsxs)(`div`,{className:`demo-note-header`,children:[(0,U.jsx)(`span`,{children:`笔记`}),(0,U.jsx)(P,{sync:{action:null,status:`synced`,statusLabel:`已同步`,hasConflict:!1,uploadNow:async()=>!0,restoreFromCloud:async()=>!0,exportLocalBackup:()=>$(`info`,`本地导出`),importLocalBackup:()=>$(`info`,`本地导入`)}})]}),(0,U.jsx)(`div`,{className:`sidebar demo-note-sidebar`,children:(0,U.jsx)(F,{children:(0,U.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,U.jsx)(`p`,{children:`NoteSidebar 已迁入 components`})})})}),(0,U.jsxs)(`button`,{type:`button`,className:`btn btn-secondary demo-move-trigger`,onClick:()=>Z(!0),children:[(0,U.jsx)(r,{size:16}),`NoteMoveModal`]})]})})]})}),be.map((e,t)=>(0,U.jsx)(C,{message:e.message,type:e.type,index:t,onDone:()=>Ce(e.id)},e.id)),S&&(0,U.jsx)(E,{onClose:()=>K(!1),children:(0,U.jsxs)(`div`,{className:`demo-basic-modal`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`h3`,{children:`ModalOverlay`}),(0,U.jsx)(`p`,{children:`这是基础容器示例,用来检查玻璃背景、居中和关闭行为。`}),(0,U.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>K(!1),children:`关闭`})]})}),q&&(0,U.jsx)(A,{title:`确认弹窗示例`,message:`用于检查标题、正文、按钮和危险态之外的默认确认状态。`,confirmText:`确认`,onConfirm:()=>{J(!1),$(`success`,`ConfirmModal 已确认`)},onClose:()=>J(!1)}),_e&&(0,U.jsx)(O,{title:`输入弹窗示例`,placeholder:`输入任意文本`,confirmText:`保存`,defaultValue:`MostBox`,onConfirm:e=>{Y(!1),$(`success`,`InputModal: ${e}`)},onClose:()=>Y(!1),validate:e=>e.length<2?`至少输入 2 个字符`:``}),ve&&(0,U.jsx)(ne,{items:[{cid:`bafy-demo-file`}],allFolders:[{name:`图片`,path:`图片`},{name:`壁纸`,path:`图片/壁纸`},{name:`文档`,path:`文档`}],currentPath:`图片`,onMove:e=>{X(!1),$(`success`,`MoveModal: ${e||`根目录`}`)},onClose:()=>X(!1)}),ye&&(0,U.jsx)(N,{target:he,directories:ge,onMove:e=>{Z(!1),$(`success`,`NoteMoveModal: ${e||`全部笔记`}`)},onClose:()=>Z(!1)}),(0,U.jsx)(D,{}),(0,U.jsx)(k,{})]})}var q=x(`/demo/`)({component:K});export{q as Route};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-BqJzntYE.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-QxXZzOUL.js","assets/index-BdaFEQG-.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{n as r}from"./upload-ByP6Ydde.js";import{n as i,t as a}from"./trash-2-BBjpgK_f.js";import{n as o,r as s}from"./LanguageToggle-CtzCCAYv.js";import{t as c}from"./lock-D5OSNhep.js";import{t as l}from"./AppShell-CQhg6DJU.js";import{t as u}from"./notebook-pen-DqKDQ6MJ.js";import{t as d}from"./OpenSidebarButton-Dd0JmKuE.js";import{t as f}from"./plus-BxxbpH6Q.js";import{t as ee}from"./save-DkH1n_Ov.js";import{t as p}from"./search-BQi5Z0E-.js";import{E as m,F as h,G as te,I as g,J as _,L as v,O as y,P as b,T as ne,V as re,W as x,Z as ie,f as S,o as ae,q as oe,s as se,t as C,u as w,z as ce}from"./index-QxXZzOUL.js";import{n as le,r as ue,t as de}from"./NoteSidebar-C-rIt32H.js";var fe=x(`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`}]]),pe=x(`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=`https://api.most.box/auth/backup`;async function D(e,t){return(await e.clone().json().catch(()=>null))?.error||t}function me(e,t){return m(JSON.stringify({notes:e||[]}),t)}function O(e,t){if(!String(e||``).startsWith(`mp://1`))throw Error(`无效的备份数据格式`);let n=ne(e,t);if(!n)throw Error(`解密失败,请确认当前 Web3 登录账号正确`);let r=JSON.parse(n);if(!Array.isArray(r.notes))throw Error(`备份数据缺少 notes`);return r}async function k(e){return b(JSON.stringify({notes:e||[]}))}async function A(e,t,n=E){let r=Date.now().toString(),i=new URL(n).pathname,a=`${r}:${String(t).toUpperCase()}:${i}`,{address:o,signature:s}=await y(e.danger,a);return{Authorization:`${o},${r},${s}`}}async function j(e,t){let n=await b(JSON.stringify({notes:t||[]}));return{cid:n,body:me(t,e.danger),headers:{"Content-Type":`text/plain`,"x-backup-cid":n,...await A(e,`PUT`,E)}}}async function he(e,t,n=E){let r=await j(e,t),i=await fetch(n,{method:`PUT`,headers:r.headers,body:r.body});if(!i.ok)throw Error(await D(i,`云备份失败`));return{cid:r.cid}}async function ge(e,t=E){let n=await fetch(t,{method:`GET`,headers:await A(e,`GET`,t)});if(n.status===404)return{found:!1,cid:``,time:0,notes:[]};if(!n.ok)throw Error(await D(n,`云端恢复失败`));let r=await n.text();if(!r)throw Error(`云端无备份数据`);let i=O(r,e.danger);return{found:!0,cid:n.headers.get(`x-backup-cid`)||``,time:Number(n.headers.get(`x-backup-time`)||0),notes:i.notes}}var M=!1,N=``,P=``;function F(e,t){return e instanceof Error?e.message:t}function I(e,t){switch(e){case`disabled`:return t(`note.sync.status.disabled`);case`checking`:return t(`note.sync.status.checking`);case`uploading`:return t(`note.sync.status.uploading`);case`restoring`:return t(`note.sync.status.restoring`);case`synced`:return t(`note.sync.status.synced`);case`conflict`:return t(`note.sync.status.conflict`);case`error`:return t(`note.sync.status.error`);default:return t(`note.sync.status.idle`)}}function _e(){let{t:e}=te(),t=w(e=>e.wallet),n=w(e=>e.openLoginModal),r=S(e=>e.addToast),i=S(e=>e.notes),a=S(e=>e.importNotes),o=S(e=>e.localDataReady),[s,c]=(0,T.useState)(null),[l,u]=(0,T.useState)(t?`idle`:`disabled`),[d,f]=(0,T.useState)(M),[ee,p]=(0,T.useState)(!1),m=(0,T.useRef)(0),h=(0,T.useCallback)(e=>{M=e,f(e)},[]),g=(0,T.useCallback)((e=!1)=>w.getState().wallet||(e||n(),null),[r,n]),_=(0,T.useCallback)(async(t={})=>{let{silent:n=!1,confirmConflict:i=!0}=t,a=g(n);if(!a)return u(`disabled`),!1;if(M&&i&&!window.confirm(e(`note.sync.confirm.uploadConflict`)))return n||r(e(`note.sync.toast.cancelSync`),`info`),u(`conflict`),!1;c(`save`),u(`uploading`);try{let t=S.getState().notes;return N=(await he(a,t)).cid,P=a.address,h(!1),u(`synced`),n||r(e(`note.sync.toast.cloudUpdated`),`success`),!0}catch(t){return u(`error`),n?console.info(F(t,e(`note.sync.error.backupFailed`))):r(F(t,e(`note.sync.error.backupFailed`)),`error`),!1}finally{c(null)}},[r,g,h,e]),v=(0,T.useCallback)(async(t={})=>{let{manual:n=!1,uploadWhenMissing:i=!1}=t,o=g(!n);if(!o)return u(`disabled`),!1;c(n?`restore`:`sync`),u(n?`restoring`:`checking`);try{let t=await ge(o),s=S.getState().notes;if(!t.found)return h(!1),P=o.address,i&&s.length>0?(c(null),_({silent:!0,confirmConflict:!1})):(u(s.length>0?`idle`:`synced`),n&&r(e(`note.sync.toast.noCloudBackup`),`info`),!1);let l=t.notes||[],d=await k(s),f=t.cid||await k(l);return s.length>0&&d!==f&&!window.confirm(e(`note.sync.confirm.restoreConflict`))?(h(!0),u(`conflict`),n&&r(e(`note.sync.toast.cancelRestore`),`info`),!1):(d!==f&&a(l),N=f,P=o.address,h(!1),u(`synced`),n&&r(e(`note.sync.toast.restoredCloud`),`success`),!0)}catch(t){return u(`error`),n?r(F(t,e(`note.sync.error.restoreCloudFailed`)),`error`):console.info(F(t,e(`note.sync.error.restoreCloudFailed`))),!1}finally{c(null)}},[r,a,g,h,e,_]),y=(0,T.useCallback)(()=>{let t=g(!1);if(t)try{let n=S.getState().notes,i=me(n,t.danger),a=new Blob([i],{type:`text/plain`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`${t.address.slice(-4)}-most-notes-${new Date().toISOString().slice(0,10)}.txt`,s.click(),URL.revokeObjectURL(o),r(e(`note.sync.toast.exportedLocal`),`success`)}catch(t){r(F(t,e(`note.sync.error.exportFailed`)),`error`)}},[r,g,e]),b=(0,T.useCallback)(()=>{let t=g(!1);if(!t)return;let n=document.createElement(`input`);n.type=`file`,n.accept=`.txt`,n.onchange=n=>{let i=n.target.files?.[0];if(!i)return;let o=new FileReader;o.onload=async()=>{try{let n=o.result,i=O(n,t.danger);if(S.getState().notes.length>0&&!window.confirm(e(`note.sync.confirm.importOverwrite`))){r(e(`note.sync.toast.cancelRestore`),`info`);return}a(i.notes),r(e(`note.sync.toast.restoredLocal`),`success`),await _({silent:!0})}catch(t){r(F(t,e(`note.sync.error.importFailed`)),`error`)}},o.readAsText(i)},n.click()},[r,a,g,e,_]);return(0,T.useEffect)(()=>{if(!o)return;if(!t){P=``,N=``,p(!1),h(!1),u(`disabled`);return}if(P===t.address){p(!0),u(M?`conflict`:`synced`);return}let e=!1;return p(!1),v({manual:!1,uploadWhenMissing:!0}).finally(()=>{e||p(!0)}),()=>{e=!0}},[o,v,h,t]),(0,T.useEffect)(()=>{if(!t||!o||!ee||(m.current+=1,m.current<=1))return;let e=window.setTimeout(async()=>{let e=S.getState().notes;await k(e)!==N&&await _({silent:!0})},900);return()=>window.clearTimeout(e)},[ee,o,i,_,t]),{action:s,status:l,statusLabel:(0,T.useMemo)(()=>I(l,e),[l,e]),hasConflict:d,uploadNow:_,restoreFromCloud:v,exportLocalBackup:y,importLocalBackup:b}}var L=n(),ve=(0,T.lazy)(async()=>({default:(await C(()=>import(`./MilkdownEditor-BqJzntYE.js`),__vite__mapDeps([0,1,2,3,4,5]))).MilkdownEditor}));function ye(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,mode:n===`edit`?`edit`:void 0}}function be(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function xe(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 R={"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 z(e,t,n){let r=e instanceof Error?e.message:``,i=R[r];return i?n(i):r||t}function Se(e){return e.type===`directory`?v(e.path?`${e.path}/${e.name}`:e.name):g(e)}function Ce(e,t){let n=new Set;for(let t of e){let e=v(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 B(){let{t:e,formatDate:t,compareStrings:n}=te(),_=ie(),y=oe({select:e=>e.searchStr}),b=(0,T.useMemo)(()=>ye(y),[y]),x=(0,T.useRef)(null),C=_e(),E=S(e=>e.addToast),D=S(e=>e.isDarkMode),me=S(e=>e.setIsDarkMode),O=w(e=>e.wallet),k=w(e=>e.openLoginModal),A=S(e=>e.notes),j=S(e=>e.notesPath),he=S(e=>e.setNotesPath),ge=S(e=>e.saveNote),M=S(e=>e.deleteNote),N=S(e=>e.renameNote),P=S(e=>e.localDataReady),F=b.cid||``,I=A.find(e=>e.cid===F),R=!!F,B=R&&b.mode===`edit`,[V,we]=(0,T.useState)(``),[H,Te]=(0,T.useState)(null),[U,Ee]=(0,T.useState)(null),[W,De]=(0,T.useState)(null),[Oe,G]=(0,T.useState)(``),[ke,K]=(0,T.useState)(``),[Ae,q]=(0,T.useState)(``),[je,Me]=(0,T.useState)(``),[Ne,Pe]=(0,T.useState)(``),[Fe,J]=(0,T.useState)(``),[Y,Ie]=(0,T.useState)(!1),[X,Z]=(0,T.useState)(``),[Le,Re]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(!F){G(``),K(``);return}if(!I){G(``),K(P?e(`note.error.notFound`):``);return}if(I.content.startsWith(`mp://1`)){if(!O){G(``),K(e(`note.error.loginToDecrypt`));return}let t=ne(I.content,O.danger);if(!t){G(``),K(e(`note.error.decryptFailed`));return}G(t),K(``);return}G(I.content||``),K(``)},[F,P,I,e,O]),(0,T.useEffect)(()=>{if(!B){Re(!1);return}if(!F||!I){Me(``),Pe(``),J(``),Ie(!1),Z(P?e(`note.error.notFound`):``);return}if(Me(I.name),Pe(I.path||``),Ie(I.isSecret===!0||I.content.startsWith(`mp://1`)),I.content.startsWith(`mp://1`)){if(!O){J(``),Z(e(`note.error.loginToDecrypt`));return}let t=ne(I.content,O.danger);if(!t){J(``),Z(e(`note.error.decryptFailed`));return}J(t),Z(``);return}J(I.content||``),Z(``)},[F,B,P,I,e,O]),(0,T.useEffect)(()=>{q(I?.name||``)},[I?.cid,I?.name]);let ze=(0,T.useMemo)(()=>h(A,j,V),[A,j,V]),Be=ze.filter(e=>e.type===`file`).length,Ve=I?.isSecret===!0||I?.content.startsWith(`mp://1`)===!0,He=e(B?Y?`note.privacy.secret`:`note.privacy.public`:Ve?`note.privacy.secret`:`note.privacy.public`),Ue=(0,T.useMemo)(()=>{let t=j.split(`/`).filter(Boolean);return[{label:e(`note.root`),path:``},...t.map((e,n)=>({label:e,path:t.slice(0,n+1).join(`/`)}))]},[j,e]),We=(0,T.useMemo)(()=>Ce(A,n),[n,A]);function Q(e={},t=!1){_({href:be(e),replace:t})}function Ge(e){Q({cid:e.cid})}function Ke(e){Q({cid:e.cid,mode:`edit`})}function $(){return O?!0:(k(),!1)}function qe(){Q(I?{cid:I.cid}:{})}async function Je(){if($()){if(!I){E(e(`note.toast.notFound`),`error`);return}if(!je.trim()){E(e(`note.toast.nameRequired`),`warning`);return}Re(!0);try{let t=x.current?.getMarkdown()??Fe,n=Y?m(t,O.danger):t,r=await ge({cid:I.cid,name:je,path:Ne,content:n,isSecret:Y});J(t),E(e(`note.toast.saved`),`success`),await C.uploadNow({silent:!0}),Q({cid:r},!0)}catch(t){E(z(t,e(`note.toast.saveFailed`),e),`error`)}finally{Re(!1)}}}function Ye(){$()&&Te({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if($())try{let n=await ge({name:t,path:j,content:``,isSecret:!1});Te(null),E(e(`note.toast.created`),`success`),await C.uploadNow({silent:!0}),Q({cid:n,mode:`edit`})}catch(t){E(z(t,e(`note.toast.createFailed`),e),`error`)}}})}async function Xe(){if(!$()||!I)return;let t=Ae.trim();if(!t){q(I.name),E(e(`note.toast.nameRequired`),`warning`);return}if(t!==I.name)try{N(g(I),I.path,t),E(e(`note.toast.renamed`),`success`),await C.uploadNow({silent:!0})}catch(t){q(I.name),E(z(t,e(`note.toast.renameFailed`),e),`error`)}}function Ze(e){$()&&De(e)}async function Qe(t){if(W)try{N(Se(W),t,W.name),De(null),E(e(`note.toast.moved`),`success`),await C.uploadNow({silent:!0})}catch(t){E(z(t,e(`note.toast.moveFailed`),e),`error`)}}function $e(t){if(!$())return;let n=t.type===`directory`;Ee({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:t.name}),confirmText:e(`note.action.delete`),onConfirm:async()=>{M(n?void 0:t.cid,t.path,t.name),Ee(null),E(e(`note.toast.deleted`),`success`),await C.uploadNow({silent:!0}),t.type===`file`&&t.cid===F&&Q()}})}let et=(0,L.jsxs)(`div`,{className:`note-header-title`,children:[(0,L.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,L.jsx)(`span`,{children:e(`note.count`,{count:A.length})})]}),tt=(0,L.jsxs)(`div`,{className:`note-theme-wrap`,children:[(0,L.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>me(!D),title:e(`common.theme.toggle`),"aria-label":e(`common.theme.toggle`),children:D?(0,L.jsx)(o,{size:16}):(0,L.jsx)(s,{size:16})}),(0,L.jsx)(ue,{sync:C})]}),nt=(0,L.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,L.jsxs)(`div`,{className:`note-list-header`,children:[(0,L.jsx)(`div`,{className:`note-current-location`,children:(0,L.jsx)(`div`,{className:`note-breadcrumbs`,children:Ue.map((e,t)=>(0,L.jsxs)(T.Fragment,{children:[t>0&&(0,L.jsx)(`span`,{children:`/`}),(0,L.jsx)(`button`,{onClick:()=>he(e.path),children:(0,L.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))})}),(0,L.jsx)(`span`,{className:`note-count`,children:e(`note.count`,{count:Be})})]}),(0,L.jsxs)(`div`,{className:`note-search`,children:[(0,L.jsx)(p,{size:16}),(0,L.jsx)(`input`,{className:`input input-flex`,value:V,onChange:e=>we(e.target.value),placeholder:e(`note.search.placeholder`)})]}),ze.length===0?(0,L.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,L.jsx)(u,{size:32}),(0,L.jsx)(`p`,{children:e(V?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,L.jsx)(`div`,{className:`note-list`,children:ze.map(n=>(0,L.jsx)(`article`,{className:`ui-list-item note-list-item ${n.type===`file`&&n.cid===F?`active`:``}`,children:(0,L.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${n.type===`directory`?`folder`:``}`,onClick:()=>{n.type===`directory`?he(v(n.path?`${n.path}/${n.name}`:n.name)):Ge(n)},children:[(0,L.jsx)(`span`,{className:`ui-list-icon note-list-icon ${n.type===`directory`?`warning`:``}`,children:n.type===`directory`?(0,L.jsx)(r,{size:18}):n.isSecret?(0,L.jsx)(c,{size:18}):(0,L.jsx)(i,{size:18})}),(0,L.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,L.jsx)(`span`,{className:`ui-list-title note-list-name`,translate:`no`,children:n.name}),n.type===`file`?(0,L.jsx)(`span`,{className:`ui-list-desc note-list-preview`,translate:`no`,children:xe(n,e)}):(0,L.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:e(`note.folder`)})]}),n.type===`file`&&(0,L.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:t(n.updated_at)})]})},`${n.cid}:${n.path}:${n.name}`))}),(0,L.jsx)(`div`,{className:`note-create-btn`,children:(0,L.jsxs)(`button`,{className:`btn`,onClick:Ye,children:[(0,L.jsx)(f,{size:16}),e(`note.newNote`)]})})]});return(0,L.jsxs)(l,{sidebar:()=>(0,L.jsx)(de,{children:nt}),headerTitle:et,headerRight:tt,children:[(0,L.jsx)(`main`,{className:`note-page note-browser-page ${R?`has-editor`:``}`,children:(0,L.jsx)(`section`,{className:`note-workspace`,children:(0,L.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(B?`note.editorLabel.edit`:`note.editorLabel.read`),children:R?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,L.jsxs)(`div`,{className:`note-editor-title-area`,children:[B?(0,L.jsx)(`input`,{className:`note-title-input`,value:je,onChange:e=>Me(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!I}):I?(0,L.jsx)(`input`,{className:`note-title-input`,value:Ae,onBlur:Xe,onChange:e=>q(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(q(I.name),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),title:e(`app.rename`),translate:`no`}):(0,L.jsx)(`h3`,{children:e(`note.untitled`)}),I&&(0,L.jsxs)(`div`,{className:`note-editor-info`,children:[(0,L.jsx)(`span`,{children:e(B?`note.mode.edit`:`note.mode.read`)}),(0,L.jsx)(`span`,{children:He}),(0,L.jsx)(`span`,{children:t(I.updated_at)})]})]}),(0,L.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:B?qe:()=>Q(),title:e(B?`common.cancel`:`common.close`),"aria-label":e(B?`common.cancel`:`common.close`),children:(0,L.jsx)(ce,{size:16})}),B?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{className:`btn btn-sm ${Y?`btn-warning`:`btn-secondary`}`,onClick:()=>Ie(!Y),disabled:!I,children:[Y?(0,L.jsx)(c,{size:16}):(0,L.jsx)(re,{size:16}),e(Y?`note.privacy.secret`:`note.privacy.public`)]}),(0,L.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Je,disabled:Le||!!X||!I,children:[(0,L.jsx)(ee,{size:16}),e(Le?`note.action.saving`:`note.action.save`)]})]}):I&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>Ze(I),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,L.jsx)(fe,{size:16})}),(0,L.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>$e(I),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,L.jsx)(a,{size:16})}),(0,L.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>Ke(I),disabled:!!ke,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,L.jsx)(pe,{size:16}),e(`note.action.edit`)]})]})]})]}),B?X?(0,L.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,L.jsx)(c,{size:36}),(0,L.jsx)(`p`,{children:X})]}):I?(0,L.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,L.jsx)(ve,{ref:x,content:Fe,onChange:J,className:`milkdown-editor`})}):(0,L.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,L.jsx)(u,{size:36}),(0,L.jsx)(`p`,{children:e(P?`note.error.notFound`:`note.loading`)})]}):ke?(0,L.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,L.jsx)(c,{size:36}),(0,L.jsx)(`p`,{children:ke})]}):I?(0,L.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,L.jsx)(ve,{content:Oe,readOnly:!0,className:`milkdown-editor`})}):(0,L.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,L.jsx)(u,{size:36}),(0,L.jsx)(`p`,{children:e(P?`note.error.notFound`:`note.loading`)})]})]}):(0,L.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,L.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,L.jsx)(u,{size:32})}),(0,L.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,L.jsx)(`p`,{className:`ui-empty-desc`,children:A.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,L.jsx)(d,{label:e(`note.openList`),variant:`default`})]})})})}),H&&(0,L.jsx)(ae,{title:H.title,placeholder:H.placeholder,defaultValue:H.defaultValue,confirmText:H.confirmText,onConfirm:H.onConfirm,onClose:()=>Te(null)}),U&&(0,L.jsx)(se,{title:U.title,message:U.message,confirmText:U.confirmText,danger:!0,onConfirm:U.onConfirm,onClose:()=>Ee(null)}),W&&(0,L.jsx)(le,{target:W,directories:We,onMove:Qe,onClose:()=>De(null)})]})}function V(){let{t:e}=te();return(0,L.jsx)(T.Suspense,{fallback:(0,L.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:(0,L.jsx)(B,{})})}var we=_(`/note/`)({component:V});export{we as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./copy-C1MttOli.js";import{n as i,r as a}from"./LanguageToggle-CtzCCAYv.js";import{t as o}from"./AppShell-CQhg6DJU.js";import{t as s}from"./play-BIl8q9eU.js";import{a as c,i as l,n as u,r as d,t as f}from"./useGameRoom-DPmweWwe.js";import{C as p,G as ee,J as m,S as h,V as g,W as _,f as v,u as te,w as ne}from"./index-QxXZzOUL.js";var re=_(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),y=t(e(),1),b=[10,20,50,100],x=[`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`],S=[`D`,`C`,`H`,`S`],ie=new Map(x.map((e,t)=>[e,t+2])),C=new Map(S.map((e,t)=>[e,t+1])),w={high:1,pair:2,straight:3,flush:4,straightFlush:5,triple:6},T={[w.high]:`散牌`,[w.pair]:`对子`,[w.straight]:`顺子`,[w.flush]:`金花`,[w.straightFlush]:`顺金`,[w.triple]:`豹子`};function E(e){return String(e||``).trim().toUpperCase().replace(/[^A-Z0-9]/g,``).slice(0,8)}function D(e=`zhajinhua`){return`${e}_${Date.now()}_${ge(4)}`}function O(){return D(`round`)}function ae(){let e=[];for(let t of S)for(let n of x)e.push(`${n}${t}`);return e}function oe(e=ae(),t=Math.random){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 k(e){let t=String(e||``).trim().toUpperCase(),n=t.slice(-1),r=t.slice(0,-1);if(!ie.has(r)||!C.has(n))throw Error(`Invalid card: ${e}`);return{id:`${r}${n}`,rank:r,suit:n,rankValue:ie.get(r),suitValue:C.get(n)}}function se(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]||0,i=t[r]||0;if(n!==i)return n-i}return 0}function A(e){let t=[...new Set(e)].sort((e,t)=>e-t);return t.length===3?t[0]===2&&t[1]===3&&t[2]===14?3:t[0]+1===t[1]&&t[1]+1===t[2]?t[2]:0:0}function j(e){if(!Array.isArray(e)||e.length!==3)throw Error(`炸金花手牌必须是 3 张牌`);let t=e.map(k),n=t.map(e=>e.rankValue),r=new Map;for(let e of n)r.set(e,(r.get(e)||0)+1);let i=new Set(t.map(e=>e.suit)).size===1,a=A(n),o=[...n].sort((e,t)=>t-e),s=Math.max(...t.map(e=>e.suitValue)),c=w.high,l=o;return r.size===1?(c=w.triple,l=[o[0]]):a&&i?(c=w.straightFlush,l=[a]):i?(c=w.flush,l=o):a?(c=w.straight,l=[a]):r.size===2&&(c=w.pair,l=[[...r.entries()].find(([,e])=>e===2)[0],[...r.entries()].find(([,e])=>e===1)[0]]),{category:c,label:T[c],tiebreakers:l,tieSuit:s,cards:t.map(e=>e.id)}}function M(e,t){let n=j(e),r=j(t);if(n.category!==r.category)return n.category-r.category;let i=se(n.tiebreakers,r.tiebreakers);return i===0?n.tieSuit-r.tieSuit:i}function ce(e){return j(e).label}function le({roundId:e,action:t,amount:n,target:r}){return{roundId:e,eventId:D(`action`),action:t,amount:n,target:r}}function ue(e=[]){let t=e.filter(e=>Number(e.chips)>=10);return t.length>=2&&t.length<=5}function de({roomCode:e,players:t,hostAddress:n,previousSeq:r=0,previousWinner:i=``,roundId:a=O(),random:o=Math.random}){let s=t.filter(e=>Number(e.chips)>=10).slice(0,5);if(s.length<2)throw Error(`至少需要 2 名有足够筹码的玩家`);let c=oe(ae(),o),l={},u=s.map((e,t)=>{let n=c.slice(t*3,t*3+3);return l[e.address]=n,{address:e.address,name:e.name,publicKey:e.publicKey,chips:Number(e.chips)-10,status:`active`,looked:!1,bet:10}}),d,f=W(i),p=f?u.findIndex(e=>W(e.address)===f):-1;return d=p>=0?u[p].address:u[Math.floor(o()*u.length)].address,{roomCode:E(e),roundId:a,status:`playing`,host:W(n),seq:r+1,startedAt:Date.now(),ante:10,pot:10*u.length,currentBet:10,turnAddress:d,players:u,lastAction:`本局开始`,winner:null,showdown:null,appliedEventIds:[],hands:l,actionCounts:{},compareReveal:{}}}function fe(e){if(!e)return null;let t={...e};return delete t.hands,G(t)}function pe(e,t){let n=N(e);return!n||!t||typeof t!=`object`?null:{...n,hands:G(t)}}function N(e){return!e||typeof e!=`object`||!e.roundId||!Array.isArray(e.players)?null:{roomCode:E(e.roomCode),roundId:String(e.roundId),status:e.status===`finished`?`finished`:`playing`,host:W(e.host),seq:Number(e.seq)||1,startedAt:Number(e.startedAt)||Date.now(),ante:Number(e.ante)||10,pot:Math.max(0,Number(e.pot)||0),currentBet:Math.max(0,Number(e.currentBet)||10),turnAddress:W(e.turnAddress),players:e.players.map(U).filter(Boolean),lastAction:String(e.lastAction||``),winner:e.winner?W(e.winner):null,showdown:e.showdown&&typeof e.showdown==`object`?G(e.showdown):null,appliedEventIds:Array.isArray(e.appliedEventIds)?e.appliedEventIds.map(String):[],actionCounts:e.actionCounts&&typeof e.actionCounts==`object`?G(e.actionCounts):{},compareReveal:e.compareReveal&&typeof e.compareReveal==`object`?G(e.compareReveal):{},lastCompare:e.lastCompare&&typeof e.lastCompare==`object`?G(e.lastCompare):null,finishedAt:e.finishedAt?Number(e.finishedAt):null}}function P(e,t,n){let r=N(e);if(!r||r.status!==`playing`)return{ok:!1,error:`当前没有进行中的牌局`};let i=W(n),a=r.players.find(e=>e.address===i);if(!a||a.status!==`active`)return{ok:!1,error:`玩家不在本轮牌局中`};if(r.turnAddress!==i)return{ok:!1,error:`还没有轮到你操作`};let o=t?.action;if(![`look`,`call`,`raise`,`compare`,`fold`].includes(o))return{ok:!1,error:`未知操作`};if(o===`look`)return a.looked?{ok:!1,error:`已经看过牌`}:{ok:!0};if(o===`call`)return a.chips>=10?{ok:!0}:{ok:!1,error:`筹码不足,不能跟注`};if(o===`raise`){let e=Number(t.amount);if(!b.includes(e))return{ok:!1,error:`加注档位无效`};let n=r.currentBet+e-a.bet;return a.chips>=n?{ok:!0}:{ok:!1,error:`筹码不足,不能加注`}}if(o===`compare`){let e=W(t.target),n=r.players.find(t=>t.address===e);if(!e||e===i||!n||n.status!==`active`)return{ok:!1,error:`请选择有效的比牌对象`};if(!r.players.filter(e=>e.status===`active`).every(e=>(r.actionCounts?.[e.address]||0)>=1))return{ok:!1,error:`第一轮不能比牌,请先跟注或加注`};let o=Math.max(0,r.currentBet-a.bet);return a.chips>=o?{ok:!0}:{ok:!1,error:`筹码不足,不能比牌`}}return{ok:!0}}function F(e,t,n){let r=P(e,t,n);if(!r.ok)return{ok:!1,error:r.error,state:e};let i=G(e),a=W(n),o=i.players.find(e=>e.address===a),s=String(t.eventId);if(i.appliedEventIds?.includes(s))return{ok:!0,state:i,duplicate:!0};if(Array.isArray(i.appliedEventIds)||(i.appliedEventIds=[]),i.appliedEventIds.push(s),t.action===`look`)return o.looked=!0,i.lastAction=`${o.name} 看牌`,H(i);if(t.action===`fold`)return o.status=`folded`,i.lastAction=`${o.name} 弃牌`,R(i,a),z(i,a);if(t.action===`call`)return o.chips-=10,o.bet+=10,i.pot+=10,i.lastAction=`${o.name} 跟注`,R(i,a),z(i,a);if(t.action===`raise`){let e=Number(t.amount);return i.currentBet+=e,L(i,o),i.lastAction=`${o.name} 加注 ${e}`,R(i,a),z(i,a)}if(t.action===`compare`){L(i,o);let e=W(t.target),n=i.players.find(t=>t.address===e),r=o.looked,s=n.looked,c=M(i.hands?.[a]||[],i.hands?.[e]||[]),l=c>=0?o:n,u=c>=0?n:o;u.status=`folded`,u.looked=!0,i.compareReveal||={};let d=r&&s,f=!r&&!s;if(d)i.compareReveal[a]=i.hands?.[e]||[],i.compareReveal[e]=i.hands?.[a]||[];else if(f)i.compareReveal[u.address]=i.hands?.[l.address]||[];else{let e=r?o:n,t=r?n:o;i.compareReveal[e.address]=i.hands?.[t.address]||[],i.compareReveal[u.address]=i.hands?.[l.address]||[]}return i.lastCompare={initiator:a,target:e,winner:l.address,loser:u.address,initiatorLooked:r,targetLooked:s,timestamp:Date.now()},i.lastAction=`${o.name} 与 ${n.name} 比牌,${u.name} 出局`,R(i,a),z(i,a)}return{ok:!1,error:`未知操作`,state:e}}function I(e){return(e?.players||[]).filter(e=>e.status===`active`)}function me(e,t){let n=(e?.players||[]).find(e=>e.address===W(t));if(!e||e.status!==`playing`||!n||n.status!==`active`||e.turnAddress!==n.address)return[];let r=[];return n.looked||r.push(`look`),P(e,{action:`call`},n.address).ok&&r.push(`call`),b.some(t=>P(e,{action:`raise`,amount:t},n.address).ok)&&r.push(`raise`),I(e).length>1&&e.players.filter(e=>e.status===`active`).every(t=>(e.actionCounts?.[t.address]||0)>=1)&&r.push(`compare`),r.push(`fold`),r}function L(e,t){let n=Math.max(0,e.currentBet-t.bet);t.chips-=n,t.bet+=n,e.pot+=n}function R(e,t){e.actionCounts||={},e.actionCounts[t]=(e.actionCounts[t]||0)+1}function z(e,t){let n=I(e);return n.length===1?B(e,n[0].address):(e.turnAddress=V(e,t),H(e))}function B(e,t){let n=e.players.find(e=>e.address===t),r=e.pot;return n&&(n.chips+=e.pot),e.status=`finished`,e.winner=t,e.winAmount=r,e.turnAddress=``,e.showdown=e.hands?G(e.hands):null,e.lastAction=n?`${n.name} 赢得 ${r} 筹码`:`本局结束`,e.pot=0,e.finishedAt=Date.now(),H(e)}function V(e,t){let n=e.players,r=Math.max(0,n.findIndex(e=>e.address===W(t)));for(let e=1;e<=n.length;e++){let t=n[(r+e)%n.length];if(t.status===`active`)return t.address}return``}function H(e){return e.seq=Number(e.seq||0)+1,{ok:!0,state:e}}function U(e){if(!e||typeof e!=`object`)return null;let t=W(e.address);return t?{address:t,name:String(e.name||he(t)).slice(0,50),publicKey:String(e.publicKey||``),chips:Math.max(0,Number(e.chips)||0),status:e.status===`folded`?`folded`:`active`,looked:e.looked===!0,bet:Math.max(0,Number(e.bet)||0)}:null}function W(e){let t=String(e||``).trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():``}function he(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function G(e){return JSON.parse(JSON.stringify(e))}function ge(e){let t=new Uint8Array(e);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var K={page:`_page_1nzmd_1`,headerActions:`_headerActions_1nzmd_12`,entry:`_entry_1nzmd_18`,entryBrand:`_entryBrand_1nzmd_28`,cardMark:`_cardMark_1nzmd_34`,entryPanel:`_entryPanel_1nzmd_62`,accountLine:`_accountLine_1nzmd_72`,joinForm:`_joinForm_1nzmd_89`,status:`_status_1nzmd_110`,board:`_board_1nzmd_116`,table:`_table_1nzmd_123`,tableCenter:`_tableCenter_1nzmd_144`,finishBanner:`_finishBanner_1nzmd_173`,finishBannerIcon:`_finishBannerIcon_1nzmd_192`,seats:`_seats_1nzmd_196`,seat:`_seat_1nzmd_196`,seatTurn:`_seatTurn_1nzmd_218`,seatWinner:`_seatWinner_1nzmd_223`,seatFolded:`_seatFolded_1nzmd_228`,seatAvatar:`_seatAvatar_1nzmd_232`,seatMain:`_seatMain_1nzmd_244`,seatMeta:`_seatMeta_1nzmd_245`,panel:`_panel_1nzmd_276`,panelSection:`_panelSection_1nzmd_283`,panelTitle:`_panelTitle_1nzmd_293`,hand:`_hand_1nzmd_303`,card:`_card_1nzmd_34`,red:`_red_1nzmd_337`,black:`_black_1nzmd_341`,cardBack:`_cardBack_1nzmd_345`,handLabel:`_handLabel_1nzmd_366`,actionGrid:`_actionGrid_1nzmd_373`,raiseRow:`_raiseRow_1nzmd_374`,statusGrid:`_statusGrid_1nzmd_385`,muted:`_muted_1nzmd_403`,compareOverlay:`_compareOverlay_1nzmd_410`,compareBox:`_compareBox_1nzmd_422`,compareTitle:`_compareTitle_1nzmd_436`,comparePlayers:`_comparePlayers_1nzmd_442`,compareSide:`_compareSide_1nzmd_449`,compareWinner:`_compareWinner_1nzmd_461`,compareName:`_compareName_1nzmd_466`,compareCards:`_compareCards_1nzmd_477`,compareLabel:`_compareLabel_1nzmd_502`,compareVs:`_compareVs_1nzmd_508`,compareResult:`_compareResult_1nzmd_515`},q=n(),_e=`zhajinhua`;function J(...e){return e.filter(Boolean).join(` `)}function Y(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function ve(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function ye(e){return e.displayName||e.username}function be(e){let t=String(e||``),n=t.slice(-1);return{rank:t.slice(0,-1),suit:{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[n]||n,color:n===`H`||n===`D`?`red`:`black`}}function xe(){let{t:e}=ee(),t=v(e=>e.isDarkMode),n=v(e=>e.setIsDarkMode),m=v(e=>e.addToast),_=te(e=>e.initializeUser),[x,S]=(0,y.useState)(``),[ie,C]=(0,y.useState)(!1),w=(0,y.useRef)(``),T=(0,y.useRef)(!1),[E,D]=(0,y.useState)(20),[O,ae]=(0,y.useState)(``),[oe,k]=(0,y.useState)({}),[se,A]=(0,y.useState)(!0),[j,M]=(0,y.useState)(!1),N=(0,y.useRef)(null),P=(0,y.useRef)(new Set),L=f({gameId:_e,onError:e=>m(e,`error`),getPlayerPayload:e=>{let t=h(e.danger);return{address:e.address,name:ye(e),publicKey:t.public_key,joinedAt:Date.now()}}}),R=(0,y.useMemo)(()=>L.userIdentity?.danger?h(L.userIdentity.danger):null,[L.userIdentity?.danger]);(0,y.useEffect)(()=>{_()},[_]),(0,y.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(S(e),w.current=e)},[]),(0,y.useEffect)(()=>{let t=w.current;!t||T.current||!L.isBackendReady||!L.userIdentity||(T.current=!0,w.current=``,L.joinRoom(t).then(t=>{t&&m(e(`game.toast.joinedRoom`),`success`)}))},[L.isBackendReady,L.userIdentity,L.joinRoom,m,e]),(0,y.useEffect)(()=>{if(!L.roomCode)return;let e=`/game/zhajinhua?room=${L.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[L.roomCode]);let z=(0,y.useMemo)(()=>u(L.messages,{gameId:_e,roomCode:L.roomCode}),[L.messages,L.roomCode]),B=(0,y.useMemo)(()=>d(L.messages,{gameId:_e,roomCode:L.roomCode}),[L.messages,L.roomCode])?.payload?.round||null,V=B?.host||z.hostAddress,H=Y(V,L.userIdentity?.address),U=L.userIdentity?.address?.toLowerCase()||``,W=B?.players.find(e=>Y(e.address,U)),he=W||z.players.find(e=>Y(e.address,U)),G=oe[B?.roundId||``]||null,ge=B?.showdown&&U?B.showdown[U]:null,xe=B?.compareReveal&&U?B.compareReveal[U]:null,Z=ge||xe||(W?.looked?G:null),Q=me(B,U),Ce=I(B),we=H&&ue(z.players.map(e=>({...e,chips:B?.players.find(t=>Y(t.address,e.address))?.chips??1e3}))),Te=L.roomCode&&typeof window<`u`?`${window.location.origin}/game/zhajinhua?room=${L.roomCode}`:``;(0,y.useEffect)(()=>{if(!(!B||!L.userIdentity||!R||!V))for(let e of L.roomEvents){let t=e.event;if(!t||t.event!==`deal:private`)continue;let n=t.payload;if(n.roundId!==B.roundId||!Y(n.recipient,L.userIdentity.address))continue;let r=p(n.encrypted||``,{senderPublicKey:n.senderPublicKey||``,recipientPrivateKey:R.private_key});if(r)try{let e=JSON.parse(r);Array.isArray(e)&&k(t=>({...t,[B.roundId]:e.map(String)}))}catch{}}},[B?.roundId,L.roomEvents,L.userIdentity,V,R?.private_key]),(0,y.useEffect)(()=>{if(B?.status===`finished`&&B.winner){A(!0);let e=setTimeout(()=>A(!1),5e3);return()=>clearTimeout(e)}},[B?.finishedAt,B?.status,B?.winner]),(0,y.useEffect)(()=>{if(B?.lastCompare?.timestamp){M(!0);let e=setTimeout(()=>M(!1),5e3);return()=>clearTimeout(e)}else M(!1)},[B?.lastCompare?.timestamp,B?.roundId]),(0,y.useEffect)(()=>{if(!H||!B||B.status!==`playing`)return;let e=N.current;if(!e)return;let t=L.roomEvents.filter(e=>{let t=e.event;if(!t||t.event!==`player:action`)return!1;let n=t.payload.actionEvent;return!(!n||n.roundId!==B.roundId||P.current.has(n.eventId)||B.appliedEventIds?.includes(n.eventId))});if(t.length===0)return;let n=!1;async function r(){let r=pe(B,e);if(r)for(let e of t){if(n)return;let t=(e.event?.payload).actionEvent,i=F(r,t,e.message.author);if(!i.ok){let n=e.message.author;if(!Y(n,L.userIdentity?.address)&&r.status===`playing`&&Y(r.turnAddress,n)){let e=F(r,le({roundId:r.roundId,action:`call`,amount:void 0,target:void 0}),n);if(e.ok)i=e;else{let e=F(r,le({roundId:r.roundId,action:`fold`,amount:void 0,target:void 0}),n);e.ok&&(i=e)}}if(!i.ok){P.current.add(t.eventId);continue}}if(r=i.state,N.current=i.state.hands,await ke(i.state)&&P.current.add(t.eventId),i.state.status===`finished`)break}}return r(),()=>{n=!0}},[B?.roundId,B?.seq,B?.status,L.roomEvents,H]);async function Ee(){await L.createRoom()&&m(e(`game.toast.roomCreated`),`success`)}async function De(t){t.preventDefault(),await L.joinRoom(x)&&m(e(`game.toast.joinedRoom`),`success`)}async function Oe(){Te&&(await navigator.clipboard.writeText(Te),C(!0),setTimeout(()=>C(!1),1400))}async function ke(e){return L.sendRoomEvent(`room:state`,{round:fe(e),seq:e.seq})}async function Ae(){if(!L.userIdentity||!R||!we){m(e(`game.zhajinhua.error.notEnoughPlayers`),`error`);return}try{let t=z.players.map(e=>({...e,chips:B?.players.find(t=>Y(t.address,e.address))?.chips??1e3})),n=de({roomCode:L.roomCode,players:t,hostAddress:L.userIdentity.address,previousSeq:B?.seq||0,previousWinner:B?.winner||``});N.current=n.hands,P.current.clear(),await ke(n);for(let e of n.players){let t=ne(JSON.stringify(n.hands[e.address]),{senderPrivateKey:R.private_key,recipientPublicKey:e.publicKey});await L.sendRoomEvent(`deal:private`,{roundId:n.roundId,recipient:e.address,senderPublicKey:R.public_key,encrypted:t})}k(e=>({...e,[n.roundId]:n.hands[L.userIdentity.address.toLowerCase()]})),m(e(`game.zhajinhua.toast.roundStarted`),`success`)}catch(t){m(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function $(e,t={}){if(!B||!L.userIdentity)return;let n=le({roundId:B.roundId,action:e,amount:t.amount,target:t.target});await L.sendRoomEvent(`player:action`,{actionEvent:n})}let je=B?.status===`playing`?Y(B.turnAddress,U)?e(`game.zhajinhua.status.yourTurn`):B.turnAddress?e(`game.zhajinhua.status.waitingPlayer`,{player:X(B.turnAddress,z.players)}):e(`game.status.playing`):B?.status===`finished`?e(`game.status.finished`):e(`game.status.waitingStart`),Me=Ce.filter(e=>!Y(e.address,U));return(0,q.jsx)(o,{sidebar:({closeSidebar:e})=>(0,q.jsx)(l,{activeGame:`zhajinhua`,closeSidebar:e}),headerTitle:(0,q.jsx)(`h2`,{className:`header-title`,children:e(`game.zhajinhua.title`)}),headerRight:(0,q.jsxs)(`div`,{className:K.headerActions,children:[L.roomCode&&(0,q.jsxs)(`button`,{className:`btn btn-sm`,onClick:Oe,children:[(0,q.jsx)(r,{size:14}),e(ie?`common.copied`:`game.action.shareRoom`)]}),(0,q.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>n(!t),title:e(`common.theme.toggle`),children:t?(0,q.jsx)(i,{size:16}):(0,q.jsx)(a,{size:16})})]}),children:(0,q.jsx)(`main`,{className:K.page,children:L.roomCode?(0,q.jsxs)(`div`,{className:K.board,children:[(0,q.jsxs)(`section`,{className:K.table,children:[B?.status===`finished`&&B.winner&&se&&(0,q.jsxs)(`div`,{className:K.finishBanner,children:[(0,q.jsx)(`span`,{className:K.finishBannerIcon,children:`🏆`}),(0,q.jsx)(`span`,{children:e(`game.zhajinhua.result.winChips`,{player:X(B.winner,z.players),amount:B.winAmount??0})})]}),B?.lastCompare&&j&&(0,q.jsx)(Se,{lastCompare:B.lastCompare,compareReveal:B.compareReveal||{},myAddress:U,myDealtHand:G,lobbyPlayers:z.players,onClose:()=>M(!1)}),(0,q.jsxs)(`div`,{className:K.tableCenter,children:[(0,q.jsx)(`span`,{children:e(`game.zhajinhua.pot`)}),(0,q.jsx)(`strong`,{children:B?.pot||0}),(0,q.jsx)(`small`,{children:e(`game.zhajinhua.currentBet`,{amount:B?.currentBet||0})})]}),(0,q.jsx)(`div`,{className:K.seats,children:z.players.map(t=>{let n=B?.players.find(e=>Y(e.address,t.address)),r=B?.turnAddress===t.address,i=B?.winner===t.address,a=n?.status===`folded`;return(0,q.jsxs)(`div`,{className:J(K.seat,r&&K.seatTurn,i&&K.seatWinner,a&&K.seatFolded),children:[(0,q.jsx)(`div`,{className:K.seatAvatar,children:t.name.slice(0,1)}),(0,q.jsxs)(`div`,{className:K.seatMain,children:[(0,q.jsx)(`strong`,{translate:`no`,children:t.name}),(0,q.jsx)(`span`,{translate:`no`,children:ve(t.address)})]}),(0,q.jsxs)(`div`,{className:K.seatMeta,children:[(0,q.jsx)(`span`,{children:e(`game.zhajinhua.chips`,{amount:n?.chips??1e3})}),(0,q.jsx)(`span`,{children:n?.status===`folded`?e(`game.zhajinhua.player.folded`):n?.looked?e(`game.zhajinhua.player.looked`):e(B?`game.zhajinhua.player.inRound`:`game.status.waitingStart`)})]})]},t.address)})})]}),(0,q.jsxs)(`aside`,{className:K.panel,children:[(0,q.jsxs)(`div`,{className:K.panelSection,children:[(0,q.jsxs)(`div`,{className:K.panelTitle,children:[(0,q.jsx)(c,{size:16}),(0,q.jsx)(`span`,{children:e(`game.zhajinhua.myHand`)})]}),(0,q.jsx)(`div`,{className:K.hand,children:Z?Z.map(e=>{let t=be(e),n=`${t.suit}${t.rank}`;return(0,q.jsxs)(`div`,{className:J(K.card,K[t.color]),children:[(0,q.jsx)(`span`,{children:n}),(0,q.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,q.jsx)(`div`,{className:K.cardBack,children:(0,q.jsx)(c,{size:18})},e))}),(0,q.jsx)(`p`,{className:K.handLabel,children:Z?ce(Z):e(G?`game.zhajinhua.hand.unlooked`:`game.zhajinhua.hand.waitingDeal`)})]}),(0,q.jsxs)(`div`,{className:K.panelSection,children:[(0,q.jsxs)(`div`,{className:K.panelTitle,children:[(0,q.jsx)(s,{size:16}),(0,q.jsx)(`span`,{children:e(`game.actions`)})]}),H?(0,q.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:Ae,disabled:!we||B?.status===`playing`,children:[(0,q.jsx)(re,{size:16}),B?.status===`finished`?e(`game.action.nextRound`):e(`game.action.startRound`)]}):(0,q.jsx)(`p`,{className:K.muted,children:e(`game.waitingHost`)}),H&&B?.status===`finished`&&!we&&(0,q.jsx)(`p`,{className:K.muted,children:e(`game.zhajinhua.error.tooManyLowChips`)}),(0,q.jsxs)(`div`,{className:K.actionGrid,children:[(0,q.jsxs)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`look`),onClick:()=>$(`look`),children:[(0,q.jsx)(g,{size:16}),e(`game.zhajinhua.action.look`)]}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`call`),onClick:()=>$(`call`),children:e(`game.zhajinhua.action.call`)}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`fold`),onClick:()=>$(`fold`),children:e(`game.zhajinhua.action.fold`)})]}),(0,q.jsxs)(`div`,{className:K.raiseRow,children:[(0,q.jsx)(`select`,{className:`input input-compact`,value:E,onChange:e=>D(Number(e.target.value)),children:b.map(t=>(0,q.jsx)(`option`,{value:t,children:e(`game.zhajinhua.action.raiseOption`,{amount:t})},t))}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`raise`),onClick:()=>$(`raise`,{amount:E}),children:e(`game.zhajinhua.action.raise`)})]}),(0,q.jsxs)(`div`,{className:K.raiseRow,children:[(0,q.jsxs)(`select`,{className:`input input-compact`,value:O,onChange:e=>ae(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:e(`game.zhajinhua.action.comparePlaceholder`)}),Me.map(e=>(0,q.jsx)(`option`,{value:e.address,children:e.name},e.address))]}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`compare`)||!O,onClick:()=>$(`compare`,{target:O}),children:e(`game.zhajinhua.action.compare`)})]})]}),(0,q.jsxs)(`div`,{className:K.panelSection,children:[(0,q.jsx)(`div`,{className:K.panelTitle,children:e(`game.status.title`)}),(0,q.jsxs)(`div`,{className:K.statusGrid,children:[(0,q.jsx)(`span`,{children:e(`game.host`)}),(0,q.jsx)(`strong`,{children:V?ve(V):`-`}),(0,q.jsx)(`span`,{children:e(`game.zhajinhua.myChips`)}),(0,q.jsx)(`strong`,{children:he?.chips??1e3}),(0,q.jsx)(`span`,{children:e(`game.round`)}),(0,q.jsx)(`strong`,{children:je}),(0,q.jsx)(`span`,{children:e(`game.hint`)}),(0,q.jsx)(`strong`,{children:B?.lastAction||e(`game.waitingPlayers`)})]})]})]})]}):(0,q.jsxs)(`section`,{className:K.entry,children:[(0,q.jsxs)(`div`,{className:K.entryBrand,children:[(0,q.jsx)(`div`,{className:K.cardMark,children:(0,q.jsx)(c,{size:48})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:e(`game.zhajinhua.hero.title`)}),(0,q.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,q.jsxs)(`div`,{className:K.entryPanel,children:[(0,q.jsxs)(`div`,{className:K.accountLine,children:[(0,q.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,q.jsx)(`strong`,{translate:`no`,children:L.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,disabled:L.joining,onClick:Ee,children:[(0,q.jsx)(s,{size:16}),e(`game.action.createRoom`)]}),(0,q.jsxs)(`form`,{onSubmit:De,className:K.joinForm,children:[(0,q.jsxs)(`label`,{children:[e(`game.roomCode`),(0,q.jsx)(`input`,{value:x,maxLength:8,onChange:e=>S(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,q.jsx)(`button`,{className:`btn`,disabled:L.joining||!x,children:e(`game.action.joinRoom`)})]}),(0,q.jsx)(`p`,{className:K.status,children:L.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Se({lastCompare:e,compareReveal:t,myAddress:n,myDealtHand:r,lobbyPlayers:i,onClose:a}){let{t:o}=ee(),s=X(e.initiator,i),l=X(e.target,i),u=X(e.winner,i),d=Y(n,e.initiator),f=Y(n,e.target),p=d||f;function m(e,i){return t[e]||(p&&Y(e,n)&&i&&r?r:null)}let h=m(e.initiator,e.initiatorLooked),g=m(e.target,e.targetLooked);return(0,q.jsx)(`div`,{className:K.compareOverlay,onClick:a,children:(0,q.jsxs)(`div`,{className:K.compareBox,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(`div`,{className:K.compareTitle,children:o(`game.zhajinhua.compareResult`)}),(0,q.jsxs)(`div`,{className:K.comparePlayers,children:[(0,q.jsxs)(`div`,{className:J(K.compareSide,Y(e.winner,e.initiator)&&K.compareWinner),children:[(0,q.jsx)(`div`,{className:K.compareName,children:s}),(0,q.jsx)(`div`,{className:K.compareCards,children:h?h.map(e=>{let t=be(e);return(0,q.jsxs)(`div`,{className:J(K.card,K[t.color]),children:[(0,q.jsx)(`span`,{children:t.rank}),(0,q.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,q.jsx)(`div`,{className:K.cardBack,children:(0,q.jsx)(c,{size:18})},e))}),h&&(0,q.jsx)(`div`,{className:K.compareLabel,children:ce(h)})]}),(0,q.jsx)(`div`,{className:K.compareVs,children:`VS`}),(0,q.jsxs)(`div`,{className:J(K.compareSide,Y(e.winner,e.target)&&K.compareWinner),children:[(0,q.jsx)(`div`,{className:K.compareName,children:l}),(0,q.jsx)(`div`,{className:K.compareCards,children:g?g.map(e=>{let t=be(e);return(0,q.jsxs)(`div`,{className:J(K.card,K[t.color]),children:[(0,q.jsx)(`span`,{children:t.rank}),(0,q.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,q.jsx)(`div`,{className:K.cardBack,children:(0,q.jsx)(c,{size:18})},e))}),g&&(0,q.jsx)(`div`,{className:K.compareLabel,children:ce(g)})]})]}),(0,q.jsx)(`div`,{className:K.compareResult,children:o(`game.zhajinhua.result.winner`,{player:u})}),(0,q.jsx)(`button`,{className:`btn btn-sm`,onClick:a,children:o(`common.close`)})]})})}function X(e,t){let n=e.toLowerCase();return t.find(e=>e.address===n)?.name||ve(e)}var Z=m(`/game/zhajinhua/`)({component:xe});export{Z as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./check-DUNsD2t6.js";import{r as i,t as a}from"./upload-ByP6Ydde.js";import{t as o}from"./copy-C1MttOli.js";import{t as s}from"./download-y7SZXu6E.js";import{t as ee}from"./SidebarAccount-ClS-N0lq.js";import{n as te,t as ne}from"./trash-2-BBjpgK_f.js";import{n as re,r as ie,t as c}from"./filePreview-UI9NH34f.js";import{a as ae,i as l,n as oe,r as se,t as ce}from"./MoveModal-4D9n11Kw.js";import{n as le,r as ue}from"./LanguageToggle-CtzCCAYv.js";import{r as de,t as fe}from"./AppShell-CQhg6DJU.js";import{t as pe}from"./OpenSidebarButton-Dd0JmKuE.js";import{t as me}from"./search-BQi5Z0E-.js";import{G as he,J as ge,U as _e,W as u,b as ve,f as d,g as f,l as ye,o as be,s as xe,u as Se,v as Ce,z as p}from"./index-QxXZzOUL.js";import{t as we}from"./format-CR8oUWq6.js";import{i as Te,n as m,r as Ee,t as De}from"./downloadValidation-B0p9Ai_9.js";var Oe=u(`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`}]]),ke=u(`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`}]]),Ae=u(`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`}]]),h=t(e(),1);function je(e={}){let t=e.timeout??2e3,[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(!1),o=(0,h.useRef)(null);(0,h.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 g=n();function _(e){return l(e)}function Me(e){let t=new Set;return e.forEach(e=>{let{folder:n}=_(e.fileName),r=n.split(`/`).filter(Boolean),i=``;for(let e of r)i+=(i?`/`:``)+e,t.add(i)}),[...t].sort()}function v(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 Ne(e,t,n){return{folders:v(t,n),files:e.filter(e=>_(e.fileName).folder===n)}}function Pe(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 y(){let e=d(e=>e.isDarkMode),t=d(e=>e.setIsDarkMode),n=d(e=>e.addToast),l=d(e=>e.hasBackend),ge=d(e=>e.openConnectModal),u=Se(e=>e.identity),v=Se(e=>e.openLoginModal),[y,b]=(0,h.useState)([]),[Fe,x]=(0,h.useState)([]),[Ie,S]=(0,h.useState)(null),[C,Le]=(0,h.useState)(`all`),[Re,ze]=(0,h.useState)(!1),[w,T]=(0,h.useState)([]),[Be,E]=(0,h.useState)(null),[D,O]=(0,h.useState)(null),[Ve,He]=de(!1),[Ue,k]=(0,h.useState)(``),[A,j]=(0,h.useState)(null),[M,We]=(0,h.useState)(!1),[Ge,N]=(0,h.useState)([]),[Ke,P]=de(!1),[F,I]=(0,h.useState)(``),{copy:qe,copied:Je}=je({timeout:2e3}),[Ye,L]=de(!1),[R,z]=(0,h.useState)(null),[B,V]=(0,h.useState)(null),[Xe,Ze]=(0,h.useState)(!1),{t:H,formatDate:Qe}=he(),U=l===!0,$e=e=>e?Qe(e):``,W=Ie||``,et=Me(y),{folders:tt,files:nt}=Ne(y,et,W);function G(){return U?!0:(ge(),!1)}function K(){return u?!0:(v(),!1)}let rt=F?y.filter(e=>_(e.fileName).name.toLowerCase().includes(F.toLowerCase())):nt,q=async()=>{if(!U||!u){b([]);return}try{b(await m.listPublishedFiles()||[])}catch{b([])}},J=async()=>{if(!U||!u){x([]);return}try{x(await m.listTrashFiles()||[])}catch{x([])}},it=e=>{T(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},at=async e=>{if(K()&&G())try{await m.restoreTrashFile(e),n(H(`app.toast.restored`),`success`),q(),J()}catch(e){n(await f(e,H(`app.toast.restoreFailed`)),`error`)}},ot=async()=>{K()&&G()&&z({title:H(`app.clearTrash.title`),message:H(`app.clearTrash.message`),confirmText:H(`app.clear`),danger:!0,onConfirm:async()=>{z(null);try{await m.emptyTrash(),n(H(`app.toast.trashEmptied`),`success`),J()}catch(e){n(await f(e,H(`app.toast.emptyFailed`)),`error`)}}})},st=async e=>{if(K()&&G())try{let t=await m.toggleStar(e);b(n=>n.map(n=>n.cid===e?{...n,starred:t.starred}:n)),n(t.starred?H(`app.toast.favorited`):H(`app.toast.unfavorited`),`success`)}catch(e){n(await f(e,H(`app.toast.actionFailed`)),`error`)}},ct=async()=>{if(!K()||!G())return;let e=C===`trash`;z({title:H(e?`app.permanentDelete`:`app.batchDelete`),message:H(e?`app.deleteSelectedPermanent`:`app.deleteSelected`,{count:w.length}),confirmText:H(e?`app.permanentDelete`:`app.delete`),danger:!0,onConfirm:async()=>{z(null);try{for(let t of w)e?await m.permanentDeleteTrashFile(t):t.startsWith(`__`)||await m.deletePublishedFile(t);T([]),n(H(e?`app.toast.deletedPermanently`:`app.toast.deleted`),`success`),q(),J()}catch(e){n(await f(e,H(`app.toast.deleteFailed`)),`error`)}}})},lt=async e=>{if(K()&&G())try{for(let t of w){let n=y.find(e=>e.cid===t);if(!n)continue;let{name:r}=_(n.fileName),i=e?`${e}/${r}`:r;n.fileName!==i&&await m.moveFile(t,i)}T([]),L.close(),n(H(`app.toast.moved`),`success`),q()}catch(e){n(await f(e,H(`app.toast.moveFailed`)),`error`)}},ut=e=>{let t=!!e.path,r=t?e.name:_(e.fileName).name;V({title:H(t?`app.renameFolder`:`app.renameFile`),placeholder:H(`app.enterNewName`),defaultValue:r,confirmText:H(`app.rename`),onConfirm:async i=>{if(i!==r&&K()&&G()){Ze(!0);try{if(t){let t=e.path.lastIndexOf(`/`),r=t===-1?``:e.path.substring(0,t),a=r?`${r}/${i}`:i;await m.renameFolder(e.path,a),n(H(`app.toast.renamed`),`success`),q(),Q(a)}else{let{folder:t}=_(e.fileName),r=t?`${t}/${i}`:i;await m.moveFile(e.cid,r),n(H(`app.toast.renamed`),`success`),q()}V(null)}catch(e){n(await f(e,H(`app.toast.renameFailed`)),`error`)}finally{Ze(!1)}}}})},dt=async e=>{if(!u){v(),n(H(`app.toast.signInBeforePublish`),`warning`);return}if(!G())return;let t=W?W+`/`:``,r=[];for(let i of Array.from(e)){let e=t+i.name;if(y.some(t=>t.fileName===e)){n(H(`app.fileAlreadyExists`,{fileName:i.name}),`warning`);continue}let a=`upload_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o={id:a,fileName:i.name,progress:0,type:`upload`,status:`uploading`};r.push(o),N(e=>[...e,o]),r.length>0&&P.open();try{(await m.publishFile(i,e)).alreadyExists?(N(e=>e.map(e=>e.id===a?{...e,status:`completed`}:e)),n(H(`app.fileAlreadyExists`,{fileName:i.name}),`warning`)):(N(e=>e.map(e=>e.id===a?{...e,progress:100,status:`completed`}:e)),n(H(`app.fileAddedLocal`,{fileName:i.name}),`success`))}catch(e){N(e=>e.map(e=>e.id===a?{...e,status:`error`}:e)),n(await f(e,H(`app.publishFailedWithFile`,{fileName:i.name})),`error`)}}setTimeout(()=>{N(e=>e.filter(e=>e.status!==`completed`&&e.status!==`error`&&e.status!==`cancelled`))},3e3),q()},ft=()=>{qe(`most://${D.cid}?filename=${encodeURIComponent(D.fileName)}`)},[Y,pt]=(0,h.useState)(!1),X=Ue.trim(),Z=A?.status===`success`&&A.link===X,mt=()=>{He.close(),j(null)},ht=e=>{k(e.target.value),j(null)},gt=async()=>{let e=De(X,H);if(e){j({status:`error`,link:X,message:e}),n(e,`warning`);return}if(!(M||Y)&&K()&&G()){We(!0),j(null);try{let e=await m.checkDownload(X);j({status:`success`,link:X,message:e.alreadyExists?H(`app.fileAlreadyLocal`,{fileName:e.fileName}):H(`app.fileAvailable`,{fileName:e.fileName})}),n(e.alreadyExists?H(`app.fileAlreadyExists`,{fileName:e.fileName}):H(`app.toast.checkPassed`),e.alreadyExists?`warning`:`success`)}catch(e){let t=await Ee(e);j({status:`error`,link:X,message:t}),n(t,`error`)}finally{We(!1)}}},_t=async()=>{if(!u){v(),n(H(`app.toast.signInBeforeDownload`),`warning`);return}if(!G())return;let e=De(X,H);if(e){n(e,`warning`);return}if(!Z){n(H(`app.toast.checkLinkFirst`),`warning`);return}if(!Y){pt(!0);try{let e=await m.downloadFile(X);if(k(``),j(null),mt(),e.alreadyExists)n(H(`app.fileAlreadyExists`,{fileName:e.fileName}),`warning`);else{let t={id:e.taskId,fileName:H(`app.downloadFallbackName`),progress:0,type:`download`,status:`downloading`};N(e=>[...e,t]),P.open(),n(H(`app.toast.downloadStarted`),`info`)}}catch(e){n(await f(e,H(`app.toast.downloadFailed`)),`error`)}finally{pt(!1)}}},vt=async e=>{if(K()&&G()&&e.type===`download`&&e.status===`downloading`){N(t=>t.map(t=>t.id===e.id?{...t,status:`cancelling`}:t));try{await m.cancelDownload(e.id)}catch(t){N(t=>t.map(t=>t.id===e.id?{...t,status:`downloading`}:t)),n(await f(t,H(`app.toast.cancelFailed`)),`error`)}}},yt=async e=>{if(K()&&G()){if(e.localAvailable===!1){n(H(`app.toast.fileNotLocal`),`warning`);return}try{let t=await fetch(m.getFileDownloadUrl(e.cid),{headers:await Ce(`GET`,`/api/files/${e.cid}/download`)});if(!t.ok)throw Error(H(`app.toast.getFileFailed`));let r=await t.blob(),i=window.showSaveFilePicker;if(i){let t=await(await i({suggestedName:e.fileName})).createWritable();await t.write(r),await t.close(),n(H(`app.toast.fileSaved`),`success`)}else{let t=URL.createObjectURL(r),i=document.createElement(`a`);i.href=t,i.download=e.fileName,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t),n(H(`app.toast.fileDownloaded`),`success`)}}catch(e){e.name!==`AbortError`&&n(H(`app.saveFailedWithError`,{error:e.message}),`error`)}}},bt=async e=>{if(K()&&G())try{n(H(`app.toast.startPullLocal`),`info`),await m.cacheFile(e.cid),n(H(`app.toast.pulledAndSeeding`),`success`),q()}catch(e){n(await f(e,H(`app.toast.pullFailed`)),`error`)}},Q=e=>{S(e||null),T([])};(0,h.useEffect)(()=>{if(l!==!0)return;let e=null,t=!1;return(async()=>{if(e=new WebSocket(await ve(`/ws`)),t){e.close();return}e.onmessage=e=>{try{let{event:t,data:r}=JSON.parse(e.data);if(t===`publish:success`||t===`download:success`){q();let e=r.taskId||r.fileName;N(t=>t.map(t=>t.id===e||t.fileName===r.fileName?{...t,progress:100,status:`completed`}:t)),t===`download:success`&&(r.alreadyExists?n(H(`app.fileAlreadyExists`,{fileName:r.fileName}),`warning`):n(H(`app.fileDownloadCompleted`,{fileName:r.fileName}),`success`),setTimeout(()=>{N(t=>t.filter(t=>!(t.id===e&&t.status===`completed`)))},3e3))}t===`publish:progress`&&N(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})),t===`download:progress`&&N(e=>e.map(e=>e.id===r.taskId?{...e,progress:r.percent||0,loaded:r.loaded,total:r.total}:e)),t===`download:error`&&(N(e=>e.map(e=>e.id===r.taskId?{...e,status:`error`}:e)),n(H(`app.downloadFailedWithError`,{error:r.error}),`error`)),t===`download:status`&&N(e=>e.map(e=>e.id===r.taskId?{...e,fileName:r.file||e.fileName}:e)),t===`download:cancelled`&&(N(e=>e.map(e=>e.id===r.taskId?{...e,status:`cancelled`}:e)),n(H(`app.toast.downloadCancelled`),`warning`)),t===`user:metadata:updated`&&(q(),J())}catch(e){console.warn(`[App WS] Failed to parse message:`,e.message)}}})(),()=>{t=!0,e?.close()}},[l,u?.address]),(0,h.useEffect)(()=>{if(l===!0&&u){q(),J();return}l===!1&&(b([]),x([]))},[l,u?.address]),(0,h.useEffect)(()=>{u||(T([]),E(null),O(null),k(``),j(null),N([]),I(``),S(null),Le(`all`))},[u?.address]);let xt=H(C===`all`?`app.nav.local`:C===`starred`?`app.nav.favorites`:`app.nav.trash`),$=C===`all`?rt:C===`starred`?y.filter(e=>e.starred&&_(e.fileName).name.toLowerCase().includes(F.toLowerCase())):Fe.filter(e=>_(e.fileName).name.toLowerCase().includes(F.toLowerCase())),St=C===`starred`?[]:tt.filter(e=>e.name.toLowerCase().includes(F.toLowerCase())),Ct=Pe(W,H(`app.allContent`));return(0,g.jsxs)(fe,{sidebar:({closeSidebar:e})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`sidebar-header sidebar-header-link`,onClick:()=>window.location.href=`/`,children:[(0,g.jsx)(_e,{size:18}),(0,g.jsx)(`h1`,{children:`MOST PEOPLE`})]}),(0,g.jsx)(`nav`,{className:`sidebar-nav`,children:[{id:`all`,icon:(0,g.jsx)(ke,{size:18}),label:H(`app.nav.local`)},{id:`starred`,icon:(0,g.jsx)(Ae,{size:18}),label:H(`app.nav.favorites`)},{id:`trash`,icon:(0,g.jsx)(ne,{size:18}),label:H(`app.nav.trash`)}].map(t=>(0,g.jsxs)(`button`,{onClick:()=>{Le(t.id),S(null),T([]),I(``),e()},className:`sidebar-nav-btn ${C===t.id?`active`:``}`,children:[t.icon,(0,g.jsx)(`span`,{children:t.label})]},t.id))}),(0,g.jsx)(ee,{})]}),headerTitle:(0,g.jsx)(`h2`,{className:`header-title`,children:xt}),headerRight:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`search-box`,children:[(0,g.jsx)(me,{size:14}),(0,g.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),placeholder:H(`app.search.placeholder`)}),F&&(0,g.jsx)(`button`,{onClick:()=>I(``),children:(0,g.jsx)(p,{size:12})})]}),C===`trash`&&Fe.length>0&&(0,g.jsx)(`button`,{onClick:ot,className:`btn btn-sm btn-empty-trash`,children:H(`app.emptyTrash`)}),(0,g.jsx)(`button`,{onClick:()=>P.open(),className:`btn btn-icon`,children:(0,g.jsx)(Oe,{size:16})}),(0,g.jsx)(`button`,{onClick:()=>t(!e),className:`btn btn-icon`,children:e?(0,g.jsx)(le,{size:16}):(0,g.jsx)(ue,{size:16})})]}),children:[C===`all`&&(0,g.jsxs)(`div`,{className:`action-grid`,children:[(0,g.jsxs)(`div`,{className:`action-card upload ${Re?`drag-over`:``}`,onDragOver:e=>{e.preventDefault(),ze(!0)},onDragLeave:()=>ze(!1),onDrop:e=>{e.preventDefault(),ze(!1),!(!K()||!G())&&dt(e.dataTransfer.files)},children:[(0,g.jsx)(`input`,{type:`file`,multiple:!0,onClick:e=>{(!K()||!G())&&e.preventDefault()},onChange:e=>dt(e.target.files),className:`action-card-input`}),(0,g.jsx)(a,{size:20,className:`action-grid-icon`}),(0,g.jsx)(`p`,{children:H(`app.publishFile`)})]}),(0,g.jsxs)(`div`,{className:`action-card action-card-download`,onClick:()=>{!K()||!G()||He.open()},children:[(0,g.jsx)(s,{size:20,className:`action-grid-icon`}),(0,g.jsx)(`p`,{children:H(`app.downloadFile`)})]})]}),C===`all`&&(0,g.jsx)(`div`,{className:`breadcrumb`,children:W?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{onClick:()=>Q(``),children:H(`app.allContent`)}),Ct.slice(1).map((e,t)=>(0,g.jsxs)(h.Fragment,{children:[(0,g.jsx)(i,{size:12}),(0,g.jsx)(`button`,{onClick:()=>Q(e.path),className:t===Ct.length-2?`current`:``,children:(0,g.jsx)(`span`,{translate:`no`,children:e.name})}),t===Ct.length-2&&(0,g.jsx)(`button`,{onClick:()=>ut(e),className:`breadcrumb-edit-btn`,children:(0,g.jsx)(re,{size:12})})]},e.path))]}):null}),(0,g.jsxs)(`div`,{className:`content-grid`,children:[C===`trash`&&($.length===0?(0,g.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,g.jsx)(`p`,{children:H(F?`app.noMatches`:`app.trashEmpty`)}),(0,g.jsx)(pe,{label:H(`app.openFileNavigation`)})]}):(0,g.jsx)(`div`,{className:`file-grid`,children:$.map(e=>(0,g.jsxs)(`div`,{onClick:()=>T(t=>t.includes(e.cid)?t.filter(t=>t!==e.cid):[...t,e.cid]),onDoubleClick:()=>at(e.cid),className:`card ${w.includes(e.cid)?`selected`:``}`,children:[(0,g.jsx)(`div`,{className:`card-icon trash`,children:(0,g.jsx)(te,{size:24,color:`#fff`})}),(0,g.jsx)(`p`,{className:`card-name`,translate:`no`,children:_(e.fileName).name}),(0,g.jsx)(`p`,{className:`card-date`,children:H(`app.deletedOn`,{date:$e(e.deletedAt)})})]},e.cid))})),C!==`trash`&&($.length===0&&St.length===0?(0,g.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,g.jsx)(`p`,{children:H(F?`app.noMatches`:C===`starred`?`app.noFavorites`:`app.noLocalFiles`)}),(0,g.jsx)(pe,{label:H(`app.openFileNavigation`)})]}):(0,g.jsxs)(`div`,{className:`file-grid`,children:[St.map(e=>(0,g.jsx)(se,{folder:e,onClick:()=>Q(e.path)},e.path)),$.map(e=>(0,g.jsx)(oe,{file:e,isSelected:w.includes(e.cid),onSelect:it,onPreview:e=>{if(e.localAvailable===!1){n(H(`app.toast.fileNotLocal`),`warning`);return}E({...e,subtype:c(e.fileName)})}},e.cid))]}))]}),R&&(0,g.jsx)(xe,{title:R.title,message:R.message,confirmText:R.confirmText,danger:R.danger,onConfirm:R.onConfirm,onClose:()=>z(null)}),B&&(0,g.jsx)(be,{title:B.title,placeholder:B.placeholder,defaultValue:B.defaultValue,confirmText:B.confirmText,isLoading:Xe,onConfirm:B.onConfirm,onClose:()=>V(null)}),Ye&&(0,g.jsx)(ce,{items:w.map(e=>y.find(t=>t.cid===e)).filter(Boolean),allFolders:et.map(e=>({path:e,name:e.split(`/`).pop()})),currentPath:W,onMove:lt,onClose:()=>L.close()}),D&&(0,g.jsx)(ye,{onClose:()=>O(null),children:(0,g.jsxs)(`div`,{className:`share-modal`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`modal-header`,children:[(0,g.jsx)(`h3`,{children:H(`app.shareLink`)}),(0,g.jsx)(`button`,{onClick:()=>O(null),className:`btn btn-icon`,children:(0,g.jsx)(p,{size:18})})]}),(0,g.jsxs)(`div`,{className:`share-link-box`,children:[(0,g.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:`most://${D.cid}?filename=${encodeURIComponent(D.fileName)}`}),(0,g.jsx)(`button`,{onClick:ft,className:`btn btn-circle btn-primary ${Je?`copied`:``}`,children:Je?(0,g.jsx)(r,{size:18}):(0,g.jsx)(o,{size:18})})]}),(0,g.jsx)(`div`,{className:`share-storage-note`,children:(0,g.jsx)(`span`,{children:H(`app.shareSeedNote`)})})]})}),Ve&&(0,g.jsx)(ye,{onClose:mt,children:(0,g.jsxs)(`div`,{className:`download-modal`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`modal-header`,children:[(0,g.jsx)(`h3`,{children:H(`app.downloadFile`)}),(0,g.jsx)(`button`,{onClick:mt,className:`btn btn-icon`,children:(0,g.jsx)(p,{size:18})})]}),(0,g.jsxs)(`div`,{className:`download-link-row`,children:[(0,g.jsx)(`input`,{type:`text`,className:`input`,value:Ue,onChange:ht,placeholder:H(`app.downloadLink.placeholder`)}),(0,g.jsxs)(`button`,{type:`button`,onClick:gt,disabled:!X||M||Y,className:`btn btn-secondary download-check-btn`,children:[M?(0,g.jsx)(ie,{size:14,className:`spin`}):Z?(0,g.jsx)(r,{size:14}):(0,g.jsx)(me,{size:14}),H(M?`app.checking`:Z?`app.passed`:`app.check`)]})]}),A&&(0,g.jsxs)(`div`,{className:`download-check-status ${A.status}`,children:[A.status===`success`?(0,g.jsx)(r,{size:14}):(0,g.jsx)(ae,{size:14}),(0,g.jsx)(`span`,{children:A.message})]}),(0,g.jsxs)(`button`,{onClick:_t,disabled:!Z||Y||M,className:`btn btn-info btn-full`,children:[Y?(0,g.jsx)(ie,{size:14,className:`spin`}):(0,g.jsx)(s,{size:14}),H(Y?`app.downloading`:`app.startDownload`)]})]})}),Be&&(0,g.jsx)(Te,{item:Be,isBackendReady:U,getFileDownloadUrl:m.getFileDownloadUrl,onClose:()=>E(null)}),w.length>0&&(0,g.jsxs)(`div`,{className:`batch-bar`,children:[(0,g.jsx)(`span`,{className:`batch-info`,children:H(`app.selectedItems`,{count:w.length})}),(0,g.jsx)(`button`,{onClick:()=>T([]),className:`batch-dismiss`,children:(0,g.jsx)(p,{size:16})}),(0,g.jsx)(`div`,{className:`batch-divider`}),C===`trash`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{onClick:async()=>{K()&&G()&&(await Promise.all(w.map(e=>m.restoreTrashFile(e))),T([]),n(H(`app.toast.restored`),`success`),q(),J())},className:`btn btn-sm`,children:H(`app.restore`)}),(0,g.jsx)(`button`,{onClick:ct,className:`btn btn-sm btn-danger`,children:H(`app.permanentDelete`)})]}):(0,g.jsxs)(g.Fragment,{children:[w.length===1&&(()=>{let e=y.find(e=>e.cid===w[0]);return e&&c(e.fileName)!==`file`})()&&(0,g.jsx)(`button`,{onClick:()=>{let e=y.find(e=>e.cid===w[0]);if(e){if(e.localAvailable===!1){n(H(`app.toast.fileNotLocal`),`warning`);return}let t=c(e.fileName);E({...e,subtype:t})}},className:`btn btn-sm`,children:H(`app.preview`)}),(0,g.jsx)(`button`,{onClick:()=>{let e=w.some(e=>{let t=y.find(t=>t.cid===e);return t&&!t.starred});w.forEach(t=>{let n=y.find(e=>e.cid===t);n&&(e?!n.starred:n.starred)&&st(t)})},className:`btn btn-sm btn-star`,children:H(`app.favorite`)}),w.length===1&&(0,g.jsx)(`button`,{onClick:()=>{let e=y.find(e=>e.cid===w[0]);e&&ut(e)},className:`btn btn-sm`,children:H(`app.rename`)}),(0,g.jsx)(`button`,{onClick:()=>L.open(),className:`btn btn-sm btn-move`,children:H(`app.move`)}),(0,g.jsx)(`button`,{onClick:ct,className:`btn btn-sm btn-danger`,children:H(`app.delete`)}),w.length===1&&(()=>{let e=y.find(e=>e.cid===w[0]);return e&&e.localAvailable===!1})()&&(0,g.jsx)(`button`,{onClick:()=>{let e=y.find(e=>e.cid===w[0]);e&&bt(e)},className:`btn btn-sm`,children:H(`app.pullToLocal`)}),w.length===1&&(0,g.jsx)(`button`,{onClick:()=>O(y.find(e=>e.cid===w[0])),className:`btn btn-sm`,children:H(`app.share`)}),w.length===1&&(0,g.jsx)(`button`,{onClick:()=>{let e=y.find(e=>e.cid===w[0]);e&&yt(e)},className:`btn btn-sm`,children:H(`app.saveAs`)})]})]}),Ke&&(0,g.jsx)(ye,{onClose:()=>P.close(),children:(0,g.jsxs)(`div`,{className:`transfer-modal`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`modal-header`,children:[(0,g.jsx)(`h3`,{children:H(`app.transfers`)}),(0,g.jsx)(`button`,{onClick:()=>P.close(),className:`btn btn-icon`,children:(0,g.jsx)(p,{size:18})})]}),Ge.length===0?(0,g.jsx)(`div`,{className:`empty-transfer`,children:H(`app.noTransfers`)}):Ge.map(e=>(0,g.jsxs)(`div`,{className:`transfer-item`,children:[(0,g.jsxs)(`div`,{className:`transfer-item-header`,children:[e.type===`upload`?(0,g.jsx)(a,{size:14}):(0,g.jsx)(s,{size:14}),(0,g.jsx)(`span`,{className:`transfer-item-name`,translate:`no`,children:e.fileName}),e.status===`downloading`&&e.type===`download`&&(0,g.jsx)(`button`,{onClick:()=>vt(e),className:`transfer-item-cancel`,children:(0,g.jsx)(p,{size:14})})]}),(0,g.jsxs)(`div`,{className:`transfer-progress-row`,children:[(0,g.jsx)(`progress`,{className:`transfer-progress-meter ${e.type===`download`?`download`:``} ${e.status===`error`?`error`:``} ${e.status===`cancelled`?`cancelled`:``}`,value:Math.max(0,Math.min(100,e.progress)),max:100,"aria-label":H(`app.transferProgress`,{fileName:e.fileName})}),(0,g.jsx)(`span`,{className:`transfer-progress-text`,children:e.status===`completed`?H(`app.completed`):e.status===`error`?H(`app.failed`):e.status===`cancelled`?H(`app.cancelled`):e.status===`cancelling`?H(`app.cancelling`):e.loaded&&e.total?`${we(e.loaded)}/${we(e.total)}`:`${e.progress}%`})]})]},e.id))]})})]})}var b=ge(`/app/`)({component:y});export{b as Route};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./chevron-down-D6mpsfv4.js";import{n as i,t as a}from"./wallet-c7zIhNSM.js";import{t as o}from"./key-round-CZniN9lv.js";import{n as s,r as c}from"./LanguageToggle-CtzCCAYv.js";import{t as l}from"./lock-D5OSNhep.js";import{t as u}from"./AppShell-CQhg6DJU.js";import{a as d,i as f,n as p,r as m,t as h}from"./PemBlock-C8dEIzu-.js";import{A as g,C as _,D as v,G as y,H as b,J as x,M as S,N as C,S as w,U as T,V as E,W as D,f as ee,i as te,j as ne,k as re,u as ie,w as ae}from"./index-QxXZzOUL.js";import{t as oe}from"./dayjs.min-Dcc0B6Je.js";var se=D(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ce=D(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),le=D(`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`}]]),ue=D(`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`}]]),de=D(`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`}]]),fe=D(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),O=t(e()),k=t(ne(),1);oe();var pe=`0123456789abcdefghijklmnopqrstuvwxyz`,me=e=>{let t=[];for(;e>=128;)t.push(e&127|128),e>>=7;return t.push(e),t},he=e=>{let t=new Uint8Array([8,1,18,...me(e.length)]),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n},ge=(e,t)=>{if(e.length===0)return``;let n=t.length,r=0;for(;r<e.length&&e[r]===0;)r++;let i=[0];for(let t=r;t<e.length;t++){let r=e[t];for(let e=0;e<i.length;e++){let t=i[e]*256+r;i[e]=t%n,r=Math.floor(t/n)}for(;r>0;)i.push(r%n),r=Math.floor(r/n)}let a=``;for(let e=0;e<r;e++)a+=t[0];for(let e=i.length-1;e>=0;e--)a+=t[i[e]];return a},_e=(e,t)=>{let n=t.slice(2),r=new Uint8Array(C(e+n));return k.default.sign.keyPair.fromSecretKey(r)},ve=(e,t)=>{let n=he(_e(e,t).publicKey),r=new Uint8Array(2+n.length);r[0]=0,r[1]=36,r.set(n,2);let i=new Uint8Array([1,114]),a=new Uint8Array(i.length+r.length);return a.set(i,0),a.set(r,i.length),`k`+ge(a,pe)},A=n();function ye(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function j({title:e,username:t,password:n,showPassword:r,showPrivateKey:i,account:a,onUsernameChange:s,onPasswordChange:c,onTogglePassword:l,onTogglePrivateKey:u,onGenerate:d}){let{t:p}=y();return(0,A.jsxs)(`div`,{className:`web3-box-account`,children:[(0,A.jsx)(`div`,{className:`web3-box-account-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:e}),(0,A.jsx)(`p`,{children:p(`web3.box.account.desc`)})]})}),(0,A.jsxs)(`div`,{className:`web3-box-login`,children:[(0,A.jsx)(`input`,{type:`text`,placeholder:p(`login.username.placeholder`),value:t,onChange:e=>s(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.jsx)(`input`,{type:r?`text`:`password`,placeholder:p(`web3.login.passwordOptional`),value:n,onChange:e=>c(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`button`,{className:`input-eye`,onClick:l,type:`button`,children:r?(0,A.jsx)(b,{size:16}):(0,A.jsx)(E,{size:16})})]}),(0,A.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:d,disabled:!t.trim(),type:`button`,children:[(0,A.jsx)(o,{size:16}),p(`web3.box.account.generate`)]})]}),a?(0,A.jsxs)(`div`,{className:`web3-box-key-list`,children:[(0,A.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,A.jsx)(`span`,{children:p(`web3.label.address`)}),(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:a.address.toLowerCase()}),(0,A.jsx)(f,{text:a.address.toLowerCase()})]})]}),(0,A.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,A.jsx)(`span`,{children:p(`web3.label.x25519Public`)}),(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:a.publicKey}),(0,A.jsx)(f,{text:a.publicKey})]})]}),(0,A.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,A.jsx)(`span`,{children:p(`web3.label.x25519Private`)}),(0,A.jsxs)(`div`,{className:`mono-row danger`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:i?a.privateKey:ye(a.privateKey)}),(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:u,title:p(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,A.jsx)(E,{size:14}):(0,A.jsx)(b,{size:14})})]})]})]}):null]})}function be(e,t){return Number.isFinite(e)?t(e):`-`}function M({title:e,description:t,message:n,cipherText:r,decryptedText:i,error:a,encryptLabel:s,decryptLabel:c,messagePlaceholder:u,cipherPlaceholder:d,onMessageChange:f,onCipherTextChange:p,onEncrypt:m,onDecrypt:h}){let{t:_,formatDateTime:v}=y(),b=`box-message-${e.replaceAll(/\s+/g,`-`)}`,x=g(r);return(0,A.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,A.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:e}),(0,A.jsx)(`p`,{children:t})]})}),(0,A.jsx)(`label`,{className:`web3-box-label`,htmlFor:b,children:_(`web3.box.plaintext`)}),(0,A.jsx)(`textarea`,{id:b,className:`textarea`,value:n,onChange:e=>f(e.target.value),rows:4,placeholder:u,translate:`no`}),(0,A.jsxs)(`div`,{className:`web3-box-actions`,children:[(0,A.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,type:`button`,children:[(0,A.jsx)(l,{size:16}),s]}),(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:h,type:`button`,children:[(0,A.jsx)(o,{size:16}),c]})]}),a&&(0,A.jsx)(`p`,{className:`web3-tools-danger`,children:a}),(0,A.jsxs)(`div`,{className:`web3-box-result-grid`,children:[(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:_(`web3.box.ciphertext`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:r,onChange:e=>p(e.target.value),rows:5,placeholder:d,translate:`no`})]}),(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:_(`web3.box.decryptResult`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:i,readOnly:!0,rows:5,placeholder:_(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]}),x&&(0,A.jsxs)(`div`,{className:`web3-box-token-meta`,children:[(0,A.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,A.jsx)(`span`,{children:_(`web3.box.timestamp`)}),(0,A.jsx)(`code`,{translate:`no`,children:be(x.timestampMs,v)})]}),(0,A.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,A.jsx)(`span`,{children:_(`web3.box.nonce`)}),(0,A.jsx)(`code`,{translate:`no`,children:x.nonce})]})]})]})}function xe(e){let{t}=y();return(0,A.jsxs)(`div`,{className:`web3-box-workspace`,children:[(0,A.jsxs)(`div`,{className:`web3-box-grid`,children:[(0,A.jsx)(j,{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,A.jsx)(j,{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,A.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,A.jsx)(M,{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,A.jsx)(M,{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,A.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,A.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,A.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`web3.box.encryptTitle`)}),(0,A.jsx)(`p`,{children:t(`web3.box.encryptDesc`)})]})}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.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,A.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxEncryptShowPrivateKeyToggle,type:`button`,children:e.boxEncryptShowPrivateKey?(0,A.jsx)(b,{size:16}):(0,A.jsx)(E,{size:16})})]}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,A.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,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.plaintext`)})}),(0,A.jsx)(`textarea`,{className:`textarea`,value:e.boxEncryptMessage,onChange:t=>e.onBoxEncryptMessageChange(t.target.value),rows:4,placeholder:t(`web3.box.messagePlaceholder`),translate:`no`}),(0,A.jsx)(`div`,{className:`web3-box-actions`,children:(0,A.jsxs)(`button`,{className:`btn btn-primary`,onClick:e.onEncryptOnly,type:`button`,children:[(0,A.jsx)(l,{size:16}),t(`web3.box.encryptTitle`)]})}),e.boxEncryptError&&(0,A.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxEncryptError}),(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:e.boxEncryptCipherText,readOnly:!0,rows:5,placeholder:t(`web3.box.encryptResultPlaceholder`),translate:`no`})]})]}),(0,A.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,A.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`web3.box.decryptTitle`)}),(0,A.jsx)(`p`,{children:t(`web3.box.decryptDesc`)})]})}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,A.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,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.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,A.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxDecryptShowPrivateKeyToggle,type:`button`,children:e.boxDecryptShowPrivateKey?(0,A.jsx)(b,{size:16}):(0,A.jsx)(E,{size:16})})]}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,A.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,A.jsx)(`div`,{className:`web3-box-actions`,children:(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:e.onDecryptOnly,type:`button`,children:[(0,A.jsx)(o,{size:16}),t(`web3.box.decryptTitle`)]})}),e.boxDecryptError&&(0,A.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxDecryptError}),(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.decryptResult`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptResult,readOnly:!0,rows:5,placeholder:t(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]})]})]})}function Se({walletResult:e,publicPem:t,privatePem:n}){let{t:r}=y();if(!t||!n)return(0,A.jsx)(m,{icon:(0,A.jsx)(l,{size:36}),message:r(`web3.empty.pem`)});let i=e?.username||`wallet`;return(0,A.jsxs)(`div`,{className:`web3-pem-list`,children:[(0,A.jsx)(h,{label:`${i}.pub`,pem:t,filename:`${i}.pub`}),(0,A.jsx)(h,{label:`${i}.pem`,pem:n,filename:`${i}.pem`})]})}var Ce=Object.defineProperty,N=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,F=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||={})we.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))P.call(t,n)&&F(e,n,t[n]);return e},L=(e,t)=>{var n={};for(var r in e)we.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&N)for(var r of N(e))t.indexOf(r)<0&&P.call(e,r)&&(n[r]=e[r]);return n},R;(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})(R||={}),(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||={})})(R||={}),(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||={})})(R||={});var z=R,B={L:z.QrCode.Ecc.LOW,M:z.QrCode.Ecc.MEDIUM,Q:z.QrCode.Ecc.QUARTILE,H:z.QrCode.Ecc.HIGH},V=128,Te=`L`,H=`#FFFFFF`,U=`#000000`,Ee=!1,W=1,De=4,G=0,Oe=.1;function K(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 ke(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 q(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*Oe),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 Ae(e,t){return t==null?e?De:G:Math.max(Math.floor(t),0)}function J({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(...z.QrSegment.makeSegments(t)),e),[]);return z.QrCode.encodeSegments(r,B[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=Ae(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:q(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var je=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Me=O.forwardRef(function(e,t){let n=e,{value:r,size:i=V,level:a=Te,bgColor:o=H,fgColor:s=U,includeMargin:c=Ee,minVersion:l=W,boostLevel:u,marginSize:d,imageSettings:f}=n,p=L(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=L(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}=J({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=ke(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,je?t.fill(new Path2D(K(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 E=I({height:i,width:i},m),D=null;return g!=null&&(D=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`,I({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});Me.displayName=`QRCodeCanvas`;var Y=O.forwardRef(function(e,t){let n=e,{value:r,size:i=V,level:a=Te,bgColor:o=H,fgColor:s=U,includeMargin:c=Ee,minVersion:l=W,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=L(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=J({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=ke(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=K(y,h);return O.createElement(`svg`,I({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)});Y.displayName=`QRCodeSVG`;function Ne({walletResult:e,mnemonicPhrase:t,deriveBatch:n,deriveList:i,deriveShowIndex:s,deriveShowAddress:c,deriveShowPrivateKey:l,showAddressQr:u,showMnemonicReveal:p,showMnemonicQr:h,onToggleAddressQr:g,onToggleMnemonicReveal:_,onToggleMnemonicQr:v,onToggleDeriveIndex:b,onToggleDeriveAddress:x,onToggleDerivePrivateKey:S,onDerive:C}){let{t:w}=y(),T=e?.address||``;return!e||!T?(0,A.jsx)(m,{icon:(0,A.jsx)(a,{size:36}),message:w(`web3.empty.walletTools`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,A.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:g,children:[(0,A.jsx)(ue,{size:14}),w(u?`web3.action.hideAddressQr`:`web3.action.showAddressQr`),u?(0,A.jsx)(se,{size:14}):(0,A.jsx)(r,{size:14})]}),u&&(0,A.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,A.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,A.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:T}),(0,A.jsx)(f,{text:T})]}),(0,A.jsx)(`div`,{className:`qr-wrap`,children:(0,A.jsx)(Y,{value:T,size:200})})]})]}),t&&(0,A.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,A.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:_,children:[(0,A.jsx)(o,{size:14}),w(p?`web3.action.hideMnemonic`:`web3.action.showMnemonic`),p?(0,A.jsx)(se,{size:14}):(0,A.jsx)(r,{size:14})]}),p&&(0,A.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,A.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,A.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:t}),(0,A.jsx)(f,{text:t})]}),(0,A.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,A.jsx)(d,{size:14}),w(`web3.warning.mnemonic`)]}),(0,A.jsx)(`button`,{className:`web3-tools-toggle`,onClick:v,children:w(h?`web3.action.hideMnemonicQr`:`web3.action.showMnemonicQr`)}),h&&(0,A.jsx)(`div`,{className:`qr-wrap`,children:(0,A.jsx)(Y,{value:t,size:260})})]})]}),t&&(0,A.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`button`,{className:`btn btn-primary`,onClick:C,children:w(`web3.action.deriveAddresses`,{count:n})})}),(0,A.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,A.jsx)(d,{size:14}),w(`web3.warning.privateKey`)]}),i.length>0&&(0,A.jsx)(`div`,{className:`web3-derive-table-wrap`,children:(0,A.jsxs)(`table`,{className:`web3-derive-table`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{onClick:b,className:`web3-derive-th`,children:w(`web3.label.account`)}),(0,A.jsx)(`th`,{onClick:x,className:`web3-derive-th`,children:w(`web3.label.address`)}),(0,A.jsx)(`th`,{onClick:S,className:`web3-derive-th danger`,children:w(`web3.label.privateKeyToggle`,{action:w(l?`web3.action.hide`:`web3.action.show`)})})]})}),(0,A.jsx)(`tbody`,{children:i.map(e=>(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`td`,{children:s?e.index+1:``}),(0,A.jsx)(`td`,{translate:`no`,children:c?e.address:``}),(0,A.jsx)(`td`,{className:`danger`,children:(0,A.jsx)(`span`,{translate:`no`,children:l?e.privateKey:``})})]},e.index))})]})})]})]})}function Pe(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function Fe({walletResult:e,keys:t,ipns:n,avatarSrc:r,showPrivateKey:a,onTogglePrivateKey:s}){let{t:c}=y(),l=e?.address||``;return!e||!l?(0,A.jsx)(m,{icon:(0,A.jsx)(fe,{size:36}),message:c(`web3.empty.identity`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`web3-identity-card`,children:[(0,A.jsx)(`img`,{src:r,alt:`avatar`,className:`web3-identity-avatar`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`web3-identity-name`,children:e.username||c(`web3.notSignedIn`)}),(0,A.jsxs)(`div`,{className:`web3-identity-address`,children:[(0,A.jsx)(`code`,{translate:`no`,children:l.toLowerCase()}),(0,A.jsx)(f,{text:l.toLowerCase()}),(0,A.jsxs)(`a`,{href:`https://debank.com/profile/${l}`,target:`_blank`,rel:`noopener noreferrer`,className:`link`,children:[(0,A.jsx)(i,{size:14}),c(`web3.action.view`)]})]})]})]}),t&&(0,A.jsxs)(`div`,{className:`web3-key-grid`,children:[(0,A.jsx)(p,{title:c(`web3.label.ed25519Public`),icon:(0,A.jsx)(ce,{size:18}),children:(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:t.ed_public_key}),(0,A.jsx)(f,{text:t.ed_public_key})]})}),(0,A.jsx)(p,{title:c(`web3.label.x25519Public`),icon:(0,A.jsx)(o,{size:18}),children:(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:t.public_key}),(0,A.jsx)(f,{text:t.public_key})]})}),(0,A.jsx)(p,{title:c(`web3.label.combinedPrivate`),icon:(0,A.jsx)(de,{size:18}),accent:!0,children:(0,A.jsxs)(`div`,{className:`mono-row danger`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:a?t.private_key:Pe(t.private_key)}),(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:s,title:c(a?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:a?(0,A.jsx)(E,{size:14}):(0,A.jsx)(b,{size:14})})]})}),(0,A.jsx)(p,{title:`IPNS ID`,icon:(0,A.jsx)(le,{size:18}),children:(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,A.jsx)(f,{text:n})]})})]})]})}function Ie({username:e,password:t,showPassword:n,generating:r,onUsernameChange:i,onPasswordChange:o,onTogglePassword:s,onGenerate:c}){let{t:l}=y();return(0,A.jsxs)(`div`,{className:`input-panel`,children:[(0,A.jsxs)(`div`,{className:`web3-tools-inputs`,children:[(0,A.jsx)(`input`,{type:`text`,placeholder:l(`login.username.placeholder`),value:e,onChange:e=>i(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.jsx)(`input`,{type:n?`text`:`password`,placeholder:l(`web3.login.passwordOptional`),value:t,onChange:e=>o(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`button`,{className:`input-eye`,onClick:s,type:`button`,children:n?(0,A.jsx)(b,{size:16}):(0,A.jsx)(E,{size:16})})]})]}),(0,A.jsx)(`button`,{className:`btn btn-primary btn-full`,onClick:c,disabled:!e.trim()||r,type:`button`,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`spinner`}),l(`web3.login.generating`)]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{size:16}),l(`web3.login.generateAndSignIn`)]})})]})}var Le=e=>btoa(String.fromCharCode(...e)),Re=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${Le(a).match(/.{1,64}/g)?.join(`
2
+ `)}\n-----END PRIVATE KEY-----`},ze=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${Le(i).match(/.{1,64}/g)?.join(`
3
+ `)}\n-----END PUBLIC KEY-----`},Be=[`wallet`,`pem`,`export`,`EA`];function Ve(){let e=window.location.hash.replace(`#`,``);return Be.includes(e)?e:`wallet`}function He(){let{t:e}=y(),t=ee(e=>e.isDarkMode),n=ee(e=>e.setIsDarkMode),r=ee(e=>e.addToast),i=ie(e=>e.setUserIdentity),[d,f]=(0,O.useState)(`wallet`),[p,m]=(0,O.useState)(``),[h,g]=(0,O.useState)(``),[b,x]=(0,O.useState)(!1),[C,E]=(0,O.useState)(null),[D,ne]=(0,O.useState)(null),[oe,se]=(0,O.useState)(``),[ce,le]=(0,O.useState)(``),[ue,de]=(0,O.useState)(``),[k,pe]=(0,O.useState)(``),[me,he]=(0,O.useState)([]),[ge,ye]=(0,O.useState)(0),[j,be]=(0,O.useState)(!0),[M,Ce]=(0,O.useState)(!0),[N,we]=(0,O.useState)(!1),[P,F]=(0,O.useState)(!1),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(!1),[Te,H]=(0,O.useState)(!1),[U,Ee]=(0,O.useState)(``),[W,De]=(0,O.useState)(``),[G,Oe]=(0,O.useState)(!1),[K,ke]=(0,O.useState)(!1),[q,Ae]=(0,O.useState)(null),[J,je]=(0,O.useState)(``),[Me,Y]=(0,O.useState)(``),[Pe,Le]=(0,O.useState)(!1),[Be,He]=(0,O.useState)(!1),[X,Ue]=(0,O.useState)(null),[We,Ge]=(0,O.useState)(`Hello B. This is from A.`),[Ke,qe]=(0,O.useState)(``),[Je,Ye]=(0,O.useState)(``),[Xe,Ze]=(0,O.useState)(``),[Qe,$e]=(0,O.useState)(`Hello A. This is from B.`),[et,tt]=(0,O.useState)(``),[nt,rt]=(0,O.useState)(``),[it,Z]=(0,O.useState)(``),[at,ot]=(0,O.useState)(``),[st,ct]=(0,O.useState)(``),[lt,ut]=(0,O.useState)(``),[dt,ft]=(0,O.useState)(``),[pt,Q]=(0,O.useState)(``),[mt,ht]=(0,O.useState)(!1),[gt,_t]=(0,O.useState)(``),[vt,yt]=(0,O.useState)(``),[bt,xt]=(0,O.useState)(``),[St,Ct]=(0,O.useState)(``),[wt,$]=(0,O.useState)(``),[Tt,Et]=(0,O.useState)(!1);(0,O.useEffect)(()=>{f(Ve());let e=()=>f(Ve());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let Dt=e=>{f(e),window.location.hash=e},Ot=(0,O.useCallback)(async()=>{if(!p.trim())return;H(!0),await new Promise(e=>setTimeout(e,0));let t=re(p.trim(),h),n=`${t.username}#${t.address.slice(-4).toUpperCase()}`;E(t),i({...t,displayName:n}),r(e(`login.toast.signedIn`,{username:t.username}),`success`),pe(v(t.danger));let a=w(t.danger);ne(a),se(ve(a.private_key,a.ed_public_key));let o=_e(a.private_key,a.ed_public_key);le(Re(o.secretKey)),de(ze(o.publicKey)),he([]),ye(0),F(!1),L(!1),z(!1),V(!1),H(!1)},[r,h,i,e,p]);function kt(t,n,i){let a=t.trim();if(!a)return;let o=re(a,n),s=w(o.danger);i({username:o.username,address:o.address,publicKey:s.public_key,privateKey:s.private_key}),Ye(``),Ze(``),rt(``),Z(``),r(e(`web3.toast.accountGenerated`),`success`)}function At({senderAccount:t,recipientAccount:n,message:r,setCipherText:i,setDecryptedText:a,setError:o}){if(!t||!n){o(e(`web3.error.accountsRequired`));return}if(!r.trim()){o(e(`web3.error.messageRequired`));return}i(ae(r,{senderPrivateKey:t.privateKey,recipientPublicKey:n.publicKey})),a(``),o(``)}function jt({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=_(r,{senderPublicKey:t.publicKey,recipientPrivateKey:n.privateKey});if(!o){a(e(`web3.error.decryptFailed`)),i(``);return}i(o),a(``)}function Mt(){if(!at.trim()){Q(e(`web3.error.senderPublicRequired`));return}if(!st.trim()){Q(e(`web3.error.recipientPrivateRequired`));return}if(!lt.trim()){Q(e(`web3.error.cipherRequired`));return}let t=_(lt,{senderPublicKey:at.trim(),recipientPrivateKey:st.trim()});if(!t){Q(e(`web3.error.decryptFailed`)),ft(``);return}ft(t),Q(``)}function Nt(){if(!gt.trim()){$(e(`web3.error.senderPrivateRequired`));return}if(!vt.trim()){$(e(`web3.error.recipientPublicRequired`));return}if(!bt.trim()){$(e(`web3.error.messageRequired`));return}Ct(ae(bt,{senderPrivateKey:gt.trim(),recipientPublicKey:vt.trim()})),$(``)}let Pt=()=>{if(!k)return;let e=[];for(let t=ge;t<ge+10;t++){let n=`m/44'/60'/0'/0/${t}`,r=S.fromPhrase(k,void 0,n);e.push({index:t,address:r.address,privateKey:r.privateKey})}he(t=>[...t,...e]),ye(e=>e+10)},Ft=te(C?.address||void 0),It=d===`wallet`?`web3.view.wallet`:d===`pem`?`web3.view.pem`:d===`EA`?`web3.view.asymmetric`:`web3.view.export`,Lt=[{id:`wallet`,icon:(0,A.jsx)(fe,{size:16}),labelKey:`web3.view.wallet`},{id:`pem`,icon:(0,A.jsx)(l,{size:16}),labelKey:`web3.view.pem`},{id:`export`,icon:(0,A.jsx)(a,{size:16}),labelKey:`web3.view.export`},{id:`EA`,icon:(0,A.jsx)(o,{size:16}),labelKey:`web3.view.asymmetric`}],Rt=d!==`EA`;return(0,A.jsx)(u,{sidebar:({closeSidebar:t})=>(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`sidebar-header sidebar-header-link`,onClick:()=>window.location.href=`/`,children:[(0,A.jsx)(T,{size:18}),(0,A.jsx)(`h1`,{children:`MOST PEOPLE`})]}),(0,A.jsx)(`nav`,{className:`sidebar-nav`,children:Lt.map(n=>(0,A.jsxs)(`button`,{onClick:()=>{Dt(n.id),t()},className:`sidebar-nav-btn ${d===n.id?`active`:``}`,children:[n.icon,(0,A.jsx)(`span`,{children:e(n.labelKey)})]},n.id))})]}),headerTitle:(0,A.jsx)(`h2`,{className:`header-title`,children:e(It)}),headerRight:(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>n(!t),title:e(`common.theme.toggle`),children:t?(0,A.jsx)(s,{size:16}):(0,A.jsx)(c,{size:16})}),children:(0,A.jsx)(`div`,{className:`web3-page`,children:(0,A.jsxs)(`div`,{className:`web3-container ${d===`EA`?`wide`:``}`,children:[Rt&&(0,A.jsx)(Ie,{username:p,password:h,showPassword:b,generating:Te,onUsernameChange:m,onPasswordChange:g,onTogglePassword:()=>x(!b),onGenerate:Ot}),d===`wallet`&&(0,A.jsx)(Fe,{walletResult:C,keys:D,ipns:oe,avatarSrc:Ft,showPrivateKey:B,onTogglePrivateKey:()=>V(!B)}),d===`pem`&&(0,A.jsx)(Se,{walletResult:C,publicPem:ue,privatePem:ce}),d===`export`&&(0,A.jsx)(Ne,{walletResult:C,mnemonicPhrase:k,deriveBatch:10,deriveList:me,deriveShowIndex:j,deriveShowAddress:M,deriveShowPrivateKey:N,showAddressQr:P,showMnemonicReveal:I,showMnemonicQr:R,onToggleAddressQr:()=>F(!P),onToggleMnemonicReveal:()=>L(!I),onToggleMnemonicQr:()=>z(!R),onToggleDeriveIndex:()=>be(!j),onToggleDeriveAddress:()=>Ce(!M),onToggleDerivePrivateKey:()=>we(!N),onDerive:Pt}),d===`EA`&&(0,A.jsx)(xe,{boxAUsername:U,boxAPassword:W,boxAShowPassword:G,boxAShowPrivateKey:K,boxAAccount:q,boxBUsername:J,boxBPassword:Me,boxBShowPassword:Pe,boxBShowPrivateKey:Be,boxBAccount:X,boxABMessage:We,boxABCipherText:Ke,boxABDecryptedText:Je,boxABError:Xe,boxBAMessage:Qe,boxBACipherText:et,boxBADecryptedText:nt,boxBAError:it,boxEncryptSenderPrivateKey:gt,boxEncryptRecipientPublicKey:vt,boxEncryptMessage:bt,boxEncryptCipherText:St,boxEncryptError:wt,boxEncryptShowPrivateKey:Tt,boxDecryptSenderPublicKey:at,boxDecryptRecipientPrivateKey:st,boxDecryptCipherText:lt,boxDecryptResult:dt,boxDecryptError:pt,boxDecryptShowPrivateKey:mt,onBoxAUsernameChange:Ee,onBoxAPasswordChange:De,onBoxAShowPasswordToggle:()=>Oe(!G),onBoxAShowPrivateKeyToggle:()=>ke(!K),onGenerateBoxA:()=>kt(U,W,Ae),onBoxBUsernameChange:je,onBoxBPasswordChange:Y,onBoxBShowPasswordToggle:()=>Le(!Pe),onBoxBShowPrivateKeyToggle:()=>He(!Be),onGenerateBoxB:()=>kt(J,Me,Ue),onBoxABMessageChange:Ge,onBoxABCipherTextChange:qe,onEncryptBoxAB:()=>At({senderAccount:q,recipientAccount:X,message:We,setCipherText:qe,setDecryptedText:Ye,setError:Ze}),onDecryptBoxAB:()=>jt({senderAccount:q,recipientAccount:X,cipherText:Ke,setDecryptedText:Ye,setError:Ze}),onBoxBAMessageChange:$e,onBoxBACipherTextChange:tt,onEncryptBoxBA:()=>At({senderAccount:X,recipientAccount:q,message:Qe,setCipherText:tt,setDecryptedText:rt,setError:Z}),onDecryptBoxBA:()=>jt({senderAccount:X,recipientAccount:q,cipherText:et,setDecryptedText:rt,setError:Z}),onBoxEncryptSenderPrivateKeyChange:_t,onBoxEncryptRecipientPublicKeyChange:yt,onBoxEncryptMessageChange:xt,onBoxEncryptShowPrivateKeyToggle:()=>Et(!Tt),onEncryptOnly:Nt,onBoxDecryptSenderPublicKeyChange:ot,onBoxDecryptRecipientPrivateKeyChange:ct,onBoxDecryptCipherTextChange:ut,onBoxDecryptShowPrivateKeyToggle:()=>ht(!mt),onDecryptOnly:Mt})]})})})}var X=x(`/web3/`)({component:He});export{X as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./cloud-BMyOoC2x.js";import{n as i}from"./LogoIcon-Dxto3Sb4.js";import{t as a}from"./music-CbUskKgg.js";import{t as o}from"./play-BIl8q9eU.js";import{t as s}from"./search-BQi5Z0E-.js";import{t as c}from"./send-Cl6NtD2T.js";import{t as l}from"./wifi-Bm4biAjc.js";import{G as u,J as d,W as f}from"./index-QxXZzOUL.js";import{t as p}from"./MarketingLayout-BQw0IS2i.js";var m=f(`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`}]]),h=f(`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`}]]),g=f(`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`}]]),_=f(`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`}]]),v=f(`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`}]]),y=f(`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`}]]),b=f(`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`}]]),x=f(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),ee=f(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),te=f(`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 D(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 oe={provider:``,aliases:{},not_found:{},...re};function O(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function k(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!O(e,oe))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!O(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]||!O(t,T))return null}return t}var A=Object.create(null);function se(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function j(e,t){let n=A[e]||(A[e]=Object.create(null));return n[t]||(n[t]=se(e,t))}function ce(e,t){return k(t)?D(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function le(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var ue=/^[a-z0-9]+(-[a-z0-9]+)*$/,M=(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&&!N(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&&!N(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!N(e,n)?null:e}return null},N=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1,P=!1;function F(e){return typeof e==`boolean`&&(P=e),P}function I(e){let t=typeof e==`string`?M(e,!0,P):e;if(t){let e=j(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function de(e,t){let n=M(e,!0,P);if(!n)return!1;let r=j(n.provider,n.prefix);return t?le(r,n.name,t):(r.missing.add(n.name),!0)}function fe(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),P&&!t&&!e.prefix){let t=!1;return k(e)&&(e.prefix=``,D(e,(e,n)=>{de(e,n)&&(t=!0)})),t}let n=e.prefix;return N({prefix:n,name:`a`})?!!ce(j(t,n),e):!1}var L=Object.freeze({width:null,height:null}),R=Object.freeze({...L,...C}),pe=/(-?[0-9.]*[0-9]+[0-9.]*)/g,me=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function z(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(pe);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=me.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 he(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 ge(e,t){return e?`<defs>`+e+`</defs>`+t:t}function _e(e,t,n){let r=he(e);return ge(r.defs,t+r.content+n)}var ve=e=>e===`unset`||e===`undefined`||e===`none`;function ye(e,t){let n={...w,...e},r={...R,...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=_e(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=z(d,c/l)):(u=o===`auto`?c:o,d=s===null?z(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{ve(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 be=/\sid="(\S+)"/g,xe=`IconifyId`+Date.now().toString(16)+(Math.random()*16777216|0).toString(16),Se=0;function Ce(e,t=xe){let n=[],r;for(;r=be.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+(Se++).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 B=Object.create(null);function we(e,t){B[e]=t}function V(e){return B[e]||B[``]}function H(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 U=Object.create(null),W=[`https://api.simplesvg.com`,`https://api.unisvg.com`],G=[];W.length>0;)W.length===1||Math.random()>.5?G.push(W.shift()):G.push(W.pop());U[``]=H({resources:[`https://api.iconify.design`].concat(G)});function Te(e,t){let n=H(t);return n===null?!1:(U[e]=n,!0)}function K(e){return U[e]}var q=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function Ee(e,t){let n=K(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 De(e){return e===404}var Oe=(e,t,n)=>{let r=[],i=Ee(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 ke(e){if(typeof e==`string`){let t=K(e);if(t)return t.path}return`/`}var Ae={prepare:Oe,send:(e,t,n)=>{if(!q){n(`abort`,424);return}let r=ke(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;q(e+r).then(e=>{let t=e.status;if(t!==200){setTimeout(()=>{n(De(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 je(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||je([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=je.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]=j(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`?M(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=K(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=V(e);if(!t)return n(void 0,424),Be;i=t.send;let a=Ve(e);a&&(r=a.redundancy)}else{let t=H(e);if(t){r=ze(t);let n=V(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(ue)?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(!ce(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(ue)?V(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,F()));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(j(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=j(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 L?(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={...R,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=M(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=ye(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(Ce(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(F(!0),we(``,Ae),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`||!fe(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;Te(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=I(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=I(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)(s,{size:20})},{name:`Cloudflare`,host:`cloudflare.com`,icon:`simple-icons:cloudflare`,fallback:(0,Q.jsx)(r,{size:20})},{name:`YouTube`,host:`youtube.com`,icon:`simple-icons:youtube`,fallback:(0,Q.jsx)(o,{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)(g,{size:20})},{name:`X`,host:`x.com`,icon:`simple-icons:x`,fallback:(0,Q.jsx)(m,{size:20})},{name:`Instagram`,host:`instagram.com`,icon:`simple-icons:instagram`,fallback:(0,Q.jsx)(_,{size:20})},{name:`Reddit`,host:`reddit.com`,icon:`simple-icons:reddit`,fallback:(0,Q.jsx)(i,{size:20})},{name:`Wikipedia`,host:`wikipedia.org`,icon:`simple-icons:wikipedia`,fallback:(0,Q.jsx)(h,{size:20})},{name:`Apple`,host:`apple.com`,icon:`simple-icons:apple`,fallback:(0,Q.jsx)(x,{size:20})},{name:`Telegram`,host:`telegram.org`,icon:`simple-icons:telegram`,fallback:(0,Q.jsx)(c,{size:20})},{name:`Discord`,host:`discord.com`,icon:`simple-icons:discord`,fallback:(0,Q.jsx)(v,{size:20})},{name:`TikTok`,host:`tiktok.com`,icon:`simple-icons:tiktok`,fallback:(0,Q.jsx)(a,{size:20})},{name:`npm`,host:`npmjs.com`,icon:`simple-icons:npm`,fallback:(0,Q.jsx)(y,{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}=u(),[n,r]=(0,S.useState)(new Map),[i,a]=(0,S.useState)(!1),o=(0,S.useRef)(new Map);(0,S.useEffect)(()=>{document.title=e(`ping.meta.title`)},[e]);let s=(0,S.useCallback)(e=>{r(t=>{let n=new Map(t);return n.set(e,{status:`pending`,latency:0}),n});let t=new AbortController;o.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)})},[]),c=(0,S.useCallback)(()=>{a(!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;o.current.set(e.host,n);let i=performance.now(),s=(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&&a(!1))},c=setTimeout(()=>{n.abort()},gt);fetch(`https://${e.host}/`,{method:`HEAD`,mode:`no-cors`,cache:`no-store`,signal:n.signal}).then(()=>{clearTimeout(c),s(`ok`,Math.round(performance.now()-i))}).catch(()=>{clearTimeout(c),s(`timeout`,0)})})},[]);return(0,S.useEffect)(()=>(c(),()=>{o.current.forEach(e=>e.abort()),o.current.clear()}),[c]),(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)(l,{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:c,disabled:i,"aria-label":e(`ping.retryAll`),title:e(`ping.retryAll`),children:(0,Q.jsx)(b,{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:()=>s(r.host),disabled:a,"aria-label":e(`ping.retryOne`,{name:r.name}),title:e(`ping.retry`),children:(0,Q.jsx)(b,{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)(p,{children:(0,Q.jsx)(vt,{})})}var bt=d(`/ping/`)({component:yt});export{bt as Route};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./arrow-right-urE9Rd7j.js";import{t as i}from"./check-DUNsD2t6.js";import{t as a}from"./download-y7SZXu6E.js";import{n as o,t as s}from"./wallet-c7zIhNSM.js";import{t as c}from"./hard-drive-D13Qbobu.js";import{n as l}from"./LogoIcon-Dxto3Sb4.js";import{t as u}from"./notebook-pen-DqKDQ6MJ.js";import{B as d,G as f,J as p,W as m,Y as h,f as g}from"./index-QxXZzOUL.js";import{t as _}from"./MarketingLayout-BQw0IS2i.js";var v=m(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),y=m(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),b=m(`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`}]]),x=t(e(),1),S=n(),C=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,S.jsx)(y,{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`},{num:`2`,titleKey:`portal.feature.app.step.install.title`,descKey:`portal.feature.app.step.install.desc`},{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,S.jsx)(l,{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`},{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,S.jsx)(u,{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,S.jsx)(b,{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,S.jsx)(s,{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 w(){let e=g(e=>e.hasBackend),t=g(e=>e.openConnectModal),[n,s]=(0,x.useState)(`app`),{t:l}=f(),u=C.find(e=>e.id===n)||C[0],p=l(u.titleKey);return(0,S.jsxs)(`div`,{className:`portal-page`,children:[(0,S.jsx)(`section`,{className:`portal-hero`,children:(0,S.jsxs)(`div`,{className:`mkt-container`,children:[(0,S.jsx)(`h1`,{className:`portal-hero-title`,children:l(`common.brand`)}),(0,S.jsx)(`p`,{className:`portal-hero-subtitle`,children:l(`portal.hero.subtitle`)})]})}),(0,S.jsx)(`section`,{className:`portal-cards-section`,children:(0,S.jsxs)(`div`,{className:`mkt-container`,children:[(0,S.jsx)(`div`,{className:`portal-cards`,children:C.map(t=>{let r=n===t.id,i=t.requiresBackend,a=i?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,o=l(t.titleKey);return(0,S.jsxs)(`button`,{className:`portal-card ${r?`active`:``}`,onClick:()=>s(t.id),children:[(0,S.jsx)(h,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:l(`portal.openFeature`,{title:o}),children:(0,S.jsx)(v,{size:16})}),(0,S.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,S.jsx)(`div`,{className:`portal-card-title`,children:o}),(0,S.jsx)(`div`,{className:`portal-card-subtitle`,children:l(t.subtitleKey)}),i?(0,S.jsxs)(`div`,{className:`ui-badge portal-card-status ${a}`,children:[a===`checking`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`status-dot checking`}),l(`common.status.checking`)]}),a===`connected`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`status-dot connected`}),l(`common.status.connected`)]}),a===`disconnected`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`status-dot disconnected`}),l(`common.status.needsConnection`)]})]}):(0,S.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,S.jsx)(`span`,{className:`status-dot ready`}),l(`common.status.ready`)]})]},t.id)})}),(0,S.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":l(`portal.nodeEntry`),children:[(0,S.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,S.jsx)(d,{size:16}),l(`portal.webConnectNode`)]}),(0,S.jsxs)(h,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,S.jsx)(c,{size:16}),l(`portal.nodeAdmin`)]})]})]})}),(0,S.jsx)(`section`,{className:`portal-marketing`,children:(0,S.jsx)(`div`,{className:`mkt-container`,children:(0,S.jsxs)(`div`,{className:`portal-marketing-inner`,children:[(0,S.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,S.jsx)(`h2`,{children:l(u.heroKey)}),(0,S.jsx)(`p`,{children:l(u.descKey)})]}),(0,S.jsx)(`div`,{className:`portal-marketing-features`,children:u.featureKeys.map(e=>(0,S.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,S.jsx)(`span`,{className:`portal-feature-icon`,children:(0,S.jsx)(i,{size:14,strokeWidth:3})}),(0,S.jsx)(`span`,{children:l(e)})]},e))}),(0,S.jsx)(`div`,{className:`portal-marketing-steps`,children:u.steps.map(e=>(0,S.jsxs)(`div`,{className:`portal-step`,children:[(0,S.jsx)(`span`,{className:`portal-step-num`,children:e.num}),(0,S.jsxs)(`div`,{className:`portal-step-content`,children:[(0,S.jsx)(`strong`,{children:l(e.titleKey)}),(0,S.jsx)(`p`,{children:l(e.descKey)}),e.code&&(0,S.jsx)(`code`,{className:`portal-step-code`,translate:`no`,children:e.code}),e.link&&e.linkTextKey&&(0,S.jsx)(`p`,{className:`portal-step-link`,children:(0,S.jsxs)(h,{to:e.link,children:[l(e.linkTextKey),` `,(0,S.jsx)(o,{size:12})]})})]})]},e.num))}),(0,S.jsxs)(`div`,{className:`portal-actions`,children:[(0,S.jsxs)(h,{to:u.path,className:`btn btn-primary`,children:[l(`portal.enterFeature`,{title:p}),(0,S.jsx)(r,{size:16})]}),u.requiresBackend&&e===!1&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,S.jsx)(d,{size:16}),l(`portal.webConnectNode`)]}),(0,S.jsxs)(h,{to:`/download/`,className:`btn btn-secondary`,children:[(0,S.jsx)(a,{size:16}),l(`nav.downloadClient`)]})]})]})]})})})]})}function T(){return(0,S.jsx)(_,{children:(0,S.jsx)(w,{})})}var E=p(`/`)({component:T});export{E as Route};