@xopcai/xopc 0.0.238 → 0.0.240

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 (141) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BCZ6T3y8.js → agent-avatar-dicebear-DNqb8LGQ.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CDZBY8QF.js +1 -0
  5. package/dist/gateway/static/root/assets/agents-BpWZKFrQ.js +1 -0
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-B_h6HVgw.js → app-management-settings-panel-4-eqCZG_.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-D07Ew40N.js → appearance-settings-Dus5TPxo.js} +1 -1
  8. package/dist/gateway/static/root/assets/apps-page-DPacUrzS.js +1 -0
  9. package/dist/gateway/static/root/assets/{attachment-load-C2Ac3q6g.js → attachment-load-CX2u191M.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-Bc4Is3z0.js → automations-page-BizspokZ.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-workspace-CudEcxwk.js +6 -0
  12. package/dist/gateway/static/root/assets/{binary-plugins-yMQJYHIQ.js → binary-plugins-CSn8R1EL.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-DrNzI_0p.js → block-editor-D5MN7UPI.js} +3 -3
  14. package/dist/gateway/static/root/assets/browser-settings-page-wKhgAIwg.js +8 -0
  15. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CHHw7Ula.js → browser-workflow-inputs-CeG3fWhC.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-workflows-page-D_EOs50E.js → browser-workflows-page-oqmPd1KI.js} +2 -2
  17. package/dist/gateway/static/root/assets/{capabilities-settings-panel-gKLN0aaW.js → capabilities-settings-panel-Dj_x6HTl.js} +5 -5
  18. package/dist/gateway/static/root/assets/channels-settings-BpsJRsjG.js +1 -0
  19. package/dist/gateway/static/root/assets/{chat-terminal-dock-B7agEwma.js → chat-terminal-dock-C0m-ie_q.js} +2 -2
  20. package/dist/gateway/static/root/assets/connectors-page-B-Gdzfob.js +2 -0
  21. package/dist/gateway/static/root/assets/{cron-expression-bjxQQFdv.js → cron-expression-DJOvtnKf.js} +1 -1
  22. package/dist/gateway/static/root/assets/{date-picker-C7ujLHll.js → date-picker-B06ZCEsb.js} +1 -1
  23. package/dist/gateway/static/root/assets/{dependency-picker-rl8E7nXp.js → dependency-picker-BU8dmVCo.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-D4GbYBcD.js → desktop-pet-INH03b4z.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-Bo34tFlD.js → desktop-pet-settings-CzAGt3M_.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-debug-page-DuPa1bVQ.js → extension-debug-page-BcEHXLQ2.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-page-CB9xF3qo.js → extension-page-CWefEHKN.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-settings-page-CovEdmGD.js → extension-settings-page-CjBTLU5X.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-config-api-CAaoukkR.js → gateway-config-api-4GYzRHAt.js} +1 -1
  30. package/dist/gateway/static/root/assets/{gateway-settings-CesXGTe3.js → gateway-settings-C8MQeYbR.js} +1 -1
  31. package/dist/gateway/static/root/assets/heartbeat-settings-C_8vY0Eu.js +1 -0
  32. package/dist/gateway/static/root/assets/home-page-D1SM6UXd.js +1 -0
  33. package/dist/gateway/static/root/assets/index-BN4XPtJY.js +70 -0
  34. package/dist/gateway/static/root/assets/index-CCBexxKW.css +2 -0
  35. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CpZxPmd0.js → keyboard-shortcuts-settings-xvS2czSF.js} +1 -1
  36. package/dist/gateway/static/root/assets/local-app-workbench-page-DAh4_rTj.js +2 -0
  37. package/dist/gateway/static/root/assets/{local-apps-page-5KTZwLbX.js → local-apps-page-BAYQxS0S.js} +1 -1
  38. package/dist/gateway/static/root/assets/{logs-page-frYgoe2x.js → logs-page-COS-Yb-N.js} +2 -2
  39. package/dist/gateway/static/root/assets/{management-settings-9iZjSpHe.js → management-settings-DYmKy_2v.js} +1 -1
  40. package/dist/gateway/static/root/assets/{markdown-split-C4-0M8mu.js → markdown-split-Cr32dNv1.js} +1 -1
  41. package/dist/gateway/static/root/assets/{media-plugins-CjMa9GMF.js → media-plugins-KPSjs3vW.js} +1 -1
  42. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DikJ7HCm.js → mobile-pairing-wizard-pWsC7jcc.js} +1 -1
  43. package/dist/gateway/static/root/assets/{notes-page-CC45W2KR.js → notes-page-DBBnJrFf.js} +1 -1
  44. package/dist/gateway/static/root/assets/notes-workbench-CSAzL8Tf.js +4 -0
  45. package/dist/gateway/static/root/assets/popover-select-DrILF6mR.js +1 -0
  46. package/dist/gateway/static/root/assets/project-detail-page-DHIJpssV.js +1 -0
  47. package/dist/gateway/static/root/assets/{projects-page-DR7OvyAl.js → projects-page-BDoAwszu.js} +1 -1
  48. package/dist/gateway/static/root/assets/remote-access-hub-DPi4SQVV.js +1 -0
  49. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DLv-QsQo.js → runtime-tools-settings-panel-DFTHpNg6.js} +1 -1
  50. package/dist/gateway/static/root/assets/{schema-form-DDW7aJWa.js → schema-form-CW7qifxi.js} +1 -1
  51. package/dist/gateway/static/root/assets/sessions-page-VNrtwwV5.js +1 -0
  52. package/dist/gateway/static/root/assets/settings-advanced-gate-CUcTHMDp.js +1 -0
  53. package/dist/gateway/static/root/assets/{settings-form-section-5NTg906_.js → settings-form-section-OMPX3Svb.js} +1 -1
  54. package/dist/gateway/static/root/assets/{settings-page-DgTYtrmh.js → settings-page-CDKXJ12S.js} +1 -1
  55. package/dist/gateway/static/root/assets/setup-status-panel-Dnvfemeb.js +1 -0
  56. package/dist/gateway/static/root/assets/{share-preview-page-BX2Ev7-I.js → share-preview-page-BoSIu0WX.js} +1 -1
  57. package/dist/gateway/static/root/assets/shares-settings-C87QeRxC.js +1 -0
  58. package/dist/gateway/static/root/assets/skill-reload-api-rY5ujr0j.js +1 -0
  59. package/dist/gateway/static/root/assets/{skills-page-Cmqu9f_n.js → skills-page-DAAlmTSh.js} +1 -1
  60. package/dist/gateway/static/root/assets/{skills-page.utils-KOxLvm84.js → skills-page.utils-CiMRNDFM.js} +1 -1
  61. package/dist/gateway/static/root/assets/{system-settings-panel-CS7cDwv2.js → system-settings-panel-Bq7niN-G.js} +1 -1
  62. package/dist/gateway/static/root/assets/task-detail-page-JtztFp2Y.js +1 -0
  63. package/dist/gateway/static/root/assets/tunnel-api-eBX1eb2v.js +1 -0
  64. package/dist/gateway/static/root/assets/{use-autosave-DvATIVb_.js → use-autosave-CkwILwYg.js} +1 -1
  65. package/dist/gateway/static/root/assets/user-context-page-CMH2GOGL.js +1 -0
  66. package/dist/gateway/static/root/assets/{voice-api-key-field-C3BgRKG2.js → voice-api-key-field-BG-kpmoU.js} +1 -1
  67. package/dist/gateway/static/root/assets/{work-discovery-overlay-DHcQSZZD.js → work-discovery-overlay-BOH2utuu.js} +1 -1
  68. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Nx6xmy_N.js → workflow-run-setup-panel-B92rr2yf.js} +2 -2
  69. package/dist/gateway/static/root/assets/workflows-page-DXvdYJff.js +5 -0
  70. package/dist/gateway/static/root/index.html +3 -3
  71. package/dist/package.js +1 -1
  72. package/dist/src/agent/agent-manager.js +4 -4
  73. package/dist/src/agent/background-review/run-background-review.js +1 -1
  74. package/dist/src/agent/embedded/model-runtime.js +1 -1
  75. package/dist/src/agent/embedded/run-for-session.js +1 -1
  76. package/dist/src/agent/image/tool-model-config.js +1 -1
  77. package/dist/src/agent/ipc/inbox.js +1 -1
  78. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  79. package/dist/src/agent/service.js +2 -2
  80. package/dist/src/agent/session/session-inspector.js +1 -1
  81. package/dist/src/agent/skills/hub-lock.js +1 -1
  82. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  83. package/dist/src/ai-assist/text-assist.js +1 -1
  84. package/dist/src/auth/credentials.js +2 -2
  85. package/dist/src/auth/profiles/store.js +1 -1
  86. package/dist/src/auth/sync-provider-auth.js +2 -2
  87. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  88. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  89. package/dist/src/cli/commands/models.js +1 -1
  90. package/dist/src/config/index.js +4 -4
  91. package/dist/src/config/loader.js +1 -1
  92. package/dist/src/config/models-json.js +1 -1
  93. package/dist/src/extensions/lockfile.js +1 -1
  94. package/dist/src/gateway/agents-admin.js +1 -1
  95. package/dist/src/gateway/file-path-classifier.js +1 -1
  96. package/dist/src/gateway/heartbeat/service.js +1 -1
  97. package/dist/src/gateway/hono/app.js +2 -2
  98. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  99. package/dist/src/gateway/hono/routes/execution-environments.js +22 -0
  100. package/dist/src/gateway/hono/routes/models.js +1 -1
  101. package/dist/src/gateway/hono/routes/sessions.js +4 -0
  102. package/dist/src/gateway/hono/routes/shares.js +3 -0
  103. package/dist/src/gateway/security/csp.d.ts +2 -0
  104. package/dist/src/gateway/security/csp.js +17 -1
  105. package/dist/src/gateway/service/config-coordinator.js +1 -1
  106. package/dist/src/gateway/service.js +3 -3
  107. package/dist/src/heartbeat/index.js +1 -1
  108. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  109. package/dist/src/providers/index.js +2 -2
  110. package/dist/src/providers/model-registry.js +1 -1
  111. package/dist/src/providers/register-runtime-providers.js +1 -1
  112. package/dist/src/share/hosted-session-share.js +1 -1
  113. package/dist/src/tui/tui-startup-resources.js +1 -1
  114. package/dist/src/tui/tui.js +1 -1
  115. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  116. package/package.json +3 -3
  117. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-KPtQudPf.js +0 -1
  118. package/dist/gateway/static/root/assets/agents-DKQZKGCB.js +0 -1
  119. package/dist/gateway/static/root/assets/apps-page-_toby2SK.js +0 -1
  120. package/dist/gateway/static/root/assets/automations-workspace-DH-QeQ0O.js +0 -6
  121. package/dist/gateway/static/root/assets/browser-settings-page-Bv8GclZd.js +0 -8
  122. package/dist/gateway/static/root/assets/channels-settings-Bh7BqWsN.js +0 -1
  123. package/dist/gateway/static/root/assets/connectors-page-DifO0WX4.js +0 -2
  124. package/dist/gateway/static/root/assets/heartbeat-settings-Bu5cIcNb.js +0 -1
  125. package/dist/gateway/static/root/assets/home-page-sQfx98tH.js +0 -1
  126. package/dist/gateway/static/root/assets/index-C73V7tJP.js +0 -70
  127. package/dist/gateway/static/root/assets/index-C9rUND9-.css +0 -2
  128. package/dist/gateway/static/root/assets/local-app-workbench-page-DjvHSI0e.js +0 -2
  129. package/dist/gateway/static/root/assets/notes-workbench-BFreGbmY.js +0 -4
  130. package/dist/gateway/static/root/assets/popover-select-DBrVS3tZ.js +0 -1
  131. package/dist/gateway/static/root/assets/project-detail-page-53z9nB5L.js +0 -1
  132. package/dist/gateway/static/root/assets/remote-access-hub-BkSGDDbn.js +0 -1
  133. package/dist/gateway/static/root/assets/sessions-page-C-yaSuuQ.js +0 -1
  134. package/dist/gateway/static/root/assets/settings-advanced-gate-CelrRPXt.js +0 -1
  135. package/dist/gateway/static/root/assets/setup-status-panel-Dm_gdAfm.js +0 -1
  136. package/dist/gateway/static/root/assets/shares-settings-D2Zd9l04.js +0 -1
  137. package/dist/gateway/static/root/assets/skill-reload-api-BvND7xsL.js +0 -1
  138. package/dist/gateway/static/root/assets/task-detail-page-COpgFG6K.js +0 -1
  139. package/dist/gateway/static/root/assets/tunnel-api-D3h311_s.js +0 -1
  140. package/dist/gateway/static/root/assets/user-context-page-PKrbPu4w.js +0 -1
  141. package/dist/gateway/static/root/assets/workflows-page-DBkP6B4E.js +0 -5
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,t as o}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as s}from"./check-DUBLcKHA.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./button-CSEbl4zT.js";import{n as f,r as p}from"./locale-store-XDFAPNNu.js";import{t as m}from"./skeleton-BwbyijEw.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BPoKqzeH.js";import{a as S,i as C}from"./vendor-swr-BIWyz7Rc.js";import{Aa as w,As as te,Bc as ne,Bo as re,Ea as ie,Hi as ae,Ji as oe,Vs as T,Wc as E,Wr as se,as as ce,bs as le,es as ue,kc as de,ms as fe,pc as pe,ps as me,wc as he,yl as ge,ys as _e,zo as ve}from"./index-C73V7tJP.js";import{n as ye,t as be}from"./tab-completion-input-D64VNmiA.js";import{t as xe}from"./tab-completion-input.utils-BP3NH_du.js";import{a as Se,c as Ce,l as we,n as Te,o as Ee,r as De,s as Oe,t as ke}from"./api-IUm57Zse.js";var D=e(t(),1),Ae=`build-xopc-local-app`;function je(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function Me(e){return e.find(e=>je(e)===`coder`)??null}function Ne(e,t){let n=new URLSearchParams({skill:Ae}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var O=new Set([`document`,`content`,`interaction`,`criteria`]),Pe=new Set([`passed`,`failed`,`skipped`]);function Fe(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.source!==`xopc-local-app-preview`||t.version!==1)return null;if(t.type===`ready`)return{type:`ready`,detail:{}};if(t.type===`criteria`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.scenarios)||e.scenarios.length>10)return null;let n=e.scenarios.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!t.id.trim()||t.id.length>80||typeof t.name!=`string`||!t.name.trim()||t.name.length>120||t.status!==`passed`&&t.status!==`failed`||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,name:t.name,status:t.status,message:t.message.slice(0,500),failureKind:`scenario`}});if(n.some(e=>e===null))return null;let r=typeof e.scenarioCount==`number`&&Number.isInteger(e.scenarioCount)&&e.scenarioCount>=0&&e.scenarioCount<=10?e.scenarioCount:n.length;return{type:`criteria`,detail:{status:e.status,scenarioCount:r,scenarios:n}}}if(t.type===`acceptance`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.checks))return null;let n=e.checks.slice(0,10).map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return!O.has(t.id)||!Pe.has(t.status)||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,status:t.status,message:t.message.slice(0,500)}});if(!n.length||n.some(e=>e===null))return null;let r=typeof e.interactiveCount==`number`&&Number.isFinite(e.interactiveCount)&&e.interactiveCount>=0?Math.min(Math.floor(e.interactiveCount),1e4):0;return{type:`acceptance`,detail:{status:e.status,checks:n,interactiveCount:r}}}if(t.type!==`error`||!t.detail||typeof t.detail!=`object`)return null;let n=t.detail;return n.kind!==`script_error`&&n.kind!==`unhandled_rejection`||typeof n.message!=`string`||!n.message.trim()?null:{type:`error`,detail:{kind:n.kind,message:n.message.slice(0,500),filename:typeof n.filename==`string`?n.filename.slice(0,500):void 0,line:typeof n.line==`number`?n.line:void 0,column:typeof n.column==`number`?n.column:void 0}}}function Ie(e){return e?.checks.filter(e=>e.status===`failed`).map(e=>e.message)??[]}function Le(e){let t=e.filename?` (${e.filename}${e.line?`:${e.line}${e.column?`:${e.column}`:``}`:``})`:``;return`${e.message}${t}`}var Re=Object.freeze({source:`xopc-local-app-host`,version:1,type:`connect`});function ze(e,t){let n=null,r=()=>{n?.close();let r=new MessageChannel;n=r.port1,n.onmessage=e=>t(e.data),n.start(),e.contentWindow?.postMessage(Re,`*`,[r.port2])};return e.addEventListener(`load`,r),r(),()=>{e.removeEventListener(`load`,r),n?.close()}}var Be=n(),k=r();function Ve(e){let t=(0,Be.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let u=a?`产品场景`:`Product scenarios`,f;t[0]===u?f=t[1]:(f=(0,k.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:u}),t[0]=u,t[1]=f);let p=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,m;t[2]===p?m=t[3]:(m=(0,k.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:p}),t[2]=p,t[3]=m);let h;t[4]!==f||t[5]!==m?(h=(0,k.jsxs)(`div`,{children:[f,m]}),t[4]=f,t[5]=m,t[6]=h):h=t[6];let g=i!==null,_;t[7]===i?_=t[8]:(_=i===`all`?(0,k.jsx)(l,{className:`size-3 animate-spin`}):(0,k.jsx)(fe,{className:`size-3`}),t[7]=i,t[8]=_);let v=a?`全部重跑`:`Run all`,y;t[9]!==o||t[10]!==g||t[11]!==_||t[12]!==v?(y=(0,k.jsxs)(d,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:g,children:[_,v]}),t[9]=o,t[10]=g,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==h||t[15]!==y?(b=(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[h,y]}),t[14]=h,t[15]=y,t[16]=b):b=t[16];let x=a?`产品场景验收结果`:`Product scenario acceptance results`,S;if(t[17]!==c||t[18]!==s||t[19]!==r||t[20]!==i||t[21]!==n||t[22]!==a){let e;t[24]!==c||t[25]!==s||t[26]!==r||t[27]!==i||t[28]!==a?(e=e=>{let t=r[e.id],n=i===`all`||i===e.id?`running`:t?.status??`pending`;return(0,k.jsx)(`li`,{className:`py-2.5 first:pt-1`,children:(0,k.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,k.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:n===`running`?(0,k.jsx)(l,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,k.jsx)(ee,{className:`size-3.5 text-success`}):n===`failed`?(0,k.jsx)(E,{className:`size-3.5 text-danger`}):(0,k.jsx)(ne,{className:`size-3.5 text-fg-subtle`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-[11px] font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`mt-0.5 text-[10px] text-fg-subtle`,children:a?`${e.stepCount} 个步骤`:`${e.stepCount} step${e.stepCount===1?``:`s`}`})]}),(0,k.jsx)(d,{variant:`ghost`,className:`size-7 shrink-0 rounded-lg p-0`,onClick:()=>s(e.id),disabled:i!==null,"aria-label":a?`重跑${e.name}`:`Rerun ${e.name}`,title:a?`单独重跑`:`Rerun scenario`,children:(0,k.jsx)(fe,{className:`size-3`})})]}),n===`running`?(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`正在隔离预览中执行…`:`Running in an isolated preview…`}):t?.status===`failed`?(0,k.jsxs)(`div`,{className:`mt-1.5`,children:[(0,k.jsx)(`p`,{className:`text-[11px] leading-4 text-danger`,children:t.message}),(0,k.jsxs)(d,{variant:`ghost`,className:`mt-1 h-7 rounded-lg px-2 text-[11px] text-danger hover:text-danger`,onClick:()=>c(e,t),children:[(0,k.jsx)(T,{className:`size-3`}),a?`让 Coder 修复`:`Ask Coder to fix`]})]}):t?.status===`passed`?(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`场景已通过`:`Scenario passed`}):(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`等待运行`:`Waiting to run`})]})]})},e.id)},t[24]=c,t[25]=s,t[26]=r,t[27]=i,t[28]=a,t[29]=e):e=t[29],S=n.map(e),t[17]=c,t[18]=s,t[19]=r,t[20]=i,t[21]=n,t[22]=a,t[23]=S}else S=t[23];let C;t[30]!==x||t[31]!==S?(C=(0,k.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":x,children:S}),t[30]=x,t[31]=S,t[32]=C):C=t[32];let w;return t[33]!==b||t[34]!==C?(w=(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[b,C]}),t[33]=b,t[34]=C,t[35]=w):w=t[35],w}var He=`allow-scripts allow-forms`;function Ue(e,t){return se(e,t)}function We(e,t,n){return!!(t&&n&&e.sourceHash===t&&e.status===n.status&&e.interactiveCount===n.interactiveCount&&JSON.stringify(e.checks)===JSON.stringify(n.checks))}function A(){let{appId:e}=i(),t=e===`new`,n=f(e=>e.language)===`zh`,r=f(e=>e.language),ne=a(),{mutate:E}=S(),se=ie(e=>e.moveToFront),Ae=w(e=>e.setPageHeader),je=w(e=>e.clearPageHeader),{data:O,isLoading:Pe,error:Re,mutate:Be}=C(!t&&e?[`local-app`,e]:null,()=>Te(e)),{data:A,isLoading:Ge,mutate:j}=C(!t&&e?[`local-app-validation`,e]:null,()=>we(e)),[Ke,qe]=(0,D.useState)(``),[Je,Ye]=(0,D.useState)(``),[M,N]=(0,D.useState)(!1),[Xe,P]=(0,D.useState)(null),[Ze,Qe]=(0,D.useState)(!1),[$e,et]=(0,D.useState)(!1),[tt,nt]=(0,D.useState)(0),[rt,it]=(0,D.useState)(``),[F,at]=(0,D.useState)(!1),[ot,st]=(0,D.useState)(!1),[I,L]=(0,D.useState)(`booting`),[R,ct]=(0,D.useState)(null),[z,lt]=(0,D.useState)(null),[B,ut]=(0,D.useState)({}),[V,H]=(0,D.useState)(`all`),[U,W]=(0,D.useState)(0),[dt,ft]=(0,D.useState)(0),[pt,mt]=(0,D.useState)(null),[G,ht]=(0,D.useState)(null),[gt,_t]=(0,D.useState)([]),[vt,yt]=(0,D.useState)(!1),bt=(0,D.useRef)(new Set),K=(0,D.useRef)(null),xt=(0,D.useRef)(null),St=(0,D.useRef)(null),q=(0,D.useRef)(null),J=(0,D.useRef)(``),Y=A?.acceptanceScenarios??[],X=(0,D.useMemo)(()=>{if(!Y.length)return null;let e=Y.map(e=>B[e.id]).filter(e=>!!e);return e.length===Y.length?{status:e.some(e=>e.status===`failed`)?`failed`:`passed`,scenarioCount:Y.length,scenarios:e}:null},[Y,B]),Z=(0,D.useMemo)(()=>{if(!z)return null;if(!A?.acceptanceScenarioCount)return z;if(!X)return null;let e=X.scenarios.find(e=>e.status===`failed`),t={id:`criteria`,status:X.status,message:e?`${e.name}: ${e.message}`:`${X.scenarioCount} product scenario(s) passed`},n=[...z.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:z.interactiveCount}},[z,X,A?.acceptanceScenarioCount]),Ct=(0,D.useCallback)(async(e,t)=>{let n=Me(await oe(e.projectId))??await ae(e.projectId,`coder`);bt.current.add(n.key),ne(Ne(n.key,t))},[ne]),wt=(0,D.useCallback)(async(e=!0)=>{if(!O)return null;st(!0);try{let t=await we(O.id);return await j(t,{revalidate:!1}),e&&(q.current=t.sourceHash??null,H(`all`),W(0),nt(e=>e+1)),t}catch(e){return P(e instanceof Error?e.message:String(e)),null}finally{st(!1)}},[O,j]);(0,D.useEffect)(()=>{if(!O)return;let e=!1;oe(O.projectId).then(t=>{e||(bt.current=new Set(t.filter(e=>(e.routing?.agentId??e.agentId)?.toLowerCase()===`coder`).map(e=>e.key)))}).catch(()=>{});let t=e=>{let t=e.detail?.key;!t||!bt.current.has(t)||(K.current!==null&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>{K.current=null,wt(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),K.current!==null&&window.clearTimeout(K.current)}},[O,wt]),(0,D.useEffect)(()=>{_t(O?.acceptanceRuns??[])},[O?.acceptanceRuns]),(0,D.useEffect)(()=>{q.current=null},[O?.id]),(0,D.useEffect)(()=>{!A?.sourceHash||q.current||(q.current=A.sourceHash,H(`all`),W(0),nt(e=>e+1))},[A?.sourceHash]),(0,D.useLayoutEffect)(()=>{if(!O)return;L(`booting`),ct(null),lt(null),ht(null),yt(!1),J.current=``;let e=window.setTimeout(()=>L(e=>e===`failed`?e:`timeout`),7e3),t=xt.current?ze(xt.current,t=>{let n=Fe(t);if(n){if(n.type===`ready`){L(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),lt(n.detail),ht(q.current);return}n.type!==`criteria`&&(window.clearTimeout(e),ct(n.detail),L(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[O,tt]),(0,D.useLayoutEffect)(()=>{if(!O||A?.status!==`healthy`||!Y.length){mt(null);return}let e=V===`all`?Y[U]:Y.find(e=>e.id===V),t=e?[e]:[];if(!t.length)return;mt(V),ut(e=>{if(V===`all`&&U===0)return{};let t={...e};return delete t[V],t});let r=!1,i=e=>{ut(n=>{let r={...n};for(let n of t)r[n.id]={id:n.id,name:n.name,status:`failed`,message:e,failureKind:`runner`};return r}),mt(null)},a=window.setTimeout(()=>i(r?n?`场景在 10 秒内未完成。`:`Scenario did not finish within 10 seconds.`:n?`验收执行器未能连接,请重新验收。`:`The acceptance runner did not connect. Run acceptance again.`),1e4),o=St.current?ze(St.current,e=>{let t=Fe(e);t&&(t.type===`ready`?r=!0:t.type===`criteria`?(window.clearTimeout(a),ut(e=>{let n={...e};for(let e of t.detail.scenarios)(n[e.id]?.status!==`failed`||e.status===`failed`)&&(n[e.id]=e);return n}),V===`all`&&U+1<Y.length?(W(e=>e+1),ft(e=>e+1)):mt(null)):t.type===`error`&&(window.clearTimeout(a),i(Le(t.detail))))}):()=>{};return()=>{window.clearTimeout(a),o()}},[Y,O,dt,V,U,tt,A?.status,n]),(0,D.useEffect)(()=>{if(!O||!Z||!G||G!==A?.sourceHash)return;let e=`${O.id}:${G}:${JSON.stringify(Z)}`;J.current!==e&&(J.current=e,yt(!0),Se(O.id,G,Z).then(t=>{J.current===e&&_t(e=>[t,...e.filter(e=>e.id!==t.id)].toSorted((e,t)=>t.createdAt-e.createdAt).slice(0,20))}).catch(t=>{J.current===e&&(J.current=``,P(t instanceof Error?t.message:String(t)))}).finally(()=>{J.current===e&&yt(!1)}))},[Z,G,O,A?.sourceHash]);let Q=(0,D.useCallback)(async e=>{if(O){at(!0),P(null);try{await Ct(O,e)}catch(e){P(e instanceof Error?e.message:String(e)),at(!1)}}},[O,Ct]);(0,D.useLayoutEffect)(()=>(Ae({startExtra:(0,k.jsx)(o,{to:`/local-apps`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`返回本地应用`:`Back to local apps`,children:(0,k.jsx)(ge,{className:`size-4`})}),main:(0,k.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:O?.name||(n?`创建本地应用`:`Create local app`)}),end:O?(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(d,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,k.jsxs)(o,{to:`/projects/${encodeURIComponent(O.projectId)}`,children:[(0,k.jsx)(he,{className:`size-4`}),`Project`]})}),(0,k.jsxs)(d,{className:`h-9`,onClick:()=>void Q(),disabled:F,children:[F?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(T,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>je()),[O,F,je,Q,Ae,n]);async function Tt(e){e.preventDefault(),N(!0),P(null);try{let e=await ke({name:Ke,idea:Je});await E(`local-apps-list`);let t=n?`请基于 APP_BRIEF.md 完成这个本地应用的首版。先检查现有草稿,再实现最小可用版本并运行校验;完成后告诉我可以如何预览。`:`Build the first usable version of this local app from APP_BRIEF.md. Inspect the existing draft, implement the smallest useful version, run validation, and tell me how to preview it.`;try{await Ct(e,t)}catch{ne(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Et(){if(O){N(!0),P(null);try{let e=await De(O.id);await Be(e,{revalidate:!1}),await j(),await Promise.all([E(`local-apps-list`),E(`gateway-extensions-list`)]),se(`ext:${e.extensionId}:app`),Qe(!1)}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Dt(e,t=!1){N(!0),P(null);try{let n=await e();return await Be(n,{revalidate:!1}),await j(),await Promise.all([E(`local-apps-list`),E(`gateway-extensions-list`)]),t&&se(`ext:${n.extensionId}:app`),!0}catch(e){return P(e instanceof Error?e.message:String(e)),!1}finally{N(!1)}}async function Ot(e){O&&await Dt(()=>Oe(O.id,e),e)}async function kt(e){O&&await Dt(()=>Ee(O.id,e),!0)}async function At(){O&&await Dt(()=>Ce(O.id))&&et(!1)}function jt(){let e=Array.from(new Set([...A?.issues.map(e=>e.message)??[],...R?[Le(R)]:[],...Z?.checks.filter(e=>e.status===`failed`&&e.id!==`criteria`).map(e=>e.message)??[],...Object.values(B).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.failureKind===`runner`?`[验收执行器] `:``}${e.message}`),...I===`timeout`?[n?`预览在 7 秒内未完成启动,可能存在白屏或阻塞。`:`The preview did not finish booting within 7 seconds and may be blank or blocked.`]:[]]));if(!e.length)return;let t=e.map(e=>`- ${e}`).join(`
2
- `);Q(n?`请修复当前本地应用草稿的校验问题,保持扩展 ID 和已安装版本不变。先复现并判断问题来自应用行为还是验收执行器,不要通过弱化断言绕过问题。修复后运行完整校验。\n\n${t}`:`Fix the current local-app draft validation issues without changing the extension id or installed release. Reproduce first and determine whether each issue comes from app behavior or the acceptance runner; do not weaken assertions to bypass it. Run the full validation afterward.\n\n${t}`)}function Mt(){H(`all`),W(0),ft(e=>e+1)}function Nt(e){H(e),W(0),ft(e=>e+1)}function Pt(e,t){let r=t.failureKind===`runner`?n?`验收执行器`:`acceptance runner`:n?`产品场景`:`product scenario`;Q(n?`请修复本地应用的${r}问题“${e.name}”。当前失败信息:${t.message}\n\n保持扩展 ID 和场景原意不变;先复现并判断问题来自应用行为还是验收执行器,不要通过弱化断言绕过问题。修复后运行完整校验。`:`Fix the local-app ${r} issue "${e.name}". Current failure: ${t.message}\n\nPreserve the extension id and scenario intent. Reproduce first and determine whether the issue comes from app behavior or the runner; do not weaken assertions to bypass it. Run the full validation afterward.`)}let Ft=gt.findIndex(e=>We(e,G,Z)),$=Ft>=0?gt[Ft]:null,It=Ft>=0?gt[Ft+1]??null:gt[0]??null,Lt=Ie(Z),Rt=It?It.checks.filter(e=>e.status===`failed`).map(e=>e.message):[],zt=A?.status===`failed`||I===`failed`||I===`timeout`||Z?.status===`failed`||Object.values(B).some(e=>e.status===`failed`),Bt=Rt.filter(e=>!Lt.includes(e)).length;async function Vt(){let e=await wt(!1);if(e?.status===`healthy`&&e.sourceHash!==G){q.current=e.sourceHash??null,W(0),nt(e=>e+1);return}e?.status===`healthy`&&I===`healthy`&&Z?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&Qe(!0)}return t?(0,k.jsx)(`div`,{className:`flex min-h-0 flex-1 bg-surface-panel p-3 sm:p-5 xl:p-6`,children:(0,k.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-surface lg:grid-cols-[minmax(280px,0.8fr)_minmax(0,1.5fr)]`,children:[(0,k.jsxs)(`form`,{onSubmit:Tt,className:`flex flex-col border-b border-edge-subtle p-5 lg:border-b-0 lg:border-r`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[(0,k.jsx)(ue,{className:`size-4`}),n?`告诉 Coder 你的想法`:`Tell Coder your idea`]}),(0,k.jsx)(`h2`,{className:`mt-4 text-xl font-semibold tracking-tight text-fg`,children:n?`你想创建什么?`:`What do you want to create?`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`我们会建立一个 Coder Project,并把应用上下文和开发 Skill 带入对话。`:`We will create a Coder Project and carry the app context and development skill into chat.`}),(0,k.jsxs)(`label`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:[n?`应用名称`:`App name`,(0,k.jsx)(be,{value:Ke,onChange:e=>qe(e.target.value),suggestion:xe(n?`例如:阅读清单`:`e.g. Reading list`),onAcceptSuggestion:qe,required:!0,className:`mt-2 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:阅读清单`:`e.g. Reading list`})]}),(0,k.jsxs)(`label`,{className:`mt-4 text-xs font-medium text-fg-muted`,children:[n?`描述你的想法`:`Describe your idea`,(0,k.jsx)(ye,{value:Je,onChange:e=>Ye(e.target.value),suggestion:xe(n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`),onAcceptSuggestion:Ye,required:!0,rows:7,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`})]}),Xe?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:Xe}):null,(0,k.jsxs)(d,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:M||!Ke.trim()||!Je.trim(),children:[M?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(T,{className:`size-4`}),n?`进入 Coder 对话`:`Continue with Coder`]})]}),(0,k.jsx)(`div`,{className:`hidden min-h-[620px] place-items-center bg-surface-panel p-8 lg:grid`,children:(0,k.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,k.jsx)(`div`,{className:`mx-auto flex size-16 items-center justify-center rounded-2xl border border-edge bg-surface-base text-accent shadow-surface`,children:(0,k.jsx)(te,{className:`size-7`})}),(0,k.jsx)(`h3`,{className:`mt-5 text-base font-semibold text-fg`,children:n?`创建后,这里就是实时预览`:`Your live preview appears here`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`你可以先体验草稿,再决定是否把它添加到左侧导航。`:`Try the draft first, then decide whether to add it to the sidebar.`})]})})]})}):Pe?(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_260px]`,children:[(0,k.jsx)(m,{className:`rounded-xl`}),(0,k.jsx)(m,{className:`rounded-xl`}),(0,k.jsx)(m,{className:`rounded-xl`})]}):Re||!O?(0,k.jsx)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:Re instanceof Error?Re.message:n?`找不到应用`:`App not found`}):(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_300px]`,children:[(0,k.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.12em] text-accent`,children:[(0,k.jsx)(ue,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,k.jsx)(`div`,{className:`mt-4 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg`,children:O.idea}),(0,k.jsxs)(`div`,{className:`mt-4 rounded-xl bg-accent-soft p-3`,children:[(0,k.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-accent-fg`,children:[(0,k.jsx)(ee,{className:`size-4`}),n?`草稿已准备好`:`Draft is ready`]}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`继续迭代会进入对应 Project,由 Coder 读取应用上下文和专属 skill。`:`Continue in the Project where Coder has the app context and dedicated skill.`})]}),(0,k.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),Q(rt)},children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`local-app-change-request`,children:n?`下一步想改什么?`:`What should change next?`}),(0,k.jsx)(ye,{id:`local-app-change-request`,value:rt,onChange:e=>it(e.target.value),suggestion:xe(n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`),onAcceptSuggestion:it,rows:4,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`}),(0,k.jsxs)(d,{type:`submit`,className:`mt-2 w-full`,disabled:F||!rt.trim(),children:[F?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(T,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,k.jsxs)(d,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:F,children:[(0,k.jsx)(he,{className:`size-4`}),n?`打开已有开发对话`:`Open development chat`]})]}),(0,k.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,k.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-edge-subtle px-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,k.jsx)(`span`,{className:`size-2 rounded-full ${A?.status===`failed`||I===`failed`||I===`timeout`||Z?.status===`failed`?`bg-danger`:A?.status===`healthy`&&I===`healthy`&&Z?.status===`passed`&&$?.sourceHash===A.sourceHash&&!vt?`bg-success`:`bg-fg-subtle`}`}),I===`failed`||I===`timeout`?n?`预览运行异常`:`Preview runtime issue`:A?.status===`failed`||Z?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:I===`booting`||!Z?n?`自动验收中`:`Running acceptance`:vt||$?.sourceHash!==A?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,k.jsxs)(d,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void wt(!0),disabled:ot,children:[ot?(0,k.jsx)(l,{className:`size-3.5 animate-spin`}):(0,k.jsx)(fe,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,k.jsx)(`iframe`,{ref:xt,title:`${O.name} preview`,src:p(O.previewUrl),sandbox:He,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{ct({kind:`script_error`,message:`Preview document failed to load`}),L(`failed`)}},tt),A?.status===`healthy`&&A.acceptanceScenarioCount>0?(0,k.jsx)(`iframe`,{ref:St,title:`${O.name} acceptance runner`,src:`${p(O.previewUrl)}?xopcAcceptance=1&xopcScenario=${encodeURIComponent(V===`all`?Y[U]?.id??``:V)}`,sandbox:He,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${tt}-${dt}-${U}`):null]}),(0,k.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n?`发布状态`:`Release status`}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O.installationState===`not_installed`?n?`尚未安装`:`Not installed`:O.enabled?n?`版本 ${O.activeVersion} 正在使用`:`Version ${O.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,k.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${O.enabled?`bg-success`:`bg-fg-subtle`}`,"aria-hidden":!0})]}),(0,k.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 text-xs`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`当前草稿`:`Draft`}),(0,k.jsxs)(`dd`,{className:`mt-1 font-medium text-fg`,children:[`v`,O.draftVersion]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`已安装`:`Installed`}),(0,k.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:O.activeVersion?`v${O.activeVersion}`:`—`})]})]}),(0,k.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,k.jsx)(de,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),Ge||ot?(0,k.jsx)(l,{className:`size-3.5 animate-spin text-fg-muted`}):A?.status===`healthy`?(0,k.jsx)(ee,{className:`size-4 text-success`}):(0,k.jsx)(ve,{className:`size-4 text-danger`})]}),A?(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`p`,{className:`text-xs leading-5 ${A.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:A.status===`healthy`?A.hasDraftChanges?n?`${A.changedFileCount} 个文件有改动,可以安装新版本。`:`${A.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:A.issues[0]?.message}),A.changedFiles.length?(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:A.changedFiles.slice(0,4).map(e=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,A.changedFileCount>4?(0,k.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${A.changedFileCount-4} 个文件`:`${A.changedFileCount-4} more files`}):null,(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,k.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,k.jsx)(`span`,{className:`size-2 rounded-full ${I===`healthy`?`bg-success`:I===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${I===`failed`||I===`timeout`?`text-danger`:`text-fg-muted`}`,children:R?Le(R):I===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:I===`timeout`?n?`7 秒内未完成启动,可能出现白屏或阻塞。`:`Did not finish booting within 7 seconds.`:n?`正在等待应用启动。`:`Waiting for the app to start.`})]}),(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,k.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,k.jsx)(`span`,{className:`size-2 rounded-full ${Z?.status===`passed`?`bg-success`:Z?.status===`failed`?`bg-danger`:`bg-fg-subtle`}`}),n?`自动验收`:`Automatic acceptance`]}),Z?(0,k.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:Z.checks.map(e=>(0,k.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4 ${e.status===`failed`?`text-danger`:`text-fg-muted`}`,children:[(0,k.jsx)(`span`,{className:`mt-1 size-1.5 shrink-0 rounded-full ${e.status===`failed`?`bg-danger`:e.status===`passed`?`bg-success`:`bg-fg-subtle`}`}),(0,k.jsx)(`span`,{children:e.message})]},e.id))}):(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:A?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${A.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${A.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),vt?(0,k.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(l,{className:`size-3 animate-spin`}),n?`正在保存当前源码对应的验收快照…`:`Saving the acceptance snapshot for this source…`]}):$?(0,k.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-fg-muted`,children:It?n?`相比上次:已修复 ${Bt} 项,仍有 ${Lt.length} 项。`:`Since the previous run: ${Bt} fixed, ${Lt.length} remaining.`:n?`首个验收快照已保存。`:`First acceptance snapshot saved.`}):null,(0,k.jsx)(Ve,{scenarios:Y,results:B,runningTarget:pt,zh:n,onRunAll:Mt,onRunScenario:Nt,onAskCoder:Pt})]}),zt?(0,k.jsxs)(d,{className:`mt-3 w-full`,onClick:jt,disabled:F,children:[(0,k.jsx)(T,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,k.jsx)(m,{className:`mt-2 h-12 rounded-lg`})]}),(0,k.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,k.jsx)(ce,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,k.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(A?.permissions??O.permissions).map(e=>(0,k.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e))})]}),(0,k.jsx)(d,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Vt(),disabled:M||Ge||ot||vt||A?.status===`failed`||I!==`healthy`||Z?.status!==`passed`||!$||$.sourceHash!==A?.sourceHash||O.installationState===`installed`&&A?.hasDraftChanges===!1,children:O.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),O.installationState===`installed`?(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,k.jsxs)(d,{className:`min-w-0 flex-1`,onClick:()=>void Ot(!O.enabled),disabled:M,children:[O.enabled?(0,k.jsx)(le,{className:`size-4`}):(0,k.jsx)(_e,{className:`size-4`}),O.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,k.jsx)(d,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>et(!0),disabled:M,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,k.jsx)(re,{className:`size-4`})})]}):null,(0,k.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4`,children:[(0,k.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,k.jsx)(pe,{className:`size-4`}),n?`版本历史`:`Release history`]}),O.releases.length?(0,k.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:O.releases.map(e=>(0,k.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2.5`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[`v`,e.version,e.isActive?(0,k.jsx)(`span`,{className:`rounded-full bg-success-soft px-1.5 py-0.5 text-[10px] text-success`,children:n?`当前`:`Active`}):null]}),(0,k.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-fg-subtle`,children:Ue(e.createdAt,r)})]}),e.isActive?null:(0,k.jsxs)(d,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void kt(e.id),disabled:M,children:[(0,k.jsx)(me,{className:`size-3.5`}),n?`恢复`:`Restore`]})]},e.id))}):(0,k.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n?`安装首个版本后,可以从这里恢复。`:`Install the first version to enable recovery.`})]}),Xe?(0,k.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:Xe}):null]}),(0,k.jsx)(x,{open:Ze,onOpenChange:Qe,children:(0,k.jsxs)(v,{children:[(0,k.jsx)(h,{className:`fixed inset-0 z-50 bg-black/45`}),(0,k.jsxs)(y,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(560px,calc(100vh-32px))] w-[min(520px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-2xl focus:outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(b,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,k.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,k.jsx)(_,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,k.jsx)(u,{className:`size-4`})})]}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,k.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:O.name}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O.extensionId})]}),(0,k.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`本次迭代`:`This iteration`}),(0,k.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-3 text-xs`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`文件变化`:`Changed files`}),(0,k.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:A?.changedFileCount??0})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`自动验收`:`Acceptance`}),(0,k.jsxs)(`dd`,{className:`mt-1 flex items-center gap-1.5 font-medium text-success`,children:[(0,k.jsx)(ee,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),A?.changedFiles.length?(0,k.jsx)(`ul`,{className:`mt-3 space-y-1`,children:A.changedFiles.slice(0,5).map(e=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,(0,k.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`请求权限`:`Requested permissions`}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-2`,children:(A?.permissions??O.permissions).map(e=>(0,k.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,k.jsx)(s,{className:`size-4 text-success`}),e,O.installationState===`installed`&&A?.permissionDelta.added.includes(e)?(0,k.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-[10px] text-warning`,children:n?`新增`:`New`}):null]},e))}),O.installationState===`installed`&&A?.permissionDelta.added.length?(0,k.jsx)(`p`,{className:`mt-4 rounded-xl bg-warning-soft p-3 text-xs leading-5 text-warning`,children:n?`此更新增加了权限,请确认这些能力符合你的修改意图。`:`This update adds permissions. Confirm they match the change you requested.`}):null,(0,k.jsx)(`p`,{className:`mt-5 rounded-xl bg-accent-soft p-3 text-xs leading-5 text-accent-fg`,children:n?`Phase 1 应用只能使用界面主题和本地存储,不能访问网络或运行系统命令。`:`Phase 1 apps can use theme and local storage only. They cannot access the network or run system commands.`})]}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,k.jsx)(_,{asChild:!0,children:(0,k.jsx)(d,{children:n?`取消`:`Cancel`})}),(0,k.jsxs)(d,{variant:`primary`,onClick:()=>void Et(),disabled:M,children:[M?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(c,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,k.jsx)(x,{open:$e,onOpenChange:et,children:(0,k.jsxs)(v,{children:[(0,k.jsx)(h,{className:`fixed inset-0 z-50 bg-black/45`}),(0,k.jsxs)(y,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(420px,calc(100vh-32px))] w-[min(500px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-2xl focus:outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(b,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,k.jsx)(g,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:n?`应用会从侧栏移除,但 Project、源码、版本历史和本地数据都会保留。`:`The app leaves the sidebar, while its Project, source, release history, and local data remain.`})]}),(0,k.jsx)(_,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,k.jsx)(u,{className:`size-4`})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,k.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-4`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:O.name}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`之后可从任意保留版本重新安装。`:`You can reinstall any retained release later.`})]})}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,k.jsx)(_,{asChild:!0,children:(0,k.jsx)(d,{children:n?`取消`:`Cancel`})}),(0,k.jsxs)(d,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void At(),disabled:M,children:[M?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(re,{className:`size-4`}),n?`卸载但保留 Project`:`Uninstall and keep Project`]})]})]})]})})]})}export{A as LocalAppWorkbenchPage};
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-DrNzI_0p.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-C73V7tJP.js","assets/preload-helper-zJ_50EbN.js","assets/Combination-14nmIgxH.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-DaxPZj9e.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-v-O3cOpk.js","assets/dist-BPoKqzeH.js","assets/chunk-KS7C4IRE-BaASWQor.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/locale-store-XDFAPNNu.js","assets/messages-B1HDp_j8.js","assets/cn-JdwAhgNB.js","assets/product-delivery-dUJgmBQZ.js","assets/schemas-zIBW3wiV.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-Y68dCxuc.css","assets/dist-DqPZM2MH.js","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/popover-select-DBrVS3tZ.js","assets/skeleton-BwbyijEw.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/settings-shell-layer-context-DCp6ykjQ.js","assets/circle-check-C23XjkUj.js","assets/cloud-C4-yfnnk.js","assets/copy-Dv6d4Dvw.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-off-DEAzt3g1.js","assets/eye-CABVeTq0.js","assets/globe-DSSGFWFn.js","assets/notes-api-BMhFpRmW.js","assets/loader-circle-CifKLtgG.js","assets/rotate-cw-LIg3Am9S.js","assets/search-DA7gz22f.js","assets/middleware-Pd0e8Igk.js","assets/files-DQjhZjr2.js","assets/tool-activity-R8V9l6nk.js","assets/button-CSEbl4zT.js","assets/registry-api-DeVvBsl4.js","assets/gateway-startup-retry-S6aB0hVI.js","assets/config-reload-event-Bjh2zoKp.js","assets/gateway-config-swr-DfMY-MLf.js","assets/models-hub-cache-Bngs8o1m.js","assets/oauth-api-B_pcOUfT.js","assets/electron-env-DH5wF8X8.js","assets/form-field-width-DJw_jULe.js","assets/interaction-BmQogeqz.js","assets/is-masked-secret-DOkL5b_X.js","assets/activity-store-DLfkwJzZ.js","assets/theme-store-5-XHH7F0.js","assets/index-C9rUND9-.css","assets/vendor-codemirror--gTq3YAI.js","assets/with-selector-aYPsXwdl.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-nDLmA_LF.js","assets/code-editor-D4_k-6QN.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{l as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./check-DUBLcKHA.js";import{n as s,r as c}from"./popover-select-DBrVS3tZ.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./copy-Dv6d4Dvw.js";import{t as d}from"./external-link-DjqjBmc3.js";import{t as f}from"./eye-CABVeTq0.js";import{D as p,O as m,S as h,T as g,_,b as v,c as y,d as b,f as x,g as S,h as C,i as w,j as T,k as E,l as D,m as O,n as k,o as A,p as j,r as M,s as N,u as P,v as F,w as I,x as L,y as ee}from"./notes-api-BMhFpRmW.js";import{t as R}from"./loader-circle-CifKLtgG.js";import{t as te}from"./plus-Q2yW6OE7.js";import{t as z}from"./search-DA7gz22f.js";import{t as B}from"./x-B_N4OPjy.js";import{t as V}from"./cn-JdwAhgNB.js";import{t as H}from"./button-CSEbl4zT.js";import{t as ne}from"./copy-to-clipboard-HOJ79TWv.js";import{t as U}from"./messages-B1HDp_j8.js";import{n as W,s as re}from"./locale-store-XDFAPNNu.js";import{i as ie}from"./theme-store-5-XHH7F0.js";import{t as ae}from"./skeleton-BwbyijEw.js";import{a as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./dist-BPoKqzeH.js";import{i as pe}from"./vendor-swr-BIWyz7Rc.js";import{$o as me,Aa as he,As as ge,Bo as _e,Es as G,Ho as ve,Hs as ye,Oc as be,On as K,Os as q,Rc as J,Rs as xe,Ss as Se,Ts as Y,Vo as Ce,Xo as we,a as X,ai as Te,ar as Ee,bl as De,c as Oe,cr as ke,dl as Ae,dr as je,ds as Me,ec as Ne,es as Pe,fr as Fe,ga as Ie,gl as Le,ir as Re,jc as ze,l as Be,lr as Ve,mr as He,ms as Ue,o as We,or as Ge,pc as Ke,pr as qe,qo as Je,s as Ye,sa as Xe,si as Ze,sr as Qe,ss as $e,uc as et,wl as tt,ws as nt,xl as rt,yl as it,zo as at}from"./index-C73V7tJP.js";var Z=n(),Q=e(t(),1),$=r(),ot=(0,Q.createContext)(null);function st(){let e=(0,Z.c)(1),t=(0,Q.useContext)(ot);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:ct},e[0]=t):t=e[0],t}return t}function ct(){}function lt(e){let t=(0,Z.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,o]=(0,Q.useState)(null),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{o({src:e,alt:t})},t[0]=s):s=t[0];let c=s,l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={openImage:c},t[1]=l):l=t[1];let u=l,d=a!==null,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{e||o(null)},t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(oe,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=V(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=m):m=t[4];let h=a?.alt||`Image preview`,g;t[5]===h?g=t[6]:(g=(0,$.jsx)(de,{className:`sr-only`,children:h}),t[5]=h,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(B,{className:`size-5`,"aria-hidden":!0}),t[7]=_):_=t[7];let v;t[8]===i?v=t[9]:(v=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:_})}),t[8]=i,t[9]=v);let y;t[10]===a?y=t[11]:(y=a?(0,$.jsx)(`img`,{src:a.src,alt:a.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=a,t[11]=y);let b;t[12]!==v||t[13]!==y||t[14]!==g?(b=(0,$.jsxs)(le,{children:[p,(0,$.jsxs)(ue,{className:m,"aria-describedby":void 0,children:[g,v,y]})]}),t[12]=v,t[13]=y,t[14]=g,t[15]=b):b=t[15];let x;t[16]!==b||t[17]!==d?(x=(0,$.jsx)(fe,{open:d,onOpenChange:f,children:b}),t[16]=b,t[17]=d,t[18]=x):x=t[18];let S;return t[19]!==n||t[20]!==x?(S=(0,$.jsxs)(ot.Provider,{value:u,children:[n,x]}),t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function ut(e){let t=(0,Z.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,o]=(0,Q.useState)(!1),s;t[0]!==r||t[1]!==n?(s=E(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s;if(a){let e;t[3]===i?e=t[4]:(e=V(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,i),t[3]=i,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(T,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,$.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>o(!0),t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=V(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=u);let d;return t[11]!==n||t[12]!==c||t[13]!==u?(d=(0,$.jsx)(g,{src:c,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:l,className:u}),t[11]=n,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}var dt=6e4,ft=36e5,pt=864e5;function mt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function ht(e,t,n){let r=t-e;if(r<dt)return n.justNow;if(r<ft){let e=Math.floor(r/dt);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=mt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(e>=i-pt)return n.yesterday+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(r<7*pt){let e=Math.floor(r/pt);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function gt(e,t,n){let r=mt(t);if(e>=r)return n.today;if(e>=r-pt)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(void 0,{month:`long`,day:`numeric`}):i.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function _t(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function vt(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function yt(e){let t=(0,Z.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=He(),f=He(xt),p=u===n&&d===r,m=p&&o,h=p&&s,g=p?c:0,_=p&&l>0?l:i??0,v=_>0?Math.min(g/_*100,100):0,y;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==f?(y=e=>{e.stopPropagation(),f(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=f,t[4]=y):y=t[4];let b=y,x;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==f?(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),f(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=f,t[9]=x):x=t[9];let S=x,C;t[10]===a?C=t[11]:(C=V(`flex items-center gap-2`,a),t[10]=a,t[11]=C);let w=m?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,T;t[12]===w?T=t[13]:(T=V(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,w),t[12]=w,t[13]=T);let E=m?`Pause`:`Play`,D;t[14]!==h||t[15]!==m?(D=h?(0,$.jsx)(R,{className:`size-3.5 animate-spin`}):m?(0,$.jsx)(q,{className:`size-3.5`}):(0,$.jsx)(Se,{className:`size-3.5 ml-0.5`}),t[14]=h,t[15]=m,t[16]=D):D=t[16];let O;t[17]!==b||t[18]!==S||t[19]!==T||t[20]!==E||t[21]!==D?(O=(0,$.jsx)(`button`,{type:`button`,onClick:b,onKeyDown:S,className:T,"aria-label":E,children:D}),t[17]=b,t[18]=S,t[19]=T,t[20]=E,t[21]=D,t[22]=O):O=t[22];let k=`${v}%`,A;t[23]===k?A=t[24]:(A=(0,$.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:k}})}),t[23]=k,t[24]=A);let j;t[25]!==_||t[26]!==p||t[27]!==g?(j=vt(p&&g>0?g:_),t[25]=_,t[26]=p,t[27]=g,t[28]=j):j=t[28];let M;t[29]===j?M=t[30]:(M=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:j}),t[29]=j,t[30]=M);let N;t[31]!==A||t[32]!==M?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[A,M]}),t[31]=A,t[32]=M,t[33]=N):N=t[33];let P;return t[34]!==N||t[35]!==C||t[36]!==O?(P=(0,$.jsxs)(`div`,{className:C,onClick:bt,children:[O,N]}),t[34]=N,t[35]=C,t[36]=O,t[37]=P):P=t[37],P}function bt(e){return e.stopPropagation()}function xt(e){return e.toggle}function St(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Ct(e){let t=(0,Z.c)(88),{note:n,selected:r,onPress:i,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=r===void 0?!1:r,d;t[0]!==c||t[1]!==n?(d=St(n,c),t[0]=c,t[1]=n,t[2]=d):d=t[2];let f=d,p=!n.snippet?.trim(),[m]=(0,Q.useState)(At),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=ht(n.createdAt,m,l),t[3]=n.createdAt,t[4]=m,t[5]=l,t[6]=h):h=t[6];let g=h,_,v;t[7]!==n.id||t[8]!==i?(_=()=>i(n.id),v=e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),i(n.id))},t[7]=n.id,t[8]=i,t[9]=_,t[10]=v):(_=t[9],v=t[10]);let y=u?`bg-surface-active hover:bg-surface-active`:`bg-transparent hover:bg-surface-panel/70`,b;t[11]===y?b=t[12]:(b=V(`group relative flex cursor-pointer flex-col gap-2 overflow-hidden rounded-lg px-3 py-2.5`,`transition-colors duration-150 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-rail`,y),t[11]=y,t[12]=b);let x=u?`true`:void 0,S;t[13]===u?S=t[14]:(S=u?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-y-2 left-0 w-0.5 rounded-r-pill bg-accent`,"aria-hidden":!0}):null,t[13]=u,t[14]=S);let C;t[15]!==n.coverAttachmentId||t[16]!==n.id||t[17]!==n.kind||t[18]!==n.voiceAttachmentId||t[19]!==n.voiceDurationSec?(C=n.coverAttachmentId?(0,$.jsx)(ut,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,$.jsx)(yt,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[15]=n.coverAttachmentId,t[16]=n.id,t[17]=n.kind,t[18]=n.voiceAttachmentId,t[19]=n.voiceDurationSec,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=n.title&&(0,$.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[21]=n.title,t[22]=w);let T=n.title?`text-fg-muted`:p?`italic text-fg-muted`:`text-fg`,E;t[23]===T?E=t[24]:(E=V(`truncate text-sm leading-5`,T),t[23]=T,t[24]=E);let D;t[25]!==f||t[26]!==E?(D=(0,$.jsx)(`p`,{className:E,children:f}),t[25]=f,t[26]=E,t[27]=D):D=t[27];let O;t[28]!==w||t[29]!==D?(O=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[28]=w,t[29]=D,t[30]=O):O=t[30];let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(ze,{className:`size-4`}),t[31]=k):k=t[31];let A;t[32]===c.actions?A=t[33]:(A=(0,$.jsx)(Ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:kt,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-100 transition-opacity hover:bg-surface-panel focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:opacity-0 lg:group-hover:opacity-100 lg:focus-visible:opacity-100`,"aria-label":c.actions,title:c.actions,children:k})}),t[32]=c.actions,t[33]=A);let j;t[34]!==n.id||t[35]!==n.pinned||t[36]!==a?(j=()=>{a(n.id,!n.pinned).catch(Dt)},t[34]=n.id,t[35]=n.pinned,t[36]=a,t[37]=j):j=t[37];let M;t[38]===n.pinned?M=t[39]:(M=n.pinned?(0,$.jsx)(nt,{className:`size-4`}):(0,$.jsx)(Y,{className:`size-4`}),t[38]=n.pinned,t[39]=M);let N=n.pinned?c.unpin:c.pin,P;t[40]!==j||t[41]!==M||t[42]!==N?(P=(0,$.jsxs)(Ee,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:j,children:[M,N]}),t[40]=j,t[41]=M,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==n.id||t[45]!==o?(F=()=>{o(n.id).catch(Et)},t[44]=n.id,t[45]=o,t[46]=F):F=t[46];let I;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(rt,{className:`size-4`}),t[47]=I):I=t[47];let L;t[48]!==c.archive||t[49]!==F?(L=(0,$.jsxs)(Ee,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:F,children:[I,c.archive]}),t[48]=c.archive,t[49]=F,t[50]=L):L=t[50];let ee;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ke,{className:`my-1 h-px bg-edge-subtle`}),t[51]=ee):ee=t[51];let R;t[52]!==n.id||t[53]!==s?(R=()=>{s(n.id).catch(Tt)},t[52]=n.id,t[53]=s,t[54]=R):R=t[54];let te;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(_e,{className:`size-4`}),t[55]=te):te=t[55];let z;t[56]!==c.delete||t[57]!==R?(z=(0,$.jsxs)(Ee,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:R,children:[te,c.delete]}),t[56]=c.delete,t[57]=R,t[58]=z):z=t[58];let B;t[59]!==P||t[60]!==L||t[61]!==z?(B=(0,$.jsx)(Ge,{children:(0,$.jsxs)(Re,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:Ot,children:[P,L,ee,z]})}),t[59]=P,t[60]=L,t[61]=z,t[62]=B):B=t[62];let H;t[63]!==A||t[64]!==B?(H=(0,$.jsxs)(Qe,{children:[A,B]}),t[63]=A,t[64]=B,t[65]=H):H=t[65];let ne;t[66]!==C||t[67]!==O||t[68]!==H?(ne=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,O,H]}),t[66]=C,t[67]=O,t[68]=H,t[69]=ne):ne=t[69];let U;t[70]===n.pinned?U=t[71]:(U=n.pinned&&(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,$.jsx)(Y,{className:`size-3`})}),t[70]=n.pinned,t[71]=U);let W;t[72]===n.tags?W=t[73]:(W=n.tags?.slice(0,2).map(wt),t[72]=n.tags,t[73]=W);let re;t[74]===g?re=t[75]:(re=(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[74]=g,t[75]=re);let ie;t[76]!==U||t[77]!==W||t[78]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[U,W,re]}),t[76]=U,t[77]=W,t[78]=re,t[79]=ie):ie=t[79];let ae;return t[80]!==ne||t[81]!==ie||t[82]!==_||t[83]!==v||t[84]!==b||t[85]!==x||t[86]!==S?(ae=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:v,className:b,"aria-current":x,children:[S,ne,ie]}),t[80]=ne,t[81]=ie,t[82]=_,t[83]=v,t[84]=b,t[85]=x,t[86]=S,t[87]=ae):ae=t[87],ae}function wt(e){return(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function Tt(){}function Et(){}function Dt(){}function Ot(e){return e.stopPropagation()}function kt(e){return e.stopPropagation()}function At(){return Date.now()}function jt(e){let t=(0,Z.c)(45),{title:n,description:r,prompt:i,coverage:o,className:s,variant:c}=e,u=c===void 0?`card`:c,d=W(Pt),f=U(d).automations.suggestions,p=U(d).automations,m=a(),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=h):h=t[0];let{data:g}=pe(o?`automation-suggestion-coverage`:null,Nt,h),_=o?g?.automations.find(e=>Oe(e,o)):void 0,v=_?We(_,p):[];if(u===`titleAction`){if(_){let e;t[1]===s?e=t[2]:(e=V(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,s),t[1]=s,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(l,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===m?r=t[5]:(r=()=>m(`/automations`),t[4]=m,t[5]=r),(0,$.jsxs)(`section`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:f.coveredTitle}),(0,$.jsx)(H,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:f.manage})]})}let e;t[6]===s?e=t[7]:(e=V(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,s),t[6]=s,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Ne,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let o;t[9]!==r||t[10]!==n?(o=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=o):o=t[11];let c;t[12]!==m||t[13]!==i?(c=()=>{m(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[12]=m,t[13]=i,t[14]=c):c=t[14];let u;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),t[15]=u):u=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,o,(0,$.jsxs)(H,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[u,f.setup]})]})}if(_){let e;t[16]===s?e=t[17]:(e=V(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,s),t[16]=s,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===m?r=t[20]:(r=()=>m(`/automations`),t[19]=m,t[20]=r);let i;return t[21]!==f||t[22]!==r?(i=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(H,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:f.manage})}),t[21]=f,t[22]=r,t[23]=i):i=t[23],(0,$.jsxs)(`section`,{className:e,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:f.coveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:Ye(f.coveredDescription,{name:_.name})})]})]}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:p.explain.whyCovered}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:v.map(Mt)})]}),i]})}let y;t[24]===s?y=t[25]:(y=V(`rounded-lg bg-surface-panel p-3 shadow-surface`,s),t[24]=s,t[25]=y);let b;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Ne,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=b):b=t[26];let x;t[27]===n?x=t[28]:(x=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=x);let S;t[29]===r?S=t[30]:(S=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=S);let C;t[31]!==x||t[32]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[b,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]})]}),t[31]=x,t[32]=S,t[33]=C):C=t[33];let w;t[34]!==m||t[35]!==i?(w=()=>{m(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[34]=m,t[35]=i,t[36]=w):w=t[36];let T;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),t[37]=T):T=t[37];let E;t[38]!==f.create||t[39]!==w?(E=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(H,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:w,children:[T,f.create]})}),t[38]=f.create,t[39]=w,t[40]=E):E=t[40];let D;return t[41]!==E||t[42]!==y||t[43]!==C?(D=(0,$.jsxs)(`section`,{className:y,children:[C,E]}),t[41]=E,t[42]=y,t[43]=C,t[44]=D):D=t[44],D}function Mt(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Nt(){return Be.list()}function Pt(e){return e.language}function Ft(e){let t=(0,Z.c)(4),{values:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(It),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:r}),t[2]=r,t[3]=i),i}function It(e,t){return(0,$.jsx)(`li`,{children:e},`${t}:${e}`)}function Lt(e){let t=(0,Z.c)(10),{noteId:n,attachmentId:r,label:i,unavailableLabel:a}=e,[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(!1),u,d;if(t[0]!==r||t[1]!==n?(u=()=>{let e=!1,t=!1;return s(null),l(!1),p(n,r).then(i=>{if(e=!0,t){m(n,r);return}s(i)}).catch(()=>{t||l(!0)}),()=>{t=!0,e&&m(n,r)}},d=[r,n],t[0]=r,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),(0,Q.useEffect)(u,d),c){let e;return t[4]===a?e=t[5]:(e=(0,$.jsx)(`p`,{className:`text-xs text-danger`,children:a}),t[4]=a,t[5]=e),e}if(!o){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ae,{className:`h-10 w-full max-w-md`}),t[6]=e):e=t[6],e}let f;return t[7]!==i||t[8]!==o?(f=(0,$.jsx)(`audio`,{controls:!0,preload:`metadata`,src:o,className:`w-full max-w-md`,"aria-label":i}),t[7]=i,t[8]=o,t[9]=f):f=t[9],f}function Rt(e){let t=(0,Z.c)(39),{noteId:n}=e,r=U(W(Vt)).notes.discussionCapture,i,a;t[0]===n?(i=t[1],a=t[2]):(i=[`note-discussion-document`,n],a=()=>K(n),t[0]=n,t[1]=i,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[3]=o):o=t[3];let{data:s,mutate:c}=pe(i,a,o),u,d;if(t[4]===c?(u=t[5],d=t[6]):(u=()=>{let e=e=>{let t=e.detail;t&&c(e=>{if(!e||e.discussion.id!==t.discussionId)return e;let n=e.transcript.segments.filter(e=>e.sequence!==t.segment.sequence).concat(t.segment).sort(Bt);return{...e,discussion:{...e.discussion,transcriptRevision:t.transcriptRevision},transcript:{...e.transcript,revision:t.transcriptRevision,segments:n,text:t.text,stats:t.stats}}},{revalidate:!1})},t=()=>void c();return window.addEventListener(`discussion-segment-updated`,e),window.addEventListener(`discussion-updated`,t),()=>{window.removeEventListener(`discussion-segment-updated`,e),window.removeEventListener(`discussion-updated`,t)}},d=[c],t[4]=c,t[5]=u,t[6]=d),(0,Q.useEffect)(u,d),!s)return null;let{discussion:f,transcript:p}=s,m=s.organization?.organization,h=[`stopping`,`sealing`,`organizing`].includes(f.status),g=p.stats.uploaded+p.stats.transcribing,_=p.stats.failed>0?r.failedSegments.replace(`{{count}}`,String(p.stats.failed)):g>0?r.processingSegments.replace(`{{count}}`,String(g)):h?r.finalizing:f.status===`completed`?r.transcriptReady:null,v;t[7]!==r.actionItems||t[8]!==r.decisions||t[9]!==r.openQuestions||t[10]!==r.organization||t[11]!==r.risks||t[12]!==m?(v=m?(0,$.jsxs)(`section`,{className:`border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-accent-fg`,children:[(0,$.jsx)(Pe,{className:`size-4`,"aria-hidden":!0}),r.organization]}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:m.summary}),(0,$.jsxs)(`div`,{className:`mt-4 grid gap-4 text-sm leading-6 text-fg sm:grid-cols-2 xl:grid-cols-1`,children:[m.decisions.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:r.decisions}),(0,$.jsx)(Ft,{values:m.decisions})]}):null,m.actionItems.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:r.actionItems}),(0,$.jsx)(Ft,{values:m.actionItems.map(zt)})]}):null,m.risks.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:r.risks}),(0,$.jsx)(Ft,{values:m.risks})]}):null,m.openQuestions.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:r.openQuestions}),(0,$.jsx)(Ft,{values:m.openQuestions})]}):null]})]}):null,t[7]=r.actionItems,t[8]=r.decisions,t[9]=r.openQuestions,t[10]=r.organization,t[11]=r.risks,t[12]=m,t[13]=v):v=t[13];let y;t[14]!==r.recordingAudio||t[15]!==r.recordingUnavailable||t[16]!==f.audioAttachmentId||t[17]!==n?(y=f.audioAttachmentId?(0,$.jsxs)(`section`,{className:`border-b border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(xe,{className:`size-4 text-accent`,"aria-hidden":!0}),r.recordingAudio]}),(0,$.jsx)(Lt,{noteId:n,attachmentId:f.audioAttachmentId,label:r.recordingAudio,unavailableLabel:r.recordingUnavailable})]}):null,t[14]=r.recordingAudio,t[15]=r.recordingUnavailable,t[16]=f.audioAttachmentId,t[17]=n,t[18]=y):y=t[18];let b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(xe,{className:`size-4 text-accent`,"aria-hidden":!0}),t[19]=b):b=t[19];let x=f.status===`recording`?r.draftTranscript:r.fullTranscript,S;t[20]===x?S=t[21]:(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[b,x]}),t[20]=x,t[21]=S);let C;t[22]===f.status?C=t[23]:(C=f.status===`needs_attention`?(0,$.jsx)(at,{className:`size-3.5 text-danger`}):f.status===`completed`?(0,$.jsx)(l,{className:`size-3.5 text-success`}):null,t[22]=f.status,t[23]=C);let w=f.status===`needs_attention`?f.failureMessage:_,T;t[24]!==C||t[25]!==w?(T=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[C,w]}),t[24]=C,t[25]=w,t[26]=T):T=t[26];let E;t[27]!==S||t[28]!==T?(E=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[S,T]}),t[27]=S,t[28]=T,t[29]=E):E=t[29];let D=p.text||r.waitingTranscript,O;t[30]===D?O=t[31]:(O=(0,$.jsx)(`div`,{className:`mt-3 max-h-48 overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-fg-muted xl:max-h-none xl:overflow-visible`,children:D}),t[30]=D,t[31]=O);let k;t[32]!==E||t[33]!==O?(k=(0,$.jsxs)(`section`,{className:`px-6 py-4`,children:[E,O]}),t[32]=E,t[33]=O,t[34]=k):k=t[34];let A;return t[35]!==k||t[36]!==v||t[37]!==y?(A=(0,$.jsxs)(`aside`,{className:`max-h-[45%] shrink-0 overflow-y-auto border-b border-edge-subtle xl:h-full xl:max-h-none xl:w-[clamp(20rem,34%,27rem)] xl:border-r xl:border-b-0`,children:[v,y,k]}),t[35]=k,t[36]=v,t[37]=y,t[38]=A):A=t[38],A}function zt(e){return e.title}function Bt(e,t){return e.sequence-t.sequence}function Vt(e){return e.language}var Ht={edit:G,ai_edit:Pe,sync:Ue,restore:De};function Ut(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function Wt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=U(W(e=>e.language)).notes,o=a,{data:s}=pe(e?[`note-history`,e]:null,()=>P(e)),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),m=(0,Q.useCallback)(async t=>{l(!0),p(null);try{await L(e,t),d(null),i()}catch{p(a.restoreFailed)}finally{l(!1)}},[e,a.restoreSuccess,a.restoreFailed,i]),h=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),a.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:f}):null,s?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:s.map(e=>{let r=Ht[e.trigger]??G,i=t===e.timestamp,s=u===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:V(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:Ut(e.trigger,a)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:ht(e.timestamp,h,o)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:a.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),m(e.timestamp)},disabled:c,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:c?`...`:a.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:a.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:a.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:a.historyEmptyDescription})]})]})]})}function Gt({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:o,openingChat:s,onOpenChat:c,onOpenNewChat:l}){let u=U(W(e=>e.language)).notes,d=a(),f=t?.aiDeep?.catalysis,p=f?.report??null,[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),{data:v,mutate:b,isLoading:x}=pe(e?[`note-agent-context-status`,e]:null,()=>y(e),{revalidateOnFocus:!1}),S=(0,Q.useCallback)(async()=>{if(!g){_(!0),h(null);try{await b(()=>F(e),{revalidate:!1})}catch(e){h(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{_(!1)}}},[g,b,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),C=(0,Q.useCallback)(async t=>{try{await ee(e,t)}catch{}},[e]);return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Pe,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(it,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),v?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void S(),disabled:x||g,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:g?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:V(`rounded-full px-2 py-0.5 text-[11px] font-medium`,v.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:v.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:v.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(v.attachments.length)).replace(`{{tokens}}`,String(v.tokenEstimate??0))}),m?(0,$.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:m}):null,v.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:v.attachments.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:p?u.recatalyze:u.catalyzeAction}),p?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:p.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.targetUsers.slice(0,5).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.keyQuestions.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.mvpPath.slice(0,3).map((e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.risks.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.nextActions.slice(0,4).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(p.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void C(`helpful`),className:V(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void C(`not_helpful`),className:V(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(ye,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:s,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:s?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:s,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),o.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:o.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var Kt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function qt({open:e,onOpenChange:t,note:n}){let r=W(e=>e.language)===`zh`,i=r?Xt:Zt,{data:a,mutate:l}=pe(e?[`note-shares`,n.id]:null,()=>b(n.id)),[f,p]=(0,Q.useState)(new Set),[m,h]=(0,Q.useState)(`86400000`),[g,_]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),N=(0,Q.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Q.useEffect)(()=>{e&&(p(new Set(N.map(e=>e.id))),O(null),A(!1),M(null))},[e,N]);let P=async()=>{C(!0),M(null);try{O((await w(n.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...f],ttlMs:Number(m),maxViews:g.trim()?Number(g):null,description:y.trim()||void 0})).payload.shareUrl),await l()}catch(e){M(e instanceof Error?e.message:String(e))}finally{C(!1)}},F=async(e,t)=>{E(e.id),M(null);try{t===`refresh`?await v(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...f]}):t===`extend`?await Te(e.id,864e5):await Ze(e.id),await l()}catch(e){M(e instanceof Error?e.message:String(e))}finally{E(null)}},I=async e=>{M(null);try{if(!await ne(e)){A(!1),M(i.copyFailed);return}A(!0),window.setTimeout(()=>A(!1),1500)}catch{A(!1),M(i.copyFailed)}};return(0,$.jsx)(fe,{open:e,onOpenChange:t,children:(0,$.jsxs)(le,{children:[(0,$.jsx)(oe,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(ue,{className:`fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(de,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)($e,{className:`size-4`}),i.title]}),(0,$.jsx)(se,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,$.jsx)(B,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-subtle p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),N.length>0?(0,$.jsxs)(`section`,{className:`mt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:N.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:f.has(e.id),onChange:()=>p(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),className:`accent-accent`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Yt(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,$.jsx)(s,{value:m,onChange:e=>h(e.target.value),children:Kt.map(e=>(0,$.jsx)(c,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,$.jsx)(`input`,{type:`number`,min:1,max:1e3,value:g,onChange:e=>_(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,$.jsx)(`input`,{value:y,onChange:e=>x(e.target.value),className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]})]}),D?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{readOnly:!0,value:D,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(H,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void I(D),children:[k?(0,$.jsx)(o,{className:`size-4`}):(0,$.jsx)(u,{className:`size-4`}),k?i.copied:i.copy]}),(0,$.jsxs)(H,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(D,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(d,{className:`size-4`}),i.open]})]})}):null,j?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:j}):null,(a?.items.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,$.jsx)(Jt,{share:e,busy:T===e.id,t:i,onCopy:I,onAction:F},e.id))})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(H,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(H,{type:`button`,onClick:()=>void P(),disabled:S,children:[S?(0,$.jsx)(R,{className:`size-4 animate-spin`}):(0,$.jsx)($e,{className:`size-4`}),S?i.creating:i.create]})]})]})]})})}function Jt(e){let t=(0,Z.c)(68),{share:n,busy:r,t:i,onCopy:a,onAction:o}=e,s=n.revoked||n.expired,c=s&&`opacity-60`,l;t[0]===c?l=t[1]:(l=V(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let f=n.stale&&!s?i.stale:s?i.inactive:i.active,p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{children:f}),t[2]=f,t[3]=p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{children:`·`}),t[4]=m):m=t[4];let h=n.maxViews===null?``:` / ${n.maxViews}`,g;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==h?(g=(0,$.jsxs)(`span`,{children:[i.views,` `,n.viewCount,h]}),t[5]=n.viewCount,t[6]=i.views,t[7]=h,t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{children:`·`}),t[9]=_):_=t[9];let v;t[10]===n.expiresAt?v=t[11]:(v=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=v);let y;t[12]===v?y=t[13]:(y=(0,$.jsx)(`span`,{children:v}),t[12]=v,t[13]=y);let b;t[14]!==y||t[15]!==p||t[16]!==g?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,g,_,y]}),t[14]=y,t[15]=p,t[16]=g,t[17]=b):b=t[17];let x;t[18]===n.shareUrl?x=t[19]:(x=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=x);let S;t[20]!==b||t[21]!==x?(S=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[b,x]}),t[20]=b,t[21]=x,t[22]=S):S=t[22];let C;t[23]===r?C=t[24]:(C=r?(0,$.jsx)(R,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=C);let w;t[25]!==S||t[26]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,C]}),t[25]=S,t[26]=C,t[27]=w):w=t[27];let T;t[28]!==a||t[29]!==n.shareUrl?(T=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=T):T=t[30];let E;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(u,{className:`size-3.5`}),t[31]=E):E=t[31];let D;t[32]!==i.copy||t[33]!==T?(D=(0,$.jsxs)(H,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:T,children:[E,i.copy]}),t[32]=i.copy,t[33]=T,t[34]=D):D=t[34];let O;t[35]===n.shareUrl?O=t[36]:(O=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=O);let k;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(d,{className:`size-3.5`}),t[37]=k):k=t[37];let A;t[38]!==i.open||t[39]!==O?(A=(0,$.jsxs)(H,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:O,children:[k,i.open]}),t[38]=i.open,t[39]=O,t[40]=A):A=t[40];let j;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(j=n.stale&&!s?(0,$.jsxs)(H,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(Ue,{className:`size-3.5`}),i.refresh]}):null,t[41]=r,t[42]=s,t[43]=o,t[44]=n,t[45]=i.refresh,t[46]=j):j=t[46];let M;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(M=s?null:(0,$.jsx)(H,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`extend`),children:i.extend}),t[47]=r,t[48]=s,t[49]=o,t[50]=n,t[51]=i.extend,t[52]=M):M=t[52];let N;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(N=n.revoked?null:(0,$.jsxs)(H,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(_e,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=N):N=t[57];let P;t[58]!==D||t[59]!==A||t[60]!==j||t[61]!==M||t[62]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[D,A,j,M,N]}),t[58]=D,t[59]=A,t[60]=j,t[61]=M,t[62]=N,t[63]=P):P=t[63];let F;return t[64]!==w||t[65]!==l||t[66]!==P?(F=(0,$.jsxs)(`div`,{className:l,children:[w,P]}),t[64]=w,t[65]=l,t[66]=P,t[67]=F):F=t[67],F}function Yt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Xt={title:`分享笔记`,description:`创建一个无需登录即可查看的只读快照。`,close:`关闭`,untitled:`无标题笔记`,empty:`空笔记`,privateExcluded:`不会分享标签、AI 元数据、项目、讨论、历史版本或未引用附件。`,attachments:`包含的附件`,expires:`有效期`,maxViews:`最多查看次数`,unlimited:`不限`,publicDescription:`公开说明(可选)`,create:`创建分享链接`,creating:`创建中…`,copy:`复制`,copied:`已复制`,open:`打开`,activeLinks:`这条笔记的分享`,copyFailed:`无法复制到剪贴板,请手动选择链接并复制。`,stale:`旧版本`,inactive:`已失效`,active:`有效`,views:`查看`,refresh:`更新快照`,extend:`延长 24 小时`,revoke:`撤销`},Zt={title:`Share Note`,description:`Create a read-only snapshot that opens without sign-in.`,close:`Close`,untitled:`Untitled Note`,empty:`Empty Note`,privateExcluded:`Tags, AI metadata, projects, discussions, history, and unreferenced attachments are excluded.`,attachments:`Included attachments`,expires:`Expires`,maxViews:`Maximum views`,unlimited:`Unlimited`,publicDescription:`Public description (optional)`,create:`Create share link`,creating:`Creating…`,copy:`Copy`,copied:`Copied`,open:`Open`,activeLinks:`Shares for this Note`,copyFailed:`Could not copy to the clipboard. Select the link and copy it manually.`,stale:`Older version`,inactive:`Inactive`,active:`Active`,views:`Views`,refresh:`Update snapshot`,extend:`Extend 24 hours`,revoke:`Revoke`},Qt=()=>i(()=>import(`./block-editor-DrNzI_0p.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61])),$t=()=>i(()=>import(`./markdown-editor-nDLmA_LF.js`),__vite__mapDeps([62,1,3,59,5,63])),en=(0,Q.lazy)(()=>Qt().then(e=>({default:e.BlockEditor}))),tn=(0,Q.lazy)(()=>$t().then(e=>({default:e.MarkdownEditor})));function nn(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function rn(e){let t=(0,Z.c)(14),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:be},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:J},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:f},t[4]=i.preview,t[5]=s);let c;t[6]!==a||t[7]!==o||t[8]!==s?(c=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9];let l=c,u;return t[10]!==n||t[11]!==l||t[12]!==r?(u=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&Qt(),t===`source`&&$t()},onFocus:()=>{t===`wysiwyg`&&Qt(),t===`source`&&$t()},className:V(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,$.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=l,t[12]=r,t[13]=u):u=t[13],u}function an(e){let t=(0,Z.c)(15),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,onAutoFocusConsumed:u}=e,d=a===void 0?!0:a,f=s===void 0?!0:s,p=l===void 0?!1:l,m=W(on),h;t[0]===m?h=t[1]:(h=U(m),t[0]=m,t[1]=h);let g=h.notes.lightboxClose,_;t[2]!==p||t[3]!==o||t[4]!==f||t[5]!==n||t[6]!==u||t[7]!==r||t[8]!==c||t[9]!==i||t[10]!==d?(_=(0,$.jsx)(sn,{noteId:n,onBack:r,onSaved:i,showBackButton:d,backButtonClassName:o,clearHeaderOnCleanup:f,onOpenSearch:c,autoFocus:p,onAutoFocusConsumed:u}),t[2]=p,t[3]=o,t[4]=f,t[5]=n,t[6]=u,t[7]=r,t[8]=c,t[9]=i,t[10]=d,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,$.jsx)(lt,{closeLabel:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function on(e){return e.language}function sn({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:o=!0,onOpenSearch:s,autoFocus:c=!1,onAutoFocusConsumed:l}){let u=W(e=>e.language),d=U(u).notes,f=U(u).automations.suggestions,p=a(),m=ie(e=>e.resolved)===`dark`,{openImage:g}=st(),[_,v]=(0,Q.useState)(`wysiwyg`),[y,b]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[E,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(360),[P,F]=(0,Q.useState)(!1),[L,ee]=(0,Q.useState)(!1),[R,te]=(0,Q.useState)(!1),[B,H]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(null),se=(0,Q.useRef)(!1),ce=(0,Q.useRef)(!1),le=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),G=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),be=he(e=>e.setPageHeader),K=he(e=>e.clearPageHeader),{data:q,mutate:J}=pe(e?[`note-detail`,e]:null,()=>N(e)),{data:xe=[],mutate:Se}=pe(e?[`note-threads`,e]:null,()=>x(e),{revalidateOnFocus:!1}),Y=S!==null,Ce=(0,Q.useCallback)(e=>{H(`${d.refreshFailed}: ${e instanceof Error?e.message:d.quickCaptureFailedHint}`)},[d.quickCaptureFailedHint,d.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&J().catch(Ce)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[J,e,Ce]),(0,Q.useEffect)(()=>{se.current=!1,A(``),C(null),b(null),ce.current=!1,ve.current=null},[e]),(0,Q.useEffect)(()=>{!q||se.current||(A(q.title??``),se.current=!0)},[q]),(0,Q.useEffect)(()=>{if(!c||!q||Y||ve.current===e)return;let t=window.requestAnimationFrame(()=>{G.current?.focus(),l?.()});return ve.current=e,()=>window.cancelAnimationFrame(t)},[c,Y,q,e,l]);let we=q?new Date(q.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,Te=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":d.back,className:V(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,tt,i),children:(0,$.jsx)(it,{className:`size-4`,"aria-hidden":!0})}):null,[i,d.back,t,r]),Ee=(0,Q.useCallback)(t=>{A(t),e&&(fe.current=t,ue.current&&clearTimeout(ue.current),ue.current=setTimeout(async()=>{let t=fe.current;if(fe.current=null,t!==null){T(!0);try{await h(e,{title:t}),await J(),n?.()}catch{}finally{T(!1)}}},600))},[e,J,n]),De=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:V(`flex min-w-0 items-center gap-2`,tt),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:E||we||void 0,children:E||we}),w?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:d.saving}):null]}),[d.saving,w,we,E]),Oe=(0,Q.useCallback)(async(t=!1)=>{te(!0),H(null);try{let n=await O(e,{forceNew:t});await J(),await Se(),p(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){H(`${d.chatOpenFailedTitle}: ${e instanceof Error?e.message:d.chatOpenFailedMessage}`)}finally{te(!1)}},[J,Se,p,e,d.chatOpenFailedMessage,d.chatOpenFailedTitle]),ke=(0,Q.useCallback)(async()=>{ee(!0),H(null);try{await k(e),await J()}catch(e){H(`${d.catalysisFailed}: ${e instanceof Error?e.message:d.chatOpenFailedMessage}`)}finally{ee(!1)}},[J,e]),Ae=(0,Q.useCallback)(()=>{b(y===`breakdown`?null:`breakdown`),!q?.aiDeep?.catalysis?.report&&!L&&ke()},[y,L,ke,q?.aiDeep?.catalysis?.report]),Me=(0,Q.useCallback)(()=>{let t=S?.markdown??de.current??q?.markdown??``,n=S?.title??E,r=Fe([n,t].filter(Boolean).join(`
3
-
4
- `));return{source:{type:`note`,id:e,title:n||d.titlePlaceholder},text:r,language:qe(r,u)}},[u,d.titlePlaceholder,q?.markdown,e,S,E]),Ne=(0,Q.useCallback)(async()=>{le.current&&clearTimeout(le.current),ue.current&&clearTimeout(ue.current),le.current=null,ue.current=null;let t=de.current,r=fe.current;de.current=null,fe.current=null;let i={};if(t!==null&&(i.markdown=t),r!==null&&(i.title=r),Object.keys(i).length===0)return q??null;T(!0);try{let t=await h(e,i);return await J(t,{revalidate:!1}),n?.(),t}catch(e){return H(`${d.saveFailed}: ${e instanceof Error?e.message:d.saveFailedHint}`),null}finally{T(!1)}},[J,d.saveFailed,d.saveFailedHint,q,e,n]),Ie=(0,Q.useCallback)(async()=>{H(null);let e=await Ne();e&&(oe(e),re(!0))},[Ne]),Le=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:V(`flex items-center gap-2`,tt),children:[s?(0,$.jsx)(`button`,{type:`button`,onClick:s,"aria-label":d.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(je,{input:Me,labels:{read:d.readAloud,preparing:d.readAloudPreparing,pause:d.readAloudPause,resume:d.readAloudResume,retry:d.readAloudRetry},showLabel:!0}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Ie(),className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:[(0,$.jsx)($e,{className:`size-3.5`,"aria-hidden":!0}),u===`zh`?`分享`:`Share`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:Ae,disabled:L,"aria-label":d.catalysisSectionTitle,className:V(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,y===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),L?d.catalyzing:d.catalyzeButton]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Oe(!1),disabled:R,className:V(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0}),R?d.openingChat:d.openChatButton]}),(0,$.jsx)(rn,{mode:_,onModeChange:v,labels:{edit:d.modeEdit,source:d.modeSource,preview:d.modePreview}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(y===`history`?null:`history`),"aria-label":d.history,className:V(`rounded-lg p-1.5 transition-colors`,y===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0})})]}),[L,Ae,Oe,_,d.history,d.modeEdit,d.modePreview,d.modeSource,R,y,s,d.searchDialogTitle,d.readAloud,d.readAloudPause,d.readAloudPreparing,d.readAloudResume,d.readAloudRetry,Me,Ie,u]);(0,Q.useLayoutEffect)(()=>(be({startExtra:Te,main:q?De:null,end:q?Le:null}),()=>{o&&K()}),[o,K,Le,De,Te,q,be]);let Re=(0,Q.useCallback)(t=>{e&&(de.current=t,le.current&&clearTimeout(le.current),le.current=setTimeout(async()=>{let t=de.current;if(de.current=null,t!==null){T(!0),H(null);try{await h(e,{markdown:t}),await J(),n?.()}catch(e){H(`${d.saveFailed}: ${e instanceof Error?e.message:d.saveFailedHint}`)}finally{T(!1)}}},600))},[e,J,d.saveFailed,d.saveFailedHint,n]),ze=(0,Q.useCallback)(t=>{D(e,t.timestamp).then(e=>{e&&C(e)})},[e]),Be=(0,Q.useCallback)(()=>{b(null),C(null)},[]),Ve=(0,Q.useCallback)(()=>{b(null),C(null),J().catch(Ce),n?.()},[J,n,Ce]);if((0,Q.useEffect)(()=>()=>{le.current&&clearTimeout(le.current),ue.current&&clearTimeout(ue.current);let t=de.current,n=fe.current;de.current=null,fe.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&h(e,r).catch(()=>void 0)},[e]),q===void 0)return(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,$.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(q===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:d.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:d.back})]});let He=Y?S.title??``:E,Ue=Y?S.markdown??``:q.markdown??``,We=new Date(q.createdAt).getTime(),Ge=Number.isFinite(We)&&Date.now()-We<3600*1e3?(0,$.jsx)(jt,{title:f.noteCreatedTitle,description:f.noteCreatedDescription,prompt:f.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-0 min-w-0 w-full max-w-[60rem] flex-1 flex-col`,children:[B?(0,$.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:B}):null,(0,$.jsx)(X,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(X,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsxs)(`div`,{ref:me,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[(0,$.jsx)(Rt,{noteId:e}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:Y?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[He&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:He}),Ue?(0,$.jsx)(I,{noteId:e,content:Ue,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:d.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[_===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:G,type:`text`,value:E,onChange:e=>Ee(e.target.value),onCompositionStart:()=>{ce.current=!0},onCompositionEnd:()=>{ce.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!ce.current&&!t.isComposing&&(e.preventDefault(),(me.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:d.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ge]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(nn,{}),children:(0,$.jsx)(en,{initialContent:q.markdown??``,onChange:Re,noteId:e},`wysiwyg-${e}`)})})]}),_===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:G,type:`text`,value:E,onChange:e=>Ee(e.target.value),placeholder:d.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ge]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(nn,{}),children:(0,$.jsx)(tn,{initialContent:q.markdown??``,onChange:Re,isDark:m},`source-${e}`)})})]}),_===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&g(t.currentSrc||t.src,t.alt)},children:[E&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:E}),q.markdown?(0,$.jsx)(I,{noteId:e,content:q.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:d.emptyPreview})]})]})})]})]}),(0,$.jsx)(`div`,{ref:ge,className:V(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!P&&`transition-[width] duration-300 ease-in-out`),style:{width:y?j:0},children:(0,$.jsxs)(`div`,{ref:_e,className:`flex min-h-0 flex-1 flex-col`,style:{width:j},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),F(!0);let n=e.clientX,r=j,i=e.pointerId,a=0,o=j,s=j,c=()=>{a=0,s=o,y&&ge.current?.style.setProperty(`width`,`${s}px`),_e.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}F(!1),M(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:V(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,P&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:y===`history`?(0,$.jsx)(Wt,{noteId:e,activeTimestamp:S?.timestamp??null,onSelect:ze,onClose:Be,onRestored:Ve}):y===`breakdown`?(0,$.jsx)(Gt,{noteId:e,note:q??null,catalyzing:L,onCatalyze:ke,onClose:()=>b(null),noteThreads:xe,openingChat:R,onOpenChat:()=>Oe(!1),onOpenNewChat:()=>Oe(!0)}):null})]})})]}),ae?(0,$.jsx)(qt,{open:ne,onOpenChange:re,note:ae}):null]})}var cn=3e4;function ln(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function un({placeholder:e,submitLabel:t,actionsLabel:n,imageLabel:r,voiceLabel:i,stopRecordingLabel:a,onCapture:o,onImagePick:s,onVoiceCapture:c,onVoiceError:l,recordingLabel:u,imageDisabled:d=!1,voiceDisabled:f=!1,onDiscussionCapture:p,discussionCaptureLabel:m}){let[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(0),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useRef)([]),k=(0,Q.useRef)(0),A=(0,Q.useRef)(null),j=(0,Q.useRef)(null),M=(0,Q.useCallback)(()=>{A.current&&=(clearInterval(A.current),null),j.current&&=(clearTimeout(j.current),null),D.current?.getTracks().forEach(e=>e.stop()),D.current=null,E.current=null,O.current=[],b(!1),S(0)},[]);(0,Q.useEffect)(()=>()=>M(),[M]);let N=(0,Q.useCallback)(async()=>{let e=E.current;if(!e||e.state!==`recording`)return;w(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-k.current)/1e3)),n=e.mimeType||ln()||`audio/webm`,r=new Blob(O.current,{type:n});if(M(),r.size>0&&c){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await c(i,t)}finally{w(!1)}return}w(!1)},[M,c]),P=(0,Q.useCallback)(async()=>{if(!(!c||C||y)){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){l?.();return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});D.current=e;let t=ln(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);E.current=n,O.current=[],k.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&O.current.push(e.data)},n.start(),b(!0),S(0),A.current=setInterval(()=>{S(Math.round((Date.now()-k.current)/1e3))},250),j.current=setTimeout(()=>{N()},cn)}catch{M(),l?.()}}},[M,c,l,y,N,C]),F=(0,Q.useCallback)(async()=>{let e=h.trim();if(!(!e||_)){v(!0),g(``);try{await o(e)}catch{g(e)}finally{v(!1),T.current?.focus()}}},[h,_,o]),I=(0,Q.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),F())},[F]),L=_||C,ee=!!(s||c||p);return(0,$.jsxs)(`div`,{className:V(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel p-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,y&&`border-danger ring-1 ring-danger/40`),"aria-busy":L,children:[y?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:C,className:`shrink-0 rounded-lg bg-danger-soft p-2 text-danger transition-colors hover:bg-danger-soft disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":a,title:a,"aria-pressed":`true`,children:(0,$.jsx)(we,{className:`size-4 fill-current`,"aria-hidden":!0})}):ee?(0,$.jsxs)(Qe,{children:[(0,$.jsx)(Ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:L,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":n,title:n,children:(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(Ge,{children:(0,$.jsxs)(Re,{side:`top`,align:`start`,sideOffset:8,className:`z-50 min-w-44 rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,children:[s?(0,$.jsxs)(Ee,{disabled:d,onSelect:s,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(et,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),r]}):null,c?(0,$.jsxs)(Ee,{disabled:f,onSelect:()=>void P(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(xe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,p?(0,$.jsxs)(Ee,{onSelect:p,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(Le,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),m]}):null]})})]}):null,y?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:u.replace(`{{seconds}}`,String(x))}):(0,$.jsx)(`textarea`,{ref:T,value:h,onChange:e=>g(e.target.value),onKeyDown:I,placeholder:e,"aria-label":e,rows:1,disabled:L,className:`max-h-28 min-h-8 flex-1 resize-none overflow-y-auto bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,$.jsx)(`button`,{type:`button`,disabled:!h.trim()||L||y,onClick:()=>void F(),"aria-label":t,title:t,className:V(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,h.trim()&&!L&&!y?`bg-accent text-white hover:bg-accent-hover`:`text-fg-disabled`),children:(0,$.jsx)(Me,{className:`size-4`,"aria-hidden":!0})})]})}var dn={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},fn=240,pn=320,mn=520,hn=560;function gn(e){if(globalThis.localStorage===void 0)return pn;try{let t=globalThis.localStorage.getItem(e);if(!t)return pn;let n=Number(t);return Number.isFinite(n)?n:pn}catch{return pn}}function _n(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var vn={thought:Je,todo:me,voice:xe,media:et,bookmark:Ae,mixed:Je,task:me};function yn(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function bn(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function xn(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function Sn({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:i=!0,projectId:o,listTitle:l,listDescription:u,emptyText:d,emptyDescription:f,listWidthStorageKey:p=`xopc.notes.listWidth`}){let m=U(W(e=>e.language)).notes,g=!!re(e=>e.token),[v,y]=(0,Q.useReducer)(Xe,dn),[b,x]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(0),[O,k]=(0,Q.useState)(()=>gn(p)),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,ee]=(0,Q.useState)(!1),[R,H]=(0,Q.useState)(null),[ne,ie]=(0,Q.useState)(null),ae=(0,Q.useRef)(null),me=(0,Q.useRef)(null),[_e]=(0,Q.useState)(()=>Date.now()),G=a(),ve=(0,Q.useCallback)(e=>{let t=ae.current?.clientWidth??window.innerWidth,n=Math.max(fn,t-hn);return Math.max(fn,Math.min(Math.min(mn,n),e))},[]),ye=(0,Q.useCallback)(e=>{let t=ve(e);k(t),_n(p,t)},[ve,p]);(0,Q.useLayoutEffect)(()=>{k(e=>ve(e))},[ve]);let{data:be,mutate:K,isLoading:q}=pe((0,Q.useMemo)(()=>g?[`notes-list`,o,v.statusFilter,v.kindFilter,v.pinnedOnly]:null,[g,o,v.statusFilter,v.kindFilter,v.pinnedOnly]),()=>j({status:v.statusFilter===`all`?void 0:v.statusFilter,kind:v.kindFilter===`all`?void 0:v.kindFilter,projectId:o,pinned:v.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),J=q&&!be,xe=be?.items??[],Se=be?.total??0,Y=w.trim(),{data:Ce,isLoading:we}=pe(g&&b&&Y?[`notes-search`,o,Y]:null,()=>j({search:Y,projectId:o,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),X=Ce?.items??[],Te=e?xe.some(t=>t.id===e):!0;(0,Q.useEffect)(()=>{D(0)},[Y]),(0,Q.useEffect)(()=>{E>=X.length&&D(Math.max(0,X.length-1))},[E,X.length]),(0,Q.useEffect)(()=>{let e=()=>{K().catch(e=>{H(`${m.refreshFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)})};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[K,m.quickCaptureFailedHint,m.refreshFailed]);let Ee=he(e=>e.setPageHeader),De=he(e=>e.clearPageHeader),Oe=m.noteCount.replace(`{{count}}`,String(Se)),ke=!r&&Se===0&&u?u:Oe,Ae=m.searchDialogTitle,je=m.searchClose,Me=m.searchClear,Ne=(0,Q.useMemo)(()=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),className:V(`inline-flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,tt),"aria-label":Ae,children:[(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:Ae})]}),[Ae]);(0,Q.useLayoutEffect)(()=>{if(n)return g?(Ee({startExtra:null,main:(0,$.jsxs)(`div`,{className:V(`flex min-w-0 items-center gap-2`,tt),children:[(0,$.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:l??m.title}),Oe?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Oe}):null]}),end:Ne}),()=>De()):(De(),()=>De())},[De,g,Ne,l,n,m.title,Oe,e,Ee]);let Pe=(0,Q.useMemo)(()=>({justNow:m.justNow,minutesAgo:m.minutesAgo,today:m.today,yesterday:m.yesterday,daysAgo:m.daysAgo}),[m.justNow,m.minutesAgo,m.today,m.yesterday,m.daysAgo]),Fe=(0,Q.useMemo)(()=>[{id:`recent`,label:m.viewRecent,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:m.filterInbox,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:m.pinned,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:m.viewTasks,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:m.kindVoice,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:m.kindMedia,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:m.kindBookmark,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:m.filterProcessed,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:m.filterArchived,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[m.filterArchived,m.filterInbox,m.filterProcessed,m.kindBookmark,m.kindMedia,m.kindVoice,m.pinned,m.viewRecent,m.viewTasks]),Le=Fe.find(e=>bn(v,e))??Fe[0],Re=l??Le.label,ze=(0,Q.useCallback)(async e=>{H(null);try{let n=o?await M({markdown:e,kind:`thought`,projectId:o,channel:`web`}):await C(e,`web`);await K(),G(xn(t,n.id))}catch(e){throw H(`${m.quickCaptureFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`),e}},[t,K,m.quickCaptureFailed,m.quickCaptureFailedHint,G,o]),Be=(0,Q.useCallback)(async()=>{if(!L){ee(!0),H(null);try{let e=await M({markdown:``,kind:`thought`,projectId:o,channel:`web`});y({type:`patch`,patch:dn}),await K(),ie(e.id),G(xn(t,e.id))}catch(e){H(`${m.createBlankFailed}: ${e instanceof Error?e.message:m.createBlankFailedHint}`)}finally{ee(!1)}}},[t,L,K,m.createBlankFailed,m.createBlankFailedHint,G,o]),Ve=(0,Q.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{H(null),await S(t,`web`),await K()}catch(e){H(`${m.imageUploadFailed}: ${e instanceof Error?e.message:m.imageUploadFailedHint}`)}},e.click()},[K,m.imageUploadFailed,m.imageUploadFailedHint]),He=(0,Q.useCallback)(async(e,t)=>{try{H(null),await _(e,t,`web`),await K()}catch(e){H(`${m.voiceUploadFailed}: ${e instanceof Error?e.message:m.voiceUploadFailedHint}`)}},[K,m.voiceUploadFailed,m.voiceUploadFailedHint]),Ue=(0,Q.useCallback)(()=>{H(`${m.voiceCaptureFailed}: ${m.voiceCaptureFailedHint}`)},[m.voiceCaptureFailed,m.voiceCaptureFailedHint]),We=(0,Q.useCallback)(async(e,t)=>{H(null);try{await h(e,{pinned:t}),await K()}catch(e){H(`${m.actionFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}},[K,m.actionFailed,m.quickCaptureFailedHint]),Ge=(0,Q.useCallback)(async e=>{H(null);try{await h(e,{status:`archived`}),await K()}catch(e){H(`${m.actionFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}},[K,m.actionFailed,m.quickCaptureFailedHint]),Ke=(0,Q.useCallback)(async e=>{H(null);try{await A(e),await K()}catch(e){H(`${m.actionFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}},[K,m.actionFailed,m.quickCaptureFailedHint]),qe=(0,Q.useCallback)(e=>{G(xn(t,e))},[t,G]),Ye=(0,Q.useCallback)(e=>{G(xn(t,e)),x(!1)},[t,G]),Ze=(0,Q.useCallback)(e=>{if(X.length){if(e.key===`ArrowDown`)e.preventDefault(),D(e=>Math.min(X.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),D(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=X[E]??X[0];t&&Ye(t.id)}}},[E,Ye,X]),Qe=(0,Q.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=me.current;t.setPointerCapture(e.pointerId),P(!0);let r=ae.current?.clientWidth??window.innerWidth,i=Math.max(fn,r-hn),a=Math.min(mn,i),o=e=>Math.max(fn,Math.min(a,e)),s=e.clientX,c=o(O),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let m=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},h=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(m))},g=()=>{u!==0&&(window.cancelAnimationFrame(u),m());try{t.releasePointerCapture(l)}catch{}P(!1),ae.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),k(f),_n(p,f),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[p,O]);(0,Q.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),Be())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Be]);let $e=(0,Q.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),ye(O-16)):e.key===`ArrowRight`?(e.preventDefault(),ye(O+16)):e.key===`Home`?(e.preventDefault(),ye(fn)):e.key===`End`&&(e.preventDefault(),ye(mn))},[ye,O]);return g?(0,$.jsxs)(`div`,{ref:ae,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-base`,style:{"--notes-list-width":`${O}px`},children:[(0,$.jsxs)(`section`,{ref:me,className:V(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden border-r border-edge bg-surface-rail`,!N&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,F?`lg:w-0 lg:min-w-0 lg:max-w-0 lg:pointer-events-none`:`lg:w-[var(--notes-list-width)]`,e&&`hidden lg:flex`),"aria-hidden":F?!0:void 0,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[R?(0,$.jsx)(`p`,{className:`mb-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:R}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,$.jsx)(s,{value:Le.id,onChange:e=>{let t=Fe.find(t=>t.id===e.target.value);t&&y({type:`patch`,patch:t.patch})},className:`-ml-1 h-7 w-full max-w-44 rounded-lg border border-transparent bg-transparent px-2 text-sm font-semibold text-fg transition-colors hover:border-edge hover:bg-surface-base focus:border-accent focus:bg-surface-base focus:outline-none focus:ring-1 focus:ring-accent`,"aria-label":m.libraryTitle,children:Fe.map(e=>(0,$.jsx)(c,{value:e.id,children:e.label},e.id))}):(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Re}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:ke})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>I(!0),className:`hidden size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":m.collapseNotesList,title:m.collapseNotesList,children:(0,$.jsx)(ge,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:Be,disabled:L,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":m.createBlankNote,title:m.createBlankShortcut,children:(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":m.searchDialogTitle,title:m.searchDialogTitle,children:(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:J?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,$.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):xe.length===0?(0,$.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 px-6 py-10 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-1 inline-flex size-12 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-fg-muted`,children:(0,$.jsx)(Je,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:e&&!Te?m.noteOutsideCurrentView:d??m.noNotes}),e&&!Te?null:(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:f??m.noNotesDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Te?(0,$.jsx)(`div`,{className:`mb-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:m.noteOutsideCurrentView}):null,xe.map((t,n)=>{let r=n>0?_t(xe[n-1].createdAt):null;return(0,$.jsxs)(`div`,{children:[_t(t.createdAt)!==r&&(0,$.jsx)(`div`,{className:V(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:gt(t.createdAt,_e,Pe)}),(0,$.jsx)(Ct,{note:t,selected:t.id===e,onPress:qe,onPin:We,onArchive:Ge,onDelete:Ke,timeLabels:Pe,labels:{pin:m.pin,unpin:m.unpin,archive:m.archive,delete:m.delete,actions:m.noteActions,imageNote:m.imageNote,noText:m.noText}})]},t.id)})]})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(un,{placeholder:m.quickCapturePlaceholder,submitLabel:m.quickCaptureSubmit,actionsLabel:m.quickCaptureActions,imageLabel:m.quickCaptureImage,voiceLabel:m.quickCaptureVoice,stopRecordingLabel:m.stopRecording,onCapture:ze,onImagePick:i?Ve:void 0,onVoiceCapture:i?He:void 0,onVoiceError:Ue,recordingLabel:m.recording,discussionCaptureLabel:m.discussionCapture.title,onDiscussionCapture:()=>Ie(o)})})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":m.resizeNotesList,"aria-valuemin":fn,"aria-valuemax":mn,"aria-valuenow":Math.round(O),tabIndex:0,onPointerDown:Qe,onDoubleClick:()=>ye(pn),onKeyDown:$e,title:m.resizeNotesList,className:V(`group relative z-10 hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center bg-surface-base lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,F?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-2 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`),children:(0,$.jsx)(`span`,{"aria-hidden":!0,className:V(`h-full w-px bg-edge transition-[background-color,transform] duration-150`,`group-hover:bg-accent/70 group-focus-visible:bg-accent`,N&&`bg-accent scale-x-[2]`)})}),(0,$.jsxs)(`section`,{className:V(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[F?(0,$.jsx)(`button`,{type:`button`,onClick:()=>I(!1),className:`absolute left-3 top-3 z-10 hidden size-8 items-center justify-center rounded-lg border border-edge bg-surface-base text-fg-muted shadow-surface transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":m.expandNotesList,title:m.expandNotesList,children:(0,$.jsx)(ge,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,$.jsx)(an,{noteId:e,onBack:()=>G(t),onSaved:()=>{K().catch(e=>{H(`${m.refreshFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)})},backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>x(!0),autoFocus:e===ne,onAutoFocusConsumed:()=>ie(null)}):(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,$.jsxs)(`div`,{className:`max-w-sm`,children:[(0,$.jsx)(Je,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:m.emptyEditorTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:m.emptyEditorDescription}),(0,$.jsxs)(`button`,{type:`button`,onClick:Be,disabled:L,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0}),L?m.creatingBlankNote:m.createBlankNote]})]})})]}),(0,$.jsx)(fe,{open:b,onOpenChange:x,children:(0,$.jsxs)(le,{children:[(0,$.jsx)(oe,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(ue,{className:`fixed left-1/2 top-24 z-[90] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(de,{className:`text-sm font-semibold text-fg`,children:Ae}),(0,$.jsx)(se,{className:`sr-only`,children:m.searchPlaceholder}),(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":je,children:(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`p-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:w,onChange:e=>T(e.target.value),onKeyDown:Ze,placeholder:m.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-10 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),w?(0,$.jsx)(`button`,{type:`button`,onClick:()=>T(``),className:`absolute right-2 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Me,children:(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,$.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:Y?we&&!Ce?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,$.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):X.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(Je,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:m.searchNoResults}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:m.searchNoResultsDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:m.searchResultsCount.replace(`{{count}}`,String(Ce?.total??X.length))}),X.map((e,t)=>{let n=vn[e.kind]||Je,r=yn(e,{imageNote:m.imageNote,noText:m.noText});return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Ye(e.id),onMouseEnter:()=>D(t),className:V(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===E?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,$.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:ht(e.updatedAt,_e,Pe)})]}),e.title?(0,$.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,$.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]})]},e.id)})]}):(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(z,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:m.searchEmptyTitle}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:m.searchEmptyDescription})]})})]})]})]})})]}):(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,$.jsx)(Je,{className:`size-10 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.needToken})]})}export{st as n,Sn as t};
@@ -1 +0,0 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./createLucideIcon-DPHK1VkS.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{i as c,n as l}from"./dist-CxGUk8J-.js";import{a as u,c as d,g as f,h as p,i as m,l as h,n as g,o as _,p as v,r as y,t as b,u as x}from"./Combination-14nmIgxH.js";import{a as S,i as C,n as w,r as T,t as E}from"./dist-DaxPZj9e.js";import{t as D}from"./skeleton-BwbyijEw.js";import{a as O,s as k,t as A}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as ee,r as j}from"./settings-shell-layer-context-DCp6ykjQ.js";var M=a(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),te=r(),N=t({Anchor:()=>he,Arrow:()=>_e,Close:()=>ge,Content:()=>Q,Popover:()=>B,PopoverAnchor:()=>V,PopoverArrow:()=>J,PopoverClose:()=>q,PopoverContent:()=>K,PopoverPortal:()=>W,PopoverTrigger:()=>H,Portal:()=>Z,Root:()=>Y,Trigger:()=>X,createPopoverScope:()=>ne}),P=e(n(),1),F=i(),I=`Popover`,[L,ne]=p(I,[S]),R=S(),[re,z]=L(I),B=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=R(t),c=P.useRef(null),[l,u]=P.useState(!1),[d,f]=y({prop:r,defaultProp:i??!1,onChange:a,caller:I});return(0,F.jsx)(C,{...s,children:(0,F.jsx)(re,{scope:t,contentId:_(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:P.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:P.useCallback(()=>u(!0),[]),onCustomAnchorRemove:P.useCallback(()=>u(!1),[]),modal:o,children:n})})};B.displayName=I;var ie=`PopoverAnchor`,V=P.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z(ie,n),a=R(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return P.useEffect(()=>(o(),()=>s()),[o,s]),(0,F.jsx)(E,{...a,...r,ref:t})});V.displayName=ie;var ae=`PopoverTrigger`,H=P.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z(ae,n),a=R(n),o=c(t,i.triggerRef),s=(0,F.jsx)(v.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":me(i.open),...r,ref:o,onClick:f(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,F.jsx)(E,{asChild:!0,...a,children:s})});H.displayName=ae;var U=`PopoverPortal`,[oe,se]=L(U,{forceMount:void 0}),W=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=z(U,t);return(0,F.jsx)(oe,{scope:t,forceMount:n,children:(0,F.jsx)(m,{present:n||a.open,children:(0,F.jsx)(u,{asChild:!0,container:i,children:r})})})};W.displayName=U;var G=`PopoverContent`,K=P.forwardRef((e,t)=>{let n=se(G,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=z(G,e.__scopePopover);return(0,F.jsx)(m,{present:r||a.open,children:a.modal?(0,F.jsx)(le,{...i,ref:t}):(0,F.jsx)(ue,{...i,ref:t})})});K.displayName=G;var ce=l(`PopoverContent.RemoveScroll`),le=P.forwardRef((e,t)=>{let n=z(G,e.__scopePopover),r=P.useRef(null),i=c(t,r),a=P.useRef(!1);return P.useEffect(()=>{let e=r.current;if(e)return g(e)},[]),(0,F.jsx)(b,{as:ce,allowPinchZoom:!0,children:(0,F.jsx)(de,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:f(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:f(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:f(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),ue=P.forwardRef((e,t)=>{let n=z(G,e.__scopePopover),r=P.useRef(!1),i=P.useRef(!1);return(0,F.jsx)(de,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),de=P.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...f}=e,p=z(G,n),m=R(n);return h(),(0,F.jsx)(d,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(x,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,F.jsx)(T,{"data-state":me(p.open),role:`dialog`,id:p.contentId,...m,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),fe=`PopoverClose`,q=P.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z(fe,n);return(0,F.jsx)(v.button,{type:`button`,...r,ref:t,onClick:f(e.onClick,()=>i.onOpenChange(!1))})});q.displayName=fe;var pe=`PopoverArrow`,J=P.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=R(n);return(0,F.jsx)(w,{...i,...r,ref:t})});J.displayName=pe;function me(e){return e?`open`:`closed`}var Y=B,he=V,X=H,Z=W,Q=K,ge=q,_e=J;function ve(e,t=!1){if(!t)return A;switch(e){case`modal`:return O;case`page`:return k;default:return`z-50`}}function ye({value:e,options:t,placeholder:n,allowEmpty:r=!0,emptyLabel:i=n,emptyDisabled:a=!1,disabledValues:c,disabled:l,id:u,ariaLabel:d,ariaLabelledBy:f,title:p,triggerClassName:m,contentClassName:h,side:g=`bottom`,align:_=`start`,onChange:v,searchPlaceholder:y,searchValue:b,onSearchChange:x,loading:S=!1,statusMessage:C,selectedLabel:w}){let[T,E]=(0,P.useState)(!1),O=ee(),k=j(),A=ve(O,k!==null),te=t.find(t=>t.value===e),N=w??te?.label??(e?`${e} · unavailable`:n),I;return(0,F.jsxs)(Y,{open:T,onOpenChange:E,children:[(0,F.jsx)(X,{asChild:!0,children:(0,F.jsxs)(`button`,{id:u,type:`button`,"aria-label":d,"aria-labelledby":f,title:p,disabled:l,className:s(`box-border flex h-10 w-full min-w-0 items-center justify-between gap-2 rounded-lg border border-edge bg-surface-subtle px-3 text-left text-sm font-normal text-fg`,`hover:border-edge-strong focus-visible:outline-none focus-visible:border-edge-strong`,l&&`cursor-not-allowed opacity-50 hover:border-edge`,m),children:[(0,F.jsx)(`span`,{className:s(`min-w-0 truncate`,!e&&`text-fg-subtle`),children:N}),(0,F.jsx)(M,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]})}),(0,F.jsx)(Z,{container:k??void 0,children:(0,F.jsxs)(Q,{side:g,align:_,sideOffset:4,className:s(A,`w-[var(--radix-popover-trigger-width)] min-w-[16rem] overflow-hidden rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,h),children:[y?(0,F.jsx)(`input`,{type:`search`,"aria-label":y,placeholder:y,value:b,onChange:e=>x?.(e.target.value),className:`mb-1 w-full rounded-md bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}):null,(0,F.jsxs)(`div`,{className:`max-h-64 overflow-y-auto`,children:[r?(0,F.jsxs)(`button`,{type:`button`,disabled:a,className:s(`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,e===``&&`bg-surface-active font-medium`,a&&`cursor-not-allowed opacity-45 hover:bg-transparent`),onClick:()=>{a||(v(``),E(!1))},children:[(0,F.jsx)(o,{className:s(`size-4 shrink-0`,e!==``&&`invisible`),"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate text-fg-subtle`,children:i})]}):null,S?(0,F.jsx)(`div`,{className:`space-y-2 p-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,F.jsx)(D,{className:`h-8 w-full`},e))}):null,C&&!S?(0,F.jsx)(`p`,{role:`status`,className:`px-3 py-2 text-xs text-fg-muted`,children:C}):null,(S?[]:t).map(t=>{let n=t.disabled===!0||c?.has(t.value)===!0&&t.value!==e,r=t.group&&t.group!==I;return I=t.group,(0,F.jsxs)(P.Fragment,{children:[r?(0,F.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.group}):null,(0,F.jsxs)(`button`,{type:`button`,disabled:n,className:s(`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,t.value===e&&`bg-surface-active font-medium`,n&&`cursor-not-allowed opacity-45 hover:bg-transparent`),onClick:()=>{n||(v(t.value),E(!1))},children:[(0,F.jsx)(o,{className:s(`size-4 shrink-0`,t.value!==e&&`invisible`),"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:t.label})]})]},`${t.group??``}:${t.value}`)})]})]})})]})}function $(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map($).join(``):(0,P.isValidElement)(e)?$(e.props.children):``}function be(e,t){let n=[];return P.Children.forEach(e,e=>{if(!(0,P.isValidElement)(e))return;if(e.type===P.Fragment){n.push(...be(e.props.children,t));return}if(e.type===Se){let t=e.props;n.push(...be(t.children,$(t.label)));return}if(e.type!==xe)return;let r=e.props,i=$(r.children).trim(),a=r.value==null?i:String(r.value);n.push({value:a,label:i,disabled:r.disabled,group:t})}),n}function xe(e){return null}function Se(e){return null}function Ce(e){if(!e)return;let t=e.split(/\s+/).filter(Boolean).filter(e=>{let t=e.includes(`:`)?e.slice(e.lastIndexOf(`:`)+1):e;return t===`block`||t===`inline-block`||t===`inline-flex`||t===`flex`||t===`flex-1`||t===`flex-auto`||t===`flex-initial`||t===`flex-none`||t===`grow`||t===`shrink`||t===`min-w-0`||t===`min-h-0`||t.startsWith(`w-`)||t.startsWith(`min-w-`)||t.startsWith(`max-w-`)||t.startsWith(`basis-`)||t.startsWith(`grow-`)||t.startsWith(`shrink-`)||t.startsWith(`self-`)||t.startsWith(`order-`)||t.startsWith(`col-`)||t.startsWith(`row-`)});return t.length===0?void 0:t.join(` `)}function we(e){let t=(0,te.c)(66),n,r,i,a,o,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12]):({align:n,children:r,className:i,contentClassName:a,disabled:o,id:c,onChange:l,placeholder:u,side:f,triggerClassName:p,value:m,...d}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m);let h=(0,P.useId)(),g=m==null?``:String(m),_,v,y,b,x,S,C,w,T,E;if(t[13]!==r||t[14]!==i||t[15]!==o||t[16]!==h||t[17]!==c||t[18]!==u||t[19]!==d.name||t[20]!==g){let e=be(r);b=e.find(Ee),v=b!==void 0,y=b?.label||u||``,w=o||void 0,t[31]===i?T=t[32]:(T=Ce(i),t[31]=i,t[32]=T),E=d.name,_=ye,x=c??h,S=g,C=e.filter(Te),t[13]=r,t[14]=i,t[15]=o,t[16]=h,t[17]=c,t[18]=u,t[19]=d.name,t[20]=g,t[21]=_,t[22]=v,t[23]=y,t[24]=b,t[25]=x,t[26]=S,t[27]=C,t[28]=w,t[29]=T,t[30]=E}else _=t[21],v=t[22],y=t[23],b=t[24],x=t[25],S=t[26],C=t[27],w=t[28],T=t[29],E=t[30];let D=u??y,O=b?.disabled===!0,k=d[`aria-label`],A=d[`aria-labelledby`],ee=d.title,j;t[33]!==i||t[34]!==p?(j=s(i,p),t[33]=i,t[34]=p,t[35]=j):j=t[35];let M;t[36]===l?M=t[37]:(M=e=>l?.({target:{value:e},currentTarget:{value:e}}),t[36]=l,t[37]=M);let N;t[38]!==_||t[39]!==n||t[40]!==v||t[41]!==a||t[42]!==o||t[43]!==y||t[44]!==d.title||t[45]!==f||t[46]!==x||t[47]!==A||t[48]!==j||t[49]!==M||t[50]!==S||t[51]!==C||t[52]!==D||t[53]!==O||t[54]!==k?(N=(0,F.jsx)(_,{id:x,value:S,options:C,placeholder:D,allowEmpty:v,emptyLabel:y,emptyDisabled:O,disabled:o,ariaLabel:k,ariaLabelledBy:A,title:ee,side:f,align:n,triggerClassName:j,contentClassName:a,onChange:M}),t[38]=_,t[39]=n,t[40]=v,t[41]=a,t[42]=o,t[43]=y,t[44]=d.title,t[45]=f,t[46]=x,t[47]=A,t[48]=j,t[49]=M,t[50]=S,t[51]=C,t[52]=D,t[53]=O,t[54]=k,t[55]=N):N=t[55];let I;t[56]!==o||t[57]!==d.name||t[58]!==g?(I=(0,F.jsx)(`input`,{name:d.name,value:g,readOnly:!0,hidden:!0,disabled:o}),t[56]=o,t[57]=d.name,t[58]=g,t[59]=I):I=t[59];let L;return t[60]!==N||t[61]!==I||t[62]!==w||t[63]!==T||t[64]!==E?(L=(0,F.jsxs)(`div`,{"aria-disabled":w,className:T,"data-select-name":E,children:[N,I]}),t[60]=N,t[61]=I,t[62]=w,t[63]=T,t[64]=E,t[65]=L):L=t[65],L}function Te(e){return e.value!==``}function Ee(e){return e.value===``}export{_e as a,Z as c,N as d,M as f,ve as i,Y as l,we as n,ge as o,xe as r,Q as s,ye as t,X as u};