most-box 0.2.4 → 0.2.5

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 (52) hide show
  1. package/out/admin/index.html +0 -0
  2. package/out/app/index.html +0 -0
  3. package/out/assets/{AppShell-gILTcRs-.js → AppShell-oF8wPXde.js} +1 -1
  4. package/out/assets/{FilePreviewOverlay-CM-fcIaD.js → FilePreviewOverlay-DTBZt89J.js} +1 -1
  5. package/out/assets/{LanguageToggle-B99eQcTE.js → LanguageToggle-HAJ3D6Ne.js} +1 -1
  6. package/out/assets/{MarketingHeader-Q2cpkqAM.js → MarketingHeader-B3vYocUz.js} +1 -1
  7. package/out/assets/{MarketingLayout-X3Nj2JvA.js → MarketingLayout-CapVVXTP.js} +1 -1
  8. package/out/assets/{MarketingThemeToggle-z4jr4-vt.js → MarketingThemeToggle-B47H68ro.js} +1 -1
  9. package/out/assets/{MilkdownEditor-Bv2VA3bu.js → MilkdownEditor-CRA9oxMp.js} +1 -1
  10. package/out/assets/{OpenSidebarButton-CaQJk5LD.js → OpenSidebarButton-D3JRO-Hh.js} +1 -1
  11. package/out/assets/{SidebarAccount-CpNVqNva.js → SidebarAccount-8_hQAYXx.js} +1 -1
  12. package/out/assets/{downloadValidation-xzpa5rap.js → downloadValidation-eInMiVSX.js} +1 -1
  13. package/out/assets/index--p9MKNEl.js +31 -0
  14. package/out/assets/index-DEu4udaa.css +1 -0
  15. package/out/assets/{index.lazy-H7NATHUs.js → index.lazy-2K3f5PZe.js} +1 -1
  16. package/out/assets/{index.lazy-CxpNXlwa.js → index.lazy-B-2etVwK.js} +1 -1
  17. package/out/assets/index.lazy-B4WTQF5E.js +1 -0
  18. package/out/assets/index.lazy-BFfsQrRe.js +1 -0
  19. package/out/assets/{index.lazy-Dzf-q-Vf.js → index.lazy-C5udBnrO.js} +1 -1
  20. package/out/assets/{index.lazy-CJBRtbWA.js → index.lazy-C84HrZpm.js} +1 -1
  21. package/out/assets/{index.lazy-erexqght.js → index.lazy-CBC2N5p_.js} +2 -2
  22. package/out/assets/{index.lazy-b_N8nrYw.js → index.lazy-CzANViGX.js} +1 -1
  23. package/out/assets/index.lazy-D3cw7yyA.js +2 -0
  24. package/out/assets/{index.lazy-0DsJzEoI.js → index.lazy-DVVZzbCN.js} +1 -1
  25. package/out/assets/{index.lazy-DOgKxDuF.js → index.lazy-DxZgywoV.js} +1 -1
  26. package/out/assets/{index.lazy-CPV-dZxo.js → index.lazy-RBLN4SE9.js} +1 -1
  27. package/out/assets/index.lazy-s4E2z9AY.js +2 -0
  28. package/out/assets/{mp-DjXDNjls.js → mp-CJWipckT.js} +1 -1
  29. package/out/assets/triangle-alert-CO_5uXy2.js +1 -0
  30. package/out/assets/{useChannelMessages-DS1ntAKN.js → useChannelMessages-D_306Ymv.js} +1 -1
  31. package/out/assets/{useGameRoom-BSPkCY3n.js → useGameRoom-CURx56m6.js} +1 -1
  32. package/out/assets/{userProfile-BmzBA_Bk.js → userProfile-oeBvU6ch.js} +1 -1
  33. package/out/chat/index.html +0 -0
  34. package/out/chat/join/index.html +0 -0
  35. package/out/download/index.html +2 -2
  36. package/out/game/gandengyan/index.html +0 -0
  37. package/out/game/index.html +0 -0
  38. package/out/game/zhajinhua/index.html +0 -0
  39. package/out/index.html +2 -2
  40. package/out/note/index.html +0 -0
  41. package/out/ping/index.html +2 -2
  42. package/out/profile/index.html +0 -0
  43. package/out/web3/index.html +0 -0
  44. package/package.json +1 -1
  45. package/server/src/utils/api.js +149 -9
  46. package/out/assets/index-CgErXULe.css +0 -1
  47. package/out/assets/index-DN0kD5zr.js +0 -31
  48. package/out/assets/index.lazy-CQavt0-9.js +0 -2
  49. package/out/assets/index.lazy-CUq9lbK_.js +0 -1
  50. package/out/assets/index.lazy-GtegOPkJ.js +0 -2
  51. package/out/assets/index.lazy-s3nUpCQ1.js +0 -1
  52. package/out/assets/triangle-alert-D-qigSSn.js +0 -1
@@ -1,2 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-Bt-cYkS5.js";import{g as i,v as a}from"./userStore-q0BBZsIV.js";import{n as o,t as s}from"./triangle-alert-D-qigSSn.js";import{t as c}from"./download-Bhqn6hL1.js";import{t as l}from"./file-text-CFfvvCnM.js";import{t as u}from"./hard-drive-4vHpA5kz.js";import{t as d}from"./refresh-cw--JB8k6mH.js";import{t as f}from"./save-DN4eprSt.js";import{t as p}from"./shield-check-c0labdRH.js";import{t as m}from"./trash-2-zdhWec_U.js";import{t as h}from"./wifi-CVqaPDcv.js";import{A as g,C as _,I as v,S as ee,h as y,m as b,v as x}from"./index-DN0kD5zr.js";import{t as S}from"./dayjs.min-Dcc0B6Je.js";import{t as te}from"./MarketingHeader-Q2cpkqAM.js";import{t as C}from"./format-CR8oUWq6.js";var ne=i(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),re=i(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),w=i(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),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=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_tw=r(n.dayjs)})(e,(function(e){function t(e){return e&&typeof e==`object`&&`default`in e?e:{default:e}}var n=t(e),r={name:`zh-tw`,weekdays:`星期日_星期一_星期二_星期三_星期四_星期五_星期六`.split(`_`),weekdaysShort:`週日_週一_週二_週三_週四_週五_週六`.split(`_`),weekdaysMin:`日_一_二_三_四_五_六`.split(`_`),months:`一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月`.split(`_`),monthsShort:`1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月`.split(`_`),ordinal:function(e,t){return t===`W`?e+`週`:e+`日`},formats:{LT:`HH:mm`,LTS:`HH:mm:ss`,L:`YYYY/MM/DD`,LL:`YYYY年M月D日`,LLL:`YYYY年M月D日 HH:mm`,LLLL:`YYYY年M月D日dddd HH:mm`,l:`YYYY/M/D`,ll:`YYYY年M月D日`,lll:`YYYY年M月D日 HH:mm`,llll:`YYYY年M月D日dddd HH:mm`},relativeTime:{future:`%s內`,past:`%s前`,s:`幾秒`,m:`1 分鐘`,mm:`%d 分鐘`,h:`1 小時`,hh:`%d 小時`,d:`1 天`,dd:`%d 天`,M:`1 個月`,MM:`%d 個月`,y:`1 年`,yy:`%d 年`},meridiem:function(e,t){var n=100*e+t;return n<600?`凌晨`:n<900?`早上`:n<1100?`上午`:n<1300?`中午`:n<1800?`下午`:`晚上`}};return n.default.locale(r,null,!0),r}))})),O=t(e(),1),k=t(S(),1),A=t(T(),1);E(),D();var j=r();k.default.extend(A.default);var ie=null;function ae(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 M(e){return Number.isFinite(e)?String(Math.round(e/(1024*1024*1024)*100)/100):`0`}function N(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:Math.round(t*1024*1024*1024)}function oe(e){return Array.from(new Set(String(e||``).split(/[\n,]/).map(e=>e.trim()).filter(Boolean)))}function P(e,t=12,n=8){return e?e.length<=t+n+3?e:`${e.slice(0,t)}...${e.slice(-n)}`:`-`}function se(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 F(e){return{"zh-CN":`zh-cn`,"zh-TW":`zh-tw`,en:`en`}[e]}function ce(e,t,n){if(!e)return t(`admin.time.never`);let r=(0,k.default)(e);if(!r.isValid())return t(`admin.time.never`);if(r.isAfter((0,k.default)()))return t(`admin.time.justNow`);let i=F(n);return r.locale(i).from((0,k.default)().locale(i))}var le=[{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`}],ue=[{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`}],I={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 L(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 de(e,t){let n=String(t||`all`).trim().toLowerCase();if(!n||n===`all`)return!0;let r=L(e);return n===`error`?e.level===`error`||I.error.some(e=>r.includes(e)):(I[n]||[n]).some(e=>r.includes(e))}function R(){let{t:e,locale:t,formatNumber:n,formatTime:r}=v(),i=b(e=>e.hasBackend),a=b(e=>e.addToast),[S,T]=(0,O.useState)(ie),[E,D]=(0,O.useState)([]),[k,A]=(0,O.useState)(``),[F,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(!1),[V,fe]=(0,O.useState)(`all`),[H,pe]=(0,O.useState)([]),[me,U]=(0,O.useState)(``),[W,G]=(0,O.useState)({dataPath:``,capacityGiB:`100`,maxFileSizeGiB:`10`,remoteInvites:``}),K=i===!0;function q(){return K?!0:(a(e(i===null?`admin.toast.backendChecking`:`admin.toast.backendDisconnected`),`warning`),!1)}let J=(0,O.useMemo)(()=>!S||S.capacity.configuredBytes<=0?0:Math.min(100,Math.round(S.capacity.usedBytes/S.capacity.configuredBytes*100)),[S]),he=(0,O.useMemo)(()=>(S?.holdings||[]).slice(0,100),[S]),Y=Math.max(0,(S?.holdings.length||0)-100),X=_(),Z=!!X&&!X.includes(`localhost`)&&!X.includes(`127.0.0.1`),Q=async()=>{if(!K)return!1;try{let e=await y.get(`/api/node/status`).json(),t=await y.get(`/api/node/config`).json();return T(e),G({dataPath:t.dataPath||e.dataPath||``,capacityGiB:M(t.capacityBytes),maxFileSizeGiB:M(t.maxFileSizeBytes),remoteInvites:(t.remoteInvites||[]).join(`
2
- `)}),A(``),!0}catch(t){let n=await x(t,e(`admin.error.readStatus`));return A(n),a(n,`error`),!1}},ge=async()=>{q()&&await Q()&&a(e(`admin.toast.statusRefreshed`),`success`)},$=async(e=V)=>{if(K)try{let t=new URLSearchParams({limit:`80`,filter:e});D((await y.get(`/api/node/logs?${t.toString()}`).json()).logs||[])}catch{}},_e=async()=>{if(K)try{pe((await y.get(`/api/admin/users`).json()).users||[])}catch{}},ve=async()=>{if(q()){I(!0);try{await y.post(`/api/node/config`,{json:{dataPath:W.dataPath,capacityBytes:N(W.capacityGiB),maxFileSizeBytes:N(W.maxFileSizeGiB),remoteInvites:oe(W.remoteInvites)}}).json(),a(W.dataPath===(S?.dataPath||``)?e(`admin.toast.configSaved`):e(`admin.toast.configSavedRestart`),`success`),await Q(),await $()}catch(t){let n=await x(t,e(`admin.error.saveConfig`));a(n,`error`),A(n)}finally{I(!1)}}},ye=async()=>{S?.nodeId&&(await navigator.clipboard.writeText(S.nodeId),a(e(`admin.toast.nodeIdCopied`),`success`))},be=async()=>{if(q()){R(!0);try{await y.delete(`/api/node/logs`).json(),D([]),a(e(`admin.toast.logsCleared`),`success`)}catch(t){let n=await x(t,e(`admin.error.clearLogs`));a(n,`error`),A(n)}finally{R(!1)}}},xe=async()=>{if(q()){B(!0);try{let t=await y.get(`/api/node/diagnostics`).json(),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`),o=new Date().toISOString().replace(/[:.]/g,`-`);i.href=r,i.download=`mostbox-diagnostics-${o}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),a(e(`admin.toast.diagnosticsExported`),`success`)}catch(t){let n=await x(t,e(`admin.error.exportDiagnostics`));a(n,`error`),A(n)}finally{B(!1)}}},Se=async t=>{if(q()&&window.confirm(e(`admin.confirm.clearUserData`,{address:`${t.slice(0,6)}...${t.slice(-4)}`}))){U(t);try{await y.delete(`/api/admin/users/${t}/data`).json(),a(e(`admin.toast.userDataCleared`),`success`),await _e(),await Q()}catch(t){let n=await x(t,e(`admin.error.clearUserData`));a(n,`error`),A(n)}finally{U(``)}}};return(0,O.useEffect)(()=>{if(!K||Z)return;Q(),$(),_e();let e=null,t=!1;return(async()=>{if(e=new WebSocket(await ee(`/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`&&de(t.data,V)&&D(e=>[t.data,...e].slice(0,80)),t.event===`node:logs:cleared`&&D([]),(t.event===`publish:success`||t.event===`download:success`||t.event===`network:status`)&&Q()}catch{}}})(),()=>{t=!0,e?.close()}},[K,Z,V]),(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(te,{}),(0,j.jsxs)(`main`,{className:`admin-page`,children:[(0,j.jsxs)(`header`,{className:`admin-topbar`,children:[(0,j.jsx)(`div`,{className:`admin-title-group`,children:(0,j.jsx)(`h1`,{children:e(`admin.title`)})}),(0,j.jsxs)(`div`,{className:`admin-topbar-actions`,children:[(0,j.jsxs)(`span`,{className:`admin-status-pill ${S?.status===`online`?`online`:``}`,children:[(0,j.jsx)(ne,{size:14}),S?.status===`online`?e(`admin.status.online`):e(`admin.status.waiting`)]}),(0,j.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ge,children:[(0,j.jsx)(d,{size:16}),e(`admin.action.refresh`)]})]})]}),i===!1&&(0,j.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,j.jsx)(g,{size:20}),(0,j.jsx)(`span`,{children:e(`admin.error.localDaemonDisconnected`)})]}),Z&&(0,j.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,j.jsx)(s,{size:18}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`admin.remoteUnavailable.title`)}),(0,j.jsx)(`p`,{children:e(`admin.remoteUnavailable.desc`)})]})]}),!Z&&k&&(0,j.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,j.jsx)(l,{size:20}),(0,j.jsx)(`span`,{children:k})]}),!Z&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`admin-overview`,children:[(0,j.jsxs)(`div`,{className:`admin-metric`,children:[(0,j.jsx)(`div`,{className:`admin-metric-icon`,children:(0,j.jsx)(p,{size:18})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.metric.nodeId`)}),(0,j.jsx)(`strong`,{translate:`no`,children:P(S?.nodeId||``)})]}),(0,j.jsx)(`button`,{className:`btn btn-icon admin-metric-action`,onClick:ye,"aria-label":e(`admin.action.copyNodeId`),children:(0,j.jsx)(re,{size:15})})]}),(0,j.jsxs)(`div`,{className:`admin-metric`,children:[(0,j.jsx)(`div`,{className:`admin-metric-icon`,children:(0,j.jsx)(h,{size:18})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.metric.connections`)}),(0,j.jsx)(`strong`,{children:S?e(`admin.metric.peers`,{count:S.network.peers}):`-`})]})]}),(0,j.jsxs)(`div`,{className:`admin-metric`,children:[(0,j.jsx)(`div`,{className:`admin-metric-icon`,children:(0,j.jsx)(u,{size:18})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.metric.capacity`)}),(0,j.jsxs)(`strong`,{children:[J,`%`]})]})]}),(0,j.jsxs)(`div`,{className:`admin-metric`,children:[(0,j.jsx)(`div`,{className:`admin-metric-icon`,children:(0,j.jsx)(g,{size:18})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.metric.uptime`)}),(0,j.jsx)(`strong`,{children:S?ae(S.uptimeSeconds,e):`-`})]})]})]}),(0,j.jsxs)(`section`,{className:`admin-grid`,children:[(0,j.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,j.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,j.jsx)(`div`,{children:(0,j.jsx)(`h2`,{children:e(`admin.nodeStatus.title`)})}),(0,j.jsx)(o,{size:18})]}),(0,j.jsxs)(`div`,{className:`admin-status-grid`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.nodeStatus.version`)}),(0,j.jsx)(`strong`,{translate:`no`,children:S?.version||`-`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.nodeStatus.listen`)}),(0,j.jsx)(`strong`,{translate:`no`,children:S?`${S.host}:${S.port}`:`-`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{children:e(`admin.nodeStatus.dataPath`)}),(0,j.jsx)(`strong`,{translate:`no`,children:S?.dataPath||`-`})]})]}),(0,j.jsx)(`div`,{className:`admin-address-list`,children:(S?.listen.addresses||[]).map(e=>(0,j.jsxs)(`span`,{translate:`no`,children:[e.label,`: `,e.ip,`:`,S?.port]},`${e.type}-${e.ip}`))})]}),(0,j.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,j.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,j.jsx)(`div`,{children:(0,j.jsx)(`h2`,{children:e(`admin.userData.title`)})}),(0,j.jsx)(w,{size:18})]}),(0,j.jsxs)(`div`,{className:`admin-table`,children:[(0,j.jsxs)(`div`,{className:`admin-table-row admin-table-head`,children:[(0,j.jsx)(`span`,{children:e(`admin.userData.user`)}),(0,j.jsx)(`span`,{children:e(`admin.userData.files`)}),(0,j.jsx)(`span`,{children:e(`admin.userData.trash`)}),(0,j.jsx)(`span`,{children:e(`admin.userData.actions`)})]}),H.map(t=>(0,j.jsxs)(`div`,{className:`admin-table-row`,children:[(0,j.jsx)(`span`,{title:t.address,translate:`no`,children:P(t.address)}),(0,j.jsx)(`span`,{children:n(t.fileCount)}),(0,j.jsx)(`span`,{children:n(t.trashCount)}),(0,j.jsx)(`span`,{children:(0,j.jsxs)(`button`,{className:`btn btn-ghost`,onClick:()=>Se(t.address),disabled:me===t.address,children:[(0,j.jsx)(m,{size:16}),e(`admin.action.clear`)]})})]},t.address)),H.length===0&&(0,j.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.userData.empty`)})]})]}),(0,j.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,j.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,j.jsx)(`div`,{children:(0,j.jsx)(`h2`,{children:e(`admin.settings.title`)})}),(0,j.jsx)(w,{size:18})]}),(0,j.jsxs)(`div`,{className:`admin-settings-fields`,children:[(0,j.jsxs)(`label`,{className:`admin-field admin-field-wide`,children:[(0,j.jsx)(`span`,{children:e(`admin.settings.dataPath`)}),(0,j.jsx)(`input`,{className:`input`,value:W.dataPath,onChange:e=>G(t=>({...t,dataPath:e.target.value}))})]}),(0,j.jsxs)(`label`,{className:`admin-field`,children:[(0,j.jsx)(`span`,{children:e(`admin.settings.capacityGiB`)}),(0,j.jsx)(`input`,{className:`input`,type:`number`,min:`0`,step:`1`,value:W.capacityGiB,onChange:e=>G(t=>({...t,capacityGiB:e.target.value}))})]}),(0,j.jsxs)(`label`,{className:`admin-field`,children:[(0,j.jsx)(`span`,{children:e(`admin.settings.maxFileSizeGiB`)}),(0,j.jsx)(`input`,{className:`input`,type:`number`,min:`0`,step:`1`,value:W.maxFileSizeGiB,onChange:e=>G(t=>({...t,maxFileSizeGiB:e.target.value}))})]}),(0,j.jsxs)(`label`,{className:`admin-field admin-field-wide`,children:[(0,j.jsx)(`span`,{children:e(`admin.settings.remoteInvites`)}),(0,j.jsx)(`textarea`,{className:`input admin-textarea`,value:W.remoteInvites,placeholder:e(`admin.settings.remoteInvitesPlaceholder`),onChange:e=>G(t=>({...t,remoteInvites:e.target.value}))})]})]}),(0,j.jsx)(`p`,{className:`admin-field-hint`,children:e(`admin.settings.hint`)}),(0,j.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:ve,disabled:F,children:[(0,j.jsx)(f,{size:16}),e(`admin.action.saveConfig`)]})]}),(0,j.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,j.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,j.jsx)(`div`,{children:(0,j.jsx)(`h2`,{children:e(`admin.holdings.title`)})}),(0,j.jsx)(u,{size:18})]}),(0,j.jsxs)(`div`,{className:`admin-capacity-row`,children:[(0,j.jsx)(`progress`,{value:J,max:`100`}),(0,j.jsxs)(`span`,{children:[C(S?.capacity.usedBytes||0),` /`,` `,C(S?.capacity.configuredBytes||0)]})]}),(0,j.jsx)(`div`,{className:`admin-seed-help`,"aria-label":e(`admin.seedHelp.label`),children:le.map(t=>(0,j.jsxs)(`div`,{className:`admin-seed-help-item`,children:[(0,j.jsx)(`span`,{className:`admin-seed-dot ${t.tone}`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:e(t.labelKey)}),(0,j.jsx)(`span`,{children:e(t.descKey)})]})]},t.labelKey))}),Y>0&&(0,j.jsx)(`p`,{className:`admin-table-note`,children:e(`admin.holdings.hiddenCount`,{count:n(Y)})}),(0,j.jsxs)(`div`,{className:`admin-table`,children:[(0,j.jsxs)(`div`,{className:`admin-table-row admin-table-head`,children:[(0,j.jsx)(`span`,{children:e(`admin.holdings.file`)}),(0,j.jsx)(`span`,{children:`CID`}),(0,j.jsx)(`span`,{children:e(`admin.holdings.size`)}),(0,j.jsx)(`span`,{children:`Peer`}),(0,j.jsx)(`span`,{children:e(`admin.holdings.lastServed`)}),(0,j.jsx)(`span`,{children:e(`admin.holdings.status`)})]}),he.map(n=>(0,j.jsxs)(`div`,{className:`admin-table-row`,children:[(0,j.jsx)(`span`,{translate:`no`,children:n.fileName||`-`}),(0,j.jsx)(`span`,{title:n.cid,translate:`no`,children:P(n.cid)}),(0,j.jsx)(`span`,{children:C(n.size)}),(0,j.jsx)(`span`,{children:n.peerCount??0}),(0,j.jsx)(`span`,{title:n.lastServedAt||``,children:ce(n.lastServedAt,e,t)}),(0,j.jsx)(`span`,{className:`admin-seed-pill ${n.seedStatus===`error`?`error`:n.seedStatus===`active`||n.joined?`active`:``}`,children:se(n,e)})]},n.cid)),(!S||S.holdings.length===0)&&(0,j.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.holdings.empty`)})]})]}),(0,j.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,j.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,j.jsx)(`div`,{children:(0,j.jsx)(`h2`,{children:e(`admin.logs.title`)})}),(0,j.jsxs)(`div`,{className:`admin-panel-actions`,children:[(0,j.jsxs)(`button`,{className:`btn btn-secondary`,onClick:xe,disabled:z,children:[(0,j.jsx)(c,{size:16}),e(`admin.action.exportDiagnostics`)]}),(0,j.jsxs)(`button`,{className:`btn btn-ghost`,onClick:be,disabled:L||E.length===0,children:[(0,j.jsx)(m,{size:16}),e(`admin.action.clearLogs`)]}),(0,j.jsx)(l,{size:18})]})]}),(0,j.jsx)(`div`,{className:`admin-log-filter`,"aria-label":e(`admin.logs.filterLabel`),children:ue.map(t=>(0,j.jsx)(`button`,{type:`button`,className:V===t.value?`active`:``,onClick:()=>{fe(t.value),$(t.value)},children:e(t.labelKey)},t.value))}),(0,j.jsxs)(`div`,{className:`admin-log-list`,children:[E.map(e=>(0,j.jsxs)(`div`,{className:`admin-log-row`,children:[(0,j.jsx)(`time`,{children:r(e.ts)}),(0,j.jsx)(`span`,{className:`admin-log-level ${e.level}`,translate:`no`,children:e.level}),(0,j.jsx)(`strong`,{translate:`no`,children:e.event}),(0,j.jsx)(`span`,{translate:`no`,children:e.message})]},e.id)),E.length===0&&(0,j.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.logs.empty`)})]})]})]})]})]})]})}var z=a(`/admin/`)({component:R});export{z as Route};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{n as r,t as i,v as a}from"./userStore-q0BBZsIV.js";import{a as o,i as s,r as c}from"./LanguageToggle-B99eQcTE.js";import{t as l}from"./circle-alert-CofRTRHr.js";import{t as u}from"./key-round-BpSdpOHi.js";import{t as d}from"./AppShell-gILTcRs-.js";import{F as f,I as p,N as m,O as h,P as g,_,g as v,m as y,z as b}from"./index-DN0kD5zr.js";import{i as x,t as S}from"./userProfile-BmzBA_Bk.js";var C=t(e(),1),w=[{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`}];function T(e){let t=typeof e==`string`?e.trim():e;return g(t)?t:void 0}var E=`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`,D=`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`,O=Object.freeze({id:`chatjoin_support`,name:`User / Service 测试频道`}),k=Object.freeze([Object.freeze({uid:`user`,identity:`user`,name:`测试用户`,avatar:E}),Object.freeze({uid:`service`,identity:`service`,name:`测试客服`,avatar:D})]),A=Object.freeze(k.map(e=>Object.freeze({locale:`zh-CN`,uid:e.uid,identity:e.identity,avatar:e.avatar,name:e.name,channels:[O]})));function j(e){let t=String(e||``).trim();return A.find(e=>e.uid===t)||null}function M(e){return JSON.stringify(e,null,2)}var N=n(),P=`0x955fe80bdb8312165471fcacd6a8f83df88a770dda6f38657ca4e62ec28d5b54`,F=50,I=`https://api.most.box`;function L(e){try{return JSON.parse(e)}catch{return null}}function R(e){return typeof e==`string`?L(e):e}function z(e,t){return t===null?e:JSON.stringify(t,null,2)}function B(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 V(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function H(e){return typeof e==`string`?e.trim():``}function U(e){let t=H(e);return t===`user`||t===`service`||t===`service_ai`?t:void 0}function W(e){let t=R(e);if(!V(t))return null;let n=H(t.uid),r=(Array.isArray(t.channels)?t.channels:[]).filter(V).map(e=>({id:H(e.id),name:H(e.name)||void 0})).filter(e=>e.id);return!n||r.length===0?null:{node_url:H(t.node_url)||void 0,node_invite:H(t.node_invite)||void 0,locale:T(t.locale),uid:n,identity:U(t.identity),logo:H(t.logo)||void 0,avatar:H(t.avatar)||void 0,name:H(t.name)||void 0,channels:r}}function G(e){return`/chat?channel=${encodeURIComponent(e)}`}function K(e){return String(e||``).trim().slice(0,F)}function q(){let{t:e,setLocale:t}=p(),n=b({select:e=>e.searchStr}),{token:a,pub:g,fixture:T}=(0,C.useMemo)(()=>{let e=new URLSearchParams(n);return{token:e.get(`token`)||``,pub:e.get(`pub`)||``,fixture:e.get(`fixture`)||``}},[n]),E=y(e=>e.isDarkMode),D=y(e=>e.setIsDarkMode),O=y(e=>e.hasBackend),k=i(e=>e.setUserIdentity),A=h(),[F,R]=(0,C.useState)(``),[V,H]=(0,C.useState)(``),[U,q]=(0,C.useState)(!0),[J,Y]=(0,C.useState)(``),X=(0,C.useRef)(``);return(0,C.useEffect)(()=>{let n=j(T);if(T&&!n){H(e(`chatJoin.error.unknownFixture`,{fixture:T})),q(!1);return}if(!n&&!a){H(e(`chatJoin.error.missingToken`)),q(!1);return}if(!n&&!g){H(e(`chatJoin.error.missingPub`)),q(!1);return}if(O===null){Y(e(`chatJoin.status.checkingBackend`));return}let i=n?`fixture:${T}`:`${a}:${g}`;if(X.current===i)return;X.current=i;async function o(n){let i=(t,r)=>n.locale?f(t,n.locale,r):e(t,r);if(n.locale&&t(n.locale),n.node_url){if(Y(i(`chatJoin.status.connectingRemote`)),!(await v({url:n.node_url,invite:n.node_invite||``})).ok)throw Error(i(`chatJoin.error.remoteConnectFailed`));_({url:n.node_url,invite:n.node_invite||``}),y.setState({hasBackend:!0})}else if(!O)throw Error(i(`chatJoin.error.noBackend`));Y(i(`chatJoin.status.signingIn`));let a=r(n.uid,``),o={...a,identity:n.identity,displayName:n.name||a.displayName,logo:n.logo,avatar:n.avatar};k(o),Y(i(`chatJoin.status.joiningChannel`));let s=``;for(let e of n.channels){let t=await x.createChannel(e.id,`public`,S(o)),n=t.channelKey||t.key||e.id;s||=n;let r=K(e.name);r&&await x.setChannelRemark(n,r)}let c=n.channels[0];Y(i(`chatJoin.status.openingChannel`)),window.location.href=G(s||c.id)}async function s(){try{if(n){Y(e(`chatJoin.status.loadingFixture`,{name:n.name||T})),R(M(n)),await o(n);return}Y(e(`chatJoin.status.decryptingInvite`));let t=await fetch(`${I}/api/chat.join.decrypt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:a,pub:g})}),r=await t.text(),i=L(r);if(!t.ok)H(B(r,i,e(`chatJoin.error.decrypt`)));else{R(z(r,i));let t=W(i);if(!t){H(e(`chatJoin.error.invalidInvite`));return}await o(t)}}catch(t){H(e(`chatJoin.error.request`,{message:t instanceof Error?t.message:String(t)}))}finally{q(!1)}}s()},[T,O,g,t,k,e,a]),(0,N.jsx)(d,{sidebar:()=>(0,N.jsxs)(`button`,{type:`button`,className:`sidebar-header sidebar-header-link`,onClick:A,children:[(0,N.jsx)(m,{size:18}),(0,N.jsx)(`h1`,{children:`MOST PEOPLE`})]}),headerTitle:(0,N.jsx)(`h2`,{className:`header-title`,children:e(`chatJoin.title`)}),headerRight:(0,N.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>D(!E),title:e(`common.theme.toggle`),children:E?(0,N.jsx)(c,{size:16}):(0,N.jsx)(s,{size:16})}),children:(0,N.jsx)(`div`,{className:`chat-join-container`,children:(0,N.jsxs)(`div`,{className:`chat-join-panel`,children:[U?(0,N.jsxs)(`div`,{className:`chat-join-loading`,children:[(0,N.jsx)(u,{size:32}),(0,N.jsx)(`p`,{children:J||e(`chatJoin.status.decrypting`)})]}):V?(0,N.jsxs)(`div`,{className:`chat-join-error`,children:[(0,N.jsx)(l,{size:32}),(0,N.jsx)(`p`,{children:V}),J&&(0,N.jsx)(`p`,{className:`chat-join-status`,children:J}),F&&(0,N.jsx)(`pre`,{className:`chat-join-result`,translate:`no`,children:F})]}):(0,N.jsxs)(`div`,{className:`chat-join-success`,children:[(0,N.jsx)(o,{size:32}),(0,N.jsx)(`p`,{children:J||e(`chatJoin.status.decryptSuccess`)}),(0,N.jsx)(`pre`,{className:`chat-join-result`,translate:`no`,children:F})]}),(0,N.jsxs)(`section`,{className:`chat-join-spec`,"aria-labelledby":`chat-join-spec-title`,children:[(0,N.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,N.jsx)(u,{size:18}),(0,N.jsx)(`h3`,{id:`chat-join-spec-title`,children:e(`chatJoin.specTitle`)})]}),(0,N.jsx)(`div`,{className:`chat-join-field-list`,children:w.map(t=>(0,N.jsxs)(`div`,{className:`chat-join-field`,children:[(0,N.jsxs)(`div`,{className:`chat-join-field-meta`,children:[(0,N.jsx)(`code`,{className:`chat-join-field-name`,children:t.name}),(0,N.jsx)(`span`,{children:t.required?e(`chatJoin.field.required`):e(`chatJoin.field.optional`)})]}),(0,N.jsx)(`p`,{children:e(t.descriptionKey)})]},t.name))})]}),(0,N.jsxs)(`section`,{className:`chat-join-helper`,"aria-labelledby":`ea-test-title`,children:[(0,N.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,N.jsx)(u,{size:18}),(0,N.jsx)(`h3`,{id:`ea-test-title`,children:e(`chatJoin.testPublicKey`)})]}),(0,N.jsx)(`code`,{className:`ui-code-box chat-join-public-key`,translate:`no`,children:P}),(0,N.jsx)(`a`,{className:`btn`,href:`/web3/#EA`,target:`_blank`,children:e(`chatJoin.openWeb3`)})]})]})})})}function J(){return(0,N.jsx)(C.Suspense,{children:(0,N.jsx)(q,{})})}var Y=a(`/chat/join/`)({component:J});export{Y as Route};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-Bv2VA3bu.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-DN0kD5zr.js","assets/userStore-q0BBZsIV.js","assets/useNavigate-DWlBD_-b.js","assets/index-CgErXULe.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{g as r,o as i,s as ee,t as a,v as o}from"./userStore-q0BBZsIV.js";import{n as s}from"./useNavigate-DWlBD_-b.js";import{i as te,r as c}from"./LanguageToggle-B99eQcTE.js";import{n as l,t as u}from"./lock-C0pdaery.js";import{n as d,t as ne}from"./folder-BGJCjyba.js";import{t as f}from"./file-text-CFfvvCnM.js";import{t as re}from"./AppShell-gILTcRs-.js";import{t as p}from"./notebook-pen-CfdFgaDE.js";import{t as m}from"./OpenSidebarButton-CaQJk5LD.js";import{t as h}from"./plus-Mlh7r_bm.js";import{t as g}from"./save-DN4eprSt.js";import{t as ie}from"./search-CbzMyENy.js";import{t as ae}from"./trash-2-zdhWec_U.js";import{E as _,I as oe,N as v,O as y,T as b,d as se,j as ce,k as le,l as ue,m as x,t as S,u as de,w as fe,z as pe}from"./index-DN0kD5zr.js";import{t as me}from"./SidebarAccount-CpNVqNva.js";var he=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),ge=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),C=t(e(),1),w=n();function T(e){return e.type===`directory`?_(e.path?`${e.path}/${e.name}`:e.name):b(e)}function _e({target:e,directories:t,onMove:n,onClose:r}){let{t:i}=oe(),ee=_(e.path||``),a=T(e),o=t.filter(t=>e.type===`directory`?t.path!==a&&!t.path.startsWith(`${a}/`):!0),[s,te]=(0,C.useState)(ee),[c,u]=(0,C.useState)(``),[f,re]=(0,C.useState)(new Set),p=_(c),m=c.trim()?p:s,h=_(m)===ee,g=new Map;for(let e of o){let t=g.get(e.parentPath)||[];t.push(e),g.set(e.parentPath,t)}let ie=o.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>f.has(t.slice(0,n+1).join(`/`)))}),ae=[{label:i(`note.root`),path:``},...s.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function v(e){te(_(e)),u(``)}function y(e){v(e),g.has(e)&&re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function b(){h||n(m)}return(0,w.jsx)(se,{onClose:r,children:(0,w.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(`div`,{className:`modal-header`,children:[(0,w.jsx)(`h3`,{children:i(`note.move.title`)}),(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:r,children:(0,w.jsx)(le,{size:18})})]}),(0,w.jsxs)(`div`,{className:`note-move-target`,children:[(0,w.jsx)(`span`,{children:i(`note.move.moving`)}),(0,w.jsx)(`strong`,{translate:`no`,children:e.name})]}),(0,w.jsx)(`div`,{className:`note-move-path`,children:ae.map((e,t)=>(0,w.jsxs)(C.Fragment,{children:[t>0&&(0,w.jsx)(`span`,{children:`/`}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>v(e.path),children:(0,w.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,w.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${s===``?`selected`:``}`,onClick:()=>v(``),children:[(0,w.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,w.jsx)(ne,{className:`note-move-folder-icon`,size:16}),(0,w.jsx)(`span`,{children:i(`note.root`)})]}),o.length===0?(0,w.jsx)(`p`,{className:`note-move-empty`,children:i(`note.move.noFolders`)}):ie.map(e=>{let t=g.has(e.path),n=f.has(e.path);return(0,w.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${s===e.path?`selected`:``}`,onClick:()=>y(e.path),children:[t?n?(0,w.jsx)(l,{className:`note-move-expander`,size:14}):(0,w.jsx)(d,{className:`note-move-expander`,size:14}):(0,w.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,w.jsx)(ne,{className:`note-move-folder-icon`,size:16}),(0,w.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,w.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,w.jsx)(`input`,{className:`input input-compact`,value:c,onChange:e=>u(e.target.value),placeholder:i(`note.move.pathPlaceholder`),translate:`no`}),(0,w.jsxs)(`div`,{className:`note-move-destination`,children:[(0,w.jsx)(`span`,{children:i(`note.move.destinationLabel`)}),(0,w.jsx)(`span`,{translate:m?`no`:`yes`,children:m||i(`note.root`)})]}),(0,w.jsxs)(`div`,{className:`modal-actions`,children:[(0,w.jsx)(`button`,{className:`btn btn-secondary`,onClick:r,children:i(`common.cancel`)}),(0,w.jsx)(`button`,{className:`btn btn-primary`,onClick:b,disabled:h,children:i(`note.action.move`)})]})]})})}function ve({children:e}){return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`button`,{type:`button`,className:`sidebar-header sidebar-header-link`,onClick:y(),children:[(0,w.jsx)(v,{size:18}),(0,w.jsx)(`h1`,{children:`MOST PEOPLE`})]}),e,(0,w.jsx)(me,{})]})}var ye=(0,C.lazy)(async()=>({default:(await S(()=>import(`./MilkdownEditor-Bv2VA3bu.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))).MilkdownEditor}));function be(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,mode:n===`edit`?`edit`:void 0}}function xe(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 Se(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 E={"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 D(e,t,n){let r=e instanceof Error?e.message:``,i=E[r];return i?n(i):r||t}function Ce(e){return e.type===`directory`?_(e.path?`${e.path}/${e.name}`:e.name):b(e)}function we(e,t){let n=new Set;for(let t of e){let e=_(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 O(){let{t:e,formatDate:t,compareStrings:n}=oe(),r=s(),o=pe({select:e=>e.searchStr}),l=(0,C.useMemo)(()=>be(o),[o]),d=(0,C.useRef)(null),v=x(e=>e.addToast),y=x(e=>e.isDarkMode),se=x(e=>e.setIsDarkMode),S=a(e=>e.wallet),me=a(e=>e.openLoginModal),T=x(e=>e.notes),E=x(e=>e.notesPath),O=x(e=>e.setNotesPath),k=x(e=>e.saveNote),Te=x(e=>e.deleteNote),Ee=x(e=>e.renameNote),A=x(e=>e.localDataReady),j=l.cid||``,M=T.find(e=>e.cid===j),N=!!j,P=N&&l.mode===`edit`,[F,De]=(0,C.useState)(``),[I,Oe]=(0,C.useState)(null),[L,R]=(0,C.useState)(null),[z,B]=(0,C.useState)(null),[ke,V]=(0,C.useState)(``),[H,U]=(0,C.useState)(``),[Ae,W]=(0,C.useState)(``),[G,K]=(0,C.useState)(``),[je,Me]=(0,C.useState)(``),[Ne,q]=(0,C.useState)(``),[J,Y]=(0,C.useState)(!1),[X,Z]=(0,C.useState)(``),[Pe,Fe]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(!j){V(``),U(``);return}if(!M){V(``),U(A?e(`note.error.notFound`):``);return}if(M.content.startsWith(`mp://1`)){if(!S){V(``),U(e(`note.error.loginToDecrypt`));return}let t=i(M.content,S.danger);if(!t){V(``),U(e(`note.error.decryptFailed`));return}V(t),U(``);return}V(M.content||``),U(``)},[j,A,M,e,S]),(0,C.useEffect)(()=>{if(!P){Fe(!1);return}if(!j||!M){K(``),Me(``),q(``),Y(!1),Z(A?e(`note.error.notFound`):``);return}if(K(M.name),Me(M.path||``),Y(M.isSecret===!0||M.content.startsWith(`mp://1`)),M.content.startsWith(`mp://1`)){if(!S){q(``),Z(e(`note.error.loginToDecrypt`));return}let t=i(M.content,S.danger);if(!t){q(``),Z(e(`note.error.decryptFailed`));return}q(t),Z(``);return}q(M.content||``),Z(``)},[j,P,A,M,e,S]),(0,C.useEffect)(()=>{W(M?.name||``)},[M?.cid,M?.name]);let Ie=(0,C.useMemo)(()=>fe(T,E,F),[T,E,F]),Le=Ie.filter(e=>e.type===`file`).length,Re=M?.isSecret===!0||M?.content.startsWith(`mp://1`)===!0,ze=e(P?J?`note.privacy.secret`:`note.privacy.public`:Re?`note.privacy.secret`:`note.privacy.public`),Be=(0,C.useMemo)(()=>{let t=E.split(`/`).filter(Boolean);return[{label:e(`note.root`),path:``},...t.map((e,n)=>({label:e,path:t.slice(0,n+1).join(`/`)}))]},[E,e]),Ve=(0,C.useMemo)(()=>we(T,n),[n,T]);function Q(e={},t=!1){r({href:xe(e),replace:t})}function He(e){Q({cid:e.cid})}function Ue(e){Q({cid:e.cid,mode:`edit`})}function $(){return S?!0:(me(),!1)}function We(){Q(M?{cid:M.cid}:{})}async function Ge(){if($()){if(!M){v(e(`note.toast.notFound`),`error`);return}if(!G.trim()){v(e(`note.toast.nameRequired`),`warning`);return}Fe(!0);try{let t=d.current?.getMarkdown()??Ne,n=J?ee(t,S.danger):t,r=await k({cid:M.cid,name:G,path:je,content:n,isSecret:J});q(t),Q({cid:r},!0),v(e(`note.toast.saved`),`success`)}catch(t){v(D(t,e(`note.toast.saveFailed`),e),`error`)}finally{Fe(!1)}}}function Ke(){$()&&Oe({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if($())try{let n=await k({name:t,path:E,content:``,isSecret:!1});Oe(null),v(e(`note.toast.created`),`success`),Q({cid:n,mode:`edit`})}catch(t){v(D(t,e(`note.toast.createFailed`),e),`error`)}}})}async function qe(){if(!$()||!M)return;let t=Ae.trim();if(!t){W(M.name),v(e(`note.toast.nameRequired`),`warning`);return}if(t!==M.name)try{Ee(b(M),M.path,t),v(e(`note.toast.renamed`),`success`)}catch(t){W(M.name),v(D(t,e(`note.toast.renameFailed`),e),`error`)}}function Je(e){$()&&B(e)}async function Ye(t){if(z)try{Ee(Ce(z),t,z.name),B(null),v(e(`note.toast.moved`),`success`)}catch(t){v(D(t,e(`note.toast.moveFailed`),e),`error`)}}function Xe(t){if(!$())return;let n=t.type===`directory`;R({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:t.name}),confirmText:e(`note.action.delete`),onConfirm:async()=>{Te(n?void 0:t.cid,t.path,t.name),R(null),v(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===j&&Q()}})}let Ze=(0,w.jsxs)(`div`,{className:`note-header-title`,children:[(0,w.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,w.jsx)(`span`,{children:e(`note.count`,{count:T.length})})]}),Qe=(0,w.jsx)(`div`,{className:`note-theme-wrap`,children:(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>se(!y),title:e(`common.theme.toggle`),"aria-label":e(`common.theme.toggle`),children:y?(0,w.jsx)(c,{size:16}):(0,w.jsx)(te,{size:16})})}),$e=(0,w.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,w.jsxs)(`div`,{className:`note-list-header`,children:[(0,w.jsx)(`div`,{className:`note-current-location`,children:(0,w.jsx)(`div`,{className:`note-breadcrumbs`,children:Be.map((e,t)=>(0,w.jsxs)(C.Fragment,{children:[t>0&&(0,w.jsx)(`span`,{children:`/`}),(0,w.jsx)(`button`,{onClick:()=>O(e.path),children:(0,w.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))})}),(0,w.jsx)(`span`,{className:`note-count`,children:e(`note.count`,{count:Le})})]}),(0,w.jsxs)(`div`,{className:`note-search`,children:[(0,w.jsx)(ie,{size:16}),(0,w.jsx)(`input`,{className:`input input-flex`,value:F,onChange:e=>De(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ie.length===0?(0,w.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,w.jsx)(p,{size:32}),(0,w.jsx)(`p`,{children:e(F?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,w.jsx)(`div`,{className:`note-list`,children:Ie.map(n=>(0,w.jsx)(`article`,{className:`ui-list-item note-list-item ${n.type===`file`&&n.cid===j?`active`:``}`,children:(0,w.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${n.type===`directory`?`folder`:``}`,onClick:()=>{n.type===`directory`?O(_(n.path?`${n.path}/${n.name}`:n.name)):He(n)},children:[(0,w.jsx)(`span`,{className:`ui-list-icon note-list-icon ${n.type===`directory`?`warning`:``}`,children:n.type===`directory`?(0,w.jsx)(ne,{size:18}):n.isSecret?(0,w.jsx)(u,{size:18}):(0,w.jsx)(f,{size:18})}),(0,w.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,w.jsx)(`span`,{className:`ui-list-title note-list-name`,translate:`no`,children:n.name}),n.type===`file`?(0,w.jsx)(`span`,{className:`ui-list-desc note-list-preview`,translate:`no`,children:Se(n,e)}):(0,w.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:e(`note.folder`)})]}),n.type===`file`&&(0,w.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:t(n.updated_at)})]})},`${n.cid}:${n.path}:${n.name}`))}),(0,w.jsx)(`div`,{className:`note-create-btn`,children:(0,w.jsxs)(`button`,{className:`btn`,onClick:Ke,children:[(0,w.jsx)(h,{size:16}),e(`note.newNote`)]})})]});return(0,w.jsxs)(re,{sidebar:()=>(0,w.jsx)(ve,{children:$e}),headerTitle:Ze,headerRight:Qe,children:[(0,w.jsx)(`main`,{className:`note-page note-browser-page ${N?`has-editor`:``}`,children:(0,w.jsx)(`section`,{className:`note-workspace`,children:(0,w.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(P?`note.editorLabel.edit`:`note.editorLabel.read`),children:N?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,w.jsxs)(`div`,{className:`note-editor-title-area`,children:[P?(0,w.jsx)(`input`,{className:`note-title-input`,value:G,onChange:e=>K(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!M}):M?(0,w.jsx)(`input`,{className:`note-title-input`,value:Ae,onBlur:qe,onChange:e=>W(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(W(M.name),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),title:e(`app.rename`),translate:`no`}):(0,w.jsx)(`h3`,{children:e(`note.untitled`)}),M&&(0,w.jsxs)(`div`,{className:`note-editor-info`,children:[(0,w.jsx)(`span`,{children:e(P?`note.mode.edit`:`note.mode.read`)}),(0,w.jsx)(`span`,{children:ze}),(0,w.jsx)(`span`,{children:t(M.updated_at)})]})]}),(0,w.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:P?We:()=>Q(),title:e(P?`common.cancel`:`common.close`),"aria-label":e(P?`common.cancel`:`common.close`),children:(0,w.jsx)(le,{size:16})}),P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`button`,{className:`btn btn-sm ${J?`btn-warning`:`btn-secondary`}`,onClick:()=>Y(!J),disabled:!M,children:[J?(0,w.jsx)(u,{size:16}):(0,w.jsx)(ce,{size:16}),e(J?`note.privacy.secret`:`note.privacy.public`)]}),(0,w.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Ge,disabled:Pe||!!X||!M,children:[(0,w.jsx)(g,{size:16}),e(Pe?`note.action.saving`:`note.action.save`)]})]}):M&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>Je(M),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,w.jsx)(he,{size:16})}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>Xe(M),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,w.jsx)(ae,{size:16})}),(0,w.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>Ue(M),disabled:!!H,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,w.jsx)(ge,{size:16}),e(`note.action.edit`)]})]})]})]}),P?X?(0,w.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,w.jsx)(u,{size:36}),(0,w.jsx)(`p`,{children:X})]}):M?(0,w.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,w.jsx)(ye,{ref:d,content:Ne,onChange:q,className:`milkdown-editor`})}):(0,w.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,w.jsx)(p,{size:36}),(0,w.jsx)(`p`,{children:e(A?`note.error.notFound`:`note.loading`)})]}):H?(0,w.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,w.jsx)(u,{size:36}),(0,w.jsx)(`p`,{children:H})]}):M?(0,w.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,w.jsx)(ye,{content:ke,readOnly:!0,className:`milkdown-editor`})}):(0,w.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,w.jsx)(p,{size:36}),(0,w.jsx)(`p`,{children:e(A?`note.error.notFound`:`note.loading`)})]})]}):(0,w.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,w.jsx)(p,{size:32})}),(0,w.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,w.jsx)(`p`,{className:`ui-empty-desc`,children:T.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,w.jsx)(m,{label:e(`note.openList`),variant:`default`})]})})})}),I&&(0,w.jsx)(ue,{title:I.title,placeholder:I.placeholder,defaultValue:I.defaultValue,confirmText:I.confirmText,onConfirm:I.onConfirm,onClose:()=>Oe(null)}),L&&(0,w.jsx)(de,{title:L.title,message:L.message,confirmText:L.confirmText,danger:!0,onConfirm:L.onConfirm,onClose:()=>R(null)}),z&&(0,w.jsx)(_e,{target:z,directories:Ve,onMove:Ye,onClose:()=>B(null)})]})}function k(){let{t:e}=oe();return(0,w.jsx)(C.Suspense,{fallback:(0,w.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:(0,w.jsx)(O,{})})}var Te=o(`/note/`)({component:k});export{Te as Route};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{b as r,g as i,t as a,v as o,x as ee}from"./userStore-q0BBZsIV.js";import{n as s,t as c}from"./triangle-alert-D-qigSSn.js";import{t as l}from"./download-Bhqn6hL1.js";import{t as te}from"./external-link-CNR21yFA.js";import{t as ne}from"./file-text-CFfvvCnM.js";import{t as re}from"./hard-drive-4vHpA5kz.js";import{t as ie}from"./refresh-cw--JB8k6mH.js";import{I as u,S as ae,m as d,v as oe,z as se}from"./index-DN0kD5zr.js";import{t as f}from"./format-CR8oUWq6.js";import{i as ce,n as p,r as m,t as h}from"./downloadValidation-xzpa5rap.js";var le=i(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),g=i(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),_=i(`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`}]]),v=i(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),y=t(e(),1),b=n(),ue=1800;function x(e,t){return`most://${e}${t||``}`}function S(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function C(e,t){let n=e[t];return typeof n==`string`?n:void 0}function w(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function T(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=C(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:C(a,`taskId`),percent:w(a,`percent`),loaded:w(a,`loaded`),total:w(a,`total`),file:C(a,`file`),fileName:C(a,`fileName`),error:C(a,`error`)}}}function E(){let{t:e}=u(),{cid:t}=ee({from:`/cid/$cid/`}),n=se({select:e=>e.searchStr}),i=d(e=>e.hasBackend),o=d(e=>e.addToast),s=d(e=>e.openConnectModal),C=a(e=>e.identity),w=a(e=>e.openLoginModal),E=(0,y.useMemo)(()=>x(t,n),[t,n]),k=(0,y.useMemo)(()=>ce(E),[E]),A=(0,y.useMemo)(()=>h(E,e),[E,e]),de=k.fileName||t,[j,M]=(0,y.useState)({status:`idle`,message:``}),[N,P]=(0,y.useState)(null),[F,I]=(0,y.useState)({status:`idle`,message:``}),[L,R]=(0,y.useState)(``),[z,B]=(0,y.useState)(0),[V,H]=(0,y.useState)(null),[U,W]=(0,y.useState)(null),[fe,G]=(0,y.useState)(``),[pe,K]=(0,y.useState)(!1),q=(0,y.useRef)(0),J=(0,y.useRef)(null),Y=N?.fileName||de,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,me=S(fe,e(`cid.saveToFallback`)),$=(0,y.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(i===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(i!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!C){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await p.checkDownload(E);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await m(e)}),P(null)}},[i,E,e,C,A]);(0,y.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,y.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,y.useEffect)(()=>{$()},[$]),(0,y.useEffect)(()=>{if(i!==!0)return;let e=!1;return p.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[i]),(0,y.useEffect)(()=>{if(!L||!C)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await ae(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=T(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,C]);let he=async()=>{if(!C){w();return}if(i!==!0){s();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await p.downloadFile(E);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await oe(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},ge=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},ue)},_e=async()=>{L&&await p.cancelDownload(L).catch(()=>{})},ve=D(j.status,F.status);return(0,b.jsx)(`main`,{className:`cid-page`,children:(0,b.jsxs)(`section`,{className:`cid-shell`,children:[(0,b.jsxs)(`div`,{className:`cid-heading`,children:[(0,b.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,b.jsx)(`h1`,{children:e(`cid.title`)}),(0,b.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,b.jsxs)(`div`,{className:`cid-panel`,children:[(0,b.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,b.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,b.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,b.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,b.jsxs)(`a`,{className:`btn btn-primary`,href:E,onClick:ge,children:[(0,b.jsx)(te,{size:16}),e(`cid.handoff.action`)]})]}),pe&&(0,b.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,b.jsx)(c,{size:18}),(0,b.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,b.jsxs)(r,{to:`/download/`,className:`btn btn-secondary`,children:[(0,b.jsx)(l,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,b.jsxs)(`div`,{className:`cid-status`,children:[(0,b.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ve}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`cid-status-label`,children:O(j.status,e)}),(0,b.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,b.jsxs)(`dl`,{className:`cid-details`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`dt`,{children:[(0,b.jsx)(ne,{size:16}),e(`cid.fileNameLabel`)]}),(0,b.jsx)(`dd`,{children:Y})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,b.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,b.jsx)(`dd`,{children:X?f(X):e(`cid.unknownSize`)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`dt`,{children:[(0,b.jsx)(re,{size:16}),e(`cid.saveToLabel`)]}),(0,b.jsx)(`dd`,{children:me})]})]}),F.status!==`idle`&&(0,b.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,b.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,b.jsxs)(`div`,{className:`cid-progress`,children:[(0,b.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,b.jsx)(`span`,{children:V!==null&&U!==null?`${f(V)} / ${f(U)}`:`${z}%`})]})]}),(0,b.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,b.jsxs)(`button`,{className:`btn btn-primary`,onClick:w,children:[(0,b.jsx)(_,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,b.jsxs)(`button`,{className:`btn btn-primary`,onClick:s,children:[(0,b.jsx)(v,{size:16}),e(`cid.connectAction`)]}),(0,b.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:he,children:[Q?(0,b.jsx)(g,{className:`cid-spin-icon`,size:16}):(0,b.jsx)(l,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,b.jsxs)(`button`,{className:`btn btn-secondary`,onClick:_e,children:[(0,b.jsx)(le,{size:16}),e(`cid.cancelAction`)]}),(0,b.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,b.jsx)(ie,{size:16}),e(`cid.retryAction`)]}),(0,b.jsx)(r,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})}function D(e,t){return t===`completed`?(0,b.jsx)(s,{size:28}):t===`error`||e===`error`?(0,b.jsx)(c,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,b.jsx)(g,{size:28}):e===`backend-missing`?(0,b.jsx)(v,{size:28}):e===`login-required`?(0,b.jsx)(_,{size:28}):(0,b.jsx)(s,{size:28})}function O(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:E});export{k as Route};
@@ -1 +0,0 @@
1
- import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),n=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t as n,n as t};