@xopcai/xopc 0.0.174 → 0.0.175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CyEDJeIt.js → activity-store-CM6mQUS2.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DF7Bol6I.js → agent-avatar-dicebear-eckyE9AY.js} +1 -1
- package/dist/gateway/static/root/assets/agents-D-OIB_r0.js +2 -0
- package/dist/gateway/static/root/assets/{api-DwyUxpgY.js → api-2SLLStKp.js} +1 -1
- package/dist/gateway/static/root/assets/{api-DYunqroX.js → api-BfMRS6FX.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B4xJyvDu.js → app-management-settings-panel-DYkzZQzZ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B2PQxRiu.js → appearance-settings-CDXXN57j.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CuvFyvuu.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DWhBmmjD.js → archive-plugin-k909a76t.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BOpZfa_I.js → attachment-load-CqNzyhdJ.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Byu3I7Rs.js → automation-suggestion-card-snNG6u0v.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-DetGVTjI.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-6AG1qatz.js → binary-plugins-PfQ9ZHDF.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CJhrn98_.js → block-editor-Xrw-DnE_.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-G92AdEnX.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CBVb4mt9.js → browser-workflow-inputs-DJPF2lUY.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Cq4XUKbu.js → browser-workflows-page-BoXs4pgc.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-nS_AMN1K.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-hbW4NAKO.js → capability-presets-api-BgY-Ysmi.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DIO8ZNHW.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CzMjHb17.js → channel-recipient-api-D32T1EJM.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-4Im3vtnO.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-CMctpuqb.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-B9Au6gMZ.js → connector-logo-C-l8haIK.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-vL3SjHSc.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-CwOI_Hei.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CNff5TFb.js → desktop-pet-settings-Cldo_pA3.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Bf956uo-.js → directory-picker-path-field-CMASXbgJ.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CHM8FE1g.js → dreaming-settings-BnMx02w0.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-ZqM_0eUs.js → extension-debug-page-mUFs3ign.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D4hvXOMM.js → extension-page-BsFBOZ5N.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-GsqxaJjA.js → extension-settings-page-CTEoovnV.js} +1 -1
- package/dist/gateway/static/root/assets/{focus-detail-page-CE6uwrl1.js → focus-detail-page-CCaZthpU.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-B4THmgnS.js → gateway-config-api-Bwx-EetD.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CPv-MxGE.js → gateway-settings-CvgyqhR_.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-MP3K71pP.js → gateway-startup-retry-C8f5KwkT.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Bhynl9LN.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-ChS2rU0w.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-DCcDuIjG.js → goals-config-api-CUnfbgHa.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BAS_liXl.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-o9QMXvNq.js → goals-settings-Bkk-tOcf.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DixwpXnH.js → heartbeat-settings-D9Pldf5E.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BOGH9FGi.js → image-generation-api-D7aCMgOv.js} +1 -1
- package/dist/gateway/static/root/assets/index-DJ5vdaHk.css +1 -0
- package/dist/gateway/static/root/assets/{index-eyttVNS_.js → index-TnouSpay.js} +7 -7
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D4o4ZPF6.js → keyboard-shortcuts-settings-CBhtXhHb.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-HQeu_F1C.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-GzMmpO7G.js → local-apps-page-BtJGF3M8.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CAuhEGCn.js → locale-store-DO-u1yS7.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-0lvwfLAA.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CIX8D1pv.js → markdown-split-BGPaeTch.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bp3eIA45.js → media-plugins-C_Cx8v6u.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BiBdO1-O.js → messages-BP8aQX-5.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-RVFiYAoO.js → notes-page-CIYy5BKF.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-_FgNPlOx.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BGAYH3Ef.js → page-tabs-C2vsdfJO.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BM6pDkHp.js → preview-open-alternatives-D_VT83bW.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BiMetEmn.js → product-open-page-BNP9kZ3Q.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-MNi-3mZU.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-xx8nUKZO.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-H5DSn2bR.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BdjV8MK5.js → save-bar-controls-BJL6Xb-F.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-ChlqXU46.js → schedule-field-CxCPSLbu.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DDKf5ZSH.js → schema-form-Cao1wGbk.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CMQsupwM.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-OBUdG6bV.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CPG0KGVs.js → settings-form-section-9pgClEud.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DRSDHucM.js → settings-loading-skeleton-CQz0gEUK.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CeB7_xD0.js → settings-page-DgsMzZLm.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-BENrkwd0.js → settings-page-layout-BhqupMfG.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-B7BsWxJt.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DIzczJkG.js → share-preview-page-CC4dQsQN.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Bhz21P05.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CBP-UB88.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-A0rNObNB.js +2 -0
- package/dist/gateway/static/root/assets/skills-page.utils-CF4AYPQg.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Dp4d5Q1B.js → system-settings-panel-CzZHWI4u.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CbGc1laW.js → theme-store-BZWNdSZC.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-BC922Mdg.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-DwPk3OPL.js → typed-models-lib-C1S-B1pk.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CXrEu2dw.js → use-channel-catalog-DTiLxcLF.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-8XdpiAyP.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DFoA79LB.js → voice-api-key-field-CtIYRNfI.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DBer86NF.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-BUPyfYaq.js +1 -0
- package/dist/gateway/static/root/assets/work-page-G8phwwI1.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BuniGPO0.js → workflow-run-setup-panel-IKxqDAXw.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CNls7g6v.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/skills/index.d.ts +2 -0
- package/dist/src/agent/skills/index.js +14 -5
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/test-framework.js +1 -1
- package/dist/src/automations/domain/defaults.d.ts +1 -0
- package/dist/src/automations/domain/defaults.js +4 -0
- package/dist/src/automations/domain/index.d.ts +1 -0
- package/dist/src/automations/domain/index.js +2 -1
- package/dist/src/automations/index.js +2 -1
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/routes/home.d.ts +16 -3
- package/dist/src/gateway/hono/routes/home.js +98 -25
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/project-skills.d.ts +3 -0
- package/dist/src/gateway/hono/routes/project-skills.js +119 -0
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/projects/index.d.ts +1 -0
- package/dist/src/projects/index.js +2 -1
- package/dist/src/projects/project-skill-service.d.ts +67 -0
- package/dist/src/projects/project-skill-service.js +131 -0
- package/dist/src/storage/sqlite/home-attention-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/home-attention-repository.js +21 -0
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/067_home_attention_acknowledgements.sql +9 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +10 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-BVxEFPQ5.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BtIgd82S.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-CG_SCH5b.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CfLqPWZC.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DCJmm6cR.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CnkAYvWI.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-DtqqFpDn.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-C-5yHbc0.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CaHfs8YF.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CvFMKYdb.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DAeb82xP.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-CwLSp01r.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-DvJQ6_4M.js +0 -2
- package/dist/gateway/static/root/assets/index-CfXiRNN5.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CPcfqn_A.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DXABWCZp.js +0 -7
- package/dist/gateway/static/root/assets/notes-workbench-DgJzZRX3.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-DF7F70Vg.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-Cw3jyi5s.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-ChAJsaNY.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BxZIxt7z.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DcDLS0xV.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-4Xa9NA7v.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BpN0o5Cf.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DvF2UAaL.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CGKXpNfy.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-BhgCeDuO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Dy_fKAK_.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BWkjb1NK.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DLBNFse5.js +0 -1
- package/dist/gateway/static/root/assets/work-page-Bn5RXMIE.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-_vFhRrAl.js +0 -11
|
@@ -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-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{n as c,r as l}from"./locale-store-CAuhEGCn.js";import{a as u,i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Bc as p,Bl as ee,Bo as m,Cl as h,Co as g,Fl as _,Go as v,Gs as y,Ho as b,Ms as x,Na as te,Nu as ne,Oc as re,Sc as ie,To as ae,Uo as oe,Vo as se,Wl as ce,Wo as le,Ws as ue,Zc as S,ac as de,bc as fe,bt as C,kc as pe,ks as w,lc as me,pu as he,ro as T,ru as E,su as ge,tl as D,zo as _e}from"./index-eyttVNS_.js";import{a as ve,c as ye,l as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./api-DYunqroX.js";var O=e(t(),1),Ee=`build-xopc-local-app`;function De(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function Oe(e){return e.find(e=>De(e)===`coder`)??null}function ke(e,t){let n=new URLSearchParams({skill:Ee}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var k=new Set([`document`,`content`,`interaction`,`criteria`]),Ae=new Set([`passed`,`failed`,`skipped`]);function je(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!k.has(t.id)||!Ae.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 Me(e){return e?.checks.filter(e=>e.status===`failed`).map(e=>e.message)??[]}function Ne(e){let t=e.filename?` (${e.filename}${e.line?`:${e.line}${e.column?`:${e.column}`:``}`:``})`:``;return`${e.message}${t}`}var Pe=Object.freeze({source:`xopc-local-app-host`,version:1,type:`connect`});function Fe(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(Pe,`*`,[r.port2])};return e.addEventListener(`load`,r),r(),()=>{e.removeEventListener(`load`,r),n?.close()}}var Ie=n(),A=r();function Le(e){let t=(0,Ie.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let l=a?`产品场景`:`Product scenarios`,u;t[0]===l?u=t[1]:(u=(0,A.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:l}),t[0]=l,t[1]=u);let d=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,f;t[2]===d?f=t[3]:(f=(0,A.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,A.jsxs)(`div`,{children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let ee=i!==null,m;t[7]===i?m=t[8]:(m=i===`all`?(0,A.jsx)(D,{className:`size-3 animate-spin`}):(0,A.jsx)(ie,{className:`size-3`}),t[7]=i,t[8]=m);let h=a?`全部重跑`:`Run all`,g;t[9]!==o||t[10]!==ee||t[11]!==m||t[12]!==h?(g=(0,A.jsxs)(w,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:ee,children:[m,h]}),t[9]=o,t[10]=ee,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==p||t[15]!==g?(_=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[p,g]}),t[14]=p,t[15]=g,t[16]=_):_=t[16];let v=a?`产品场景验收结果`:`Product scenario acceptance results`,y;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,A.jsx)(`li`,{className:`py-2.5 first:pt-1`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:n===`running`?(0,A.jsx)(D,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,A.jsx)(he,{className:`size-3.5 text-success`}):n===`failed`?(0,A.jsx)(ge,{className:`size-3.5 text-danger`}):(0,A.jsx)(E,{className:`size-3.5 text-fg-subtle`})}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-[11px] font-medium text-fg`,children:e.name}),(0,A.jsx)(`p`,{className:`mt-0.5 text-[10px] text-fg-subtle`,children:a?`${e.stepCount} 个步骤`:`${e.stepCount} step${e.stepCount===1?``:`s`}`})]}),(0,A.jsx)(w,{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,A.jsx)(ie,{className:`size-3`})})]}),n===`running`?(0,A.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`正在隔离预览中执行…`:`Running in an isolated preview…`}):t?.status===`failed`?(0,A.jsxs)(`div`,{className:`mt-1.5`,children:[(0,A.jsx)(`p`,{className:`text-[11px] leading-4 text-danger`,children:t.message}),(0,A.jsxs)(w,{variant:`ghost`,className:`mt-1 h-7 rounded-lg px-2 text-[11px] text-danger hover:text-danger`,onClick:()=>c(e,t),children:[(0,A.jsx)(S,{className:`size-3`}),a?`让 Coder 修复`:`Ask Coder to fix`]})]}):t?.status===`passed`?(0,A.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`场景已通过`:`Scenario passed`}):(0,A.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],y=n.map(e),t[17]=c,t[18]=s,t[19]=r,t[20]=i,t[21]=n,t[22]=a,t[23]=y}else y=t[23];let b;t[30]!==v||t[31]!==y?(b=(0,A.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":v,children:y}),t[30]=v,t[31]=y,t[32]=b):b=t[32];let x;return t[33]!==_||t[34]!==b?(x=(0,A.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[_,b]}),t[33]=_,t[34]=b,t[35]=x):x=t[35],x}var Re=`allow-scripts allow-forms`;function ze(e,t){return C(e,t)}function Be(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 j(){let{appId:e}=i(),t=e===`new`,n=c(e=>e.language)===`zh`,r=c(e=>e.language),C=a(),{mutate:E}=u(),ge=g(e=>e.moveToFront),Ee=ae(e=>e.setPageHeader),De=ae(e=>e.clearPageHeader),{data:k,isLoading:Ae,error:Pe,mutate:Ie}=d(!t&&e?[`local-app`,e]:null,()=>xe(e)),{data:j,isLoading:Ve,mutate:He}=d(!t&&e?[`local-app-validation`,e]:null,()=>be(e)),[Ue,We]=(0,O.useState)(``),[Ge,Ke]=(0,O.useState)(``),[M,N]=(0,O.useState)(!1),[qe,P]=(0,O.useState)(null),[Je,Ye]=(0,O.useState)(!1),[Xe,Ze]=(0,O.useState)(!1),[F,Qe]=(0,O.useState)(0),[$e,et]=(0,O.useState)(``),[I,tt]=(0,O.useState)(!1),[nt,rt]=(0,O.useState)(!1),[L,R]=(0,O.useState)(`booting`),[z,it]=(0,O.useState)(null),[B,at]=(0,O.useState)(null),[V,ot]=(0,O.useState)({}),[H,st]=(0,O.useState)(`all`),[U,W]=(0,O.useState)(0),[ct,lt]=(0,O.useState)(0),[ut,dt]=(0,O.useState)(null),[G,ft]=(0,O.useState)(null),[pt,mt]=(0,O.useState)([]),[ht,gt]=(0,O.useState)(!1),_t=(0,O.useRef)(new Set),K=(0,O.useRef)(null),vt=(0,O.useRef)(null),yt=(0,O.useRef)(null),q=(0,O.useRef)(null),J=(0,O.useRef)(``),Y=j?.acceptanceScenarios??[],X=(0,O.useMemo)(()=>{if(!Y.length)return null;let e=Y.map(e=>V[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,V]),Z=(0,O.useMemo)(()=>{if(!B)return null;if(!j?.acceptanceScenarioCount)return B;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=[...B.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:B.interactiveCount}},[B,X,j?.acceptanceScenarioCount]),bt=(0,O.useCallback)(async(e,t)=>{let n=Oe(await f(e.projectId))??await te(e.projectId,`coder`);_t.current.add(n.key),C(ke(n.key,t))},[C]),xt=(0,O.useCallback)(async(e=!0)=>{if(!k)return null;rt(!0);try{let t=await be(k.id);return await He(t,{revalidate:!1}),e&&(q.current=t.sourceHash??null,st(`all`),W(0),Qe(e=>e+1)),t}catch(e){return P(e instanceof Error?e.message:String(e)),null}finally{rt(!1)}},[k,He]);(0,O.useEffect)(()=>{if(!k)return;let e=!1;f(k.projectId).then(t=>{e||(_t.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||!_t.current.has(t)||(K.current!==null&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>{K.current=null,xt(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),K.current!==null&&window.clearTimeout(K.current)}},[k,xt]),(0,O.useEffect)(()=>{mt(k?.acceptanceRuns??[])},[k?.acceptanceRuns]),(0,O.useEffect)(()=>{q.current=null},[k?.id]),(0,O.useEffect)(()=>{!j?.sourceHash||q.current||(q.current=j.sourceHash,st(`all`),W(0),Qe(e=>e+1))},[j?.sourceHash]),(0,O.useLayoutEffect)(()=>{if(!k)return;R(`booting`),it(null),at(null),ft(null),gt(!1),J.current=``;let e=window.setTimeout(()=>R(e=>e===`failed`?e:`timeout`),7e3),t=vt.current?Fe(vt.current,t=>{let n=je(t);if(n){if(n.type===`ready`){R(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),at(n.detail),ft(q.current);return}n.type!==`criteria`&&(window.clearTimeout(e),it(n.detail),R(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[k,F]),(0,O.useLayoutEffect)(()=>{if(!k||j?.status!==`healthy`||!Y.length){dt(null);return}let e=H===`all`?Y[U]:Y.find(e=>e.id===H),t=e?[e]:[];if(!t.length)return;dt(H),ot(e=>{if(H===`all`&&U===0)return{};let t={...e};return delete t[H],t});let r=!1,i=e=>{ot(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}),dt(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=yt.current?Fe(yt.current,e=>{let t=je(e);t&&(t.type===`ready`?r=!0:t.type===`criteria`?(window.clearTimeout(a),ot(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}),H===`all`&&U+1<Y.length?(W(e=>e+1),lt(e=>e+1)):dt(null)):t.type===`error`&&(window.clearTimeout(a),i(Ne(t.detail))))}):()=>{};return()=>{window.clearTimeout(a),o()}},[Y,k,ct,H,U,F,j?.status,n]),(0,O.useEffect)(()=>{if(!k||!Z||!G||G!==j?.sourceHash)return;let e=`${k.id}:${G}:${JSON.stringify(Z)}`;J.current!==e&&(J.current=e,gt(!0),ve(k.id,G,Z).then(t=>{J.current===e&&mt(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&>(!1)}))},[Z,G,k,j?.sourceHash]);let Q=(0,O.useCallback)(async e=>{if(k){tt(!0),P(null);try{await bt(k,e)}catch(e){P(e instanceof Error?e.message:String(e)),tt(!1)}}},[k,bt]);(0,O.useLayoutEffect)(()=>(Ee({startExtra:(0,A.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,A.jsx)(ne,{className:`size-4`})}),main:(0,A.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k?.name||(n?`创建本地应用`:`Create local app`)}),end:k?(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(w,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,A.jsxs)(o,{to:`/projects/${encodeURIComponent(k.projectId)}`,children:[(0,A.jsx)(_,{className:`size-4`}),`Project`]})}),(0,A.jsxs)(w,{className:`h-9`,onClick:()=>void Q(),disabled:I,children:[I?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(S,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>De()),[k,I,De,Q,Ee,n]);async function St(e){e.preventDefault(),N(!0),P(null);try{let e=await Te({name:Ue,idea:Ge});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 bt(e,t)}catch{C(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Ct(){if(k){N(!0),P(null);try{let e=await Ce(k.id);await Ie(e,{revalidate:!1}),await He(),await Promise.all([E(`local-apps-list`),E(`gateway-extensions-list`)]),ge(`ext:${e.extensionId}:app`),Ye(!1)}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function wt(e,t=!1){N(!0),P(null);try{let n=await e();return await Ie(n,{revalidate:!1}),await He(),await Promise.all([E(`local-apps-list`),E(`gateway-extensions-list`)]),t&&ge(`ext:${n.extensionId}:app`),!0}catch(e){return P(e instanceof Error?e.message:String(e)),!1}finally{N(!1)}}async function Tt(e){k&&await wt(()=>we(k.id,e),e)}async function Et(e){k&&await wt(()=>Se(k.id,e),!0)}async function Dt(){k&&await wt(()=>ye(k.id))&&Ze(!1)}function Ot(){let e=Array.from(new Set([...j?.issues.map(e=>e.message)??[],...z?[Ne(z)]:[],...Z?.checks.filter(e=>e.status===`failed`&&e.id!==`criteria`).map(e=>e.message)??[],...Object.values(V).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.failureKind===`runner`?`[验收执行器] `:``}${e.message}`),...L===`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 kt(){st(`all`),W(0),lt(e=>e+1)}function At(e){st(e),W(0),lt(e=>e+1)}function jt(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 Mt=pt.findIndex(e=>Be(e,G,Z)),$=Mt>=0?pt[Mt]:null,Nt=Mt>=0?pt[Mt+1]??null:pt[0]??null,Pt=Me(Z),Ft=Nt?Nt.checks.filter(e=>e.status===`failed`).map(e=>e.message):[],It=j?.status===`failed`||L===`failed`||L===`timeout`||Z?.status===`failed`||Object.values(V).some(e=>e.status===`failed`),Lt=Ft.filter(e=>!Pt.includes(e)).length;async function Rt(){let e=await xt(!1);if(e?.status===`healthy`&&e.sourceHash!==G){q.current=e.sourceHash??null,W(0),Qe(e=>e+1);return}e?.status===`healthy`&&L===`healthy`&&Z?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&Ye(!0)}return t?(0,A.jsx)(`div`,{className:`flex min-h-0 flex-1 bg-surface-panel p-3 sm:p-5 xl:p-6`,children:(0,A.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,A.jsxs)(`form`,{onSubmit:St,className:`flex flex-col border-b border-edge-subtle p-5 lg:border-b-0 lg:border-r`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[(0,A.jsx)(de,{className:`size-4`}),n?`告诉 Coder 你的想法`:`Tell Coder your idea`]}),(0,A.jsx)(`h2`,{className:`mt-4 text-xl font-semibold tracking-tight text-fg`,children:n?`你想创建什么?`:`What do you want to create?`}),(0,A.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,A.jsxs)(`label`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:[n?`应用名称`:`App name`,(0,A.jsx)(`input`,{value:Ue,onChange:e=>We(e.target.value),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,A.jsxs)(`label`,{className:`mt-4 text-xs font-medium text-fg-muted`,children:[n?`描述你的想法`:`Describe your idea`,(0,A.jsx)(`textarea`,{value:Ge,onChange:e=>Ke(e.target.value),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…`})]}),qe?(0,A.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:qe}):null,(0,A.jsxs)(w,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:M||!Ue.trim()||!Ge.trim(),children:[M?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(S,{className:`size-4`}),n?`进入 Coder 对话`:`Continue with Coder`]})]}),(0,A.jsx)(`div`,{className:`hidden min-h-[620px] place-items-center bg-surface-panel p-8 lg:grid`,children:(0,A.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,A.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,A.jsx)(p,{className:`size-7`})}),(0,A.jsx)(`h3`,{className:`mt-5 text-base font-semibold text-fg`,children:n?`创建后,这里就是实时预览`:`Your live preview appears here`}),(0,A.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.`})]})})]})}):Ae?(0,A.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,A.jsx)(T,{className:`rounded-xl`}),(0,A.jsx)(T,{className:`rounded-xl`}),(0,A.jsx)(T,{className:`rounded-xl`})]}):Pe||!k?(0,A.jsx)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:Pe instanceof Error?Pe.message:n?`找不到应用`:`App not found`}):(0,A.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,A.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.12em] text-accent`,children:[(0,A.jsx)(de,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,A.jsx)(`div`,{className:`mt-4 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg`,children:k.idea}),(0,A.jsxs)(`div`,{className:`mt-4 rounded-xl bg-accent-soft p-3`,children:[(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-accent-fg`,children:[(0,A.jsx)(he,{className:`size-4`}),n?`草稿已准备好`:`Draft is ready`]}),(0,A.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,A.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),Q($e)},children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`local-app-change-request`,children:n?`下一步想改什么?`:`What should change next?`}),(0,A.jsx)(`textarea`,{id:`local-app-change-request`,value:$e,onChange:e=>et(e.target.value),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,A.jsxs)(w,{type:`submit`,className:`mt-2 w-full`,disabled:I||!$e.trim(),children:[I?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(S,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,A.jsxs)(w,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:I,children:[(0,A.jsx)(_,{className:`size-4`}),n?`打开已有开发对话`:`Open development chat`]})]}),(0,A.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,A.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-edge-subtle px-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,A.jsx)(`span`,{className:`size-2 rounded-full ${j?.status===`failed`||L===`failed`||L===`timeout`||Z?.status===`failed`?`bg-danger`:j?.status===`healthy`&&L===`healthy`&&Z?.status===`passed`&&$?.sourceHash===j.sourceHash&&!ht?`bg-success`:`bg-fg-subtle`}`}),L===`failed`||L===`timeout`?n?`预览运行异常`:`Preview runtime issue`:j?.status===`failed`||Z?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:L===`booting`||!Z?n?`自动验收中`:`Running acceptance`:ht||$?.sourceHash!==j?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,A.jsxs)(w,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void xt(!0),disabled:nt,children:[nt?(0,A.jsx)(D,{className:`size-3.5 animate-spin`}):(0,A.jsx)(ie,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,A.jsx)(`iframe`,{ref:vt,title:`${k.name} preview`,src:l(k.previewUrl),sandbox:Re,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{it({kind:`script_error`,message:`Preview document failed to load`}),R(`failed`)}},F),j?.status===`healthy`&&j.acceptanceScenarioCount>0?(0,A.jsx)(`iframe`,{ref:yt,title:`${k.name} acceptance runner`,src:`${l(k.previewUrl)}?xopcAcceptance=1&xopcScenario=${encodeURIComponent(H===`all`?Y[U]?.id??``:H)}`,sandbox:Re,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${F}-${ct}-${U}`):null]}),(0,A.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n?`发布状态`:`Release status`}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:k.installationState===`not_installed`?n?`尚未安装`:`Not installed`:k.enabled?n?`版本 ${k.activeVersion} 正在使用`:`Version ${k.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,A.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${k.enabled?`bg-success`:`bg-fg-subtle`}`,"aria-hidden":!0})]}),(0,A.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 text-xs`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`当前草稿`:`Draft`}),(0,A.jsxs)(`dd`,{className:`mt-1 font-medium text-fg`,children:[`v`,k.draftVersion]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`已安装`:`Installed`}),(0,A.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:k.activeVersion?`v${k.activeVersion}`:`—`})]})]}),(0,A.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,A.jsx)(ee,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),Ve||nt?(0,A.jsx)(D,{className:`size-3.5 animate-spin text-fg-muted`}):j?.status===`healthy`?(0,A.jsx)(he,{className:`size-4 text-success`}):(0,A.jsx)(ue,{className:`size-4 text-danger`})]}),j?(0,A.jsxs)(`div`,{className:`mt-2`,children:[(0,A.jsx)(`p`,{className:`text-xs leading-5 ${j.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:j.status===`healthy`?j.hasDraftChanges?n?`${j.changedFileCount} 个文件有改动,可以安装新版本。`:`${j.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:j.issues[0]?.message}),j.changedFiles.length?(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:j.changedFiles.slice(0,4).map(e=>(0,A.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,A.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,j.changedFileCount>4?(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${j.changedFileCount-4} 个文件`:`${j.changedFileCount-4} more files`}):null,(0,A.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,A.jsx)(`span`,{className:`size-2 rounded-full ${L===`healthy`?`bg-success`:L===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${L===`failed`||L===`timeout`?`text-danger`:`text-fg-muted`}`,children:z?Ne(z):L===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:L===`timeout`?n?`7 秒内未完成启动,可能出现白屏或阻塞。`:`Did not finish booting within 7 seconds.`:n?`正在等待应用启动。`:`Waiting for the app to start.`})]}),(0,A.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,A.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,A.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:Z.checks.map(e=>(0,A.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4 ${e.status===`failed`?`text-danger`:`text-fg-muted`}`,children:[(0,A.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,A.jsx)(`span`,{children:e.message})]},e.id))}):(0,A.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:j?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${j.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${j.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),ht?(0,A.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,A.jsx)(D,{className:`size-3 animate-spin`}),n?`正在保存当前源码对应的验收快照…`:`Saving the acceptance snapshot for this source…`]}):$?(0,A.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-fg-muted`,children:Nt?n?`相比上次:已修复 ${Lt} 项,仍有 ${Pt.length} 项。`:`Since the previous run: ${Lt} fixed, ${Pt.length} remaining.`:n?`首个验收快照已保存。`:`First acceptance snapshot saved.`}):null,(0,A.jsx)(Le,{scenarios:Y,results:V,runningTarget:ut,zh:n,onRunAll:kt,onRunScenario:At,onAskCoder:jt})]}),It?(0,A.jsxs)(w,{className:`mt-3 w-full`,onClick:Ot,disabled:I,children:[(0,A.jsx)(S,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,A.jsx)(T,{className:`mt-2 h-12 rounded-lg`})]}),(0,A.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,A.jsx)(me,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(j?.permissions??k.permissions).map(e=>(0,A.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e))})]}),(0,A.jsx)(w,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Rt(),disabled:M||Ve||nt||ht||j?.status===`failed`||L!==`healthy`||Z?.status!==`passed`||!$||$.sourceHash!==j?.sourceHash||k.installationState===`installed`&&j?.hasDraftChanges===!1,children:k.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),k.installationState===`installed`?(0,A.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,A.jsxs)(w,{className:`min-w-0 flex-1`,onClick:()=>void Tt(!k.enabled),disabled:M,children:[k.enabled?(0,A.jsx)(pe,{className:`size-4`}):(0,A.jsx)(re,{className:`size-4`}),k.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,A.jsx)(w,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>Ze(!0),disabled:M,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,A.jsx)(y,{className:`size-4`})})]}):null,(0,A.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,A.jsx)(h,{className:`size-4`}),n?`版本历史`:`Release history`]}),k.releases.length?(0,A.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:k.releases.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2.5`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[`v`,e.version,e.isActive?(0,A.jsx)(`span`,{className:`rounded-full bg-success-soft px-1.5 py-0.5 text-[10px] text-success`,children:n?`当前`:`Active`}):null]}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-fg-subtle`,children:ze(e.createdAt,r)})]}),e.isActive?null:(0,A.jsxs)(w,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void Et(e.id),disabled:M,children:[(0,A.jsx)(fe,{className:`size-3.5`}),n?`恢复`:`Restore`]})]},e.id))}):(0,A.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n?`安装首个版本后,可以从这里恢复。`:`Install the first version to enable recovery.`})]}),qe?(0,A.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:qe}):null]}),(0,A.jsx)(_e,{open:Je,onOpenChange:Ye,children:(0,A.jsxs)(le,{children:[(0,A.jsx)(oe,{className:`fixed inset-0 z-50 bg-black/45`}),(0,A.jsxs)(se,{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,A.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(v,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,A.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,A.jsx)(m,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,A.jsx)(x,{className:`size-4`})})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,A.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:k.name}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:k.extensionId})]}),(0,A.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`本次迭代`:`This iteration`}),(0,A.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-3 text-xs`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`文件变化`:`Changed files`}),(0,A.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:j?.changedFileCount??0})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`自动验收`:`Acceptance`}),(0,A.jsxs)(`dd`,{className:`mt-1 flex items-center gap-1.5 font-medium text-success`,children:[(0,A.jsx)(he,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),j?.changedFiles.length?(0,A.jsx)(`ul`,{className:`mt-3 space-y-1`,children:j.changedFiles.slice(0,5).map(e=>(0,A.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,A.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,(0,A.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`请求权限`:`Requested permissions`}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-2`,children:(j?.permissions??k.permissions).map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,A.jsx)(s,{className:`size-4 text-success`}),e,k.installationState===`installed`&&j?.permissionDelta.added.includes(e)?(0,A.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-[10px] text-warning`,children:n?`新增`:`New`}):null]},e))}),k.installationState===`installed`&&j?.permissionDelta.added.length?(0,A.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,A.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,A.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,A.jsx)(m,{asChild:!0,children:(0,A.jsx)(w,{children:n?`取消`:`Cancel`})}),(0,A.jsxs)(w,{variant:`primary`,onClick:()=>void Ct(),disabled:M,children:[M?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(ce,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,A.jsx)(_e,{open:Xe,onOpenChange:Ze,children:(0,A.jsxs)(le,{children:[(0,A.jsx)(oe,{className:`fixed inset-0 z-50 bg-black/45`}),(0,A.jsxs)(se,{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,A.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(v,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,A.jsx)(b,{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,A.jsx)(m,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,A.jsx)(x,{className:`size-4`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,A.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-4`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.name}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`之后可从任意保留版本重新安装。`:`You can reinstall any retained release later.`})]})}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,A.jsx)(m,{asChild:!0,children:(0,A.jsx)(w,{children:n?`取消`:`Cancel`})}),(0,A.jsxs)(w,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void Dt(),disabled:M,children:[M?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(y,{className:`size-4`}),n?`卸载但保留 Project`:`Uninstall and keep Project`]})]})]})]})})]})}export{j as LocalAppWorkbenchPage};
|
|
@@ -1,7 +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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./copy-to-clipboard-HOJ79TWv.js";import{t as s}from"./messages-BiBdO1-O.js";import{l as c,n as l,r as u,s as d}from"./locale-store-CAuhEGCn.js";import{Bo as f,Ds as p,Go as m,Jl as h,Js as g,Ml as _,Ms as v,Rl as y,Sc as b,Uo as x,Vo as S,Wo as C,_u as w,au as T,ds as E,fs as D,ha as O,hc as k,hs as A,is as j,jl as M,ks as N,ls as P,ms as F,ns as I,oa as L,ol as R,ps as z,ro as B,us as ee,ws as te,zo as ne}from"./index-eyttVNS_.js";import{r as V}from"./segmented-styles-BL8oLBEp.js";var H=e(t(),1),U=n();function W(e){let t=new URLSearchParams;if(!e)return``;e.level?.length&&t.set(`level`,e.level.join(`,`)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.q&&t.set(`q`,e.q),e.module&&t.set(`module`,e.module),e.requestId&&t.set(`requestId`,e.requestId),e.sessionKey&&t.set(`sessionKey`,e.sessionKey),e.sessionId&&t.set(`sessionId`,e.sessionId),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return n?`?${n}`:``}async function G(e){return d(u(`/api/logs${W(e)}`))}async function K(){return(await d(u(`/api/logs/files`))).files??[]}async function q(){return(await d(u(`/api/logs/modules`))).modules??[]}async function J(){let e=await d(u(`/api/logs/stats`));return{byLevel:e.byLevel??{},runtime:e.runtime}}async function Y(){return(await d(u(`/api/logs/dir`))).dir??``}async function X(){return(await d(u(`/api/logs/level`))).level??`info`}async function Z(e,t){return d(u(`/api/logs/level`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:e,...t==null?{}:{duration:String(t)}})})}async function re(e){let t=new URLSearchParams;e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit!=null&&t.set(`limit`,String(e.limit));let n=t.toString();return(await d(u(`/api/logs/errors/summary${n?`?${n}`:``}`))).items??[]}var ie=500,ae=class{_token;_callbacks;_abort;constructor(e,t){this._token=e,this._callbacks=t}connect(e,t){this.disconnect();let n=new AbortController;this._abort=n,this._consume(n,e,t)}async _consume(e,t,n){let r=new URL(u(`/api/logs/stream`));t?.length?r.searchParams.set(`levels`,t.join(`,`)):r.searchParams.set(`levels`,`trace,debug,info,warn,error,fatal`),n&&r.searchParams.set(`module`,n);try{let t=new Headers({Accept:`text/event-stream`});this._token&&t.set(`Authorization`,`Bearer ${this._token}`);let n=await fetch(r.toString(),{headers:t,signal:e.signal});if(!n.ok||!n.body)throw Error(`Log stream failed: ${n.status}`);let i=n.body.getReader(),a=new TextDecoder,o=``;for(;!e.signal.aborted;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.indexOf(`
|
|
2
|
-
|
|
3
|
-
`);for(;n>=0;)this._dispatchChunk(o.slice(0,n)),o=o.slice(n+2),n=o.indexOf(`
|
|
4
|
-
|
|
5
|
-
`)}}catch(t){e.signal.aborted||this._callbacks.onError(t instanceof Error?t.message:`Log stream disconnected`)}finally{this._abort===e&&(this._abort=void 0)}}_dispatchChunk(e){let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
|
|
6
|
-
`);if(t)try{let e=JSON.parse(t);if(e.type===`connected`){this._callbacks.onConnected();return}if(e.type===`heartbeat`)return;this._callbacks.onEntry(e)}catch{}}disconnect(){this._abort?.abort(),this._abort=void 0}};function oe(e,t){let n=`${t.timestamp}-${t.requestId??``}-${t.message}`;return[t,...e.filter(e=>`${e.timestamp}-${e.requestId??``}-${e.message}`!==n)].slice(0,ie)}var Q=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`];function se(e){let t=new Date(String(e.timestamp)).getTime();return Number.isFinite(t)?t:0}function ce(e){return e.toSorted((e,t)=>se(t)-se(e))}var le=new Set(Q),ue=[`error`,`fatal`],de=[`warn`,`error`,`fatal`],fe=[`info`,`warn`,`error`,`fatal`];function pe(e){if(!e)return new Set;let t=new Set;for(let n of e.split(`,`)){let e=n.trim();le.has(e)&&t.add(e)}return t}function me(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function he(e,t){return e.size===t.length?t.every(t=>e.has(t)):!1}function ge(e){return e.size===0?`all`:he(e,ue)?`errors`:he(e,de)?`warnPlus`:he(e,fe)?`infoPlus`:e.size===Q.length&&Q.every(t=>e.has(t))?`verbose`:`custom`}function _e(e){let t=ge(e);return t===`custom`?`other`:t}function ve(e){switch(e){case`all`:return new Set;case`errors`:return new Set(ue);case`warnPlus`:return new Set(de);case`infoPlus`:return new Set(fe);case`verbose`:return new Set(Q)}}function ye(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function be(e){return String(e.module||e.service||e.extension||`—`)}function xe(e){if(typeof e.message==`string`&&e.message)return e.message;try{return JSON.stringify(e)}catch{return``}}function Se(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{return e}}function Ce(e){try{return new Date(e).toLocaleString()}catch{return e}}function we(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Te(e){let t=e.trim();return t.length<=10?t:`${t.slice(0,8)}…`}function Ee(e){return String(e).toLowerCase()}function De(e){let t=e.phase??e.meta?.phase;return typeof t==`string`&&t.trim()?t:`—`}function Oe(e){return`${e.timestamp}-${e.requestId??``}-${e.message}`}function ke(e){let t=e.err??e.meta?.err;if(!t||typeof t!=`object`)return null;let n=t;return{name:typeof n.name==`string`?n.name:void 0,message:typeof n.message==`string`?n.message:void 0,stack:typeof n.stack==`string`?n.stack:void 0}}function Ae(e,t){if(t.selectedLevels.size>0&&!t.selectedLevels.has(e.level)||t.moduleFilter&&be(e)!==t.moduleFilter||t.requestIdFilter&&e.requestId!==t.requestIdFilter||t.sessionIdFilter&&e.sessionId!==t.sessionIdFilter&&e.sessionKey!==t.sessionIdFilter)return!1;if(t.dateFrom){let n=new Date(t.dateFrom).getTime(),r=new Date(String(e.timestamp)).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&r<n)return!1}if(t.dateTo){let n=new Date(t.dateTo).getTime(),r=new Date(String(e.timestamp)).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&r>n)return!1}if(t.debouncedSearch){let n=t.debouncedSearch.toLowerCase();if(![e.message,be(e),De(e),e.requestId,e.sessionKey,e.sessionId,ke(e)?.message,ke(e)?.stack].filter(Boolean).map(String).join(` `).toLowerCase().includes(n))return!1}return!0}function je(e,t){let n=[];for(let r of Q){let i=e[r]??0;i>0&&n.push(`${t[r]} ${i}`)}return n.join(` · `)}function Me(e,t){switch(t.type){case`setSearchInput`:return e.searchInput===t.value?e:{...e,searchInput:t.value};case`setDebouncedSearch`:return e.debouncedSearch===t.value?e:{...e,debouncedSearch:t.value};case`setLevels`:return me(e.selectedLevels,t.value)?e:{...e,selectedLevels:t.value};case`toggleLevel`:{let n=new Set(e.selectedLevels);return n.has(t.level)?n.delete(t.level):n.add(t.level),{...e,selectedLevels:n}}case`setModule`:return e.moduleFilter===t.value?e:{...e,moduleFilter:t.value};case`setRequestIdFilter`:return e.requestIdFilter===t.value?e:{...e,requestIdFilter:t.value};case`setSessionIdFilter`:return e.sessionIdFilter===t.value?e:{...e,sessionIdFilter:t.value};case`setDateFrom`:return e.dateFrom===t.value?e:{...e,dateFrom:t.value};case`setDateTo`:return e.dateTo===t.value?e:{...e,dateTo:t.value};case`setAutoRefresh`:return e.autoRefresh===t.value?e:{...e,autoRefresh:t.value};case`syncFromUrl`:{let n=t.payload;return e.searchInput===n.searchInput&&e.debouncedSearch===n.debouncedSearch&&me(e.selectedLevels,n.selectedLevels)&&e.moduleFilter===n.moduleFilter&&e.requestIdFilter===n.requestIdFilter&&e.sessionIdFilter===n.sessionIdFilter&&e.dateFrom===n.dateFrom&&e.dateTo===n.dateTo&&e.autoRefresh===n.autoRefresh?e:{...e,...n}}case`clearAll`:return{searchInput:``,debouncedSearch:``,selectedLevels:new Set,moduleFilter:``,requestIdFilter:``,sessionIdFilter:``,dateFrom:``,dateTo:``,autoRefresh:e.autoRefresh}}}var Ne={logs:[],loading:!1,error:null,hasMore:!1,modules:[],files:[],stats:null,logDir:null};function Pe(e,t){switch(t.type){case`queryStart`:return{...e,loading:!0,error:null,logs:[]};case`querySuccess`:return{...e,loading:!1,logs:ce(t.logs),hasMore:t.hasMore};case`queryError`:return t.resetLogs?{...e,loading:!1,error:t.message,logs:[],hasMore:!1}:{...e,loading:!1,error:t.message};case`appendSuccess`:return{...e,loading:!1,logs:ce([...e.logs,...t.logs]),hasMore:t.hasMore};case`metaSuccess`:return{...e,modules:t.modules,stats:t.stats,files:t.files};case`filesSuccess`:return{...e,files:t.files,logDir:t.logDir};case`filesClear`:return{...e,files:[]};case`liveTick`:return{...e,logs:ce(t.logs),hasMore:t.hasMore,stats:t.stats};case`appendLiveEntry`:return{...e,logs:ce(oe(e.logs,t.entry))};case`updateStats`:return{...e,stats:t.stats};case`refreshAllSuccess`:return{...e,loading:!1,logs:ce(t.logs),hasMore:t.hasMore,stats:t.stats,files:t.files}}}function Fe(e){let t=s(e).logs,n=c(e=>e.token),r=!!n,[a,o]=i(),l=(0,H.useRef)(a),[u,d]=(0,H.useReducer)(Me,void 0,()=>{let e=l.current,t=e.get(`q`)??``;return{searchInput:t,debouncedSearch:t.trim(),selectedLevels:pe(e.get(`level`)),moduleFilter:e.get(`module`)??``,requestIdFilter:e.get(`requestId`)??``,sessionIdFilter:e.get(`sessionId`)??``,dateFrom:e.get(`from`)??``,dateTo:e.get(`to`)??``,autoRefresh:e.get(`live`)===`1`}}),[f,p]=(0,H.useReducer)(Pe,Ne),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)([]),[w,T]=(0,H.useState)(!1),{searchInput:E,debouncedSearch:D,selectedLevels:k,moduleFilter:A,requestIdFilter:j,sessionIdFilter:M,dateFrom:N,dateTo:P,autoRefresh:F}=u,{logs:I,loading:L,error:R,hasMore:z,modules:B,files:ee,stats:te,logDir:ne}=f,V=(0,H.useCallback)(e=>d({type:`setSearchInput`,value:e}),[]),U=(0,H.useCallback)(e=>d({type:`setLevels`,value:e}),[]),W=(0,H.useCallback)(e=>d({type:`setModule`,value:e}),[]),X=(0,H.useCallback)(e=>d({type:`setRequestIdFilter`,value:e}),[]),Z=(0,H.useCallback)(e=>d({type:`setSessionIdFilter`,value:e}),[]),ie=(0,H.useCallback)(e=>d({type:`setDateFrom`,value:e}),[]),oe=(0,H.useCallback)(e=>d({type:`setDateTo`,value:e}),[]),Q=(0,H.useCallback)(e=>d({type:`setAutoRefresh`,value:e}),[]),se=(0,H.useMemo)(()=>_e(k),[k]),ce=e=>{if(e===`other`){y(!0);return}d({type:`setLevels`,value:ve(e)})},le=D.length>0||k.size>0||!!A||!!j||!!M||!!N||!!P,ue=+(D.length>0)+ +(k.size>0)+ +!!A+ +!!j+ +!!M+(N||P?1:0);(0,H.useEffect)(()=>{let e=setTimeout(()=>d({type:`setDebouncedSearch`,value:E.trim()}),300);return()=>clearTimeout(e)},[E]),(0,H.useEffect)(()=>{let e=a.get(`q`)??``;d({type:`syncFromUrl`,payload:{searchInput:e,debouncedSearch:e.trim(),selectedLevels:pe(a.get(`level`)),moduleFilter:a.get(`module`)??``,requestIdFilter:a.get(`requestId`)??``,sessionIdFilter:a.get(`sessionId`)??``,dateFrom:a.get(`from`)??``,dateTo:a.get(`to`)??``,autoRefresh:a.get(`live`)===`1`}})},[a]),(0,H.useEffect)(()=>{let e=new URLSearchParams(a),t=D.trim();t?e.set(`q`,t):e.delete(`q`),k.size>0?e.set(`level`,Array.from(k).sort().join(`,`)):e.delete(`level`),A?e.set(`module`,A):e.delete(`module`),j?e.set(`requestId`,j):e.delete(`requestId`),M?e.set(`sessionId`,M):e.delete(`sessionId`),N?e.set(`from`,N):e.delete(`from`),P?e.set(`to`,P):e.delete(`to`),F?e.set(`live`,`1`):e.delete(`live`),e.toString()!==a.toString()&&o(e,{replace:!0})},[F,N,P,D,A,j,M,a,k,o]);let de=(0,H.useMemo)(()=>({q:D||void 0,level:k.size>0?Array.from(k):void 0,module:A||void 0,requestId:j||void 0,sessionId:M||void 0,from:N||void 0,to:P||void 0,limit:50}),[D,k,A,j,M,N,P]),fe=(0,H.useMemo)(()=>({debouncedSearch:D,selectedLevels:k,moduleFilter:A,requestIdFilter:j,sessionIdFilter:M,dateFrom:N,dateTo:P}),[D,k,A,j,M,N,P]),me=(0,H.useRef)(fe);return me.current=fe,(0,H.useEffect)(()=>{if(!r)return;let e=!1;return T(!0),re({from:N||void 0,to:P||void 0,limit:12}).then(t=>{e||C(t)}).catch(()=>{e||C([])}).finally(()=>{e||T(!1)}),()=>{e=!0}},[r,N,P]),(0,H.useEffect)(()=>{if(!r)return;let e=!1;return p({type:`queryStart`}),(async()=>{try{let t=await G({...de,offset:0});if(e)return;p({type:`querySuccess`,logs:t.logs,hasMore:t.logs.length===50})}catch(n){e||p({type:`queryError`,message:n instanceof Error?n.message:t.loadError,resetLogs:!0})}})(),()=>{e=!0}},[r,de,t.loadError]),(0,H.useEffect)(()=>{if(!r)return;let e=!1;return(async()=>{try{let[t,n,r]=await Promise.all([q(),J(),K()]);e||p({type:`metaSuccess`,modules:t,stats:n,files:r})}catch{}})(),()=>{e=!0}},[r]),(0,H.useEffect)(()=>{if(!r||!g)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([K(),Y()]);e||p({type:`filesSuccess`,files:t,logDir:n})}catch{e||p({type:`filesClear`})}})(),()=>{e=!0}},[r,g]),(0,H.useEffect)(()=>{if(!F||!r)return;let e=new ae(n??void 0,{onConnected:()=>{},onEntry:e=>{Ae(e,me.current)&&p({type:`appendLiveEntry`,entry:e})},onError:()=>{}});e.connect(k.size>0?Array.from(k):void 0,A||void 0);let t=window.setInterval(()=>{J().then(e=>{p({type:`updateStats`,stats:e})}).catch(()=>{})},3e4);return()=>{e.disconnect(),clearInterval(t)}},[F,r,n,k,A]),(0,H.useEffect)(()=>{if(!b)return;let e=window.setTimeout(()=>x(null),2e3);return()=>clearTimeout(e)},[b]),{L:t,hasToken:r,logs:I,loading:L,error:R,hasMore:z,searchInput:E,setSearchInput:V,selectedLevels:k,setSelectedLevels:U,moduleFilter:A,setModuleFilter:W,requestIdFilter:j,sessionIdFilter:M,dateFrom:N,setDateFrom:ie,dateTo:P,setDateTo:oe,modules:B,files:ee,stats:te,selectedLog:m,setSelectedLog:h,filesOpen:g,setFilesOpen:_,filtersOpen:v,setFiltersOpen:y,logDir:ne,autoRefresh:F,setAutoRefresh:Q,copiedDetail:b,setCopiedDetail:x,hasActiveFilters:le,activeFilterCount:ue,clearFilters:()=>d({type:`clearAll`}),toggleDialogLevel:e=>d({type:`toggleLevel`,level:e}),handleLoadMore:()=>{L||!z||(async()=>{p({type:`queryStart`});try{let e=await G({...de,offset:I.length});p({type:`appendSuccess`,logs:e.logs,hasMore:e.logs.length===50})}catch(e){p({type:`queryError`,message:e instanceof Error?e.message:t.loadError})}})()},refreshAll:()=>{(async()=>{p({type:`queryStart`});try{let e=await G({...de,offset:0}),[t,n]=await Promise.all([J(),K()]);p({type:`refreshAllSuccess`,logs:e.logs,hasMore:e.logs.length===50,stats:t,files:n})}catch(e){p({type:`queryError`,message:e instanceof Error?e.message:t.loadError})}})()},levelSegment:se,handleLevelSegment:ce,filterByRequestId:(0,H.useCallback)(e=>{h(null),X(e)},[X]),filterBySessionId:(0,H.useCallback)(e=>{h(null),Z(e)},[Z]),filterByErrorSummary:(0,H.useCallback)(e=>{d({type:`setSearchInput`,value:e.errName}),d({type:`setDebouncedSearch`,value:e.errName}),e.module&&d({type:`setModule`,value:e.module}),d({type:`setLevels`,value:ve(`errors`)})},[]),openChatForSession:(0,H.useCallback)(e=>{let t=e.sessionKey?.trim();if(t){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t}}));return}let n=e.sessionId?.trim();n&&O({sessionId:n}).then(e=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e.sessionKey}}))}).catch(()=>{})},[]),errorSummary:S,errorSummaryLoading:w}}var $=r();function Ie(e){let t=(0,U.c)(36),{L:n,items:r,loading:i,onSelectItem:o}=e,[s,c]=(0,H.useState)(!1);if(!i&&r.length===0)return null;let l;t[0]===r?l=t[1]:(l=r.reduce(Re,0),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>c(Le),t[2]=d):d=t[2];let f;t[3]===n.errorSummaryTitle?f=t[4]:(f=(0,$.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-fg`,children:n.errorSummaryTitle}),t[3]=n.errorSummaryTitle,t[4]=f);let p;t[5]===n.errorSummaryHint?p=t[6]:(p=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:n.errorSummaryHint}),t[5]=n.errorSummaryHint,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==r.length||t[11]!==i||t[12]!==u?(h=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{className:`h-5 w-8 rounded-md`}),(0,$.jsx)(B,{className:`h-5 w-10 rounded-md`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs tabular-nums text-red-600 dark:text-red-400`,children:r.length}),(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-2 py-0.5 text-xs tabular-nums text-fg-muted`,children:[`×`,u]})]}),t[10]=r.length,t[11]=i,t[12]=u,t[13]=h):h=t[13];let g=s&&`rotate-180`,_;t[14]===g?_=t[15]:(_=a(`size-4 text-fg-muted transition-transform duration-150 ease-out motion-reduce:transition-none`,g),t[14]=g,t[15]=_);let v;t[16]===_?v=t[17]:(v=(0,$.jsx)(w,{className:_,strokeWidth:1.75,"aria-hidden":!0}),t[16]=_,t[17]=v);let y;t[18]!==h||t[19]!==v?(y=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[h,v]}),t[18]=h,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==s||t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:d,"aria-expanded":s,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset`,children:[m,y]}),t[21]=s,t[22]=y,t[23]=m,t[24]=b):b=t[24];let x;t[25]!==n.module||t[26]!==n.phase||t[27]!==n.time||t[28]!==s||t[29]!==r||t[30]!==i||t[31]!==o?(x=s&&!i&&r.length>0?(0,$.jsx)(`ul`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle dark:divide-edge dark:border-edge`,children:r.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o?.(e),className:a(`flex w-full flex-col gap-1 px-4 py-2.5 text-left transition-colors hover:bg-surface-hover`,o&&`cursor-pointer`),children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.errName}),(0,$.jsxs)(`span`,{className:`shrink-0 rounded-md bg-red-500/10 px-2 py-0.5 text-xs tabular-nums text-red-600 dark:text-red-400`,children:[`×`,e.count]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[e.phase?(0,$.jsxs)(`span`,{children:[n.phase,`: `,e.phase]}):null,e.module?(0,$.jsxs)(`span`,{children:[n.module,`: `,e.module]}):null,(0,$.jsxs)(`span`,{children:[n.time,`: `,Se(e.lastSeen)]})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.sampleMessage})]})},e.key))}):null,t[25]=n.module,t[26]=n.phase,t[27]=n.time,t[28]=s,t[29]=r,t[30]=i,t[31]=o,t[32]=x):x=t[32];let S;return t[33]!==b||t[34]!==x?(S=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[b,x]}),t[33]=b,t[34]=x,t[35]=S):S=t[35],S}function Le(e){return!e}function Re(e,t){return e+t.count}function ze(e){let t=(0,U.c)(75),{log:n,labels:r,onFilterByRequestId:i,onFilterBySessionId:o,onOpenChat:s}=e,c=n.level??`info`,l=typeof n.requestId==`string`?n.requestId:``,u=typeof n.sessionKey==`string`?n.sessionKey:``,d=typeof n.sessionId==`string`?n.sessionId:``,f;t[0]===n?f=t[1]:(f=De(n),t[0]=n,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=ke(n),t[2]=n,t[3]=m);let h=m,g=c===`error`||c===`fatal`,_;t[4]===r.message?_=t[5]:(_=(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.message}),t[4]=r.message,t[5]=_);let v=g&&`border-red-500/40`,y;t[6]===v?y=t[7]:(y=a(`mt-2 whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,v),t[6]=v,t[7]=y);let b=n.message||`—`,x;t[8]!==y||t[9]!==b?(x=(0,$.jsx)(`pre`,{className:y,children:b}),t[8]=y,t[9]=b,t[10]=x):x=t[10];let S;t[11]!==_||t[12]!==x?(S=(0,$.jsxs)(`div`,{children:[_,x]}),t[11]=_,t[12]=x,t[13]=S):S=t[13];let C;t[14]!==h||t[15]!==r.stackTrace?(C=h?.stack?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.stackTrace}),h.name?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:h.name}):null,(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-red-500/30 bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-red-500/30`,children:h.stack})]}):null,t[14]=h,t[15]=r.stackTrace,t[16]=C):C=t[16];let w;t[17]===r.time?w=t[18]:(w=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.time}),t[17]=r.time,t[18]=w);let T;t[19]===n.timestamp?T=t[20]:(T=(0,$.jsx)(`code`,{className:`break-all text-fg`,children:n.timestamp}),t[19]=n.timestamp,t[20]=T);let E;t[21]===r.level?E=t[22]:(E=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.level}),t[21]=r.level,t[22]=E);let D=g&&`font-medium text-red-600 dark:text-red-400`,O;t[23]===D?O=t[24]:(O=a(`text-fg`,D),t[23]=D,t[24]=O);let k;t[25]===c?k=t[26]:(k=Ee(c),t[25]=c,t[26]=k);let A;t[27]!==O||t[28]!==k?(A=(0,$.jsx)(`span`,{className:O,children:k}),t[27]=O,t[28]=k,t[29]=A):A=t[29];let j;t[30]===r.module?j=t[31]:(j=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.module}),t[30]=r.module,t[31]=j);let M;t[32]===n?M=t[33]:(M=be(n),t[32]=n,t[33]=M);let P;t[34]===M?P=t[35]:(P=(0,$.jsx)(`code`,{className:`break-all text-fg`,children:M}),t[34]=M,t[35]=P);let F;t[36]!==r.phase||t[37]!==p?(F=p===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.phase}),(0,$.jsx)(`code`,{className:`break-all text-fg`,children:p})]}),t[36]=r.phase,t[37]=p,t[38]=F):F=t[38];let I;t[39]!==r.filterByRequestId||t[40]!==r.requestId||t[41]!==i||t[42]!==l?(I=l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.requestId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:l}),i?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>i(l),children:r.filterByRequestId}):null]})]}):null,t[39]=r.filterByRequestId,t[40]=r.requestId,t[41]=i,t[42]=l,t[43]=I):I=t[43];let L;t[44]!==r.openChat||t[45]!==r.sessionKey||t[46]!==s||t[47]!==u?(L=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.sessionKey}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:u}),s?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>s({sessionKey:u}),children:r.openChat}):null]})]}):null,t[44]=r.openChat,t[45]=r.sessionKey,t[46]=s,t[47]=u,t[48]=L):L=t[48];let R;t[49]!==r.filterBySessionId||t[50]!==r.openChat||t[51]!==r.sessionId||t[52]!==o||t[53]!==s||t[54]!==d?(R=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.sessionId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:d}),o?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>o(d),children:r.filterBySessionId}):null,s?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>s({sessionId:d}),children:r.openChat}):null]})]}):null,t[49]=r.filterBySessionId,t[50]=r.openChat,t[51]=r.sessionId,t[52]=o,t[53]=s,t[54]=d,t[55]=R):R=t[55];let z;t[56]!==w||t[57]!==T||t[58]!==E||t[59]!==A||t[60]!==j||t[61]!==P||t[62]!==F||t[63]!==I||t[64]!==L||t[65]!==R?(z=(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-2 text-xs`,children:[w,T,E,A,j,P,F,I,L,R]}),t[56]=w,t[57]=T,t[58]=E,t[59]=A,t[60]=j,t[61]=P,t[62]=F,t[63]=I,t[64]=L,t[65]=R,t[66]=z):z=t[66];let B;t[67]!==r.metadata||t[68]!==n.meta?(B=n.meta&&Object.keys(n.meta).length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.metadata}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,children:JSON.stringify(n.meta,null,2)})]}):null,t[67]=r.metadata,t[68]=n.meta,t[69]=B):B=t[69];let ee;return t[70]!==z||t[71]!==B||t[72]!==S||t[73]!==C?(ee=(0,$.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[S,C,z,B]}),t[70]=z,t[71]=B,t[72]=S,t[73]=C,t[74]=ee):ee=t[74],ee}function Be(e){let t=(0,U.c)(50),{L:n,log:r,onClose:i,copiedDetail:s,onCopiedMessage:c,onCopiedJson:l,onFilterByRequestId:u,onFilterBySessionId:d,onOpenChat:p}=e,h=r!==null,g;t[0]===i?g=t[1]:(g=e=>!e&&i(),t[0]=i,t[1]=g);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(x,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ee)}),t[2]=_):_=t[2];let y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=a(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,P,`dark:border-edge`),t[3]=y):y=t[3];let b;t[4]===n.details?b=t[5]:(b=(0,$.jsx)(m,{className:`text-base font-semibold tracking-tight text-fg`,children:n.details}),t[4]=n.details,t[5]=b);let w;t[6]!==n.copied||t[7]!==n.copyJson||t[8]!==n.copyMessage||t[9]!==s||t[10]!==r||t[11]!==l||t[12]!==c?(w=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{o(typeof r.message==`string`?r.message:``).then(e=>{e&&c()})},children:[(0,$.jsx)(T,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s===`message`?n.copied:n.copyMessage})]}),(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{o(JSON.stringify(r,null,2)).then(e=>{e&&l()})},children:[(0,$.jsx)(T,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s===`json`?n.copied:n.copyJson})]})]}):null,t[6]=n.copied,t[7]=n.copyJson,t[8]=n.copyMessage,t[9]=s,t[10]=r,t[11]=l,t[12]=c,t[13]=w):w=t[13];let E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(v,{className:`size-5`,strokeWidth:1.75}),t[14]=E):E=t[14];let D;t[15]===n.close?D=t[16]:(D=(0,$.jsx)(f,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:E})}),t[15]=n.close,t[16]=D);let O;t[17]!==w||t[18]!==D?(O=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[w,D]}),t[17]=w,t[18]=D,t[19]=O):O=t[19];let k;t[20]!==b||t[21]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[b,O]}),t[20]=b,t[21]=O,t[22]=k):k=t[22];let A;t[23]!==n.filterByRequestId||t[24]!==n.filterBySessionId||t[25]!==n.level||t[26]!==n.message||t[27]!==n.metadata||t[28]!==n.module||t[29]!==n.openChat||t[30]!==n.phase||t[31]!==n.requestId||t[32]!==n.sessionId||t[33]!==n.sessionKey||t[34]!==n.stackTrace||t[35]!==n.time||t[36]!==r||t[37]!==u||t[38]!==d||t[39]!==p?(A=r?(0,$.jsx)(ze,{log:r,labels:{time:n.time,level:n.level,module:n.module,message:n.message,metadata:n.metadata,requestId:n.requestId,sessionKey:n.sessionKey,sessionId:n.sessionId,phase:n.phase,stackTrace:n.stackTrace,filterByRequestId:n.filterByRequestId,filterBySessionId:n.filterBySessionId,openChat:n.openChat},onFilterByRequestId:u,onFilterBySessionId:d,onOpenChat:p}):null,t[23]=n.filterByRequestId,t[24]=n.filterBySessionId,t[25]=n.level,t[26]=n.message,t[27]=n.metadata,t[28]=n.module,t[29]=n.openChat,t[30]=n.phase,t[31]=n.requestId,t[32]=n.sessionId,t[33]=n.sessionKey,t[34]=n.stackTrace,t[35]=n.time,t[36]=r,t[37]=u,t[38]=d,t[39]=p,t[40]=A):A=t[40];let j;t[41]===A?j=t[42]:(j=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 font-mono text-sm leading-relaxed`,children:A}),t[41]=A,t[42]=j);let M;t[43]!==k||t[44]!==j?(M=(0,$.jsxs)(C,{children:[_,(0,$.jsxs)(S,{className:y,"aria-describedby":void 0,children:[k,j]})]}),t[43]=k,t[44]=j,t[45]=M):M=t[45];let F;return t[46]!==h||t[47]!==M||t[48]!==g?(F=(0,$.jsx)(ne,{open:h,onOpenChange:g,children:M}),t[46]=h,t[47]=M,t[48]=g,t[49]=F):F=t[49],F}function Ve(e){let t=(0,U.c)(25),{L:n,open:r,onOpenChange:i,files:o,logDir:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(x,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ee)}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=a(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(32rem,85vh)] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,P,`dark:border-edge`),t[1]=l):l=t[1];let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(_,{className:`size-4 text-fg-muted`,strokeWidth:1.75}),t[2]=u):u=t[2];let d;t[3]===n.logFiles?d=t[4]:(d=(0,$.jsxs)(m,{className:`flex items-center gap-2 text-base font-semibold tracking-tight text-fg`,children:[u,n.logFiles]}),t[3]=n.logFiles,t[4]=d);let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(v,{className:`size-5`,strokeWidth:1.75}),t[5]=p):p=t[5];let h;t[6]===n.close?h=t[7]:(h=(0,$.jsx)(f,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:p})}),t[6]=n.close,t[7]=h);let g;t[8]!==d||t[9]!==h?(g=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[d,h]}),t[8]=d,t[9]=h,t[10]=g):g=t[10];let y;t[11]!==n.filesEmpty||t[12]!==o?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:o.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.filesEmpty}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:o.map(He)})}),t[11]=n.filesEmpty,t[12]=o,t[13]=y):y=t[13];let b;t[14]!==n.logDir||t[15]!==s?(b=s?(0,$.jsxs)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-2 text-xs text-fg-subtle dark:border-edge`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[n.logDir,`: `]}),(0,$.jsx)(`code`,{className:`break-all text-fg-subtle`,children:s})]}):null,t[14]=n.logDir,t[15]=s,t[16]=b):b=t[16];let w;t[17]!==g||t[18]!==y||t[19]!==b?(w=(0,$.jsxs)(C,{children:[c,(0,$.jsxs)(S,{className:l,children:[g,y,b]})]}),t[17]=g,t[18]=y,t[19]=b,t[20]=w):w=t[20];let T;return t[21]!==i||t[22]!==r||t[23]!==w?(T=(0,$.jsx)(ne,{open:r,onOpenChange:i,children:w}),t[21]=i,t[22]=r,t[23]=w,t[24]=T):T=t[24],T}function He(e){return(0,$.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 dark:border-edge`,children:[(0,$.jsx)(`span`,{className:`break-all font-mono text-xs text-fg`,children:e.name}),(0,$.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:we(e.size)}),(0,$.jsx)(`span`,{children:Ce(e.modified)})]})]},e.name)}function Ue(e){let t=(0,U.c)(68),{L:n,open:r,onOpenChange:i,dateFrom:o,onDateFromChange:s,dateTo:c,onDateToChange:l,selectedLevels:u,onToggleLevel:d}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(x,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ee)}),t[0]=p):p=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=a(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(32rem,90vh)] w-[min(100%-2rem,22rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,P,`dark:border-edge`),t[1]=h):h=t[1];let g;t[2]===n.filtersDialogTitle?g=t[3]:(g=(0,$.jsx)(m,{className:`text-base font-semibold tracking-tight text-fg`,children:n.filtersDialogTitle}),t[2]=n.filtersDialogTitle,t[3]=g);let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(v,{className:`size-5`,strokeWidth:1.75}),t[4]=_):_=t[4];let y;t[5]===n.close?y=t[6]:(y=(0,$.jsx)(f,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:_})}),t[5]=n.close,t[6]=y);let b;t[7]!==g||t[8]!==y?(b=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[g,y]}),t[7]=g,t[8]=y,t[9]=b):b=t[9];let w;t[10]===n.filtersDialogDesc?w=t[11]:(w=(0,$.jsx)(`div`,{id:`log-filters-desc`,className:`sr-only`,children:n.filtersDialogDesc}),t[10]=n.filtersDialogDesc,t[11]=w);let T;t[12]===n.timeRange?T=t[13]:(T=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.timeRange}),t[12]=n.timeRange,t[13]=T);let E;t[14]===n.from?E=t[15]:(E=(0,$.jsx)(`label`,{htmlFor:`log-from-d`,className:`mb-1 block text-xs text-fg-muted`,children:n.from}),t[14]=n.from,t[15]=E);let D;t[16]===s?D=t[17]:(D=e=>s(e.target.value),t[16]=s,t[17]=D);let O;t[18]!==o||t[19]!==D?(O=(0,$.jsx)(`input`,{id:`log-from-d`,type:`datetime-local`,value:o,onChange:D,className:`w-full rounded-xl border border-edge bg-surface-base p-2 text-sm text-fg dark:border-edge`}),t[18]=o,t[19]=D,t[20]=O):O=t[20];let k;t[21]!==O||t[22]!==E?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[21]=O,t[22]=E,t[23]=k):k=t[23];let A;t[24]===n.to?A=t[25]:(A=(0,$.jsx)(`label`,{htmlFor:`log-to-d`,className:`mb-1 block text-xs text-fg-muted`,children:n.to}),t[24]=n.to,t[25]=A);let j;t[26]===l?j=t[27]:(j=e=>l(e.target.value),t[26]=l,t[27]=j);let M;t[28]!==c||t[29]!==j?(M=(0,$.jsx)(`input`,{id:`log-to-d`,type:`datetime-local`,value:c,onChange:j,className:`w-full rounded-xl border border-edge bg-surface-base p-2 text-sm text-fg dark:border-edge`}),t[28]=c,t[29]=j,t[30]=M):M=t[30];let F;t[31]!==A||t[32]!==M?(F=(0,$.jsxs)(`div`,{children:[A,M]}),t[31]=A,t[32]=M,t[33]=F):F=t[33];let I;t[34]!==k||t[35]!==F?(I=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[k,F]}),t[34]=k,t[35]=F,t[36]=I):I=t[36];let L;t[37]===n.levelCustom?L=t[38]:(L=(0,$.jsx)(`p`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:n.levelCustom}),t[37]=n.levelCustom,t[38]=L);let R;t[39]===n.levelCustomHint?R=t[40]:(R=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:n.levelCustomHint}),t[39]=n.levelCustomHint,t[40]=R);let z=n.level,B;t[41]!==n.levelNames||t[42]!==d||t[43]!==u?(B=Q.map(e=>(0,$.jsx)(`button`,{type:`button`,className:a(`rounded-full border px-3 py-1.5 text-xs font-medium capitalize transition-[color,background-color,border-color] 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-panel`,u.has(e)?`border-edge bg-surface-active text-fg dark:border-edge`:`border-edge-subtle bg-surface-base text-fg-muted hover:bg-surface-hover dark:border-edge`),onClick:()=>d(e),children:n.levelNames[e]},e)),t[41]=n.levelNames,t[42]=d,t[43]=u,t[44]=B):B=t[44];let te;t[45]!==n.level||t[46]!==B?(te=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`group`,"aria-label":z,children:B}),t[45]=n.level,t[46]=B,t[47]=te):te=t[47];let V;t[48]!==I||t[49]!==L||t[50]!==R||t[51]!==te||t[52]!==T?(V=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[T,I,L,R,te]}),t[48]=I,t[49]=L,t[50]=R,t[51]=te,t[52]=T,t[53]=V):V=t[53];let H;t[54]===i?H=t[55]:(H=()=>i(!1),t[54]=i,t[55]=H);let W;t[56]!==n.filtersDone||t[57]!==H?(W=(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,$.jsx)(N,{type:`button`,className:`w-full rounded-xl`,onClick:H,children:n.filtersDone})}),t[56]=n.filtersDone,t[57]=H,t[58]=W):W=t[58];let G;t[59]!==V||t[60]!==W||t[61]!==b||t[62]!==w?(G=(0,$.jsxs)(C,{children:[p,(0,$.jsxs)(S,{className:h,"aria-describedby":`log-filters-desc`,children:[b,w,V,W]})]}),t[59]=V,t[60]=W,t[61]=b,t[62]=w,t[63]=G):G=t[63];let K;return t[64]!==i||t[65]!==r||t[66]!==G?(K=(0,$.jsx)(ne,{open:r,onOpenChange:i,children:G}),t[64]=i,t[65]=r,t[66]=G,t[67]=K):K=t[67],K}var We=1;function Ge(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;return i===t?{x:n,y:r}:null}var Ke=`pointer-events-none absolute left-0 top-0 z-[1] rounded-pill bg-surface-panel shadow-sm will-change-transform [backface-visibility:hidden] dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,qe=`relative z-[2] box-border flex h-6 min-h-0 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] 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-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function Je({value:e,onChange:t,options:n,"aria-label":r,className:i,buttonClassName:o}){let s=(0,H.useRef)(null),c=(0,H.useRef)([]),[l,u]=(0,H.useState)({x:0,y:0,w:0,h:0}),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),h=(0,H.useCallback)(()=>{let t=s.current;if(!t)return;let r=n.findIndex(t=>t.value===e);if(r<0)return;let i=c.current[r];if(!i)return;let a=We,o=t.getBoundingClientRect(),l=i.getBoundingClientRect(),d=Ge(i,t),p,m;if(d)p=d.x,m=d.y;else{let e=getComputedStyle(t),n=parseFloat(e.borderLeftWidth)||0,r=parseFloat(e.borderTopWidth)||0;p=l.left-o.left-n,m=l.top-o.top-r}u({x:p+a,y:m+a,w:Math.max(0,l.width-a*2),h:Math.max(0,l.height-a*2)}),f(!0)},[n,e]),g=(0,H.useRef)(h);return g.current=h,(0,H.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>h());return()=>cancelAnimationFrame(e)},[h]),(0,H.useEffect)(()=>{let e=requestAnimationFrame(()=>{requestAnimationFrame(()=>m(!0))});return()=>cancelAnimationFrame(e)},[]),(0,H.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{requestAnimationFrame(()=>g.current())},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,$.jsxs)(`div`,{ref:s,className:a(V,`relative isolate flex w-full max-w-full flex-row items-center`,i),role:`group`,"aria-label":r,children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:a(Ke,`motion-reduce:!transition-none motion-reduce:!duration-0`,p&&`transition-[transform,width,height] duration-300 [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]`),style:{width:l.w,height:l.h,transform:`translate3d(${l.x}px, ${l.y}px, 0)`,opacity:d&&l.w>0?1:0}}),n.map((n,r)=>{let i=n.icon,s=e===n.value;return(0,$.jsxs)(`button`,{ref:e=>{c.current[r]=e},type:`button`,"aria-pressed":s,title:n.title??n.label,onClick:()=>t(n.value),className:a(qe,s?`text-fg`:`text-fg-subtle`,o),children:[i?(0,$.jsx)(i,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:n.label})]},n.value)})]})}function Ye(e){let t=(0,U.c)(76),{L:n,levelSegment:r,onLevelSegment:i,searchInput:o,onSearchInputChange:s,moduleFilter:c,onModuleFilterChange:l,modules:u,onOpenFilters:d,activeFilterCount:f,hasActiveFilters:m,onClearFilters:h,autoRefresh:g}=e,_=n.filters,y;t[0]===n.presetAll?y=t[1]:(y={value:`all`,label:n.presetAll},t[0]=n.presetAll,t[1]=y);let b;t[2]===n.presetErrors?b=t[3]:(b={value:`errors`,label:n.presetErrors},t[2]=n.presetErrors,t[3]=b);let x;t[4]===n.presetWarnPlus?x=t[5]:(x={value:`warnPlus`,label:n.presetWarnPlus},t[4]=n.presetWarnPlus,t[5]=x);let S;t[6]===n.presetInfoPlus?S=t[7]:(S={value:`infoPlus`,label:n.presetInfoPlus},t[6]=n.presetInfoPlus,t[7]=S);let C;t[8]===n.presetVerbose?C=t[9]:(C={value:`verbose`,label:n.presetVerbose},t[8]=n.presetVerbose,t[9]=C);let w;t[10]===n.presetOther?w=t[11]:(w={value:`other`,label:n.presetOther},t[10]=n.presetOther,t[11]=w);let T;t[12]!==y||t[13]!==b||t[14]!==x||t[15]!==S||t[16]!==C||t[17]!==w?(T=[y,b,x,S,C,w],t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==n.levelPresetAria||t[20]!==r||t[21]!==i||t[22]!==T?(E=(0,$.jsx)(`div`,{className:`overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:(0,$.jsx)(`div`,{className:`min-w-[min(100%,36rem)]`,children:(0,$.jsx)(Je,{"aria-label":n.levelPresetAria,value:r,onChange:i,options:T,buttonClassName:`h-8 px-1.5 text-[11px] sm:px-2 sm:text-xs`})})}),t[19]=n.levelPresetAria,t[20]=r,t[21]=i,t[22]=T,t[23]=E):E=t[23];let D;t[24]===n.searchPlaceholder?D=t[25]:(D=(0,$.jsx)(`span`,{className:`sr-only`,children:n.searchPlaceholder}),t[24]=n.searchPlaceholder,t[25]=D);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=O):O=t[26];let A;t[27]===s?A=t[28]:(A=e=>s(e.target.value),t[27]=s,t[28]=A);let M=n.searchPlaceholder,P;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(P=a(`h-10 w-full rounded-md border border-edge bg-surface-panel py-0 pl-10 pr-3 text-sm leading-5 text-fg placeholder:text-fg-subtle dark:border-edge`,te),t[29]=P):P=t[29];let F;t[30]!==n.searchPlaceholder||t[31]!==o||t[32]!==A?(F=(0,$.jsx)(`input`,{type:`search`,value:o,onChange:A,placeholder:M,autoComplete:`off`,spellCheck:!1,className:P}),t[30]=n.searchPlaceholder,t[31]=o,t[32]=A,t[33]=F):F=t[33];let L;t[34]!==D||t[35]!==F?(L=(0,$.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:min-w-[12rem]`,children:[D,O,F]}),t[34]=D,t[35]=F,t[36]=L):L=t[36];let z;t[37]===l?z=t[38]:(z=e=>l(e.target.value),t[37]=l,t[38]=z);let B=n.module,ee=n.module,ne;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ne=a(p,`h-10 w-full min-w-0 rounded-md py-0 sm:w-[min(100%,14rem)] sm:shrink-0`),t[39]=ne):ne=t[39];let V;t[40]===n.allModules?V=t[41]:(V=(0,$.jsx)(j,{value:``,children:n.allModules}),t[40]=n.allModules,t[41]=V);let H;t[42]===u?H=t[43]:(H=u.map(Xe),t[42]=u,t[43]=H);let W;t[44]!==n.module||t[45]!==c||t[46]!==z||t[47]!==V||t[48]!==H?(W=(0,$.jsxs)(I,{id:`log-module`,value:c,onChange:z,"aria-label":B,title:ee,className:ne,children:[V,H]}),t[44]=n.module,t[45]=c,t[46]=z,t[47]=V,t[48]=H,t[49]=W):W=t[49];let G;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(R,{className:`size-4`,strokeWidth:1.75}),t[50]=G):G=t[50];let K;t[51]===f?K=t[52]:(K=f>0?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 text-xs tabular-nums text-fg-muted`,children:f}):null,t[51]=f,t[52]=K);let q;t[53]!==n.filtersMore||t[54]!==d||t[55]!==K?(q=(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`h-10 min-h-[44px] gap-2 rounded-md sm:min-h-10`,onClick:d,children:[G,n.filtersMore,K]}),t[53]=n.filtersMore,t[54]=d,t[55]=K,t[56]=q):q=t[56];let J;t[57]!==n.clear||t[58]!==m||t[59]!==h?(J=m?(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-10 min-h-[44px] gap-1 sm:min-h-10`,onClick:h,children:[(0,$.jsx)(v,{className:`size-4`,strokeWidth:1.75}),n.clear]}):null,t[57]=n.clear,t[58]=m,t[59]=h,t[60]=J):J=t[60];let Y;t[61]!==q||t[62]!==J?(Y=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[q,J]}),t[61]=q,t[62]=J,t[63]=Y):Y=t[63];let X;t[64]!==L||t[65]!==W||t[66]!==Y?(X=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[L,W,Y]}),t[64]=L,t[65]=W,t[66]=Y,t[67]=X):X=t[67];let Z;t[68]!==n.liveHint||t[69]!==g?(Z=g?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:n.liveHint}):null,t[68]=n.liveHint,t[69]=g,t[70]=Z):Z=t[70];let re;return t[71]!==n.filters||t[72]!==X||t[73]!==Z||t[74]!==E?(re=(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,"aria-label":_,children:[E,X,Z]}),t[71]=n.filters,t[72]=X,t[73]=Z,t[74]=E,t[75]=re):re=t[75],re}function Xe(e){return(0,$.jsx)(j,{value:e,children:e},e)}function Ze(e){let t=(0,U.c)(20),{L:n,logs:r,loading:i,hasMore:o,onSelectLog:s,onLoadMore:c,onRefreshAll:l,onFilterByRequestId:u}=e,d;t[0]!==i||t[1]!==r.length?(d=i&&r.length===0?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel shadow-surface`,"aria-busy":`true`,children:Array.from({length:8}).map(Qe)}):null,t[0]=i,t[1]=r.length,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==i||t[5]!==r.length||t[6]!==l?(f=!i&&r.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl bg-surface-base py-16 text-center`,children:[(0,$.jsx)(y,{className:`size-12 text-fg-subtle`,strokeWidth:1.5,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n.noLogs}),(0,$.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:n.noLogsDescription}),(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`mt-4 gap-2`,onClick:l,children:[(0,$.jsx)(b,{className:`size-4`,strokeWidth:1.75}),n.refresh]})]}):null,t[3]=n,t[4]=i,t[5]=r.length,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==n||t[9]!==o||t[10]!==i||t[11]!==r||t[12]!==u||t[13]!==c||t[14]!==s?(p=r.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:[ye(n.showingCount,{count:String(r.length)}),o?(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[` · `,n.moreAvailable]}):null]}),(0,$.jsx)(`ul`,{className:`overflow-hidden rounded-xl bg-surface-panel font-mono text-sm leading-6 shadow-surface`,children:r.map(e=>{let t=e.level??`info`,r=typeof e.requestId==`string`?e.requestId.trim():``,i=De(e),o=t===`error`||t===`fatal`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:a(`flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,o&&`border-l-2 border-l-red-500/70`),children:[(0,$.jsx)(`span`,{className:`w-[5.25rem] shrink-0 tabular-nums text-fg-subtle`,children:Se(e.timestamp)}),(0,$.jsx)(`span`,{className:a(`w-[4.5rem] shrink-0 truncate`,o?`font-medium text-red-600 dark:text-red-400`:`text-fg-muted`),title:t,children:Ee(t)}),(0,$.jsx)(`span`,{className:`w-[4.5rem] shrink-0 truncate sm:w-[5.25rem]`,children:r?u?(0,$.jsx)(`span`,{role:`link`,tabIndex:0,className:`cursor-pointer text-accent hover:underline`,title:`${n.requestId}: ${r}`,onClick:e=>{e.stopPropagation(),u(r)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),u(r))},children:Te(r)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:`${n.requestId}: ${r}`,children:Te(r)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,$.jsx)(`span`,{className:`hidden max-w-[6rem] shrink-0 truncate text-fg-subtle xl:inline`,title:i===`—`?void 0:i,children:i===`—`?`—`:i}),(0,$.jsx)(`span`,{className:`hidden max-w-[7rem] shrink-0 truncate text-fg-muted lg:inline`,title:be(e),children:be(e)}),(0,$.jsx)(`span`,{className:a(`min-w-0 flex-1 truncate`,`text-fg`),children:xe(e)})]})},Oe(e))})}),o?(0,$.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`gap-2`,disabled:i,onClick:c,children:[i?(0,$.jsx)(b,{className:`size-4 animate-spin motion-reduce:animate-none`,strokeWidth:1.75}):(0,$.jsx)(w,{className:`size-4`,strokeWidth:1.75}),n.loadMore]})}):null]}):null,t[8]=n,t[9]=o,t[10]=i,t[11]=r,t[12]=u,t[13]=c,t[14]=s,t[15]=p):p=t[15];let m;return t[16]!==d||t[17]!==f||t[18]!==p?(m=(0,$.jsxs)($.Fragment,{children:[d,f,p]}),t[16]=d,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function Qe(e,t){return(0,$.jsxs)(`div`,{className:`flex gap-3 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`h-4 w-16 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 w-12 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 w-20 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 min-w-0 flex-1 bg-surface-hover motion-reduce:animate-none animate-pulse`})]},t)}function $e(e){let t=(0,U.c)(8),{L:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(g,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r):r=t[0];let i;t[1]===n.title?i=t[2]:(i=(0,$.jsx)(`h1`,{className:`text-base font-semibold tracking-tight text-fg`,children:n.title}),t[1]=n.title,t[2]=i);let a;t[3]===n.needToken?a=t[4]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.needToken}),t[3]=n.needToken,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,$.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-10 sm:px-5 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[r,(0,$.jsxs)(`div`,{children:[i,a]})]})}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function et(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function tt(e){let t=[`timestamp`,`level`,`module`,`phase`,`requestId`,`sessionId`,`message`],n=e.map(e=>{let t=String(e.module||``),n=String(e.phase??e.meta?.phase??``);return[e.timestamp,e.level,t,n,e.requestId??``,e.sessionId??``,e.message??``].map(e=>et(String(e))).join(`,`)});return[t.join(`,`),...n].join(`
|
|
7
|
-
`)}function nt(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}function rt(e,t){let n=new Date().toISOString().replace(/[:.]/g,`-`);if(t===`json`){nt(JSON.stringify(e,null,2),`xopc-logs-${n}.json`,`application/json`);return}nt(tt(e),`xopc-logs-${n}.csv`,`text/csv;charset=utf-8`)}function it(e){let t=(0,U.c)(32),{L:n,logs:r,disabled:i}=e,o=i||r.length===0,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(h,{className:`size-4`,strokeWidth:1.75}),t[0]=s):s=t[0];let c;t[1]===n.exportLogs?c=t[2]:(c=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.exportLogs}),t[1]=n.exportLogs,t[2]=c);let l;t[3]!==n.exportLogs||t[4]!==o||t[5]!==c?(l=(0,$.jsx)(A,{asChild:!0,children:(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`h-9 gap-2 px-3 text-xs`,disabled:o,title:n.exportLogs,children:[s,c]})}),t[3]=n.exportLogs,t[4]=o,t[5]=c,t[6]=l):l=t[6];let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(`w-52 rounded-xl border border-edge bg-surface-panel p-2 shadow-popover outline-none`,E,`dark:border-edge`),t[7]=u):u=t[7];let d;t[8]===n.exportLogs?d=t[9]:(d=(0,$.jsx)(`p`,{className:`px-2 py-1 text-xs font-medium text-fg`,children:n.exportLogs}),t[8]=n.exportLogs,t[9]=d);let f;t[10]===n.exportHint?f=t[11]:(f=(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs leading-5 text-fg-muted`,children:n.exportHint}),t[10]=n.exportHint,t[11]=f);let p;t[12]===r?p=t[13]:(p=()=>rt(r,`json`),t[12]=r,t[13]=p);let m;t[14]!==n.exportJson||t[15]!==p?(m=(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`h-8 justify-start px-2 text-xs`,onClick:p,children:n.exportJson}),t[14]=n.exportJson,t[15]=p,t[16]=m):m=t[16];let g;t[17]===r?g=t[18]:(g=()=>rt(r,`csv`),t[17]=r,t[18]=g);let _;t[19]!==n.exportCsv||t[20]!==g?(_=(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`h-8 justify-start px-2 text-xs`,onClick:g,children:n.exportCsv}),t[19]=n.exportCsv,t[20]=g,t[21]=_):_=t[21];let v;t[22]!==_||t[23]!==m?(v=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m,_]}),t[22]=_,t[23]=m,t[24]=v):v=t[24];let y;t[25]!==v||t[26]!==d||t[27]!==f?(y=(0,$.jsx)(z,{children:(0,$.jsxs)(D,{side:`bottom`,align:`end`,sideOffset:6,className:u,children:[d,f,v]})}),t[25]=v,t[26]=d,t[27]=f,t[28]=y):y=t[28];let b;return t[29]!==y||t[30]!==l?(b=(0,$.jsxs)(F,{children:[l,y]}),t[29]=y,t[30]=l,t[31]=b):b=t[31],b}function at(e){let t=(0,U.c)(38),{L:n}=e,[r,i]=(0,H.useState)(!1),[o,s]=(0,H.useState)(`info`),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(null),f,p;t[0]!==n.logLevelLoadError||t[1]!==r?(f=()=>{if(!r)return;let e=!1;return X().then(t=>{e||s(t)}).catch(t=>{e||d(t instanceof Error?t.message:n.logLevelLoadError)}),()=>{e=!0}},p=[r,n.logLevelLoadError],t[0]=n.logLevelLoadError,t[1]=r,t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,H.useEffect)(f,p);let m;t[4]===n.logLevelSaveError?m=t[5]:(m=e=>{l(!0),d(null),Z(e).then(e=>{s(e.current),i(!1)}).catch(e=>{d(e instanceof Error?e.message:n.logLevelSaveError)}).finally(()=>l(!1))},t[4]=n.logLevelSaveError,t[5]=m);let h=m,g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(M,{className:`size-4`,strokeWidth:1.75}),t[6]=g):g=t[6];let _;t[7]===n.logLevelTitle?_=t[8]:(_=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.logLevelTitle}),t[7]=n.logLevelTitle,t[8]=_);let v;t[9]===o?v=t[10]:(v=(0,$.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:o}),t[9]=o,t[10]=v);let y;t[11]!==n.logLevelTitle||t[12]!==_||t[13]!==v?(y=(0,$.jsx)(A,{asChild:!0,children:(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`h-9 gap-2 px-3 text-xs`,title:n.logLevelTitle,children:[g,_,v]})}),t[11]=n.logLevelTitle,t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=a(`w-56 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover outline-none`,E,`dark:border-edge`),t[15]=b):b=t[15];let x;t[16]===n.logLevelTitle?x=t[17]:(x=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.logLevelTitle}),t[16]=n.logLevelTitle,t[17]=x);let S;t[18]===n.logLevelHint?S=t[19]:(S=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.logLevelHint}),t[18]=n.logLevelHint,t[19]=S);let C;t[20]!==n.levelNames||t[21]!==h||t[22]!==o||t[23]!==c?(C=Q.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>h(e),className:a(`flex w-full items-center justify-between rounded-md px-2 py-1.5 text-left text-xs transition-colors`,o===e?`bg-accent/10 font-medium text-accent`:`text-fg hover:bg-surface-hover`),children:[(0,$.jsx)(`span`,{children:n.levelNames[e]}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] uppercase text-fg-subtle`,children:e})]})},e)),t[20]=n.levelNames,t[21]=h,t[22]=o,t[23]=c,t[24]=C):C=t[24];let w;t[25]===C?w=t[26]:(w=(0,$.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1`,children:C}),t[25]=C,t[26]=w);let T;t[27]===u?T=t[28]:(T=u?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:u}):null,t[27]=u,t[28]=T);let O;t[29]!==S||t[30]!==w||t[31]!==T||t[32]!==x?(O=(0,$.jsx)(z,{children:(0,$.jsxs)(D,{side:`bottom`,align:`end`,sideOffset:6,className:b,children:[x,S,w,T]})}),t[29]=S,t[30]=w,t[31]=T,t[32]=x,t[33]=O):O=t[33];let k;return t[34]!==r||t[35]!==O||t[36]!==y?(k=(0,$.jsxs)(F,{open:r,onOpenChange:i,children:[y,O]}),t[34]=r,t[35]=O,t[36]=y,t[37]=k):k=t[37],k}function ot(e){let t=(0,U.c)(49),{L:n,autoRefresh:r,onAutoRefreshChange:i,fileCount:a,onOpenFiles:o,loading:s,onRefreshAll:c,logs:l}=e,u;t[0]===n.title?u=t[1]:(u=(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),t[0]=n.title,t[1]=u);let d;t[2]===n.subtitle?d=t[3]:(d=(0,$.jsx)(`p`,{className:`mt-0.5 text-sm leading-relaxed text-fg-muted`,children:n.subtitle}),t[2]=n.subtitle,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=r?`live`:`paused`,m;t[7]===i?m=t[8]:(m=e=>i(e===`live`),t[7]=i,t[8]=m);let h;t[9]===n.refreshManual?h=t[10]:(h={value:`paused`,label:n.refreshManual},t[9]=n.refreshManual,t[10]=h);let g;t[11]===n.refreshLive?g=t[12]:(g={value:`live`,label:n.refreshLive},t[11]=n.refreshLive,t[12]=g);let v;t[13]!==h||t[14]!==g?(v=[h,g],t[13]=h,t[14]=g,t[15]=v):v=t[15];let y;t[16]!==n.refreshModeAria||t[17]!==p||t[18]!==m||t[19]!==v?(y=(0,$.jsx)(`div`,{className:`w-full sm:w-48`,children:(0,$.jsx)(Je,{"aria-label":n.refreshModeAria,value:p,onChange:m,options:v,buttonClassName:`h-8`})}),t[16]=n.refreshModeAria,t[17]=p,t[18]=m,t[19]=v,t[20]=y):y=t[20];let b;t[21]===n?b=t[22]:(b=(0,$.jsx)(at,{L:n}),t[21]=n,t[22]=b);let x;t[23]!==n||t[24]!==s||t[25]!==l?(x=(0,$.jsx)(it,{L:n,logs:l,disabled:s}),t[23]=n,t[24]=s,t[25]=l,t[26]=x):x=t[26];let S;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(_,{className:`size-4`,strokeWidth:1.75}),t[27]=S):S=t[27];let C;t[28]===a?C=t[29]:(C=a>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-1.5 text-xs text-fg-muted`,children:a}):null,t[28]=a,t[29]=C);let w;t[30]!==n.logFiles||t[31]!==o||t[32]!==C?(w=(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,title:n.logFiles,"aria-label":n.logFiles,onClick:o,children:[S,C]}),t[30]=n.logFiles,t[31]=o,t[32]=C,t[33]=w):w=t[33];let T;t[34]!==n.refresh||t[35]!==s||t[36]!==c?(T=(0,$.jsx)(L,{className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,loading:s,label:n.refresh,onClick:c}),t[34]=n.refresh,t[35]=s,t[36]=c,t[37]=T):T=t[37];let E;t[38]!==b||t[39]!==x||t[40]!==w||t[41]!==T?(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 self-end sm:self-center`,children:[b,x,w,T]}),t[38]=b,t[39]=x,t[40]=w,t[41]=T,t[42]=E):E=t[42];let D;t[43]!==E||t[44]!==y?(D=(0,$.jsxs)(`div`,{className:`flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:max-w-md sm:flex-row sm:items-center sm:justify-end`,children:[y,E]}),t[43]=E,t[44]=y,t[45]=D):D=t[45];let O;return t[46]!==D||t[47]!==f?(O=(0,$.jsxs)(`header`,{className:`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[f,D]}),t[46]=D,t[47]=f,t[48]=O):O=t[48],O}function st(e){let t=(0,U.c)(33),{L:n,stats:r}=e,i;t[0]===r.byLevel?i=t[1]:(i=r.byLevel??{},t[0]=r.byLevel,t[1]=i);let o;t[2]!==n.levelNames||t[3]!==i?(o=je(i,n.levelNames),t[2]=n.levelNames,t[3]=i,t[4]=o):o=t[4];let s=o,c=r.runtime?.errorsLast24h;if(!s&&c==null)return null;let l;t[5]===n.statsRegion?l=t[6]:(l=(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.statsRegion}),t[5]=n.statsRegion,t[6]=l);let u;t[7]===s?u=t[8]:(u=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:s})]}):null,t[7]=s,t[8]=u);let d;t[9]!==n.runtimeErrors||t[10]!==c?(d=c!=null&&c>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,$.jsxs)(`span`,{className:`tabular-nums text-red-600 dark:text-red-400`,children:[n.runtimeErrors,` `,c]})]}):null,t[9]=n.runtimeErrors,t[10]=c,t[11]=d):d=t[11];let f;t[12]!==l||t[13]!==u||t[14]!==d?(f=(0,$.jsx)(A,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded-lg border border-transparent px-1 py-0.5 text-left text-xs leading-5 text-fg-subtle transition-colors duration-150 ease-out hover:border-edge-subtle hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel dark:hover:border-edge`,children:[l,u,d]})}),t[12]=l,t[13]=u,t[14]=d,t[15]=f):f=t[15];let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=a(`w-[min(calc(100vw-2rem),20rem)] rounded-xl border border-edge bg-surface-panel p-3 shadow-popover outline-none`,E,`dark:border-edge`),t[16]=p):p=t[16];let m;t[17]===n.statsDetailTitle?m=t[18]:(m=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.statsDetailTitle}),t[17]=n.statsDetailTitle,t[18]=m);let h;t[19]===n.statsHint?h=t[20]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.statsHint}),t[19]=n.statsHint,t[20]=h);let g;t[21]!==n.levelNames||t[22]!==r.byLevel?(g=Q.map(e=>{let t=r.byLevel?.[e]??0;return t===0?null:(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs dark:border-edge`,children:[(0,$.jsx)(`span`,{className:`font-medium capitalize text-fg`,children:n.levelNames[e]}),(0,$.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:t})]},e)}),t[21]=n.levelNames,t[22]=r.byLevel,t[23]=g):g=t[23];let _;t[24]===g?_=t[25]:(_=(0,$.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1.5`,children:g}),t[24]=g,t[25]=_);let v;t[26]!==_||t[27]!==m||t[28]!==h?(v=(0,$.jsx)(z,{children:(0,$.jsxs)(D,{side:`bottom`,align:`start`,sideOffset:6,className:p,children:[m,h,_]})}),t[26]=_,t[27]=m,t[28]=h,t[29]=v):v=t[29];let y;return t[30]!==v||t[31]!==f?(y=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(F,{children:[f,v]})}),t[30]=v,t[31]=f,t[32]=y):y=t[32],y}function ct(){let e=(0,U.c)(89),{L:t,hasToken:n,logs:r,loading:i,error:a,hasMore:o,searchInput:s,setSearchInput:c,selectedLevels:u,moduleFilter:d,setModuleFilter:f,dateFrom:p,setDateFrom:m,dateTo:h,setDateTo:g,modules:_,files:v,stats:y,selectedLog:b,setSelectedLog:x,filesOpen:S,setFilesOpen:C,filtersOpen:w,setFiltersOpen:T,logDir:E,autoRefresh:D,setAutoRefresh:O,copiedDetail:k,setCopiedDetail:A,hasActiveFilters:j,activeFilterCount:M,clearFilters:N,toggleDialogLevel:P,handleLoadMore:F,refreshAll:I,levelSegment:L,handleLevelSegment:R,filterByRequestId:z,filterBySessionId:B,filterByErrorSummary:ee,openChatForSession:te,errorSummary:ne,errorSummaryLoading:V}=Fe(l(lt));if(!n){let n;return e[0]===t?n=e[1]:(n=(0,$.jsx)($e,{L:t}),e[0]=t,e[1]=n),n}let H;e[2]===C?H=e[3]:(H=()=>C(!0),e[2]=C,e[3]=H);let W;e[4]!==t||e[5]!==D||e[6]!==v.length||e[7]!==i||e[8]!==r||e[9]!==I||e[10]!==O||e[11]!==H?(W=(0,$.jsx)(ot,{L:t,autoRefresh:D,onAutoRefreshChange:O,fileCount:v.length,onOpenFiles:H,loading:i,onRefreshAll:I,logs:r}),e[4]=t,e[5]=D,e[6]=v.length,e[7]=i,e[8]=r,e[9]=I,e[10]=O,e[11]=H,e[12]=W):W=e[12];let G;e[13]===a?G=e[14]:(G=a?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg dark:border-edge`,role:`alert`,children:a}):null,e[13]=a,e[14]=G);let K;e[15]!==t||e[16]!==y?(K=y?(0,$.jsx)(st,{L:t,stats:y}):null,e[15]=t,e[16]=y,e[17]=K):K=e[17];let q;e[18]!==t||e[19]!==ne||e[20]!==V||e[21]!==ee?(q=(0,$.jsx)(Ie,{L:t,items:ne,loading:V,onSelectItem:ee}),e[18]=t,e[19]=ne,e[20]=V,e[21]=ee,e[22]=q):q=e[22];let J;e[23]===T?J=e[24]:(J=()=>T(!0),e[23]=T,e[24]=J);let Y;e[25]!==t||e[26]!==M||e[27]!==D||e[28]!==N||e[29]!==R||e[30]!==j||e[31]!==L||e[32]!==d||e[33]!==_||e[34]!==s||e[35]!==f||e[36]!==c||e[37]!==J?(Y=(0,$.jsx)(Ye,{L:t,levelSegment:L,onLevelSegment:R,searchInput:s,onSearchInputChange:c,moduleFilter:d,onModuleFilterChange:f,modules:_,onOpenFilters:J,activeFilterCount:M,hasActiveFilters:j,onClearFilters:N,autoRefresh:D}),e[25]=t,e[26]=M,e[27]=D,e[28]=N,e[29]=R,e[30]=j,e[31]=L,e[32]=d,e[33]=_,e[34]=s,e[35]=f,e[36]=c,e[37]=J,e[38]=Y):Y=e[38];let X;e[39]!==t||e[40]!==z||e[41]!==F||e[42]!==o||e[43]!==i||e[44]!==r||e[45]!==I||e[46]!==x?(X=(0,$.jsx)(Ze,{L:t,logs:r,loading:i,hasMore:o,onSelectLog:x,onLoadMore:F,onRefreshAll:I,onFilterByRequestId:z}),e[39]=t,e[40]=z,e[41]=F,e[42]=o,e[43]=i,e[44]=r,e[45]=I,e[46]=x,e[47]=X):X=e[47];let Z;e[48]!==t||e[49]!==p||e[50]!==h||e[51]!==w||e[52]!==u||e[53]!==m||e[54]!==g||e[55]!==T||e[56]!==P?(Z=(0,$.jsx)(Ue,{L:t,open:w,onOpenChange:T,dateFrom:p,onDateFromChange:m,dateTo:h,onDateToChange:g,selectedLevels:u,onToggleLevel:P}),e[48]=t,e[49]=p,e[50]=h,e[51]=w,e[52]=u,e[53]=m,e[54]=g,e[55]=T,e[56]=P,e[57]=Z):Z=e[57];let re;e[58]===x?re=e[59]:(re=()=>x(null),e[58]=x,e[59]=re);let ie,ae;e[60]===A?(ie=e[61],ae=e[62]):(ie=()=>A(`message`),ae=()=>A(`json`),e[60]=A,e[61]=ie,e[62]=ae);let oe;e[63]!==t||e[64]!==k||e[65]!==z||e[66]!==B||e[67]!==te||e[68]!==b||e[69]!==ie||e[70]!==ae||e[71]!==re?(oe=(0,$.jsx)(Be,{L:t,log:b,onClose:re,copiedDetail:k,onCopiedMessage:ie,onCopiedJson:ae,onFilterByRequestId:z,onFilterBySessionId:B,onOpenChat:te}),e[63]=t,e[64]=k,e[65]=z,e[66]=B,e[67]=te,e[68]=b,e[69]=ie,e[70]=ae,e[71]=re,e[72]=oe):oe=e[72];let Q;e[73]!==t||e[74]!==v||e[75]!==S||e[76]!==E||e[77]!==C?(Q=(0,$.jsx)(Ve,{L:t,open:S,onOpenChange:C,files:v,logDir:E}),e[73]=t,e[74]=v,e[75]=S,e[76]=E,e[77]=C,e[78]=Q):Q=e[78];let se;return e[79]!==W||e[80]!==oe||e[81]!==Q||e[82]!==G||e[83]!==K||e[84]!==q||e[85]!==Y||e[86]!==X||e[87]!==Z?(se=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[W,G,K,q,Y,X,Z,oe,Q]}),e[79]=W,e[80]=oe,e[81]=Q,e[82]=G,e[83]=K,e[84]=q,e[85]=Y,e[86]=X,e[87]=Z,e[88]=se):se=e[88],se}function lt(e){return e.language}export{ct as LogsPage};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-CJhrn98_.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-eyttVNS_.js","assets/preload-helper-zJ_50EbN.js","assets/Combination-14nmIgxH.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-C230izr8.js","assets/chunk-KS7C4IRE-BMhrPKJC.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/check-DUBLcKHA.js","assets/circle-alert-BEjgurr2.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-CAuhEGCn.js","assets/messages-BiBdO1-O.js","assets/cn-JdwAhgNB.js","assets/schemas-DgQq6Z5S.js","assets/product-delivery-BTRT9kCS.js","assets/config-reload-event-Bjh2zoKp.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/gateway-startup-retry-MP3K71pP.js","assets/activity-store-CyEDJeIt.js","assets/theme-store-CbGc1laW.js","assets/index-CfXiRNN5.css","assets/vendor-codemirror--gTq3YAI.js","assets/with-selector-aYPsXwdl.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-BvUebh3C.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-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-BiBdO1-O.js";import{l as c,n as l}from"./locale-store-CAuhEGCn.js";import{i as u}from"./theme-store-CbGc1laW.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$n as f,$s as p,Ac as m,Bc as h,Bo as g,Ci as _,Cl as v,Cr as y,Ei as b,Er as x,Fc as S,Fu as C,Go as w,Gs as T,Ho as E,Ic as D,Iu as O,Jc as k,Kl as A,Ks as j,Mc as M,Ms as N,Nt as P,Nu as F,Pc as ee,Qc as I,Rc as L,Rl as R,Sc as z,Si as te,Sl as B,Ti as ne,To as re,Tu as ie,U as ae,Ul as V,Uo as oe,Vo as H,Wo as U,_ as se,_r as W,ac as ce,ar as le,bl as G,br as K,cr as ue,dr as de,er as fe,eu as pe,fr as me,gr as he,hc as ge,hl as _e,hr as ve,ic as q,is as J,lr as ye,mc as Y,mr as be,nc as xe,ns as Se,or as Ce,pr as we,qo as Te,qs as Ee,ru as De,sr as Oe,tl as ke,tr as Ae,ur as je,vr as Me,wi as X,wr as Ne,xi as Pe,xr as Fe,yl as Ie,yr as Le,zo as Re,zu as ze}from"./index-eyttVNS_.js";import{t as Be}from"./automation-suggestion-card-Byu3I7Rs.js";var Z=n(),Q=e(t(),1),$=r(),Ve=(0,Q.createContext)(null);function He(){let e=(0,Z.c)(1),t=(0,Q.useContext)(Ve);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:Ue},e[0]=t):t=e[0],t}return t}function Ue(){}function We(e){let t=(0,Z.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,s]=(0,Q.useState)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{s({src:e,alt:t})},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={openImage:l},t[1]=u):u=t[1];let d=u,f=a!==null,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>{e||s(null)},t[2]=p):p=t[2];let m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(oe,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=m):m=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`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]=h):h=t[4];let _=a?.alt||`Image preview`,v;t[5]===_?v=t[6]:(v=(0,$.jsx)(w,{className:`sr-only`,children:_}),t[5]=_,t[6]=v);let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(N,{className:`size-5`,"aria-hidden":!0}),t[7]=y):y=t[7];let b;t[8]===i?b=t[9]:(b=(0,$.jsx)(g,{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:y})}),t[8]=i,t[9]=b);let x;t[10]===a?x=t[11]:(x=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]=x);let S;t[12]!==b||t[13]!==x||t[14]!==v?(S=(0,$.jsxs)(U,{children:[m,(0,$.jsxs)(H,{className:h,"aria-describedby":void 0,children:[v,b,x]})]}),t[12]=b,t[13]=x,t[14]=v,t[15]=S):S=t[15];let C;t[16]!==S||t[17]!==f?(C=(0,$.jsx)(Re,{open:f,onOpenChange:p,children:S}),t[16]=S,t[17]=f,t[18]=C):C=t[18];let T;return t[19]!==n||t[20]!==C?(T=(0,$.jsxs)(Ve.Provider,{value:d,children:[n,C]}),t[19]=n,t[20]=C,t[21]=T):T=t[21],T}function Ge(e){let t=(0,Z.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,s]=(0,Q.useState)(!1),c;t[0]!==r||t[1]!==n?(c=x(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(a){let e;t[3]===i?e=t[4]:(e=o(`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)(B,{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 u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!0),t[8]=u):u=t[8];let d;t[9]===i?d=t[10]:(d=o(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=d);let f;return t[11]!==n||t[12]!==l||t[13]!==d?(f=(0,$.jsx)(Ne,{src:l,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:u,className:d}),t[11]=n,t[12]=l,t[13]=d,t[14]=f):f=t[14],f}var Ke=6e4,qe=36e5,Je=864e5;function Ye(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Xe(e,t,n){let r=t-e;if(r<Ke)return n.justNow;if(r<qe){let e=Math.floor(r/Ke);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=Ye(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(e>=i-Je)return n.yesterday+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(r<7*Je){let e=Math.floor(r/Je);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Ze(e,t,n){let r=Ye(t);if(e>=r)return n.today;if(e>=r-Je)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 Qe(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function $e(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 et(e){let t=(0,Z.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=Ae(),p=Ae(nt),m=d===n&&f===r,h=m&&s,g=m&&c,_=m?l:0,v=m&&u>0?u:i??0,y=v>0?Math.min(_/v*100,100):0,b;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==p?(b=e=>{e.stopPropagation(),p(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=p,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==p?(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),p(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=p,t[9]=S):S=t[9];let C=S,w;t[10]===a?w=t[11]:(w=o(`flex items-center gap-2`,a),t[10]=a,t[11]=w);let T=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,E;t[12]===T?E=t[13]:(E=o(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,T),t[12]=T,t[13]=E);let D=h?`Pause`:`Play`,O;t[14]!==g||t[15]!==h?(O=g?(0,$.jsx)(ke,{className:`size-3.5 animate-spin`}):h?(0,$.jsx)(L,{className:`size-3.5`}):(0,$.jsx)(M,{className:`size-3.5 ml-0.5`}),t[14]=g,t[15]=h,t[16]=O):O=t[16];let k;t[17]!==x||t[18]!==C||t[19]!==E||t[20]!==D||t[21]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:x,onKeyDown:C,className:E,"aria-label":D,children:O}),t[17]=x,t[18]=C,t[19]=E,t[20]=D,t[21]=O,t[22]=k):k=t[22];let A=`${y}%`,j;t[23]===A?j=t[24]:(j=(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:A}})}),t[23]=A,t[24]=j);let N;t[25]!==v||t[26]!==m||t[27]!==_?(N=$e(m&&_>0?_:v),t[25]=v,t[26]=m,t[27]=_,t[28]=N):N=t[28];let P;t[29]===N?P=t[30]:(P=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:N}),t[29]=N,t[30]=P);let F;t[31]!==j||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=F):F=t[33];let ee;return t[34]!==F||t[35]!==w||t[36]!==k?(ee=(0,$.jsxs)(`div`,{className:w,onClick:tt,children:[k,F]}),t[34]=F,t[35]=w,t[36]=k,t[37]=ee):ee=t[37],ee}function tt(e){return e.stopPropagation()}function nt(e){return e.toggle}function rt(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function it(e){let t=(0,Z.c)(80),{note:n,selected:r,onPress:i,onPin:a,onArchive:s,onDelete:c,labels:l,timeLabels:u}=e,d=r===void 0?!1:r,f;t[0]!==l||t[1]!==n?(f=rt(n,l),t[0]=l,t[1]=n,t[2]=f):f=t[2];let p=f,m=!n.snippet?.trim(),[h]=(0,Q.useState)(ct),g;t[3]!==n.createdAt||t[4]!==h||t[5]!==u?(g=Xe(n.createdAt,h,u),t[3]=n.createdAt,t[4]=h,t[5]=u,t[6]=g):g=t[6];let v=g,y,x;t[7]!==n.id||t[8]!==i?(y=()=>i(n.id),x=e=>{(e.key===`Enter`||e.key===` `)&&i(n.id)},t[7]=n.id,t[8]=i,t[9]=y,t[10]=x):(y=t[9],x=t[10]);let C=d?`bg-surface-active hover:bg-surface-active`:`bg-surface-base hover:bg-surface-hover`,w;t[11]===C?w=t[12]:(w=o(`group relative flex cursor-pointer flex-col gap-2 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-panel`,C),t[11]=C,t[12]=w);let E=d?`true`:void 0,D;t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(D=n.coverAttachmentId?(0,$.jsx)(Ge,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,$.jsx)(et,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=D):D=t[18];let k;t[19]===n.title?k=t[20]:(k=n.title&&(0,$.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=k);let j=n.title?`text-fg-muted`:m?`italic text-fg-muted`:`text-fg`,M;t[21]===j?M=t[22]:(M=o(`truncate text-sm leading-5`,j),t[21]=j,t[22]=M);let N;t[23]!==p||t[24]!==M?(N=(0,$.jsx)(`p`,{className:M,children:p}),t[23]=p,t[24]=M,t[25]=N):N=t[25];let P;t[26]!==k||t[27]!==N?(P=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[k,N]}),t[26]=k,t[27]=N,t[28]=P):P=t[28];let F;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:st,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-0 transition-opacity group-hover:opacity-100 hover:bg-surface-panel focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,children:(0,$.jsx)(A,{className:`size-4`})})}),t[29]=F):F=t[29];let I;t[30]!==n.id||t[31]!==n.pinned||t[32]!==a?(I=()=>a(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=a,t[33]=I):I=t[33];let L;t[34]===n.pinned?L=t[35]:(L=n.pinned?(0,$.jsx)(ee,{className:`size-4`}):(0,$.jsx)(S,{className:`size-4`}),t[34]=n.pinned,t[35]=L);let R=n.pinned?l.unpin:l.pin,z;t[36]!==I||t[37]!==L||t[38]!==R?(z=(0,$.jsxs)(te,{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:I,children:[L,R]}),t[36]=I,t[37]=L,t[38]=R,t[39]=z):z=t[39];let B;t[40]!==n.id||t[41]!==s?(B=()=>s(n.id),t[40]=n.id,t[41]=s,t[42]=B):B=t[42];let re;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(O,{className:`size-4`}),t[43]=re):re=t[43];let ie;t[44]!==l.archive||t[45]!==B?(ie=(0,$.jsxs)(te,{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:B,children:[re,l.archive]}),t[44]=l.archive,t[45]=B,t[46]=ie):ie=t[46];let ae;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(ne,{className:`my-1 h-px bg-edge-subtle`}),t[47]=ae):ae=t[47];let V;t[48]!==n.id||t[49]!==c?(V=()=>c(n.id),t[48]=n.id,t[49]=c,t[50]=V):V=t[50];let oe;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(T,{className:`size-4`}),t[51]=oe):oe=t[51];let H;t[52]!==l.delete||t[53]!==V?(H=(0,$.jsxs)(te,{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:V,children:[oe,l.delete]}),t[52]=l.delete,t[53]=V,t[54]=H):H=t[54];let U;t[55]!==z||t[56]!==ie||t[57]!==H?(U=(0,$.jsxs)(X,{children:[F,(0,$.jsx)(_,{children:(0,$.jsxs)(Pe,{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:[z,ie,ae,H]})})]}),t[55]=z,t[56]=ie,t[57]=H,t[58]=U):U=t[58];let se;t[59]!==P||t[60]!==U||t[61]!==D?(se=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[D,P,U]}),t[59]=P,t[60]=U,t[61]=D,t[62]=se):se=t[62];let W;t[63]===n.pinned?W=t[64]:(W=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)(S,{className:`size-3`})}),t[63]=n.pinned,t[64]=W);let ce;t[65]===n.tags?ce=t[66]:(ce=n.tags?.slice(0,2).map(at),t[65]=n.tags,t[66]=ce);let le;t[67]===v?le=t[68]:(le=(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:v}),t[67]=v,t[68]=le);let G;t[69]!==W||t[70]!==ce||t[71]!==le?(G=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[W,ce,le]}),t[69]=W,t[70]=ce,t[71]=le,t[72]=G):G=t[72];let K;return t[73]!==se||t[74]!==G||t[75]!==y||t[76]!==x||t[77]!==w||t[78]!==E?(K=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:y,onKeyDown:x,className:w,"aria-current":E,children:[se,G]}),t[73]=se,t[74]=G,t[75]=y,t[76]=x,t[77]=w,t[78]=E,t[79]=K):K=t[79],K}function at(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 ot(e){return e.stopPropagation()}function st(e){return e.stopPropagation()}function ct(){return Date.now()}var lt={edit:D,ai_edit:ce,sync:z,restore:C};function ut(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function dt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=s(l(e=>e.language)).notes,c=a,{data:u}=d(e?[`note-history`,e]:null,()=>de(e)),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),g=(0,Q.useCallback)(async t=>{p(!0);try{await K(e,t),h(null),i()}catch{Te({type:`error`,title:a.restoreFailed})}finally{p(!1)}},[e,a.restoreSuccess,a.restoreFailed,i]),_=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)(v,{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)(N,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:u?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:u.map(e=>{let r=lt[e.trigger]??D,i=t===e.timestamp,s=m===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:o(`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:Xe(e.timestamp,_,c)})]}),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(),g(e.timestamp)},disabled:f,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:f?`...`:a.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h(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(),h(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 ft(e){let t=(0,Z.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:u,noteThreads:f,openingChat:p,onOpenChat:m,onOpenNewChat:h}=e,g=s(l(yt)).notes,_=a(),v=r?.aiDeep?.catalysis,y=v?.report??null,b;t[0]===n?b=t[1]:(b=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=b);let x;t[2]===n?x=t[3]:(x=()=>ye(n),t[2]=n,t[3]=x);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},t[4]=S):S=t[4];let{data:C,mutate:w,isLoading:T}=d(b,x,S),E;t[5]===n?E=t[6]:(E=async e=>{try{await Le(n,e)}catch{}},t[5]=n,t[6]=E);let D=E,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),t[7]=O):O=t[7];let k;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(F,{className:`size-4 rotate-180`,"aria-hidden":!0}),t[8]=k):k=t[8];let A;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(I,{className:`size-4 text-accent`,"aria-hidden":!0}),t[9]=A):A=t[9],(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:[O,(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:g.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:u,"aria-label":g.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:k})]}),(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:g.catalysisSectionDescription}),C?(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:g.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(()=>Me(n),{revalidate:!1}),disabled:T,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.contextRebuild}),(0,$.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,C.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:C.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:C.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:g.contextStatusDetail.replace(`{{attachments}}`,String(C.attachments.length)).replace(`{{tokens}}`,String(C.tokenEstimate??0))}),C.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:C.attachments.slice(0,5).map(vt)}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:i,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:i?g.processing:y?g.recatalyze:g.catalyzeAction}),y?(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:g.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:y.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.targetUsers.slice(0,5).map(_t)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.keyQuestions.slice(0,3).map(gt)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.mvpPath.slice(0,3).map(ht)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.risks.slice(0,3).map(mt)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.nextActions.slice(0,4).map(pt)})]}),(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:g.confidenceLabel.replace(`{{percent}}`,String(Math.round(y.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void D(`helpful`),className:o(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackHelpfulAria,children:(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void D(`not_helpful`),className:o(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackNotHelpfulAria,children:(0,$.jsx)(Ee,{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:g.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:[A,g.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:m,disabled:p,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:p?g.openingChat:g.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:h,disabled:p,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:g.newThread})]})]}),f.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:f.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(`/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||g.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.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:g.noThreads})]})]})]})}function pt(e){return(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}`)}function mt(e){return(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)}function ht(e,t){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e)}function gt(e){return(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)}function _t(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function vt(e){return(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)}function yt(e){return e.language}var bt=()=>i(()=>import(`./block-editor-CJhrn98_.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])),xt=()=>i(()=>import(`./markdown-editor-BvUebh3C.js`).then(e=>e.n),__vite__mapDeps([28,1,3,25,5,29])),St=(0,Q.lazy)(()=>bt().then(e=>({default:e.BlockEditor}))),Ct=(0,Q.lazy)(()=>xt().then(e=>({default:e.MarkdownEditor})));function wt(){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 Tt(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:R},t[0]=i.edit,t[1]=a);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:pe},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:V},t[4]=i.preview,t[5]=c);let l;t[6]!==a||t[7]!==s||t[8]!==c?(l=[a,s,c],t[6]=a,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:u.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&bt(),t===`source`&&xt()},onFocus:()=>{t===`wysiwyg`&&bt(),t===`source`&&xt()},className:o(`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]=u,t[12]=r,t[13]=d):d=t[13],d}function Et(e){let t=(0,Z.c)(15),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:c,onOpenSearch:u,autoFocus:d,onAutoFocusConsumed:f}=e,p=a===void 0?!0:a,m=c===void 0?!0:c,h=d===void 0?!1:d,g=l(Dt),_;t[0]===g?_=t[1]:(_=s(g),t[0]=g,t[1]=_);let v=_.notes.lightboxClose,y;t[2]!==h||t[3]!==o||t[4]!==m||t[5]!==n||t[6]!==f||t[7]!==r||t[8]!==u||t[9]!==i||t[10]!==p?(y=(0,$.jsx)(Ot,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:o,clearHeaderOnCleanup:m,onOpenSearch:u,autoFocus:h,onAutoFocusConsumed:f}),t[2]=h,t[3]=o,t[4]=m,t[5]=n,t[6]=f,t[7]=r,t[8]=u,t[9]=i,t[10]=p,t[11]=y):y=t[11];let b;return t[12]!==v||t[13]!==y?(b=(0,$.jsx)(We,{closeLabel:v,children:y}),t[12]=v,t[13]=y,t[14]=b):b=t[14],b}function Dt(e){return e.language}function Ot({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:c=!0,onOpenSearch:p,autoFocus:m=!1,onAutoFocusConsumed:h}){let g=l(e=>e.language),_=s(g).notes,b=s(g).automations.suggestions,x=a(),S=u(e=>e.resolved)===`dark`,{openImage:C}=He(),[w,T]=(0,Q.useState)(`wysiwyg`),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(``),[P,ee]=(0,Q.useState)(360),[L,R]=(0,Q.useState)(!1),[z,te]=(0,Q.useState)(!1),[B,ne]=(0,Q.useState)(!1),ie=(0,Q.useRef)(!1),V=(0,Q.useRef)(!1),oe=(0,Q.useRef)(null),H=(0,Q.useRef)(null),U=(0,Q.useRef)(null),W=(0,Q.useRef)(null),G=(0,Q.useRef)(null),K=(0,Q.useRef)(null),de=(0,Q.useRef)(null),pe=(0,Q.useRef)(null),he=(0,Q.useRef)(null),_e=re(e=>e.setPageHeader),ve=re(e=>e.clearPageHeader),{data:q,mutate:J}=d(e?[`note-detail`,e]:null,()=>ue(e)),{data:ye=[],mutate:Y}=d(e?[`note-threads`,e]:null,()=>me(e),{revalidateOnFocus:!1}),xe=O!==null;(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&J()};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[J,e]),(0,Q.useEffect)(()=>{ie.current=!1,N(``),k(null),D(null),V.current=!1,he.current=null},[e]),(0,Q.useEffect)(()=>{!q||ie.current||(N(q.title??``),ie.current=!0)},[q]),(0,Q.useEffect)(()=>{if(!m||!q||xe||he.current===e)return;let t=window.requestAnimationFrame(()=>{pe.current?.focus(),h?.()});return he.current=e,()=>window.cancelAnimationFrame(t)},[m,xe,q,e,h]);let Se=q?new Date(q.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,Ce=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":_.back,className:o(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,ze,i),children:(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0})}):null,[i,_.back,t,r]),we=(0,Q.useCallback)(t=>{N(t),e&&(W.current=t,H.current&&clearTimeout(H.current),H.current=setTimeout(async()=>{let t=W.current;if(W.current=null,t!==null){j(!0);try{await Fe(e,{title:t}),await J(),n?.()}catch{}finally{j(!1)}}},600))},[e,J,n]),Ee=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:o(`flex min-w-0 items-center gap-2`,ze),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:M||Se||void 0,children:M||Se}),A?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:_.saving}):null]}),[_.saving,A,Se,M]),De=(0,Q.useCallback)(async(t=!1)=>{ne(!0);try{let n=await be(e,{forceNew:t});await J(),await Y(),x(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){Te({type:`error`,title:_.chatOpenFailedTitle,message:e instanceof Error?e.message:_.chatOpenFailedMessage})}finally{ne(!1)}},[J,Y,x,e,_.chatOpenFailedMessage,_.chatOpenFailedTitle]),Oe=(0,Q.useCallback)(async()=>{te(!0);try{await le(e),await J()}catch(e){Te({type:`error`,title:_.catalysisFailed,message:e instanceof Error?e.message:_.chatOpenFailedMessage})}finally{te(!1)}},[J,e]),ke=(0,Q.useCallback)(()=>{D(E===`breakdown`?null:`breakdown`),!q?.aiDeep?.catalysis?.report&&!z&&Oe()},[E,z,Oe,q?.aiDeep?.catalysis?.report]),Ae=(0,Q.useCallback)(()=>{let t=O?.markdown??U.current??q?.markdown??``,n=O?.title??M,r=f([n,t].filter(Boolean).join(`
|
|
3
|
-
|
|
4
|
-
`));return{source:{type:`note`,id:e,title:n||_.titlePlaceholder},text:r,language:fe(r,g)}},[g,_.titlePlaceholder,q?.markdown,e,O,M]),Me=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:o(`flex items-center gap-2`,ze),children:[p?(0,$.jsx)(`button`,{type:`button`,onClick:p,"aria-label":_.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)(ge,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(ae,{input:Ae,labels:{read:_.readAloud,preparing:_.readAloudPreparing,pause:_.readAloudPause,resume:_.readAloudResume,retry:_.readAloudRetry},showLabel:!0}),(0,$.jsxs)(`button`,{type:`button`,onClick:ke,disabled:z,"aria-label":_.catalysisSectionTitle,className:o(`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`,E===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),z?_.catalyzing:_.catalyzeButton]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>De(!1),disabled:B,className:o(`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)(I,{className:`size-3.5`,"aria-hidden":!0}),B?_.openingChat:_.openChatButton]}),(0,$.jsx)(Tt,{mode:w,onModeChange:T,labels:{edit:_.modeEdit,source:_.modeSource,preview:_.modePreview}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>D(E===`history`?null:`history`),"aria-label":_.history,className:o(`rounded-lg p-1.5 transition-colors`,E===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]}),[z,ke,De,w,_.history,_.modeEdit,_.modePreview,_.modeSource,B,E,p,_.searchDialogTitle,_.readAloud,_.readAloudPause,_.readAloudPreparing,_.readAloudResume,_.readAloudRetry,Ae]);(0,Q.useLayoutEffect)(()=>(_e({startExtra:Ce,main:q?Ee:null,end:q?Me:null}),()=>{c&&ve()}),[c,ve,Me,Ee,Ce,q,_e]);let X=(0,Q.useCallback)(t=>{e&&(U.current=t,oe.current&&clearTimeout(oe.current),oe.current=setTimeout(async()=>{let t=U.current;if(U.current=null,t!==null){j(!0);try{await Fe(e,{markdown:t}),await J(),n?.()}catch(e){Te({type:`error`,title:_.saveFailed,message:e instanceof Error?e.message:_.saveFailedHint})}finally{j(!1)}}},600))},[e,J,_.saveFailed,_.saveFailedHint,n]),Ne=(0,Q.useCallback)(t=>{je(e,t.timestamp).then(e=>{e&&k(e)})},[e]),Pe=(0,Q.useCallback)(()=>{D(null),k(null)},[]),Ie=(0,Q.useCallback)(()=>{D(null),k(null),J(),n?.()},[J,n]);if((0,Q.useEffect)(()=>()=>{oe.current&&clearTimeout(oe.current),H.current&&clearTimeout(H.current);let t=U.current,n=W.current;U.current=null,W.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&Fe(e,r)},[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:_.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.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:_.back})]});let Le=xe?O.title??``:M,Re=xe?O.markdown??``:q.markdown??``,Z=new Date(q.createdAt).getTime(),Ve=Number.isFinite(Z)&&Date.now()-Z<3600*1e3?(0,$.jsx)(Be,{title:b.noteCreatedTitle,description:b.noteCreatedDescription,prompt:b.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)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(se,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(se,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(`div`,{ref:G,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:xe?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Le&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Le}),Re?(0,$.jsx)(y,{noteId:e,content:Re,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:_.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[w===`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:pe,type:`text`,value:M,onChange:e=>we(e.target.value),onCompositionStart:()=>{V.current=!0},onCompositionEnd:()=>{V.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!V.current&&!t.isComposing&&(e.preventDefault(),(G.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:_.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`}),Ve]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wt,{}),children:(0,$.jsx)(St,{initialContent:q.markdown??``,onChange:X,noteId:e},`wysiwyg-${e}`)})})]}),w===`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:pe,type:`text`,value:M,onChange:e=>we(e.target.value),placeholder:_.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`}),Ve]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wt,{}),children:(0,$.jsx)(Ct,{initialContent:q.markdown??``,onChange:X,isDark:S},`source-${e}`)})})]}),w===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&C(t.currentSrc||t.src,t.alt)},children:[M&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:M}),q.markdown?(0,$.jsx)(y,{noteId:e,content:q.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:_.emptyPreview})]})]})})]}),(0,$.jsx)(`div`,{ref:K,className:o(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!L&&`transition-[width] duration-300 ease-in-out`),style:{width:E?P:0},children:(0,$.jsxs)(`div`,{ref:de,className:`flex min-h-0 flex-1 flex-col`,style:{width:P},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),R(!0);let n=e.clientX,r=P,i=e.pointerId,a=0,o=P,s=P,c=()=>{a=0,s=o,E&&K.current?.style.setProperty(`width`,`${s}px`),de.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{}R(!1),ee(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:o(`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`,L&&`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:E===`history`?(0,$.jsx)(dt,{noteId:e,activeTimestamp:O?.timestamp??null,onSelect:Ne,onClose:Pe,onRestored:Ie}):E===`breakdown`?(0,$.jsx)(ft,{noteId:e,note:q??null,catalyzing:z,onCatalyze:Oe,onClose:()=>D(null),noteThreads:ye,openingChat:B,onOpenChat:()=>De(!1),onOpenNewChat:()=>De(!0)}):null})]})})]})}var kt=3e4;function At(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function jt({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:i,recordingLabel:a=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(0),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)([]),C=(0,Q.useRef)(0),w=(0,Q.useRef)(null),T=(0,Q.useRef)(null),E=(0,Q.useCallback)(()=>{w.current&&=(clearInterval(w.current),null),T.current&&=(clearTimeout(T.current),null),x.current?.getTracks().forEach(e=>e.stop()),x.current=null,b.current=null,S.current=[],m(!1),g(0)},[]);(0,Q.useEffect)(()=>()=>E(),[E]);let D=(0,Q.useCallback)(async()=>{let e=b.current;if(!e||e.state!==`recording`)return;v(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-C.current)/1e3)),n=e.mimeType||At()||`audio/webm`,r=new Blob(S.current,{type:n});if(E(),r.size>0&&i){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,a=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await i(a,t)}finally{v(!1)}return}v(!1)},[E,i]),O=(0,Q.useCallback)(async()=>{if(!(!i||_||p)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=At(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);x.current=e,b.current=n,S.current=[],C.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&S.current.push(e.data)},n.start(),m(!0),g(0),w.current=setInterval(()=>{g(Math.round((Date.now()-C.current)/1e3))},250),T.current=setTimeout(()=>{D()},kt)}catch{E()}},[E,i,p,D,_]),A=(0,Q.useCallback)(()=>{if(p){D();return}O()},[p,O,D]),j=(0,Q.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),y.current?.focus()}}},[l,d,n]),M=(0,Q.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),j()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),j({navigate:!1}))},[j]),N=d||_;return(0,$.jsxs)(`div`,{className:o(`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`,p&&`border-danger ring-1 ring-danger/40`),children:[r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:N||s||p,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Image`,children:(0,$.jsx)(G,{className:`size-4`})}),i&&(0,$.jsx)(`button`,{type:`button`,onClick:A,disabled:N||c||d,className:o(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,p?`bg-danger-soft text-danger hover:bg-danger-soft`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-label":p?`Stop recording`:`Voice`,"aria-pressed":p,children:p?(0,$.jsx)(xe,{className:`size-4 fill-current`}):(0,$.jsx)(k,{className:`size-4`})}),p?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:a.replace(`{{seconds}}`,String(h))}):(0,$.jsx)(`textarea`,{ref:y,value:l,onChange:e=>u(e.target.value),onKeyDown:M,placeholder:e,rows:1,disabled:N,className:`min-h-8 flex-1 resize-none 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:!l.trim()||N||p,onClick:e=>void j({navigate:!e.shiftKey}),"aria-label":t,className:o(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!N&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,$.jsx)(Y,{className:`size-4`})})]})}var Mt={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Nt=240,Pt=320,Ft=520,It=560;function Lt(e){if(globalThis.localStorage===void 0)return Pt;try{let t=globalThis.localStorage.getItem(e);if(!t)return Pt;let n=Number(t);return Number.isFinite(n)?n:Pt}catch{return Pt}}function Rt(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var zt={thought:p,todo:q,voice:k,media:G,bookmark:ie,mixed:p,task:q};function Bt(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Vt(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function Ht(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function Ut({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:i=!0,listTag:u,captureTags:f=[],listTitle:_,listDescription:v,emptyText:y,emptyDescription:b,listWidthStorageKey:x=`xopc.notes.listWidth`}){let C=s(l(e=>e.language)).notes,T=!!c(e=>e.token),[D,A]=(0,Q.useReducer)(P,Mt),[j,M]=(0,Q.useState)(!1),[F,ee]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(0),[R,z]=(0,Q.useState)(()=>Lt(x)),[te,B]=(0,Q.useState)(!1),[ne,ae]=(0,Q.useState)(!1),[V,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(null),K=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),[de]=(0,Q.useState)(()=>Date.now()),fe=a(),pe=(0,Q.useCallback)(e=>{let t=K.current?.clientWidth??window.innerWidth,n=Math.max(Nt,t-It);return Math.max(Nt,Math.min(Math.min(Ft,n),e))},[]),me=(0,Q.useCallback)(e=>{let t=pe(e);z(t),Rt(x,t)},[pe,x]);(0,Q.useLayoutEffect)(()=>{z(e=>pe(e))},[pe]);let{data:ye,mutate:Y,isLoading:be}=d((0,Q.useMemo)(()=>T?[`notes-list`,u,D.statusFilter,D.kindFilter,D.pinnedOnly]:null,[T,u,D.statusFilter,D.kindFilter,D.pinnedOnly]),()=>we({status:D.statusFilter===`all`?void 0:D.statusFilter,kind:D.kindFilter===`all`?void 0:D.kindFilter,tag:u,pinned:D.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),xe=be&&!ye,Ee=ye?.items??[],ke=ye?.total??0,Ae=F.trim(),{data:je,isLoading:Me}=d(T&&j&&Ae?[`notes-search`,u,Ae]:null,()=>we({search:Ae,tag:u,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),X=je?.items??[],Ne=e?Ee.some(t=>t.id===e):!0;(0,Q.useEffect)(()=>{L(0)},[Ae]),(0,Q.useEffect)(()=>{I>=X.length&&L(Math.max(0,X.length-1))},[I,X.length]),(0,Q.useEffect)(()=>{let e=()=>{Y()};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[Y]);let Pe=re(e=>e.setPageHeader),Le=re(e=>e.clearPageHeader),Be=ke>0?C.noteCount.replace(`{{count}}`,String(ke)):null,Z=C.searchDialogTitle,Ve=C.searchClose,He=C.searchClear,Ue=(0,Q.useMemo)(()=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>M(!0),className:o(`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`,ze),"aria-label":Z,children:[(0,$.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:Z})]}),[Z]);(0,Q.useLayoutEffect)(()=>{if(n)return T?(Pe({startExtra:null,main:(0,$.jsxs)(`div`,{className:o(`flex min-w-0 items-center gap-2`,ze),children:[(0,$.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:_??C.title}),Be?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Be}):null]}),end:Ue}),()=>Le()):(Le(),()=>Le())},[Le,T,Ue,_,n,C.title,Be,e,Pe]);let We=(0,Q.useMemo)(()=>({justNow:C.justNow,minutesAgo:C.minutesAgo,today:C.today,yesterday:C.yesterday,daysAgo:C.daysAgo}),[C.justNow,C.minutesAgo,C.today,C.yesterday,C.daysAgo]),Ge=(0,Q.useMemo)(()=>[{id:`recent`,label:C.viewRecent,description:C.viewRecentDescription,icon:De,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:C.filterInbox,description:C.viewInboxDescription,icon:Ie,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:C.pinned,description:C.viewPinnedDescription,icon:S,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:C.viewTasks,description:C.viewTasksDescription,icon:q,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:C.kindVoice,description:C.viewVoiceDescription,icon:k,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:C.kindMedia,description:C.viewMediaDescription,icon:G,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:C.kindBookmark,description:C.viewBookmarksDescription,icon:ie,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:C.filterProcessed,description:C.viewProcessedDescription,icon:_e,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:C.filterArchived,description:C.viewArchiveDescription,icon:O,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[C.filterArchived,C.filterInbox,C.filterProcessed,C.kindBookmark,C.kindMedia,C.kindVoice,C.pinned,C.viewArchiveDescription,C.viewBookmarksDescription,C.viewInboxDescription,C.viewMediaDescription,C.viewPinnedDescription,C.viewProcessedDescription,C.viewRecent,C.viewRecentDescription,C.viewTasks,C.viewTasksDescription,C.viewVoiceDescription]),Ke=Ge.find(e=>Vt(D,e))??Ge[0],qe=_??Ke.label,Je=v??Ke.description,Ye=(0,Q.useCallback)(async(e,n)=>{let r=f.length?await Ce({markdown:e,kind:`thought`,tags:f,channel:`web`}):await ve(e,`web`);await Y(),n?.navigate!==!1&&fe(Ht(t,r.id))},[t,f,Y,fe]),$e=(0,Q.useCallback)(async()=>{if(!V){se(!0);try{let e=await Ce({markdown:``,kind:`thought`,tags:f,channel:`web`});A({type:`patch`,patch:Mt}),await Y(),le(e.id),fe(Ht(t,e.id))}catch(e){Te({type:`error`,title:C.createBlankFailed,message:e instanceof Error?e.message:C.createBlankFailedHint})}finally{se(!1)}}},[t,f,V,Y,C.createBlankFailed,C.createBlankFailedHint,fe]),et=(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{await he(t,`web`),await Y()}catch(e){Te({type:`error`,title:C.imageUploadFailed,message:e instanceof Error?e.message:C.imageUploadFailedHint})}},e.click()},[Y,C.imageUploadFailed,C.imageUploadFailedHint]),tt=(0,Q.useCallback)(async(e,t)=>{try{await W(e,t,`web`),await Y()}catch(e){Te({type:`error`,title:C.voiceUploadFailed,message:e instanceof Error?e.message:C.voiceUploadFailedHint})}},[Y,C.voiceUploadFailed,C.voiceUploadFailedHint]),nt=(0,Q.useCallback)(async(e,t)=>{await Fe(e,{pinned:t}),await Y()},[Y]),rt=(0,Q.useCallback)(async e=>{await Fe(e,{status:`archived`}),await Y()},[Y]),at=(0,Q.useCallback)(async e=>{await Oe(e),await Y()},[Y]),ot=(0,Q.useCallback)(e=>{fe(Ht(t,e))},[t,fe]),st=(0,Q.useCallback)(e=>{fe(Ht(t,e)),M(!1)},[t,fe]),ct=(0,Q.useCallback)(e=>{if(X.length){if(e.key===`ArrowDown`)e.preventDefault(),L(e=>Math.min(X.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),L(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=X[I]??X[0];t&&st(t.id)}}},[I,st,X]),lt=(0,Q.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=ue.current;t.setPointerCapture(e.pointerId),B(!0);let r=K.current?.clientWidth??window.innerWidth,i=Math.max(Nt,r-It),a=Math.min(Ft,i),o=e=>Math.max(Nt,Math.min(a,e)),s=e.clientX,c=o(R),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let p=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},m=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(p))},h=()=>{u!==0&&(window.cancelAnimationFrame(u),p());try{t.releasePointerCapture(l)}catch{}B(!1),K.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),z(f),Rt(x,f),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,h)};window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,h)},[x,R]);(0,Q.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),$e())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$e]);let ut=(0,Q.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),me(R-16)):e.key===`ArrowRight`?(e.preventDefault(),me(R+16)):e.key===`Home`?(e.preventDefault(),me(Nt)):e.key===`End`&&(e.preventDefault(),me(Ft))},[me,R]);return T?(0,$.jsxs)(`div`,{ref:K,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,style:{"--notes-list-width":`${R}px`},children:[(0,$.jsxs)(`section`,{ref:ue,className:o(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-panel`,!te&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,ne?`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":ne?!0:void 0,children:[(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,$.jsx)(Se,{value:Ke.id,onChange:e=>{let t=Ge.find(t=>t.id===e.target.value);t&&A({type:`patch`,patch:t.patch})},className:`-ml-1 block max-w-44 truncate rounded-lg border border-transparent bg-transparent px-1 py-0.5 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":C.libraryTitle,children:Ge.map(e=>(0,$.jsx)(J,{value:e.id,children:e.label},e.id))}):(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:qe}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:Be??Je})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>ae(!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":C.collapseNotesList,title:C.collapseNotesList,children:(0,$.jsx)(h,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:$e,disabled:V,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":C.createBlankNote,title:C.createBlankShortcut,children:(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(!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":C.searchDialogTitle,children:(0,$.jsx)(ge,{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:xe?(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))}):Ee.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 px-6 py-16 text-center`,children:[(0,$.jsx)(p,{className:`size-8 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:e&&!Ne?C.noteOutsideCurrentView:y??C.noNotes}),e&&!Ne?null:(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:b??C.noNotesDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Ne?(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:C.noteOutsideCurrentView}):null,Ee.map((t,n)=>{let r=n>0?Qe(Ee[n-1].createdAt):null;return(0,$.jsxs)(`div`,{children:[Qe(t.createdAt)!==r&&(0,$.jsx)(`div`,{className:o(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:Ze(t.createdAt,de,We)}),(0,$.jsx)(it,{note:t,selected:t.id===e,onPress:ot,onPin:nt,onArchive:rt,onDelete:at,timeLabels:We,labels:{pin:C.pin,unpin:C.unpin,archive:C.archive,delete:C.delete,imageNote:C.imageNote,noText:C.noText}})]},t.id)})]})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(jt,{placeholder:C.quickCapturePlaceholder,sendLabel:C.send,onCapture:Ye,onImagePick:i?et:void 0,onVoiceCapture:i?tt:void 0,recordingLabel:C.recording})})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":C.resizeNotesList,"aria-valuemin":Nt,"aria-valuemax":Ft,"aria-valuenow":Math.round(R),tabIndex:0,onPointerDown:lt,onDoubleClick:()=>me(Pt),onKeyDown:ut,title:C.resizeNotesList,className:o(`group relative hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,ne?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-3 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:o(`h-8 w-1 rounded-pill opacity-0 transition-[background-color,opacity,transform] duration-150`,`bg-edge-strong/55 group-hover:opacity-100 group-focus-visible:opacity-100`,`group-hover:scale-y-110 group-focus-visible:scale-y-110`,te&&`bg-accent opacity-100 scale-y-125`)})}),(0,$.jsxs)(`section`,{className:o(`relative min-w-0 flex-1 bg-surface-panel`,!e&&`hidden lg:flex`),children:[ne?(0,$.jsx)(`button`,{type:`button`,onClick:()=>ae(!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":C.expandNotesList,title:C.expandNotesList,children:(0,$.jsx)(h,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,$.jsx)(Et,{noteId:e,onBack:()=>fe(t),onSaved:()=>void Y(),backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>M(!0),autoFocus:e===ce,onAutoFocusConsumed:()=>le(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)(p,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:C.emptyEditorTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:C.emptyEditorDescription}),(0,$.jsxs)(`button`,{type:`button`,onClick:$e,disabled:V,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)(m,{className:`size-4`,"aria-hidden":!0}),V?C.creatingBlankNote:C.createBlankNote]})]})})]}),(0,$.jsx)(Re,{open:j,onOpenChange:M,children:(0,$.jsxs)(U,{children:[(0,$.jsx)(oe,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(H,{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)(w,{className:`text-sm font-semibold text-fg`,children:Z}),(0,$.jsx)(E,{className:`sr-only`,children:C.searchPlaceholder}),(0,$.jsx)(g,{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":Ve,children:(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`p-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ge,{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:F,onChange:e=>ee(e.target.value),onKeyDown:ct,placeholder:C.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`}),F?(0,$.jsx)(`button`,{type:`button`,onClick:()=>ee(``),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":He,children:(0,$.jsx)(N,{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:Ae?Me&&!je?(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)(p,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:C.searchNoResults}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:C.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:C.searchResultsCount.replace(`{{count}}`,String(je?.total??X.length))}),X.map((e,t)=>{let n=zt[e.kind]||p,r=Bt(e,{imageNote:C.imageNote,noText:C.noText});return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>st(e.id),onMouseEnter:()=>L(t),className:o(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===I?`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:Xe(e.updatedAt,de,We)})]}),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)(ge,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:C.searchEmptyTitle}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:C.searchEmptyDescription})]})})]})]})]})})]}):(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,$.jsx)(p,{className:`size-10 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C.needToken})]})}export{He as n,Ut as t};
|