@xopcai/xopc 0.0.122 → 0.0.123
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/{agent-avatar-dicebear-CK3s5cJo.js → agent-avatar-dicebear-Bicr3ZBg.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CxDSFHGx.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CWsNHtTs.js → app-management-settings-panel-CbEy9sR1.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C4b8y6iZ.js → appearance-settings-CTHja6n9.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CYb6fame.js → apps-page-CyZdgqvm.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DAtNW3Ia.js → archive-plugin-Bpy64GjU.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Dm-RY54y.js → attachment-load-DMkp4xSb.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BKHewSVT.js → automation-suggestion-card-KnYaP7NT.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-8VLKM4au.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BG6Xnk71.js → binary-plugins-DA9C5mCw.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DfndiO3h.js → block-editor-CiSXk_YC.js} +27 -27
- package/dist/gateway/static/root/assets/browser-settings-page-5tPg0DcP.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-Cx93GLdw.js → capability-presets-api-CEJ44WCU.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D528_YFy.js → capability-presets-settings-panel-BJW3aVST.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-DdPTtEs8.js → channel-recipient-api-CDhrhfhN.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-Ck-3h5lI.js → channels-settings-CorUCTrs.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-VKstC3sP.js +2 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-D835EHJd.js → directory-picker-path-field-7jKfbH0J.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CCa1F7Fg.js → dreaming-settings-m1-wmz4o.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-W2ITCPSA.js → extension-debug-page-C9qQQrBS.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DrvUytvn.js → extension-page-DcBBMEGl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-qM8aLT5u.js → extension-settings-page-BQ-jMMP9.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-ovkvM8KQ.js → fetch-Dtpbbe0s.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-BB3biuD0.js → gateway-config-api-BN6pyX2c.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-mmmnIH27.js → gateway-settings-hQtgVmSR.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CanQ8UcR.js → gateway-startup-retry-BIET2x3y.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-CNqNdEkQ.js → goal-create-dialog-BuIMDx6C.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-FEypCq74.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-BBOX6mUl.js → goals-config-api-CQm2r1Ty.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-C4-2_MLG.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Bh3A7OZV.js → goals-settings-DDrdRMxB.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BJVok3Sl.js +1 -0
- package/dist/gateway/static/root/assets/index-CBDr5xjB.css +1 -0
- package/dist/gateway/static/root/assets/{index-DdqSO9R2.js → index-T0SaNd5a.js} +18 -18
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B4TKJHla.js → keyboard-shortcuts-settings-C2TuQppb.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BgVk5DvZ.js → logs-page-DwkwPgid.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-DcFtdLci.js → markdown-split-DhONQ81k.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-B6SmeLVB.js → media-plugins-DS44pJzr.js} +1 -1
- package/dist/gateway/static/root/assets/messages-avfvyZuQ.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-huNY4A1G.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-DdfGuEZ1.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-B0bT9Hqa.js +2 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-C29O19s7.js → preview-open-alternatives-Dej6zHnr.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CjxhPorG.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-C4Z5OJMF.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CVCOPUVd.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-B4ad9GfB.js → save-bar-controls-Zu1FzH6z.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-DdYncfLR.js → schedule-field-BW78mKc0.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BMTrDE-7.js → schema-form-Cc-IOydE.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-B4qExXHC.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Ce8yLTBi.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-MwTW2eK4.js → settings-collapsible-section-DIpIYht_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Dg6LBbcr.js → settings-form-section-BFxBNxOG.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-C4fivemT.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-BX4T-OLF.js → settings-page-layout-CLx4o2PN.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Kyc4eUf0.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DWE-dUFh.js → share-preview-page-ZswWCrDu.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Bu76CMiC.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-D-CFg86j.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CUU4f6Ss.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Dd6Y35Cm.js → system-settings-panel-3ZNcGRhS.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-Cx6XV5A2.js → typed-models-lib-bpzZjiVF.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-D4sMbmy7.js → use-channel-catalog-BCjZLZ3O.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-Bx-hjMQc.js → user-profile-settings-panel-CIXafITi.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-D7b_vZnv.js → utils-DXMtz5j_.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-C1MrQD8R.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-DqizIcY5.js +3 -0
- package/dist/gateway/static/root/assets/{workflow-start-dialog-B0lavx_o.js → workflow-start-dialog-B4sZpTDQ.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-B3sVNPFk.js +18 -0
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/goal-tool.d.ts +5 -1
- package/dist/src/agent/tools/goal-tool.js +8 -2
- package/dist/src/agent/tools/goal-tool.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/chat-commands/builtins/goal.js +4 -1
- package/dist/src/chat-commands/builtins/goal.js.map +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/projects.js +97 -13
- package/dist/src/gateway/hono/routes/projects.js.map +1 -1
- package/dist/src/mcp/channel-bridge.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-service.d.ts +14 -0
- package/dist/src/projects/project-service.js +96 -3
- package/dist/src/projects/project-service.js.map +1 -1
- package/dist/src/projects/types.d.ts +3 -1
- package/dist/src/projects/workspace-project.d.ts +22 -0
- package/dist/src/projects/workspace-project.js +143 -0
- package/dist/src/projects/workspace-project.js.map +1 -0
- package/dist/src/tui/backends/embedded-backend.d.ts +7 -1
- package/dist/src/tui/backends/embedded-backend.js +40 -1
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +7 -1
- package/dist/src/tui/backends/gateway-sse-backend.js +22 -0
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +16 -0
- package/dist/src/tui/tui.js +21 -0
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-SsQrj9B-.js +0 -2
- package/dist/gateway/static/root/assets/automations-page-DpOOq1nk.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-9nXxgh4u.js +0 -8
- package/dist/gateway/static/root/assets/connectors-page-DL-fAqE_.js +0 -2
- package/dist/gateway/static/root/assets/goal-detail-page-Ceu5zrN6.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-BP1kfvWv.js +0 -2
- package/dist/gateway/static/root/assets/heartbeat-settings-YoYgKlfX.js +0 -1
- package/dist/gateway/static/root/assets/index-jGB-2nI-.css +0 -1
- package/dist/gateway/static/root/assets/messages-B5O4OIEo.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-BU0x8PGP.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-D6JYVP4I.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-mqRJYnJS.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-DOTgzoeh.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DGUIb4y5.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DVKKUj3u.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BVbzUWxW.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DrNNoSqE.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-CMDqgeMR.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Ce1pcFtR.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-aKSraR8l.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CS-FU_B-.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BaF3u0LA.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-CkhbRt1q.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel--TdohF5N.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-CZR05Bu_.js +0 -18
|
@@ -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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-ovkvM8KQ.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$a as p,$t as m,At as h,Ba as g,Bo as _,Bt as v,Cc as y,Da as b,Ds as x,Dt as S,Ea as C,Fi as w,Fo as T,Ft as E,Ga as D,Gt as O,H as k,Ha as A,Ht as j,Ic as M,Io as N,It as P,Kt as F,La as I,Lt as L,Mi as R,Mt as ee,Na as te,Nt as z,Ot as ne,Pa as B,Po as V,Pt as re,Qt as ie,Ra as ae,Rt as oe,So as H,Ut as se,Vt as ce,Wt as le,Xo as ue,Xt as de,Yt as fe,Zt as pe,aa as me,ba as he,bo as ge,cc as _e,ct as ve,da as ye,dc as be,ea as xe,en as Se,es as Ce,f as we,ga as U,ha as Te,ia as Ee,jc as De,ji as Oe,jt as ke,ka as W,kt as Ae,lo as je,lt as Me,nn as Ne,ns as G,oa as Pe,qt as Fe,ra as Ie,rn as Le,ta as Re,tn as ze,ut as Be,va as K,ya as Ve,yo as He,ys as Ue,za as q,zs as We,zt as Ge}from"./index-DdqSO9R2.js";import{a as Ke,c as qe,d as Je,f as Ye,l as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt,u as nt}from"./voice-api-key-field-CkhbRt1q.js";import{t as rt}from"./settings-advanced-gate-DrNNoSqE.js";import{t as it}from"./settings-collapsible-section-MwTW2eK4.js";import{n as at,t as ot}from"./settings-form-section-Dg6LBbcr.js";import{n as st,t as ct}from"./settings-page-layout-BX4T-OLF.js";import{n as lt,t as ut}from"./save-bar-controls-B4ad9GfB.js";var J=n(),Y=e(t(),1),X=r(),dt=()=>c(Ye),ft=()=>c(`/api/image/capabilities`),pt=()=>c(`/api/global-defaults`),mt={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function ht(){let e=await l(ft());if(!e.payload)throw Error(`Invalid image capabilities response`);return e.payload}function gt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function _t(e){return e.map(e=>e.trim()).filter(Boolean)}function vt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=_t(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=_t(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function yt(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function bt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var xt={saving:!1,savedFlash:!1,error:void 0};function St(e){let t=(0,J.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,m;t[0]!==c||t[1]!==s?(m=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=m):m=t[2];let h=m,g;t[3]!==l||t[4]!==h||t[5]!==s?(g=s?l.find(e=>!h.has(e.value))?.value??``:``,t[3]=l,t[4]=h,t[5]=s,t[6]=g):g=t[6];let _=g,v;t[7]!==c||t[8]!==_||t[9]!==f?(v=()=>{_&&f([...c,_])},t[7]=c,t[8]=_,t[9]=f,t[10]=v):v=t[10];let y=v,b;t[11]!==c||t[12]!==f?(b=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=b):b=t[13];let x=b,S;t[14]!==c||t[15]!==f?(S=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=S):S=t[16];let C=S,w;t[17]===n?w=t[18]:(w=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=w);let T;t[19]===r?T=t[20]:(T=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,X.jsxs)(`div`,{className:`mb-3`,children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===c?D=t[25]:(D=new Set(c),t[24]=c,t[25]=D);let O;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==D||t[30]!==s?(O=(0,X.jsx)(Te,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:D,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=D,t[30]=s,t[31]=O):O=t[31];let k;t[32]!==i||t[33]!==O?(k=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,O]}),t[32]=i,t[33]=O,t[34]=k):k=t[34];let A;t[35]===a?A=t[36]:(A=(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=A);let j;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==C||t[43]!==h||t[44]!==x?(j=c.length===0?(0,X.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg border border-dashed border-edge bg-surface-subtle px-3 text-sm font-normal text-fg-subtle`,children:o}):c.map((e,t)=>(0,X.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,X.jsx)(Te,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:h,onChange:e=>x(t,e)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,X.jsx)(p,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=C,t[43]=h,t[44]=x,t[45]=j):j=t[45];let M=!_,N;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(V,{className:`size-4`,"aria-hidden":`true`}),t[46]=N):N=t[46];let P;t[47]!==y||t[48]!==a||t[49]!==M?(P=(0,X.jsxs)(`button`,{type:`button`,onClick:y,disabled:M,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[N,a]}),t[47]=y,t[48]=a,t[49]=M,t[50]=P):P=t[50];let F;t[51]!==j||t[52]!==P?(F=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[j,P]}),t[51]=j,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==A||t[55]!==F?(I=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,F]}),t[54]=A,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==k||t[58]!==I?(L=(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[k,I]}),t[57]=k,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==E?(R=(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[E,L]}),t[60]=L,t[61]=E,t[62]=R):R=t[62],R}function Ct(){let e=o(e=>e.language),t=a(e),n=t.imageModelsSettings,r=!!s(e=>e.token),[i,c]=(0,Y.useReducer)(Be,xt),{saving:l,error:u}=i,p=w(),m=(0,Y.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),{data:h=[],isLoading:g}=f(r?dt():null,Je,{revalidateOnFocus:!1}),{data:_,isLoading:v,mutate:y}=f(r?ft():null,ht,{revalidateOnFocus:!1}),{data:b,isLoading:x,mutate:C}=f(r?pt():null,S,{revalidateOnFocus:!1}),T=h.some(e=>e.configured),E=Xe(h),[D,O]=(0,Y.useState)(mt),[k,A]=(0,Y.useState)(mt);(0,Y.useEffect)(()=>{if(!b?.models)return;let e=gt(b.models);O(e),A(e)},[b?.models]);let j=JSON.stringify(D)!==JSON.stringify(k),M=E.credDirty||j;(0,Y.useEffect)(()=>{if(!M)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[M]),lt({id:`image-models`,dirty:M,saving:l,save:(0,Y.useCallback)(async()=>{c({type:`patch`,patch:{saving:!0,error:void 0}});try{if(j){if(!b?.models)throw Error(n.loadError);let e=await ne(vt(b.models,D));await C(e,!1),await y();let t=gt(e.models);O(t),A(t)}E.credDirty&&(await E.saveCredentials(n.credentialsSaveError),await y()),c({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:n.saved})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{saving:!1}})}},[E,b?.models,j,D,C,y,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,Y.useCallback)(()=>{E.credDirty&&E.onDiscardCredentials(),j&&O(k),c({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[E,k,j])});let N=(0,Y.useMemo)(()=>bt(n),[n]),P=(0,Y.useMemo)(()=>yt(_?.imageUnderstanding.providers??[]),[_?.imageUnderstanding.providers]),F=(0,Y.useMemo)(()=>yt(_?.imageGeneration.providers??[]),[_?.imageGeneration.providers]),I=(0,Y.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]);return r?g||v||x?(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-2 text-sm text-fg-muted`,children:[(0,X.jsx)(G,{className:`size-4 animate-spin`}),` Loading…`]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u?(0,X.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:u}):null,(0,X.jsx)(St,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:D.imageModel,fallbackValues:D.imageModelFallbacks,options:P,emptyLabel:n.noModelSelected,onValueChange:e=>O(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>O(t=>({...t,imageModelFallbacks:e}))}),(0,X.jsx)(St,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:D.imageGenerationModel,fallbackValues:D.imageGenerationModelFallbacks,options:F,emptyLabel:n.noModelSelected,onValueChange:e=>O(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>O(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[(0,X.jsxs)(`div`,{className:`mb-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,X.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,X.jsx)(`input`,{type:`number`,min:1,value:D.imageGenerationModelTimeoutMs,onChange:e=>O(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,X.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:D.imageGenerationModelAutoProviderFallback,onChange:e=>O(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,X.jsx)(it,{icon:ge,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:T,children:h.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,X.jsx)(nt,{summaries:h,credDraft:E.credDraft,credBaseline:E.credBaseline,credDirty:E.credDirty,credSaving:E.credSaving,credError:E.credError,credSavedFlash:E.credSavedFlash,credNoopFlash:E.credNoopFlash,updateCredRow:E.updateCredRow,onDiscardCredentials:E.onDiscardCredentials,onSaveCredentials:()=>void E.saveCredentials(n.credentialsSaveError),extensionIds:m,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:I,messages:N})})]}):(0,X.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Z=I;function wt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Tt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Et(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function Q(){return i(ae,I)}function Dt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ot(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var kt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],At=[{id:`whisper-1`,name:`Whisper-1`}],jt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Mt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Nt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Pt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Ft=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],It=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Lt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Rt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],zt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Bt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Vt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Ht(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Ut(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Wt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Gt(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Kt(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function qt(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function Jt(){let e=a(o(e=>e.language)).voiceSettings,t=!!s(e=>e.token),[n,r]=(0,Y.useReducer)(qt,{form:null,baseline:null}),i=n.form,l=n.baseline,[u,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),y=(0,Y.useRef)(!1),b=(0,Y.useRef)({parsed:null,models:void 0}),{data:x,error:S,isLoading:C,mutate:w}=R(t),{data:T,error:E,isLoading:D,mutate:O}=f(t?c(`/api/voice/models`):null,Ze,{revalidateOnFocus:!1}),{data:k,error:A,isLoading:j}=f(t?c(`/api/voice/providers`):null,$e,{revalidateOnFocus:!1}),{data:M,error:N,isLoading:P}=f(t?c(`/api/voice/stt-providers`):null,Ke,{revalidateOnFocus:!1}),F=(0,Y.useMemo)(()=>k?.providers??[],[k]),I=(0,Y.useMemo)(()=>M?.providers??[],[M]),L=(0,Y.useMemo)(()=>x?.payload?.config===void 0?null:Qe(x.payload.config),[x]),ee=(0,Y.useMemo)(()=>!i||!l?!1:JSON.stringify(i)!==JSON.stringify(l),[i,l]);t?L!==null&&T!==void 0&&!y.current&&(b.current.parsed!==L||b.current.models!==T)&&(b.current={parsed:L,models:T},r({type:`sync`,value:L}),p(T)):(b.current.parsed!==null||b.current.models!==void 0)&&(b.current={parsed:null,models:void 0},r({type:`reset`}),p(null),y.current=!1);let te=!!(t&&(L===null||T===void 0||k===void 0||M===void 0)&&(C||D||j||P)),z=S instanceof Error?S.message:S?String(S):E instanceof Error?E.message:E?String(E):A instanceof Error?A.message:A?String(A):N instanceof Error?N.message:N?String(N):null,ne=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),B=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),V=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),re=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ie=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ae=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),oe=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),H=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),se=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ce=(0,Y.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(lt({id:`voice`,dirty:ee,saving:m,save:(0,Y.useCallback)(async()=>{if(!(!i||m)){h(!0),v(null);try{await et(i),r({type:`saved`,value:i}),y.current=!1,d({type:`success`,title:e.saved})}catch(t){v(t instanceof Error?t.message:e.saveError)}finally{h(!1)}}},[i,m,e.saveError]),discard:(0,Y.useCallback)(()=>{l&&(y.current=!1,r({type:`discard`}),v(null))},[l])}),!t)return(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(te)return(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,X.jsx)(G,{className:`size-4 animate-spin`}),e.loading]})});if(!i||u===null)return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_??z??e.loadError}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>{w(),O()},children:e.retry})]});let le=i.stt,ue=i.tts,de=Wt(e);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[_?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_}):null,(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(Yt,{v:e,stt:le,tts:ue}),(0,X.jsx)(Zt,{v:e,apiKeyLabels:de,stt:le,models:u,sttProviders:I,updateStt:ne,updateSttAlibaba:B,updateSttOpenai:V,updateSttFallback:re}),(0,X.jsx)(nn,{v:e,apiKeyLabels:de,tts:ue,models:u,ttsProviders:F,updateTts:ie,updateTtsAlibaba:ae,updateTtsOpenai:oe,updateTtsEdge:H,updateTtsMinimax:se,updateTtsLocalCli:ce})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,X.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function Yt(e){let t=(0,J.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,X.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Bt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,X.jsx)(Xt,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Ht(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,X.jsx)(Xt,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Vt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,X.jsx)(Xt,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,X.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,X.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function Xt(e){let t=(0,J.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,X.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,X.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,X.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function Zt(e){let t=(0,J.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:kt,p=o?.stt?.openai?.length?o.stt.openai:At,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(tn),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,X.jsx)(ue,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,X.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,X.jsx)(rn,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:n.stt.provider}),(0,X.jsx)(U,{className:Q(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,X.jsxs)(K,{value:e.id,children:[Bt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,X.jsx)(U,{className:Q(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(en)}):a.provider===`openai`?(0,X.jsx)(U,{className:Q(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map($t)}):a.provider===`groq`?(0,X.jsx)(U,{className:Q(),value:m||jt[0].id,onChange:e=>w({model:e.target.value}),children:jt.map(Qt)}):(0,X.jsx)(`input`,{className:Et(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:n.stt.apiKey}),(0,X.jsx)(tt,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,X.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,wt(a.provider)?` ${wt(a.provider)}`:``]})]})]}),S.length>0?(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,X.jsx)(an,{field:e,value:Gt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Z},e.key))}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,X.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,X.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function Qt(e){return(0,X.jsx)(K,{value:e.id,children:e.name},e.id)}function $t(e){return(0,X.jsx)(K,{value:e.id,children:e.name},e.id)}function en(e){return(0,X.jsx)(K,{value:e.id,children:e.name},e.id)}function tn(e){return e.key!==`apiKey`&&e.key!==`model`}function nn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Mt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Nt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Pt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Ft,_=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:It,v=r?.tts?.minimax?.length?r.tts.minimax:Lt,y=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Rt,[b,x]=(0,Y.useState)(e.tts.test.sampleText),[S,C]=(0,Y.useState)({status:`idle`}),w=(0,Y.useRef)(null),T=(0,Y.useRef)(null),E=(0,Y.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.current),null)},[]),O=(0,Y.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),k=O.find(e=>e.id===n.provider),A=n.providers?.[n.provider],j={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...A??{}},M=(k?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),P=!!k?.diagnostics.requiresApiKey,F=!!k?.configured||!P,I=n.enabled?F?`ready`:`action`:`muted`,L=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,R=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Y.useEffect)(()=>()=>E(),[E]);let ee=(0,Y.useCallback)(e=>{o({provider:e}),C({status:`idle`})},[o]),te=(0,Y.useCallback)(async()=>{let t=b.trim();if(!t){C({status:`error`,message:e.tts.test.emptyText});return}E(),C({status:`loading`});try{let r=await qe({text:t,provider:n.provider,providerConfig:j,...L?{model:L}:{},...R?{voice:R}:{}}),i=Ot(r.audio,r.mimeType);T.current=i;let a=new Audio(i);w.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Dt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>C({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>C({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),C({status:`playing`,summary:o})}catch(e){E(),C({status:`error`,message:e instanceof Error?e.message:String(e)})}},[L,R,j,E,b,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),z=(0,Y.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),ne=(0,Y.useCallback)((e,t)=>{let r={[e.key]:t};z(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,z,l,u,c]);return(0,X.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(D,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(rn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,X.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,I===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:I===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,X.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?F?`${e.tts.statusReady} ${Vt(n.provider,e)}${R?` · ${R}`:``}`:`${e.tts.statusNeedsSetup} ${Vt(n.provider,e)} · ${k?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:e.tts.trigger}),(0,X.jsxs)(U,{className:Q(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,X.jsx)(K,{value:`off`,children:e.tts.triggerOff}),(0,X.jsx)(K,{value:`inbound`,children:e.tts.triggerInbound}),(0,X.jsx)(K,{value:`tagged`,children:e.tts.triggerTagged}),(0,X.jsx)(K,{value:`always`,children:e.tts.triggerAlways})]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:e.tts.provider}),(0,X.jsx)(U,{className:Q(),value:n.provider,onChange:e=>ee(e.target.value),children:O.map(t=>(0,X.jsx)(K,{value:t.id,children:Vt(t.id,e)},t.id))}),(0,X.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[k?.configured?e.tts.configured:k?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${k.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,k?.description??Ut(n.provider,e)]})]})]}),(0,X.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,open:!F||n.provider===`tts-local-cli`,children:[(0,X.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,X.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:e.stt.apiKey}),(0,X.jsx)(tt,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,X.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Tt(n.provider)?` ${Tt(n.provider)}`:``]})]}),(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:e.stt.model}),(0,X.jsx)(U,{className:Q(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:v).map(e=>(0,X.jsx)(K,{value:e.id,children:e.name},e.id))})]}),(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:e.tts.voice}),(0,X.jsx)(U,{className:Q(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:y).map(e=>(0,X.jsx)(K,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Z),children:[(0,X.jsx)($,{children:e.tts.voice}),(0,X.jsx)(U,{className:Q(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:_.map(e=>(0,X.jsx)(K,{value:e.id,children:e.name},e.id))}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,X.jsx)($,{children:e.tts.localCli.preset}),(0,X.jsxs)(U,{className:Q(),value:``,onChange:e=>{let t=zt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,X.jsx)(K,{value:``,children:e.tts.localCli.presetPlaceholder}),zt.map(e=>(0,X.jsx)(K,{value:e.id,children:e.id},e.id))]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,X.jsx)($,{children:e.tts.localCli.command}),(0,X.jsx)(`input`,{className:i(Et(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)($,{children:e.tts.localCli.cwd}),(0,X.jsx)(`input`,{className:i(Et(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)($,{children:e.tts.localCli.outputFormat}),(0,X.jsxs)(U,{className:Q(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,X.jsx)(K,{value:`wav`,children:`wav`}),(0,X.jsx)(K,{value:`mp3`,children:`mp3`}),(0,X.jsx)(K,{value:`opus`,children:`opus`})]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,X.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,X.jsx)(`input`,{className:Et(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,M.length>0?(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:M.map(e=>(0,X.jsx)(an,{field:e,value:Gt(j,e),onChange:t=>ne(e,t),className:e.type===`textarea`?`sm:col-span-2`:Z},e.key))}):null]})]}),(0,X.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,X.jsxs)(g,{type:`button`,variant:`primary`,onClick:()=>void te(),disabled:S.status===`loading`,className:`h-9`,children:[S.status===`loading`?(0,X.jsx)(G,{className:`size-4 animate-spin`}):(0,X.jsx)(N,{className:`size-4`}),S.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,X.jsxs)(g,{type:`button`,variant:`secondary`,onClick:()=>{E(),C(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:S.status!==`playing`,className:`h-9`,children:[(0,X.jsx)(je,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,X.jsx)(`textarea`,{className:i(Et(),`mt-3 min-h-20 resize-y`),value:b,onChange:e=>x(e.target.value),maxLength:1e3}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-fg-subtle`,children:[b.length,`/1000`]}),S.status===`playing`||S.status===`done`?(0,X.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[S.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,S.summary]}):null,S.status===`error`?(0,X.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:S.message}):null]})]})]}):null]})]})}function rn(e){let t=(0,J.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`border-accent/45 bg-accent/10 text-fg shadow-surface dark:bg-accent/15`:`border-edge bg-surface-panel text-fg hover:border-accent/35 hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl border px-4 py-3 text-left transition-colors`,q,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,X.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,X.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,X.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,X.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,X.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,w]}),t[27]=n,t[28]=l,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function an(e){let t=(0,J.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,X.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,X.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(Kt(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,X.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,X.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,X.jsx)(U,{id:s,className:Q(),value:l,required:n.required,onChange:e=>a(Kt(n,e.target.value)),children:(n.options??[]).map(on)}):n.type===`textarea`?(0,X.jsx)(`textarea`,{id:s,className:i(Et(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Kt(n,e.target.value))}):n.type===`password`?(0,X.jsx)(W,{id:s,className:o,value:l,onChange:e=>a(Kt(n,e)),placeholder:n.placeholder,labels:C}):(0,X.jsx)(`input`,{id:s,className:Et(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Kt(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,X.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function on(e){return(0,X.jsx)(K,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,J.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function sn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function cn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Oe()}async function ln(e){let t=await l(c(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function un(e){let t=(0,J.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function dn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function fn(){return i(ae,I)}var pn=[`brave`,`tavily`,`bing`,`searxng`];function mn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var hn=ve();function gn(){let e=a(o(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!s(e=>e.token),[c,l]=(0,Y.useReducer)(hn,{form:null,baseline:null}),u=c.form,f=c.baseline,[p,m]=(0,Y.useState)(!1),[h,_]=(0,Y.useState)(null),v=(0,Y.useRef)(!1),x=(0,Y.useRef)(null),{data:S,error:C,isLoading:w,mutate:T}=R(r);Me({enabled:r,parsed:(0,Y.useMemo)(()=>S?.payload?.config===void 0?null:sn(S.payload.config),[S]),dirty:v.current,trackedParsedRef:x,dispatch:l,onResetDirty:()=>{v.current=!1}});let E=!!(r&&w&&S===void 0&&!C),D=C instanceof Error?C.message:C?String(C):null,O=(0,Y.useMemo)(()=>!u||!f?!1:JSON.stringify(u)!==JSON.stringify(f),[u,f]),k=(0,Y.useCallback)(e=>{v.current=!0,l({type:`patch`,patch:e})},[]);return lt({id:`search`,dirty:O,saving:p,save:(0,Y.useCallback)(async()=>{if(!(!u||p)){m(!0),_(null);try{await cn(u),v.current=!1,l({type:`saved`,value:u}),d({type:`success`,title:t.saved})}catch(e){_(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[u,p,t.saveError]),discard:(0,Y.useCallback)(()=>{f&&(v.current=!1,l({type:`discard`}),_(null))},[f])}),r?E?(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,X.jsx)(G,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading})]}):u?(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,X.jsxs)(ot,{children:[(0,X.jsx)(at,{icon:H,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,X.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,X.jsx)(un,{label:t.regionLabel,description:t.regionDesc,children:(0,X.jsxs)(U,{className:fn(),value:u.regionMode,onChange:e=>k({regionMode:e.target.value}),children:[(0,X.jsx)(K,{value:`auto`,children:t.regionAuto}),(0,X.jsx)(K,{value:`cn`,children:t.regionCn}),(0,X.jsx)(K,{value:`global`,children:t.regionGlobal})]})})})]}),(0,X.jsx)(rt,{children:(0,X.jsxs)(ot,{children:[(0,X.jsx)(at,{icon:y,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,X.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:u.blocklistEnabled,onChange:e=>k({blocklistEnabled:e.target.checked})}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,X.jsx)(un,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,X.jsx)(`textarea`,{className:i(dn(),`min-h-[6rem] font-mono text-xs`),value:u.blocklistDomains.join(`
|
|
2
|
-
`),placeholder:t.blocklistDomainsPlaceholder,disabled:!u.blocklistEnabled,onChange:e=>{k({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,X.jsxs)(ot,{children:[(0,X.jsx)(at,{icon:H,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,X.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,X.jsx)(un,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,X.jsx)(`input`,{type:`number`,min:1,max:50,className:dn(),value:u.maxResults,onChange:e=>k({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),u.providers.map((n,r)=>(0,X.jsx)(_n,{row:n,providerIndex:r,labels:t,secretLabels:b(e.providersSettings),onChange:e=>{let t=[...u.providers];t[r]=e,k({providers:t})},onRemove:()=>{k({providers:u.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,X.jsxs)(g,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>k({providers:[...u.providers,mn()]}),children:[(0,X.jsx)(V,{className:`size-4`}),t.addProvider]})]})]})]}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??D??t.loadError}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>void T(),children:n.refresh})]}):(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function _n(e){let t=(0,J.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>ln(r).then(vn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(fn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,m;t[3]!==s||t[4]!==n?(m=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=m):m=t[5];let h;t[6]===a.providerTypes?h=t[7]:(h=pn.map(e=>(0,X.jsx)(K,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=h);let _;t[8]!==n.type||t[9]!==m||t[10]!==h?(_=(0,X.jsx)(U,{className:d,value:f,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=_):_=t[11];let v;t[12]!==s||t[13]!==n?(v=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=v):v=t[14];let y;t[15]!==n.disabled||t[16]!==v?(y=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:v}),t[15]=n.disabled,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==a.disabled||t[19]!==y?(b=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[y,a.disabled]}),t[18]=a.disabled,t[19]=y,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(p,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===c?S=t[23]:(S=(0,X.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:x}),t[22]=c,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==_?(w=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[_,C]}),t[27]=C,t[28]=_,t[29]=w):w=t[29];let T;t[30]!==a.urlDesc||t[31]!==a.urlLabel||t[32]!==s||t[33]!==n?(T=n.type===`searxng`?(0,X.jsx)(un,{label:a.urlLabel,description:a.urlDesc,children:(0,X.jsx)(`input`,{type:`url`,className:dn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=a.urlDesc,t[31]=a.urlLabel,t[32]=s,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==s||t[36]!==n?(E=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==a.keyPlaceholder||t[39]!==a.keyPlaceholderMasked||t[40]!==a.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==o||t[44]!==E?(D=(0,X.jsx)(W,{value:n.apiKey,onChange:E,placeholder:a.keyPlaceholder,labels:o,reveal:u,loadFailedLabel:a.saveError,notInConfigFile:a.keyPlaceholderMasked}),t[38]=a.keyPlaceholder,t[39]=a.keyPlaceholderMasked,t[40]=a.saveError,t[41]=u,t[42]=n.apiKey,t[43]=o,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==a.apiKeyDesc||t[47]!==a.apiKeyLabel||t[48]!==D?(O=(0,X.jsx)(un,{label:a.apiKeyLabel,description:a.apiKeyDesc,children:D}),t[46]=a.apiKeyDesc,t[47]=a.apiKeyLabel,t[48]=D,t[49]=O):O=t[49];let k;return t[50]!==w||t[51]!==T||t[52]!==O?(k=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[w,T,O]}),t[50]=w,t[51]=T,t[52]=O,t[53]=k):k=t[53],k}function vn(e){return e.apiKey??null}function yn(){let e=(0,J.c)(31),t=s(wn),n=!!t,{data:r,isLoading:i}=R(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},e[4]=l):l=e[4];let{data:u,isLoading:d}=f(a,o,l),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=f(n?Ne:null,Cn,p),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=f(n?Se:null,Sn,v),b;bb0:{if(!u||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==u||e[12]!==_?(t=de(u,ie(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=u,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=O(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==u||e[19]!==_){w=[];let t=new Set((u??[]).filter(xn).map(bn)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=u,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||d||h,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function bn(e){return e.id}function xn(e){return e.configured}function Sn(){return le()}function Cn(){return Le()}function wn(e){return e.token}function Tn(e){let t=(0,J.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=yn();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-surface-hover`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(Dn)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(En),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(V,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,X.jsxs)(g,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,X.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,X.jsxs)(g,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,X.jsx)(V,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,X.jsx)(On,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function En(e){return e.configured}function Dn(e){return(0,X.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function On(e){let t=(0,J.c)(28),{card:n,labels:r,onManage:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=i(`group relative flex flex-col justify-between rounded-2xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,X.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,X.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(_e,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(He,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,X.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==a||t[25]!==g||t[26]!==d?(_=(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,g]}),t[24]=a,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function kn(e){let t=await u(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function An(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function jn(e,t){let n=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function Mn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Nn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Pn(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Fn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function In(e){let t=new Map;for(let e of Fn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Ln(e){let t=(0,J.c)(22),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Y.useState)(u),[p,m]=(0,Y.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(Ie,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,he)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,Ve),t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==o||t[10]!==v||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(x=(0,X.jsxs)(Ee,{children:[y,(0,X.jsx)(Re,{className:b,children:d.type===`pick`?(0,X.jsx)(zn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>{let t=L(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,X.jsx)(Bn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,X.jsx)(Un,{initialPresetKey:d.presetKey,customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=a,t[9]=o,t[10]=v,t[11]=s,t[12]=c,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=x):x=t[17];let S;return t[18]!==g||t[19]!==n||t[20]!==x?(S=(0,X.jsx)(me,{open:n,onOpenChange:g,children:x}),t[18]=g,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function Rn(e){let t=(0,J.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,X.jsx)(xe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function zn(e){let t=(0,J.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:a,labels:o,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=Ae[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=In(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,X.jsx)(Pe,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let g;t[11]===o.close?g=t[12]:(g=(0,X.jsx)(Rn,{label:o.close}),t[11]=o.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(H,{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[16]=v):v=t[16];let y;t[17]===a?y=t[18]:(y=e=>a(e.target.value),t[17]=a,t[18]=y);let b=o.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,q),t[19]=S):S=t[19];let C;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==y?(C=(0,X.jsx)(`div`,{className:`px-5 pt-3`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[v,(0,X.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=y,t[23]=C):C=t[23];let w;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(w=u?null:(0,X.jsxs)(`button`,{type:`button`,onClick:c,className:i(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.press),children:[(0,X.jsx)(x,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,X.jsx)(be,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=w):w=t[28];let T;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(T=f.length===0?(0,X.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:Fn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:i(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.press),children:[(0,X.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,X.jsx)(_e,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=T):T=t[34];let E;t[35]!==w||t[36]!==T?(E=(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[w,T]}),t[35]=w,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==C||t[39]!==E||t[40]!==_?(D=(0,X.jsxs)(X.Fragment,{children:[_,C,E]}),t[38]=C,t[39]=E,t[40]=_,t[41]=D):D=t[41],D}function Bn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=Ae[e],[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),x=(0,Y.useRef)(null),S=a(r).providersSettings,C=b(S),w=(0,Y.useMemo)(()=>h(e,r),[e,r]),T=c?.supportsApiKey!==!1,E=c?.supportsOAuth===!0,[D,O]=(0,Y.useState)(null),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(`idle`),[N,P]=(0,Y.useState)(null),[F,I]=(0,Y.useState)(null),[L,R]=(0,Y.useState)(``),ee=j===`waiting`||j===`waiting_code`;(0,Y.useEffect)(()=>{if(!D||!ee)return;let e=window.setInterval(()=>{(async()=>{try{let t=await An(D);t.status===`waiting_auth`||t.status===`waiting_code`?(M(t.status===`waiting_code`?`waiting_code`:`waiting`),A(t.message??null),P(t.authUrl??null),I(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),M(`success`),A(t.message??S.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),M(`error`),A(t.error??t.message??S.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[D,ee,s,S.revokeFailed,S.saved]),(0,Y.useEffect)(()=>()=>{D&&Nn(D).catch(()=>{})},[D]);let te=async()=>{M(`waiting`),A(S.oauthStarting),_(null);try{O((await kn(e)).sessionId)}catch(e){M(`error`),A(e instanceof Error?e.message:S.revokeFailed)}},z=async()=>{if(D){try{await Mn(D)}catch{}M(`idle`),A(null),O(null),P(null),I(null)}},ne=async()=>{if(!(!D||!L.trim()))try{await jn(D,L.trim()),R(``),A(S.oauthProcessingCode)}catch(e){M(`error`),A(e instanceof Error?e.message:S.revokeFailed)}},V=async()=>{let t=u.trim();if(!(!t||!T)){p(!0),_(null);try{await pe({[e]:t}),y(!0),window.setTimeout(s,600)}catch(e){_(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),"aria-label":n.back,children:(0,X.jsx)(be,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,X.jsx)(Pe,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,X.jsx)(Rn,{label:n.close})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,T?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,X.jsx)(W,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:C,inputRef:x,onKeyDown:e=>{e.key===`Enter`&&V()}})]}):null,E?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:S.oauth}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:S.oauthHint})]}),(0,X.jsxs)(g,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ee,onClick:()=>void te(),children:[ee?(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,S.oauth]})]}),k?(0,X.jsx)(`p`,{className:i(`text-xs`,j===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:k}):null,j===`waiting`||j===`waiting_code`?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,X.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[S.openAuthPage,(0,X.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>void z(),children:S.cancelOAuth})]}):null,F?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:F}):null,j===`waiting_code`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ne(),placeholder:S.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)}),(0,X.jsx)(g,{type:`button`,variant:`primary`,onClick:()=>void ne(),children:S.submitCode})]}):null]}):null,w.length>0&&T?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.map(({kind:e,href:t})=>(0,X.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[ke(e,n),(0,X.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),T?(0,X.jsx)(g,{type:`button`,variant:`primary`,disabled:!u.trim()||f||v,onClick:()=>void V(),children:v?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Vn(e=`custom`){if(e!==`custom`&&z[e]){let t=z[e].config;return{preset:e,providerId:Ge(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Hn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:z[t.key]?Vn(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Un({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:o,onSaved:s}){let[c,l]=(0,Y.useReducer)(Hn,void 0,()=>Vn(e)),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=b(a(r).providersSettings),{preset:h,providerId:_,baseUrl:y,api:x,apiKey:S,modelIds:C,error:w}=c,T=async()=>{let e=_.trim(),r=y.trim();if(!e){l({type:`setError`,value:n.providerIdRequired});return}if(!r){l({type:`setError`,value:n.baseUrlRequired});return}let i=C.map(e=>e.trim()).filter(Boolean);d(!0),l({type:`setError`,value:null});try{let n=t?.providers??{},a=h===`custom`?void 0:z[h]?.config,o={...a??{},baseUrl:r,api:x,apiKey:S.trim()||void 0,models:i.map(e=>a?.models?.find(t=>t.id===e)??{id:e})};await F({providers:{...n,[e]:o}}),s()}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},E=async()=>{let e=_.trim()||Ge(h)||`custom`,t=y.trim();if(!t){l({type:`setError`,value:n.baseUrlRequired});return}p(!0),l({type:`setError`,value:null});try{let r=h===`custom`?void 0:z[h]?.config,i=(await se({providerId:e,baseUrl:t,apiKey:S.trim()||void 0,api:x,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));l({type:`setModelIds`,values:i}),i.length===0&&l({type:`setError`,value:n.discoverModelsHint})}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},D=_.trim()&&y.trim(),O=(x===`openai-completions`||x===`openai-responses`)&&y.trim();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),"aria-label":n.back,children:(0,X.jsx)(be,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,X.jsx)(Pe,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,X.jsx)(Rn,{label:n.close})]}),(0,X.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,X.jsxs)(U,{id:`custom-preset`,value:h,onChange:e=>l({type:`applyPreset`,key:e.target.value}),className:v(),children:[(0,X.jsx)(K,{value:`custom`,children:n.presetCustom}),re.map(e=>(0,X.jsx)(K,{value:e.key,children:e.label},e.key))]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,X.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:_,onChange:e=>l({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)})]}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,X.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:y,onChange:e=>l({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,X.jsx)(U,{id:`custom-api-type`,value:x,onChange:e=>l({type:`setApi`,value:e.target.value}),className:v(),children:ce.map(e=>(0,X.jsx)(K,{value:e.value,children:e.label},e.value))})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,X.jsx)(W,{id:`custom-api-key`,value:S,onChange:e=>l({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,X.jsxs)(g,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!O||f,onClick:()=>void E(),children:[f?(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),C.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>l({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)}),C.length>1?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l({type:`removeModelSlot`,index:t}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,B.press),children:(0,X.jsx)(A,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,X.jsxs)(g,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>l({type:`addModelSlot`}),children:[(0,X.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),w?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),(0,X.jsx)(g,{type:`button`,variant:`primary`,disabled:!D||u,onClick:()=>void T(),children:u?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Wn(e){let t=(0,J.c)(156),{model:n,isNew:r,providerId:a,onSave:o,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:j(``),t[0]=n,t[1]=l);let[u,d]=(0,Y.useState)(l),[f,p]=(0,Y.useState)(Gn),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,_;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(_=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=_):_=t[8];let y=_,b;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim();o({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=o,t[12]=y,t[13]=b):b=t[13];let x=b,S=u,C;t[14]===S?C=t[15]:(C=oe(S),t[14]=S,t[15]=C);let w=C,T=r?c.addModelTitle:c.editModelTitle,D;t[16]===T?D=t[17]:(D=(0,X.jsx)(Pe,{className:`text-base font-semibold text-fg`,children:T}),t[16]=T,t[17]=D);let O;t[18]!==c.modelProviderLabel||t[19]!==a?(O=a?(0,X.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,a]}):null,t[18]=c.modelProviderLabel,t[19]=a,t[20]=O):O=t[20];let k;t[21]!==D||t[22]!==O?(k=(0,X.jsxs)(`div`,{children:[D,O]}),t[21]=D,t[22]=O,t[23]=k):k=t[23];let M;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(M=i(te,`p-1.5 hover:bg-surface-base`),t[24]=M):M=t[24];let N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(A,{className:`size-4`}),t[25]=N):N=t[25];let F;t[26]===c.close?F=t[27]:(F=(0,X.jsx)(xe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:M,"aria-label":c.close,children:N})}),t[26]=c.close,t[27]=F);let I;t[28]!==k||t[29]!==F?(I=(0,X.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[k,F]}),t[28]=k,t[29]=F,t[30]=I):I=t[30];let L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=L):L=t[31];let R;t[32]===c.modelId?R=t[33]:(R=(0,X.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,L]}),t[32]=c.modelId,t[33]=R);let z;t[34]===f?z=t[35]:(z=i(E(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=z);let ne=u.id||``,B;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>h(`id`,e.target.value),t[36]=B):B=t[36];let V=!r,re;t[37]!==z||t[38]!==ne||t[39]!==V?(re=(0,X.jsx)(`input`,{className:z,value:ne,onChange:B,placeholder:`e.g. llama3.1:8b`,disabled:V}),t[37]=z,t[38]=ne,t[39]=V,t[40]=re):re=t[40];let ie;t[41]===f?ie=t[42]:(ie=f.has(`id`)?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=ie);let ae;t[43]!==R||t[44]!==re||t[45]!==ie?(ae=(0,X.jsxs)(`div`,{children:[R,re,ie]}),t[43]=R,t[44]=re,t[45]=ie,t[46]=ae):ae=t[46];let H;t[47]===c.displayName?H=t[48]:(H=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=H);let se;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(se=E(),t[49]=se):se=t[49];let ce=u.name||``,le;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>h(`name`,e.target.value),t[50]=le):le=t[50];let ue;t[51]===ce?ue=t[52]:(ue=(0,X.jsx)(`input`,{className:se,value:ce,onChange:le}),t[51]=ce,t[52]=ue);let de;t[53]!==H||t[54]!==ue?(de=(0,X.jsxs)(`div`,{children:[H,ue]}),t[53]=H,t[54]=ue,t[55]=de):de=t[55];let fe;t[56]===c.inputTypes?fe=t[57]:(fe=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=fe);let pe;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(pe=v(),t[58]=pe):pe=t[58];let me;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>h(`input`,P(e.target.value)),t[59]=me):me=t[59];let he;t[60]===c?he=t[61]:(he=ee.map(e=>(0,X.jsx)(K,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=he);let ge;t[62]!==w||t[63]!==he?(ge=(0,X.jsx)(U,{className:pe,value:w,onChange:me,children:he}),t[62]=w,t[63]=he,t[64]=ge):ge=t[64];let _e;t[65]!==fe||t[66]!==ge?(_e=(0,X.jsxs)(`div`,{children:[fe,ge]}),t[65]=fe,t[66]=ge,t[67]=_e):_e=t[67];let ve=u.reasoning||!1,ye;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>h(`reasoning`,e.target.checked),t[68]=ye):ye=t[68];let be;t[69]===ve?be=t[70]:(be=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ve,onChange:ye}),t[69]=ve,t[70]=be);let Se;t[71]!==c.reasoning||t[72]!==be?(Se=(0,X.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[be,c.reasoning]}),t[71]=c.reasoning,t[72]=be,t[73]=Se):Se=t[73];let Ce;t[74]!==_e||t[75]!==Se?(Ce=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[_e,Se]}),t[74]=_e,t[75]=Se,t[76]=Ce):Ce=t[76];let we;t[77]===c.contextWindow?we=t[78]:(we=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=we);let Te;t[79]===f?Te=t[80]:(Te=i(E(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=Te);let Ee=u.contextWindow??128e3,De;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(De=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=De):De=t[81];let Oe;t[82]!==Te||t[83]!==Ee?(Oe=(0,X.jsx)(`input`,{type:`number`,min:1,className:Te,value:Ee,onChange:De}),t[82]=Te,t[83]=Ee,t[84]=Oe):Oe=t[84];let ke;t[85]===f?ke=t[86]:(ke=f.has(`contextWindow`)?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=ke);let W;t[87]!==we||t[88]!==Oe||t[89]!==ke?(W=(0,X.jsxs)(`div`,{children:[we,Oe,ke]}),t[87]=we,t[88]=Oe,t[89]=ke,t[90]=W):W=t[90];let Ae;t[91]===c.maxOutputTokens?Ae=t[92]:(Ae=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=Ae);let je;t[93]===f?je=t[94]:(je=i(E(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=je);let Me=u.maxTokens??16384,Ne;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Ne):Ne=t[95];let G;t[96]!==je||t[97]!==Me?(G=(0,X.jsx)(`input`,{type:`number`,min:1,className:je,value:Me,onChange:Ne}),t[96]=je,t[97]=Me,t[98]=G):G=t[98];let Fe;t[99]===f?Fe=t[100]:(Fe=f.has(`maxTokens`)?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Fe);let Ie;t[101]!==Ae||t[102]!==G||t[103]!==Fe?(Ie=(0,X.jsxs)(`div`,{children:[Ae,G,Fe]}),t[101]=Ae,t[102]=G,t[103]=Fe,t[104]=Ie):Ie=t[104];let Le;t[105]!==W||t[106]!==Ie?(Le=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[W,Ie]}),t[105]=W,t[106]=Ie,t[107]=Le):Le=t[107];let Re;t[108]===c.costSection?Re=t[109]:(Re=(0,X.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Re);let ze;t[110]===c.costInput?ze=t[111]:(ze=(0,X.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=ze);let Be;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Be=E(),t[112]=Be):Be=t[112];let Ve=u.cost?.input??0,He;t[113]===u.cost?He=t[114]:(He=e=>h(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=He);let Ue;t[115]!==Ve||t[116]!==He?(Ue=(0,X.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Be,value:Ve,onChange:He}),t[115]=Ve,t[116]=He,t[117]=Ue):Ue=t[117];let q;t[118]!==ze||t[119]!==Ue?(q=(0,X.jsxs)(`div`,{children:[ze,Ue]}),t[118]=ze,t[119]=Ue,t[120]=q):q=t[120];let We;t[121]===c.costOutput?We=t[122]:(We=(0,X.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=We);let Ge;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=E(),t[123]=Ge):Ge=t[123];let Ke=u.cost?.output??0,qe;t[124]===u.cost?qe=t[125]:(qe=e=>h(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=qe);let Je;t[126]!==Ke||t[127]!==qe?(Je=(0,X.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ge,value:Ke,onChange:qe}),t[126]=Ke,t[127]=qe,t[128]=Je):Je=t[128];let Ye;t[129]!==We||t[130]!==Je?(Ye=(0,X.jsxs)(`div`,{children:[We,Je]}),t[129]=We,t[130]=Je,t[131]=Ye):Ye=t[131];let Xe;t[132]!==q||t[133]!==Ye?(Xe=(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[q,Ye]}),t[132]=q,t[133]=Ye,t[134]=Xe):Xe=t[134];let Ze;t[135]!==Re||t[136]!==Xe?(Ze=(0,X.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Re,Xe]}),t[135]=Re,t[136]=Xe,t[137]=Ze):Ze=t[137];let Qe;t[138]!==ae||t[139]!==de||t[140]!==Ce||t[141]!==Le||t[142]!==Ze?(Qe=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ae,de,Ce,Le,Ze]}),t[138]=ae,t[139]=de,t[140]=Ce,t[141]=Le,t[142]=Ze,t[143]=Qe):Qe=t[143];let $e;t[144]===c.cancel?$e=t[145]:($e=(0,X.jsx)(xe,{asChild:!0,children:(0,X.jsx)(g,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=$e);let et=r?c.addModelConfirm:c.saveModelConfirm,tt;t[146]!==x||t[147]!==et?(tt=(0,X.jsx)(g,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:x,children:et}),t[146]=x,t[147]=et,t[148]=tt):tt=t[148];let nt;t[149]!==$e||t[150]!==tt?(nt=(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[$e,tt]}),t[149]=$e,t[150]=tt,t[151]=nt):nt=t[151];let rt;return t[152]!==I||t[153]!==Qe||t[154]!==nt?(rt=(0,X.jsxs)(X.Fragment,{children:[I,Qe,nt]}),t[152]=I,t[153]=Qe,t[154]=nt,t[155]=rt):rt=t[155],rt}function Gn(){return new Map}function Kn(e){let t=(0,J.c)(16),{open:n,onOpenChange:r,providerId:a,model:o,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(Ie,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,he)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,Ve,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==a?(f=n?(0,X.jsx)(Wn,{model:o,isNew:s,providerId:a,onSave:c,onClose:()=>r(!1),m:l},`${a??`none`}-${o?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=o,t[5]=r,t[6]=c,t[7]=n,t[8]=a,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,X.jsxs)(Ee,{children:[u,(0,X.jsx)(Re,{className:d,onOpenAutoFocus:qn,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,X.jsx)(me,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function qn(e){return e.preventDefault()}function Jn(e){let t=(0,J.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>m(n).then(Yn),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,X.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,X.jsx)(W,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Yn(e){return e.apiKey??null}function Xn(e){let t=(0,J.c)(16),{open:n,onOpenChange:r,providerId:a,isCustom:o,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(Ie,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,he)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,Ve),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,X.jsxs)(Ee,{children:[p,(0,X.jsx)(Re,{className:m,children:o?(0,X.jsx)(Qn,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,X.jsx)(Zn,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,X.jsx)(me,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Zn({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=Ae[e],d=n.filter(t=>t.provider===e),[f,m]=(0,Y.useState)(l?.apiKey??``),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(!1),T=a(o).providersSettings,E=l?.supportsApiKey!==!1,D=l?.supportsOAuth===!0,O=l?.authMode===`oauth`&&l.authStatus===`connected`,k=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(null),[F,I]=(0,Y.useState)(`idle`),[L,R]=(0,Y.useState)(null),[ee,te]=(0,Y.useState)(null),[z,ne]=(0,Y.useState)(``),V=F===`waiting`||F===`waiting_code`,re=(0,Y.useMemo)(()=>h(e,o),[e,o]),ie=f!==(l?.apiKey??``),ae=async()=>{let t=f.trim();if(!(!t||!E||fe(t))){v(!0),S(null);try{await pe({[e]:t}),b(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){S(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}};(0,Y.useEffect)(()=>{if(!j||!V)return;let e=window.setInterval(()=>{(async()=>{try{let t=await An(j);t.status===`waiting_auth`||t.status===`waiting_code`?(I(t.status===`waiting_code`?`waiting_code`:`waiting`),P(t.message??null),R(t.authUrl??null),te(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),I(`success`),P(t.message??T.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),I(`error`),P(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[j,V,s,c,T.revokeFailed,T.saved]),(0,Y.useEffect)(()=>()=>{j&&Nn(j).catch(()=>{})},[j]);let oe=async()=>{try{await Fe(e),c(),s()}catch{}},H=async()=>{I(`waiting`),P(T.oauthStarting),S(null);try{M((await kn(e)).sessionId)}catch(e){I(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},se=async()=>{if(j){try{await Mn(j)}catch{}I(`idle`),P(null),M(null),R(null),te(null)}},ce=async()=>{if(!(!j||!z.trim()))try{await jn(j,z.trim()),ne(``),P(T.oauthProcessingCode)}catch(e){I(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},le=async()=>{try{await Pn(e),c(),s()}catch(e){S(e instanceof Error?e.message:T.revokeFailed)}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(Pe,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,X.jsx)(xe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),children:(0,X.jsx)(A,{className:`size-4`,"aria-hidden":!0})})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,X.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:l.baseUrl})]}):l?.category===`extension`?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,E?(0,X.jsx)(Jn,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{m(e),b(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):l?.category===`extension`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,X.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,X.jsxs)(De,{to:`/settings/ext/${encodeURIComponent(l.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:s,children:[r.openExtensionSettings,(0,X.jsx)(We,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,D?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:O?T.sourceOauth:T.oauthHint})]}),O?(0,X.jsx)(g,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void le(),children:T.revoke}):(0,X.jsxs)(g,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:V,onClick:()=>void H(),children:[V?(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),N?(0,X.jsx)(`p`,{className:i(`text-xs`,F===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,F===`waiting`||F===`waiting_code`?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L?(0,X.jsxs)(`a`,{href:L,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,X.jsx)(We,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>void se(),children:T.cancelOAuth})]}):null,ee?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ee}):null,F===`waiting_code`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,X.jsx)(`input`,{type:`text`,value:z,onChange:e=>ne(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ce(),placeholder:T.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)}),(0,X.jsx)(g,{type:`button`,variant:`primary`,onClick:()=>void ce(),children:T.submitCode})]}):null]}):null,re.length>0&&E?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:re.map(({kind:e,href:t})=>(0,X.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[ke(e,r),(0,X.jsx)(We,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,X.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,X.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),x?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[k?(0,X.jsxs)(g,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>w(!0),children:[(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,X.jsx)(`span`,{}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:E&&ie&&!fe(f.trim())?(0,X.jsx)(g,{type:`button`,variant:`primary`,disabled:!f.trim()||_||y,onClick:()=>void ae(),children:y?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,X.jsx)(we,{open:C,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void oe(),onCancel:()=>w(!1)})]})}function Qn({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,Y.useState)(l?.baseUrl??``),[f,m]=(0,Y.useState)(l?.apiKey??``),[h,v]=(0,Y.useState)(l?.models??[]),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(!1),[k,j]=(0,Y.useState)(null),M=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:fe(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},N=async()=>{let e=M({models:h});if(e){b(!0),S(null);try{await F(e),s(),o()}catch(e){S(e instanceof Error?e.message:n.saveError)}finally{b(!1)}}},P=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await F({providers:r}),s(),o()}catch{}},I=(e,t)=>{j({model:e,isNew:t}),O(!0)},L=async e=>{if(!k)return;let t=k.isNew?[...h,e]:h.map(t=>t.id===e.id?e:t);v(t);let r=M({models:t});if(r)try{await F(r),s()}catch(e){S(e instanceof Error?e.message:n.saveError)}},R=async e=>{let t=h.filter(t=>t.id!==e);v(t),E(null);let r=M({models:t});if(r)try{await F(r),s()}catch(e){S(e instanceof Error?e.message:n.saveError)}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Pe,{className:`text-base font-semibold text-fg`,children:e}),(0,X.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,X.jsx)(xe,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),children:(0,X.jsx)(A,{className:`size-4`,"aria-hidden":!0})})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,X.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)})]}),(0,X.jsx)(Jn,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:m,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,X.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,h.length>0?` (${h.length})`:``]}),(0,X.jsxs)(g,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>I(null,!0),children:[(0,X.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),h.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,X.jsx)(`ul`,{className:`space-y-2`,children:h.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,X.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),onClick:()=>I(e,!1),"aria-label":c.editModel,children:(0,X.jsx)(_,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,B.press),onClick:()=>E(e.id),"aria-label":c.removeModel,children:(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),x?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,X.jsxs)(g,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>w(!0),children:[(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(g,{type:`button`,variant:`primary`,disabled:y,onClick:()=>void N(),children:y?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,X.jsx)(we,{open:C,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void P(),onCancel:()=>w(!1)}),(0,X.jsx)(we,{open:T!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,T??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{T&&R(T)},onCancel:()=>E(null)}),(0,X.jsx)(Kn,{open:D,onOpenChange:e=>{O(e),e||j(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void L(e),m:c})]})}var $n=[`services`,`image-models`,`voice`,`search`];function er(e){let t=(e??``).trim();return $n.includes(t)?t:`services`}function tr(){let e=(0,J.c)(59),t=o(rr),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.modelsHub,[s,c]=M(),l;e[2]===s?l=e[3]:(l=er(s.get(`tab`)),e[2]=s,e[3]=l);let u=l,[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),h=yn(),g;e[4]!==i.servicesHint||e[5]!==i.tabs.services?(g={id:`services`,icon:T,label:i.tabs.services,hint:i.servicesHint},e[4]=i.servicesHint,e[5]=i.tabs.services,e[6]=g):g=e[6];let _;e[7]!==i.imageModelsHint||e[8]!==i.tabs.imageModels?(_={id:`image-models`,icon:Ue,label:i.tabs.imageModels,hint:i.imageModelsHint},e[7]=i.imageModelsHint,e[8]=i.tabs.imageModels,e[9]=_):_=e[9];let v;e[10]!==i.tabs.voice||e[11]!==i.voiceHint?(v={id:`voice`,icon:ue,label:i.tabs.voice,hint:i.voiceHint},e[10]=i.tabs.voice,e[11]=i.voiceHint,e[12]=v):v=e[12];let y;e[13]!==i.searchHint||e[14]!==i.tabs.search?(y={id:`search`,icon:H,label:i.tabs.search,hint:i.searchHint},e[13]=i.searchHint,e[14]=i.tabs.search,e[15]=y):y=e[15];let b;e[16]!==g||e[17]!==_||e[18]!==v||e[19]!==y?(b=[g,_,v,y],e[16]=g,e[17]=_,e[18]=v,e[19]=y,e[20]=b):b=e[20];let x=b,S;e[21]===c?S=e[22]:(S=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=S);let C=S,w=nr,E=r.settingsSections.credentials,D=i.subtitle,O;e[23]===t?O=e[24]:(O=ye(t,`configuration`),e[23]=t,e[24]=O);let A;e[25]!==i.docsLink||e[26]!==i.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==O?(A=(0,X.jsx)(st,{title:E,subtitle:D,docsLink:O,docsLabel:i.docsLink}),e[25]=i.docsLink,e[26]=i.subtitle,e[27]=r.settingsSections.credentials,e[28]=O,e[29]=A):A=e[29];let j;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,X.jsx)(ut,{}),e[30]=j):j=e[30];let N;e[31]!==u||e[32]!==i.tabsAria||e[33]!==C||e[34]!==x?(N=(0,X.jsx)(k,{items:x,activeTab:u,onChange:C,ariaLabel:i.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=u,e[32]=i.tabsAria,e[33]=C,e[34]=x,e[35]=N):N=e[35];let P;e[36]!==u||e[37]!==i.connectedProviders||e[38]!==x?(P=x.map(e=>(0,X.jsx)(ar,{id:e.id,activeTab:u,hint:e.hint,children:e.id===`services`?(0,X.jsx)(Tn,{labels:i.connectedProviders,onAdd:()=>f(!0),onManage:(e,t)=>m({providerId:e,isCustom:t})}):(0,X.jsx)(ir,{tab:e.id})},e.id)),e[36]=u,e[37]=i.connectedProviders,e[38]=x,e[39]=P):P=e[39];let F;e[40]!==d||e[41]!==i.addProviderDialog||e[42]!==t||e[43]!==h.builtinRows||e[44]!==h.customConfig?(F=(0,X.jsx)(Ln,{open:d,onOpenChange:f,builtinRows:h.builtinRows,customConfig:h.customConfig,labels:i.addProviderDialog,language:t,onSaved:w}),e[40]=d,e[41]=i.addProviderDialog,e[42]=t,e[43]=h.builtinRows,e[44]=h.customConfig,e[45]=F):F=e[45];let I;e[46]!==i.manageProviderDialog||e[47]!==t||e[48]!==p||e[49]!==h.allModels||e[50]!==h.builtinRows||e[51]!==h.customConfig?(I=p?(0,X.jsx)(Xn,{open:!0,onOpenChange:e=>{e||m(null)},providerId:p.providerId,isCustom:p.isCustom,builtinRows:h.builtinRows,customConfig:h.customConfig,allModels:h.allModels,labels:i.manageProviderDialog,language:t,onSaved:w}):null,e[46]=i.manageProviderDialog,e[47]=t,e[48]=p,e[49]=h.allModels,e[50]=h.builtinRows,e[51]=h.customConfig,e[52]=I):I=e[52];let L;return e[53]!==A||e[54]!==N||e[55]!==P||e[56]!==F||e[57]!==I?(L=(0,X.jsxs)(ct,{children:[A,j,N,P,F,I]}),e[53]=A,e[54]=N,e[55]=P,e[56]=F,e[57]=I,e[58]=L):L=e[58],L}function nr(){ze()}function rr(e){return e.language}function ir(e){let t=(0,J.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ct,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Jt,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(gn,{}),t[2]=e):e=t[2],e}}}function ar({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,Y.useRef)(a);return a&&(o.current=!0),o.current?(0,X.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(`min-w-0 rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,a?`flex flex-col gap-3`:void 0),children:[a?(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{tr as ModelsHubPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{Fc as n}from"./index-DdqSO9R2.js";import{t as r}from"./notes-workbench-mqRJYnJS.js";var i=e(),a=t();function o(){let e=(0,i.c)(2),{noteId:t}=n(),o;return e[0]===t?o=e[1]:(o=(0,a.jsx)(r,{selectedNoteId:t,basePath:`/notes`,managePageHeader:!0,showLibrary:!0,allowMediaCapture:!0,listWidthStorageKey:`xopc.notes.listWidth`}),e[0]=t,e[1]=o),o}export{o as NotesPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-DfndiO3h.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-DdqSO9R2.js","assets/preload-helper-zJ_50EbN.js","assets/dist-Mys7eFJ5.js","assets/Combination-HAlzriaz.js","assets/vendor-react-BOUWij0V.js","assets/cn-BQ_8x0bT.js","assets/vendor-swr-BIWyz7Rc.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-Ba72bFmP.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-B5O4OIEo.js","assets/fetch-ovkvM8KQ.js","assets/gateway-startup-retry-CanQ8UcR.js","assets/toast-z0toXu32.js","assets/theme-store-Bt6vAkSB.js","assets/index-jGB-2nI-.css","assets/vendor-codemirror-CNP1wPe7.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-AssmZFx4.js","assets/code-editor-dZTY2dRW.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{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-B5O4OIEo.js";import{c as s,n as c}from"./locale-store-Ba72bFmP.js";import{i as l}from"./theme-store-Bt6vAkSB.js";import{c as u}from"./fetch-ovkvM8KQ.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$a as p,$o as m,Bo as h,Cn as g,Dc as _,En as v,Fs as y,Ha as b,Io as x,Oc as S,On as C,Oo as w,Pc as T,Po as E,Qs as D,Ro as O,Rs as k,So as A,Ss as j,Tc as M,Tn as N,Uo as P,Vo as F,Vs as I,Xo as L,Ys as ee,_n as te,aa as ne,an as re,bn as R,cn as ie,dn as z,do as B,ea as V,eo as H,fn as ae,fo as U,gn as W,hn as oe,i as se,ia as ce,la as le,ln as ue,lo as G,mn as de,ms as fe,na as pe,ns as me,oa as he,on as ge,oo as _e,pn as ve,ra as K,sa as ye,sn as q,ta as be,to as xe,un as J,ut as Se,vn as Ce,vs as we,wn as Te,xn as Ee,xo as De,xs as Oe,yc as ke,yn as Ae,ys as je,zo as Me}from"./index-DdqSO9R2.js";import{a as Ne,i as Pe,n as Y,o as Fe,r as Ie,t as Le}from"./dist-wO9a2_ID.js";import{t as Re}from"./automation-suggestion-card-BKHewSVT.js";var X=e(t(),1),Z=n(),Q=r(),ze={noteId:null,attachmentId:null,playing:!1,currentTime:0,duration:0,loading:!1},$=null,Be=null,Ve=null,He=null;function Ue(){return $||($=new Audio,$.addEventListener(`timeupdate`,()=>{Ge.setState({currentTime:$.currentTime})}),$.addEventListener(`loadedmetadata`,()=>{let e=$.duration;Number.isFinite(e)&&Ge.setState({duration:e})}),$.addEventListener(`ended`,()=>{Ge.setState({playing:!1,currentTime:0}),$.currentTime=0}),$.addEventListener(`pause`,()=>{Ge.setState({playing:!1})}),$.addEventListener(`play`,()=>{Ge.setState({playing:!0})})),$}function We(){Ve&&He&&v(Ve,He),Be=null,Ve=null,He=null}var Ge=s()((e,t)=>({...ze,play:async(n,r,i)=>{let a=Ue(),o=t();if(o.noteId===n&&o.attachmentId===r&&Be){a.play();return}a.pause(),We(),e({noteId:n,attachmentId:r,playing:!1,currentTime:0,duration:i??0,loading:!0});try{let t=await N(n,r);Be=t,Ve=n,He=r,a.src=t,await a.play(),e({loading:!1})}catch{e({loading:!1,playing:!1}),We()}},pause:()=>{Ue().pause()},toggle:(e,n,r)=>{let i=t();i.noteId===e&&i.attachmentId===n&&i.playing?t().pause():t().play(e,n,r)},seek:t=>{let n=Ue();n.currentTime=t,e({currentTime:t})},reset:()=>{Ue().pause(),Ue().src=``,We(),e(ze)}})),Ke=(0,X.createContext)(null);function qe(){let e=(0,Z.c)(1),t=(0,X.useContext)(Ke);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:Je},e[0]=t):t=e[0],t}return t}function Je(){}function Ye(e){let t=(0,Z.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[o,s]=(0,X.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=o!==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,Q.jsx)(K,{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=a(`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 g=o?.alt||`Image preview`,_;t[5]===g?_=t[6]:(_=(0,Q.jsx)(he,{className:`sr-only`,children:g}),t[5]=g,t[6]=_);let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(b,{className:`h-5 w-5`,"aria-hidden":!0}),t[7]=v):v=t[7];let y;t[8]===i?y=t[9]:(y=(0,Q.jsx)(V,{asChild:!0,children:(0,Q.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:v})}),t[8]=i,t[9]=y);let x;t[10]===o?x=t[11]:(x=o?(0,Q.jsx)(`img`,{src:o.src,alt:o.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=o,t[11]=x);let S;t[12]!==y||t[13]!==x||t[14]!==_?(S=(0,Q.jsxs)(ce,{children:[m,(0,Q.jsxs)(be,{className:h,"aria-describedby":void 0,children:[_,y,x]})]}),t[12]=y,t[13]=x,t[14]=_,t[15]=S):S=t[15];let C;t[16]!==S||t[17]!==f?(C=(0,Q.jsx)(ne,{open:f,onOpenChange:p,children:S}),t[16]=S,t[17]=f,t[18]=C):C=t[18];let w;return t[19]!==n||t[20]!==C?(w=(0,Q.jsxs)(Ke.Provider,{value:d,children:[n,C]}),t[19]=n,t[20]=C,t[21]=w):w=t[21],w}function Xe(e){let t=(0,Z.c)(15),{noteId:n,attachmentId:r,className:i}=e,[o,s]=(0,X.useState)(!1),c;t[0]!==r||t[1]!==n?(c=C(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(o){let e;t[3]===i?e=t[4]:(e=a(`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,Q.jsx)(Oe,{className:`h-4 w-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,Q.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=a(`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,Q.jsx)(Te,{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 Ze=6e4,Qe=36e5,$e=864e5;function et(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function tt(e,t,n){let r=t-e;if(r<Ze)return n.justNow;if(r<Qe){let e=Math.floor(r/Ze);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=et(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(e>=i-$e)return n.yesterday+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(r<7*$e){let e=Math.floor(r/$e);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function nt(e,t,n){let r=et(t);if(e>=r)return n.today;if(e>=r-$e)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 rt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function it(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 at(e){let t=(0,Z.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:o}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=Ge(),p=Ge(st),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 S=b,C;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==p?(C=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]=C):C=t[9];let w=C,T;t[10]===o?T=t[11]:(T=a(`flex items-center gap-2`,o),t[10]=o,t[11]=T);let E=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,D;t[12]===E?D=t[13]:(D=a(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,E),t[12]=E,t[13]=D);let O=h?`Pause`:`Play`,k;t[14]!==g||t[15]!==h?(k=g?(0,Q.jsx)(me,{className:`h-3.5 w-3.5 animate-spin`}):h?(0,Q.jsx)(F,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(x,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=g,t[15]=h,t[16]=k):k=t[16];let A;t[17]!==S||t[18]!==w||t[19]!==D||t[20]!==O||t[21]!==k?(A=(0,Q.jsx)(`button`,{type:`button`,onClick:S,onKeyDown:w,className:D,"aria-label":O,children:k}),t[17]=S,t[18]=w,t[19]=D,t[20]=O,t[21]=k,t[22]=A):A=t[22];let j=`${y}%`,M;t[23]===j?M=t[24]:(M=(0,Q.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:j}})}),t[23]=j,t[24]=M);let N;t[25]!==v||t[26]!==m||t[27]!==_?(N=it(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,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:N}),t[29]=N,t[30]=P);let I;t[31]!==M||t[32]!==P?(I=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=I):I=t[33];let L;return t[34]!==I||t[35]!==T||t[36]!==A?(L=(0,Q.jsxs)(`div`,{className:T,onClick:ot,children:[A,I]}),t[34]=I,t[35]=T,t[36]=A,t[37]=L):L=t[37],L}function ot(e){return e.stopPropagation()}function st(e){return e.toggle}function ct(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function lt(e){let t=(0,Z.c)(80),{note:n,selected:r,onPress:i,onPin:o,onArchive:s,onDelete:c,labels:l,timeLabels:u}=e,d=r===void 0?!1:r,f;t[0]!==l||t[1]!==n?(f=ct(n,l),t[0]=l,t[1]=n,t[2]=f):f=t[2];let m=f,h=!n.snippet?.trim(),[g]=(0,X.useState)(pt),_;t[3]!==n.createdAt||t[4]!==g||t[5]!==u?(_=tt(n.createdAt,g,u),t[3]=n.createdAt,t[4]=g,t[5]=u,t[6]=_):_=t[6];let v=_,y,b;t[7]!==n.id||t[8]!==i?(y=()=>i(n.id),b=e=>{(e.key===`Enter`||e.key===` `)&&i(n.id)},t[7]=n.id,t[8]=i,t[9]=y,t[10]=b):(y=t[9],b=t[10]);let x=d&&`border-edge bg-surface-active hover:bg-surface-active`,C;t[11]===x?C=t[12]:(C=a(`group relative flex cursor-pointer flex-col gap-2 rounded-lg px-3 py-2.5`,`border border-transparent 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`,x),t[11]=x,t[12]=C);let w=d?`true`:void 0,T;t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(T=n.coverAttachmentId?(0,Q.jsx)(Xe,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,Q.jsx)(at,{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]=T):T=t[18];let E;t[19]===n.title?E=t[20]:(E=n.title&&(0,Q.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=E);let D=n.title?`text-fg-muted`:h?`italic text-fg-muted`:`text-fg`,k;t[21]===D?k=t[22]:(k=a(`truncate text-sm leading-5`,D),t[21]=D,t[22]=k);let A;t[23]!==m||t[24]!==k?(A=(0,Q.jsx)(`p`,{className:k,children:m}),t[23]=m,t[24]=k,t[25]=A):A=t[25];let j;t[26]!==E||t[27]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,A]}),t[26]=E,t[27]=A,t[28]=j):j=t[28];let M;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(Fe,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:ft,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,Q.jsx)(I,{className:`h-4 w-4`})})}),t[29]=M):M=t[29];let N;t[30]!==n.id||t[31]!==n.pinned||t[32]!==o?(N=()=>o(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=o,t[33]=N):N=t[33];let P;t[34]===n.pinned?P=t[35]:(P=n.pinned?(0,Q.jsx)(O,{className:`h-4 w-4`}):(0,Q.jsx)(Me,{className:`h-4 w-4`}),t[34]=n.pinned,t[35]=P);let F=n.pinned?l.unpin:l.pin,L;t[36]!==N||t[37]!==P||t[38]!==F?(L=(0,Q.jsxs)(Y,{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:N,children:[P,F]}),t[36]=N,t[37]=P,t[38]=F,t[39]=L):L=t[39];let ee;t[40]!==n.id||t[41]!==s?(ee=()=>s(n.id),t[40]=n.id,t[41]=s,t[42]=ee):ee=t[42];let te;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(S,{className:`h-4 w-4`}),t[43]=te):te=t[43];let ne;t[44]!==l.archive||t[45]!==ee?(ne=(0,Q.jsxs)(Y,{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:ee,children:[te,l.archive]}),t[44]=l.archive,t[45]=ee,t[46]=ne):ne=t[46];let re;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(Ne,{className:`my-1 h-px bg-edge-subtle`}),t[47]=re):re=t[47];let R;t[48]!==n.id||t[49]!==c?(R=()=>c(n.id),t[48]=n.id,t[49]=c,t[50]=R):R=t[50];let ie;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(p,{className:`h-4 w-4`}),t[51]=ie):ie=t[51];let z;t[52]!==l.delete||t[53]!==R?(z=(0,Q.jsxs)(Y,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:R,children:[ie,l.delete]}),t[52]=l.delete,t[53]=R,t[54]=z):z=t[54];let B;t[55]!==L||t[56]!==ne||t[57]!==z?(B=(0,Q.jsxs)(Pe,{children:[M,(0,Q.jsx)(Ie,{children:(0,Q.jsxs)(Le,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:dt,children:[L,ne,re,z]})})]}),t[55]=L,t[56]=ne,t[57]=z,t[58]=B):B=t[58];let V;t[59]!==j||t[60]!==B||t[61]!==T?(V=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[T,j,B]}),t[59]=j,t[60]=B,t[61]=T,t[62]=V):V=t[62];let H;t[63]===n.pinned?H=t[64]:(H=n.pinned&&(0,Q.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,Q.jsx)(Me,{className:`h-3 w-3`})}),t[63]=n.pinned,t[64]=H);let ae;t[65]===n.tags?ae=t[66]:(ae=n.tags?.slice(0,2).map(ut),t[65]=n.tags,t[66]=ae);let U;t[67]===v?U=t[68]:(U=(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:v}),t[67]=v,t[68]=U);let W;t[69]!==H||t[70]!==ae||t[71]!==U?(W=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[H,ae,U]}),t[69]=H,t[70]=ae,t[71]=U,t[72]=W):W=t[72];let oe;return t[73]!==V||t[74]!==W||t[75]!==y||t[76]!==b||t[77]!==C||t[78]!==w?(oe=(0,Q.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:y,onKeyDown:b,className:C,"aria-current":w,children:[V,W]}),t[73]=V,t[74]=W,t[75]=y,t[76]=b,t[77]=C,t[78]=w,t[79]=oe):oe=t[79],oe}function ut(e){return(0,Q.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 dt(e){return e.stopPropagation()}function ft(e){return e.stopPropagation()}function pt(){return Date.now()}var mt={edit:h,ai_edit:U,sync:w,restore:_};function ht(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function gt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let s=o(c(e=>e.language)).notes,l=s,{data:u}=f(e?[`note-history`,e]:null,()=>z(e)),[p,m]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),v=(0,X.useCallback)(async t=>{m(!0);try{await R(e,t),d({type:`success`,title:s.restoreSuccess}),_(null),i()}catch{d({type:`error`,title:s.restoreFailed})}finally{m(!1)}},[e,s.restoreSuccess,s.restoreFailed,i]),y=Date.now();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(j,{className:`h-4 w-4`,"aria-hidden":!0}),s.history]}),(0,Q.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,Q.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:u?.length?(0,Q.jsx)(`ul`,{className:`divide-y divide-edge`,children:u.map(e=>{let r=mt[e.trigger]??h,i=t===e.timestamp,o=g===e.timestamp;return(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:a(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:ht(e.trigger,s)}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:tt(e.timestamp,y,l)})]}),e.snippet&&(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,Q.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:s.restoreConfirm}),(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),v(e.timestamp)},disabled:p,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:p?`...`:s.restore}),(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),_(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),_(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:s.restore})})]},e.timestamp)})}):(0,Q.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:s.historyEmpty}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:s.historyEmptyDescription})]})})]})}function _t(e){let t=(0,Z.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:s,onClose:l,noteThreads:u,openingChat:d,onOpenChat:p,onOpenNewChat:h}=e,g=o(c(wt)).notes,_=T(),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=()=>ue(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:E}=f(b,x,S),D;t[5]===n?D=t[6]:(D=async e=>{try{await Ae(n,e)}catch{}},t[5]=n,t[6]=D);let O=D,k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(U,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=k):k=t[7];let A;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(M,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=A):A=t[8];let j;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(m,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=j):j=t[9],(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:g.catalysisSectionTitle})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:l,"aria-label":g.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:A})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,Q.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:g.catalysisSectionDescription}),C?(0,Q.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.contextStatusTitle}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void w(()=>Ce(n),{revalidate:!1}),disabled:E,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,Q.jsx)(`span`,{className:a(`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,Q.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,Q.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:C.attachments.slice(0,5).map(Ct)}):null]}):null,(0,Q.jsx)(`button`,{type:`button`,onClick:s,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,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.valueHypothesis}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:y.valueHypothesis})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.targetUsers}),(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.targetUsers.slice(0,5).map(St)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.keyQuestions}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.keyQuestions.slice(0,3).map(xt)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.mvpPathLabel}),(0,Q.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.mvpPath.slice(0,3).map(bt)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.risks}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.risks.slice(0,3).map(yt)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.nextActions}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.nextActions.slice(0,4).map(vt)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:g.confidenceLabel.replace(`{{percent}}`,String(Math.round(y.confidence*100)))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void O(`helpful`),className:a(`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,Q.jsx)(H,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void O(`not_helpful`),className:a(`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,Q.jsx)(xe,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,Q.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,Q.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[j,g.relatedThreadsTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.relatedThreadsDescription})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:p,disabled:d,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:d?g.openingChat:g.openThread}),(0,Q.jsx)(`button`,{type:`button`,onClick:h,disabled:d,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})]})]}),u.length>0?(0,Q.jsx)(`div`,{className:`space-y-2`,children:u.slice(0,5).map(e=>(0,Q.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,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||g.noteDiscussionFallback}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,Q.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 vt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,Q.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function yt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,Q.jsx)(`span`,{children:e})]},e)}function bt(e,t){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,Q.jsx)(`span`,{children:e})]},e)}function xt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,Q.jsx)(`span`,{children:e})]},e)}function St(e){return(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function Ct(e){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function wt(e){return e.language}var Tt=()=>i(()=>import(`./block-editor-DfndiO3h.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),Et=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([20,1,3,18,6,21])),Dt=(0,X.lazy)(()=>Tt().then(e=>({default:e.BlockEditor}))),Ot=(0,X.lazy)(()=>Et().then(e=>({default:e.MarkdownEditor})));function kt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,Q.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function At(e){let t=(0,Z.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:y},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:ee},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:k},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,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,Q.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:o}=e;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&Tt(),t===`source`&&Et()},onFocus:()=>{t===`wysiwyg`&&Tt(),t===`source`&&Et()},className:a(`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,Q.jsx)(o,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function jt(e){let t=(0,Z.c)(15),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:s,clearHeaderOnCleanup:l,onOpenSearch:u,autoFocus:d,onAutoFocusConsumed:f}=e,p=a===void 0?!0:a,m=l===void 0?!0:l,h=d===void 0?!1:d,g=c(Mt),_;t[0]===g?_=t[1]:(_=o(g),t[0]=g,t[1]=_);let v=_.notes.lightboxClose,y;t[2]!==h||t[3]!==s||t[4]!==m||t[5]!==n||t[6]!==f||t[7]!==r||t[8]!==u||t[9]!==i||t[10]!==p?(y=(0,Q.jsx)(Nt,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:s,clearHeaderOnCleanup:m,onOpenSearch:u,autoFocus:h,onAutoFocusConsumed:f}),t[2]=h,t[3]=s,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,Q.jsx)(Ye,{closeLabel:v,children:y}),t[12]=v,t[13]=y,t[14]=b):b=t[14],b}function Mt(e){return e.language}function Nt({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:s=!0,onOpenSearch:u,autoFocus:p=!1,onAutoFocusConsumed:h}){let _=c(e=>e.language),v=o(_).notes,y=o(_).automations.suggestions,b=T(),x=l(e=>e.resolved)===`dark`,{openImage:S}=qe(),[C,w]=(0,X.useState)(`wysiwyg`),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(null),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(``),[L,ee]=(0,X.useState)(360),[te,ne]=(0,X.useState)(!1),[R,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(!1),H=(0,X.useRef)(!1),W=(0,X.useRef)(!1),oe=(0,X.useRef)(null),ce=(0,X.useRef)(null),ue=(0,X.useRef)(null),G=(0,X.useRef)(null),fe=(0,X.useRef)(null),pe=(0,X.useRef)(null),me=(0,X.useRef)(null),he=(0,X.useRef)(null),ge=(0,X.useRef)(null),_e=ye(e=>e.setPageHeader),ve=ye(e=>e.clearPageHeader),{data:K,mutate:q}=f(e?[`note-detail`,e]:null,()=>ie(e)),{data:be=[],mutate:xe}=f(e?[`note-threads`,e]:null,()=>ae(e),{revalidateOnFocus:!1}),Se=O!==null;(0,X.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&q()};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[q,e]),(0,X.useEffect)(()=>{H.current=!1,I(``),k(null),D(null),W.current=!1,ge.current=null},[e]),(0,X.useEffect)(()=>{!K||H.current||(I(K.title??``),H.current=!0)},[K]),(0,X.useEffect)(()=>{if(!p||!K||Se||ge.current===e)return;let t=window.requestAnimationFrame(()=>{he.current?.focus(),h?.()});return ge.current=e,()=>window.cancelAnimationFrame(t)},[p,Se,K,e,h]);let Ce=K?new Date(K.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,we=(0,X.useMemo)(()=>r?(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":v.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,le,i),children:(0,Q.jsx)(M,{className:`h-4 w-4`,"aria-hidden":!0})}):null,[i,v.back,t,r]),Te=(0,X.useCallback)(t=>{I(t),e&&(G.current=t,ce.current&&clearTimeout(ce.current),ce.current=setTimeout(async()=>{let t=G.current;if(G.current=null,t!==null){P(!0);try{await Ee(e,{title:t}),await q(),n?.()}catch{}finally{P(!1)}}},600))},[e,q,n]),De=(0,X.useMemo)(()=>(0,Q.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,le),children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:F||Ce||void 0,children:F||Ce}),N?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:v.saving}):null]}),[v.saving,N,Ce,F]),Oe=(0,X.useCallback)(async(t=!1)=>{V(!0);try{let n=await de(e,{forceNew:t});await q(),await xe(),b(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){d({type:`error`,title:v.chatOpenFailedTitle,message:e instanceof Error?e.message:v.chatOpenFailedMessage})}finally{V(!1)}},[q,xe,b,e,v.chatOpenFailedMessage,v.chatOpenFailedTitle]),ke=(0,X.useCallback)(async()=>{z(!0);try{await re(e),await q(),d({type:`success`,title:v.catalysisDone})}catch(e){d({type:`error`,title:v.catalysisFailed,message:e instanceof Error?e.message:v.chatOpenFailedMessage})}finally{z(!1)}},[q,e]),Ae=(0,X.useCallback)(()=>{D(E===`breakdown`?null:`breakdown`),!K?.aiDeep?.catalysis?.report&&!R&&ke()},[E,R,ke,K?.aiDeep?.catalysis?.report]),je=(0,X.useMemo)(()=>(0,Q.jsxs)(`div`,{className:a(`flex items-center gap-2`,le),children:[u?(0,Q.jsx)(`button`,{type:`button`,onClick:u,"aria-label":v.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,Q.jsx)(A,{className:`h-4 w-4`,"aria-hidden":!0})}):null,(0,Q.jsxs)(`button`,{type:`button`,onClick:Ae,disabled:R,"aria-label":v.catalysisSectionTitle,className:a(`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,Q.jsx)(U,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),R?v.catalyzing:v.catalyzeButton]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>Oe(!1),disabled:B,className:a(`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,Q.jsx)(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B?v.openingChat:v.openChatButton]}),(0,Q.jsx)(At,{mode:C,onModeChange:w,labels:{edit:v.modeEdit,source:v.modeSource,preview:v.modePreview}}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>D(E===`history`?null:`history`),"aria-label":v.history,className:a(`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,Q.jsx)(j,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[R,Ae,Oe,C,v.history,v.modeEdit,v.modePreview,v.modeSource,B,E,u,v.searchDialogTitle]);(0,X.useLayoutEffect)(()=>(_e({startExtra:we,main:K?De:null,end:K?je:null}),()=>{s&&ve()}),[s,ve,je,De,we,K,_e]);let Me=(0,X.useCallback)(t=>{e&&(ue.current=t,oe.current&&clearTimeout(oe.current),oe.current=setTimeout(async()=>{let t=ue.current;if(ue.current=null,t!==null){P(!0);try{await Ee(e,{markdown:t}),await q(),n?.()}catch(e){d({type:`error`,title:v.saveFailed,message:e instanceof Error?e.message:v.saveFailedHint})}finally{P(!1)}}},600))},[e,q,v.saveFailed,v.saveFailedHint,n]),Ne=(0,X.useCallback)(t=>{J(e,t.timestamp).then(e=>{e&&k(e)})},[e]),Pe=(0,X.useCallback)(()=>{D(null),k(null)},[]),Y=(0,X.useCallback)(()=>{D(null),k(null),q(),n?.()},[q,n]);if((0,X.useEffect)(()=>()=>{oe.current&&clearTimeout(oe.current),ce.current&&clearTimeout(ce.current);let t=ue.current,n=G.current;ue.current=null,G.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&Ee(e,r)},[e]),K===void 0)return(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(K===null)return(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:v.notFoundTitle}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v.notFoundDescription}),(0,Q.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:v.back})]});let Fe=Se?O.title??``:F,Ie=Se?O.markdown??``:K.markdown??``,Le=new Date(K.createdAt).getTime(),Z=Number.isFinite(Le)&&Date.now()-Le<3600*1e3?(0,Q.jsx)(Re,{title:y.noteCreatedTitle,description:y.noteCreatedDescription,prompt:y.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,Q.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(se,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,Q.jsx)(se,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,Q.jsx)(`div`,{ref:fe,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:Se?(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Fe&&(0,Q.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Fe}),Ie?(0,Q.jsx)(g,{noteId:e,content:Ie,className:`opacity-80`}):(0,Q.jsx)(`p`,{className:`italic text-fg-muted`,children:v.emptyPreview})]}):(0,Q.jsxs)(Q.Fragment,{children:[C===`wysiwyg`&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,Q.jsx)(`input`,{ref:he,type:`text`,value:F,onChange:e=>Te(e.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!W.current&&!t.isComposing&&(e.preventDefault(),(fe.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:v.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`}),Z]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(X.Suspense,{fallback:(0,Q.jsx)(kt,{}),children:(0,Q.jsx)(Dt,{initialContent:K.markdown??``,onChange:Me,noteId:e},`wysiwyg-${e}`)})})]}),C===`source`&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,Q.jsx)(`input`,{ref:he,type:`text`,value:F,onChange:e=>Te(e.target.value),placeholder:v.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`}),Z]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(X.Suspense,{fallback:(0,Q.jsx)(kt,{}),children:(0,Q.jsx)(Ot,{initialContent:K.markdown??``,onChange:Me,isDark:x},`source-${e}`)})})]}),C===`preview`&&(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&S(t.currentSrc||t.src,t.alt)},children:[F&&(0,Q.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:F}),K.markdown?(0,Q.jsx)(g,{noteId:e,content:K.markdown,className:`[&_img]:cursor-zoom-in`}):(0,Q.jsx)(`p`,{className:`italic text-fg-muted`,children:v.emptyPreview})]})]})})]}),(0,Q.jsx)(`div`,{ref:pe,className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!te&&`transition-[width] duration-300 ease-in-out`),style:{width:E?L:0},children:(0,Q.jsxs)(`div`,{ref:me,className:`flex min-h-0 flex-1 flex-col`,style:{width:L},children:[(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),ne(!0);let n=e.clientX,r=L,i=e.pointerId,a=0,o=L,s=L,c=()=>{a=0,s=o,E&&pe.current?.style.setProperty(`width`,`${s}px`),me.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{}ne(!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:a(`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`,te&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:E===`history`?(0,Q.jsx)(gt,{noteId:e,activeTimestamp:O?.timestamp??null,onSelect:Ne,onClose:Pe,onRestored:Y}):E===`breakdown`?(0,Q.jsx)(_t,{noteId:e,note:K??null,catalyzing:R,onCatalyze:ke,onClose:()=>D(null),noteThreads:be,openingChat:B,onOpenChat:()=>Oe(!1),onOpenNewChat:()=>Oe(!0)}):null})]})})]})}var Pt=3e4;function Ft(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function It({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:i,recordingLabel:o=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(0),[_,v]=(0,X.useState)(!1),y=(0,X.useRef)(null),b=(0,X.useRef)(null),x=(0,X.useRef)(null),S=(0,X.useRef)([]),C=(0,X.useRef)(0),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.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,X.useEffect)(()=>()=>E(),[E]);let D=(0,X.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||Ft()||`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,X.useCallback)(async()=>{if(!(!i||_||p)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=Ft(),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()},Pt)}catch{E()}},[E,i,p,D,_]),k=(0,X.useCallback)(()=>{if(p){D();return}O()},[p,O,D]),A=(0,X.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]),j=(0,X.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),A({navigate:!1}))},[A]),M=d||_;return(0,Q.jsxs)(`div`,{className:a(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel px-2 py-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,Q.jsx)(`button`,{type:`button`,onClick:r,disabled:M||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,Q.jsx)(je,{className:`h-4 w-4`})}),i&&(0,Q.jsx)(`button`,{type:`button`,onClick:k,disabled:M||c||d,className:a(`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,Q.jsx)(G,{className:`h-4 w-4 fill-current`}):(0,Q.jsx)(L,{className:`h-4 w-4`})}),p?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(h))}):(0,Q.jsx)(`textarea`,{ref:y,value:l,onChange:e=>u(e.target.value),onKeyDown:j,placeholder:e,rows:1,disabled:M,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,Q.jsx)(`button`,{type:`button`,disabled:!l.trim()||M||p,onClick:e=>void A({navigate:!e.shiftKey}),"aria-label":t,className:a(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!M&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,Q.jsx)(De,{className:`h-4 w-4`})})]})}var Lt={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Rt=288,zt=320,Bt=520,Vt=560;function Ht(e){if(globalThis.localStorage===void 0)return zt;try{let t=globalThis.localStorage.getItem(e);if(!t)return zt;let n=Number(t);return Number.isFinite(n)?n:zt}catch{return zt}}function Ut(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var Wt={thought:_e,todo:B,voice:L,media:je,bookmark:ke,mixed:_e,task:B};function Gt(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Kt(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function qt(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function Jt({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:i=!0,listTag:s,captureTags:l=[],listTitle:p,listDescription:m,emptyText:h,emptyDescription:g,listWidthStorageKey:_=`xopc.notes.listWidth`}){let v=o(c(e=>e.language)).notes,y=!!u(e=>e.token),[x,C]=(0,X.useReducer)(Se,Lt),[w,O]=(0,X.useState)(!1),[k,j]=(0,X.useState)(``),[M,N]=(0,X.useState)(0),[F,I]=(0,X.useState)(()=>Ht(_)),[ee,re]=(0,X.useState)(!1),[R,ie]=(0,X.useState)(!1),[z,H]=(0,X.useState)(!1),[ae,U]=(0,X.useState)(null),se=(0,X.useRef)(null),[ue]=(0,X.useState)(()=>Date.now()),G=T(),de=(0,X.useCallback)(e=>{let t=se.current?.clientWidth??window.innerWidth,n=Math.max(Rt,t-Vt);return Math.max(Rt,Math.min(Math.min(Bt,n),e))},[]),me=(0,X.useCallback)(e=>{let t=de(e);I(t),Ut(_,t)},[de,_]);(0,X.useLayoutEffect)(()=>{I(e=>de(e))},[de]);let{data:xe,mutate:J,isLoading:Ce}=f((0,X.useMemo)(()=>y?[`notes-list`,s,x.statusFilter,x.kindFilter,x.pinnedOnly]:null,[y,s,x.statusFilter,x.kindFilter,x.pinnedOnly]),()=>ve({status:x.statusFilter===`all`?void 0:x.statusFilter,kind:x.kindFilter===`all`?void 0:x.kindFilter,tag:s,pinned:x.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),Te=Ce&&!xe,De=xe?.items??[],Oe=xe?.total??0,Ae=k.trim(),{data:Ne,isLoading:Pe}=f(y&&w&&Ae?[`notes-search`,s,Ae]:null,()=>ve({search:Ae,tag:s,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),Y=Ne?.items??[],Fe=e?De.some(t=>t.id===e):!0;(0,X.useEffect)(()=>{N(0)},[Ae]),(0,X.useEffect)(()=>{M>=Y.length&&N(Math.max(0,Y.length-1))},[M,Y.length]),(0,X.useEffect)(()=>{let e=()=>{J()};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[J]);let Ie=ye(e=>e.setPageHeader),Le=ye(e=>e.clearPageHeader),Re=Oe>0?v.noteCount.replace(`{{count}}`,String(Oe)):null,Z=v.searchDialogTitle,ze=v.searchClose,$=v.searchClear,Be=(0,X.useMemo)(()=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(!0),className:a(`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`,le),"aria-label":Z,children:[(0,Q.jsx)(A,{className:`size-4`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:Z})]}),[Z]);(0,X.useLayoutEffect)(()=>{if(n)return y?(Ie({startExtra:null,main:(0,Q.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,le),children:[(0,Q.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:p??v.title}),Re?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Re}):null]}),end:Be}),()=>Le()):(Le(),()=>Le())},[Le,y,Be,p,n,v.title,Re,e,Ie]);let Ve=(0,X.useMemo)(()=>({justNow:v.justNow,minutesAgo:v.minutesAgo,today:v.today,yesterday:v.yesterday,daysAgo:v.daysAgo}),[v.justNow,v.minutesAgo,v.today,v.yesterday,v.daysAgo]),He=(0,X.useMemo)(()=>[{id:`recent`,label:v.viewRecent,description:v.viewRecentDescription,icon:D,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:v.filterInbox,description:v.viewInboxDescription,icon:we,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:v.pinned,description:v.viewPinnedDescription,icon:Me,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:v.viewTasks,description:v.viewTasksDescription,icon:B,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:v.kindVoice,description:v.viewVoiceDescription,icon:L,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:v.kindMedia,description:v.viewMediaDescription,icon:je,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:v.kindBookmark,description:v.viewBookmarksDescription,icon:ke,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:v.filterProcessed,description:v.viewProcessedDescription,icon:fe,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:v.filterArchived,description:v.viewArchiveDescription,icon:S,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[v.filterArchived,v.filterInbox,v.filterProcessed,v.kindBookmark,v.kindMedia,v.kindVoice,v.pinned,v.viewArchiveDescription,v.viewBookmarksDescription,v.viewInboxDescription,v.viewMediaDescription,v.viewPinnedDescription,v.viewProcessedDescription,v.viewRecent,v.viewRecentDescription,v.viewTasks,v.viewTasksDescription,v.viewVoiceDescription]),Ue=He.find(e=>Kt(x,e))??He[0],We=p??Ue.label,Ge=m??Ue.description,Ke=(0,X.useCallback)(async(e,n)=>{let r=l.length?await ge({markdown:e,kind:`thought`,tags:l,channel:`web`}):await oe(e,`web`);await J(),n?.navigate!==!1&&G(qt(t,r.id))},[t,l,J,G]),qe=(0,X.useCallback)(async()=>{if(!z){H(!0);try{let e=await ge({markdown:``,kind:`thought`,tags:l,channel:`web`});C({type:`patch`,patch:Lt}),await J(),U(e.id),G(qt(t,e.id))}catch(e){d({type:`error`,title:v.createBlankFailed,message:e instanceof Error?e.message:v.createBlankFailedHint})}finally{H(!1)}}},[t,l,z,J,v.createBlankFailed,v.createBlankFailedHint,G]),Je=(0,X.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{await W(t,`web`),await J()}catch(e){d({type:`error`,title:v.imageUploadFailed,message:e instanceof Error?e.message:v.imageUploadFailedHint})}},e.click()},[J,v.imageUploadFailed,v.imageUploadFailedHint]),Ye=(0,X.useCallback)(async(e,t)=>{try{await te(e,t,`web`),await J()}catch(e){d({type:`error`,title:v.voiceUploadFailed,message:e instanceof Error?e.message:v.voiceUploadFailedHint})}},[J,v.voiceUploadFailed,v.voiceUploadFailedHint]),Xe=(0,X.useCallback)(async(e,t)=>{await Ee(e,{pinned:t}),await J()},[J]),Ze=(0,X.useCallback)(async e=>{await Ee(e,{status:`archived`}),await J()},[J]),Qe=(0,X.useCallback)(async e=>{await q(e),await J()},[J]),$e=(0,X.useCallback)(e=>{G(qt(t,e))},[t,G]),et=(0,X.useCallback)(e=>{G(qt(t,e)),O(!1)},[t,G]),it=(0,X.useCallback)(e=>{if(Y.length){if(e.key===`ArrowDown`)e.preventDefault(),N(e=>Math.min(Y.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),N(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=Y[M]??Y[0];t&&et(t.id)}}},[M,et,Y]),at=(0,X.useCallback)(e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),re(!0);let n=e.clientX,r=F,i=e.pointerId,a=0,o=F,s=F,c=()=>{a=0,s=o,se.current?.style.setProperty(`--notes-list-width`,`${s}px`)},l=e=>{o=de(r+e.clientX-n),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}re(!1),I(s),Ut(_,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)},[de,_,F]);(0,X.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),qe())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[qe]);let ot=(0,X.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),me(F-16)):e.key===`ArrowRight`?(e.preventDefault(),me(F+16)):e.key===`Home`?(e.preventDefault(),me(Rt)):e.key===`End`&&(e.preventDefault(),me(Bt))},[me,F]);return y?(0,Q.jsxs)(`div`,{ref:se,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,style:{"--notes-list-width":`${F}px`},children:[(0,Q.jsxs)(`section`,{className:a(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-panel`,`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,R?`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":R?!0:void 0,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-3 border-b border-edge-subtle p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,Q.jsx)(`select`,{value:Ue.id,onChange:e=>{let t=He.find(t=>t.id===e.target.value);t&&C({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":v.libraryTitle,children:He.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}):(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:We}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:Re??Ge})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ie(!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":v.collapseNotesList,title:v.collapseNotesList,children:(0,Q.jsx)(P,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:qe,disabled:z,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":v.createBlankNote,title:v.createBlankShortcut,children:(0,Q.jsx)(E,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>O(!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":v.searchDialogTitle,children:(0,Q.jsx)(A,{className:`h-4 w-4`,"aria-hidden":!0})})]})]}),(0,Q.jsx)(It,{placeholder:v.quickCapturePlaceholder,sendLabel:v.send,onCapture:Ke,onImagePick:i?Je:void 0,onVoiceCapture:i?Ye:void 0,recordingLabel:v.recording})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:Te?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,Q.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):De.length===0?(0,Q.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,Q.jsx)(_e,{className:`h-8 w-8 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:e&&!Fe?v.noteOutsideCurrentView:h??v.noNotes}),e&&!Fe?null:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:g??v.noNotesDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Fe?(0,Q.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:v.noteOutsideCurrentView}):null,De.map((t,n)=>{let r=n>0?rt(De[n-1].createdAt):null;return(0,Q.jsxs)(`div`,{children:[rt(t.createdAt)!==r&&(0,Q.jsx)(`div`,{className:a(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:nt(t.createdAt,ue,Ve)}),(0,Q.jsx)(lt,{note:t,selected:t.id===e,onPress:$e,onPin:Xe,onArchive:Ze,onDelete:Qe,timeLabels:Ve,labels:{pin:v.pin,unpin:v.unpin,archive:v.archive,delete:v.delete,imageNote:v.imageNote,noText:v.noText}})]},t.id)})]})})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":v.resizeNotesList,"aria-valuemin":Rt,"aria-valuemax":Bt,"aria-valuenow":Math.round(F),tabIndex:0,onPointerDown:at,onKeyDown:ot,className:a(`relative hidden shrink-0 cursor-col-resize touch-none select-none items-stretch 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`,R?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-2 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`,`before:pointer-events-none before:block before:h-full before:w-px before:bg-edge-subtle before:transition-colors before:duration-150`,`hover:before:bg-edge-strong`,ee&&`before:bg-accent`)}),(0,Q.jsxs)(`section`,{className:a(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[R?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ie(!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":v.expandNotesList,title:v.expandNotesList,children:(0,Q.jsx)(P,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,Q.jsx)(jt,{noteId:e,onBack:()=>G(t),onSaved:()=>void J(),backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>O(!0),autoFocus:e===ae,onAutoFocusConsumed:()=>U(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(_e,{className:`mx-auto h-9 w-9 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:v.emptyEditorTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:v.emptyEditorDescription}),(0,Q.jsxs)(`button`,{type:`button`,onClick:qe,disabled:z,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,Q.jsx)(E,{className:`h-4 w-4`,"aria-hidden":!0}),z?v.creatingBlankNote:v.createBlankNote]})]})})]}),(0,Q.jsx)(ne,{open:w,onOpenChange:O,children:(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(K,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(he,{className:`text-sm font-semibold text-fg`,children:Z}),(0,Q.jsx)(pe,{className:`sr-only`,children:v.searchPlaceholder}),(0,Q.jsx)(V,{asChild:!0,children:(0,Q.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":ze,children:(0,Q.jsx)(b,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(A,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{autoFocus:!0,type:`search`,value:k,onChange:e=>j(e.target.value),onKeyDown:it,placeholder:v.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`}),k?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>j(``),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":$,children:(0,Q.jsx)(b,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:Ae?Pe&&!Ne?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):Y.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(_e,{className:`h-7 w-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.searchNoResults}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:v.searchNoResultsDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:v.searchResultsCount.replace(`{{count}}`,String(Ne?.total??Y.length))}),Y.map((e,t)=>{let n=Wt[e.kind]||_e,r=Gt(e,{imageNote:v.imageNote,noText:v.noText});return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>et(e.id),onMouseEnter:()=>N(t),className:a(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===M?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,Q.jsx)(n,{className:`mt-0.5 h-4 w-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:tt(e.updatedAt,ue,Ve)})]}),e.title?(0,Q.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,Q.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(A,{className:`h-7 w-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.searchEmptyTitle}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:v.searchEmptyDescription})]})})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,Q.jsx)(_e,{className:`h-10 w-10 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v.needToken})]})}export{qe as n,Ge as r,Jt as t};
|
|
@@ -1 +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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{$ as s,$a as c,Ac as l,Ai as u,Ba as d,Ca as ee,Ci as te,Do as f,E as p,Fc as ne,H as re,Io as m,K as ie,Pc as ae,Po as h,Ps as g,Qo as oe,Sa as _,Si as se,So as v,Ta as ce,Tc as y,To as b,Va as x,Vo as le,Zs as S,_i as ue,aa as de,at as fe,bi as C,c as w,cc as pe,dc as T,ea as me,et as he,fi as ge,gi as _e,hi as ve,ia as ye,jc as E,js as be,lo as xe,mc as Se,mi as Ce,na as we,nt as Te,oa as Ee,pc as De,pi as D,ps as Oe,ra as ke,rn as Ae,ro as je,sa as Me,ta as Ne,uc as Pe,vi as Fe,vo as O,wa as Ie,wi as Le,xi as Re,yi as ze,zn as Be}from"./index-DdqSO9R2.js";import{t as Ve}from"./notes-workbench-mqRJYnJS.js";import{t as He}from"./directory-picker-path-field-D835EHJd.js";import{t as Ue}from"./goals-config-api-BBOX6mUl.js";import{n as We,t as Ge}from"./goal-create-dialog-CNqNdEkQ.js";import{t as Ke}from"./workflow-start-dialog-B0lavx_o.js";var qe=n(),k=e(t(),1),A=r(),Je=[{id:`overview`,icon:Oe},{id:`sessions`,icon:oe},{id:`goals`,icon:je},{id:`workflows`,icon:m},{id:`files`,icon:be},{id:`automations`,icon:x},{id:`notes`,icon:g},{id:`settings`,icon:O}],Ye=Je.map(e=>e.id),Xe=new Set(Je.map(e=>e.id)),Ze=`xopc.projectTabs.`;function Qe(e){return!!(e&&Xe.has(e))}function $e(e){return`${Ze}${e}`}function et(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t)!Qe(e)||n.has(e)||(n.add(e),r.push(e));for(let e of Ye)n.has(e)||r.push(e);return r}function tt(e){if(!e)return Ye;try{let t=window.localStorage.getItem($e(e));return et(t?JSON.parse(t):null)}catch{return Ye}}function j(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function M(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function nt(e){if(e===void 0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function N(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function rt(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`||e===`cancelled`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function P(e){let t=(0,qe.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,A.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,A.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function F(e=!1){return i(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function it(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function at(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function I(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function ot({currentProject:e,pm:t,projectsText:n,wd:r}){let a=ae(),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)([e]),[u,te]=(0,k.useState)(``),[f,p]=(0,k.useState)(!1),[ne,re]=(0,k.useState)(null),[m,ie]=(0,k.useState)(!1),[g,oe]=(0,k.useState)(`new`),[y,b]=(0,k.useState)(``),[x,le]=(0,k.useState)(``),[S,ue]=(0,k.useState)(!1),[fe,C]=(0,k.useState)(null),w=(0,k.useCallback)(async()=>{p(!0),re(null);try{let t=await se({limit:100});l(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){re(e instanceof Error?e.message:String(e))}finally{p(!1)}},[e]);(0,k.useEffect)(()=>{l(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,k.useEffect)(()=>{o&&w()},[w,o]);let pe=(0,k.useMemo)(()=>{let t=u.trim().toLowerCase().split(/\s+/).filter(Boolean);return c.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=it(e);return t.every(e=>n.includes(e))}).sort((e,t)=>at(t)-at(e))},[e.id,c,u]),T=e=>t.statuses[e.status]??e.status,he=e=>e.workspaceRoot||e.description||e.brief||t.common.defaultWorkspace,ge=e=>{oe(e),b(``),le(``),C(null),ie(!0),s(!1)},_e=(0,k.useCallback)(async e=>{e.preventDefault();let t=x.trim(),n=y.trim()||(g===`directory`?I(t):``);if(n){ue(!0),C(null);try{let e=await D({name:n,...t?{workspaceRoot:t}:{}});ie(!1),b(``),le(``),l(t=>[e,...t.filter(t=>t.id!==e.id)]),a(`/projects/${encodeURIComponent(e.id)}`)}catch(e){C(e instanceof Error?e.message:String(e))}finally{ue(!1)}}},[g,y,a,x]),ve=e=>{le(e),g===`directory`&&!y.trim()&&b(I(e))},E=(e,t)=>(0,A.jsxs)(`button`,{type:`button`,className:i(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{s(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,A.jsx)(Se,{className:i(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,A.jsxs)(`span`,{className:`min-w-0`,children:[(0,A.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,A.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:he(e)})]}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,N(e.status)),children:T(e)})]},e.id);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(Ie,{open:o,onOpenChange:s,children:[(0,A.jsx)(ce,{asChild:!0,children:(0,A.jsxs)(`button`,{type:`button`,className:`group -ml-2 flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,A.jsxs)(`span`,{className:`min-w-0`,children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,A.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,N(e.status)),children:T(e)})]}),(0,A.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:he(e)})]}),(0,A.jsx)(De,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,A.jsx)(ee,{children:(0,A.jsxs)(_,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,A.jsxs)(`label`,{className:`relative block`,children:[(0,A.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,A.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:u,onChange:e=>te(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,A.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,A.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),E(e,!0),(0,A.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),ne?(0,A.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:ne}):null,f&&pe.length===0?(0,A.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!f&&pe.length===0?(0,A.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,pe.map(e=>E(e,!1))]}),(0,A.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>ge(`new`),children:[(0,A.jsx)(h,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,A.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>ge(`directory`),children:[(0,A.jsx)(be,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,A.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{s(!1),a(`/projects`)},children:[(0,A.jsx)(O,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,A.jsx)(de,{open:m,onOpenChange:e=>!S&&ie(e),children:(0,A.jsxs)(ye,{children:[(0,A.jsx)(ke,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,A.jsxs)(Ne,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,A.jsx)(Ee,{className:`text-base font-semibold text-fg`,children:g===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,A.jsx)(we,{className:`mt-1 text-sm text-fg-muted`,children:g===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,A.jsxs)(`form`,{onSubmit:_e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[fe?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:fe}):null,(0,A.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,A.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,A.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:y,onChange:e=>b(e.target.value),placeholder:`xopc`,autoFocus:!0})]}),(0,A.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,A.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,A.jsx)(He,{value:x,onChange:ve,disabled:S,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,A.jsx)(me,{asChild:!0,children:(0,A.jsx)(d,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:S,children:n.cancel})}),(0,A.jsxs)(d,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:S||!(y.trim()||g===`directory`&&I(x)),children:[(0,A.jsx)(h,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})})]})}function L(){let{projectId:e=``,tabId:t,noteId:n}=ne(),r=ae(),ee=o(e=>e.language),_=a(ee),se=_.chat.workingDirectory,v=_.projectDetailPage,ce=_.projectsPage,Se=Me(e=>e.setPageHeader),De=Me(e=>e.clearPageHeader),[D,Oe]=(0,k.useState)(null),[O,Ie]=(0,k.useState)(null),[qe,Xe]=(0,k.useState)([]),[Ze,it]=(0,k.useState)([]),[at,I]=(0,k.useState)([]),[L,st]=(0,k.useState)([]),[ct,lt]=(0,k.useState)([]),[R,ut]=(0,k.useState)([]),[dt,ft]=(0,k.useState)(!1),[pt,mt]=(0,k.useState)(null),[ht,gt]=(0,k.useState)(!1),[z,B]=(0,k.useState)(``),[_t,vt]=(0,k.useState)([]),[yt,bt]=(0,k.useState)(null),[xt,St]=(0,k.useState)(!1),[Ct,wt]=(0,k.useState)(null),[Tt,Et]=(0,k.useState)([]),[V,Dt]=(0,k.useState)(``),[Ot,kt]=(0,k.useState)(!0),[At,jt]=(0,k.useState)(!1),[Mt,Nt]=(0,k.useState)(!1),[Pt,Ft]=(0,k.useState)(!1),[It,Lt]=(0,k.useState)(!1),[Rt,zt]=(0,k.useState)(!1),[Bt,Vt]=(0,k.useState)(!1),[Ht,Ut]=(0,k.useState)(null),[H,Wt]=(0,k.useState)(null),[Gt,Kt]=(0,k.useState)(!1),[qt,Jt]=(0,k.useState)(!1),[Yt,Xt]=(0,k.useState)(!1),[Zt,U]=(0,k.useState)(null),[Qt,$t]=(0,k.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),[W,en]=(0,k.useState)({title:``,reason:``}),[tn,nn]=(0,k.useState)(()=>tt(e)),[G,K]=(0,k.useState)({name:``,description:``,status:`active`,defaultAgentId:``,workspaceRoot:``,brief:``,instructions:``}),rn=tn[0]??Ye[0],q=n?`notes`:Qe(t)?t:rn,J=(0,k.useCallback)(t=>{e&&r(`/projects/${encodeURIComponent(e)}/${t}`)},[r,e]),an=(0,k.useCallback)(t=>e?`/projects/${encodeURIComponent(e)}/${t}`:`/projects`,[e]),on=(0,k.useCallback)(t=>{e&&r(an(t),{replace:!0})},[r,e,an]),Y=(0,k.useCallback)((e,t)=>{on(e),r(t)},[r,on]),X=(0,k.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||on(e)},[on]),sn=(0,k.useCallback)(e=>e.startsWith(`/goals/`)?`goals`:e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/workflows`)?`workflows`:e.startsWith(`/automations`)?`automations`:e.startsWith(`/notes`)?`notes`:q,[q]);(0,k.useEffect)(()=>{!e||!t||Qe(t)||r(`/projects/${encodeURIComponent(e)}/${rn}`,{replace:!0})},[rn,r,e,t]),(0,k.useEffect)(()=>{nn(tt(e))},[e]);let cn=(0,k.useCallback)((t,n,r=`before`)=>{t!==n&&nn(i=>{let a=et(i),o=a.indexOf(t),s=a.indexOf(n);if(o<0||s<0)return a;let[c]=a.splice(o,1),l=a.indexOf(n);return l<0?et(i):(a.splice(r===`after`?l+1:l,0,c),e&&window.localStorage.setItem($e(e),JSON.stringify(a)),a)})},[e]);(0,k.useEffect)(()=>{if(!e)return;let t=!1;return kt(!0),U(null),Promise.all([C(e),Re(e),ze(e),Be().catch(()=>null)]).then(([e,n,r,i])=>{if(t)return;let a=e.project;Oe(a),Ie(e),Xe(n),it(r),Et(i?.agents??[]),Dt(a.defaultAgentId??``),K({name:a.name,description:a.description??``,status:a.status,defaultAgentId:a.defaultAgentId??``,workspaceRoot:a.workspaceRoot??``,brief:a.brief??``,instructions:a.instructions??``})}).catch(e=>{t||U(e instanceof Error?e.message:String(e))}).finally(()=>{t||kt(!1)}),()=>{t=!0}},[e]),(0,k.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([Be(),Ae(),u()]);e||$t(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=D?.defaultAgentId||V||i,o=t.status===`fulfilled`?t.value.agents:e.agents,s=n.status===`fulfilled`?n.value:e.models,c=r.status===`fulfilled`?Ue(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy;return{defaultAgentId:a,agents:o.length?o:[{id:a||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:s,checklistDecomposePolicy:c}})}return t(),()=>{e=!0}},[D?.defaultAgentId,V]);let Z=(0,k.useCallback)(async()=>{if(D){zt(!0),U(null);try{let[e,t]=await Promise.all([s(),he(100,{ownerAgentId:V||void 0,projectId:D.id})]);I(e),st(t)}catch(e){U(e instanceof Error?e.message:String(e))}finally{zt(!1)}}},[D,V]);(0,k.useEffect)(()=>{D&&Z()},[D,Z]);let Q=(0,k.useCallback)(async()=>{if(D){ft(!0),U(null);try{let[e,t]=await Promise.all([w.list({projectId:D.id}),w.runs(50,void 0,{projectId:D.id})]);lt(e.automations),ut(t.runs)}catch(e){U(e instanceof Error?e.message:String(e))}finally{ft(!1)}}},[D]);(0,k.useEffect)(()=>{q===`automations`&&Q()},[Q,q]);let ln=(0,k.useCallback)(async e=>{mt(`run:${e.id}`),U(null);try{await w.runNow(e.id),await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{mt(null)}},[Q]),un=(0,k.useCallback)(async e=>{mt(`toggle:${e.id}`),U(null);try{e.enabled?await w.pause(e.id):await w.resume(e.id),await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{mt(null)}},[Q]),dn=(0,k.useCallback)(async()=>{if(!D?.workspaceRoot?.trim()){vt([]),bt(null),wt(null);return}St(!0),wt(null);try{let e=await Fe(D.id,z);vt(e.entries),B(e.path),bt(e.parentPath)}catch(e){vt([]),bt(null),wt(e instanceof Error?e.message:String(e))}finally{St(!1)}},[z,D]);(0,k.useEffect)(()=>{q===`files`&&dn()},[dn,q]);let fn=(0,k.useCallback)(async()=>{if(D){Lt(!0),U(null);try{let e=await _e(D.id,V||void 0);Y(`sessions`,`/chat/${encodeURIComponent(e.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{Lt(!1)}}},[Y,D,V]),pn=(0,k.useCallback)(async()=>{if(!D)return;let[e,t]=await Promise.all([C(D.id),ze(D.id)]);Ie(e),Oe(e.project),it(t)},[D]),mn=(0,k.useCallback)(async e=>{if(!D||!e.title.trim())return;let t=Number.parseInt(e.maxTurns,10),n=e.deadline?new Date(e.deadline).getTime():void 0;Kt(!0),U(null);try{let r=await ve(D.id,{title:e.title.trim(),description:e.description.trim()||void 0,attachments:e.attachments.length?e.attachments:void 0,priority:e.priority,deadlineAt:Number.isFinite(n)?n:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0});for(let t of We(e.checklist))await ge(r.id,t);Xt(!1),J(`goals`),await pn()}catch(e){throw U(e instanceof Error?e.message:String(e)),e}finally{Kt(!1)}},[J,D,pn]),hn=(0,k.useCallback)(async e=>{if(e.preventDefault(),!(!D||!W.title.trim())){Jt(!0),U(null);try{await Ce(D.id,{title:W.title.trim(),reason:W.reason.trim()||void 0}),en({title:``,reason:``}),await pn()}catch(e){U(e instanceof Error?e.message:String(e))}finally{Jt(!1)}}},[W.reason,W.title,D,pn]),gn=(0,k.useCallback)(async e=>{if(!(!D||!H)){Vt(!0),U(null);try{let t=await fe({definitionId:H.id,projectId:D.id,agentId:V||void 0,goal:e.goal,input:e.input,concurrency:e.concurrency,maxSubagents:e.maxSubagents});Wt(null),await Z(),Y(`workflows`,p(t.runId))}catch(e){U(e instanceof Error?e.message:String(e))}finally{Vt(!1)}}},[Y,D,Z,V,H]),_n=(0,k.useCallback)(async e=>{if(D){Ut(`retry:${e.id}`),U(null);try{let t=await Te(e.id,{ownerAgentId:V||e.metadata?.agentId,projectId:e.metadata?.projectId||D.id});await Z(),Y(`workflows`,p(t.runId))}catch(e){U(e instanceof Error?e.message:String(e))}finally{Ut(null)}}},[Y,D,Z,V]),vn=(0,k.useCallback)(async e=>{Ut(`cancel:${e.id}`),U(null);try{await ie(e.id,{ownerAgentId:V||e.metadata?.agentId}),await Z()}catch(e){U(e instanceof Error?e.message:String(e))}finally{Ut(null)}},[Z,V]),yn=(0,k.useMemo)(()=>(0,A.jsx)(E,{to:`/projects`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":v.backToProjects,children:(0,A.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),[v.backToProjects]),bn=(0,k.useMemo)(()=>D?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`select`,{className:`h-9 rounded-lg border border-edge bg-surface-muted px-3 text-sm text-fg outline-none focus:border-accent`,value:V,onChange:e=>Dt(e.target.value),"aria-label":v.common.agent,children:[(0,A.jsx)(`option`,{value:``,children:v.common.defaultAgent}),Tt.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))]}),(0,A.jsxs)(d,{variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>void fn(),disabled:It,children:[(0,A.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),v.common.newChat]})]}):null,[Tt,v.common.agent,v.common.defaultAgent,v.common.newChat,D,V,fn,It]);(0,k.useLayoutEffect)(()=>(Se({startExtra:yn,main:D?(0,A.jsx)(ot,{currentProject:D,pm:v,projectsText:ce,wd:se}):(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:v.fallbackTitle}),(0,A.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:v.fallbackContext})]}),end:bn}),()=>De()),[De,bn,yn,v,D,ce,Se,se]);async function xn(e){if(e.preventDefault(),!(!D||!G.name.trim())){jt(!0),U(null);try{let e=await Le(D.id,{name:G.name.trim(),status:G.status,description:G.description,defaultAgentId:G.defaultAgentId,workspaceRoot:G.workspaceRoot,brief:G.brief,instructions:G.instructions});Oe(t=>t?{...t,...e}:null),Ie(t=>t?{...t,project:{...t.project,...e}}:null),Dt(e.defaultAgentId??``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{jt(!1)}}}async function Sn(){if(D){Ft(!0),U(null);try{await ue(D.id),Nt(!1),r(`/projects`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{Ft(!1)}}}async function Cn(){if(!(!D||ht)){gt(!0),U(null);try{await te(D.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{gt(!1)}}}if(Ot)return(0,A.jsx)(`main`,{className:`w-full flex-1 px-3 py-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:v.loading});if(!D)return(0,A.jsxs)(`main`,{className:`w-full flex-1 px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,A.jsxs)(E,{to:`/projects`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,A.jsx)(y,{className:`size-4`,"aria-hidden":!0}),v.backToProjects]}),(0,A.jsx)(`p`,{className:`mt-6 rounded-lg border border-edge bg-surface-panel p-4 text-sm text-fg-muted`,children:Zt||v.notFound})]});let wn=O?.recentSessions.length?O.recentSessions:D.recentSessions,Tn=O?.recentWorkflowRuns.length?O.recentWorkflowRuns:D.recentWorkflowRuns,En=O?.attentionItems??[],Dn=O?.timeline??[],On=z?z.split(`/`).filter(Boolean):[],$=e=>v.statuses[e]??e,kn=e=>j(v.common.messages,{count:e});return(0,A.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,A.jsx)(re,{items:tn.map(e=>{let t=Je.find(t=>t.id===e);return{...t,label:v.tabs[t.id]}}),activeTab:q,onChange:J,onReorder:cn,ariaLabel:v.navAria,tabIdPrefix:`project-tab`,panelIdPrefix:`project-panel`,className:`shrink-0`}),Zt?(0,A.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:Zt}):null,(0,A.jsxs)(`div`,{className:i(`mt-3 min-h-0 flex-1`,q===`overview`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[q===`overview`?(0,A.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-tab-overview`,className:`grid h-full min-h-0 overflow-hidden gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]`,children:[(0,A.jsxs)(`div`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.directionTitle}),(0,A.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:O?.digest?.summary||O?.recommendedAction||D.description||D.brief||v.overview.directionFallback}),O?.digest?.nextAction?(0,A.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm font-medium leading-6 text-fg`,children:j(v.overview.recommendedNext,{action:O.digest.nextAction})}):null]}),(0,A.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:(0,A.jsxs)(d,{type:`button`,variant:`secondary`,onClick:()=>void Cn(),disabled:ht,children:[(0,A.jsx)(b,{className:`size-4`,"aria-hidden":!0}),ht?v.overview.savingDigest:v.overview.saveDigest]})})]}),(0,A.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-2 sm:grid-cols-2 lg:grid-cols-5`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 rounded-md border border-edge bg-surface-base px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-fg-muted`,children:[(0,A.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:v.overview.sessions})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-fg`,children:O?.stats.sessionCount??D.sessionCount})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-md border border-edge bg-surface-base px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-fg-muted`,children:[(0,A.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:v.overview.activeGoals})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-fg`,children:O?.stats.activeGoalCount??D.activeGoalCount})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-md border border-edge bg-surface-base px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-fg-muted`,children:[(0,A.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:v.overview.attention})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-fg`,children:O?.stats.attentionCount??En.length})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-md border border-edge bg-surface-base px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-fg-muted`,children:[(0,A.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:v.overview.staleGoals})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-fg`,children:O?.stats.staleGoalCount??O?.staleGoals?.length??0})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-md border border-edge bg-surface-base px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-fg-muted`,children:[(0,A.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:v.overview.recentWorkflowRuns})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-fg`,children:O?.stats.recentWorkflowRunCount??D.recentWorkflowRuns.length})]})]})]}),(0,A.jsxs)(`div`,{className:`grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.nextActions}),(0,A.jsxs)(d,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>Xt(!0),children:[(0,A.jsx)(h,{className:`size-4`,"aria-hidden":!0}),v.overview.goal]})]}),(0,A.jsx)(`div`,{className:`divide-y divide-edge`,children:O?.nextActions.length?O.nextActions.map(e=>(0,A.jsxs)(E,{to:`/goals/${encodeURIComponent(e.goalId)}`,onClick:X(`goals`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,N(e.status)),children:$(e.status)})]}),(0,A.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.nextAction})]},e.goalId)):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.overview.noNextActions})})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.activeGoals}),(0,A.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>J(`goals`),children:v.common.viewAll})]}),(0,A.jsx)(`div`,{className:`divide-y divide-edge`,children:O?.activeGoals.length?O.activeGoals.map(e=>(0,A.jsxs)(E,{to:`/goals/${encodeURIComponent(e.id)}`,onClick:X(`goals`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,N(e.status)),children:$(e.status)})]}),(0,A.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.nextAction||e.description||v.overview.noNextAction})]},e.id)):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.overview.noActiveGoals})})]})]}),(0,A.jsxs)(`div`,{className:`grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[(0,A.jsx)(S,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.recentSessions})]}),(0,A.jsx)(`div`,{className:`divide-y divide-edge`,children:wn.length?wn.map(e=>(0,A.jsxs)(E,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:X(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:M(e.updatedAt)})]}),(0,A.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.agentId||v.common.agent})]},e.key)):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.overview.noSessions})})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[(0,A.jsx)(pe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.workflowRuns})]}),(0,A.jsx)(`div`,{className:`divide-y divide-edge`,children:Tn.length?Tn.map(e=>(0,A.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.definitionId}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,rt(e.status)),children:$(e.status)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:M(e.createdAt)})]},e.runId)):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.overview.noWorkflowRuns})})]})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[(0,A.jsx)(l,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.timeline})]}),(0,A.jsx)(`div`,{className:`divide-y divide-edge`,children:Dn.length?Dn.map(e=>{let t=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:M(e.timestamp)})]}),(0,A.jsxs)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:[v.overview.timelineKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:``]})]});return e.href?(0,A.jsx)(E,{to:e.href,onClick:X(sn(e.href)),className:`block px-4 py-3 hover:bg-surface-hover`,children:t},e.id):(0,A.jsx)(`div`,{className:`px-4 py-3`,children:t},e.id)}):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.overview.noTimeline})})]})]}),(0,A.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.workspace}),(0,A.jsx)(`p`,{className:`mt-2 break-all text-sm leading-5 text-fg-muted`,children:D.workspaceRoot||v.common.defaultWorkspace}),(0,A.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:j(v.common.updated,{time:M(D.updatedAt)})})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.brief}),(0,A.jsx)(`p`,{className:`mt-2 break-words whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:D.brief||v.overview.noBrief})]}),(0,A.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.overview.attention}),En.length?(0,A.jsx)(`div`,{className:`mt-3 grid gap-3`,children:En.map(e=>{let t=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,A.jsx)(Pe,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,A.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[v.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${$(e.status)}`:``]})]});return e.href?(0,A.jsx)(E,{to:e.href,onClick:X(sn(e.href)),className:`min-w-0 rounded-md border border-edge bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,A.jsx)(`div`,{className:`min-w-0 rounded-md border border-edge bg-surface-base p-3`,children:t},e.id)})}):(0,A.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:v.overview.noBlockedGoals}),(0,A.jsxs)(`form`,{onSubmit:hn,className:`mt-4 grid gap-2 border-t border-edge pt-4`,children:[(0,A.jsx)(`input`,{className:`min-h-9 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:W.title,onChange:e=>en(t=>({...t,title:e.target.value})),placeholder:v.overview.blockerTitlePlaceholder}),(0,A.jsx)(`textarea`,{className:`min-h-20 rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:W.reason,onChange:e=>en(t=>({...t,reason:e.target.value})),placeholder:v.overview.blockerReasonPlaceholder}),(0,A.jsxs)(d,{type:`submit`,variant:`secondary`,className:`justify-self-start rounded-lg`,disabled:qt||!W.title.trim(),children:[(0,A.jsx)(h,{className:`size-4`,"aria-hidden":!0}),qt?v.overview.addingBlocker:v.overview.addBlocker]})]})]})]})]}):null,q===`workflows`?(0,A.jsxs)(`section`,{id:`project-panel-workflows`,role:`tabpanel`,"aria-labelledby":`project-tab-workflows`,className:`grid h-full min-h-[28rem] gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,A.jsx)(`div`,{className:`min-h-0`,children:(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.workflows.runsTitle}),(0,A.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.workflows.runsHint})]}),(0,A.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void Z(),disabled:Rt,children:[(0,A.jsx)(f,{className:`size-4`,"aria-hidden":!0}),v.common.refresh]})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:Rt&&L.length===0?(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.workflows.loadingRuns}):L.length?L.map(e=>{let t=e.status===`queued`||e.status===`running`,n=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,A.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>Y(`workflows`,p(e.id)),children:e.title||e.definitionId}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,rt(e.status)),children:$(e.status)})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:j(v.workflows.runMeta,{definitionId:e.definitionId,done:e.metrics.doneAgentCount,total:e.metrics.agentCount,time:M(e.createdAtMs)})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(d,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>Y(`workflows`,p(e.id)),children:v.common.open}),n?(0,A.jsxs)(d,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Ht===`retry:${e.id}`,onClick:()=>void _n(e),children:[(0,A.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),v.common.retry]}):null,t?(0,A.jsxs)(d,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Ht===`cancel:${e.id}`,onClick:()=>void vn(e),children:[(0,A.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),v.common.cancel]}):null]})]})]},e.id)}):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.workflows.emptyRuns})})]})}),(0,A.jsx)(`aside`,{className:`min-h-0`,children:(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-3`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.workflows.startTitle}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v.workflows.startHint})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:(0,A.jsx)(`div`,{className:`grid gap-2`,children:at.length?at.map(e=>(0,A.jsxs)(`button`,{type:`button`,className:`grid gap-1 rounded-md border border-edge bg-surface-base p-3 text-left hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-accent/30`,onClick:()=>Wt(e),children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,A.jsx)(m,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}),(0,A.jsx)(`span`,{className:`line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description||e.metadata.whenToUse||e.name})]},e.id)):(0,A.jsx)(`div`,{className:`px-1 py-3 text-sm text-fg-muted`,children:v.workflows.emptyDefinitions})})})]})})]}):null,q===`automations`?(0,A.jsxs)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-tab-automations`,className:`grid h-full min-h-[28rem] overflow-hidden gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,A.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.automations.title}),(0,A.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.automations.hint})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void Q(),disabled:dt,children:[(0,A.jsx)(f,{className:`size-4`,"aria-hidden":!0}),v.common.refresh]}),(0,A.jsxs)(d,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>Y(`automations`,`/automations?projectId=${encodeURIComponent(D.id)}&action=create`),children:[(0,A.jsx)(h,{className:`size-4`,"aria-hidden":!0}),v.common.new]})]})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:dt&&ct.length===0?(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.automations.loading}):ct.length?ct.map(e=>{let t=R.find(t=>t.automationId===e.id),n=e.state.runningRunId?R.find(t=>t.id===e.state.runningRunId):null;return(0,A.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>Y(`automations`,`/automations?automation=${encodeURIComponent(e.id)}`),children:e.name}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?v.automations.enabled:v.automations.paused})]}),(0,A.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.description||e.action.kind}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:j(v.common.lastRun,{trigger:e.trigger.kind,action:e.action.kind,time:t?M(t.createdAtMs):v.common.never})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsxs)(d,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:pt===`run:${e.id}`||!!n,onClick:()=>void ln(e),children:[(0,A.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),v.automations.run]}),(0,A.jsxs)(d,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:pt===`toggle:${e.id}`,onClick:()=>void un(e),children:[e.enabled?(0,A.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}):(0,A.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),e.enabled?v.automations.pause:v.automations.resume]})]})]})]},e.id)}):(0,A.jsxs)(`div`,{className:`grid gap-3 px-4 py-6 text-sm text-fg-muted`,children:[(0,A.jsx)(`p`,{children:v.automations.empty}),(0,A.jsx)(`div`,{children:(0,A.jsxs)(d,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Y(`automations`,`/automations?projectId=${encodeURIComponent(D.id)}&action=create`),children:[(0,A.jsx)(x,{className:`size-4`,"aria-hidden":!0}),v.automations.create]})})]})})]}),(0,A.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.automations.recentRuns})}),(0,A.jsx)(`div`,{className:`divide-y divide-edge`,children:R.length?R.slice(0,8).map(e=>(0,A.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.automationName}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,rt(e.status)),children:$(e.status)})]}),(0,A.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:M(e.createdAtMs)})]},e.id)):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.automations.emptyRuns})})]}),(0,A.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.automations.contextTitle}),(0,A.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:v.automations.contextHint}),(0,A.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:D.workspaceRoot||v.common.defaultWorkspace})]})]})]}):null,q===`notes`?(0,A.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:(0,A.jsx)(Ve,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(D.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,listTag:`project:${D.id}`,captureTags:[`project:${D.id}`,D.slug],listTitle:v.notes.title,listDescription:v.notes.hint,emptyText:v.notes.emptyTitle,emptyDescription:v.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${D.id}`})}):null,q===`files`?(0,A.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-tab-files`,className:`h-full min-h-[28rem]`,children:(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.files.title}),(0,A.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:D.workspaceRoot||v.files.noWorkspace}),(0,A.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-5 text-fg-subtle`,children:v.files.boundaryHint})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,A.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void dn(),disabled:xt||!D.workspaceRoot,children:[(0,A.jsx)(f,{className:`size-4`,"aria-hidden":!0}),v.common.refresh]}),(0,A.jsxs)(d,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>J(`workflows`),children:[(0,A.jsx)(m,{className:`size-4`,"aria-hidden":!0}),v.tabs.workflows]})]})]}),D.workspaceRoot?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 py-1.5 text-sm`,children:[(0,A.jsx)(`button`,{type:`button`,className:i(`rounded-md px-2 py-1 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,!z&&`bg-surface-hover text-fg`),onClick:()=>B(``),children:v.common.root}),On.map((e,t)=>{let n=On.slice(0,t+1).join(`/`);return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(T,{className:`size-3.5 text-fg-subtle`,"aria-hidden":!0}),(0,A.jsx)(`button`,{type:`button`,className:i(`max-w-40 truncate rounded-md px-2 py-1 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,t===On.length-1&&`bg-surface-hover text-fg`),onClick:()=>B(n),children:e})]},n)})]}),Ct?(0,A.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Ct}):null,(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[yt===null?null:(0,A.jsxs)(`button`,{type:`button`,className:`grid h-8 w-full grid-cols-[minmax(0,1fr)_5rem] items-center gap-3 px-3 text-left text-sm hover:bg-surface-hover sm:grid-cols-[minmax(0,1fr)_8rem_10rem]`,onClick:()=>B(yt),children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-fg`,children:[(0,A.jsx)(T,{className:`size-3.5 shrink-0 rotate-180 text-fg-subtle`,"aria-hidden":!0}),(0,A.jsx)(be,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:`..`})]}),(0,A.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:v.common.folder}),(0,A.jsx)(`span`,{className:`hidden sm:block`})]}),xt&&_t.length===0?(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.files.loading}):_t.length?_t.map(e=>{let t=e.type===`directory`,n=t?be:g;return(0,A.jsxs)(`button`,{type:`button`,className:i(`grid h-8 w-full grid-cols-[minmax(0,1fr)_5rem] items-center gap-3 px-3 text-left text-sm sm:grid-cols-[minmax(0,1fr)_8rem_10rem]`,t?`hover:bg-surface-hover`:`cursor-default`),onClick:()=>{t&&B(e.path)},children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-fg`,children:[(0,A.jsx)(T,{className:i(`size-3.5 shrink-0 text-fg-subtle`,!t&&`opacity-0`),"aria-hidden":!0}),(0,A.jsx)(n,{className:i(`size-4 shrink-0`,t?`text-accent-fg`:`text-fg-muted`),"aria-hidden":!0}),(0,A.jsx)(`span`,{className:i(`truncate`,t&&`font-medium`),children:e.name})]}),(0,A.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:t?v.common.folder:nt(e.size)}),(0,A.jsx)(`span`,{className:`hidden truncate text-right text-xs text-fg-subtle sm:block`,children:M(e.updatedAt)})]},e.path)}):(0,A.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:v.files.emptyDirectory})]})]}):(0,A.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,A.jsx)(`p`,{children:v.files.needWorkspace}),(0,A.jsx)(`div`,{children:(0,A.jsx)(d,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>J(`settings`),children:v.files.openSettings})})]})]})}):null,q===`sessions`?(0,A.jsx)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-tab-sessions`,className:`grid min-h-full content-start`,children:(0,A.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:qe.length?qe.map(e=>{let t=M(e.updatedAt),n=e.routing?.agentId||e.agentId||v.common.agent,r=t?j(v.sessions.metaWithTime,{agent:n,messages:kn(e.messageCount??0),time:t}):j(v.sessions.meta,{agent:n,messages:kn(e.messageCount??0)});return(0,A.jsx)(`article`,{className:`grid gap-3 border-b border-edge px-4 py-3 transition-colors last:border-b-0 hover:bg-surface-hover/50 sm:grid-cols-[minmax(0,1fr)_auto]`,children:(0,A.jsxs)(E,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:X(`sessions`),className:`min-w-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 sm:col-span-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),t?(0,A.jsx)(`span`,{className:`hidden shrink-0 text-xs text-fg-subtle md:block`,children:t}):null]}),(0,A.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:r})]})},e.key)}):(0,A.jsx)(`div`,{className:`grid gap-1 px-4 py-8 text-center`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v.sessions.emptyTitle}),(0,A.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:v.sessions.emptyDescription})]})})})}):null,q===`goals`?(0,A.jsxs)(`section`,{id:`project-panel-goals`,role:`tabpanel`,"aria-labelledby":`project-tab-goals`,className:`grid min-h-full content-start gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v.goals.title})}),(0,A.jsxs)(d,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3`,disabled:Gt,onClick:()=>Xt(!0),children:[(0,A.jsx)(h,{className:`size-4`,"aria-hidden":!0}),v.goals.new]})]}),(0,A.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:Ze.length?Ze.map(e=>(0,A.jsxs)(E,{to:`/goals/${encodeURIComponent(e.id)}`,onClick:X(`goals`),className:`grid gap-1 border-b border-edge px-4 py-3 last:border-b-0 hover:bg-surface-hover`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,A.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,N(e.status)),children:$(e.status)})]}),(0,A.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e.nextAction||e.description||v.goals.noNextAction})]},e.id)):(0,A.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:v.goals.empty})})]}):null,q===`settings`?(0,A.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-tab-settings`,onSubmit:xn,className:`grid min-h-full content-start gap-4 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(P,{label:v.settings.name,children:(0,A.jsx)(`input`,{className:F(),value:G.name,onChange:e=>K(t=>({...t,name:e.target.value}))})}),(0,A.jsx)(P,{label:v.settings.status,children:(0,A.jsxs)(`select`,{className:F(),value:G.status,onChange:e=>K(t=>({...t,status:e.target.value})),children:[(0,A.jsx)(`option`,{value:`active`,children:v.settings.statuses.active}),(0,A.jsx)(`option`,{value:`paused`,children:v.settings.statuses.paused}),(0,A.jsx)(`option`,{value:`archived`,children:v.settings.statuses.archived})]})}),(0,A.jsx)(P,{label:v.settings.defaultAgent,children:(0,A.jsxs)(`select`,{className:F(),value:G.defaultAgentId,onChange:e=>K(t=>({...t,defaultAgentId:e.target.value})),children:[(0,A.jsx)(`option`,{value:``,children:v.settings.globalDefaultAgent}),Tt.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))]})})]}),(0,A.jsx)(P,{label:v.settings.description,children:(0,A.jsx)(`input`,{className:F(),value:G.description,onChange:e=>K(t=>({...t,description:e.target.value}))})}),(0,A.jsx)(P,{label:v.settings.workspaceRoot,children:(0,A.jsx)(He,{value:G.workspaceRoot,onChange:e=>K(t=>({...t,workspaceRoot:e})),disabled:At,wd:se,placeholder:v.settings.workspacePlaceholder,inputClassName:F()})}),(0,A.jsx)(P,{label:v.settings.brief,children:(0,A.jsx)(`textarea`,{className:F(!0),value:G.brief,onChange:e=>K(t=>({...t,brief:e.target.value}))})}),(0,A.jsx)(P,{label:v.settings.instructions,children:(0,A.jsx)(`textarea`,{className:F(!0),value:G.instructions,onChange:e=>K(t=>({...t,instructions:e.target.value}))})}),(0,A.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge pt-4`,children:[(0,A.jsxs)(d,{type:`button`,variant:`ghost`,onClick:()=>Nt(!0),children:[(0,A.jsx)(c,{className:`size-4`,"aria-hidden":!0}),v.common.delete]}),(0,A.jsxs)(d,{type:`submit`,variant:`primary`,disabled:At||!G.name.trim(),children:[(0,A.jsx)(b,{className:`size-4`,"aria-hidden":!0}),v.common.save]})]})]}):null]}),(0,A.jsx)(de,{open:Mt,onOpenChange:e=>{Pt||Nt(e)},children:(0,A.jsxs)(ye,{children:[(0,A.jsx)(ke,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,A.jsxs)(Ne,{className:`fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,A.jsx)(Pe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(Ee,{className:`text-base font-semibold text-fg`,children:v.settings.deleteConfirmTitle}),(0,A.jsx)(we,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:D?j(v.settings.deleteConfirm,{name:D.name}):v.settings.deleteConfirmFallback})]})]}),(0,A.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,A.jsx)(me,{asChild:!0,children:(0,A.jsx)(d,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Pt,children:v.common.cancel})}),(0,A.jsxs)(d,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:Pt||!D,onClick:()=>void Sn(),children:[(0,A.jsx)(c,{className:`size-4`,"aria-hidden":!0}),v.settings.deleteConfirmAction]})]})]})]})}),(0,A.jsx)(Ge,{open:Yt,t:_.goalsPage,chat:_.chat,busy:Gt,options:Qt,onClose:()=>!Gt&&Xt(!1),onCreate:mn}),(0,A.jsx)(Ke,{open:!!H,definition:H,language:ee,starting:Bt,onClose:()=>!Bt&&Wt(null),onStart:e=>void gn(e)})]})}export{L as ProjectDetailPage};
|
|
@@ -1 +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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Ba as s,Ns as c,Po as l,Si as u,So as d,aa as f,ea as p,ia as m,jc as h,na as g,oa as _,pi as v,ra as y,sa as b,ta as x}from"./index-DdqSO9R2.js";import{t as S}from"./directory-picker-path-field-D835EHJd.js";var C=n(),w=e(t(),1),T=r(),E=[`all`,`active`,`paused`,`archived`];function D(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function O(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function k(e,t){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function A(e){let t=(0,C.c)(37),{project:n,t:r}=e,a=r.statuses[n.status],o=`/projects/${encodeURIComponent(n.id)}`,s;t[0]===n.name?s=t[1]:(s=(0,T.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=s);let c;t[2]===n.slug?c=t[3]:(c=(0,T.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.slug}),t[2]=n.slug,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===n.status?u=t[8]:(u=i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,D(n.status)),t[7]=n.status,t[8]=u);let d;t[9]!==a||t[10]!==u?(d=(0,T.jsx)(`span`,{className:u,children:a}),t[9]=a,t[10]=u,t[11]=d):d=t[11];let f;t[12]!==l||t[13]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[l,d]}),t[12]=l,t[13]=d,t[14]=f):f=t[14];let p=n.description||n.brief||r.noDescription,m;t[15]===p?m=t[16]:(m=(0,T.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-sm leading-5 text-fg-muted`,children:p}),t[15]=p,t[16]=m);let g=n.workspaceRoot||r.agentDefault,_;t[17]!==r.workspaceLabel||t[18]!==g?(_=O(r.workspaceLabel,{workspace:g}),t[17]=r.workspaceLabel,t[18]=g,t[19]=_):_=t[19];let v;t[20]===_?v=t[21]:(v=(0,T.jsx)(`div`,{className:`truncate`,children:_}),t[20]=_,t[21]=v);let y;t[22]!==n.lastActiveAt||t[23]!==n.updatedAt||t[24]!==r.lastActive||t[25]!==r.never?(y=O(r.lastActive,{time:k(n.lastActiveAt??n.updatedAt,r.never)}),t[22]=n.lastActiveAt,t[23]=n.updatedAt,t[24]=r.lastActive,t[25]=r.never,t[26]=y):y=t[26];let b;t[27]===y?b=t[28]:(b=(0,T.jsx)(`div`,{children:y}),t[27]=y,t[28]=b);let x;t[29]!==v||t[30]!==b?(x=(0,T.jsxs)(`div`,{className:`mt-auto grid gap-1 pt-4 text-xs text-fg-subtle`,children:[v,b]}),t[29]=v,t[30]=b,t[31]=x):x=t[31];let S;return t[32]!==o||t[33]!==x||t[34]!==f||t[35]!==m?(S=(0,T.jsxs)(h,{to:o,className:`group flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4 transition-colors hover:border-accent/50 hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[f,m,x]}),t[32]=o,t[33]=x,t[34]=f,t[35]=m,t[36]=S):S=t[36],S}function j(){let e=a(o(e=>e.language)),t=e.chat.workingDirectory,n=e.projectsPage,r=b(e=>e.setPageHeader),h=b(e=>e.clearPageHeader),[C,D]=(0,w.useState)([]),[k,j]=(0,w.useState)(`all`),[M,N]=(0,w.useState)(``),[P,F]=(0,w.useState)(!0),[I,L]=(0,w.useState)(null),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(``),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let e=!1;return F(!0),L(null),u({...k===`all`?{}:{status:k},...M.trim()?{search:M}:{},limit:100}).then(t=>{e||D(t.items)}).catch(t=>{e||L(t instanceof Error?t.message:String(t))}).finally(()=>{e||F(!1)}),()=>{e=!0}},[M,k]);let K=(0,w.useMemo)(()=>({active:C.filter(e=>e.status===`active`),paused:C.filter(e=>e.status===`paused`),archived:C.filter(e=>e.status===`archived`)}),[C]),q=(0,w.useCallback)(async e=>{e.preventDefault();let t=R.trim();if(t){G(!0),L(null);try{let e=await v({name:t,...B.trim()?{workspaceRoot:B.trim()}:{}});D(t=>[e,...t]),z(``),V(``),U(!1)}catch(e){L(e instanceof Error?e.message:String(e))}finally{G(!1)}}},[R,B]),J=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,T.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,T.jsx)(`input`,{className:`h-9 w-40 rounded-lg border border-edge bg-surface-muted pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent sm:w-56 lg:w-72`,value:M,onChange:e=>N(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchPlaceholder})]}),(0,T.jsxs)(s,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>U(e=>!e),children:[(0,T.jsx)(l,{className:`size-4`,"aria-hidden":!0}),n.create]})]}),[M,n.create,n.searchPlaceholder]);(0,w.useLayoutEffect)(()=>(r({startExtra:null,main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:O(n.summary,{count:C.length})})]}),end:J}),()=>h()),[h,J,C.length,r,n.summary,n.title]);let Y=k===`all`?[[n.statuses.active,K.active],[n.statuses.paused,K.paused],[n.statuses.archived,K.archived]]:[[n.statuses[k],C]];return(0,T.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsx)(f,{open:H,onOpenChange:U,children:(0,T.jsxs)(m,{children:[(0,T.jsx)(y,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,T.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,T.jsx)(_,{className:`text-base font-semibold text-fg`,children:n.createTitle}),(0,T.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:n.createDescription})]}),(0,T.jsxs)(`form`,{onSubmit:q,className:`flex min-h-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,T.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:R,onChange:e=>z(e.target.value),placeholder:`xopc`,autoFocus:!0})]}),(0,T.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,T.jsx)(S,{value:B,onChange:V,disabled:W,wd:t,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,T.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,T.jsx)(p,{asChild:!0,children:(0,T.jsx)(s,{type:`button`,variant:`ghost`,className:`rounded-lg`,children:n.cancel})}),(0,T.jsxs)(s,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:W||!R.trim(),children:[(0,T.jsx)(l,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,T.jsxs)(`section`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-lg border border-edge bg-surface-panel p-1`,children:E.map(e=>(0,T.jsx)(`button`,{type:`button`,onClick:()=>j(e),className:i(`rounded-md px-3 py-1.5 text-sm font-medium transition-colors`,k===e?`bg-accent text-white`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:e===`all`?n.all:n.statuses[e]},e))}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,T.jsx)(c,{className:`size-4`,"aria-hidden":!0}),n.optionalContext]})]}),I?(0,T.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:I}):null,P?(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):null,!P&&C.length===0?(0,T.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel p-8 text-center`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.emptyTitle}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]}):null,Y.map(([e,t])=>t.length?(0,T.jsxs)(`section`,{className:`space-y-3`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wide text-fg-subtle`,children:e}),(0,T.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:t.map(e=>(0,T.jsx)(A,{project:e,t:n},e.id))})]},e):null)]})}export{j as ProjectsPage};
|