@xopcai/xopc 0.0.417 → 0.0.418
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/{index-BpCi0TdG.js → index-fKpEKELX.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/external-tools/cliProvider.js +2 -2
- package/dist/src/agent/external-tools/composio-provider.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/repository.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/global-defaults-admin.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/service.js +2 -2
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/imports/importService.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r,n
|
|
|
3
3
|
|
|
4
4
|
`,fB=/\r\n/g,pB=`xopc.npmPendingRestart`;function mB(e){let t=e?.postUpdate;if(!t||typeof t!=`object`)return!1;let n=t.restart;if(!n||typeof n!=`object`)return!1;let r=n;return r.ok===!0&&[`in-process`,`daemon`,`unmanaged`].includes(String(r.mode))}function hB(e,t){try{sessionStorage.setItem(pB,JSON.stringify({installedVersion:e,automaticRestart:t}))}catch{}window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e,automaticRestart:t}})),t&&window.dispatchEvent(new Event(`gateway-restart-initiated`))}var gB=typeof window<`u`&&window.electronAPI?.updater!==void 0;function _B(){return null}function vB(e){if(!(!e||typeof window>`u`))try{let t=sessionStorage.getItem(pB);if(!t)return;let n=JSON.parse(t),r=typeof n.installedVersion==`string`?n.installedVersion.trim():``;r&&r===e&&sessionStorage.removeItem(pB)}catch{}}function yB(e){return vB(e.currentVersion),e}function bB(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(()=>_B()),[o,s]=(0,Z.useState)(gB?{state:`idle`}:_B()),c=(0,Z.useRef)(null),l=gB||i!==null;(0,Z.useEffect)(()=>{if(l)return;SB().then(e=>t(yB(e))).catch(()=>{});let e=e=>{let n=e.detail;if(n===null)t(e=>e&&yB({...e,updateAvailable:!1,latestVersion:null,channel:null}));else if(n&&typeof n==`object`){let e=n;t(yB({currentVersion:e.currentVersion??``,updateAvailable:!0,latestVersion:e.latestVersion??null,channel:e.channel??null}))}};return window.addEventListener(`update-available`,e),()=>window.removeEventListener(`update-available`,e)},[l]),(0,Z.useEffect)(()=>{if(!gB)return;let e=window.electronAPI.updater;return e.getStatus().then(e=>s(e)),e.onStatusChanged(e=>s(e))},[]),(0,Z.useEffect)(()=>{},[]),(0,Z.useEffect)(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);let u=(0,Z.useCallback)(async()=>{if(l)return!1;try{let e=await Po(Lo(`/api/update/check`),{method:`POST`});if(!e.ok)return!1;let n=await e.json();return n.payload?(t(yB(n.payload)),!0):!1}catch{return!1}},[l]),d=(0,Z.useCallback)(async()=>{if(l)return{ok:!1,error:`not-applicable`,message:`npm update is not used in the desktop app.`,status:400};r(!0);try{let e=await Po(Lo(`/api/update/run/stream`),{method:`POST`,headers:{Accept:`text/event-stream`}});if(!e.ok||!e.body){let t=await e.text().catch(()=>``),n=`HTTP ${e.status}`;try{let e=JSON.parse(t);typeof e.message==`string`&&(n=e.message)}catch{t&&(n=t.slice(0,500))}return{ok:!1,error:e.status===409?`busy`:`unknown`,message:n,status:e.status}}let t=await CB(e.body);if(t.ok&&t.result){let e=t.result;if(e&&typeof e==`object`&&e.status===`ok`&&typeof e.installedVersion==`string`){let t=mB(e);hB(e.installedVersion,t)}else e&&typeof e==`object`&&e.status===`up-to-date`&&typeof e.latestVersion==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.latestVersion}}))}return t}catch(e){return{ok:!1,error:`network`,message:e instanceof Error?e.message:String(e),status:0}}finally{r(!1)}},[l]),f=(0,Z.useCallback)(()=>{if(gB){window.electronAPI.updater.check();return}},[i]),p=(0,Z.useCallback)(()=>{gB&&window.electronAPI.updater.quitAndInstall()},[]);return{npm:e,electron:gB?o:i??o,isElectron:l,checkNow:u,runNpmUpdate:d,npmUpdateRunning:n,electronCheck:f,electronQuitAndInstall:p}}var xB=null;async function SB(){return xB||(xB=(async()=>{let e=await Po(Lo(`/api/update/status`));if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).payload})().finally(()=>{xB=null}),xB)}async function CB(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=e=>{try{let t=JSON.parse(e);typeof t.line==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-progress`,{detail:{line:t.line,source:t.source===`stderr`?`stderr`:`stdout`}}))}catch{}},o=e=>{let t=``,n=``;for(let r of e.split(`
|
|
5
5
|
`)){let e=r.replace(/\r$/,``);e.startsWith(`event:`)?t=e.slice(6).trim():e.startsWith(`data:`)&&(n+=e.slice(5).trimStart())}if(n){if(t===`progress`){a(n);return}if(t===`result`)try{let e=JSON.parse(n);i=e.ok?{ok:!0,result:e.result??null}:{ok:!1,error:String(e.error??`unknown`),message:String(e.message??`Update failed`),status:e.error===`busy`?409:400,result:e.result??null}}catch{i={ok:!1,error:`parse`,message:`Invalid update stream`,status:0}}}};try{let e=async()=>{if(i!==null)return i;let{done:a,value:s}=await t.read();if(a)return i;r+=n.decode(s,{stream:!0}),r=r.replace(fB,`
|
|
6
|
-
`);let c=r.split(dB);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var wB=`xopc.updateReminder.dismissed`,TB=typeof window<`u`&&window.electronAPI?.updater!==void 0,EB=`xopc:electron-update-recheck`;function DB(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(wB);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var OB=160;function kB(e){let t=e.trim();return t.length<=OB?t:`${t.slice(0,OB-1)}…`}function AB(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=bB(),[o,s]=(0,Z.useState)(DB),[c,l]=(0,Z.useState)({downloading:!1,electronError:!1}),[u,d]=(0,Z.useState)(()=>{if(typeof window>`u`||TB)return null;try{let e=sessionStorage.getItem(pB);if(!e)return null;let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;return n?{version:n,automatic:t.automaticRestart===!0}:null}catch{return null}}),f=(0,Z.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,Z.useRef)(null);if(u&&e?.currentVersion===u.version&&p.current!==u.version){p.current=u.version;try{sessionStorage.removeItem(pB)}catch{}d(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(pB);if(!e){d(null);return}let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;d(n?{version:n,automatic:t.automaticRestart===!0}:null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(wB,JSON.stringify(t))}catch{}return t})};return window.addEventListener(EB,e),()=>window.removeEventListener(EB,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(wB,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:kB(t.message)}:!n&&u&&e&&e.currentVersion!==u.version?u.automatic?{kind:`npm-restarting`,version:u.version}:{kind:`npm-restart-required`,version:u.version}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,Z.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`||m.kind===`npm-restarting`){try{sessionStorage.removeItem(pB)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(wB,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var jB={version:`0.0.417`,commit:`171df30d55822b1b157268b45e53e411c7912887`,buildTimeIso:`2026-10-25T05:08:28.126Z`},MB=`https://github.com/xopcai/xopc`,NB=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),PB=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function FB(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?NB:PB).format(n)}catch{return n.toISOString()}}function IB({open:e,onOpenChange:t}){let n=zo(e=>e.language),r=Do(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:f}=bB(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),{data:x}=iu(async()=>{let e=await Bo(Lo(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),S=(0,Z.useCallback)(e=>{e||(m(!1),g(!1),v(!1),b(null)),t(e)},[t]),C=(0,Z.useCallback)(async()=>{b(null);let e=Do(n).updatePanel,t=await d();if(t.ok){Vc({tone:`success`,title:e.updateSuccess,message:mB(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;b(`${r}: ${t.message}`)},[d,n]),w=jB.commit,T=n===`zh`?`zh-CN`:`en-US`,E=FB(jB.buildTimeIso,T),D=new Date().getFullYear(),O=i.copyright.replace(`{year}`,String(D));return(0,$.jsx)(us,{open:e,onOpenChange:S,children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(cs,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(os,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(ll,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(ls,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(as,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:jB.version}),(0,$.jsx)(`button`,{type:`button`,className:Y(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(EB)),m(!0),c()):(m(!0),v(!1),g(!0),(async()=>{let e=await l();g(!1),e||v(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(h||f),children:o&&s?.state===`checking`||!o&&h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Hi,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&p&&(0,$.jsx)(LB,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&p&&(0,$.jsx)(RB,{checking:h,checkFailed:_,npm:u,npmUpdateRunning:f,upgradeError:y,onUpgrade:C,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:w})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:E})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:x??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:MB,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:O})]})]})]})]})})}function LB(e){let t=(0,Q.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(An,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Wa,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_r,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_r,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function RB(e){let t=(0,Q.c)(28),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,upgradeError:o,onUpgrade:s,d:c,tp:l}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===c.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesChecking})]}),t[1]=c.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===c.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesError})]}),t[4]=c.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===l.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:l.updateRunning})]}),t[7]=l.updateRunning,t[8]=n),n}if(o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;return t[10]===o?n=t[11]:(n=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-red-500 dark:text-red-400`,role:`alert`,children:[e,(0,$.jsx)(`span`,{children:o})]}),t[10]=o,t[11]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Wa,{className:`mt-0.5 size-3.5 shrink-0`}),t[12]=e):e=t[12];let n;t[13]!==i.latestVersion||t[14]!==l.reminderNpm?(n=l.reminderNpm.replace(`{{version}}`,i.latestVersion),t[13]=i.latestVersion,t[14]=l.reminderNpm,t[15]=n):n=t[15];let r;t[16]===n?r=t[17]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[16]=n,t[17]=r);let a;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(a=Y(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-on-accent`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[18]=a):a=t[18];let o;t[19]!==s||t[20]!==l.updateNow?(o=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:a,children:l.updateNow}),t[19]=s,t[20]=l.updateNow,t[21]=o):o=t[21];let c;return t[22]!==r||t[23]!==o?(c=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,o]}),t[22]=r,t[23]=o,t[24]=c):c=t[24],c}let u;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(An,{className:`size-3.5`}),t[25]=u):u=t[25];let d;return t[26]===c.checkUpdatesUpToDate?d=t[27]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[u,(0,$.jsx)(`span`,{children:c.checkUpdatesUpToDate})]}),t[26]=c.checkUpdatesUpToDate,t[27]=d),d}var zB=Y(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`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-overlay`),BB=Y(`overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,`dark:border-edge`);function VB(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=Y(`touch-target flex w-full items-center justify-between gap-2 rounded-none px-3 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=Y(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(hn,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function HB(e){let t=(0,Q.c)(220),{onNavigate:n,onAboutClick:r,onSupportClick:i,onDeviceConnectClick:a}=e,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=zo(JB),d=zo(qB),f=gl(KB),p=gl(GB),m=fl(WB),h=fl(UB),g;t[0]===u?g=t[1]:(g=Do(u),t[0]=u,t[1]=g);let _=g,v=_.appearanceSettings,b=u===`zh`?v.langOptionZh:v.langOptionEn,x=f===`light`?v.themeOptionLight:f===`dark`?v.themeOptionDark:v.themeOptionSystem,S=m===`compact`?v.fontScaleCompact:m===`large`?v.fontScaleLarge:v.fontScaleDefault,C=typeof window<`u`?window.electronAPI?.pet:void 0,w=!!C,T=c?.visible?v.hideDesktopPet:v.showDesktopPet,E,D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{if(!C)return;let e=!1;C.getState().then(t=>{e||l(t)});let t=C.onStateChanged(t=>{e||l(t)});return()=>{e=!0,t()}},D=[C],t[2]=E,t[3]=D):(E=t[2],D=t[3]),(0,Z.useEffect)(E,D);let O;t[4]===c?.visible?O=t[5]:(O=async()=>{C&&(c?.visible?await C.hide():await C.show(),l(await C.getState()))},t[4]=c?.visible,t[5]=O);let k=O,A;t[6]===o?A=t[7]:(A=e=>Y(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,o===e?`block`:`hidden`),t[6]=o,t[7]=A);let j=A,M;t[8]===o?M=t[9]:(M=e=>Y(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,o===e?`pointer-events-auto`:`pointer-events-none`),t[8]=o,t[9]=M);let N=M,P;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>s(null),t[10]=P):P=t[10];let F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>s(`lang`),t[11]=F):F=t[11];let I=o===`lang`&&`bg-surface-hover`,L;t[12]===I?L=t[13]:(L=Y(zB,I),t[12]=I,t[13]=L);let R=o===`lang`,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ci,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=z):z=t[14];let B;t[15]===v.languageTitle?B=t[16]:(B=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.languageTitle}),t[15]=v.languageTitle,t[16]=B);let V;t[17]===b?V=t[18]:(V=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:b}),t[17]=b,t[18]=V);let H;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(vn,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=H):H=t[19];let U;t[20]!==L||t[21]!==R||t[22]!==B||t[23]!==V?(U=(0,$.jsxs)(`button`,{type:`button`,className:L,"aria-haspopup":`menu`,"aria-expanded":R,children:[z,B,V,H]}),t[20]=L,t[21]=R,t[22]=B,t[23]=V,t[24]=U):U=t[24];let W;t[25]===N?W=t[26]:(W=N(`lang`),t[25]=N,t[26]=W);let ee;t[27]===W?ee=t[28]:(ee=(0,$.jsx)(`div`,{className:W,"aria-hidden":!0}),t[27]=W,t[28]=ee);let G;t[29]===j?G=t[30]:(G=j(`lang`),t[29]=j,t[30]=G);let K=u===`en`,q;t[31]===d?q=t[32]:(q=()=>d(`en`),t[31]=d,t[32]=q);let te;t[33]!==v.langOptionEn||t[34]!==K||t[35]!==q?(te=(0,$.jsx)(VB,{selected:K,label:v.langOptionEn,onSelect:q}),t[33]=v.langOptionEn,t[34]=K,t[35]=q,t[36]=te):te=t[36];let ne=u===`zh`,re;t[37]===d?re=t[38]:(re=()=>d(`zh`),t[37]=d,t[38]=re);let ie;t[39]!==v.langOptionZh||t[40]!==ne||t[41]!==re?(ie=(0,$.jsx)(VB,{selected:ne,label:v.langOptionZh,onSelect:re}),t[39]=v.langOptionZh,t[40]=ne,t[41]=re,t[42]=ie):ie=t[42];let ae;t[43]!==te||t[44]!==ie?(ae=(0,$.jsxs)(`div`,{className:BB,children:[te,ie]}),t[43]=te,t[44]=ie,t[45]=ae):ae=t[45];let oe;t[46]!==v.languageTitle||t[47]!==G||t[48]!==ae?(oe=(0,$.jsx)(`div`,{className:G,role:`menu`,"aria-label":v.languageTitle,children:ae}),t[46]=v.languageTitle,t[47]=G,t[48]=ae,t[49]=oe):oe=t[49];let se;t[50]!==U||t[51]!==ee||t[52]!==oe?(se=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:F,children:[U,ee,oe]}),t[50]=U,t[51]=ee,t[52]=oe,t[53]=se):se=t[53];let ce;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>s(`theme`),t[54]=ce):ce=t[54];let le=o===`theme`&&`bg-surface-hover`,ue;t[55]===le?ue=t[56]:(ue=Y(zB,le),t[55]=le,t[56]=ue);let de=o===`theme`,fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(KO,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=fe):fe=t[57];let pe;t[58]===v.themeTitle?pe=t[59]:(pe=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.themeTitle}),t[58]=v.themeTitle,t[59]=pe);let me;t[60]===x?me=t[61]:(me=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:x}),t[60]=x,t[61]=me);let he;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(vn,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=he):he=t[62];let ge;t[63]!==ue||t[64]!==de||t[65]!==pe||t[66]!==me?(ge=(0,$.jsxs)(`button`,{type:`button`,className:ue,"aria-haspopup":`menu`,"aria-expanded":de,children:[fe,pe,me,he]}),t[63]=ue,t[64]=de,t[65]=pe,t[66]=me,t[67]=ge):ge=t[67];let _e;t[68]===N?_e=t[69]:(_e=N(`theme`),t[68]=N,t[69]=_e);let ve;t[70]===_e?ve=t[71]:(ve=(0,$.jsx)(`div`,{className:_e,"aria-hidden":!0}),t[70]=_e,t[71]=ve);let J;t[72]===j?J=t[73]:(J=j(`theme`),t[72]=j,t[73]=J);let ye=f===`light`,be;t[74]===p?be=t[75]:(be=()=>p(`light`),t[74]=p,t[75]=be);let xe;t[76]!==v.themeOptionLight||t[77]!==ye||t[78]!==be?(xe=(0,$.jsx)(VB,{selected:ye,label:v.themeOptionLight,onSelect:be}),t[76]=v.themeOptionLight,t[77]=ye,t[78]=be,t[79]=xe):xe=t[79];let Se=f===`dark`,Ce;t[80]===p?Ce=t[81]:(Ce=()=>p(`dark`),t[80]=p,t[81]=Ce);let we;t[82]!==v.themeOptionDark||t[83]!==Se||t[84]!==Ce?(we=(0,$.jsx)(VB,{selected:Se,label:v.themeOptionDark,onSelect:Ce}),t[82]=v.themeOptionDark,t[83]=Se,t[84]=Ce,t[85]=we):we=t[85];let Te=f===`system`,Ee;t[86]===p?Ee=t[87]:(Ee=()=>p(`system`),t[86]=p,t[87]=Ee);let De;t[88]!==v.themeOptionSystem||t[89]!==Te||t[90]!==Ee?(De=(0,$.jsx)(VB,{selected:Te,label:v.themeOptionSystem,onSelect:Ee}),t[88]=v.themeOptionSystem,t[89]=Te,t[90]=Ee,t[91]=De):De=t[91];let Oe;t[92]!==xe||t[93]!==we||t[94]!==De?(Oe=(0,$.jsxs)(`div`,{className:BB,children:[xe,we,De]}),t[92]=xe,t[93]=we,t[94]=De,t[95]=Oe):Oe=t[95];let ke;t[96]!==v.themeTitle||t[97]!==J||t[98]!==Oe?(ke=(0,$.jsx)(`div`,{className:J,role:`menu`,"aria-label":v.themeTitle,children:Oe}),t[96]=v.themeTitle,t[97]=J,t[98]=Oe,t[99]=ke):ke=t[99];let Ae;t[100]!==ge||t[101]!==ve||t[102]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:ce,children:[ge,ve,ke]}),t[100]=ge,t[101]=ve,t[102]=ke,t[103]=Ae):Ae=t[103];let je;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>s(`font`),t[104]=je):je=t[104];let Me=o===`font`&&`bg-surface-hover`,Ne;t[105]===Me?Ne=t[106]:(Ne=Y(zB,Me),t[105]=Me,t[106]=Ne);let Pe=o===`font`,Fe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(YI,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=Fe):Fe=t[107];let Ie;t[108]===v.fontScaleTitle?Ie=t[109]:(Ie=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.fontScaleTitle}),t[108]=v.fontScaleTitle,t[109]=Ie);let Le;t[110]===S?Le=t[111]:(Le=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:S}),t[110]=S,t[111]=Le);let Re;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(vn,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=Re):Re=t[112];let ze;t[113]!==Ne||t[114]!==Pe||t[115]!==Ie||t[116]!==Le?(ze=(0,$.jsxs)(`button`,{type:`button`,className:Ne,"aria-haspopup":`menu`,"aria-expanded":Pe,children:[Fe,Ie,Le,Re]}),t[113]=Ne,t[114]=Pe,t[115]=Ie,t[116]=Le,t[117]=ze):ze=t[117];let Be;t[118]===N?Be=t[119]:(Be=N(`font`),t[118]=N,t[119]=Be);let Ve;t[120]===Be?Ve=t[121]:(Ve=(0,$.jsx)(`div`,{className:Be,"aria-hidden":!0}),t[120]=Be,t[121]=Ve);let He;t[122]===j?He=t[123]:(He=j(`font`),t[122]=j,t[123]=He);let Ue=m===`compact`,We;t[124]===h?We=t[125]:(We=()=>h(`compact`),t[124]=h,t[125]=We);let Ge;t[126]!==v.fontScaleCompact||t[127]!==Ue||t[128]!==We?(Ge=(0,$.jsx)(VB,{selected:Ue,label:v.fontScaleCompact,onSelect:We}),t[126]=v.fontScaleCompact,t[127]=Ue,t[128]=We,t[129]=Ge):Ge=t[129];let Ke=m==="default",qe;t[130]===h?qe=t[131]:(qe=()=>h(`default`),t[130]=h,t[131]=qe);let Je;t[132]!==v.fontScaleDefault||t[133]!==Ke||t[134]!==qe?(Je=(0,$.jsx)(VB,{selected:Ke,label:v.fontScaleDefault,onSelect:qe}),t[132]=v.fontScaleDefault,t[133]=Ke,t[134]=qe,t[135]=Je):Je=t[135];let Ye=m===`large`,Xe;t[136]===h?Xe=t[137]:(Xe=()=>h(`large`),t[136]=h,t[137]=Xe);let Ze;t[138]!==v.fontScaleLarge||t[139]!==Ye||t[140]!==Xe?(Ze=(0,$.jsx)(VB,{selected:Ye,label:v.fontScaleLarge,onSelect:Xe}),t[138]=v.fontScaleLarge,t[139]=Ye,t[140]=Xe,t[141]=Ze):Ze=t[141];let Qe;t[142]!==Ge||t[143]!==Je||t[144]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:BB,children:[Ge,Je,Ze]}),t[142]=Ge,t[143]=Je,t[144]=Ze,t[145]=Qe):Qe=t[145];let $e;t[146]!==v.fontScaleTitle||t[147]!==He||t[148]!==Qe?($e=(0,$.jsx)(`div`,{className:He,role:`menu`,"aria-label":v.fontScaleTitle,children:Qe}),t[146]=v.fontScaleTitle,t[147]=He,t[148]=Qe,t[149]=$e):$e=t[149];let et;t[150]!==ze||t[151]!==Ve||t[152]!==$e?(et=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:je,children:[ze,Ve,$e]}),t[150]=ze,t[151]=Ve,t[152]=$e,t[153]=et):et=t[153];let tt;t[154]!==T||t[155]!==k?(tt=w?(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:()=>void k(),onMouseEnter:()=>s(null),onFocus:()=>s(null),children:[(0,$.jsx)(gk,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:T})]}):null,t[154]=T,t[155]=k,t[156]=tt):tt=t[156];let nt;t[157]===a?nt=t[158]:(nt=()=>a?.(),t[157]=a,t[158]=nt);let rt,it,at;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(rt=()=>s(null),it=()=>s(null),at=(0,$.jsx)(da,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[159]=rt,t[160]=it,t[161]=at):(rt=t[159],it=t[160],at=t[161]);let ot;t[162]===_.endpointToolsSettings.deviceAccess.flow.title?ot=t[163]:(ot=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.endpointToolsSettings.deviceAccess.flow.title}),t[162]=_.endpointToolsSettings.deviceAccess.flow.title,t[163]=ot);let st;t[164]!==nt||t[165]!==ot?(st=(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:nt,onMouseEnter:rt,onFocus:it,children:[at,ot]}),t[164]=nt,t[165]=ot,t[166]=st):st=t[166];let ct;t[167]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[167]=ct):ct=t[167];let lt;t[168]===r?lt=t[169]:(lt=()=>r?.(),t[168]=r,t[169]=lt);let ut,dt,ft;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(ut=()=>s(null),dt=()=>s(null),ft=(0,$.jsx)(Pi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=ut,t[171]=dt,t[172]=ft):(ut=t[170],dt=t[171],ft=t[172]);let pt;t[173]===v.aboutApp?pt=t[174]:(pt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.aboutApp}),t[173]=v.aboutApp,t[174]=pt);let mt;t[175]!==lt||t[176]!==pt?(mt=(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:lt,onMouseEnter:ut,onFocus:dt,children:[ft,pt]}),t[175]=lt,t[176]=pt,t[177]=mt):mt=t[177];let ht;t[178]===u?ht=t[179]:(ht=wl(u),t[178]=u,t[179]=ht);let gt,_t,vt;t[180]===Symbol.for(`react.memo_cache_sentinel`)?(gt=()=>s(null),_t=()=>s(null),vt=(0,$.jsx)(Xt,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[180]=gt,t[181]=_t,t[182]=vt):(gt=t[180],_t=t[181],vt=t[182]);let yt;t[183]===_.sidebar.helpDocs?yt=t[184]:(yt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.sidebar.helpDocs}),t[183]=_.sidebar.helpDocs,t[184]=yt);let bt;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(bt=(0,$.jsx)(br,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[185]=bt):bt=t[185];let xt;t[186]!==ht||t[187]!==yt?(xt=(0,$.jsxs)(`a`,{href:ht,target:`_blank`,rel:`noopener noreferrer`,className:zB,onMouseEnter:gt,onFocus:_t,children:[vt,yt,bt]}),t[186]=ht,t[187]=yt,t[188]=xt):xt=t[188];let St;t[189]===i?St=t[190]:(St=()=>i?.(),t[189]=i,t[190]=St);let Ct,wt,Tt;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=()=>s(null),Ct=()=>s(null),wt=(0,$.jsx)(fD,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[191]=Ct,t[192]=wt,t[193]=Tt):(Ct=t[191],wt=t[192],Tt=t[193]);let Et;t[194]===_.supportReport.menu?Et=t[195]:(Et=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.supportReport.menu}),t[194]=_.supportReport.menu,t[195]=Et);let Dt;t[196]!==Et||t[197]!==St?(Dt=(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:St,onMouseEnter:Tt,onFocus:Ct,children:[wt,Et]}),t[196]=Et,t[197]=St,t[198]=Dt):Dt=t[198];let Ot,kt,At;t[199]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=Y(zB,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),kt=()=>s(null),At=()=>s(null),t[199]=Ot,t[200]=kt,t[201]=At):(Ot=t[199],kt=t[200],At=t[201]);let jt;t[202]===n?jt=t[203]:(jt=()=>n?.(),t[202]=n,t[203]=jt);let Mt;t[204]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=(0,$.jsx)($a,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[204]=Mt):Mt=t[204];let Nt;t[205]===v.openFullPreferences?Nt=t[206]:(Nt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:v.openFullPreferences}),t[205]=v.openFullPreferences,t[206]=Nt);let Pt;t[207]!==jt||t[208]!==Nt?(Pt=(0,$.jsxs)(y,{to:`/settings/overview`,className:Ot,onMouseEnter:kt,onFocus:At,onClick:jt,children:[Mt,Nt]}),t[207]=jt,t[208]=Nt,t[209]=Pt):Pt=t[209];let Ft;return t[210]!==Dt||t[211]!==Pt||t[212]!==se||t[213]!==Ae||t[214]!==et||t[215]!==tt||t[216]!==st||t[217]!==mt||t[218]!==xt?(Ft=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:P,children:[se,Ae,et,tt,st,ct,mt,xt,Dt,Pt]}),t[210]=Dt,t[211]=Pt,t[212]=se,t[213]=Ae,t[214]=et,t[215]=tt,t[216]=st,t[217]=mt,t[218]=xt,t[219]=Ft):Ft=t[219],Ft}function UB(e){return e.setPreference}function WB(e){return e.preference}function GB(e){return e.setPreference}function KB(e){return e.preference}function qB(e){return e.setLanguage}function JB(e){return e.language}var YB=`open-support-report`;function XB(e={}){window.dispatchEvent(new CustomEvent(YB,{detail:e}))}var ZB=(0,Z.lazy)(()=>s(()=>import(`./device-pairing-wizard-CLCPuf4R.js`).then(e=>e.n).then(e=>({default:e.DevicePairingWizard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])));function QB({collapsed:e=!1,onNavigate:t}){let n=Do(zo(e=>e.language)),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{s(()=>import(`./settings-page-DROUGyJl.js`),__vite__mapDeps([52,1,2,3,4,15,18,53])),s(()=>import(`./sessions-page-DsLw2aMD.js`),__vite__mapDeps([54,1,2,3,4,55,6,56,8,57,58,59,60,61,62,16,17,28,63,64,32,22,65,21,24,34,35,25,66,67,68,9,69,70,71,72,73,74,75,76,77,14,15,18,19,20,23,78,79,49,44,80,45,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,10,96,97,47,48,98,99,42,100])),s(()=>import(`./logs-page-CbY1N-zi.js`),__vite__mapDeps([101,1,2,3,4,102,6,64,32,16,17,22,65,21,24,34,35,25,103,9,104,105,106,107,75,62,14,15,18,20,23,78,28,79,36,108,109,45,82,110,90,95,10,96,97])),s(()=>import(`./automations-page-oLsNzu_6.js`),__vite__mapDeps([111,2,1,112,3,4,113,6,114,32,102,5,64,16,17,22,65,21,24,34,35,25,99,7,8,115,116,57,117,118,9,119,74,14,15,18,23,26,27,28,29,36,120,121,122,58,123,48,124,107,75,125,126,96,127,77,128,19,20,129,130,131,132,133,86,82,87,44,110,134,89,61,49,80,79,45,135,136,137,138])),s(()=>import(`./capabilities-page-DFW4Y0x8.js`),__vite__mapDeps([139,1,2,4,3,15,140,18,22,16,17,133,141,142,75,6,20,21,65,24,34,35,143]))},[]),(0,$.jsxs)(`div`,{className:Y(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[c?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ZB,{open:!0,onOpenChange:l})}):null,(0,$.jsxs)(ps,{open:r,onOpenChange:i,children:[e?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(y,{to:`/user-model`,onClick:()=>t?.(),className:`rounded-full outline-none ring-offset-surface-base transition-transform hover:opacity-95 active:scale-95 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 motion-reduce:active:scale-100`,title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(au,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex size-10 shrink-0 items-center justify-center rounded-xl text-fg-muted outline-none ring-offset-surface-base transition-colors`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)($a,{className:`size-[17px]`,strokeWidth:1.5})})})]}):(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-1 rounded-xl p-1`,children:[(0,$.jsx)(y,{to:`/user-model`,onClick:()=>t?.(),className:Y(`flex size-10 shrink-0 items-center justify-center rounded-full text-left outline-none transition-transform duration-150 ease-out`,`hover:bg-surface-active/70`,`hover:opacity-95 active:scale-95`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(au,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left text-fg-muted transition-colors`,`outline-none hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:n.appearanceSettings.quickMenuHint})]}),(0,$.jsx)($a,{className:`size-[18px] shrink-0`,strokeWidth:1.5})]})})]}),(0,$.jsx)(ds,{children:(0,$.jsx)(fs,{className:Y(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`end`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(HB,{onNavigate:()=>{i(!1),t?.()},onAboutClick:()=>{o(!0),i(!1)},onSupportClick:()=>{i(!1),XB()},onDeviceConnectClick:()=>{i(!1),l(!0)}})})})]}),(0,$.jsx)(IB,{open:a,onOpenChange:o})]})}function $B(e){return qR[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var eV=3,tV=[`work`,`capabilities`,`automation`,`apps`],nV={work:dn,capabilities:Li,automation:To,apps:oh};function rV(e,t,n=!1){return Y(`flex w-full items-center text-sm font-medium transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,n?`gap-2 rounded-md px-2 py-1.5 text-left leading-5`:e?`justify-center rounded-xl p-2.5 leading-6`:`gap-2 rounded-lg px-3 py-2.5 text-left leading-6 md:py-1.5`,t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}function iV(e){let t=(0,Q.c)(2),{Icon:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r),r}function aV(e){let t=(0,Q.c)(36),{collapsed:n,onNavigate:r,visibleLimit:i}=e,a=n!==void 0&&n,o=i===void 0?eV:i,{pathname:s}=p(),c=zo(fV),l=Do(c),u=l.productNavigation,d;t[0]===s?d=t[1]:(d=ko(s),t[0]=s,t[1]=d);let f=d,m=hc(),{profile:h,displayName:g}=ou(),_=me(),[v,b]=(0,Z.useState)(!1),x=tV.map(e=>{let t=Ao.find(t=>t.id===e);return{id:e,label:u.domains[e],to:t.path,Icon:nV[e],active:f===e}}),S=Number.isFinite(o)?Math.min(x.length,Math.max(1,Math.round(o))):eV,C=x.slice(0,S),w=x.slice(S),T;t[2]===s?T=t[3]:(T=e=>e.activationEligible===!1?[]:(e.ui?.contributions?.pages??[]).filter(dV).map(t=>{let n=jn(e.id,t);return{id:`extension:${e.id}:${t.id}`,label:t.title,to:n,Icon:t.navIcon?$B(t.navIcon)??Ba:Ba,active:s===n||s.startsWith(`${n}/`)}}),t[2]=s,t[3]=T);let E=m.flatMap(T),D=w.some(uV)||E.some(lV),O;t[4]!==a||t[5]!==r?(O=(e,t)=>{let n=t!==void 0&&t;return(0,$.jsxs)(y,{to:e.to,"aria-current":e.active?`page`:void 0,className:rV(a,e.active,n),title:e.label,onMouseEnter:()=>nu(e.to),onFocus:()=>nu(e.to),onClick:()=>{b(!1),r?.()},children:[(0,$.jsx)(iV,{Icon:e.Icon}),!a||n?(0,$.jsx)(`span`,{className:`truncate`,children:e.label}):null]},e.id)},t[4]=a,t[5]=r,t[6]=O):O=t[6];let k=O,A=s===`/personal`?`page`:void 0,j;t[7]!==a||t[8]!==s?(j=Y(`relative`,rV(a,s===`/personal`)),t[7]=a,t[8]=s,t[9]=j):j=t[9];let M;t[10]===r?M=t[11]:(M=()=>{le.getState().setCollapsed(!0),r?.()},t[10]=r,t[11]=M);let N=h?.appearance??`loopi`,P=h?.agentId,F;t[12]!==P||t[13]!==N?(F=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,"aria-hidden":!0,children:(0,$.jsx)(Ma,{appearance:N,agentId:P,className:`size-5`})}),t[12]=P,t[13]=N,t[14]=F):F=t[14];let I;t[15]!==a||t[16]!==g?(I=!a&&(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g}),t[15]=a,t[16]=g,t[17]=I):I=t[17];let L;t[18]!==a||t[19]!==c||t[20]!==_?(L=_>0&&(0,$.jsx)(`span`,{"aria-label":c===`zh`?`${_} 条未读消息`:`${_} unread messages`,className:Y(`shrink-0 rounded-full bg-accent/15 px-1.5 text-center text-[10px] font-semibold leading-5 tabular-nums text-accent`,a?`absolute right-0 top-0 min-w-4 leading-4`:`min-w-5`),children:pe(_)}),t[18]=a,t[19]=c,t[20]=_,t[21]=L):L=t[21];let R;t[22]!==g||t[23]!==F||t[24]!==I||t[25]!==L||t[26]!==A||t[27]!==j||t[28]!==M?(R=(0,$.jsxs)(y,{to:`/personal`,"aria-current":A,className:j,title:g,onMouseEnter:cV,onFocus:sV,onClick:M,children:[F,I,L]}),t[22]=g,t[23]=F,t[24]=I,t[25]=L,t[26]=A,t[27]=j,t[28]=M,t[29]=R):R=t[29];let z;t[30]===k?z=t[31]:(z=e=>k(e),t[30]=k,t[31]=z);let B=C.map(z),V=w.length>0||E.length>0?(0,$.jsxs)(ps,{open:v,onOpenChange:b,children:[(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":l.sidebar.moreAppsAria,title:l.sidebar.moreApps,className:Y(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,a?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2.5 text-left md:py-1.5`,v||D?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,$.jsx)(yr,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),a?null:(0,$.jsx)(`span`,{className:`truncate`,children:l.sidebar.moreApps})]})}),(0,$.jsx)(ds,{children:(0,$.jsx)(fs,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:`z-50 max-h-[min(32rem,var(--radix-popover-content-available-height))] min-w-[14rem] max-w-[20rem] overflow-y-auto rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,onOpenAutoFocus:oV,children:(0,$.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":l.sidebar.moreAppsAria,children:[w.map(e=>k(e,!0)),E.length>0?(0,$.jsxs)(`section`,{"aria-labelledby":`sidebar-more-extension-apps`,children:[(0,$.jsx)(`div`,{id:`sidebar-more-extension-apps`,className:`px-2 pb-1 pt-1.5 text-[11px] font-semibold tracking-wide text-fg-subtle`,children:l.sidebar.extensionAppsHeading}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:E.map(e=>k(e,!0))})]}):null]})})})]}):null,H;return t[32]!==R||t[33]!==B||t[34]!==V?(H=(0,$.jsxs)($.Fragment,{children:[R,B,V]}),t[32]=R,t[33]=B,t[34]=V,t[35]=H):H=t[35],H}function oV(e){return e.preventDefault()}function sV(){return nu(`/personal`)}function cV(){return nu(`/personal`)}function lV(e){return e.active}function uV(e){return e.active}function dV(e){return e.showInNav}function fV(e){return e.language}var pV={sources:[],purposes:[],activity:``,project:``,days:``,status:`visible`,agentId:``,details:!1};function mV(e){return!!(e.sources.length||e.purposes.length||e.activity||e.project||e.days||e.agentId||e.status!==`visible`)}function hV(e,t,n=Date.now()){return{search:t.trim()||void 0,sources:e.sources.length?e.sources:void 0,purposes:e.purposes.length?e.purposes:[...Sa],activity:e.activity||void 0,projectId:e.project&&e.project!==`__unassigned`?e.project:void 0,unassigned:e.project===`__unassigned`||void 0,updatedAfter:e.days?n-Number(e.days)*864e5:void 0,status:e.status===`visible`?void 0:e.status,excludeArchived:e.status!==`archived`,agentId:e.agentId||void 0,sortBy:`updatedAt`,sortOrder:`desc`}}function gV(e){return`xopc-session-filters-v1:${e}`}function _V(e){try{let t=xa.safeParse({sources:e.sources,purposes:e.purposes,activity:e.activity||void 0,agentId:e.agentId||void 0});return t.success?{...pV,...t.data,sources:t.data.sources??[],purposes:t.data.purposes??[],activity:t.data.activity??``,agentId:t.data.agentId??``,project:typeof e.project==`string`?e.project:``,days:typeof e.days==`string`&&[``,`7`,`30`,`60`].includes(e.days)?e.days:``,status:e.status===`pinned`||e.status===`archived`?e.status:`visible`,details:e.details===!0}:{...pV}}catch{return{...pV}}}function vV(e){try{return _V(JSON.parse(localStorage.getItem(gV(e))??`{}`))}catch{return{...pV}}}function yV(e,t){try{localStorage.setItem(gV(e),JSON.stringify(t))}catch{}}async function bV(){let e=[];for(let t=0;;){let n=await Is({limit:100,offset:t,sortBy:`name`,sortOrder:`asc`});if(e.push(...n.items),t+=n.items.length,!n.items.length||t>=n.total)return e}}var xV=e=>`xopc-session-views-v1:${e}`;function SV(e){try{let t=JSON.parse(localStorage.getItem(xV(e))??`[]`);return Array.isArray(t)?t.filter(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&e.name.trim()).slice(0,20).map(e=>({id:e.id,name:e.name.slice(0,60),filters:_V(e.filters??{}),search:typeof e.search==`string`?e.search.slice(0,500):``})):[]}catch{return[]}}function CV(e,t){try{return localStorage.setItem(xV(e),JSON.stringify(t)),!0}catch{return!1}}var wV=`rounded-md px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,TV=`flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`;function EV(e){let t=(0,Q.c)(10),{label:n,summary:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`shrink-0`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-xs text-fg-muted`,title:r,children:r}),t[2]=r,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(vn,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i||t[7]!==a||t[8]!==o?(c=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-10 w-full min-w-0 items-center gap-3 rounded-md px-2 py-2 text-left text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n,children:[a,o,s]}),t[5]=n,t[6]=i,t[7]=a,t[8]=o,t[9]=c):c=t[9],c}function DV(e){let t=(0,Q.c)(261),{filters:n,onChange:r,search:i,onSearch:a,labels:o,gateway:s,agents:c}=e,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`home`),[p,m]=(0,Z.useState)(``),h;t[0]===s?h=t[1]:(h=()=>SV(s),t[0]=s,t[1]=h);let[g,_]=(0,Z.useState)(h),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(`home`),w=(0,Z.useId)(),T=(0,Z.useId)(),E;if(t[2]!==n||t[3]!==g||t[4]!==i){let e;t[6]!==n||t[7]!==i?(e=e=>e.search===i&&JSON.stringify(e.filters)===JSON.stringify(n),t[6]=n,t[7]=i,t[8]=e):e=t[8],E=g.find(e),t[2]=n,t[3]=g,t[4]=i,t[5]=E}else E=t[5];let D=E,O;t[9]!==n.project||t[10]!==s||t[11]!==l||t[12]!==d?(O=l&&d===`project`||n.project?[`session-filter-projects`,s]:null,t[9]=n.project,t[10]=s,t[11]=l,t[12]=d,t[13]=O):O=t[13];let{data:k,error:A,mutate:j}=qo(O,bV),M;t[14]!==n||t[15]!==r?(M=e=>r({...n,...e}),t[14]=n,t[15]=r,t[16]=M):M=t[16];let N=M,P;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{f(e),m(``),x(!1)},t[17]=P):P=t[17];let F=P,I;t[18]===d?I=t[19]:(I=()=>F(d===`save`?`views`:[`purposes`,`status`,`agent`].includes(d)?`advanced`:`home`),t[18]=d,t[19]=I);let L=I,R;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{u(e),e&&F(`home`)},t[20]=R):R=t[20];let z=R,B,V;t[21]!==l||t[22]!==d?(B=()=>{l&&C.current!==d&&(S.current?.querySelector(`[data-page-autofocus]`))?.focus(),C.current=d},V=[l,d],t[21]=l,t[22]=d,t[23]=B,t[24]=V):(B=t[23],V=t[24]),(0,Z.useLayoutEffect)(B,V);let H;t[25]===n?H=t[26]:(H=mV({...n,activity:``}),t[25]=n,t[26]=H);let U=H,W=n.status!==`visible`,ee;t[27]!==n.activity||t[28]!==n.agentId||t[29]!==n.days||t[30]!==n.project||t[31]!==n.purposes.length||t[32]!==n.sources.length||t[33]!==W?(ee=[n.sources.length,n.purposes.length,n.project,n.days,n.agentId,n.activity,W].filter(Boolean),t[27]=n.activity,t[28]=n.agentId,t[29]=n.days,t[30]=n.project,t[31]=n.purposes.length,t[32]=n.sources.length,t[33]=W,t[34]=ee):ee=t[34];let G=ee.length,K=n.status!==`visible`,q;t[35]!==n.agentId||t[36]!==n.purposes.length||t[37]!==K?(q=[n.purposes.length,n.agentId,K].filter(Boolean),t[35]=n.agentId,t[36]=n.purposes.length,t[37]=K,t[38]=q):q=t[38];let te=q.length,ne;t[39]===o.selectedCount?ne=t[40]:(ne=e=>o.selectedCount.replace(`{{count}}`,String(e)),t[39]=o.selectedCount,t[40]=ne);let re=ne,ie;t[41]!==n.sources||t[42]!==o.all||t[43]!==o.sources?(ie=n.sources.length?n.sources.map(e=>o.sources[e]).join(` · `):o.all,t[41]=n.sources,t[42]=o.all,t[43]=o.sources,t[44]=ie):ie=t[44];let ae=ie,oe;t[45]!==n.purposes||t[46]!==o.all||t[47]!==o.purposes?(oe=n.purposes.length?n.purposes.map(e=>o.purposes[e]).join(` · `):o.all,t[45]=n.purposes,t[46]=o.all,t[47]=o.purposes,t[48]=oe):oe=t[48];let se=oe,ce;t[49]!==n.project||t[50]!==o.unassigned||t[51]!==k?(ce=n.project===`__unassigned`?o.unassigned:k?.find(e=>e.id===n.project)?.name??n.project,t[49]=n.project,t[50]=o.unassigned,t[51]=k,t[52]=ce):ce=t[52];let le=ce,ue;t[53]!==n.days||t[54]!==o.anyTime||t[55]!==o.days?(ue=n.days?o.days.replace(`{{days}}`,n.days):o.anyTime,t[53]=n.days,t[54]=o.anyTime,t[55]=o.days,t[56]=ue):ue=t[56];let de=ue,fe;t[57]!==o.agent||t[58]!==o.filters||t[59]!==o.moreFilters||t[60]!==o.project||t[61]!==o.purposesLabel||t[62]!==o.saveView||t[63]!==o.savedViews||t[64]!==o.sourcesLabel||t[65]!==o.status||t[66]!==o.time?(fe={home:o.filters,sources:o.sourcesLabel,purposes:o.purposesLabel,project:o.project,time:o.time,status:o.status,agent:o.agent,advanced:o.moreFilters,views:o.savedViews,save:o.saveView},t[57]=o.agent,t[58]=o.filters,t[59]=o.moreFilters,t[60]=o.project,t[61]=o.purposesLabel,t[62]=o.saveView,t[63]=o.savedViews,t[64]=o.sourcesLabel,t[65]=o.status,t[66]=o.time,t[67]=fe):fe=t[67];let pe=fe,me,he,ge,_e,ve;if(t[68]!==c||t[69]!==L||t[70]!==n.agentId||t[71]!==n.days||t[72]!==n.project||t[73]!==n.purposes||t[74]!==n.sources||t[75]!==n.status||t[76]!==o||t[77]!==p||t[78]!==d||t[79]!==N||t[80]!==k){let e;if(t[86]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[86]=e):e=t[86],ve=e,d===`sources`){let e;t[87]===o.sources?e=t[88]:(e=e=>({value:e,label:o.sources[e]}),t[87]=o.sources,t[88]=e),he=wa.map(e),ve=n.sources;let r;t[89]===N?r=t[90]:(r=e=>N({sources:e}),t[89]=N,t[90]=r),me=r}else if(d===`purposes`){let e;t[91]===o.purposes?e=t[92]:(e=e=>({value:e,label:o.purposes[e]}),t[91]=o.purposes,t[92]=e),he=Sa.map(e),ve=n.purposes;let r;t[93]===N?r=t[94]:(r=e=>N({purposes:e}),t[93]=N,t[94]=r),me=r}else if(d===`project`){he=[{value:``,label:o.allProjects},{value:`__unassigned`,label:o.unassigned},...(k??[]).map(kV)],n.project&&!he.some(e=>e.value===n.project)&&he.push({value:n.project,label:n.project});let e;t[95]===n.project?e=t[96]:(e=[n.project],t[95]=n.project,t[96]=e),ve=e;let r;t[97]!==L||t[98]!==N?(r=e=>{let[t]=e;N({project:t}),L()},t[97]=L,t[98]=N,t[99]=r):r=t[99],me=r}else if(d===`time`){he=[{value:``,label:o.anyTime},...[`7`,`30`,`60`].map(e=>({value:e,label:o.days.replace(`{{days}}`,e)}))];let e;t[100]===n.days?e=t[101]:(e=[n.days],t[100]=n.days,t[101]=e),ve=e;let r;t[102]!==L||t[103]!==N?(r=e=>{let[t]=e;N({days:t}),L()},t[102]=L,t[103]=N,t[104]=r):r=t[104],me=r}else if(d===`status`){he=[`visible`,`pinned`,`archived`].map(e=>({value:e,label:o[e]}));let e;t[105]===n.status?e=t[106]:(e=[n.status],t[105]=n.status,t[106]=e),ve=e;let r;t[107]!==L||t[108]!==N?(r=e=>{let[t]=e;N({status:t}),L()},t[107]=L,t[108]=N,t[109]=r):r=t[109],me=r}else if(d===`agent`){he=[{value:``,label:o.allAgents},...c.map(OV)],n.agentId&&!he.some(e=>e.value===n.agentId)&&he.push({value:n.agentId,label:n.agentId});let e;t[110]===n.agentId?e=t[111]:(e=[n.agentId],t[110]=n.agentId,t[111]=e),ve=e;let r;t[112]!==L||t[113]!==N?(r=e=>{let[t]=e;N({agentId:t}),L()},t[112]=L,t[113]=N,t[114]=r):r=t[114],me=r}ge=d===`project`||d===`agent`,_e=he?.filter(e=>e.label.toLocaleLowerCase().includes(p.trim().toLocaleLowerCase())),t[68]=c,t[69]=L,t[70]=n.agentId,t[71]=n.days,t[72]=n.project,t[73]=n.purposes,t[74]=n.sources,t[75]=n.status,t[76]=o,t[77]=p,t[78]=d,t[79]=N,t[80]=k,t[81]=me,t[82]=he,t[83]=ge,t[84]=_e,t[85]=ve}else me=t[81],he=t[82],ge=t[83],_e=t[84],ve=t[85];let J=_e,ye;t[115]!==n.details||t[116]!==r||t[117]!==d||t[118]!==N?(ye=()=>{d===`sources`?N({sources:[]}):d===`purposes`?N({purposes:[]}):r({...pV,details:n.details})},t[115]=n.details,t[116]=r,t[117]=d,t[118]=N,t[119]=ye):ye=t[119];let be=ye,xe=l&&`bg-surface-hover opacity-100`,Se;t[120]===xe?Se=t[121]:(Se=Y(TV,`relative size-6 text-fg-subtle opacity-0 transition-[color,background-color,opacity] group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100 [@media(hover:none)]:opacity-100`,xe),t[120]=xe,t[121]=Se);let Ce=`${o.filters}${G?` (${G})`:``}`,we;t[122]!==G||t[123]!==o.filters||t[124]!==re?(we=G?`${o.filters} · ${re(G)}`:o.filters,t[122]=G,t[123]=o.filters,t[124]=re,t[125]=we):we=t[125];let Te;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(yr,{className:`size-3.5`,"aria-hidden":!0}),t[126]=Te):Te=t[126];let Ee;t[127]!==G||t[128]!==i?(Ee=G>0||i.trim()?(0,$.jsx)(`span`,{className:`absolute top-0.5 right-0.5 size-1 rounded-full bg-fg-muted`,"aria-hidden":!0}):null,t[127]=G,t[128]=i,t[129]=Ee):Ee=t[129];let De;t[130]!==Se||t[131]!==Ce||t[132]!==we||t[133]!==Ee?(De=(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Se,"aria-label":Ce,title:we,children:[Te,Ee]})}),t[130]=Se,t[131]=Ce,t[132]=we,t[133]=Ee,t[134]=De):De=t[134];let Oe;t[135]!==L||t[136]!==d?(Oe=e=>{d!==`home`&&(e.preventDefault(),L())},t[135]=L,t[136]=d,t[137]=Oe):Oe=t[137];let ke;t[138]!==L||t[139]!==o.back||t[140]!==d||t[141]!==ge?(ke=d===`home`?null:(0,$.jsx)(`button`,{type:`button`,className:TV,"aria-label":o.back,onClick:L,"data-page-autofocus":!ge&&d!==`save`?``:void 0,children:(0,$.jsx)(_t,{className:`size-4`,"aria-hidden":!0})}),t[138]=L,t[139]=o.back,t[140]=d,t[141]=ge,t[142]=ke):ke=t[142];let Ae=pe[d],je;t[143]!==T||t[144]!==Ae?(je=(0,$.jsx)(`span`,{id:T,className:`min-w-0 flex-1 truncate px-1 font-medium`,children:Ae}),t[143]=T,t[144]=Ae,t[145]=je):je=t[145];let Me;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0}),t[146]=Me):Me=t[146];let Ne;t[147]===o.close?Ne=t[148]:(Ne=(0,$.jsx)(ms,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:TV,"aria-label":o.close,children:Me})}),t[147]=o.close,t[148]=Ne);let Pe;t[149]!==ke||t[150]!==je||t[151]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-edge px-2 py-2`,children:[ke,je,Ne]}),t[149]=ke,t[150]=je,t[151]=Ne,t[152]=Pe):Pe=t[152];let Fe;t[153]!==o.searchOptions||t[154]!==p||t[155]!==ge?(Fe=ge?(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,$.jsx)(`input`,{type:`search`,"data-page-autofocus":!0,value:p,onChange:e=>m(e.target.value),placeholder:o.searchOptions,"aria-label":o.searchOptions,className:`w-full rounded-md border border-edge bg-surface-base px-2 py-1.5 text-sm outline-none focus:border-edge-strong focus:ring-1 focus:ring-edge-strong`})}):null,t[153]=o.searchOptions,t[154]=p,t[155]=ge,t[156]=Fe):Fe=t[156];let Ie;t[157]!==o.search||t[158]!==a||t[159]!==d||t[160]!==i?(Ie=d===`home`?(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,$.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base px-2 py-1.5 focus-within:border-edge-strong focus-within:ring-1 focus-within:ring-edge-strong`,children:[(0,$.jsx)(Xa,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:o.search,"aria-label":o.search,className:`min-w-0 w-full bg-transparent text-sm text-fg outline-none`})]})}):null,t[157]=o.search,t[158]=a,t[159]=d,t[160]=i,t[161]=Ie):Ie=t[161];let Le;t[162]!==te||t[163]!==U||t[164]!==n.activity||t[165]!==n.details||t[166]!==o||t[167]!==r||t[168]!==d||t[169]!==le||t[170]!==g.length||t[171]!==re||t[172]!==D?.name||t[173]!==ae||t[174]!==de?(Le=d===`home`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(su,{className:`mb-2 flex gap-1 rounded-md bg-surface-base p-1`,role:`group`,"aria-label":o.filters,indicatorClassName:`rounded-md bg-surface-active`,children:[``,`manual`,`automatic`].map(e=>(0,$.jsx)(`button`,{type:`button`,"data-page-autofocus":e===``?``:void 0,className:Y(wV,`min-w-0 flex-1 px-1`,!U&&n.activity===e&&`bg-surface-active text-fg`),"aria-pressed":!U&&n.activity===e,onClick:()=>{r({...pV,details:n.details,activity:e}),u(!1)},children:e?o[e]:o.all},e))}),(0,$.jsx)(EV,{label:o.sourcesLabel,summary:ae,onClick:()=>F(`sources`)}),(0,$.jsx)(EV,{label:o.project,summary:le||o.allProjects,onClick:()=>F(`project`)}),(0,$.jsx)(EV,{label:o.time,summary:de,onClick:()=>F(`time`)}),(0,$.jsx)(`div`,{className:`my-2 border-t border-edge`}),(0,$.jsx)(EV,{label:o.moreFilters,summary:te?re(te):``,onClick:()=>F(`advanced`)}),(0,$.jsx)(EV,{label:o.savedViews,summary:D?.name??(g.length?String(g.length):``),onClick:()=>F(`views`)})]}):null,t[162]=te,t[163]=U,t[164]=n.activity,t[165]=n.details,t[166]=o,t[167]=r,t[168]=d,t[169]=le,t[170]=g.length,t[171]=re,t[172]=D?.name,t[173]=ae,t[174]=de,t[175]=Le):Le=t[175];let Re;t[176]!==me||t[177]!==o.noOptions||t[178]!==o.projectError||t[179]!==o.retry||t[180]!==J||t[181]!==he||t[182]!==d||t[183]!==A||t[184]!==k||t[185]!==j||t[186]!==pe||t[187]!==ve?(Re=he&&me?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wn,{options:J??[],values:ve,multiple:d===`sources`||d===`purposes`,onChange:me,ariaLabel:pe[d]}),d===`project`&&!k&&!A?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3 p-2`,children:[(0,$.jsx)(Xo,{className:`h-5 w-3/4`}),(0,$.jsx)(Xo,{className:`h-5 w-2/3`})]}):null,d===`project`&&A?(0,$.jsxs)(`div`,{role:`alert`,className:`p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:o.projectError}),(0,$.jsx)(`button`,{type:`button`,className:wV,onClick:()=>void j(),children:o.retry})]}):null,!J?.length&&!(d===`project`&&!k)?(0,$.jsx)(`p`,{className:`p-2 text-xs text-fg-muted`,children:o.noOptions}):null]}):null,t[176]=me,t[177]=o.noOptions,t[178]=o.projectError,t[179]=o.retry,t[180]=J,t[181]=he,t[182]=d,t[183]=A,t[184]=k,t[185]=j,t[186]=pe,t[187]=ve,t[188]=Re):Re=t[188];let ze;t[189]!==c||t[190]!==n.agentId||t[191]!==n.details||t[192]!==n.status||t[193]!==o||t[194]!==d||t[195]!==N||t[196]!==se?(ze=d===`advanced`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(EV,{label:o.purposesLabel,summary:se,onClick:()=>F(`purposes`)}),(0,$.jsx)(EV,{label:o.status,summary:o[n.status],onClick:()=>F(`status`)}),c.length>1||n.agentId?(0,$.jsx)(EV,{label:o.agent,summary:c.find(e=>e.id===n.agentId)?.name??(n.agentId||o.allAgents),onClick:()=>F(`agent`)}):null,(0,$.jsxs)(`label`,{className:`mt-2 flex min-h-10 items-center gap-3 border-t border-edge px-2 pt-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.details,onChange:e=>N({details:e.target.checked})}),o.details]})]}):null,t[189]=c,t[190]=n.agentId,t[191]=n.details,t[192]=n.status,t[193]=o,t[194]=d,t[195]=N,t[196]=se,t[197]=ze):ze=t[197];let Be;t[198]!==s||t[199]!==o.deleteView||t[200]!==o.noViews||t[201]!==r||t[202]!==a||t[203]!==d||t[204]!==g||t[205]!==D?.id?(Be=d===`views`?(0,$.jsxs)($.Fragment,{children:[g.length?null:(0,$.jsx)(`p`,{className:`px-2 py-4 text-sm text-fg-muted`,children:o.noViews}),g.map(e=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{r(e.filters),a(e.search),u(!1)},"aria-pressed":D?.id===e.id,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),D?.id===e.id?(0,$.jsx)(hn,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]}),(0,$.jsx)(`button`,{type:`button`,className:TV,"aria-label":o.deleteView.replace(`{{name}}`,e.name),onClick:()=>{let t=g.filter(t=>t.id!==e.id);CV(s,t)?(_(t),x(!1)):x(!0)},children:(0,$.jsx)(ho,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))]}):null,t[198]=s,t[199]=o.deleteView,t[200]=o.noViews,t[201]=r,t[202]=a,t[203]=d,t[204]=g,t[205]=D?.id,t[206]=Be):Be=t[206];let Ve;t[207]!==n||t[208]!==w||t[209]!==s||t[210]!==o.saveViewHint||t[211]!==o.viewLimit||t[212]!==o.viewName||t[213]!==d||t[214]!==g||t[215]!==i||t[216]!==v?(Ve=d===`save`?(0,$.jsxs)(`form`,{id:w,className:`space-y-3 p-1`,onSubmit:e=>{e.preventDefault();let t=v.trim();if(!t||g.length>=20)return;let r=[...g,{id:crypto.randomUUID(),name:t,filters:n,search:i}];if(!CV(s,r)){x(!0);return}_(r),y(``),F(`views`)},children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:o.viewName}),(0,$.jsx)(`input`,{"data-page-autofocus":!0,value:v,onChange:e=>y(e.target.value),maxLength:60,placeholder:o.viewName,"aria-label":o.viewName,className:`w-full rounded-md border border-edge bg-surface-base px-2 py-2 focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.saveViewHint}),g.length>=20?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.viewLimit}):null]}):null,t[207]=n,t[208]=w,t[209]=s,t[210]=o.saveViewHint,t[211]=o.viewLimit,t[212]=o.viewName,t[213]=d,t[214]=g,t[215]=i,t[216]=v,t[217]=Ve):Ve=t[217];let He;t[218]!==o.viewSaveError||t[219]!==b?(He=b?(0,$.jsx)(`p`,{role:`alert`,className:`p-2 text-xs text-danger`,children:o.viewSaveError}):null,t[218]=o.viewSaveError,t[219]=b,t[220]=He):He=t[220];let Ue;t[221]!==d||t[222]!==Le||t[223]!==Re||t[224]!==ze||t[225]!==Be||t[226]!==Ve||t[227]!==He?(Ue=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain p-2`,"data-session-filter-scroll":!0,children:[Le,Re,ze,Be,Ve,He]},d),t[221]=d,t[222]=Le,t[223]=Re,t[224]=ze,t[225]=Be,t[226]=Ve,t[227]=He,t[228]=Ue):Ue=t[228];let We;t[229]!==be||t[230]!==G||t[231]!==o.clear||t[232]!==o.clearSelection||t[233]!==o.saveView||t[234]!==d||t[235]!==g.length||t[236]!==ve?(We=d===`home`||d===`sources`||d===`purposes`?(0,$.jsx)(`button`,{type:`button`,className:wV,disabled:d===`home`?!G:!ve.length,onClick:be,children:d===`home`?o.clear:o.clearSelection}):d===`views`?(0,$.jsx)(`button`,{type:`button`,className:wV,disabled:g.length>=20,onClick:()=>F(`save`),children:o.saveView}):(0,$.jsx)(`span`,{}),t[229]=be,t[230]=G,t[231]=o.clear,t[232]=o.clearSelection,t[233]=o.saveView,t[234]=d,t[235]=g.length,t[236]=ve,t[237]=We):We=t[237];let Ge;t[238]!==L||t[239]!==w||t[240]!==o.done||t[241]!==o.saveView||t[242]!==d||t[243]!==g.length||t[244]!==v?(Ge=d===`save`?(0,$.jsx)(`button`,{type:`submit`,form:w,className:Y(wV,`bg-surface-active text-fg`),disabled:!v.trim()||g.length>=20,children:o.saveView}):(0,$.jsx)(`button`,{type:`button`,className:Y(wV,`bg-surface-active text-fg`),onClick:()=>d===`home`?u(!1):L(),children:o.done}),t[238]=L,t[239]=w,t[240]=o.done,t[241]=o.saveView,t[242]=d,t[243]=g.length,t[244]=v,t[245]=Ge):Ge=t[245];let Ke;t[246]!==We||t[247]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-3 py-2`,children:[We,Ge]}),t[246]=We,t[247]=Ge,t[248]=Ke):Ke=t[248];let qe;t[249]!==T||t[250]!==Oe||t[251]!==Pe||t[252]!==Fe||t[253]!==Ie||t[254]!==Ue||t[255]!==Ke?(qe=(0,$.jsx)(ds,{children:(0,$.jsxs)(fs,{ref:S,side:`bottom`,align:`start`,sideOffset:8,collisionPadding:12,sticky:`always`,"aria-labelledby":T,className:`z-50 flex h-[min(26rem,calc(100dvh-1.5rem))] max-h-[var(--radix-popover-content-available-height)] w-[min(20rem,calc(100vw-1.5rem))] max-w-[var(--radix-popover-content-available-width)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-sm text-fg shadow-popover`,onEscapeKeyDown:Oe,children:[Pe,Fe,Ie,Ue,Ke]})}),t[249]=T,t[250]=Oe,t[251]=Pe,t[252]=Fe,t[253]=Ie,t[254]=Ue,t[255]=Ke,t[256]=qe):qe=t[256];let Je;return t[257]!==l||t[258]!==De||t[259]!==qe?(Je=(0,$.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,$.jsxs)(ps,{open:l,onOpenChange:z,children:[De,qe]})}),t[257]=l,t[258]=De,t[259]=qe,t[260]=Je):Je=t[260],Je}function OV(e){return{value:e.id,label:e.name||e.id}}function kV(e){return{value:e.id,label:e.name}}var AV=30;function jV(e,t){let n=(0,Q.c)(47),r;n[0]===e?r=n[1]:(r=()=>vV(e),n[0]=e,n[1]=r);let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(``),[c]=cu(o,250),[l,u]=(0,Z.useState)(!1),d;n[2]!==i||n[3]!==o?(d=mV(i)||!!o.trim(),n[2]=i,n[3]=o,n[4]=d):d=n[4];let f=d,p;n[5]!==f||n[6]!==e||n[7]!==t?(p=f&&t?[`session-filter-projects`,e]:null,n[5]=f,n[6]=e,n[7]=t,n[8]=p):p=n[8];let{data:m}=qo(p,bV),h;n[9]!==c||n[10]!==i?(h=hV(i,c),n[9]=c,n[10]=i,n[11]=h):h=n[11];let g=h,_;n[12]!==f||n[13]!==e||n[14]!==g||n[15]!==t?(_=(n,r)=>!t||!f||r&&!r.hasMore?null:[`session-discovery`,e,t,g,n],n[12]=f,n[13]=e,n[14]=g,n[15]=t,n[16]=_):_=n[16];let v;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!1},n[17]=v):v=n[17];let{data:y,error:b,isValidating:x,size:S,setSize:C,mutate:w}=Yo(_,PV,v),T;n[18]===e?T=n[19]:(T=t=>{a(t),yV(e,t)},n[18]=e,n[19]=T);let E=T,D;n[20]===w?D=n[21]:(D=()=>{u(!1),w()},n[20]=w,n[21]=D);let O=D,k,A;n[22]===f?(k=n[23],A=n[24]):(k=()=>{if(!f)return;let e=()=>u(!0),t=[`session-list-refresh`,`session-created`,`session-updated`,`session-transcript-updated`,`project-updated`];return t.forEach(t=>window.addEventListener(t,e)),()=>t.forEach(t=>window.removeEventListener(t,e))},A=[f],n[22]=f,n[23]=k,n[24]=A),(0,Z.useEffect)(k,A);let j;n[25]===y?j=n[26]:(j=[...new Map(y?.flatMap(NV).map(MV)??[]).values()],n[25]=y,n[26]=j);let M=j,N=y?.[0]?.total??0,P=!b&&(!y||o!==c),F;n[27]===y?F=n[28]:(F=y?.at(-1)?.hasMore??!1,n[27]=y,n[28]=F);let I=x&&!!y,L;n[29]!==C||n[30]!==S?(L=()=>void C(S+1),n[29]=C,n[30]=S,n[31]=L):L=n[31];let R;return n[32]!==f||n[33]!==b||n[34]!==i||n[35]!==M||n[36]!==l||n[37]!==m||n[38]!==O||n[39]!==o||n[40]!==N||n[41]!==P||n[42]!==F||n[43]!==I||n[44]!==L||n[45]!==E?(R={projects:m,filters:i,updateFilters:E,search:o,setSearch:s,active:f,items:M,total:N,loading:P,error:b,hasMore:F,loadingMore:I,loadMore:L,refresh:O,pendingUpdate:l},n[32]=f,n[33]=b,n[34]=i,n[35]=M,n[36]=l,n[37]=m,n[38]=O,n[39]=o,n[40]=N,n[41]=P,n[42]=F,n[43]=I,n[44]=L,n[45]=E,n[46]=R):R=n[46],R}function MV(e){return[e.key,e]}function NV(e){return e.items}function PV(e){let[,,,t,n]=e;return Js({...t,limit:AV,offset:n*AV})}function FV(e,t){if(!e||typeof e!=`object`)return!0;let n=e.key??e.conversationId;return typeof n!=`string`||!n.trim()||!t.has(n)}var IV=(0,Z.createContext)(!1),LV=(0,Z.createContext)({}),RV=(0,Z.memo)(function(e){let t=(0,Q.c)(27),{child:n,activeTaskId:r,onNavigate:i,sb:a}=e,o=p(),s;t[0]===n.activeConversationId?s=t[1]:(s=e=>n.activeConversationId?e.runs[n.activeConversationId]:void 0,t[0]=n.activeConversationId,t[1]=s);let c=te(s),l;t[2]!==n.activeConversationId||t[3]!==n.taskId||t[4]!==o?(l=n.activeConversationId?`/chat/task/${encodeURIComponent(n.taskId)}`:ea(`${o.pathname}${o.search}`,n.taskId),t[2]=n.activeConversationId,t[3]=n.taskId,t[4]=o,t[5]=l):l=t[5];let u=r===n.taskId&&`bg-surface-active text-fg`,d;t[6]===u?d=t[7]:(d=Y(`ml-8 flex min-h-8 items-center gap-2 rounded-lg px-2 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,u),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=()=>i?.(),t[8]=i,t[9]=f);let m;t[10]!==c||t[11]!==a?(m=c?.unread?(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":c.status===`failed`?a.taskSessionAgentFailed:a.taskSessionAgentCompleted}):null,t[10]=c,t[11]=a,t[12]=m):m=t[12];let h;t[13]===n.title?h=t[14]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[13]=n.title,t[14]=h);let g=n.runStatus??n.phase,_;t[15]!==a||t[16]!==g?(_=XV(g,a),t[15]=a,t[16]=g,t[17]=_):_=t[17];let v;t[18]===_?v=t[19]:(v=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:_}),t[18]=_,t[19]=v);let b;return t[20]!==v||t[21]!==l||t[22]!==d||t[23]!==f||t[24]!==m||t[25]!==h?(b=(0,$.jsxs)(y,{to:l,className:d,onClick:f,children:[m,h,v]}),t[20]=v,t[21]=l,t[22]=d,t[23]=f,t[24]=m,t[25]=h,t[26]=b):b=t[26],b}),zV=20,BV=12,VV=5,HV=60,UV=`application/x-xopc-sidebar-item`;function WV(e,t,n,r){let i=e.filter(e=>e!==t),a=i.indexOf(n);return a<0?e:(i.splice(a+ +!!r,0,t),i)}function GV(e,t,n){if(!t?.length)return e;let r=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({item:e,index:t,rank:r.get(n(e))})).sort((e,t)=>e.rank!==void 0&&t.rank!==void 0?e.rank-t.rank:e.rank===void 0?t.rank===void 0?e.index-t.index:-1:1).map(({item:e})=>e)}function KV({spec:e,children:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null);return e?(0,$.jsxs)(`div`,{draggable:!0,className:Y(`relative cursor-grab transition-[opacity,transform] duration-200 ease-out active:cursor-grabbing`,n&&`opacity-50`),onDragStart:t=>{r(!0),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(UV,JSON.stringify({containerId:e.containerId,itemId:e.itemId}))},onDragEnd:()=>{r(!1),a(null)},onDragOver:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();a(e.clientY>=t.top+t.height/2?`after`:`before`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(null)},onDrop:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>=n.top+n.height/2;a(null);try{let n=JSON.parse(t.dataTransfer.getData(UV));if(n.containerId!==e.containerId||n.itemId===e.itemId)return;e.onReorder(e.containerId,WV(e.itemIds,n.itemId,e.itemId,r))}catch{}},children:[i===`before`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 top-0 z-30 h-0.5 rounded-full bg-accent`}):null,t,i===`after`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 bottom-0 z-30 h-0.5 rounded-full bg-accent`}):null]}):t}function qV(e,t){return e.name?.trim()||t}function JV(e){let t=/^\/chat\/([^/]+)$/.exec(e);if(!t)return;let n=decodeURIComponent(t[1]);if(n!==`new`)return n}function YV(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function XV(e,t){return e===`running`||e===`active`||e===`verifying`?t.delegatedTaskRunning:e===`completed`||e===`succeeded`||e===`closed`?t.delegatedTaskCompleted:e===`failed`?t.delegatedTaskFailed:e===`backlog`||e===`ready`||e===`queued`||e===`waiting`?t.delegatedTaskWaiting:e}function ZV(e){let t=new Date(e.updatedAt).getTime();return Number.isFinite(t)?t:0}function QV(e){return Y(`group relative flex min-h-8 w-full min-w-0 items-center rounded-lg pr-1 text-left text-sm leading-5 transition-colors duration-200 ease-out`,`pl-6`,`focus-within:outline-none`,e?`bg-surface-active font-medium text-fg`:`font-normal text-fg-muted hover:bg-surface-hover hover:text-fg`)}var $V=`text-xs font-normal leading-5 text-fg-subtle`,eH=Y($V,`transition-colors hover:text-fg-muted`);function tH(e){let t=(0,Q.c)(5),{indented:n}=e,r=n!==void 0&&n&&`pl-6`,i;t[0]===r?i=t[1]:(i=Y(`flex items-center gap-2 p-1.5`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(Xo,{className:`h-3 w-4/5 animate-none`}),(0,$.jsx)(Xo,{className:`mt-1.5 h-2.5 w-2/5 animate-none`})]}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`div`,{className:i,children:a}),t[3]=i,t[4]=o),o}function nH(){let e=(0,Q.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Xo,{className:`mb-1.5 h-2.5 w-14 animate-none`}),(0,$.jsx)(tH,{})]}),n=(0,$.jsx)(Xo,{className:`mb-1.5 h-2.5 w-16 animate-none`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-4`,"aria-busy":`true`,children:[t,(0,$.jsxs)(`div`,{children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(tH,{}),(0,$.jsx)(tH,{indented:!0}),(0,$.jsx)(tH,{indented:!0})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Xo,{className:`mb-1.5 h-2.5 w-12 animate-none`}),(0,$.jsx)(tH,{}),(0,$.jsx)(tH,{})]})]}),e[2]=r):r=e[2],r}var rH=(0,Z.memo)(function({session:e,isActive:t,onNavigate:n,mutate:r,onRequestRename:i,onRequestDelete:a,sb:o,sess:s,clipboard:c,defaultUnnamedTitle:l,contextLabel:u,sort:d,showTaskChildren:f=!0}){let m=(0,Z.useContext)(LV)[e.key],h=p(),g=/^\/chat\/task\/([^/]+)$/.exec(h.pathname)?.[1],_=m?.items.some(e=>e.taskId===g||e.activeConversationId===JV(h.pathname))??!1,[v,b]=(0,Z.useState)(_);(0,Z.useEffect)(()=>{_&&b(!0)},[_]);let x=(0,Z.useContext)(IV),S=ba(e),C=S.source!==`workbench`||S.purpose!==`chat`,w=E(e,o.sessionFilters),T=[w,u].filter(Boolean).join(` · `),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),j=We(e.key),M=te(t=>t.runs[e.key]),N=qV(e,l),P=e.status===`pinned`,F=j||!!M?.unread,I=async()=>{if(!k){A(!0);try{P?await qs(e.key):await Hs(e.key),O(!1),r()}catch{}finally{A(!1)}}},L=async()=>{let t=await xc(e.key);if(O(!1),t){ii(`success`,o.taskChatIdCopied,void 0,{duration:2e3});return}ii(`warning`,c.copyFailed,void 0,{duration:4e3})};return(0,$.jsx)(KV,{spec:d,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:QV(t),children:[f&&m?.total?(0,$.jsx)(`button`,{type:`button`,className:`absolute left-0 flex size-6 items-center justify-center text-fg-subtle hover:text-fg`,"aria-label":v?o.delegatedTasksCollapse:o.delegatedTasksExpand,"aria-expanded":v,onClick:()=>b(e=>!e),children:(0,$.jsx)(gn,{className:Y(`size-3.5 transition-transform`,!v&&`-rotate-90`),"aria-hidden":!0})}):null,(0,$.jsxs)(y,{to:`/chat/${encodeURIComponent(e.key)}`,className:Y(`min-w-0 flex-1 self-stretch rounded-lg py-1 outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`flex min-w-0 items-center gap-2`,F?`pr-[4.75rem]`:`pr-12`),title:`${N} — ${T}`,"aria-label":`${N} — ${T}`,onClick:()=>n?.(),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),i(e)},children:[C?(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,title:w,children:(0,$.jsx)(Ta,{sourceChannel:e.sourceChannel,session:e,className:`size-3.5`})}):null,(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:N}),x?(0,$.jsx)(`span`,{className:`block truncate text-xs font-normal text-fg-muted`,children:T}):null]})]}),j?(0,$.jsxs)(`span`,{className:`pointer-events-none absolute right-2 top-1/2 z-10 flex size-2.5 -translate-y-1/2 items-center justify-center`,title:o.taskSessionAgentRunning,"aria-label":o.taskSessionAgentRunning,children:[(0,$.jsx)(`span`,{className:`absolute size-full animate-ping rounded-full bg-accent/70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`relative size-2 rounded-full bg-accent`,"aria-hidden":!0})]}):M?.unread?(0,$.jsx)(`span`,{className:Y(`pointer-events-none absolute right-2 top-1/2 z-10 size-2.5 -translate-y-1/2 rounded-full`,M.status===`failed`?`bg-red-500`:`bg-emerald-500`),title:M.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted,"aria-label":M.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted}):null,(0,$.jsxs)(`div`,{className:Y(`pointer-events-none absolute inset-y-0 z-10 flex items-center opacity-0 transition-opacity`,`group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100`,F?`right-7`:`right-1`,D&&`pointer-events-auto opacity-100`),children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 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 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:cursor-wait`),"aria-label":P?s.unpin:s.pin,title:P?s.unpin:s.pin,"aria-pressed":P,disabled:k,onClick:()=>void I(),children:k?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):P?(0,$.jsx)(Pa,{className:`size-4 rotate-45`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Na,{className:`size-4 rotate-45`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(ps,{open:D,onOpenChange:O,children:[(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 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 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),"aria-label":o.taskSessionMenuAria,title:o.taskSessionMenuAria,"aria-expanded":D,children:(0,$.jsx)(yr,{className:`size-4`,strokeWidth:2,"aria-hidden":!0})})}),(0,$.jsx)(ds,{children:(0,$.jsxs)(fs,{className:`z-50 w-[9.25rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>{O(!1),i(e)},children:[(0,$.jsx)(Aa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskRename]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>void L(),children:[(0,$.jsx)(Yn,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskCopyChatId]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:()=>{O(!1),a(e.key)},children:[(0,$.jsx)(ho,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskDeleteTask]})]})})]})]})]}),f&&v&&m?.items.map(e=>(0,$.jsx)(RV,{child:e,activeTaskId:g,onNavigate:n,sb:o},e.taskId))]})})});function iH(e){let t=(0,Q.c)(74),{project:n,onNavigate:r,onPinToggle:i,onRequestRename:a,onArchive:o,onRequestRemove:s,sb:c}=e,[l,u]=(0,Z.useState)(!1),d;t[0]!==n.effectiveWorkspaceRoot||t[1]!==n.workspaceRoot?(d=n.effectiveWorkspaceRoot?.trim()||n.workspaceRoot?.trim()||``,t[0]=n.effectiveWorkspaceRoot,t[1]=n.workspaceRoot,t[2]=d):d=t[2];let f=d,p=!!(f&&window.electronAPI?.shell?.openPath),m=!!n.pinnedAt,h;t[3]!==c.projectOpenInExplorerFailed||t[4]!==c.projectOpenInExplorerUnavailable||t[5]!==f?(h=async()=>{if(!f||!window.electronAPI?.shell?.openPath){ii(`warning`,c.projectOpenInExplorerUnavailable,void 0,{duration:3500}),u(!1);return}let e=await window.electronAPI.shell.openPath(f);u(!1),e.ok===!1&&ii(`warning`,e.error||c.projectOpenInExplorerFailed,void 0,{duration:4e3})},t[3]=c.projectOpenInExplorerFailed,t[4]=c.projectOpenInExplorerUnavailable,t[5]=f,t[6]=h):h=t[6];let g=h,_=l&&`opacity-100`,v;t[7]===_?v=t[8]:(v=Y(`relative z-10 flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,_,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[7]=_,t[8]=v);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(yr,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=b):b=t[9];let x;t[10]!==l||t[11]!==c.projectMenuAria||t[12]!==v?(x=(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v,"aria-label":c.projectMenuAria,title:c.projectMenuAria,"aria-expanded":l,children:b})}),t[10]=l,t[11]=c.projectMenuAria,t[12]=v,t[13]=x):x=t[13];let S=`/projects/${encodeURIComponent(n.id)}`,C;t[14]===r?C=t[15]:(C=()=>{u(!1),r?.()},t[14]=r,t[15]=C);let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(br,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]!==c.projectOpen||t[18]!==S||t[19]!==C?(T=(0,$.jsxs)(y,{to:S,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:C,children:[w,c.projectOpen]}),t[17]=c.projectOpen,t[18]=S,t[19]=C,t[20]=T):T=t[20];let E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>u(!1),t[21]=E):E=t[21];let O;t[22]===n.id?O=t[23]:(O=(0,$.jsx)(uu,{projectId:n.id,onStarted:E,className:`flex w-full rounded-md px-2 py-1.5 text-left text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`}),t[22]=n.id,t[23]=O);let k;t[24]!==i||t[25]!==n?(k=()=>{u(!1),i(n)},t[24]=i,t[25]=n,t[26]=k):k=t[26];let A;t[27]===m?A=t[28]:(A=m?(0,$.jsx)(Pa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Na,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=m,t[28]=A);let j=m?c.projectUnpin:c.projectPin,M;t[29]!==k||t[30]!==A||t[31]!==j?(M=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:k,children:[A,j]}),t[29]=k,t[30]=A,t[31]=j,t[32]=M):M=t[32];let N;t[33]===g?N=t[34]:(N=()=>void g(),t[33]=g,t[34]=N);let P=!p,F=p?void 0:c.projectOpenInExplorerUnavailable,I;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(Kr,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=I):I=t[35];let L;t[36]!==c.projectOpenInExplorer||t[37]!==N||t[38]!==P||t[39]!==F?(L=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:text-fg-subtle disabled:hover:bg-transparent`,onClick:N,disabled:P,title:F,children:[I,c.projectOpenInExplorer]}),t[36]=c.projectOpenInExplorer,t[37]=N,t[38]=P,t[39]=F,t[40]=L):L=t[40];let R;t[41]!==a||t[42]!==n?(R=()=>{u(!1),a(n)},t[41]=a,t[42]=n,t[43]=R):R=t[43];let z;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Aa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[44]=z):z=t[44];let B;t[45]!==c.projectRename||t[46]!==R?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:R,children:[z,c.projectRename]}),t[45]=c.projectRename,t[46]=R,t[47]=B):B=t[47];let V;t[48]!==o||t[49]!==n?(V=()=>{u(!1),o(n)},t[48]=o,t[49]=n,t[50]=V):V=t[50];let H;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(D,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[51]=H):H=t[51];let U;t[52]!==c.projectArchive||t[53]!==V?(U=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:V,children:[H,c.projectArchive]}),t[52]=c.projectArchive,t[53]=V,t[54]=U):U=t[54];let W;t[55]!==s||t[56]!==n?(W=()=>{u(!1),s(n)},t[55]=s,t[56]=n,t[57]=W):W=t[57];let ee;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ho,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[58]=ee):ee=t[58];let G;t[59]!==c.projectRemove||t[60]!==W?(G=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:W,children:[ee,c.projectRemove]}),t[59]=c.projectRemove,t[60]=W,t[61]=G):G=t[61];let K;t[62]!==T||t[63]!==O||t[64]!==M||t[65]!==L||t[66]!==B||t[67]!==U||t[68]!==G?(K=(0,$.jsx)(ds,{children:(0,$.jsxs)(fs,{className:`z-50 w-[12rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:aH,children:[T,O,M,L,B,U,G]})}),t[62]=T,t[63]=O,t[64]=M,t[65]=L,t[66]=B,t[67]=U,t[68]=G,t[69]=K):K=t[69];let q;return t[70]!==l||t[71]!==K||t[72]!==x?(q=(0,$.jsxs)(ps,{open:l,onOpenChange:u,children:[x,K]}),t[70]=l,t[71]=K,t[72]=x,t[73]=q):q=t[73],q}function aH(e){return e.preventDefault()}function oH(e){let t=(0,Q.c)(70),{group:n,isExpanded:r,isCollapsed:i,activeConversationId:a,onToggleExpanded:o,onToggleCollapsed:s,onCreateProjectChat:c,onToggleProjectPin:l,onRequestProjectRename:u,onArchiveProject:d,onRequestProjectRemove:f,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,excludedConversationIds:x,projectSort:S,onReorder:C}=e,w;t[0]!==x||t[1]!==n.sessions?(w=x?n.sessions.filter(e=>!x.has(e.key)):n.sessions,t[0]=x,t[1]=n.sessions,t[2]=w):w=t[2];let T=w,E;t[3]!==r||t[4]!==T?(E=r?T:T.slice(0,VV),t[3]=r,t[4]=T,t[5]=E):E=t[5];let D=E,O=T.length>VV,k=n.sessionHasMore||O,A=r&&!n.sessionHasMore&&O,j;t[6]===a?j=t[7]:(j=e=>e.key===a,t[6]=a,t[7]=j);let M=T.some(j),N=n.project.name,P=M?`text-fg`:`text-fg-muted`,F;t[8]===P?F=t[9]:(F=Y(`group flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-2 text-sm font-medium leading-5`,P),t[8]=P,t[9]=F);let I;t[10]!==n.project.id||t[11]!==s?(I=()=>s(n.project.id),t[10]=n.project.id,t[11]=s,t[12]=I):I=t[12];let L=!i,R;t[13]===i?R=t[14]:(R=i?(0,$.jsx)(qr,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Kr,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=i,t[14]=R);let z;t[15]===n.project.name?z=t[16]:(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.project.name}),t[15]=n.project.name,t[16]=z);let B;t[17]!==n.project.name||t[18]!==z||t[19]!==I||t[20]!==L||t[21]!==R?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 min-w-0 flex-1 items-center gap-1 text-left hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:I,title:n.project.name,"aria-expanded":L,children:[R,z]}),t[17]=n.project.name,t[18]=z,t[19]=I,t[20]=L,t[21]=R,t[22]=B):B=t[22];let V;t[23]!==n.project||t[24]!==d||t[25]!==p||t[26]!==f||t[27]!==u||t[28]!==l||t[29]!==_?(V=(0,$.jsx)(iH,{project:n.project,onNavigate:p,onPinToggle:l,onRequestRename:u,onArchive:d,onRequestRemove:f,sb:_}),t[23]=n.project,t[24]=d,t[25]=p,t[26]=f,t[27]=u,t[28]=l,t[29]=_,t[30]=V):V=t[30];let H;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[31]=H):H=t[31];let U;t[32]!==n.project||t[33]!==c?(U=()=>c(n.project),t[32]=n.project,t[33]=c,t[34]=U):U=t[34];let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(Ra,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=W):W=t[35];let ee;t[36]!==_.projectNewChat||t[37]!==U?(ee=(0,$.jsx)(`button`,{type:`button`,className:H,onClick:U,title:_.projectNewChat,"aria-label":_.projectNewChat,children:W}),t[36]=_.projectNewChat,t[37]=U,t[38]=ee):ee=t[38];let G;t[39]!==B||t[40]!==V||t[41]!==ee||t[42]!==F?(G=(0,$.jsxs)(`div`,{className:F,children:[B,V,ee]}),t[39]=B,t[40]=V,t[41]=ee,t[42]=F,t[43]=G):G=t[43];let K;t[44]!==a||t[45]!==k||t[46]!==y||t[47]!==b||t[48]!==n.project.id||t[49]!==n.sessionLoading||t[50]!==i||t[51]!==m||t[52]!==p||t[53]!==C||t[54]!==g||t[55]!==h||t[56]!==o||t[57]!==_||t[58]!==v||t[59]!==A||t[60]!==T||t[61]!==D?(K=i?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D.map(e=>(0,$.jsx)(rH,{session:e,isActive:a===e.key,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,sort:{containerId:`project:${n.project.id}`,itemId:e.key,itemIds:T.map(sH),onReorder:C}},e.key)),k?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:()=>o(n.project.id),disabled:n.sessionLoading,"aria-busy":n.sessionLoading||void 0,children:[n.sessionLoading?(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(gn,{className:Y(`size-3.5 transition-transform duration-150 ease-out`,A&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),A?_.projectShowLess:_.projectShowMore]}):null]}),t[44]=a,t[45]=k,t[46]=y,t[47]=b,t[48]=n.project.id,t[49]=n.sessionLoading,t[50]=i,t[51]=m,t[52]=p,t[53]=C,t[54]=g,t[55]=h,t[56]=o,t[57]=_,t[58]=v,t[59]=A,t[60]=T,t[61]=D,t[62]=K):K=t[62];let q;t[63]!==n.project.name||t[64]!==G||t[65]!==K?(q=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":N,children:[G,K]}),t[63]=n.project.name,t[64]=G,t[65]=K,t[66]=q):q=t[66];let te;return t[67]!==S||t[68]!==q?(te=(0,$.jsx)(KV,{spec:S,children:q}),t[67]=S,t[68]=q,t[69]=te):te=t[69],te}function sH(e){return e.key}function cH(e){let t=(0,Q.c)(49),{sessions:n,hasMore:r,loadingMore:i,isCollapsed:a,onToggleCollapsed:o,onCreateChat:s,onLoadMore:c,activeConversationId:l,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,excludedConversationIds:v,onReorder:y,sortable:b}=e,x=b===void 0||b,S;t[0]!==v||t[1]!==n?(S=v?n.filter(e=>!v.has(e.key)):n,t[0]=v,t[1]=n,t[2]=S):S=t[2];let C=S;if(C.length===0&&!r)return null;let w=m.inboxHeading,T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=Y(`flex min-w-0 flex-1 items-center gap-1 px-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,eH),t[3]=T):T=t[3];let E=!a,D=m.inboxHeading,O=a&&`-rotate-90`,k;t[4]===O?k=t[5]:(k=Y(`size-3.5 transition-transform duration-150 ease-out`,O),t[4]=O,t[5]=k);let A;t[6]===k?A=t[7]:(A=(0,$.jsx)(gn,{className:k,strokeWidth:1.75,"aria-hidden":!0}),t[6]=k,t[7]=A);let j;t[8]!==o||t[9]!==m.inboxHeading||t[10]!==E||t[11]!==A?(j=(0,$.jsxs)(`button`,{type:`button`,className:T,onClick:o,"aria-expanded":E,children:[D,A]}),t[8]=o,t[9]=m.inboxHeading,t[10]=E,t[11]=A,t[12]=j):j=t[12];let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Ra,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=N):N=t[14];let P;t[15]!==_||t[16]!==s?(P=(0,$.jsx)(`button`,{type:`button`,className:M,onClick:s,title:_,"aria-label":_,children:N}),t[15]=_,t[16]=s,t[17]=P):P=t[17];let F;t[18]!==j||t[19]!==P?(F=(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center pb-1`,children:[j,P]}),t[18]=j,t[19]=P,t[20]=F):F=t[20];let I=a&&`hidden`,L;t[21]===I?L=t[22]:(L=Y(`flex flex-col gap-0.5`,I),t[21]=I,t[22]=L);let R;t[23]!==l||t[24]!==g||t[25]!==_||t[26]!==d||t[27]!==u||t[28]!==y||t[29]!==p||t[30]!==f||t[31]!==m||t[32]!==h||t[33]!==x||t[34]!==C?(R=C.map(e=>(0,$.jsx)(rH,{session:e,isActive:l===e.key,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,sort:x?{containerId:`inbox`,itemId:e.key,itemIds:C.map(lH),onReorder:y}:void 0},e.key)),t[23]=l,t[24]=g,t[25]=_,t[26]=d,t[27]=u,t[28]=y,t[29]=p,t[30]=f,t[31]=m,t[32]=h,t[33]=x,t[34]=C,t[35]=R):R=t[35];let z;t[36]!==r||t[37]!==i||t[38]!==c||t[39]!==m.projectShowMore?(z=r?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:c,disabled:i,"aria-busy":i||void 0,children:[i?(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(gn,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),m.projectShowMore]}):null,t[36]=r,t[37]=i,t[38]=c,t[39]=m.projectShowMore,t[40]=z):z=t[40];let B;t[41]!==L||t[42]!==R||t[43]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[41]=L,t[42]=R,t[43]=z,t[44]=B):B=t[44];let V;return t[45]!==m.inboxHeading||t[46]!==F||t[47]!==B?(V=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":w,children:[F,B]}),t[45]=m.inboxHeading,t[46]=F,t[47]=B,t[48]=V):V=t[48],V}function lH(e){return e.key}function uH(e){let t=(0,Q.c)(21),{sessions:n,activeConversationId:r,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,onReorder:f}=e;if(n.length===0)return null;let p=l.pinnedSessions,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`px-2 pb-1`,$V),t[0]=m):m=t[0];let h;t[1]===l.pinnedSessions?h=t[2]:(h=(0,$.jsx)(`h2`,{className:m,children:l.pinnedSessions}),t[1]=l.pinnedSessions,t[2]=h);let g;t[3]!==r||t[4]!==u||t[5]!==d||t[6]!==a||t[7]!==i||t[8]!==f||t[9]!==s||t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==n?(g=n.map(e=>(0,$.jsx)(rH,{session:e,isActive:r===e.key,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,sort:{containerId:`pinned`,itemId:e.key,itemIds:n.map(dH),onReorder:f}},e.key)),t[3]=r,t[4]=u,t[5]=d,t[6]=a,t[7]=i,t[8]=f,t[9]=s,t[10]=o,t[11]=c,t[12]=l,t[13]=n,t[14]=g):g=t[14];let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:g}),t[15]=g,t[16]=_);let v;return t[17]!==l.pinnedSessions||t[18]!==h||t[19]!==_?(v=(0,$.jsxs)(`section`,{className:`mb-3 flex flex-col gap-0.5`,"aria-label":p,children:[h,_]}),t[17]=l.pinnedSessions,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function dH(e){return e.key}function fH(e){let t=(0,Q.c)(4),{onNavigate:n,scrollHeader:r}=e,i=Ro(pH),a;return t[0]!==i||t[1]!==n||t[2]!==r?(a=(0,$.jsx)(mH,{gateway:i,onNavigate:n,scrollHeader:r},i),t[0]=i,t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function pH(e){return e.baseUrl}function mH({onNavigate:e,gateway:t,scrollHeader:n}){let r=zo(e=>e.language),i=Do(r),a=i.sidebar,o=i.sessions,s=i.projectsPage,c=i.chat.workingDirectory,l=Ro(e=>e.conversationId),u=jV(t,l),d=a.sessionFilters,f=(0,Z.useRef)(null),m=(0,Z.useRef)(0);(0,Z.useLayoutEffect)(()=>{f.current&&(f.current.scrollTop=u.active?0:m.current)},[u.active]);let h=Ro(e=>e.openTokenDialog),{data:g,mutate:_}=qo(l?[`gateway-chat-agents`,l]:null,du,{revalidateOnFocus:!1}),v=g?.defaultId??`main`;(0,Z.useEffect)(()=>{let e=()=>void _();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[_]);let{pathname:y}=p(),x=b(),S=JV(y),C=(0,Z.useMemo)(()=>Date.now()-HV*24*60*60*1e3,[]),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(null),[W,ee]=(0,Z.useState)(!1),[G,K]=(0,Z.useState)(!0),[q,te]=(0,Z.useState)(()=>S),[ne,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(()=>new Set),[ce,le]=(0,Z.useState)(()=>new Set),[ue,de]=(0,Z.useState)({}),[fe,pe]=(0,Z.useState)({}),[me,he]=(0,Z.useState)(()=>new Set),[ge,_e]=(0,Z.useState)([]),[ve,J]=(0,Z.useState)(null),[ye,be]=(0,Z.useState)(!1),[xe,Se]=(0,Z.useState)({}),Ce=(0,Z.useRef)(new Set),we=fu({initialPath:B,onPicked:V}),{data:Te,size:Ee,setSize:De,isValidating:Oe,mutate:ke}=Yo((e,t)=>!l||t&&!t.projects.hasMore?null:[`sidebar-chat-list`,l,q??``,e],async([,,e,t])=>Ws({projectLimit:BV,projectOffset:t*BV,sessionPreviewLimit:VV,inboxLimit:t===0?zV:1,inboxOffset:0,staleDays:HV,includeConversationId:e||void 0}),{keepPreviousData:!0,revalidateOnFocus:!1}),Ae=(0,Z.useMemo)(()=>{let e=Te??[],t=[],n=new Set;for(let r of e)for(let e of r.projects.items){if(n.has(e.project.id))continue;n.add(e.project.id);let r=ue[e.project.id],i=r?.sessions??e.sessions;t.push({project:e.project,sessions:i,sessionTotal:r?.sessionTotal??e.sessionTotal,sessionHasMore:r?.hasMore??e.sessionHasMore,sessionLoading:me.has(e.project.id)})}return GV(t.map(e=>({...e,sessions:GV(e.sessions,xe[`project:${e.project.id}`],e=>e.key)})),xe.projects,e=>e.project.id)},[Te,me,xe,ue]),je=(0,Z.useMemo)(()=>{let e={};for(let t of Te??[])Object.assign(e,t.childrenByConversationId);return{...e,...fe}},[Te,fe]),Me=Te?.[0]?.inbox,Ne=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of[...Me?.items??[],...ge])t.has(n.key)||(t.add(n.key),e.push(n));return e.sort((e,t)=>ZV(t)-ZV(e)),GV(e,xe.inbox??Te?.[0]?.layouts.inbox?.itemIds,e=>e.key)},[Te,Me?.items,ge,xe.inbox]),Pe=ve??Me?.hasMore??!1,Fe=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of Ae)for(let r of n.sessions)t.has(r.key)||(t.add(r.key),e.push(r));for(let n of Ne)t.has(n.key)||(t.add(n.key),e.push(n));return e},[Ne,Ae]),Ie=(0,Z.useMemo)(()=>new Set(Fe.map(e=>e.key)),[Fe]),Le=Ae.length>0||Ne.length>0,Re=(0,Z.useMemo)(()=>GV(Te?.[0]?.pinned??[],xe.pinned,e=>e.key),[Te,xe.pinned]),ze=(0,Z.useMemo)(()=>new Set(Re.map(e=>e.key)),[Re]),Be=!!(Te&&Ee>Te.length),Ve=(Te?.[Te.length-1])?.projects.hasMore??!1,He=!!(l&&!Te&&Oe),Ue=(0,Z.useCallback)(()=>{de({}),_e([]),J(null),pe({}),ke()},[ke]),We=(0,Z.useCallback)((e,t)=>{if(Ce.current.has(e))return;let n=Te?.[0]?.layouts[e]?.revision??0;Se(n=>({...n,[e]:t})),Ce.current.add(e),(async()=>{try{await Us({containerId:e,itemIds:t,expectedRevision:n}),await ke()}catch{ii(`warning`,r===`zh`?`未能保存侧栏顺序,已恢复原位置`:`Could not save sidebar order; the previous order was restored`,void 0,{duration:3500})}finally{Ce.current.delete(e),Se(t=>{let n={...t};return delete n[e],n})}})()},[Te,r,ke]),Ge=(0,Z.useCallback)(e=>{let t=e.currentTarget;if(u.active||(m.current=t.scrollTop,!Ve||Be))return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t;r-n-i>100||De(e=>e+1)},[u.active,Ve,Be,De]);(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{Ue()},t=e=>{if(!e.detail?.key){Ue();return}Ue()},n=e=>{FV(e.detail,Ie)&&Ue()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-created`,e),window.addEventListener(`project-updated`,e),window.addEventListener(`task-updated`,e),window.addEventListener(`session-transcript-updated`,n),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-created`,e),window.removeEventListener(`project-updated`,e),window.removeEventListener(`task-updated`,e),window.removeEventListener(`session-transcript-updated`,n)}},[l,Ue,Ie]),(0,Z.useEffect)(()=>{!l||!S||!Te||Fe.some(e=>e.key===S)||te(e=>e===S?e:S)},[S,Te,Fe,l]);let Ke=(0,Z.useCallback)(e=>{T(e.key),D(qV(e,i.chat.newSession))},[i.chat.newSession]),qe=async()=>{if(!w)return;let e=E.trim();if(e)try{await Gs(w,e),T(null),u.refresh(),Ue()}catch{}},Je=async e=>{try{await Ks(e),u.refresh(),S===e&&x(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),Ue()}catch{}},Ye=(0,Z.useCallback)(e=>{j(e.id),N(e.name.trim())},[]),Xe=async()=>{if(!A||!at)return;let e=M.trim();if(e)try{await Bs(A,e,at.version),j(null),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:A}}))}catch{}},Ze=(0,Z.useCallback)(async e=>{try{await Vs(e.id,e.version),y===`/projects/${encodeURIComponent(e.id)}`&&x(`/projects`),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[x,y,Ue]),Qe=(0,Z.useCallback)(async e=>{try{e.pinnedAt?await Fs(e.id,e.version):await Ls(e.id,e.version),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[Ue]),$e=async e=>{let t=e.id;try{await Rs(t,e.version),y===`/projects/${encodeURIComponent(t)}`&&x(`/projects`),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:t}}))}catch{}},et=(0,Z.useCallback)(e=>{let t=Ae.find(t=>t.project.id===e);if(t){if(ce.has(e)&&!t.sessionHasMore){le(t=>{let n=new Set(t);return n.delete(e),n});return}le(t=>{let n=new Set(t);return n.add(e),n}),!(!t.sessionHasMore||me.has(e))&&(he(t=>new Set(t).add(e)),(async()=>{try{let n=await Js({projectId:e,limit:5e3,offset:0,updatedAfter:C,includePinned:!0,includeConversationId:S,rootConversationsOnly:!0});pe(e=>({...e,...n.childrenByConversationId})),de(r=>{let i=r[e]?.sessions??t.sessions,a=new Set(i.map(e=>e.key)),o=[...i];for(let e of n.items)a.has(e.key)||(a.add(e.key),o.push(e));let s=GV(o,xe[`project:${e}`]??Te?.[0]?.layouts[`project:${e}`]?.itemIds,e=>e.key);return{...r,[e]:{sessions:s,sessionTotal:n.total,hasMore:!1}}})}finally{he(t=>{let n=new Set(t);return n.delete(e),n})}})())}},[S,Te,ce,me,xe,Ae,C]),tt=(0,Z.useCallback)(e=>{se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),nt=(0,Z.useCallback)(()=>{!Pe||ye||(be(!0),(async()=>{try{let e=await Js({unassigned:!0,limit:5e3,offset:0,updatedAfter:C,includePinned:!0,includeConversationId:S,rootConversationsOnly:!0});pe(t=>({...t,...e.childrenByConversationId})),_e(t=>{let n=new Set([...Me?.items??[],...t].map(e=>e.key)),r=[...t];for(let t of e.items)n.has(t.key)||(n.add(t.key),r.push(t));return GV(r,xe.inbox??Te?.[0]?.layouts.inbox?.itemIds,e=>e.key)}),J(!1)}finally{be(!1)}})())},[S,Te,Me?.items,Pe,ye,xe.inbox,C]),rt=(0,Z.useCallback)(t=>{x(kc(t.id),{state:{forceNewChat:!0,agentId:t.defaultAgentId??v}}),e?.()},[v,x,e]),it=(0,Z.useCallback)(async e=>{e.preventDefault();let t=R.trim(),n=B.trim();if(!(!t||!n||W)){ee(!0),U(null);try{let e=await zs({name:t,workspaceRoot:n,autoUnderstand:G});z(``),V(``),K(!0),L(!1),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){U(e instanceof Error?e.message:String(e))}finally{ee(!1)}}},[R,B,W,Ue,G]),at=A?Ae.find(e=>e.project.id===A)?.project:void 0,ot=P?Ae.find(e=>e.project.id===P)?.project:void 0;return l?(0,$.jsx)(IV,{value:u.filters.details,children:(0,$.jsx)(LV,{value:je,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{ref:f,className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,onScroll:Ge,children:[n,(0,$.jsx)(`div`,{hidden:u.active||He,className:`px-2`,children:(0,$.jsx)(uH,{sessions:Re,activeConversationId:S,onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,onReorder:We})}),(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center gap-1.5 px-2 pb-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex shrink-0 items-center gap-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,eH),onClick:()=>re(e=>!e),"aria-expanded":!ne,children:[a.projectsHeading,(0,$.jsx)(gn,{className:Y(`size-3.5 transition-transform duration-150 ease-out`,ne&&`-rotate-90`),strokeWidth:1.75,"aria-hidden":!0})]}),(0,$.jsx)(DV,{filters:u.filters,onChange:u.updateFilters,search:u.search,onSearch:u.setSearch,labels:d,gateway:t,agents:g?.items??[]}),(0,$.jsx)(`button`,{type:`button`,className:Y(`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-subtle opacity-0 transition-[color,background-color,opacity] hover:bg-surface-hover hover:text-fg focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,I&&`opacity-100`),onClick:()=>L(!0),"aria-label":s.createTitle,title:s.createTitle,children:(0,$.jsx)(Ra,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0})})]})}),u.active?(0,$.jsxs)(`div`,{className:`px-2 py-2`,children:[u.pendingUpdate?(0,$.jsx)(`button`,{type:`button`,className:`mb-2 w-full rounded-md px-2 py-1 text-xs text-accent-fg hover:bg-surface-hover`,onClick:u.refresh,children:d.refresh}):null,u.error?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:d.error}),(0,$.jsx)(X,{variant:`secondary`,onClick:u.refresh,children:d.retry})]}):u.loading?(0,$.jsx)(nH,{}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs text-fg-muted`,"aria-live":`polite`,children:d.results.replace(`{{count}}`,String(u.total))}),u.items.length?null:(0,$.jsx)(`p`,{className:`px-2 py-4 text-xs text-fg-muted`,children:d.empty}),(0,$.jsx)(IV,{value:!0,children:u.items.map(t=>(0,$.jsx)(rH,{session:t,isActive:t.key===S,showTaskChildren:!1,contextLabel:t.projectId?u.projects?.find(e=>e.id===t.projectId)?.name??Ae.find(e=>e.project.id===t.projectId)?.project.name??t.projectId:d.unassigned,onNavigate:e,mutate:()=>{u.refresh(),Ue()},onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession},t.key))}),u.loadingMore?(0,$.jsx)(tH,{}):u.hasMore?(0,$.jsx)(`button`,{type:`button`,className:`w-full rounded-md py-2 text-xs text-fg-muted hover:bg-surface-hover`,onClick:u.loadMore,children:d.more}):null]})]}):null,(0,$.jsxs)(`div`,{hidden:u.active,children:[He?(0,$.jsx)(nH,{}):Le?(0,$.jsxs)(`div`,{className:`flex flex-col px-2`,children:[Ae.length>0?(0,$.jsx)(`div`,{className:`pb-1`,children:ne?null:Ae.map(t=>(0,$.jsx)(oH,{group:t,isExpanded:ce.has(t.project.id),isCollapsed:oe.has(t.project.id),activeConversationId:S,onToggleExpanded:et,onToggleCollapsed:tt,onCreateProjectChat:e=>void rt(e),onToggleProjectPin:e=>void Qe(e),onRequestProjectRename:Ye,onArchiveProject:e=>void Ze(e),onRequestProjectRemove:e=>F(e.id),onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:ze,projectSort:{containerId:`projects`,itemId:t.project.id,itemIds:Ae.map(e=>e.project.id),onReorder:We},onReorder:We},t.project.id))}):null,(0,$.jsx)(cH,{sessions:Ne.filter(e=>ba(e).source!==`system`),hasMore:Pe,loadingMore:ye,isCollapsed:ie,onToggleCollapsed:()=>ae(e=>!e),onCreateChat:()=>{x(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),e?.()},onLoadMore:nt,activeConversationId:S,onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:ze,onReorder:We}),Ne.some(e=>ba(e).source===`system`)?(0,$.jsxs)(`details`,{className:`mt-3`,open:Ne.some(e=>e.key===S&&ba(e).source===`system`),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-2 py-2 text-xs text-fg-muted`,children:r===`zh`?`系统活动`:`System activity`}),(0,$.jsx)(cH,{sessions:Ne.filter(e=>ba(e).source===`system`),hasMore:!1,loadingMore:ye,isCollapsed:!1,onToggleCollapsed:()=>void 0,onCreateChat:()=>{x(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),e?.()},onLoadMore:nt,activeConversationId:S,onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:ze,onReorder:We,sortable:!1})]}):null]}):(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-3 text-xs leading-relaxed text-fg-muted`,children:a.taskListEmpty})}),Be?(0,$.jsx)(`div`,{className:`flex justify-center py-2`,"aria-busy":!0,children:(0,$.jsx)(Hi,{className:`size-4 animate-spin text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})}):null]})]}),(0,$.jsx)(us,{open:I,onOpenChange:e=>{W||(L(e),e||U(null))},children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(30rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:s.createTitle}),(0,$.jsx)(as,{className:`mt-1 text-sm text-fg-muted`,children:s.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:it,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[s.projectName,(0,$.jsx)(`input`,{autoFocus:!0,className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:R,onChange:e=>z(e.target.value),maxLength:160})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:s.workspaceRoot}),(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:we.pick,disabled:W||we.picking,children:[we.picking?(0,$.jsx)(Hi,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,$.jsx)(Kr,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:B?c.chooseFolder:c.selectWorkingDirectory}),(0,$.jsx)(`span`,{className:Y(`mt-0.5 block truncate font-mono text-xs font-normal`,B?`text-fg-muted`:`text-fg-subtle`),title:B||void 0,children:B||s.workspaceSelectionPlaceholder})]})]}),(0,$.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:s.workspaceSelectionHint})]}),(0,$.jsx)(lu,{checked:G,onChange:K,disabled:W}),H?(0,$.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:H}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(os,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:W,children:s.cancel})}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:W||!R.trim()||!B.trim(),children:W?s.home.creating:s.create})]})]})]})]})}),we.hasNativePicker?null:(0,$.jsx)(Sn,{open:we.modalOpen,onOpenChange:we.setModalOpen,initialAbsolutePath:B||void 0,onConfirm:we.confirmPick,wd:c}),(0,$.jsx)(us,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:a.taskRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-rename-input`,children:a.taskRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-rename-input`,type:`text`,value:E,onChange:e=>D(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,ul,`dark:border-edge`),placeholder:i.chat.newSession,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),qe())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>T(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void qe(),disabled:!E.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(us,{open:O!==null,onOpenChange:e=>!e&&k(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:o.deleteSessionTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:O?YV(o.deleteSessionMessage,{name:Fe.find(e=>e.key===O)?.name?.trim()||i.chat.newSession}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>k(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{O&&Je(O),k(null)},children:o.delete})]})]})]})}),(0,$.jsx)(us,{open:A!==null,onOpenChange:e=>!e&&j(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:a.projectRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-project-rename-input`,children:a.projectRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-project-rename-input`,type:`text`,value:M,onChange:e=>N(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,ul,`dark:border-edge`),placeholder:at?.name??``,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Xe())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>j(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void Xe(),disabled:!M.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(us,{open:P!==null,onOpenChange:e=>!e&&F(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:a.projectRemoveTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:ot?YV(a.projectRemoveMessage,{name:ot.name}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>F(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{ot&&$e(ot),F(null)},children:a.projectRemove})]})]})]})})]})})}):(0,$.jsxs)(`div`,{className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,children:[n,(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 px-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.taskListNeedToken}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`mt-3 h-8 w-full text-xs font-medium`,onClick:()=>{h(),e?.()},children:a.taskListAddToken})]})})]})}var hH=42,gH=1,_H=4,vH=3,yH=`xopc-web-sidebar-visible-app-count-v2`;function bH(e){return Math.min(_H,Math.max(gH,e))}function xH(){try{let e=Number.parseInt(globalThis.localStorage?.getItem(yH)??``,10);return Number.isFinite(e)?bH(e):vH}catch{return vH}}function SH({onNavigate:e,collapsed:t=!1}){let n=Do(zo(e=>e.language)),[r,i]=(0,Z.useState)(xH),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{try{globalThis.localStorage?.setItem(yH,String(r))}catch{}},[r]);function o(e){e.preventDefault(),a.current={clientY:e.clientY,visibleCount:r},e.currentTarget.setPointerCapture(e.pointerId)}function s(e){let t=a.current;if(!t)return;let n=Math.round((e.clientY-t.clientY)/hH);i(bH(t.visibleCount+n))}function c(e){a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}function l(e){e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),i(e=>bH(e+1))):e.key===`ArrowUp`||e.key===`ArrowLeft`?(e.preventDefault(),i(e=>bH(e-1))):e.key===`Home`?(e.preventDefault(),i(gH)):e.key===`End`&&(e.preventDefault(),i(_H))}return(0,$.jsxs)(`div`,{className:`app-sidebar-content flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:Y(`flex min-h-0 flex-1 flex-col overflow-hidden`,t&&`hidden`),"aria-hidden":t?!0:void 0,children:(0,$.jsx)(fH,{onNavigate:e,scrollHeader:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`app-sidebar-sticky-surface sticky top-0 z-20 px-4 pt-1.5 pb-0.5`,children:(0,$.jsxs)(y,{to:`/chat/new`,state:{forceNewChat:!0},className:Y(`flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-sm font-medium leading-6 transition-colors duration-200 ease-out md:py-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`text-fg-muted hover:bg-surface-hover hover:text-fg`),title:n.sidebar.newTask,onClick:()=>e?.(),children:[(0,$.jsx)(Ra,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:n.sidebar.newTask})]})}),(0,$.jsx)(`nav`,{className:`px-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(aV,{onNavigate:e,visibleLimit:r})})}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":n.sidebar.resizeApps,"aria-valuemin":gH,"aria-valuemax":_H,"aria-valuenow":r,tabIndex:0,className:`group flex h-3 touch-none cursor-row-resize items-center px-4 focus-visible:outline-none`,title:n.sidebar.resizeApps,onPointerDown:o,onPointerMove:s,onPointerUp:c,onPointerCancel:c,onKeyDown:l,children:(0,$.jsx)(`span`,{className:`h-px w-full bg-transparent transition-colors group-hover:bg-edge group-focus-visible:bg-accent`})}),(0,$.jsx)(`div`,{className:`h-2`,"aria-hidden":!0})]})})}),t?(0,$.jsx)(`nav`,{className:`min-h-0 flex-1 overflow-y-auto px-1.5 pb-2 pt-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(aV,{collapsed:!0,onNavigate:e,visibleLimit:vH})})}):null,(0,$.jsx)(QB,{collapsed:t,onNavigate:e})]})}var CH=`(min-width: 768px)`,wH=(0,Z.memo)(function(){let e=(0,Q.c)(42),t=zo(TH),n;e[0]===t?n=e[1]:(n=Do(t),e[0]=t,e[1]=n);let r=n,i=le(EH),a=le(DH),o=le(OH),s=ge(kH),c=ge(AH),[l,u]=(0,Z.useState)(!1),d=ve({runtime:fe(),sidebarCollapsed:i,mobileNavOpen:s}),f;e[2]!==o||e[3]!==i?(f=e=>{if(i)return;e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),u(!0);let r=e.clientX,a=le.getState().expandedWidthPx,s=e.pointerId,c=0,l=a,d=a,f=()=>{c=0,d=l,n?.style.setProperty(`--sidebar-expanded-px`,`${d}px`)},p=e=>{l=oe(a+(e.clientX-r)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(s)}catch{}u(!1),o(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},e[2]=o,e[3]=i,e[4]=f):f=e[4];let p=f,m,h;e[5]===c?(m=e[6],h=e[7]):(m=()=>{let e=e=>{e.key===`Escape`&&c(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[c],e[5]=c,e[6]=m,e[7]=h),(0,Z.useEffect)(m,h);let g,_;e[8]===c?(g=e[9],_=e[10]):(g=()=>{let e=window.matchMedia(CH),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},_=[c],e[8]=c,e[9]=g,e[10]=_),(0,Z.useEffect)(g,_);let v,y;e[11]===s?(v=e[12],y=e[13]):(v=()=>{if(!s||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},y=[s],e[11]=s,e[12]=v,e[13]=y),(0,Z.useEffect)(v,y);let b;e[14]!==r||e[15]!==s||e[16]!==c?(b=s?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":r.closeMenu,onClick:()=>c(!1)}):null,e[14]=r,e[15]=s,e[16]=c,e[17]=b):b=e[17];let x=l&&`sidebar-width-resizing`,S=s?`max-md:translate-x-0`:`max-md:-translate-x-full`,C=i?`md:w-0 md:overflow-hidden md:border-0`:`app-sidebar-expanded-width`,w;e[18]!==x||e[19]!==S||e[20]!==C?(w=Y(`app-sidebar-push app-chrome-sidebar flex min-h-0 shrink-0 flex-col overflow-hidden bg-transparent`,x,`max-md:fixed max-md:left-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:w-[min(16rem,85vw)]`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,S,`md:relative md:h-full md:translate-x-0`,C),e[18]=x,e[19]=S,e[20]=C,e[21]=w):w=e[21];let T=i&&!s?!0:void 0,E=i&&!s?!0:void 0,D;e[22]!==a||e[23]!==i?(D=i?void 0:{"--sidebar-expanded-px":`${a}px`},e[22]=a,e[23]=i,e[24]=D):D=e[24];let O=d.sidebarChromeVisible?(0,$.jsxs)(`div`,{className:Y(`sidebar-chrome-row flex min-w-0`,cl,d.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,d.sidebarLeadingInsetClass,i?`justify-center gap-1 px-1.5 max-md:flex`:Y(`justify-start gap-1`,d.sidebarLeadingInsetClass?`sidebar-chrome-row-darwin pr-3`:`px-3`),i&&`md:hidden`),children:[s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-8 shrink-0 rounded-xl p-0 md:hidden`,sl),"aria-label":r.closeMenu,title:r.closeMenu,onClick:()=>c(!1),children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,d.sidebarQuickActionsVisible&&!i?(0,$.jsx)(qz,{sidebarToggleVariant:`sidebar`,className:`overflow-hidden`}):null]}):null,k;e[25]===c?k=e[26]:(k=(0,$.jsx)(SH,{collapsed:!1,onNavigate:()=>c(!1)}),e[25]=c,e[26]=k);let A;e[27]!==r||e[28]!==p||e[29]!==i?(A=i?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r.sidebar.resizeHandleAria,onPointerDown:p,className:Y(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`touch-none select-none`,sl)}),e[27]=r,e[28]=p,e[29]=i,e[30]=A):A=e[30];let j;e[31]!==w||e[32]!==T||e[33]!==E||e[34]!==D||e[35]!==O||e[36]!==k||e[37]!==A?(j=(0,$.jsxs)(`aside`,{id:`app-sidebar`,className:w,"aria-hidden":T,"data-collapsed":E,style:D,children:[O,k,A]}),e[31]=w,e[32]=T,e[33]=E,e[34]=D,e[35]=O,e[36]=k,e[37]=A,e[38]=j):j=e[38];let M;return e[39]!==j||e[40]!==b?(M=(0,$.jsxs)($.Fragment,{children:[b,j]}),e[39]=j,e[40]=b,e[41]=M):M=e[41],M});function TH(e){return e.language}function EH(e){return e.collapsed}function DH(e){return e.expandedWidthPx}function OH(e){return e.setExpandedWidthPx}function kH(e){return e.mobileNavOpen}function AH(e){return e.setMobileNavOpen}function jH(e){if(typeof e!=`string`||e.length>8192)throw Error(`Invalid browser URL`);let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password)throw Error(`Use an HTTP or HTTPS address without embedded credentials`);return t.href}function MH(e,t){let n=e.trim();if(!n)return null;if(/^https?:\/\//i.test(n))return jH(n);if(/^(localhost|127(?:\.\d+){3}|\[::1\])(?::\d+)?(?:[/?#]|$)/i.test(n))return jH(`http://${n}`);if(!/\s/.test(n)&&/^(?:[\w-]+\.)+[\w-]+(?::\d+)?(?:[/?#]|$)/i.test(n))return jH(`https://${n}`);if(/^[a-z][a-z\d+.-]*:/i.test(n))throw Error(`Only HTTP and HTTPS addresses are supported`);return t?{google:`https://www.google.com/search?q=`,bing:`https://www.bing.com/search?q=`,duckduckgo:`https://duckduckgo.com/?q=`}[t]+encodeURIComponent(n):null}var NH=Vo(e=>({tabs:{},update:t=>e(e=>({tabs:{...e.tabs,[t.workspaceTabId]:t}}))}));async function PH(e){let t=NH.getState().tabs[e];return t&&window.electronAPI?.browser&&!await window.electronAPI.browser.close(t.id)?!1:(NH.setState(t=>({tabs:Object.fromEntries(Object.entries(t.tabs).filter(([t])=>t!==e))})),!0)}Ro.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||t.conversationId&&e.conversationId!==t.conversationId)&&(NH.setState({tabs:{}}),window.electronAPI?.browser?.release().catch(()=>{}))});function FH(e,t,n){let r=(0,Q.c)(5),i,a;r[0]!==t||r[1]!==e||r[2]!==n?(i=()=>{let r=window.electronAPI?.browser,i=e.current;if(!r||!t||!i)return;let a=0,o=``,s=!1,c=()=>{if(a=0,s)return;let e=[...document.querySelectorAll(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], [data-browser-occluder]`)].some(BH),l=[i.closest(`[data-right-workspace]`),i.closest(`[role="tabpanel"]`)].filter(Boolean).some(RH),u=i.getBoundingClientRect(),d=n&&!e&&!l&&i.getClientRects().length>0&&document.visibilityState===`visible`?{x:u.x,y:u.y,width:u.width,height:u.height}:null,f=JSON.stringify(d);f!==o&&(o=f,r.present(t,d).catch(LH)),l&&(a=requestAnimationFrame(c))},l=()=>{a||=requestAnimationFrame(c)},u=new ResizeObserver(l);u.observe(i);let d=new MutationObserver(l);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-hidden`,`data-state`]});let f=()=>{o=``,l()};return window.addEventListener(`focus`,f),window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0),document.addEventListener(`visibilitychange`,l),l(),()=>{s=!0,cancelAnimationFrame(a),u.disconnect(),d.disconnect(),window.removeEventListener(`focus`,f),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),document.removeEventListener(`visibilitychange`,l),r.present(t,null).catch(IH)}},a=[t,e,n],r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,Z.useLayoutEffect)(i,a)}function IH(){}function LH(){}function RH(e){return e.getAnimations().some(zH)}function zH(e){return e.playState===`running`}function BH(e){return e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`}function VH(e){let t=(0,Q.c)(94),{tab:n,scope:r,active:i}=e,a=(0,Z.useContext)(ai),o=zo(UH)===`zh`,s=Ro(HH),c;t[0]===n.id?c=t[1]:(c=e=>e.tabs[n.id],t[0]=n.id,t[1]=c);let l=NH(c),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(n.initialUrl??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(!1),S=window.electronAPI?.browser,C,w;t[2]!==s||t[3]!==r||t[4]!==n.id||t[5]!==n.initialUrl?(C=()=>{if(!S||!s)return;let e=!1;return S.ensure({workspaceTabId:n.id,scope:r,identity:s}).then(async t=>{if(e){Object.values(ns.getState().panes).some(e=>e.tabs.some(e=>e.id===n.id))||await S.close(t.id);return}NH.getState().update(t),!t.url&&n.initialUrl&&await S.navigate(t.id,n.initialUrl)}).catch(t=>{e||_(String(t.message??t))}),()=>{e=!0}},w=[S,s,r,n.id,n.initialUrl],t[2]=s,t[3]=r,t[4]=n.id,t[5]=n.initialUrl,t[6]=C,t[7]=w):(C=t[6],w=t[7]),(0,Z.useEffect)(C,w);let T;t[8]!==m||t[9]!==l?(T=()=>{!m&&l?.url&&p(l.url)},t[8]=m,t[9]=l,t[10]=T):T=t[10];let E=l?.url,D;t[11]!==m||t[12]!==E?(D=[m,E],t[11]=m,t[12]=E,t[13]=D):D=t[13],(0,Z.useEffect)(T,D),FH(u,l?.id,i&&!!l?.url&&!l?.error&&!l?.crashed&&!b);let O,k;t[14]!==i||t[15]!==n.id?(O=()=>{if(!i)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),d.current?.focus(),d.current?.select())},t=e=>{e.detail===n.id&&(d.current?.focus(),d.current?.select())};return window.addEventListener(`browser-focus-address`,t),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`browser-focus-address`,t)}},k=[i,n.id],t[14]=i,t[15]=n.id,t[16]=O,t[17]=k):(O=t[16],k=t[17]),(0,Z.useEffect)(O,k);let A;t[18]!==f||t[19]!==v||t[20]!==l?(A=async function(e){let t=e===void 0?v:e;if(!(!S||!l))try{let e=MH(f,t);if(!e){x(!!f.trim());return}x(!1),_(``),h(!1),await S.navigate(l.id,e)}catch(e){let t=e;_(t instanceof Error?t.message:String(t))}},t[18]=f,t[19]=v,t[20]=l,t[21]=A):A=t[21];let j=A,M;t[22]===l?M=t[23]:(M=function(e){!S||!l||(_(``),S.command(l.id,e).catch(e=>_(e instanceof Error?e.message:String(e))))},t[22]=l,t[23]=M);let N=M;if(!i){let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{ref:u,hidden:!0}),t[24]=e):e=t[24],e}let P;t[25]===j?P=t[26]:(P=e=>{e.preventDefault(),j()},t[25]=j,t[26]=P);let F=o?`网页后退`:`Browser back`,I=!l?.canGoBack,L;t[27]===N?L=t[28]:(L=()=>N(`back`),t[27]=N,t[28]=L);let R;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(_t,{className:`size-4`}),t[29]=R):R=t[29];let z;t[30]!==F||t[31]!==I||t[32]!==L?(z=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":F,disabled:I,onClick:L,children:R}),t[30]=F,t[31]=I,t[32]=L,t[33]=z):z=t[33];let B=o?`网页前进`:`Browser forward`,V=!l?.canGoForward,H;t[34]===N?H=t[35]:(H=()=>N(`forward`),t[34]=N,t[35]=H);let U;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(vt,{className:`size-4`}),t[36]=U):U=t[36];let W;t[37]!==B||t[38]!==V||t[39]!==H?(W=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":B,disabled:V,onClick:H,children:U}),t[37]=B,t[38]=V,t[39]=H,t[40]=W):W=t[40];let ee=l?.loading?o?`停止加载网页`:`Stop loading page`:o?`刷新网页`:`Reload page`,G=!l?.url&&!l?.loading,K;t[41]!==N||t[42]!==l?.loading?(K=()=>N(l?.loading?`stop`:`reload`),t[41]=N,t[42]=l?.loading,t[43]=K):K=t[43];let q;t[44]===l?.loading?q=t[45]:(q=l?.loading?(0,$.jsx)(wo,{className:`size-4`}):(0,$.jsx)(Ka,{className:`size-4`}),t[44]=l?.loading,t[45]=q);let te;t[46]!==ee||t[47]!==G||t[48]!==K||t[49]!==q?(te=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":ee,disabled:G,onClick:K,children:q}),t[46]=ee,t[47]=G,t[48]=K,t[49]=q,t[50]=te):te=t[50];let ne=o?`搜索或输入网址`:`Search or enter a URL`,re,ie,ae;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>h(!0),ie=()=>h(!1),ae=e=>p(e.target.value),t[51]=re,t[52]=ie,t[53]=ae):(re=t[51],ie=t[52],ae=t[53]);let oe=o?`搜索或输入网址`:`Search or enter a URL`,se;t[54]!==f||t[55]!==ne||t[56]!==oe?(se=(0,$.jsx)(`input`,{ref:d,"aria-label":ne,autoComplete:`off`,spellCheck:!1,value:f,onFocus:re,onBlur:ie,onChange:ae,placeholder:oe,className:`h-9 min-w-0 flex-1 rounded-full border border-edge-subtle bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`}),t[54]=f,t[55]=ne,t[56]=oe,t[57]=se):se=t[57];let ce=a?.button,le=o?`在系统浏览器打开`:`Open in system browser`,ue=!l?.url,de;t[58]===l?de=t[59]:(de=()=>{l?.url&&window.electronAPI?.shell?.openExternalUrl(l.url).catch(e=>_(e instanceof Error?e.message:String(e)))},t[58]=l,t[59]=de);let fe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(br,{className:`size-4`}),t[60]=fe):fe=t[60];let pe;t[61]!==le||t[62]!==ue||t[63]!==de?(pe=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":le,disabled:ue,onClick:de,children:fe}),t[61]=le,t[62]=ue,t[63]=de,t[64]=pe):pe=t[64];let me;t[65]!==P||t[66]!==z||t[67]!==W||t[68]!==te||t[69]!==se||t[70]!==ce||t[71]!==pe?(me=(0,$.jsxs)(`form`,{"data-workspace-toolbar":!0,className:`flex h-14 shrink-0 items-center gap-1 bg-surface-inset px-2`,onSubmit:P,children:[z,W,te,se,ce,pe]}),t[65]=P,t[66]=z,t[67]=W,t[68]=te,t[69]=se,t[70]=ce,t[71]=pe,t[72]=me):me=t[72];let he;t[73]===g?he=t[74]:(he=g?(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:g}):null,t[73]=g,t[74]=he);let ge;t[75]===l?ge=t[76]:(ge=l?.notice?(0,$.jsx)(`p`,{role:`status`,className:`border-b border-edge px-3 py-2 text-xs text-fg-muted`,children:l.notice}):null,t[75]=l,t[76]=ge);let _e;t[77]!==b||t[78]!==j||t[79]!==o?(_e=b?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":o?`选择搜索引擎`:`Choose a search engine`,className:`border-b border-edge p-4 text-sm`,children:[(0,$.jsx)(`p`,{children:o?`选择搜索引擎后才会提交这次搜索。`:`Choose where to send this search.`}),(0,$.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[[`duckduckgo`,`google`,`bing`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 hover:bg-surface-hover`,onClick:()=>{y(e),j(e)},children:e===`duckduckgo`?`DuckDuckGo`:e===`google`?`Google`:`Bing`},e)),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(!1),children:o?`取消`:`Cancel`})]})]}):null,t[77]=b,t[78]=j,t[79]=o,t[80]=_e):_e=t[80];let ve;t[81]!==N||t[82]!==g||t[83]!==l||t[84]!==o?(ve=!l&&g?(0,$.jsx)(`div`,{className:`p-8 text-sm text-fg-muted`,children:o?`无法创建浏览器标签。关闭其他网页后重试。`:`Browser tab could not be created. Close another page and try again.`}):l?l.error?(0,$.jsxs)(`div`,{role:`alert`,className:`p-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.error}),(0,$.jsx)(`button`,{type:`button`,className:`mt-4 text-accent`,onClick:()=>N(`reload`),children:o?`重试`:`Retry`})]}):l.url?null:(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center text-fg-muted`,children:[(0,$.jsx)(ci,{className:`size-9`}),(0,$.jsx)(`h2`,{className:`text-lg text-fg`,children:o?`浏览网页`:`Browse the web`}),(0,$.jsx)(`p`,{className:`text-sm`,children:o?`输入网址开始。网页内容不会自动发送到聊天。`:`Enter an address to begin. Pages are not automatically shared with chat.`})]}):(0,$.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,$.jsx)(Xo,{className:`h-8 w-2/3`}),(0,$.jsx)(Xo,{className:`h-40 w-full`})]}),t[81]=N,t[82]=g,t[83]=l,t[84]=o,t[85]=ve):ve=t[85];let J;t[86]===ve?J=t[87]:(J=(0,$.jsx)(`div`,{ref:u,className:`relative min-h-0 flex-1 overflow-hidden bg-surface-base`,"data-browser-surface":!0,children:ve}),t[86]=ve,t[87]=J);let ye;return t[88]!==me||t[89]!==he||t[90]!==ge||t[91]!==_e||t[92]!==J?(ye=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-browser-tab":!0,children:[me,he,ge,_e,J]}),t[88]=me,t[89]=he,t[90]=ge,t[91]=_e,t[92]=J,t[93]=ye):ye=t[93],ye}function HH(e){return e.conversationId}function UH(e){return e.language}function WH(){let e=(0,Q.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(GH,t)}function GH(){return window.electronAPI?.browser?.onEvent(KH)}function KH(e){if(e.kind===`state`)NH.getState().update(e.state),ns.getState().updateBrowserTitle(e.state.workspaceTabId,e.state.title);else if(e.kind===`focus-address`)window.dispatchEvent(new CustomEvent(`browser-focus-address`,{detail:e.workspaceTabId}));else{let t=ns.getState();Object.values(t.panes).flatMap(JH).filter(qH).length<24&&t.openBrowser(e.url,e.scope,e.sourceTabId)}}function qH(e){return e.kind===`browser`}function JH(e){return e.tabs}var YH=(0,Z.memo)(function({elevated:e=!1,embedded:t=!1,scope:n,onCloseTree:r}){let i=Do(zo(e=>e.language)),{pathname:a,search:o}=p(),{conversationId:s}=d(),c=a.startsWith(`/chat`)&&s&&s!==`new`?decodeURIComponent(s):null,l=re(e=>e.open),u=t||l,f=(0,Z.useRef)(u),m=re(e=>e.setOpen),h=(0,Z.useCallback)(e=>{t?e||r?.():m(e)},[t,r,m]),g=re(e=>e.conversationIdOverride),_=re(e=>e.widthPx),v=re(e=>e.setWidthPx),y=n?n.conversationId??null:g??c,b=n?n.projectId??null:!y&&a.startsWith(`/chat`)?new URLSearchParams(o).get(`projectId`):null,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)([]),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),L=Ec(e=>e.path),R=Ec(e=>e.setPath),z=(0,Z.useCallback)(e=>{R(e,null,b,y)},[y,R,b]),B=Eu(e=>e.agentId),V=n?.agentId??B,{tree:H,rootResource:U,loading:W,error:ee,loadRoot:G,loadChildren:K,refreshDirectory:q,reset:te}=Tu(V,y,b),ne=y?`session:${y}`:b?`project:${b}`:`agent:${V}`,ie=(0,Z.useMemo)(()=>b?{projectId:b}:y==null?V.trim()?{agentId:V.trim()}:void 0:{conversationId:y},[y,b,V]),ae=T.trim(),oe=Ol(),se=(0,Z.useCallback)((e,t)=>{ft(e.dataTransfer,{name:t.name,path:t.path,...ie})},[ie]),{dialogOpen:ce,loading:le,result:ue,error:de,pendingParams:fe,createShareLink:pe,confirmShareLink:me,handleOpenChange:he}=Qo(),ge=(0,Z.useCallback)(e=>{if(!u)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),S(!0);let r=e.clientX,i=re.getState().widthPx,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n?.style.setProperty(`--workspace-panel-px`,`${c}px`)},d=e=>{s=J(i+(r-e.clientX)),o===0&&(o=window.requestAnimationFrame(l))},f=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}S(!1),v(c),window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[u,v]);(0,Z.useEffect)(()=>{!t&&!a.startsWith(`/chat`)&&h(!1)},[t,a,h]),(0,Z.useEffect)(()=>{let e=f.current;if(f.current=u,!u){te(),e&&!t&&z(null);return}t||z(null),G()},[t,u,ne,G,te,z]),(0,Z.useEffect)(()=>{if(!u||t)return;let e=e=>{if(e.key===`Escape`){if(C){e.preventDefault(),e.stopPropagation(),E(``),w(!1);return}Ec.getState().path||h(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,C,u,h]),(0,Z.useEffect)(()=>{if(!u||!t&&!C||!ae){O([]),A(!1),M(null);return}let e=!1;A(!0),M(null),O([]);let n=window.setTimeout(()=>{_u(ae,ie,50).then(t=>{e||O(t)}).catch(t=>{e||M(t instanceof Error?t.message:String(t))}).finally(()=>{e||A(!1)})},180);return()=>{e=!0,window.clearTimeout(n)}},[t,C,ae,u,ie]),(0,Z.useEffect)(()=>{if(!u||t||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[t,u]);let _e=(0,Z.useCallback)(e=>{K(e)},[K]),ve=(0,Z.useCallback)(async(e,t,n)=>{switch(e){case`preview`:if(t.isDirectory)return;z(t.path);break;case`download`:if(t.isDirectory)return;try{let e=ei(t.path);if($r(ti(e))!==`text`)vu(e,await(await hu(t.path,ie)).arrayBuffer(),Hc(e)??`application/octet-stream`);else{let{content:n}=await gu(t.path,ie);bu(e,n)}}catch{}break;case`copyPath`:try{await xc(t.path)&&ii(`success`,i.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:await Su(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWith`:await Su(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await Su(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),i.workspace.openFileFailed);break;case`revealInFolder`:await Su(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),i.workspace.revealFileFailed);break;case`trash`:P(t);break;case`delete`:t.isDirectory||I(t);break;case`share`:await pe({path:t.path,...t.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...ie});break;default:break}},[pe,i.workspace.openFileFailed,i.workspace.pathCopied,i.workspace.revealFileFailed,z,ie]),ye=(0,Z.useCallback)(async()=>{let e=N;if(!e)return;let n=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!n?.ok){ii(`warning`,n?.error??i.workspace.trashFailed,void 0,{duration:4e3});return}!t&&L===e.path&&z(null),P(null),await G(),ii(`success`,i.workspace.trashSuccess,void 0,{duration:2500})},[t,G,i.workspace.trashFailed,i.workspace.trashSuccess,N,L,z]),be=(0,Z.useCallback)(async(e,t)=>{try{await Promise.all(e.map(e=>yu(e,t,ie))),await q(t).catch(()=>void 0),ii(`success`,i.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await q(t).catch(()=>void 0),ii(`warning`,`${i.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[i.workspace.uploadFailed,i.workspace.uploadSuccess,q,ie]),xe=(0,Z.useCallback)(async()=>{let e=F;if(e)try{await xu(e.fileId),!t&&L===e.path&&z(null),I(null);let n=e.path.lastIndexOf(`/`);await q(n<0?``:e.path.slice(0,n)).catch(()=>void 0),ii(`success`,i.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){ii(`warning`,`${i.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[t,i.workspace.deleteFailed,i.workspace.deleteSuccess,F,L,q,z]);return(0,$.jsxs)($.Fragment,{children:[u&&!t?(0,$.jsx)(`button`,{type:`button`,className:Y(`fixed inset-0 bg-scrim md:hidden`,e?`z-[109]`:`z-40`),"aria-label":i.closeMenu,onClick:()=>h(!1)}):null,(0,$.jsx)(`aside`,{id:t?void 0:`app-workspace-panel`,"aria-label":i.workspace.title,"aria-hidden":!u,className:t?`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-base`:Y(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:h-[100dvh] max-md:shadow-popover max-md:w-[min(20rem,92vw)]`,u?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,e&&u?`pointer-events-auto z-[110]`:`max-md:z-50`,!u&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,u&&`app-workspace-panel-expanded-width md:shrink-0`,u&&x&&`workspace-panel-rail-resizing`),style:!t&&u?{"--workspace-panel-px":`${_}px`}:void 0,children:u?(0,$.jsxs)(`div`,{className:Y(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[t?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i.workspace.resizeHandleAria,onPointerDown:ge,className:Y(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,x&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,sl)}),(0,$.jsxs)(`div`,{className:Y(`flex h-11 shrink-0 items-center gap-2 px-4`,!t&&`border-b border-edge dark:border-edge`),children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:i.workspace.title}),oe?U?(0,$.jsx)(pr,{resourceId:U.fileId,displayName:U.name}):null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(qr,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:i.workspace.title})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[t?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-9 shrink-0 rounded-md p-0`,C&&`bg-surface-hover text-fg`),"aria-label":i.workspace.search,title:i.workspace.search,"aria-pressed":C,onClick:()=>w(!0),children:(0,$.jsx)(Xa,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(mu,{className:`size-9 shrink-0 rounded-md p-0`,loading:W,label:i.cron.refresh,onClick:G}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":i.workspace.close,title:i.workspace.close,onClick:()=>h(!1),children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:1.75})})]})]}),t||C?(0,$.jsx)(`div`,{className:Y(`shrink-0 px-3 pb-2 pt-1`,!t&&`border-b border-edge`),children:(0,$.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(Xa,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:T,onChange:e=>E(e.target.value),placeholder:i.workspace.searchPlaceholder,"aria-label":i.workspace.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),!t||T?(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":i.workspace.clearSearch,title:i.workspace.clearSearch,onClick:()=>{E(``),w(!1)},children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,ee?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,ee]}):null,ae?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:k?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(Xo,{className:`h-11 w-full`}),(0,$.jsx)(Xo,{className:`h-11 w-full`}),(0,$.jsx)(Xo,{className:`h-11 w-full`})]}):j?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,j]}):D.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:i.workspace.noSearchResults}):D.map(e=>(0,$.jsxs)(`button`,{type:`button`,draggable:!0,className:Y(`flex w-full min-w-0 cursor-grab items-center gap-2 px-3 py-2 text-left active:cursor-grabbing hover:bg-surface-hover`,L===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>z(e.path),onDragStart:t=>se(t,e),title:e.path,children:[(0,$.jsx)(Dr,{name:e.name}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(kr,{tree:H,selectedPath:L,onSelectFile:e=>z(e),onExpandDir:_e,onAction:ve,onFileDragStart:se,onUploadFiles:(e,t)=>void be(e,t),uploadDropHint:i.workspace.dropToUpload,actionLabels:{preview:i.workspace.preview,download:i.workspace.download,copyPath:i.workspace.copyPath,share:i.workspace.shareLink,delete:i.workspace.deleteFile,...oe?{openDefault:i.workspace.openSystemApp,openDirectory:i.workspace.openInFileManager,openWith:i.workspace.chooseApp,revealInFolder:i.workspace.revealInFolder,trash:i.workspace.moveToTrash,recommendedApps:i.workspace.recommendedApps,desktopUpdateRequired:i.workspace.desktopUpdateRequired}:{}},emptyHint:i.workspace.emptyDir})]}):null}),(0,$.jsx)(So,{open:ce,onOpenChange:he,loading:le,error:de,result:ue,pendingParams:fe,onConfirm:e=>void me(e)}),(0,$.jsx)(pu,{open:!!N,title:i.workspace.trashConfirmTitle,description:i.workspace.trashConfirmDescription.replace(`{{name}}`,N?.name??``),confirmLabel:i.workspace.moveToTrash,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void ye(),onCancel:()=>P(null)}),(0,$.jsx)(pu,{open:!!F,title:i.workspace.deleteConfirmTitle,description:i.workspace.deleteConfirmDescription.replace(`{{name}}`,F?.name??``),confirmLabel:i.workspace.deleteFile,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void xe(),onCancel:()=>I(null)})]})}),XH=`xopc:side-chat-client-id`;function ZH(){let e=sessionStorage.getItem(XH);if(e)return e;let t=crypto.randomUUID();return sessionStorage.setItem(XH,t),t}function QH(){return{"x-xopc-client-instance-id":ZH()}}async function $H(e,t){return(await Bo(Lo(`/api/sessions/${encodeURIComponent(e)}/side-chats`),{method:`POST`,headers:QH(),body:JSON.stringify({clientInstanceId:ZH(),selections:t})})).sideChat}async function eU(e){return(await Bo(Lo(`/api/side-chats/${e}`),{headers:QH()})).sideChat}async function tU(e){return(await Bo(Lo(`/api/side-chats/${e}/messages`),{headers:QH()})).messages}async function nU(e,t){return(await Bo(Lo(`/api/side-chats/${e}/config`),{method:`PATCH`,headers:QH(),body:JSON.stringify(t)})).sideChat}async function rU(e,t,n){return(await Bo(Lo(`/api/side-chats/${e}/inputs`),{method:`POST`,headers:QH(),body:JSON.stringify({content:t,attachments:n})})).payload.runId}async function iU(e,t){await Bo(Lo(`/api/side-chats/${e}/abort`),{method:`POST`,headers:QH(),body:JSON.stringify({runId:t})})}async function aU(e,t,n){await Bo(Lo(`/api/side-chats/${e}/clarify/${t}`),{method:`POST`,headers:QH(),body:JSON.stringify(n)})}async function oU(e){await Bo(Lo(`/api/side-chats/${e}`),{method:`DELETE`,headers:QH()})}async function sU(e){return(await Bo(Lo(`/api/side-chats/${e}/heartbeat`),{method:`POST`,headers:QH()})).sideChat}async function cU(e){return(await Bo(Lo(`/api/side-chats/${e}/extend`),{method:`POST`,headers:QH()})).sideChat}async function lU(e){return Bo(Lo(`/api/side-chats/${e}/promote`),{method:`POST`,headers:QH()})}var uU=`xopc:side-chat-close-confirm-disabled:v1`,dU=()=>{},fU=[];function pU(){try{return localStorage.getItem(uU)===`true`}catch{return!1}}function mU(){try{localStorage.setItem(uU,`true`)}catch{}}function hU(e){return e.role===`user`?e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
6
|
+
`);let c=r.split(dB);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var wB=`xopc.updateReminder.dismissed`,TB=typeof window<`u`&&window.electronAPI?.updater!==void 0,EB=`xopc:electron-update-recheck`;function DB(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(wB);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var OB=160;function kB(e){let t=e.trim();return t.length<=OB?t:`${t.slice(0,OB-1)}…`}function AB(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=bB(),[o,s]=(0,Z.useState)(DB),[c,l]=(0,Z.useState)({downloading:!1,electronError:!1}),[u,d]=(0,Z.useState)(()=>{if(typeof window>`u`||TB)return null;try{let e=sessionStorage.getItem(pB);if(!e)return null;let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;return n?{version:n,automatic:t.automaticRestart===!0}:null}catch{return null}}),f=(0,Z.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,Z.useRef)(null);if(u&&e?.currentVersion===u.version&&p.current!==u.version){p.current=u.version;try{sessionStorage.removeItem(pB)}catch{}d(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(pB);if(!e){d(null);return}let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;d(n?{version:n,automatic:t.automaticRestart===!0}:null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(wB,JSON.stringify(t))}catch{}return t})};return window.addEventListener(EB,e),()=>window.removeEventListener(EB,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(wB,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:kB(t.message)}:!n&&u&&e&&e.currentVersion!==u.version?u.automatic?{kind:`npm-restarting`,version:u.version}:{kind:`npm-restart-required`,version:u.version}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,Z.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`||m.kind===`npm-restarting`){try{sessionStorage.removeItem(pB)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(wB,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var jB={version:`0.0.418`,commit:`05be45a24709f6723cda4a0865b3a37928823381`,buildTimeIso:`2026-10-25T05:15:20.715Z`},MB=`https://github.com/xopcai/xopc`,NB=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),PB=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function FB(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?NB:PB).format(n)}catch{return n.toISOString()}}function IB({open:e,onOpenChange:t}){let n=zo(e=>e.language),r=Do(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:f}=bB(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),{data:x}=iu(async()=>{let e=await Bo(Lo(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),S=(0,Z.useCallback)(e=>{e||(m(!1),g(!1),v(!1),b(null)),t(e)},[t]),C=(0,Z.useCallback)(async()=>{b(null);let e=Do(n).updatePanel,t=await d();if(t.ok){Vc({tone:`success`,title:e.updateSuccess,message:mB(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;b(`${r}: ${t.message}`)},[d,n]),w=jB.commit,T=n===`zh`?`zh-CN`:`en-US`,E=FB(jB.buildTimeIso,T),D=new Date().getFullYear(),O=i.copyright.replace(`{year}`,String(D));return(0,$.jsx)(us,{open:e,onOpenChange:S,children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(cs,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(os,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(ll,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(ls,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(as,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:jB.version}),(0,$.jsx)(`button`,{type:`button`,className:Y(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(EB)),m(!0),c()):(m(!0),v(!1),g(!0),(async()=>{let e=await l();g(!1),e||v(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(h||f),children:o&&s?.state===`checking`||!o&&h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Hi,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&p&&(0,$.jsx)(LB,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&p&&(0,$.jsx)(RB,{checking:h,checkFailed:_,npm:u,npmUpdateRunning:f,upgradeError:y,onUpgrade:C,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:w})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:E})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:x??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:MB,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:O})]})]})]})]})})}function LB(e){let t=(0,Q.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(An,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Wa,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_r,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_r,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function RB(e){let t=(0,Q.c)(28),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,upgradeError:o,onUpgrade:s,d:c,tp:l}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===c.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesChecking})]}),t[1]=c.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===c.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesError})]}),t[4]=c.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===l.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:l.updateRunning})]}),t[7]=l.updateRunning,t[8]=n),n}if(o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;return t[10]===o?n=t[11]:(n=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-red-500 dark:text-red-400`,role:`alert`,children:[e,(0,$.jsx)(`span`,{children:o})]}),t[10]=o,t[11]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Wa,{className:`mt-0.5 size-3.5 shrink-0`}),t[12]=e):e=t[12];let n;t[13]!==i.latestVersion||t[14]!==l.reminderNpm?(n=l.reminderNpm.replace(`{{version}}`,i.latestVersion),t[13]=i.latestVersion,t[14]=l.reminderNpm,t[15]=n):n=t[15];let r;t[16]===n?r=t[17]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[16]=n,t[17]=r);let a;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(a=Y(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-on-accent`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[18]=a):a=t[18];let o;t[19]!==s||t[20]!==l.updateNow?(o=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:a,children:l.updateNow}),t[19]=s,t[20]=l.updateNow,t[21]=o):o=t[21];let c;return t[22]!==r||t[23]!==o?(c=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,o]}),t[22]=r,t[23]=o,t[24]=c):c=t[24],c}let u;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(An,{className:`size-3.5`}),t[25]=u):u=t[25];let d;return t[26]===c.checkUpdatesUpToDate?d=t[27]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[u,(0,$.jsx)(`span`,{children:c.checkUpdatesUpToDate})]}),t[26]=c.checkUpdatesUpToDate,t[27]=d),d}var zB=Y(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`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-overlay`),BB=Y(`overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,`dark:border-edge`);function VB(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=Y(`touch-target flex w-full items-center justify-between gap-2 rounded-none px-3 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=Y(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(hn,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function HB(e){let t=(0,Q.c)(220),{onNavigate:n,onAboutClick:r,onSupportClick:i,onDeviceConnectClick:a}=e,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=zo(JB),d=zo(qB),f=gl(KB),p=gl(GB),m=fl(WB),h=fl(UB),g;t[0]===u?g=t[1]:(g=Do(u),t[0]=u,t[1]=g);let _=g,v=_.appearanceSettings,b=u===`zh`?v.langOptionZh:v.langOptionEn,x=f===`light`?v.themeOptionLight:f===`dark`?v.themeOptionDark:v.themeOptionSystem,S=m===`compact`?v.fontScaleCompact:m===`large`?v.fontScaleLarge:v.fontScaleDefault,C=typeof window<`u`?window.electronAPI?.pet:void 0,w=!!C,T=c?.visible?v.hideDesktopPet:v.showDesktopPet,E,D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{if(!C)return;let e=!1;C.getState().then(t=>{e||l(t)});let t=C.onStateChanged(t=>{e||l(t)});return()=>{e=!0,t()}},D=[C],t[2]=E,t[3]=D):(E=t[2],D=t[3]),(0,Z.useEffect)(E,D);let O;t[4]===c?.visible?O=t[5]:(O=async()=>{C&&(c?.visible?await C.hide():await C.show(),l(await C.getState()))},t[4]=c?.visible,t[5]=O);let k=O,A;t[6]===o?A=t[7]:(A=e=>Y(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,o===e?`block`:`hidden`),t[6]=o,t[7]=A);let j=A,M;t[8]===o?M=t[9]:(M=e=>Y(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,o===e?`pointer-events-auto`:`pointer-events-none`),t[8]=o,t[9]=M);let N=M,P;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>s(null),t[10]=P):P=t[10];let F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>s(`lang`),t[11]=F):F=t[11];let I=o===`lang`&&`bg-surface-hover`,L;t[12]===I?L=t[13]:(L=Y(zB,I),t[12]=I,t[13]=L);let R=o===`lang`,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ci,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=z):z=t[14];let B;t[15]===v.languageTitle?B=t[16]:(B=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.languageTitle}),t[15]=v.languageTitle,t[16]=B);let V;t[17]===b?V=t[18]:(V=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:b}),t[17]=b,t[18]=V);let H;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(vn,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=H):H=t[19];let U;t[20]!==L||t[21]!==R||t[22]!==B||t[23]!==V?(U=(0,$.jsxs)(`button`,{type:`button`,className:L,"aria-haspopup":`menu`,"aria-expanded":R,children:[z,B,V,H]}),t[20]=L,t[21]=R,t[22]=B,t[23]=V,t[24]=U):U=t[24];let W;t[25]===N?W=t[26]:(W=N(`lang`),t[25]=N,t[26]=W);let ee;t[27]===W?ee=t[28]:(ee=(0,$.jsx)(`div`,{className:W,"aria-hidden":!0}),t[27]=W,t[28]=ee);let G;t[29]===j?G=t[30]:(G=j(`lang`),t[29]=j,t[30]=G);let K=u===`en`,q;t[31]===d?q=t[32]:(q=()=>d(`en`),t[31]=d,t[32]=q);let te;t[33]!==v.langOptionEn||t[34]!==K||t[35]!==q?(te=(0,$.jsx)(VB,{selected:K,label:v.langOptionEn,onSelect:q}),t[33]=v.langOptionEn,t[34]=K,t[35]=q,t[36]=te):te=t[36];let ne=u===`zh`,re;t[37]===d?re=t[38]:(re=()=>d(`zh`),t[37]=d,t[38]=re);let ie;t[39]!==v.langOptionZh||t[40]!==ne||t[41]!==re?(ie=(0,$.jsx)(VB,{selected:ne,label:v.langOptionZh,onSelect:re}),t[39]=v.langOptionZh,t[40]=ne,t[41]=re,t[42]=ie):ie=t[42];let ae;t[43]!==te||t[44]!==ie?(ae=(0,$.jsxs)(`div`,{className:BB,children:[te,ie]}),t[43]=te,t[44]=ie,t[45]=ae):ae=t[45];let oe;t[46]!==v.languageTitle||t[47]!==G||t[48]!==ae?(oe=(0,$.jsx)(`div`,{className:G,role:`menu`,"aria-label":v.languageTitle,children:ae}),t[46]=v.languageTitle,t[47]=G,t[48]=ae,t[49]=oe):oe=t[49];let se;t[50]!==U||t[51]!==ee||t[52]!==oe?(se=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:F,children:[U,ee,oe]}),t[50]=U,t[51]=ee,t[52]=oe,t[53]=se):se=t[53];let ce;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>s(`theme`),t[54]=ce):ce=t[54];let le=o===`theme`&&`bg-surface-hover`,ue;t[55]===le?ue=t[56]:(ue=Y(zB,le),t[55]=le,t[56]=ue);let de=o===`theme`,fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(KO,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=fe):fe=t[57];let pe;t[58]===v.themeTitle?pe=t[59]:(pe=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.themeTitle}),t[58]=v.themeTitle,t[59]=pe);let me;t[60]===x?me=t[61]:(me=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:x}),t[60]=x,t[61]=me);let he;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(vn,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=he):he=t[62];let ge;t[63]!==ue||t[64]!==de||t[65]!==pe||t[66]!==me?(ge=(0,$.jsxs)(`button`,{type:`button`,className:ue,"aria-haspopup":`menu`,"aria-expanded":de,children:[fe,pe,me,he]}),t[63]=ue,t[64]=de,t[65]=pe,t[66]=me,t[67]=ge):ge=t[67];let _e;t[68]===N?_e=t[69]:(_e=N(`theme`),t[68]=N,t[69]=_e);let ve;t[70]===_e?ve=t[71]:(ve=(0,$.jsx)(`div`,{className:_e,"aria-hidden":!0}),t[70]=_e,t[71]=ve);let J;t[72]===j?J=t[73]:(J=j(`theme`),t[72]=j,t[73]=J);let ye=f===`light`,be;t[74]===p?be=t[75]:(be=()=>p(`light`),t[74]=p,t[75]=be);let xe;t[76]!==v.themeOptionLight||t[77]!==ye||t[78]!==be?(xe=(0,$.jsx)(VB,{selected:ye,label:v.themeOptionLight,onSelect:be}),t[76]=v.themeOptionLight,t[77]=ye,t[78]=be,t[79]=xe):xe=t[79];let Se=f===`dark`,Ce;t[80]===p?Ce=t[81]:(Ce=()=>p(`dark`),t[80]=p,t[81]=Ce);let we;t[82]!==v.themeOptionDark||t[83]!==Se||t[84]!==Ce?(we=(0,$.jsx)(VB,{selected:Se,label:v.themeOptionDark,onSelect:Ce}),t[82]=v.themeOptionDark,t[83]=Se,t[84]=Ce,t[85]=we):we=t[85];let Te=f===`system`,Ee;t[86]===p?Ee=t[87]:(Ee=()=>p(`system`),t[86]=p,t[87]=Ee);let De;t[88]!==v.themeOptionSystem||t[89]!==Te||t[90]!==Ee?(De=(0,$.jsx)(VB,{selected:Te,label:v.themeOptionSystem,onSelect:Ee}),t[88]=v.themeOptionSystem,t[89]=Te,t[90]=Ee,t[91]=De):De=t[91];let Oe;t[92]!==xe||t[93]!==we||t[94]!==De?(Oe=(0,$.jsxs)(`div`,{className:BB,children:[xe,we,De]}),t[92]=xe,t[93]=we,t[94]=De,t[95]=Oe):Oe=t[95];let ke;t[96]!==v.themeTitle||t[97]!==J||t[98]!==Oe?(ke=(0,$.jsx)(`div`,{className:J,role:`menu`,"aria-label":v.themeTitle,children:Oe}),t[96]=v.themeTitle,t[97]=J,t[98]=Oe,t[99]=ke):ke=t[99];let Ae;t[100]!==ge||t[101]!==ve||t[102]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:ce,children:[ge,ve,ke]}),t[100]=ge,t[101]=ve,t[102]=ke,t[103]=Ae):Ae=t[103];let je;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>s(`font`),t[104]=je):je=t[104];let Me=o===`font`&&`bg-surface-hover`,Ne;t[105]===Me?Ne=t[106]:(Ne=Y(zB,Me),t[105]=Me,t[106]=Ne);let Pe=o===`font`,Fe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(YI,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=Fe):Fe=t[107];let Ie;t[108]===v.fontScaleTitle?Ie=t[109]:(Ie=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.fontScaleTitle}),t[108]=v.fontScaleTitle,t[109]=Ie);let Le;t[110]===S?Le=t[111]:(Le=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:S}),t[110]=S,t[111]=Le);let Re;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(vn,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=Re):Re=t[112];let ze;t[113]!==Ne||t[114]!==Pe||t[115]!==Ie||t[116]!==Le?(ze=(0,$.jsxs)(`button`,{type:`button`,className:Ne,"aria-haspopup":`menu`,"aria-expanded":Pe,children:[Fe,Ie,Le,Re]}),t[113]=Ne,t[114]=Pe,t[115]=Ie,t[116]=Le,t[117]=ze):ze=t[117];let Be;t[118]===N?Be=t[119]:(Be=N(`font`),t[118]=N,t[119]=Be);let Ve;t[120]===Be?Ve=t[121]:(Ve=(0,$.jsx)(`div`,{className:Be,"aria-hidden":!0}),t[120]=Be,t[121]=Ve);let He;t[122]===j?He=t[123]:(He=j(`font`),t[122]=j,t[123]=He);let Ue=m===`compact`,We;t[124]===h?We=t[125]:(We=()=>h(`compact`),t[124]=h,t[125]=We);let Ge;t[126]!==v.fontScaleCompact||t[127]!==Ue||t[128]!==We?(Ge=(0,$.jsx)(VB,{selected:Ue,label:v.fontScaleCompact,onSelect:We}),t[126]=v.fontScaleCompact,t[127]=Ue,t[128]=We,t[129]=Ge):Ge=t[129];let Ke=m==="default",qe;t[130]===h?qe=t[131]:(qe=()=>h(`default`),t[130]=h,t[131]=qe);let Je;t[132]!==v.fontScaleDefault||t[133]!==Ke||t[134]!==qe?(Je=(0,$.jsx)(VB,{selected:Ke,label:v.fontScaleDefault,onSelect:qe}),t[132]=v.fontScaleDefault,t[133]=Ke,t[134]=qe,t[135]=Je):Je=t[135];let Ye=m===`large`,Xe;t[136]===h?Xe=t[137]:(Xe=()=>h(`large`),t[136]=h,t[137]=Xe);let Ze;t[138]!==v.fontScaleLarge||t[139]!==Ye||t[140]!==Xe?(Ze=(0,$.jsx)(VB,{selected:Ye,label:v.fontScaleLarge,onSelect:Xe}),t[138]=v.fontScaleLarge,t[139]=Ye,t[140]=Xe,t[141]=Ze):Ze=t[141];let Qe;t[142]!==Ge||t[143]!==Je||t[144]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:BB,children:[Ge,Je,Ze]}),t[142]=Ge,t[143]=Je,t[144]=Ze,t[145]=Qe):Qe=t[145];let $e;t[146]!==v.fontScaleTitle||t[147]!==He||t[148]!==Qe?($e=(0,$.jsx)(`div`,{className:He,role:`menu`,"aria-label":v.fontScaleTitle,children:Qe}),t[146]=v.fontScaleTitle,t[147]=He,t[148]=Qe,t[149]=$e):$e=t[149];let et;t[150]!==ze||t[151]!==Ve||t[152]!==$e?(et=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:je,children:[ze,Ve,$e]}),t[150]=ze,t[151]=Ve,t[152]=$e,t[153]=et):et=t[153];let tt;t[154]!==T||t[155]!==k?(tt=w?(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:()=>void k(),onMouseEnter:()=>s(null),onFocus:()=>s(null),children:[(0,$.jsx)(gk,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:T})]}):null,t[154]=T,t[155]=k,t[156]=tt):tt=t[156];let nt;t[157]===a?nt=t[158]:(nt=()=>a?.(),t[157]=a,t[158]=nt);let rt,it,at;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(rt=()=>s(null),it=()=>s(null),at=(0,$.jsx)(da,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[159]=rt,t[160]=it,t[161]=at):(rt=t[159],it=t[160],at=t[161]);let ot;t[162]===_.endpointToolsSettings.deviceAccess.flow.title?ot=t[163]:(ot=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.endpointToolsSettings.deviceAccess.flow.title}),t[162]=_.endpointToolsSettings.deviceAccess.flow.title,t[163]=ot);let st;t[164]!==nt||t[165]!==ot?(st=(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:nt,onMouseEnter:rt,onFocus:it,children:[at,ot]}),t[164]=nt,t[165]=ot,t[166]=st):st=t[166];let ct;t[167]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[167]=ct):ct=t[167];let lt;t[168]===r?lt=t[169]:(lt=()=>r?.(),t[168]=r,t[169]=lt);let ut,dt,ft;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(ut=()=>s(null),dt=()=>s(null),ft=(0,$.jsx)(Pi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=ut,t[171]=dt,t[172]=ft):(ut=t[170],dt=t[171],ft=t[172]);let pt;t[173]===v.aboutApp?pt=t[174]:(pt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.aboutApp}),t[173]=v.aboutApp,t[174]=pt);let mt;t[175]!==lt||t[176]!==pt?(mt=(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:lt,onMouseEnter:ut,onFocus:dt,children:[ft,pt]}),t[175]=lt,t[176]=pt,t[177]=mt):mt=t[177];let ht;t[178]===u?ht=t[179]:(ht=wl(u),t[178]=u,t[179]=ht);let gt,_t,vt;t[180]===Symbol.for(`react.memo_cache_sentinel`)?(gt=()=>s(null),_t=()=>s(null),vt=(0,$.jsx)(Xt,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[180]=gt,t[181]=_t,t[182]=vt):(gt=t[180],_t=t[181],vt=t[182]);let yt;t[183]===_.sidebar.helpDocs?yt=t[184]:(yt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.sidebar.helpDocs}),t[183]=_.sidebar.helpDocs,t[184]=yt);let bt;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(bt=(0,$.jsx)(br,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[185]=bt):bt=t[185];let xt;t[186]!==ht||t[187]!==yt?(xt=(0,$.jsxs)(`a`,{href:ht,target:`_blank`,rel:`noopener noreferrer`,className:zB,onMouseEnter:gt,onFocus:_t,children:[vt,yt,bt]}),t[186]=ht,t[187]=yt,t[188]=xt):xt=t[188];let St;t[189]===i?St=t[190]:(St=()=>i?.(),t[189]=i,t[190]=St);let Ct,wt,Tt;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=()=>s(null),Ct=()=>s(null),wt=(0,$.jsx)(fD,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[191]=Ct,t[192]=wt,t[193]=Tt):(Ct=t[191],wt=t[192],Tt=t[193]);let Et;t[194]===_.supportReport.menu?Et=t[195]:(Et=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.supportReport.menu}),t[194]=_.supportReport.menu,t[195]=Et);let Dt;t[196]!==Et||t[197]!==St?(Dt=(0,$.jsxs)(`button`,{type:`button`,className:zB,onClick:St,onMouseEnter:Tt,onFocus:Ct,children:[wt,Et]}),t[196]=Et,t[197]=St,t[198]=Dt):Dt=t[198];let Ot,kt,At;t[199]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=Y(zB,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),kt=()=>s(null),At=()=>s(null),t[199]=Ot,t[200]=kt,t[201]=At):(Ot=t[199],kt=t[200],At=t[201]);let jt;t[202]===n?jt=t[203]:(jt=()=>n?.(),t[202]=n,t[203]=jt);let Mt;t[204]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=(0,$.jsx)($a,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[204]=Mt):Mt=t[204];let Nt;t[205]===v.openFullPreferences?Nt=t[206]:(Nt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:v.openFullPreferences}),t[205]=v.openFullPreferences,t[206]=Nt);let Pt;t[207]!==jt||t[208]!==Nt?(Pt=(0,$.jsxs)(y,{to:`/settings/overview`,className:Ot,onMouseEnter:kt,onFocus:At,onClick:jt,children:[Mt,Nt]}),t[207]=jt,t[208]=Nt,t[209]=Pt):Pt=t[209];let Ft;return t[210]!==Dt||t[211]!==Pt||t[212]!==se||t[213]!==Ae||t[214]!==et||t[215]!==tt||t[216]!==st||t[217]!==mt||t[218]!==xt?(Ft=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:P,children:[se,Ae,et,tt,st,ct,mt,xt,Dt,Pt]}),t[210]=Dt,t[211]=Pt,t[212]=se,t[213]=Ae,t[214]=et,t[215]=tt,t[216]=st,t[217]=mt,t[218]=xt,t[219]=Ft):Ft=t[219],Ft}function UB(e){return e.setPreference}function WB(e){return e.preference}function GB(e){return e.setPreference}function KB(e){return e.preference}function qB(e){return e.setLanguage}function JB(e){return e.language}var YB=`open-support-report`;function XB(e={}){window.dispatchEvent(new CustomEvent(YB,{detail:e}))}var ZB=(0,Z.lazy)(()=>s(()=>import(`./device-pairing-wizard-CLCPuf4R.js`).then(e=>e.n).then(e=>({default:e.DevicePairingWizard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])));function QB({collapsed:e=!1,onNavigate:t}){let n=Do(zo(e=>e.language)),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{s(()=>import(`./settings-page-DROUGyJl.js`),__vite__mapDeps([52,1,2,3,4,15,18,53])),s(()=>import(`./sessions-page-DsLw2aMD.js`),__vite__mapDeps([54,1,2,3,4,55,6,56,8,57,58,59,60,61,62,16,17,28,63,64,32,22,65,21,24,34,35,25,66,67,68,9,69,70,71,72,73,74,75,76,77,14,15,18,19,20,23,78,79,49,44,80,45,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,10,96,97,47,48,98,99,42,100])),s(()=>import(`./logs-page-CbY1N-zi.js`),__vite__mapDeps([101,1,2,3,4,102,6,64,32,16,17,22,65,21,24,34,35,25,103,9,104,105,106,107,75,62,14,15,18,20,23,78,28,79,36,108,109,45,82,110,90,95,10,96,97])),s(()=>import(`./automations-page-oLsNzu_6.js`),__vite__mapDeps([111,2,1,112,3,4,113,6,114,32,102,5,64,16,17,22,65,21,24,34,35,25,99,7,8,115,116,57,117,118,9,119,74,14,15,18,23,26,27,28,29,36,120,121,122,58,123,48,124,107,75,125,126,96,127,77,128,19,20,129,130,131,132,133,86,82,87,44,110,134,89,61,49,80,79,45,135,136,137,138])),s(()=>import(`./capabilities-page-DFW4Y0x8.js`),__vite__mapDeps([139,1,2,4,3,15,140,18,22,16,17,133,141,142,75,6,20,21,65,24,34,35,143]))},[]),(0,$.jsxs)(`div`,{className:Y(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[c?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ZB,{open:!0,onOpenChange:l})}):null,(0,$.jsxs)(ps,{open:r,onOpenChange:i,children:[e?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(y,{to:`/user-model`,onClick:()=>t?.(),className:`rounded-full outline-none ring-offset-surface-base transition-transform hover:opacity-95 active:scale-95 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 motion-reduce:active:scale-100`,title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(au,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex size-10 shrink-0 items-center justify-center rounded-xl text-fg-muted outline-none ring-offset-surface-base transition-colors`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)($a,{className:`size-[17px]`,strokeWidth:1.5})})})]}):(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-1 rounded-xl p-1`,children:[(0,$.jsx)(y,{to:`/user-model`,onClick:()=>t?.(),className:Y(`flex size-10 shrink-0 items-center justify-center rounded-full text-left outline-none transition-transform duration-150 ease-out`,`hover:bg-surface-active/70`,`hover:opacity-95 active:scale-95`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(au,{variant:`avatar`,className:`size-10`})}),(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left text-fg-muted transition-colors`,`outline-none hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:n.appearanceSettings.quickMenuHint})]}),(0,$.jsx)($a,{className:`size-[18px] shrink-0`,strokeWidth:1.5})]})})]}),(0,$.jsx)(ds,{children:(0,$.jsx)(fs,{className:Y(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`end`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(HB,{onNavigate:()=>{i(!1),t?.()},onAboutClick:()=>{o(!0),i(!1)},onSupportClick:()=>{i(!1),XB()},onDeviceConnectClick:()=>{i(!1),l(!0)}})})})]}),(0,$.jsx)(IB,{open:a,onOpenChange:o})]})}function $B(e){return qR[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var eV=3,tV=[`work`,`capabilities`,`automation`,`apps`],nV={work:dn,capabilities:Li,automation:To,apps:oh};function rV(e,t,n=!1){return Y(`flex w-full items-center text-sm font-medium transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,n?`gap-2 rounded-md px-2 py-1.5 text-left leading-5`:e?`justify-center rounded-xl p-2.5 leading-6`:`gap-2 rounded-lg px-3 py-2.5 text-left leading-6 md:py-1.5`,t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}function iV(e){let t=(0,Q.c)(2),{Icon:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r),r}function aV(e){let t=(0,Q.c)(36),{collapsed:n,onNavigate:r,visibleLimit:i}=e,a=n!==void 0&&n,o=i===void 0?eV:i,{pathname:s}=p(),c=zo(fV),l=Do(c),u=l.productNavigation,d;t[0]===s?d=t[1]:(d=ko(s),t[0]=s,t[1]=d);let f=d,m=hc(),{profile:h,displayName:g}=ou(),_=me(),[v,b]=(0,Z.useState)(!1),x=tV.map(e=>{let t=Ao.find(t=>t.id===e);return{id:e,label:u.domains[e],to:t.path,Icon:nV[e],active:f===e}}),S=Number.isFinite(o)?Math.min(x.length,Math.max(1,Math.round(o))):eV,C=x.slice(0,S),w=x.slice(S),T;t[2]===s?T=t[3]:(T=e=>e.activationEligible===!1?[]:(e.ui?.contributions?.pages??[]).filter(dV).map(t=>{let n=jn(e.id,t);return{id:`extension:${e.id}:${t.id}`,label:t.title,to:n,Icon:t.navIcon?$B(t.navIcon)??Ba:Ba,active:s===n||s.startsWith(`${n}/`)}}),t[2]=s,t[3]=T);let E=m.flatMap(T),D=w.some(uV)||E.some(lV),O;t[4]!==a||t[5]!==r?(O=(e,t)=>{let n=t!==void 0&&t;return(0,$.jsxs)(y,{to:e.to,"aria-current":e.active?`page`:void 0,className:rV(a,e.active,n),title:e.label,onMouseEnter:()=>nu(e.to),onFocus:()=>nu(e.to),onClick:()=>{b(!1),r?.()},children:[(0,$.jsx)(iV,{Icon:e.Icon}),!a||n?(0,$.jsx)(`span`,{className:`truncate`,children:e.label}):null]},e.id)},t[4]=a,t[5]=r,t[6]=O):O=t[6];let k=O,A=s===`/personal`?`page`:void 0,j;t[7]!==a||t[8]!==s?(j=Y(`relative`,rV(a,s===`/personal`)),t[7]=a,t[8]=s,t[9]=j):j=t[9];let M;t[10]===r?M=t[11]:(M=()=>{le.getState().setCollapsed(!0),r?.()},t[10]=r,t[11]=M);let N=h?.appearance??`loopi`,P=h?.agentId,F;t[12]!==P||t[13]!==N?(F=(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,"aria-hidden":!0,children:(0,$.jsx)(Ma,{appearance:N,agentId:P,className:`size-5`})}),t[12]=P,t[13]=N,t[14]=F):F=t[14];let I;t[15]!==a||t[16]!==g?(I=!a&&(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g}),t[15]=a,t[16]=g,t[17]=I):I=t[17];let L;t[18]!==a||t[19]!==c||t[20]!==_?(L=_>0&&(0,$.jsx)(`span`,{"aria-label":c===`zh`?`${_} 条未读消息`:`${_} unread messages`,className:Y(`shrink-0 rounded-full bg-accent/15 px-1.5 text-center text-[10px] font-semibold leading-5 tabular-nums text-accent`,a?`absolute right-0 top-0 min-w-4 leading-4`:`min-w-5`),children:pe(_)}),t[18]=a,t[19]=c,t[20]=_,t[21]=L):L=t[21];let R;t[22]!==g||t[23]!==F||t[24]!==I||t[25]!==L||t[26]!==A||t[27]!==j||t[28]!==M?(R=(0,$.jsxs)(y,{to:`/personal`,"aria-current":A,className:j,title:g,onMouseEnter:cV,onFocus:sV,onClick:M,children:[F,I,L]}),t[22]=g,t[23]=F,t[24]=I,t[25]=L,t[26]=A,t[27]=j,t[28]=M,t[29]=R):R=t[29];let z;t[30]===k?z=t[31]:(z=e=>k(e),t[30]=k,t[31]=z);let B=C.map(z),V=w.length>0||E.length>0?(0,$.jsxs)(ps,{open:v,onOpenChange:b,children:[(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":l.sidebar.moreAppsAria,title:l.sidebar.moreApps,className:Y(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,a?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2.5 text-left md:py-1.5`,v||D?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,$.jsx)(yr,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),a?null:(0,$.jsx)(`span`,{className:`truncate`,children:l.sidebar.moreApps})]})}),(0,$.jsx)(ds,{children:(0,$.jsx)(fs,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:`z-50 max-h-[min(32rem,var(--radix-popover-content-available-height))] min-w-[14rem] max-w-[20rem] overflow-y-auto rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,onOpenAutoFocus:oV,children:(0,$.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":l.sidebar.moreAppsAria,children:[w.map(e=>k(e,!0)),E.length>0?(0,$.jsxs)(`section`,{"aria-labelledby":`sidebar-more-extension-apps`,children:[(0,$.jsx)(`div`,{id:`sidebar-more-extension-apps`,className:`px-2 pb-1 pt-1.5 text-[11px] font-semibold tracking-wide text-fg-subtle`,children:l.sidebar.extensionAppsHeading}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:E.map(e=>k(e,!0))})]}):null]})})})]}):null,H;return t[32]!==R||t[33]!==B||t[34]!==V?(H=(0,$.jsxs)($.Fragment,{children:[R,B,V]}),t[32]=R,t[33]=B,t[34]=V,t[35]=H):H=t[35],H}function oV(e){return e.preventDefault()}function sV(){return nu(`/personal`)}function cV(){return nu(`/personal`)}function lV(e){return e.active}function uV(e){return e.active}function dV(e){return e.showInNav}function fV(e){return e.language}var pV={sources:[],purposes:[],activity:``,project:``,days:``,status:`visible`,agentId:``,details:!1};function mV(e){return!!(e.sources.length||e.purposes.length||e.activity||e.project||e.days||e.agentId||e.status!==`visible`)}function hV(e,t,n=Date.now()){return{search:t.trim()||void 0,sources:e.sources.length?e.sources:void 0,purposes:e.purposes.length?e.purposes:[...Sa],activity:e.activity||void 0,projectId:e.project&&e.project!==`__unassigned`?e.project:void 0,unassigned:e.project===`__unassigned`||void 0,updatedAfter:e.days?n-Number(e.days)*864e5:void 0,status:e.status===`visible`?void 0:e.status,excludeArchived:e.status!==`archived`,agentId:e.agentId||void 0,sortBy:`updatedAt`,sortOrder:`desc`}}function gV(e){return`xopc-session-filters-v1:${e}`}function _V(e){try{let t=xa.safeParse({sources:e.sources,purposes:e.purposes,activity:e.activity||void 0,agentId:e.agentId||void 0});return t.success?{...pV,...t.data,sources:t.data.sources??[],purposes:t.data.purposes??[],activity:t.data.activity??``,agentId:t.data.agentId??``,project:typeof e.project==`string`?e.project:``,days:typeof e.days==`string`&&[``,`7`,`30`,`60`].includes(e.days)?e.days:``,status:e.status===`pinned`||e.status===`archived`?e.status:`visible`,details:e.details===!0}:{...pV}}catch{return{...pV}}}function vV(e){try{return _V(JSON.parse(localStorage.getItem(gV(e))??`{}`))}catch{return{...pV}}}function yV(e,t){try{localStorage.setItem(gV(e),JSON.stringify(t))}catch{}}async function bV(){let e=[];for(let t=0;;){let n=await Is({limit:100,offset:t,sortBy:`name`,sortOrder:`asc`});if(e.push(...n.items),t+=n.items.length,!n.items.length||t>=n.total)return e}}var xV=e=>`xopc-session-views-v1:${e}`;function SV(e){try{let t=JSON.parse(localStorage.getItem(xV(e))??`[]`);return Array.isArray(t)?t.filter(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&e.name.trim()).slice(0,20).map(e=>({id:e.id,name:e.name.slice(0,60),filters:_V(e.filters??{}),search:typeof e.search==`string`?e.search.slice(0,500):``})):[]}catch{return[]}}function CV(e,t){try{return localStorage.setItem(xV(e),JSON.stringify(t)),!0}catch{return!1}}var wV=`rounded-md px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,TV=`flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`;function EV(e){let t=(0,Q.c)(10),{label:n,summary:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`shrink-0`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-xs text-fg-muted`,title:r,children:r}),t[2]=r,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(vn,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i||t[7]!==a||t[8]!==o?(c=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-10 w-full min-w-0 items-center gap-3 rounded-md px-2 py-2 text-left text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n,children:[a,o,s]}),t[5]=n,t[6]=i,t[7]=a,t[8]=o,t[9]=c):c=t[9],c}function DV(e){let t=(0,Q.c)(261),{filters:n,onChange:r,search:i,onSearch:a,labels:o,gateway:s,agents:c}=e,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`home`),[p,m]=(0,Z.useState)(``),h;t[0]===s?h=t[1]:(h=()=>SV(s),t[0]=s,t[1]=h);let[g,_]=(0,Z.useState)(h),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(`home`),w=(0,Z.useId)(),T=(0,Z.useId)(),E;if(t[2]!==n||t[3]!==g||t[4]!==i){let e;t[6]!==n||t[7]!==i?(e=e=>e.search===i&&JSON.stringify(e.filters)===JSON.stringify(n),t[6]=n,t[7]=i,t[8]=e):e=t[8],E=g.find(e),t[2]=n,t[3]=g,t[4]=i,t[5]=E}else E=t[5];let D=E,O;t[9]!==n.project||t[10]!==s||t[11]!==l||t[12]!==d?(O=l&&d===`project`||n.project?[`session-filter-projects`,s]:null,t[9]=n.project,t[10]=s,t[11]=l,t[12]=d,t[13]=O):O=t[13];let{data:k,error:A,mutate:j}=qo(O,bV),M;t[14]!==n||t[15]!==r?(M=e=>r({...n,...e}),t[14]=n,t[15]=r,t[16]=M):M=t[16];let N=M,P;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{f(e),m(``),x(!1)},t[17]=P):P=t[17];let F=P,I;t[18]===d?I=t[19]:(I=()=>F(d===`save`?`views`:[`purposes`,`status`,`agent`].includes(d)?`advanced`:`home`),t[18]=d,t[19]=I);let L=I,R;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{u(e),e&&F(`home`)},t[20]=R):R=t[20];let z=R,B,V;t[21]!==l||t[22]!==d?(B=()=>{l&&C.current!==d&&(S.current?.querySelector(`[data-page-autofocus]`))?.focus(),C.current=d},V=[l,d],t[21]=l,t[22]=d,t[23]=B,t[24]=V):(B=t[23],V=t[24]),(0,Z.useLayoutEffect)(B,V);let H;t[25]===n?H=t[26]:(H=mV({...n,activity:``}),t[25]=n,t[26]=H);let U=H,W=n.status!==`visible`,ee;t[27]!==n.activity||t[28]!==n.agentId||t[29]!==n.days||t[30]!==n.project||t[31]!==n.purposes.length||t[32]!==n.sources.length||t[33]!==W?(ee=[n.sources.length,n.purposes.length,n.project,n.days,n.agentId,n.activity,W].filter(Boolean),t[27]=n.activity,t[28]=n.agentId,t[29]=n.days,t[30]=n.project,t[31]=n.purposes.length,t[32]=n.sources.length,t[33]=W,t[34]=ee):ee=t[34];let G=ee.length,K=n.status!==`visible`,q;t[35]!==n.agentId||t[36]!==n.purposes.length||t[37]!==K?(q=[n.purposes.length,n.agentId,K].filter(Boolean),t[35]=n.agentId,t[36]=n.purposes.length,t[37]=K,t[38]=q):q=t[38];let te=q.length,ne;t[39]===o.selectedCount?ne=t[40]:(ne=e=>o.selectedCount.replace(`{{count}}`,String(e)),t[39]=o.selectedCount,t[40]=ne);let re=ne,ie;t[41]!==n.sources||t[42]!==o.all||t[43]!==o.sources?(ie=n.sources.length?n.sources.map(e=>o.sources[e]).join(` · `):o.all,t[41]=n.sources,t[42]=o.all,t[43]=o.sources,t[44]=ie):ie=t[44];let ae=ie,oe;t[45]!==n.purposes||t[46]!==o.all||t[47]!==o.purposes?(oe=n.purposes.length?n.purposes.map(e=>o.purposes[e]).join(` · `):o.all,t[45]=n.purposes,t[46]=o.all,t[47]=o.purposes,t[48]=oe):oe=t[48];let se=oe,ce;t[49]!==n.project||t[50]!==o.unassigned||t[51]!==k?(ce=n.project===`__unassigned`?o.unassigned:k?.find(e=>e.id===n.project)?.name??n.project,t[49]=n.project,t[50]=o.unassigned,t[51]=k,t[52]=ce):ce=t[52];let le=ce,ue;t[53]!==n.days||t[54]!==o.anyTime||t[55]!==o.days?(ue=n.days?o.days.replace(`{{days}}`,n.days):o.anyTime,t[53]=n.days,t[54]=o.anyTime,t[55]=o.days,t[56]=ue):ue=t[56];let de=ue,fe;t[57]!==o.agent||t[58]!==o.filters||t[59]!==o.moreFilters||t[60]!==o.project||t[61]!==o.purposesLabel||t[62]!==o.saveView||t[63]!==o.savedViews||t[64]!==o.sourcesLabel||t[65]!==o.status||t[66]!==o.time?(fe={home:o.filters,sources:o.sourcesLabel,purposes:o.purposesLabel,project:o.project,time:o.time,status:o.status,agent:o.agent,advanced:o.moreFilters,views:o.savedViews,save:o.saveView},t[57]=o.agent,t[58]=o.filters,t[59]=o.moreFilters,t[60]=o.project,t[61]=o.purposesLabel,t[62]=o.saveView,t[63]=o.savedViews,t[64]=o.sourcesLabel,t[65]=o.status,t[66]=o.time,t[67]=fe):fe=t[67];let pe=fe,me,he,ge,_e,ve;if(t[68]!==c||t[69]!==L||t[70]!==n.agentId||t[71]!==n.days||t[72]!==n.project||t[73]!==n.purposes||t[74]!==n.sources||t[75]!==n.status||t[76]!==o||t[77]!==p||t[78]!==d||t[79]!==N||t[80]!==k){let e;if(t[86]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[86]=e):e=t[86],ve=e,d===`sources`){let e;t[87]===o.sources?e=t[88]:(e=e=>({value:e,label:o.sources[e]}),t[87]=o.sources,t[88]=e),he=wa.map(e),ve=n.sources;let r;t[89]===N?r=t[90]:(r=e=>N({sources:e}),t[89]=N,t[90]=r),me=r}else if(d===`purposes`){let e;t[91]===o.purposes?e=t[92]:(e=e=>({value:e,label:o.purposes[e]}),t[91]=o.purposes,t[92]=e),he=Sa.map(e),ve=n.purposes;let r;t[93]===N?r=t[94]:(r=e=>N({purposes:e}),t[93]=N,t[94]=r),me=r}else if(d===`project`){he=[{value:``,label:o.allProjects},{value:`__unassigned`,label:o.unassigned},...(k??[]).map(kV)],n.project&&!he.some(e=>e.value===n.project)&&he.push({value:n.project,label:n.project});let e;t[95]===n.project?e=t[96]:(e=[n.project],t[95]=n.project,t[96]=e),ve=e;let r;t[97]!==L||t[98]!==N?(r=e=>{let[t]=e;N({project:t}),L()},t[97]=L,t[98]=N,t[99]=r):r=t[99],me=r}else if(d===`time`){he=[{value:``,label:o.anyTime},...[`7`,`30`,`60`].map(e=>({value:e,label:o.days.replace(`{{days}}`,e)}))];let e;t[100]===n.days?e=t[101]:(e=[n.days],t[100]=n.days,t[101]=e),ve=e;let r;t[102]!==L||t[103]!==N?(r=e=>{let[t]=e;N({days:t}),L()},t[102]=L,t[103]=N,t[104]=r):r=t[104],me=r}else if(d===`status`){he=[`visible`,`pinned`,`archived`].map(e=>({value:e,label:o[e]}));let e;t[105]===n.status?e=t[106]:(e=[n.status],t[105]=n.status,t[106]=e),ve=e;let r;t[107]!==L||t[108]!==N?(r=e=>{let[t]=e;N({status:t}),L()},t[107]=L,t[108]=N,t[109]=r):r=t[109],me=r}else if(d===`agent`){he=[{value:``,label:o.allAgents},...c.map(OV)],n.agentId&&!he.some(e=>e.value===n.agentId)&&he.push({value:n.agentId,label:n.agentId});let e;t[110]===n.agentId?e=t[111]:(e=[n.agentId],t[110]=n.agentId,t[111]=e),ve=e;let r;t[112]!==L||t[113]!==N?(r=e=>{let[t]=e;N({agentId:t}),L()},t[112]=L,t[113]=N,t[114]=r):r=t[114],me=r}ge=d===`project`||d===`agent`,_e=he?.filter(e=>e.label.toLocaleLowerCase().includes(p.trim().toLocaleLowerCase())),t[68]=c,t[69]=L,t[70]=n.agentId,t[71]=n.days,t[72]=n.project,t[73]=n.purposes,t[74]=n.sources,t[75]=n.status,t[76]=o,t[77]=p,t[78]=d,t[79]=N,t[80]=k,t[81]=me,t[82]=he,t[83]=ge,t[84]=_e,t[85]=ve}else me=t[81],he=t[82],ge=t[83],_e=t[84],ve=t[85];let J=_e,ye;t[115]!==n.details||t[116]!==r||t[117]!==d||t[118]!==N?(ye=()=>{d===`sources`?N({sources:[]}):d===`purposes`?N({purposes:[]}):r({...pV,details:n.details})},t[115]=n.details,t[116]=r,t[117]=d,t[118]=N,t[119]=ye):ye=t[119];let be=ye,xe=l&&`bg-surface-hover opacity-100`,Se;t[120]===xe?Se=t[121]:(Se=Y(TV,`relative size-6 text-fg-subtle opacity-0 transition-[color,background-color,opacity] group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100 [@media(hover:none)]:opacity-100`,xe),t[120]=xe,t[121]=Se);let Ce=`${o.filters}${G?` (${G})`:``}`,we;t[122]!==G||t[123]!==o.filters||t[124]!==re?(we=G?`${o.filters} · ${re(G)}`:o.filters,t[122]=G,t[123]=o.filters,t[124]=re,t[125]=we):we=t[125];let Te;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(yr,{className:`size-3.5`,"aria-hidden":!0}),t[126]=Te):Te=t[126];let Ee;t[127]!==G||t[128]!==i?(Ee=G>0||i.trim()?(0,$.jsx)(`span`,{className:`absolute top-0.5 right-0.5 size-1 rounded-full bg-fg-muted`,"aria-hidden":!0}):null,t[127]=G,t[128]=i,t[129]=Ee):Ee=t[129];let De;t[130]!==Se||t[131]!==Ce||t[132]!==we||t[133]!==Ee?(De=(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Se,"aria-label":Ce,title:we,children:[Te,Ee]})}),t[130]=Se,t[131]=Ce,t[132]=we,t[133]=Ee,t[134]=De):De=t[134];let Oe;t[135]!==L||t[136]!==d?(Oe=e=>{d!==`home`&&(e.preventDefault(),L())},t[135]=L,t[136]=d,t[137]=Oe):Oe=t[137];let ke;t[138]!==L||t[139]!==o.back||t[140]!==d||t[141]!==ge?(ke=d===`home`?null:(0,$.jsx)(`button`,{type:`button`,className:TV,"aria-label":o.back,onClick:L,"data-page-autofocus":!ge&&d!==`save`?``:void 0,children:(0,$.jsx)(_t,{className:`size-4`,"aria-hidden":!0})}),t[138]=L,t[139]=o.back,t[140]=d,t[141]=ge,t[142]=ke):ke=t[142];let Ae=pe[d],je;t[143]!==T||t[144]!==Ae?(je=(0,$.jsx)(`span`,{id:T,className:`min-w-0 flex-1 truncate px-1 font-medium`,children:Ae}),t[143]=T,t[144]=Ae,t[145]=je):je=t[145];let Me;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0}),t[146]=Me):Me=t[146];let Ne;t[147]===o.close?Ne=t[148]:(Ne=(0,$.jsx)(ms,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:TV,"aria-label":o.close,children:Me})}),t[147]=o.close,t[148]=Ne);let Pe;t[149]!==ke||t[150]!==je||t[151]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-edge px-2 py-2`,children:[ke,je,Ne]}),t[149]=ke,t[150]=je,t[151]=Ne,t[152]=Pe):Pe=t[152];let Fe;t[153]!==o.searchOptions||t[154]!==p||t[155]!==ge?(Fe=ge?(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,$.jsx)(`input`,{type:`search`,"data-page-autofocus":!0,value:p,onChange:e=>m(e.target.value),placeholder:o.searchOptions,"aria-label":o.searchOptions,className:`w-full rounded-md border border-edge bg-surface-base px-2 py-1.5 text-sm outline-none focus:border-edge-strong focus:ring-1 focus:ring-edge-strong`})}):null,t[153]=o.searchOptions,t[154]=p,t[155]=ge,t[156]=Fe):Fe=t[156];let Ie;t[157]!==o.search||t[158]!==a||t[159]!==d||t[160]!==i?(Ie=d===`home`?(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,$.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base px-2 py-1.5 focus-within:border-edge-strong focus-within:ring-1 focus-within:ring-edge-strong`,children:[(0,$.jsx)(Xa,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:o.search,"aria-label":o.search,className:`min-w-0 w-full bg-transparent text-sm text-fg outline-none`})]})}):null,t[157]=o.search,t[158]=a,t[159]=d,t[160]=i,t[161]=Ie):Ie=t[161];let Le;t[162]!==te||t[163]!==U||t[164]!==n.activity||t[165]!==n.details||t[166]!==o||t[167]!==r||t[168]!==d||t[169]!==le||t[170]!==g.length||t[171]!==re||t[172]!==D?.name||t[173]!==ae||t[174]!==de?(Le=d===`home`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(su,{className:`mb-2 flex gap-1 rounded-md bg-surface-base p-1`,role:`group`,"aria-label":o.filters,indicatorClassName:`rounded-md bg-surface-active`,children:[``,`manual`,`automatic`].map(e=>(0,$.jsx)(`button`,{type:`button`,"data-page-autofocus":e===``?``:void 0,className:Y(wV,`min-w-0 flex-1 px-1`,!U&&n.activity===e&&`bg-surface-active text-fg`),"aria-pressed":!U&&n.activity===e,onClick:()=>{r({...pV,details:n.details,activity:e}),u(!1)},children:e?o[e]:o.all},e))}),(0,$.jsx)(EV,{label:o.sourcesLabel,summary:ae,onClick:()=>F(`sources`)}),(0,$.jsx)(EV,{label:o.project,summary:le||o.allProjects,onClick:()=>F(`project`)}),(0,$.jsx)(EV,{label:o.time,summary:de,onClick:()=>F(`time`)}),(0,$.jsx)(`div`,{className:`my-2 border-t border-edge`}),(0,$.jsx)(EV,{label:o.moreFilters,summary:te?re(te):``,onClick:()=>F(`advanced`)}),(0,$.jsx)(EV,{label:o.savedViews,summary:D?.name??(g.length?String(g.length):``),onClick:()=>F(`views`)})]}):null,t[162]=te,t[163]=U,t[164]=n.activity,t[165]=n.details,t[166]=o,t[167]=r,t[168]=d,t[169]=le,t[170]=g.length,t[171]=re,t[172]=D?.name,t[173]=ae,t[174]=de,t[175]=Le):Le=t[175];let Re;t[176]!==me||t[177]!==o.noOptions||t[178]!==o.projectError||t[179]!==o.retry||t[180]!==J||t[181]!==he||t[182]!==d||t[183]!==A||t[184]!==k||t[185]!==j||t[186]!==pe||t[187]!==ve?(Re=he&&me?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wn,{options:J??[],values:ve,multiple:d===`sources`||d===`purposes`,onChange:me,ariaLabel:pe[d]}),d===`project`&&!k&&!A?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3 p-2`,children:[(0,$.jsx)(Xo,{className:`h-5 w-3/4`}),(0,$.jsx)(Xo,{className:`h-5 w-2/3`})]}):null,d===`project`&&A?(0,$.jsxs)(`div`,{role:`alert`,className:`p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:o.projectError}),(0,$.jsx)(`button`,{type:`button`,className:wV,onClick:()=>void j(),children:o.retry})]}):null,!J?.length&&!(d===`project`&&!k)?(0,$.jsx)(`p`,{className:`p-2 text-xs text-fg-muted`,children:o.noOptions}):null]}):null,t[176]=me,t[177]=o.noOptions,t[178]=o.projectError,t[179]=o.retry,t[180]=J,t[181]=he,t[182]=d,t[183]=A,t[184]=k,t[185]=j,t[186]=pe,t[187]=ve,t[188]=Re):Re=t[188];let ze;t[189]!==c||t[190]!==n.agentId||t[191]!==n.details||t[192]!==n.status||t[193]!==o||t[194]!==d||t[195]!==N||t[196]!==se?(ze=d===`advanced`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(EV,{label:o.purposesLabel,summary:se,onClick:()=>F(`purposes`)}),(0,$.jsx)(EV,{label:o.status,summary:o[n.status],onClick:()=>F(`status`)}),c.length>1||n.agentId?(0,$.jsx)(EV,{label:o.agent,summary:c.find(e=>e.id===n.agentId)?.name??(n.agentId||o.allAgents),onClick:()=>F(`agent`)}):null,(0,$.jsxs)(`label`,{className:`mt-2 flex min-h-10 items-center gap-3 border-t border-edge px-2 pt-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.details,onChange:e=>N({details:e.target.checked})}),o.details]})]}):null,t[189]=c,t[190]=n.agentId,t[191]=n.details,t[192]=n.status,t[193]=o,t[194]=d,t[195]=N,t[196]=se,t[197]=ze):ze=t[197];let Be;t[198]!==s||t[199]!==o.deleteView||t[200]!==o.noViews||t[201]!==r||t[202]!==a||t[203]!==d||t[204]!==g||t[205]!==D?.id?(Be=d===`views`?(0,$.jsxs)($.Fragment,{children:[g.length?null:(0,$.jsx)(`p`,{className:`px-2 py-4 text-sm text-fg-muted`,children:o.noViews}),g.map(e=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{r(e.filters),a(e.search),u(!1)},"aria-pressed":D?.id===e.id,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),D?.id===e.id?(0,$.jsx)(hn,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]}),(0,$.jsx)(`button`,{type:`button`,className:TV,"aria-label":o.deleteView.replace(`{{name}}`,e.name),onClick:()=>{let t=g.filter(t=>t.id!==e.id);CV(s,t)?(_(t),x(!1)):x(!0)},children:(0,$.jsx)(ho,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))]}):null,t[198]=s,t[199]=o.deleteView,t[200]=o.noViews,t[201]=r,t[202]=a,t[203]=d,t[204]=g,t[205]=D?.id,t[206]=Be):Be=t[206];let Ve;t[207]!==n||t[208]!==w||t[209]!==s||t[210]!==o.saveViewHint||t[211]!==o.viewLimit||t[212]!==o.viewName||t[213]!==d||t[214]!==g||t[215]!==i||t[216]!==v?(Ve=d===`save`?(0,$.jsxs)(`form`,{id:w,className:`space-y-3 p-1`,onSubmit:e=>{e.preventDefault();let t=v.trim();if(!t||g.length>=20)return;let r=[...g,{id:crypto.randomUUID(),name:t,filters:n,search:i}];if(!CV(s,r)){x(!0);return}_(r),y(``),F(`views`)},children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:o.viewName}),(0,$.jsx)(`input`,{"data-page-autofocus":!0,value:v,onChange:e=>y(e.target.value),maxLength:60,placeholder:o.viewName,"aria-label":o.viewName,className:`w-full rounded-md border border-edge bg-surface-base px-2 py-2 focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.saveViewHint}),g.length>=20?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.viewLimit}):null]}):null,t[207]=n,t[208]=w,t[209]=s,t[210]=o.saveViewHint,t[211]=o.viewLimit,t[212]=o.viewName,t[213]=d,t[214]=g,t[215]=i,t[216]=v,t[217]=Ve):Ve=t[217];let He;t[218]!==o.viewSaveError||t[219]!==b?(He=b?(0,$.jsx)(`p`,{role:`alert`,className:`p-2 text-xs text-danger`,children:o.viewSaveError}):null,t[218]=o.viewSaveError,t[219]=b,t[220]=He):He=t[220];let Ue;t[221]!==d||t[222]!==Le||t[223]!==Re||t[224]!==ze||t[225]!==Be||t[226]!==Ve||t[227]!==He?(Ue=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain p-2`,"data-session-filter-scroll":!0,children:[Le,Re,ze,Be,Ve,He]},d),t[221]=d,t[222]=Le,t[223]=Re,t[224]=ze,t[225]=Be,t[226]=Ve,t[227]=He,t[228]=Ue):Ue=t[228];let We;t[229]!==be||t[230]!==G||t[231]!==o.clear||t[232]!==o.clearSelection||t[233]!==o.saveView||t[234]!==d||t[235]!==g.length||t[236]!==ve?(We=d===`home`||d===`sources`||d===`purposes`?(0,$.jsx)(`button`,{type:`button`,className:wV,disabled:d===`home`?!G:!ve.length,onClick:be,children:d===`home`?o.clear:o.clearSelection}):d===`views`?(0,$.jsx)(`button`,{type:`button`,className:wV,disabled:g.length>=20,onClick:()=>F(`save`),children:o.saveView}):(0,$.jsx)(`span`,{}),t[229]=be,t[230]=G,t[231]=o.clear,t[232]=o.clearSelection,t[233]=o.saveView,t[234]=d,t[235]=g.length,t[236]=ve,t[237]=We):We=t[237];let Ge;t[238]!==L||t[239]!==w||t[240]!==o.done||t[241]!==o.saveView||t[242]!==d||t[243]!==g.length||t[244]!==v?(Ge=d===`save`?(0,$.jsx)(`button`,{type:`submit`,form:w,className:Y(wV,`bg-surface-active text-fg`),disabled:!v.trim()||g.length>=20,children:o.saveView}):(0,$.jsx)(`button`,{type:`button`,className:Y(wV,`bg-surface-active text-fg`),onClick:()=>d===`home`?u(!1):L(),children:o.done}),t[238]=L,t[239]=w,t[240]=o.done,t[241]=o.saveView,t[242]=d,t[243]=g.length,t[244]=v,t[245]=Ge):Ge=t[245];let Ke;t[246]!==We||t[247]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-3 py-2`,children:[We,Ge]}),t[246]=We,t[247]=Ge,t[248]=Ke):Ke=t[248];let qe;t[249]!==T||t[250]!==Oe||t[251]!==Pe||t[252]!==Fe||t[253]!==Ie||t[254]!==Ue||t[255]!==Ke?(qe=(0,$.jsx)(ds,{children:(0,$.jsxs)(fs,{ref:S,side:`bottom`,align:`start`,sideOffset:8,collisionPadding:12,sticky:`always`,"aria-labelledby":T,className:`z-50 flex h-[min(26rem,calc(100dvh-1.5rem))] max-h-[var(--radix-popover-content-available-height)] w-[min(20rem,calc(100vw-1.5rem))] max-w-[var(--radix-popover-content-available-width)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-sm text-fg shadow-popover`,onEscapeKeyDown:Oe,children:[Pe,Fe,Ie,Ue,Ke]})}),t[249]=T,t[250]=Oe,t[251]=Pe,t[252]=Fe,t[253]=Ie,t[254]=Ue,t[255]=Ke,t[256]=qe):qe=t[256];let Je;return t[257]!==l||t[258]!==De||t[259]!==qe?(Je=(0,$.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,$.jsxs)(ps,{open:l,onOpenChange:z,children:[De,qe]})}),t[257]=l,t[258]=De,t[259]=qe,t[260]=Je):Je=t[260],Je}function OV(e){return{value:e.id,label:e.name||e.id}}function kV(e){return{value:e.id,label:e.name}}var AV=30;function jV(e,t){let n=(0,Q.c)(47),r;n[0]===e?r=n[1]:(r=()=>vV(e),n[0]=e,n[1]=r);let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(``),[c]=cu(o,250),[l,u]=(0,Z.useState)(!1),d;n[2]!==i||n[3]!==o?(d=mV(i)||!!o.trim(),n[2]=i,n[3]=o,n[4]=d):d=n[4];let f=d,p;n[5]!==f||n[6]!==e||n[7]!==t?(p=f&&t?[`session-filter-projects`,e]:null,n[5]=f,n[6]=e,n[7]=t,n[8]=p):p=n[8];let{data:m}=qo(p,bV),h;n[9]!==c||n[10]!==i?(h=hV(i,c),n[9]=c,n[10]=i,n[11]=h):h=n[11];let g=h,_;n[12]!==f||n[13]!==e||n[14]!==g||n[15]!==t?(_=(n,r)=>!t||!f||r&&!r.hasMore?null:[`session-discovery`,e,t,g,n],n[12]=f,n[13]=e,n[14]=g,n[15]=t,n[16]=_):_=n[16];let v;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!1},n[17]=v):v=n[17];let{data:y,error:b,isValidating:x,size:S,setSize:C,mutate:w}=Yo(_,PV,v),T;n[18]===e?T=n[19]:(T=t=>{a(t),yV(e,t)},n[18]=e,n[19]=T);let E=T,D;n[20]===w?D=n[21]:(D=()=>{u(!1),w()},n[20]=w,n[21]=D);let O=D,k,A;n[22]===f?(k=n[23],A=n[24]):(k=()=>{if(!f)return;let e=()=>u(!0),t=[`session-list-refresh`,`session-created`,`session-updated`,`session-transcript-updated`,`project-updated`];return t.forEach(t=>window.addEventListener(t,e)),()=>t.forEach(t=>window.removeEventListener(t,e))},A=[f],n[22]=f,n[23]=k,n[24]=A),(0,Z.useEffect)(k,A);let j;n[25]===y?j=n[26]:(j=[...new Map(y?.flatMap(NV).map(MV)??[]).values()],n[25]=y,n[26]=j);let M=j,N=y?.[0]?.total??0,P=!b&&(!y||o!==c),F;n[27]===y?F=n[28]:(F=y?.at(-1)?.hasMore??!1,n[27]=y,n[28]=F);let I=x&&!!y,L;n[29]!==C||n[30]!==S?(L=()=>void C(S+1),n[29]=C,n[30]=S,n[31]=L):L=n[31];let R;return n[32]!==f||n[33]!==b||n[34]!==i||n[35]!==M||n[36]!==l||n[37]!==m||n[38]!==O||n[39]!==o||n[40]!==N||n[41]!==P||n[42]!==F||n[43]!==I||n[44]!==L||n[45]!==E?(R={projects:m,filters:i,updateFilters:E,search:o,setSearch:s,active:f,items:M,total:N,loading:P,error:b,hasMore:F,loadingMore:I,loadMore:L,refresh:O,pendingUpdate:l},n[32]=f,n[33]=b,n[34]=i,n[35]=M,n[36]=l,n[37]=m,n[38]=O,n[39]=o,n[40]=N,n[41]=P,n[42]=F,n[43]=I,n[44]=L,n[45]=E,n[46]=R):R=n[46],R}function MV(e){return[e.key,e]}function NV(e){return e.items}function PV(e){let[,,,t,n]=e;return Js({...t,limit:AV,offset:n*AV})}function FV(e,t){if(!e||typeof e!=`object`)return!0;let n=e.key??e.conversationId;return typeof n!=`string`||!n.trim()||!t.has(n)}var IV=(0,Z.createContext)(!1),LV=(0,Z.createContext)({}),RV=(0,Z.memo)(function(e){let t=(0,Q.c)(27),{child:n,activeTaskId:r,onNavigate:i,sb:a}=e,o=p(),s;t[0]===n.activeConversationId?s=t[1]:(s=e=>n.activeConversationId?e.runs[n.activeConversationId]:void 0,t[0]=n.activeConversationId,t[1]=s);let c=te(s),l;t[2]!==n.activeConversationId||t[3]!==n.taskId||t[4]!==o?(l=n.activeConversationId?`/chat/task/${encodeURIComponent(n.taskId)}`:ea(`${o.pathname}${o.search}`,n.taskId),t[2]=n.activeConversationId,t[3]=n.taskId,t[4]=o,t[5]=l):l=t[5];let u=r===n.taskId&&`bg-surface-active text-fg`,d;t[6]===u?d=t[7]:(d=Y(`ml-8 flex min-h-8 items-center gap-2 rounded-lg px-2 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,u),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=()=>i?.(),t[8]=i,t[9]=f);let m;t[10]!==c||t[11]!==a?(m=c?.unread?(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":c.status===`failed`?a.taskSessionAgentFailed:a.taskSessionAgentCompleted}):null,t[10]=c,t[11]=a,t[12]=m):m=t[12];let h;t[13]===n.title?h=t[14]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[13]=n.title,t[14]=h);let g=n.runStatus??n.phase,_;t[15]!==a||t[16]!==g?(_=XV(g,a),t[15]=a,t[16]=g,t[17]=_):_=t[17];let v;t[18]===_?v=t[19]:(v=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:_}),t[18]=_,t[19]=v);let b;return t[20]!==v||t[21]!==l||t[22]!==d||t[23]!==f||t[24]!==m||t[25]!==h?(b=(0,$.jsxs)(y,{to:l,className:d,onClick:f,children:[m,h,v]}),t[20]=v,t[21]=l,t[22]=d,t[23]=f,t[24]=m,t[25]=h,t[26]=b):b=t[26],b}),zV=20,BV=12,VV=5,HV=60,UV=`application/x-xopc-sidebar-item`;function WV(e,t,n,r){let i=e.filter(e=>e!==t),a=i.indexOf(n);return a<0?e:(i.splice(a+ +!!r,0,t),i)}function GV(e,t,n){if(!t?.length)return e;let r=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({item:e,index:t,rank:r.get(n(e))})).sort((e,t)=>e.rank!==void 0&&t.rank!==void 0?e.rank-t.rank:e.rank===void 0?t.rank===void 0?e.index-t.index:-1:1).map(({item:e})=>e)}function KV({spec:e,children:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null);return e?(0,$.jsxs)(`div`,{draggable:!0,className:Y(`relative cursor-grab transition-[opacity,transform] duration-200 ease-out active:cursor-grabbing`,n&&`opacity-50`),onDragStart:t=>{r(!0),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(UV,JSON.stringify({containerId:e.containerId,itemId:e.itemId}))},onDragEnd:()=>{r(!1),a(null)},onDragOver:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();a(e.clientY>=t.top+t.height/2?`after`:`before`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(null)},onDrop:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>=n.top+n.height/2;a(null);try{let n=JSON.parse(t.dataTransfer.getData(UV));if(n.containerId!==e.containerId||n.itemId===e.itemId)return;e.onReorder(e.containerId,WV(e.itemIds,n.itemId,e.itemId,r))}catch{}},children:[i===`before`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 top-0 z-30 h-0.5 rounded-full bg-accent`}):null,t,i===`after`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 bottom-0 z-30 h-0.5 rounded-full bg-accent`}):null]}):t}function qV(e,t){return e.name?.trim()||t}function JV(e){let t=/^\/chat\/([^/]+)$/.exec(e);if(!t)return;let n=decodeURIComponent(t[1]);if(n!==`new`)return n}function YV(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function XV(e,t){return e===`running`||e===`active`||e===`verifying`?t.delegatedTaskRunning:e===`completed`||e===`succeeded`||e===`closed`?t.delegatedTaskCompleted:e===`failed`?t.delegatedTaskFailed:e===`backlog`||e===`ready`||e===`queued`||e===`waiting`?t.delegatedTaskWaiting:e}function ZV(e){let t=new Date(e.updatedAt).getTime();return Number.isFinite(t)?t:0}function QV(e){return Y(`group relative flex min-h-8 w-full min-w-0 items-center rounded-lg pr-1 text-left text-sm leading-5 transition-colors duration-200 ease-out`,`pl-6`,`focus-within:outline-none`,e?`bg-surface-active font-medium text-fg`:`font-normal text-fg-muted hover:bg-surface-hover hover:text-fg`)}var $V=`text-xs font-normal leading-5 text-fg-subtle`,eH=Y($V,`transition-colors hover:text-fg-muted`);function tH(e){let t=(0,Q.c)(5),{indented:n}=e,r=n!==void 0&&n&&`pl-6`,i;t[0]===r?i=t[1]:(i=Y(`flex items-center gap-2 p-1.5`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(Xo,{className:`h-3 w-4/5 animate-none`}),(0,$.jsx)(Xo,{className:`mt-1.5 h-2.5 w-2/5 animate-none`})]}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`div`,{className:i,children:a}),t[3]=i,t[4]=o),o}function nH(){let e=(0,Q.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Xo,{className:`mb-1.5 h-2.5 w-14 animate-none`}),(0,$.jsx)(tH,{})]}),n=(0,$.jsx)(Xo,{className:`mb-1.5 h-2.5 w-16 animate-none`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-4`,"aria-busy":`true`,children:[t,(0,$.jsxs)(`div`,{children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(tH,{}),(0,$.jsx)(tH,{indented:!0}),(0,$.jsx)(tH,{indented:!0})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Xo,{className:`mb-1.5 h-2.5 w-12 animate-none`}),(0,$.jsx)(tH,{}),(0,$.jsx)(tH,{})]})]}),e[2]=r):r=e[2],r}var rH=(0,Z.memo)(function({session:e,isActive:t,onNavigate:n,mutate:r,onRequestRename:i,onRequestDelete:a,sb:o,sess:s,clipboard:c,defaultUnnamedTitle:l,contextLabel:u,sort:d,showTaskChildren:f=!0}){let m=(0,Z.useContext)(LV)[e.key],h=p(),g=/^\/chat\/task\/([^/]+)$/.exec(h.pathname)?.[1],_=m?.items.some(e=>e.taskId===g||e.activeConversationId===JV(h.pathname))??!1,[v,b]=(0,Z.useState)(_);(0,Z.useEffect)(()=>{_&&b(!0)},[_]);let x=(0,Z.useContext)(IV),S=ba(e),C=S.source!==`workbench`||S.purpose!==`chat`,w=E(e,o.sessionFilters),T=[w,u].filter(Boolean).join(` · `),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),j=We(e.key),M=te(t=>t.runs[e.key]),N=qV(e,l),P=e.status===`pinned`,F=j||!!M?.unread,I=async()=>{if(!k){A(!0);try{P?await qs(e.key):await Hs(e.key),O(!1),r()}catch{}finally{A(!1)}}},L=async()=>{let t=await xc(e.key);if(O(!1),t){ii(`success`,o.taskChatIdCopied,void 0,{duration:2e3});return}ii(`warning`,c.copyFailed,void 0,{duration:4e3})};return(0,$.jsx)(KV,{spec:d,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:QV(t),children:[f&&m?.total?(0,$.jsx)(`button`,{type:`button`,className:`absolute left-0 flex size-6 items-center justify-center text-fg-subtle hover:text-fg`,"aria-label":v?o.delegatedTasksCollapse:o.delegatedTasksExpand,"aria-expanded":v,onClick:()=>b(e=>!e),children:(0,$.jsx)(gn,{className:Y(`size-3.5 transition-transform`,!v&&`-rotate-90`),"aria-hidden":!0})}):null,(0,$.jsxs)(y,{to:`/chat/${encodeURIComponent(e.key)}`,className:Y(`min-w-0 flex-1 self-stretch rounded-lg py-1 outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`flex min-w-0 items-center gap-2`,F?`pr-[4.75rem]`:`pr-12`),title:`${N} — ${T}`,"aria-label":`${N} — ${T}`,onClick:()=>n?.(),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),i(e)},children:[C?(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,title:w,children:(0,$.jsx)(Ta,{sourceChannel:e.sourceChannel,session:e,className:`size-3.5`})}):null,(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:N}),x?(0,$.jsx)(`span`,{className:`block truncate text-xs font-normal text-fg-muted`,children:T}):null]})]}),j?(0,$.jsxs)(`span`,{className:`pointer-events-none absolute right-2 top-1/2 z-10 flex size-2.5 -translate-y-1/2 items-center justify-center`,title:o.taskSessionAgentRunning,"aria-label":o.taskSessionAgentRunning,children:[(0,$.jsx)(`span`,{className:`absolute size-full animate-ping rounded-full bg-accent/70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`relative size-2 rounded-full bg-accent`,"aria-hidden":!0})]}):M?.unread?(0,$.jsx)(`span`,{className:Y(`pointer-events-none absolute right-2 top-1/2 z-10 size-2.5 -translate-y-1/2 rounded-full`,M.status===`failed`?`bg-red-500`:`bg-emerald-500`),title:M.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted,"aria-label":M.status===`failed`?o.taskSessionAgentFailed:o.taskSessionAgentCompleted}):null,(0,$.jsxs)(`div`,{className:Y(`pointer-events-none absolute inset-y-0 z-10 flex items-center opacity-0 transition-opacity`,`group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100`,F?`right-7`:`right-1`,D&&`pointer-events-auto opacity-100`),children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 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 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:cursor-wait`),"aria-label":P?s.unpin:s.pin,title:P?s.unpin:s.pin,"aria-pressed":P,disabled:k,onClick:()=>void I(),children:k?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):P?(0,$.jsx)(Pa,{className:`size-4 rotate-45`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Na,{className:`size-4 rotate-45`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(ps,{open:D,onOpenChange:O,children:[(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`flex h-8 w-6 shrink-0 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 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),"aria-label":o.taskSessionMenuAria,title:o.taskSessionMenuAria,"aria-expanded":D,children:(0,$.jsx)(yr,{className:`size-4`,strokeWidth:2,"aria-hidden":!0})})}),(0,$.jsx)(ds,{children:(0,$.jsxs)(fs,{className:`z-50 w-[9.25rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>{O(!1),i(e)},children:[(0,$.jsx)(Aa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskRename]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>void L(),children:[(0,$.jsx)(Yn,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskCopyChatId]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:()=>{O(!1),a(e.key)},children:[(0,$.jsx)(ho,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),o.taskDeleteTask]})]})})]})]})]}),f&&v&&m?.items.map(e=>(0,$.jsx)(RV,{child:e,activeTaskId:g,onNavigate:n,sb:o},e.taskId))]})})});function iH(e){let t=(0,Q.c)(74),{project:n,onNavigate:r,onPinToggle:i,onRequestRename:a,onArchive:o,onRequestRemove:s,sb:c}=e,[l,u]=(0,Z.useState)(!1),d;t[0]!==n.effectiveWorkspaceRoot||t[1]!==n.workspaceRoot?(d=n.effectiveWorkspaceRoot?.trim()||n.workspaceRoot?.trim()||``,t[0]=n.effectiveWorkspaceRoot,t[1]=n.workspaceRoot,t[2]=d):d=t[2];let f=d,p=!!(f&&window.electronAPI?.shell?.openPath),m=!!n.pinnedAt,h;t[3]!==c.projectOpenInExplorerFailed||t[4]!==c.projectOpenInExplorerUnavailable||t[5]!==f?(h=async()=>{if(!f||!window.electronAPI?.shell?.openPath){ii(`warning`,c.projectOpenInExplorerUnavailable,void 0,{duration:3500}),u(!1);return}let e=await window.electronAPI.shell.openPath(f);u(!1),e.ok===!1&&ii(`warning`,e.error||c.projectOpenInExplorerFailed,void 0,{duration:4e3})},t[3]=c.projectOpenInExplorerFailed,t[4]=c.projectOpenInExplorerUnavailable,t[5]=f,t[6]=h):h=t[6];let g=h,_=l&&`opacity-100`,v;t[7]===_?v=t[8]:(v=Y(`relative z-10 flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,_,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[7]=_,t[8]=v);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(yr,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=b):b=t[9];let x;t[10]!==l||t[11]!==c.projectMenuAria||t[12]!==v?(x=(0,$.jsx)(hs,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v,"aria-label":c.projectMenuAria,title:c.projectMenuAria,"aria-expanded":l,children:b})}),t[10]=l,t[11]=c.projectMenuAria,t[12]=v,t[13]=x):x=t[13];let S=`/projects/${encodeURIComponent(n.id)}`,C;t[14]===r?C=t[15]:(C=()=>{u(!1),r?.()},t[14]=r,t[15]=C);let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(br,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]!==c.projectOpen||t[18]!==S||t[19]!==C?(T=(0,$.jsxs)(y,{to:S,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:C,children:[w,c.projectOpen]}),t[17]=c.projectOpen,t[18]=S,t[19]=C,t[20]=T):T=t[20];let E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>u(!1),t[21]=E):E=t[21];let O;t[22]===n.id?O=t[23]:(O=(0,$.jsx)(uu,{projectId:n.id,onStarted:E,className:`flex w-full rounded-md px-2 py-1.5 text-left text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`}),t[22]=n.id,t[23]=O);let k;t[24]!==i||t[25]!==n?(k=()=>{u(!1),i(n)},t[24]=i,t[25]=n,t[26]=k):k=t[26];let A;t[27]===m?A=t[28]:(A=m?(0,$.jsx)(Pa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Na,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=m,t[28]=A);let j=m?c.projectUnpin:c.projectPin,M;t[29]!==k||t[30]!==A||t[31]!==j?(M=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:k,children:[A,j]}),t[29]=k,t[30]=A,t[31]=j,t[32]=M):M=t[32];let N;t[33]===g?N=t[34]:(N=()=>void g(),t[33]=g,t[34]=N);let P=!p,F=p?void 0:c.projectOpenInExplorerUnavailable,I;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(Kr,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=I):I=t[35];let L;t[36]!==c.projectOpenInExplorer||t[37]!==N||t[38]!==P||t[39]!==F?(L=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:text-fg-subtle disabled:hover:bg-transparent`,onClick:N,disabled:P,title:F,children:[I,c.projectOpenInExplorer]}),t[36]=c.projectOpenInExplorer,t[37]=N,t[38]=P,t[39]=F,t[40]=L):L=t[40];let R;t[41]!==a||t[42]!==n?(R=()=>{u(!1),a(n)},t[41]=a,t[42]=n,t[43]=R):R=t[43];let z;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Aa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[44]=z):z=t[44];let B;t[45]!==c.projectRename||t[46]!==R?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:R,children:[z,c.projectRename]}),t[45]=c.projectRename,t[46]=R,t[47]=B):B=t[47];let V;t[48]!==o||t[49]!==n?(V=()=>{u(!1),o(n)},t[48]=o,t[49]=n,t[50]=V):V=t[50];let H;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(D,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[51]=H):H=t[51];let U;t[52]!==c.projectArchive||t[53]!==V?(U=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:V,children:[H,c.projectArchive]}),t[52]=c.projectArchive,t[53]=V,t[54]=U):U=t[54];let W;t[55]!==s||t[56]!==n?(W=()=>{u(!1),s(n)},t[55]=s,t[56]=n,t[57]=W):W=t[57];let ee;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ho,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[58]=ee):ee=t[58];let G;t[59]!==c.projectRemove||t[60]!==W?(G=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:W,children:[ee,c.projectRemove]}),t[59]=c.projectRemove,t[60]=W,t[61]=G):G=t[61];let K;t[62]!==T||t[63]!==O||t[64]!==M||t[65]!==L||t[66]!==B||t[67]!==U||t[68]!==G?(K=(0,$.jsx)(ds,{children:(0,$.jsxs)(fs,{className:`z-50 w-[12rem] rounded-lg border border-edge bg-surface-overlay p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:aH,children:[T,O,M,L,B,U,G]})}),t[62]=T,t[63]=O,t[64]=M,t[65]=L,t[66]=B,t[67]=U,t[68]=G,t[69]=K):K=t[69];let q;return t[70]!==l||t[71]!==K||t[72]!==x?(q=(0,$.jsxs)(ps,{open:l,onOpenChange:u,children:[x,K]}),t[70]=l,t[71]=K,t[72]=x,t[73]=q):q=t[73],q}function aH(e){return e.preventDefault()}function oH(e){let t=(0,Q.c)(70),{group:n,isExpanded:r,isCollapsed:i,activeConversationId:a,onToggleExpanded:o,onToggleCollapsed:s,onCreateProjectChat:c,onToggleProjectPin:l,onRequestProjectRename:u,onArchiveProject:d,onRequestProjectRemove:f,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,excludedConversationIds:x,projectSort:S,onReorder:C}=e,w;t[0]!==x||t[1]!==n.sessions?(w=x?n.sessions.filter(e=>!x.has(e.key)):n.sessions,t[0]=x,t[1]=n.sessions,t[2]=w):w=t[2];let T=w,E;t[3]!==r||t[4]!==T?(E=r?T:T.slice(0,VV),t[3]=r,t[4]=T,t[5]=E):E=t[5];let D=E,O=T.length>VV,k=n.sessionHasMore||O,A=r&&!n.sessionHasMore&&O,j;t[6]===a?j=t[7]:(j=e=>e.key===a,t[6]=a,t[7]=j);let M=T.some(j),N=n.project.name,P=M?`text-fg`:`text-fg-muted`,F;t[8]===P?F=t[9]:(F=Y(`group flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-2 text-sm font-medium leading-5`,P),t[8]=P,t[9]=F);let I;t[10]!==n.project.id||t[11]!==s?(I=()=>s(n.project.id),t[10]=n.project.id,t[11]=s,t[12]=I):I=t[12];let L=!i,R;t[13]===i?R=t[14]:(R=i?(0,$.jsx)(qr,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Kr,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=i,t[14]=R);let z;t[15]===n.project.name?z=t[16]:(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.project.name}),t[15]=n.project.name,t[16]=z);let B;t[17]!==n.project.name||t[18]!==z||t[19]!==I||t[20]!==L||t[21]!==R?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 min-w-0 flex-1 items-center gap-1 text-left hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:I,title:n.project.name,"aria-expanded":L,children:[R,z]}),t[17]=n.project.name,t[18]=z,t[19]=I,t[20]=L,t[21]=R,t[22]=B):B=t[22];let V;t[23]!==n.project||t[24]!==d||t[25]!==p||t[26]!==f||t[27]!==u||t[28]!==l||t[29]!==_?(V=(0,$.jsx)(iH,{project:n.project,onNavigate:p,onPinToggle:l,onRequestRename:u,onArchive:d,onRequestRemove:f,sb:_}),t[23]=n.project,t[24]=d,t[25]=p,t[26]=f,t[27]=u,t[28]=l,t[29]=_,t[30]=V):V=t[30];let H;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[31]=H):H=t[31];let U;t[32]!==n.project||t[33]!==c?(U=()=>c(n.project),t[32]=n.project,t[33]=c,t[34]=U):U=t[34];let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(Ra,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=W):W=t[35];let ee;t[36]!==_.projectNewChat||t[37]!==U?(ee=(0,$.jsx)(`button`,{type:`button`,className:H,onClick:U,title:_.projectNewChat,"aria-label":_.projectNewChat,children:W}),t[36]=_.projectNewChat,t[37]=U,t[38]=ee):ee=t[38];let G;t[39]!==B||t[40]!==V||t[41]!==ee||t[42]!==F?(G=(0,$.jsxs)(`div`,{className:F,children:[B,V,ee]}),t[39]=B,t[40]=V,t[41]=ee,t[42]=F,t[43]=G):G=t[43];let K;t[44]!==a||t[45]!==k||t[46]!==y||t[47]!==b||t[48]!==n.project.id||t[49]!==n.sessionLoading||t[50]!==i||t[51]!==m||t[52]!==p||t[53]!==C||t[54]!==g||t[55]!==h||t[56]!==o||t[57]!==_||t[58]!==v||t[59]!==A||t[60]!==T||t[61]!==D?(K=i?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D.map(e=>(0,$.jsx)(rH,{session:e,isActive:a===e.key,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,sort:{containerId:`project:${n.project.id}`,itemId:e.key,itemIds:T.map(sH),onReorder:C}},e.key)),k?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:()=>o(n.project.id),disabled:n.sessionLoading,"aria-busy":n.sessionLoading||void 0,children:[n.sessionLoading?(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(gn,{className:Y(`size-3.5 transition-transform duration-150 ease-out`,A&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),A?_.projectShowLess:_.projectShowMore]}):null]}),t[44]=a,t[45]=k,t[46]=y,t[47]=b,t[48]=n.project.id,t[49]=n.sessionLoading,t[50]=i,t[51]=m,t[52]=p,t[53]=C,t[54]=g,t[55]=h,t[56]=o,t[57]=_,t[58]=v,t[59]=A,t[60]=T,t[61]=D,t[62]=K):K=t[62];let q;t[63]!==n.project.name||t[64]!==G||t[65]!==K?(q=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":N,children:[G,K]}),t[63]=n.project.name,t[64]=G,t[65]=K,t[66]=q):q=t[66];let te;return t[67]!==S||t[68]!==q?(te=(0,$.jsx)(KV,{spec:S,children:q}),t[67]=S,t[68]=q,t[69]=te):te=t[69],te}function sH(e){return e.key}function cH(e){let t=(0,Q.c)(49),{sessions:n,hasMore:r,loadingMore:i,isCollapsed:a,onToggleCollapsed:o,onCreateChat:s,onLoadMore:c,activeConversationId:l,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,excludedConversationIds:v,onReorder:y,sortable:b}=e,x=b===void 0||b,S;t[0]!==v||t[1]!==n?(S=v?n.filter(e=>!v.has(e.key)):n,t[0]=v,t[1]=n,t[2]=S):S=t[2];let C=S;if(C.length===0&&!r)return null;let w=m.inboxHeading,T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=Y(`flex min-w-0 flex-1 items-center gap-1 px-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,eH),t[3]=T):T=t[3];let E=!a,D=m.inboxHeading,O=a&&`-rotate-90`,k;t[4]===O?k=t[5]:(k=Y(`size-3.5 transition-transform duration-150 ease-out`,O),t[4]=O,t[5]=k);let A;t[6]===k?A=t[7]:(A=(0,$.jsx)(gn,{className:k,strokeWidth:1.75,"aria-hidden":!0}),t[6]=k,t[7]=A);let j;t[8]!==o||t[9]!==m.inboxHeading||t[10]!==E||t[11]!==A?(j=(0,$.jsxs)(`button`,{type:`button`,className:T,onClick:o,"aria-expanded":E,children:[D,A]}),t[8]=o,t[9]=m.inboxHeading,t[10]=E,t[11]=A,t[12]=j):j=t[12];let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Ra,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=N):N=t[14];let P;t[15]!==_||t[16]!==s?(P=(0,$.jsx)(`button`,{type:`button`,className:M,onClick:s,title:_,"aria-label":_,children:N}),t[15]=_,t[16]=s,t[17]=P):P=t[17];let F;t[18]!==j||t[19]!==P?(F=(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center pb-1`,children:[j,P]}),t[18]=j,t[19]=P,t[20]=F):F=t[20];let I=a&&`hidden`,L;t[21]===I?L=t[22]:(L=Y(`flex flex-col gap-0.5`,I),t[21]=I,t[22]=L);let R;t[23]!==l||t[24]!==g||t[25]!==_||t[26]!==d||t[27]!==u||t[28]!==y||t[29]!==p||t[30]!==f||t[31]!==m||t[32]!==h||t[33]!==x||t[34]!==C?(R=C.map(e=>(0,$.jsx)(rH,{session:e,isActive:l===e.key,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,sort:x?{containerId:`inbox`,itemId:e.key,itemIds:C.map(lH),onReorder:y}:void 0},e.key)),t[23]=l,t[24]=g,t[25]=_,t[26]=d,t[27]=u,t[28]=y,t[29]=p,t[30]=f,t[31]=m,t[32]=h,t[33]=x,t[34]=C,t[35]=R):R=t[35];let z;t[36]!==r||t[37]!==i||t[38]!==c||t[39]!==m.projectShowMore?(z=r?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:c,disabled:i,"aria-busy":i||void 0,children:[i?(0,$.jsx)(Hi,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(gn,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),m.projectShowMore]}):null,t[36]=r,t[37]=i,t[38]=c,t[39]=m.projectShowMore,t[40]=z):z=t[40];let B;t[41]!==L||t[42]!==R||t[43]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[41]=L,t[42]=R,t[43]=z,t[44]=B):B=t[44];let V;return t[45]!==m.inboxHeading||t[46]!==F||t[47]!==B?(V=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":w,children:[F,B]}),t[45]=m.inboxHeading,t[46]=F,t[47]=B,t[48]=V):V=t[48],V}function lH(e){return e.key}function uH(e){let t=(0,Q.c)(21),{sessions:n,activeConversationId:r,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,onReorder:f}=e;if(n.length===0)return null;let p=l.pinnedSessions,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`px-2 pb-1`,$V),t[0]=m):m=t[0];let h;t[1]===l.pinnedSessions?h=t[2]:(h=(0,$.jsx)(`h2`,{className:m,children:l.pinnedSessions}),t[1]=l.pinnedSessions,t[2]=h);let g;t[3]!==r||t[4]!==u||t[5]!==d||t[6]!==a||t[7]!==i||t[8]!==f||t[9]!==s||t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==n?(g=n.map(e=>(0,$.jsx)(rH,{session:e,isActive:r===e.key,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,sort:{containerId:`pinned`,itemId:e.key,itemIds:n.map(dH),onReorder:f}},e.key)),t[3]=r,t[4]=u,t[5]=d,t[6]=a,t[7]=i,t[8]=f,t[9]=s,t[10]=o,t[11]=c,t[12]=l,t[13]=n,t[14]=g):g=t[14];let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:g}),t[15]=g,t[16]=_);let v;return t[17]!==l.pinnedSessions||t[18]!==h||t[19]!==_?(v=(0,$.jsxs)(`section`,{className:`mb-3 flex flex-col gap-0.5`,"aria-label":p,children:[h,_]}),t[17]=l.pinnedSessions,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function dH(e){return e.key}function fH(e){let t=(0,Q.c)(4),{onNavigate:n,scrollHeader:r}=e,i=Ro(pH),a;return t[0]!==i||t[1]!==n||t[2]!==r?(a=(0,$.jsx)(mH,{gateway:i,onNavigate:n,scrollHeader:r},i),t[0]=i,t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function pH(e){return e.baseUrl}function mH({onNavigate:e,gateway:t,scrollHeader:n}){let r=zo(e=>e.language),i=Do(r),a=i.sidebar,o=i.sessions,s=i.projectsPage,c=i.chat.workingDirectory,l=Ro(e=>e.conversationId),u=jV(t,l),d=a.sessionFilters,f=(0,Z.useRef)(null),m=(0,Z.useRef)(0);(0,Z.useLayoutEffect)(()=>{f.current&&(f.current.scrollTop=u.active?0:m.current)},[u.active]);let h=Ro(e=>e.openTokenDialog),{data:g,mutate:_}=qo(l?[`gateway-chat-agents`,l]:null,du,{revalidateOnFocus:!1}),v=g?.defaultId??`main`;(0,Z.useEffect)(()=>{let e=()=>void _();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[_]);let{pathname:y}=p(),x=b(),S=JV(y),C=(0,Z.useMemo)(()=>Date.now()-HV*24*60*60*1e3,[]),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(null),[W,ee]=(0,Z.useState)(!1),[G,K]=(0,Z.useState)(!0),[q,te]=(0,Z.useState)(()=>S),[ne,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(()=>new Set),[ce,le]=(0,Z.useState)(()=>new Set),[ue,de]=(0,Z.useState)({}),[fe,pe]=(0,Z.useState)({}),[me,he]=(0,Z.useState)(()=>new Set),[ge,_e]=(0,Z.useState)([]),[ve,J]=(0,Z.useState)(null),[ye,be]=(0,Z.useState)(!1),[xe,Se]=(0,Z.useState)({}),Ce=(0,Z.useRef)(new Set),we=fu({initialPath:B,onPicked:V}),{data:Te,size:Ee,setSize:De,isValidating:Oe,mutate:ke}=Yo((e,t)=>!l||t&&!t.projects.hasMore?null:[`sidebar-chat-list`,l,q??``,e],async([,,e,t])=>Ws({projectLimit:BV,projectOffset:t*BV,sessionPreviewLimit:VV,inboxLimit:t===0?zV:1,inboxOffset:0,staleDays:HV,includeConversationId:e||void 0}),{keepPreviousData:!0,revalidateOnFocus:!1}),Ae=(0,Z.useMemo)(()=>{let e=Te??[],t=[],n=new Set;for(let r of e)for(let e of r.projects.items){if(n.has(e.project.id))continue;n.add(e.project.id);let r=ue[e.project.id],i=r?.sessions??e.sessions;t.push({project:e.project,sessions:i,sessionTotal:r?.sessionTotal??e.sessionTotal,sessionHasMore:r?.hasMore??e.sessionHasMore,sessionLoading:me.has(e.project.id)})}return GV(t.map(e=>({...e,sessions:GV(e.sessions,xe[`project:${e.project.id}`],e=>e.key)})),xe.projects,e=>e.project.id)},[Te,me,xe,ue]),je=(0,Z.useMemo)(()=>{let e={};for(let t of Te??[])Object.assign(e,t.childrenByConversationId);return{...e,...fe}},[Te,fe]),Me=Te?.[0]?.inbox,Ne=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of[...Me?.items??[],...ge])t.has(n.key)||(t.add(n.key),e.push(n));return e.sort((e,t)=>ZV(t)-ZV(e)),GV(e,xe.inbox??Te?.[0]?.layouts.inbox?.itemIds,e=>e.key)},[Te,Me?.items,ge,xe.inbox]),Pe=ve??Me?.hasMore??!1,Fe=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of Ae)for(let r of n.sessions)t.has(r.key)||(t.add(r.key),e.push(r));for(let n of Ne)t.has(n.key)||(t.add(n.key),e.push(n));return e},[Ne,Ae]),Ie=(0,Z.useMemo)(()=>new Set(Fe.map(e=>e.key)),[Fe]),Le=Ae.length>0||Ne.length>0,Re=(0,Z.useMemo)(()=>GV(Te?.[0]?.pinned??[],xe.pinned,e=>e.key),[Te,xe.pinned]),ze=(0,Z.useMemo)(()=>new Set(Re.map(e=>e.key)),[Re]),Be=!!(Te&&Ee>Te.length),Ve=(Te?.[Te.length-1])?.projects.hasMore??!1,He=!!(l&&!Te&&Oe),Ue=(0,Z.useCallback)(()=>{de({}),_e([]),J(null),pe({}),ke()},[ke]),We=(0,Z.useCallback)((e,t)=>{if(Ce.current.has(e))return;let n=Te?.[0]?.layouts[e]?.revision??0;Se(n=>({...n,[e]:t})),Ce.current.add(e),(async()=>{try{await Us({containerId:e,itemIds:t,expectedRevision:n}),await ke()}catch{ii(`warning`,r===`zh`?`未能保存侧栏顺序,已恢复原位置`:`Could not save sidebar order; the previous order was restored`,void 0,{duration:3500})}finally{Ce.current.delete(e),Se(t=>{let n={...t};return delete n[e],n})}})()},[Te,r,ke]),Ge=(0,Z.useCallback)(e=>{let t=e.currentTarget;if(u.active||(m.current=t.scrollTop,!Ve||Be))return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t;r-n-i>100||De(e=>e+1)},[u.active,Ve,Be,De]);(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{Ue()},t=e=>{if(!e.detail?.key){Ue();return}Ue()},n=e=>{FV(e.detail,Ie)&&Ue()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-created`,e),window.addEventListener(`project-updated`,e),window.addEventListener(`task-updated`,e),window.addEventListener(`session-transcript-updated`,n),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-created`,e),window.removeEventListener(`project-updated`,e),window.removeEventListener(`task-updated`,e),window.removeEventListener(`session-transcript-updated`,n)}},[l,Ue,Ie]),(0,Z.useEffect)(()=>{!l||!S||!Te||Fe.some(e=>e.key===S)||te(e=>e===S?e:S)},[S,Te,Fe,l]);let Ke=(0,Z.useCallback)(e=>{T(e.key),D(qV(e,i.chat.newSession))},[i.chat.newSession]),qe=async()=>{if(!w)return;let e=E.trim();if(e)try{await Gs(w,e),T(null),u.refresh(),Ue()}catch{}},Je=async e=>{try{await Ks(e),u.refresh(),S===e&&x(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),Ue()}catch{}},Ye=(0,Z.useCallback)(e=>{j(e.id),N(e.name.trim())},[]),Xe=async()=>{if(!A||!at)return;let e=M.trim();if(e)try{await Bs(A,e,at.version),j(null),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:A}}))}catch{}},Ze=(0,Z.useCallback)(async e=>{try{await Vs(e.id,e.version),y===`/projects/${encodeURIComponent(e.id)}`&&x(`/projects`),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[x,y,Ue]),Qe=(0,Z.useCallback)(async e=>{try{e.pinnedAt?await Fs(e.id,e.version):await Ls(e.id,e.version),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[Ue]),$e=async e=>{let t=e.id;try{await Rs(t,e.version),y===`/projects/${encodeURIComponent(t)}`&&x(`/projects`),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:t}}))}catch{}},et=(0,Z.useCallback)(e=>{let t=Ae.find(t=>t.project.id===e);if(t){if(ce.has(e)&&!t.sessionHasMore){le(t=>{let n=new Set(t);return n.delete(e),n});return}le(t=>{let n=new Set(t);return n.add(e),n}),!(!t.sessionHasMore||me.has(e))&&(he(t=>new Set(t).add(e)),(async()=>{try{let n=await Js({projectId:e,limit:5e3,offset:0,updatedAfter:C,includePinned:!0,includeConversationId:S,rootConversationsOnly:!0});pe(e=>({...e,...n.childrenByConversationId})),de(r=>{let i=r[e]?.sessions??t.sessions,a=new Set(i.map(e=>e.key)),o=[...i];for(let e of n.items)a.has(e.key)||(a.add(e.key),o.push(e));let s=GV(o,xe[`project:${e}`]??Te?.[0]?.layouts[`project:${e}`]?.itemIds,e=>e.key);return{...r,[e]:{sessions:s,sessionTotal:n.total,hasMore:!1}}})}finally{he(t=>{let n=new Set(t);return n.delete(e),n})}})())}},[S,Te,ce,me,xe,Ae,C]),tt=(0,Z.useCallback)(e=>{se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),nt=(0,Z.useCallback)(()=>{!Pe||ye||(be(!0),(async()=>{try{let e=await Js({unassigned:!0,limit:5e3,offset:0,updatedAfter:C,includePinned:!0,includeConversationId:S,rootConversationsOnly:!0});pe(t=>({...t,...e.childrenByConversationId})),_e(t=>{let n=new Set([...Me?.items??[],...t].map(e=>e.key)),r=[...t];for(let t of e.items)n.has(t.key)||(n.add(t.key),r.push(t));return GV(r,xe.inbox??Te?.[0]?.layouts.inbox?.itemIds,e=>e.key)}),J(!1)}finally{be(!1)}})())},[S,Te,Me?.items,Pe,ye,xe.inbox,C]),rt=(0,Z.useCallback)(t=>{x(kc(t.id),{state:{forceNewChat:!0,agentId:t.defaultAgentId??v}}),e?.()},[v,x,e]),it=(0,Z.useCallback)(async e=>{e.preventDefault();let t=R.trim(),n=B.trim();if(!(!t||!n||W)){ee(!0),U(null);try{let e=await zs({name:t,workspaceRoot:n,autoUnderstand:G});z(``),V(``),K(!0),L(!1),Ue(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){U(e instanceof Error?e.message:String(e))}finally{ee(!1)}}},[R,B,W,Ue,G]),at=A?Ae.find(e=>e.project.id===A)?.project:void 0,ot=P?Ae.find(e=>e.project.id===P)?.project:void 0;return l?(0,$.jsx)(IV,{value:u.filters.details,children:(0,$.jsx)(LV,{value:je,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{ref:f,className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,onScroll:Ge,children:[n,(0,$.jsx)(`div`,{hidden:u.active||He,className:`px-2`,children:(0,$.jsx)(uH,{sessions:Re,activeConversationId:S,onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,onReorder:We})}),(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center gap-1.5 px-2 pb-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex shrink-0 items-center gap-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,eH),onClick:()=>re(e=>!e),"aria-expanded":!ne,children:[a.projectsHeading,(0,$.jsx)(gn,{className:Y(`size-3.5 transition-transform duration-150 ease-out`,ne&&`-rotate-90`),strokeWidth:1.75,"aria-hidden":!0})]}),(0,$.jsx)(DV,{filters:u.filters,onChange:u.updateFilters,search:u.search,onSearch:u.setSearch,labels:d,gateway:t,agents:g?.items??[]}),(0,$.jsx)(`button`,{type:`button`,className:Y(`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-subtle opacity-0 transition-[color,background-color,opacity] hover:bg-surface-hover hover:text-fg focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,I&&`opacity-100`),onClick:()=>L(!0),"aria-label":s.createTitle,title:s.createTitle,children:(0,$.jsx)(Ra,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0})})]})}),u.active?(0,$.jsxs)(`div`,{className:`px-2 py-2`,children:[u.pendingUpdate?(0,$.jsx)(`button`,{type:`button`,className:`mb-2 w-full rounded-md px-2 py-1 text-xs text-accent-fg hover:bg-surface-hover`,onClick:u.refresh,children:d.refresh}):null,u.error?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:d.error}),(0,$.jsx)(X,{variant:`secondary`,onClick:u.refresh,children:d.retry})]}):u.loading?(0,$.jsx)(nH,{}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs text-fg-muted`,"aria-live":`polite`,children:d.results.replace(`{{count}}`,String(u.total))}),u.items.length?null:(0,$.jsx)(`p`,{className:`px-2 py-4 text-xs text-fg-muted`,children:d.empty}),(0,$.jsx)(IV,{value:!0,children:u.items.map(t=>(0,$.jsx)(rH,{session:t,isActive:t.key===S,showTaskChildren:!1,contextLabel:t.projectId?u.projects?.find(e=>e.id===t.projectId)?.name??Ae.find(e=>e.project.id===t.projectId)?.project.name??t.projectId:d.unassigned,onNavigate:e,mutate:()=>{u.refresh(),Ue()},onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession},t.key))}),u.loadingMore?(0,$.jsx)(tH,{}):u.hasMore?(0,$.jsx)(`button`,{type:`button`,className:`w-full rounded-md py-2 text-xs text-fg-muted hover:bg-surface-hover`,onClick:u.loadMore,children:d.more}):null]})]}):null,(0,$.jsxs)(`div`,{hidden:u.active,children:[He?(0,$.jsx)(nH,{}):Le?(0,$.jsxs)(`div`,{className:`flex flex-col px-2`,children:[Ae.length>0?(0,$.jsx)(`div`,{className:`pb-1`,children:ne?null:Ae.map(t=>(0,$.jsx)(oH,{group:t,isExpanded:ce.has(t.project.id),isCollapsed:oe.has(t.project.id),activeConversationId:S,onToggleExpanded:et,onToggleCollapsed:tt,onCreateProjectChat:e=>void rt(e),onToggleProjectPin:e=>void Qe(e),onRequestProjectRename:Ye,onArchiveProject:e=>void Ze(e),onRequestProjectRemove:e=>F(e.id),onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:ze,projectSort:{containerId:`projects`,itemId:t.project.id,itemIds:Ae.map(e=>e.project.id),onReorder:We},onReorder:We},t.project.id))}):null,(0,$.jsx)(cH,{sessions:Ne.filter(e=>ba(e).source!==`system`),hasMore:Pe,loadingMore:ye,isCollapsed:ie,onToggleCollapsed:()=>ae(e=>!e),onCreateChat:()=>{x(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),e?.()},onLoadMore:nt,activeConversationId:S,onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:ze,onReorder:We}),Ne.some(e=>ba(e).source===`system`)?(0,$.jsxs)(`details`,{className:`mt-3`,open:Ne.some(e=>e.key===S&&ba(e).source===`system`),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-2 py-2 text-xs text-fg-muted`,children:r===`zh`?`系统活动`:`System activity`}),(0,$.jsx)(cH,{sessions:Ne.filter(e=>ba(e).source===`system`),hasMore:!1,loadingMore:ye,isCollapsed:!1,onToggleCollapsed:()=>void 0,onCreateChat:()=>{x(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),e?.()},onLoadMore:nt,activeConversationId:S,onNavigate:e,mutate:Ue,onRequestRename:Ke,onRequestDelete:k,sb:a,sess:o,clipboard:i.clipboard,defaultUnnamedTitle:i.chat.newSession,excludedConversationIds:ze,onReorder:We,sortable:!1})]}):null]}):(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-3 text-xs leading-relaxed text-fg-muted`,children:a.taskListEmpty})}),Be?(0,$.jsx)(`div`,{className:`flex justify-center py-2`,"aria-busy":!0,children:(0,$.jsx)(Hi,{className:`size-4 animate-spin text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})}):null]})]}),(0,$.jsx)(us,{open:I,onOpenChange:e=>{W||(L(e),e||U(null))},children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(30rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:s.createTitle}),(0,$.jsx)(as,{className:`mt-1 text-sm text-fg-muted`,children:s.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:it,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[s.projectName,(0,$.jsx)(`input`,{autoFocus:!0,className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:R,onChange:e=>z(e.target.value),maxLength:160})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:s.workspaceRoot}),(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:we.pick,disabled:W||we.picking,children:[we.picking?(0,$.jsx)(Hi,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,$.jsx)(Kr,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:B?c.chooseFolder:c.selectWorkingDirectory}),(0,$.jsx)(`span`,{className:Y(`mt-0.5 block truncate font-mono text-xs font-normal`,B?`text-fg-muted`:`text-fg-subtle`),title:B||void 0,children:B||s.workspaceSelectionPlaceholder})]})]}),(0,$.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:s.workspaceSelectionHint})]}),(0,$.jsx)(lu,{checked:G,onChange:K,disabled:W}),H?(0,$.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:H}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(os,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:W,children:s.cancel})}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:W||!R.trim()||!B.trim(),children:W?s.home.creating:s.create})]})]})]})]})}),we.hasNativePicker?null:(0,$.jsx)(Sn,{open:we.modalOpen,onOpenChange:we.setModalOpen,initialAbsolutePath:B||void 0,onConfirm:we.confirmPick,wd:c}),(0,$.jsx)(us,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:a.taskRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-rename-input`,children:a.taskRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-rename-input`,type:`text`,value:E,onChange:e=>D(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,ul,`dark:border-edge`),placeholder:i.chat.newSession,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),qe())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>T(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void qe(),disabled:!E.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(us,{open:O!==null,onOpenChange:e=>!e&&k(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:o.deleteSessionTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:O?YV(o.deleteSessionMessage,{name:Fe.find(e=>e.key===O)?.name?.trim()||i.chat.newSession}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>k(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{O&&Je(O),k(null)},children:o.delete})]})]})]})}),(0,$.jsx)(us,{open:A!==null,onOpenChange:e=>!e&&j(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:a.projectRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-project-rename-input`,children:a.projectRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-project-rename-input`,type:`text`,value:M,onChange:e=>N(e.target.value),className:Y(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,ul,`dark:border-edge`),placeholder:at?.name??``,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Xe())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>j(null),children:a.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void Xe(),disabled:!M.trim(),children:a.taskRenameSave})]})]})]})}),(0,$.jsx)(us,{open:P!==null,onOpenChange:e=>!e&&F(null),children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:a.projectRemoveTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:ot?YV(a.projectRemoveMessage,{name:ot.name}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>F(null),children:o.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{ot&&$e(ot),F(null)},children:a.projectRemove})]})]})]})})]})})}):(0,$.jsxs)(`div`,{className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-2`,children:[n,(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 px-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.taskListNeedToken}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`mt-3 h-8 w-full text-xs font-medium`,onClick:()=>{h(),e?.()},children:a.taskListAddToken})]})})]})}var hH=42,gH=1,_H=4,vH=3,yH=`xopc-web-sidebar-visible-app-count-v2`;function bH(e){return Math.min(_H,Math.max(gH,e))}function xH(){try{let e=Number.parseInt(globalThis.localStorage?.getItem(yH)??``,10);return Number.isFinite(e)?bH(e):vH}catch{return vH}}function SH({onNavigate:e,collapsed:t=!1}){let n=Do(zo(e=>e.language)),[r,i]=(0,Z.useState)(xH),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{try{globalThis.localStorage?.setItem(yH,String(r))}catch{}},[r]);function o(e){e.preventDefault(),a.current={clientY:e.clientY,visibleCount:r},e.currentTarget.setPointerCapture(e.pointerId)}function s(e){let t=a.current;if(!t)return;let n=Math.round((e.clientY-t.clientY)/hH);i(bH(t.visibleCount+n))}function c(e){a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}function l(e){e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),i(e=>bH(e+1))):e.key===`ArrowUp`||e.key===`ArrowLeft`?(e.preventDefault(),i(e=>bH(e-1))):e.key===`Home`?(e.preventDefault(),i(gH)):e.key===`End`&&(e.preventDefault(),i(_H))}return(0,$.jsxs)(`div`,{className:`app-sidebar-content flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(`div`,{className:Y(`flex min-h-0 flex-1 flex-col overflow-hidden`,t&&`hidden`),"aria-hidden":t?!0:void 0,children:(0,$.jsx)(fH,{onNavigate:e,scrollHeader:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`app-sidebar-sticky-surface sticky top-0 z-20 px-4 pt-1.5 pb-0.5`,children:(0,$.jsxs)(y,{to:`/chat/new`,state:{forceNewChat:!0},className:Y(`flex w-full items-center gap-2 rounded-lg px-3 py-2.5 text-left text-sm font-medium leading-6 transition-colors duration-200 ease-out md:py-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`text-fg-muted hover:bg-surface-hover hover:text-fg`),title:n.sidebar.newTask,onClick:()=>e?.(),children:[(0,$.jsx)(Ra,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:n.sidebar.newTask})]})}),(0,$.jsx)(`nav`,{className:`px-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(aV,{onNavigate:e,visibleLimit:r})})}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":n.sidebar.resizeApps,"aria-valuemin":gH,"aria-valuemax":_H,"aria-valuenow":r,tabIndex:0,className:`group flex h-3 touch-none cursor-row-resize items-center px-4 focus-visible:outline-none`,title:n.sidebar.resizeApps,onPointerDown:o,onPointerMove:s,onPointerUp:c,onPointerCancel:c,onKeyDown:l,children:(0,$.jsx)(`span`,{className:`h-px w-full bg-transparent transition-colors group-hover:bg-edge group-focus-visible:bg-accent`})}),(0,$.jsx)(`div`,{className:`h-2`,"aria-hidden":!0})]})})}),t?(0,$.jsx)(`nav`,{className:`min-h-0 flex-1 overflow-y-auto px-1.5 pb-2 pt-4`,"aria-label":`Main`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(aV,{collapsed:!0,onNavigate:e,visibleLimit:vH})})}):null,(0,$.jsx)(QB,{collapsed:t,onNavigate:e})]})}var CH=`(min-width: 768px)`,wH=(0,Z.memo)(function(){let e=(0,Q.c)(42),t=zo(TH),n;e[0]===t?n=e[1]:(n=Do(t),e[0]=t,e[1]=n);let r=n,i=le(EH),a=le(DH),o=le(OH),s=ge(kH),c=ge(AH),[l,u]=(0,Z.useState)(!1),d=ve({runtime:fe(),sidebarCollapsed:i,mobileNavOpen:s}),f;e[2]!==o||e[3]!==i?(f=e=>{if(i)return;e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),u(!0);let r=e.clientX,a=le.getState().expandedWidthPx,s=e.pointerId,c=0,l=a,d=a,f=()=>{c=0,d=l,n?.style.setProperty(`--sidebar-expanded-px`,`${d}px`)},p=e=>{l=oe(a+(e.clientX-r)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(s)}catch{}u(!1),o(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},e[2]=o,e[3]=i,e[4]=f):f=e[4];let p=f,m,h;e[5]===c?(m=e[6],h=e[7]):(m=()=>{let e=e=>{e.key===`Escape`&&c(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[c],e[5]=c,e[6]=m,e[7]=h),(0,Z.useEffect)(m,h);let g,_;e[8]===c?(g=e[9],_=e[10]):(g=()=>{let e=window.matchMedia(CH),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},_=[c],e[8]=c,e[9]=g,e[10]=_),(0,Z.useEffect)(g,_);let v,y;e[11]===s?(v=e[12],y=e[13]):(v=()=>{if(!s||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},y=[s],e[11]=s,e[12]=v,e[13]=y),(0,Z.useEffect)(v,y);let b;e[14]!==r||e[15]!==s||e[16]!==c?(b=s?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":r.closeMenu,onClick:()=>c(!1)}):null,e[14]=r,e[15]=s,e[16]=c,e[17]=b):b=e[17];let x=l&&`sidebar-width-resizing`,S=s?`max-md:translate-x-0`:`max-md:-translate-x-full`,C=i?`md:w-0 md:overflow-hidden md:border-0`:`app-sidebar-expanded-width`,w;e[18]!==x||e[19]!==S||e[20]!==C?(w=Y(`app-sidebar-push app-chrome-sidebar flex min-h-0 shrink-0 flex-col overflow-hidden bg-transparent`,x,`max-md:fixed max-md:left-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:w-[min(16rem,85vw)]`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,S,`md:relative md:h-full md:translate-x-0`,C),e[18]=x,e[19]=S,e[20]=C,e[21]=w):w=e[21];let T=i&&!s?!0:void 0,E=i&&!s?!0:void 0,D;e[22]!==a||e[23]!==i?(D=i?void 0:{"--sidebar-expanded-px":`${a}px`},e[22]=a,e[23]=i,e[24]=D):D=e[24];let O=d.sidebarChromeVisible?(0,$.jsxs)(`div`,{className:Y(`sidebar-chrome-row flex min-w-0`,cl,d.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,d.sidebarLeadingInsetClass,i?`justify-center gap-1 px-1.5 max-md:flex`:Y(`justify-start gap-1`,d.sidebarLeadingInsetClass?`sidebar-chrome-row-darwin pr-3`:`px-3`),i&&`md:hidden`),children:[s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-8 shrink-0 rounded-xl p-0 md:hidden`,sl),"aria-label":r.closeMenu,title:r.closeMenu,onClick:()=>c(!1),children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,d.sidebarQuickActionsVisible&&!i?(0,$.jsx)(qz,{sidebarToggleVariant:`sidebar`,className:`overflow-hidden`}):null]}):null,k;e[25]===c?k=e[26]:(k=(0,$.jsx)(SH,{collapsed:!1,onNavigate:()=>c(!1)}),e[25]=c,e[26]=k);let A;e[27]!==r||e[28]!==p||e[29]!==i?(A=i?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r.sidebar.resizeHandleAria,onPointerDown:p,className:Y(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`touch-none select-none`,sl)}),e[27]=r,e[28]=p,e[29]=i,e[30]=A):A=e[30];let j;e[31]!==w||e[32]!==T||e[33]!==E||e[34]!==D||e[35]!==O||e[36]!==k||e[37]!==A?(j=(0,$.jsxs)(`aside`,{id:`app-sidebar`,className:w,"aria-hidden":T,"data-collapsed":E,style:D,children:[O,k,A]}),e[31]=w,e[32]=T,e[33]=E,e[34]=D,e[35]=O,e[36]=k,e[37]=A,e[38]=j):j=e[38];let M;return e[39]!==j||e[40]!==b?(M=(0,$.jsxs)($.Fragment,{children:[b,j]}),e[39]=j,e[40]=b,e[41]=M):M=e[41],M});function TH(e){return e.language}function EH(e){return e.collapsed}function DH(e){return e.expandedWidthPx}function OH(e){return e.setExpandedWidthPx}function kH(e){return e.mobileNavOpen}function AH(e){return e.setMobileNavOpen}function jH(e){if(typeof e!=`string`||e.length>8192)throw Error(`Invalid browser URL`);let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password)throw Error(`Use an HTTP or HTTPS address without embedded credentials`);return t.href}function MH(e,t){let n=e.trim();if(!n)return null;if(/^https?:\/\//i.test(n))return jH(n);if(/^(localhost|127(?:\.\d+){3}|\[::1\])(?::\d+)?(?:[/?#]|$)/i.test(n))return jH(`http://${n}`);if(!/\s/.test(n)&&/^(?:[\w-]+\.)+[\w-]+(?::\d+)?(?:[/?#]|$)/i.test(n))return jH(`https://${n}`);if(/^[a-z][a-z\d+.-]*:/i.test(n))throw Error(`Only HTTP and HTTPS addresses are supported`);return t?{google:`https://www.google.com/search?q=`,bing:`https://www.bing.com/search?q=`,duckduckgo:`https://duckduckgo.com/?q=`}[t]+encodeURIComponent(n):null}var NH=Vo(e=>({tabs:{},update:t=>e(e=>({tabs:{...e.tabs,[t.workspaceTabId]:t}}))}));async function PH(e){let t=NH.getState().tabs[e];return t&&window.electronAPI?.browser&&!await window.electronAPI.browser.close(t.id)?!1:(NH.setState(t=>({tabs:Object.fromEntries(Object.entries(t.tabs).filter(([t])=>t!==e))})),!0)}Ro.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||t.conversationId&&e.conversationId!==t.conversationId)&&(NH.setState({tabs:{}}),window.electronAPI?.browser?.release().catch(()=>{}))});function FH(e,t,n){let r=(0,Q.c)(5),i,a;r[0]!==t||r[1]!==e||r[2]!==n?(i=()=>{let r=window.electronAPI?.browser,i=e.current;if(!r||!t||!i)return;let a=0,o=``,s=!1,c=()=>{if(a=0,s)return;let e=[...document.querySelectorAll(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], [data-browser-occluder]`)].some(BH),l=[i.closest(`[data-right-workspace]`),i.closest(`[role="tabpanel"]`)].filter(Boolean).some(RH),u=i.getBoundingClientRect(),d=n&&!e&&!l&&i.getClientRects().length>0&&document.visibilityState===`visible`?{x:u.x,y:u.y,width:u.width,height:u.height}:null,f=JSON.stringify(d);f!==o&&(o=f,r.present(t,d).catch(LH)),l&&(a=requestAnimationFrame(c))},l=()=>{a||=requestAnimationFrame(c)},u=new ResizeObserver(l);u.observe(i);let d=new MutationObserver(l);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`,`aria-hidden`,`data-state`]});let f=()=>{o=``,l()};return window.addEventListener(`focus`,f),window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0),document.addEventListener(`visibilitychange`,l),l(),()=>{s=!0,cancelAnimationFrame(a),u.disconnect(),d.disconnect(),window.removeEventListener(`focus`,f),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),document.removeEventListener(`visibilitychange`,l),r.present(t,null).catch(IH)}},a=[t,e,n],r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,Z.useLayoutEffect)(i,a)}function IH(){}function LH(){}function RH(e){return e.getAnimations().some(zH)}function zH(e){return e.playState===`running`}function BH(e){return e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`}function VH(e){let t=(0,Q.c)(94),{tab:n,scope:r,active:i}=e,a=(0,Z.useContext)(ai),o=zo(UH)===`zh`,s=Ro(HH),c;t[0]===n.id?c=t[1]:(c=e=>e.tabs[n.id],t[0]=n.id,t[1]=c);let l=NH(c),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(n.initialUrl??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(!1),S=window.electronAPI?.browser,C,w;t[2]!==s||t[3]!==r||t[4]!==n.id||t[5]!==n.initialUrl?(C=()=>{if(!S||!s)return;let e=!1;return S.ensure({workspaceTabId:n.id,scope:r,identity:s}).then(async t=>{if(e){Object.values(ns.getState().panes).some(e=>e.tabs.some(e=>e.id===n.id))||await S.close(t.id);return}NH.getState().update(t),!t.url&&n.initialUrl&&await S.navigate(t.id,n.initialUrl)}).catch(t=>{e||_(String(t.message??t))}),()=>{e=!0}},w=[S,s,r,n.id,n.initialUrl],t[2]=s,t[3]=r,t[4]=n.id,t[5]=n.initialUrl,t[6]=C,t[7]=w):(C=t[6],w=t[7]),(0,Z.useEffect)(C,w);let T;t[8]!==m||t[9]!==l?(T=()=>{!m&&l?.url&&p(l.url)},t[8]=m,t[9]=l,t[10]=T):T=t[10];let E=l?.url,D;t[11]!==m||t[12]!==E?(D=[m,E],t[11]=m,t[12]=E,t[13]=D):D=t[13],(0,Z.useEffect)(T,D),FH(u,l?.id,i&&!!l?.url&&!l?.error&&!l?.crashed&&!b);let O,k;t[14]!==i||t[15]!==n.id?(O=()=>{if(!i)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),d.current?.focus(),d.current?.select())},t=e=>{e.detail===n.id&&(d.current?.focus(),d.current?.select())};return window.addEventListener(`browser-focus-address`,t),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`browser-focus-address`,t)}},k=[i,n.id],t[14]=i,t[15]=n.id,t[16]=O,t[17]=k):(O=t[16],k=t[17]),(0,Z.useEffect)(O,k);let A;t[18]!==f||t[19]!==v||t[20]!==l?(A=async function(e){let t=e===void 0?v:e;if(!(!S||!l))try{let e=MH(f,t);if(!e){x(!!f.trim());return}x(!1),_(``),h(!1),await S.navigate(l.id,e)}catch(e){let t=e;_(t instanceof Error?t.message:String(t))}},t[18]=f,t[19]=v,t[20]=l,t[21]=A):A=t[21];let j=A,M;t[22]===l?M=t[23]:(M=function(e){!S||!l||(_(``),S.command(l.id,e).catch(e=>_(e instanceof Error?e.message:String(e))))},t[22]=l,t[23]=M);let N=M;if(!i){let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{ref:u,hidden:!0}),t[24]=e):e=t[24],e}let P;t[25]===j?P=t[26]:(P=e=>{e.preventDefault(),j()},t[25]=j,t[26]=P);let F=o?`网页后退`:`Browser back`,I=!l?.canGoBack,L;t[27]===N?L=t[28]:(L=()=>N(`back`),t[27]=N,t[28]=L);let R;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(_t,{className:`size-4`}),t[29]=R):R=t[29];let z;t[30]!==F||t[31]!==I||t[32]!==L?(z=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":F,disabled:I,onClick:L,children:R}),t[30]=F,t[31]=I,t[32]=L,t[33]=z):z=t[33];let B=o?`网页前进`:`Browser forward`,V=!l?.canGoForward,H;t[34]===N?H=t[35]:(H=()=>N(`forward`),t[34]=N,t[35]=H);let U;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(vt,{className:`size-4`}),t[36]=U):U=t[36];let W;t[37]!==B||t[38]!==V||t[39]!==H?(W=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":B,disabled:V,onClick:H,children:U}),t[37]=B,t[38]=V,t[39]=H,t[40]=W):W=t[40];let ee=l?.loading?o?`停止加载网页`:`Stop loading page`:o?`刷新网页`:`Reload page`,G=!l?.url&&!l?.loading,K;t[41]!==N||t[42]!==l?.loading?(K=()=>N(l?.loading?`stop`:`reload`),t[41]=N,t[42]=l?.loading,t[43]=K):K=t[43];let q;t[44]===l?.loading?q=t[45]:(q=l?.loading?(0,$.jsx)(wo,{className:`size-4`}):(0,$.jsx)(Ka,{className:`size-4`}),t[44]=l?.loading,t[45]=q);let te;t[46]!==ee||t[47]!==G||t[48]!==K||t[49]!==q?(te=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":ee,disabled:G,onClick:K,children:q}),t[46]=ee,t[47]=G,t[48]=K,t[49]=q,t[50]=te):te=t[50];let ne=o?`搜索或输入网址`:`Search or enter a URL`,re,ie,ae;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>h(!0),ie=()=>h(!1),ae=e=>p(e.target.value),t[51]=re,t[52]=ie,t[53]=ae):(re=t[51],ie=t[52],ae=t[53]);let oe=o?`搜索或输入网址`:`Search or enter a URL`,se;t[54]!==f||t[55]!==ne||t[56]!==oe?(se=(0,$.jsx)(`input`,{ref:d,"aria-label":ne,autoComplete:`off`,spellCheck:!1,value:f,onFocus:re,onBlur:ie,onChange:ae,placeholder:oe,className:`h-9 min-w-0 flex-1 rounded-full border border-edge-subtle bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`}),t[54]=f,t[55]=ne,t[56]=oe,t[57]=se):se=t[57];let ce=a?.button,le=o?`在系统浏览器打开`:`Open in system browser`,ue=!l?.url,de;t[58]===l?de=t[59]:(de=()=>{l?.url&&window.electronAPI?.shell?.openExternalUrl(l.url).catch(e=>_(e instanceof Error?e.message:String(e)))},t[58]=l,t[59]=de);let fe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(br,{className:`size-4`}),t[60]=fe):fe=t[60];let pe;t[61]!==le||t[62]!==ue||t[63]!==de?(pe=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-30`,"aria-label":le,disabled:ue,onClick:de,children:fe}),t[61]=le,t[62]=ue,t[63]=de,t[64]=pe):pe=t[64];let me;t[65]!==P||t[66]!==z||t[67]!==W||t[68]!==te||t[69]!==se||t[70]!==ce||t[71]!==pe?(me=(0,$.jsxs)(`form`,{"data-workspace-toolbar":!0,className:`flex h-14 shrink-0 items-center gap-1 bg-surface-inset px-2`,onSubmit:P,children:[z,W,te,se,ce,pe]}),t[65]=P,t[66]=z,t[67]=W,t[68]=te,t[69]=se,t[70]=ce,t[71]=pe,t[72]=me):me=t[72];let he;t[73]===g?he=t[74]:(he=g?(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:g}):null,t[73]=g,t[74]=he);let ge;t[75]===l?ge=t[76]:(ge=l?.notice?(0,$.jsx)(`p`,{role:`status`,className:`border-b border-edge px-3 py-2 text-xs text-fg-muted`,children:l.notice}):null,t[75]=l,t[76]=ge);let _e;t[77]!==b||t[78]!==j||t[79]!==o?(_e=b?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":o?`选择搜索引擎`:`Choose a search engine`,className:`border-b border-edge p-4 text-sm`,children:[(0,$.jsx)(`p`,{children:o?`选择搜索引擎后才会提交这次搜索。`:`Choose where to send this search.`}),(0,$.jsxs)(`div`,{className:`mt-3 flex gap-3`,children:[[`duckduckgo`,`google`,`bing`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 hover:bg-surface-hover`,onClick:()=>{y(e),j(e)},children:e===`duckduckgo`?`DuckDuckGo`:e===`google`?`Google`:`Bing`},e)),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(!1),children:o?`取消`:`Cancel`})]})]}):null,t[77]=b,t[78]=j,t[79]=o,t[80]=_e):_e=t[80];let ve;t[81]!==N||t[82]!==g||t[83]!==l||t[84]!==o?(ve=!l&&g?(0,$.jsx)(`div`,{className:`p-8 text-sm text-fg-muted`,children:o?`无法创建浏览器标签。关闭其他网页后重试。`:`Browser tab could not be created. Close another page and try again.`}):l?l.error?(0,$.jsxs)(`div`,{role:`alert`,className:`p-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.error}),(0,$.jsx)(`button`,{type:`button`,className:`mt-4 text-accent`,onClick:()=>N(`reload`),children:o?`重试`:`Retry`})]}):l.url?null:(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center text-fg-muted`,children:[(0,$.jsx)(ci,{className:`size-9`}),(0,$.jsx)(`h2`,{className:`text-lg text-fg`,children:o?`浏览网页`:`Browse the web`}),(0,$.jsx)(`p`,{className:`text-sm`,children:o?`输入网址开始。网页内容不会自动发送到聊天。`:`Enter an address to begin. Pages are not automatically shared with chat.`})]}):(0,$.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,$.jsx)(Xo,{className:`h-8 w-2/3`}),(0,$.jsx)(Xo,{className:`h-40 w-full`})]}),t[81]=N,t[82]=g,t[83]=l,t[84]=o,t[85]=ve):ve=t[85];let J;t[86]===ve?J=t[87]:(J=(0,$.jsx)(`div`,{ref:u,className:`relative min-h-0 flex-1 overflow-hidden bg-surface-base`,"data-browser-surface":!0,children:ve}),t[86]=ve,t[87]=J);let ye;return t[88]!==me||t[89]!==he||t[90]!==ge||t[91]!==_e||t[92]!==J?(ye=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-browser-tab":!0,children:[me,he,ge,_e,J]}),t[88]=me,t[89]=he,t[90]=ge,t[91]=_e,t[92]=J,t[93]=ye):ye=t[93],ye}function HH(e){return e.conversationId}function UH(e){return e.language}function WH(){let e=(0,Q.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(GH,t)}function GH(){return window.electronAPI?.browser?.onEvent(KH)}function KH(e){if(e.kind===`state`)NH.getState().update(e.state),ns.getState().updateBrowserTitle(e.state.workspaceTabId,e.state.title);else if(e.kind===`focus-address`)window.dispatchEvent(new CustomEvent(`browser-focus-address`,{detail:e.workspaceTabId}));else{let t=ns.getState();Object.values(t.panes).flatMap(JH).filter(qH).length<24&&t.openBrowser(e.url,e.scope,e.sourceTabId)}}function qH(e){return e.kind===`browser`}function JH(e){return e.tabs}var YH=(0,Z.memo)(function({elevated:e=!1,embedded:t=!1,scope:n,onCloseTree:r}){let i=Do(zo(e=>e.language)),{pathname:a,search:o}=p(),{conversationId:s}=d(),c=a.startsWith(`/chat`)&&s&&s!==`new`?decodeURIComponent(s):null,l=re(e=>e.open),u=t||l,f=(0,Z.useRef)(u),m=re(e=>e.setOpen),h=(0,Z.useCallback)(e=>{t?e||r?.():m(e)},[t,r,m]),g=re(e=>e.conversationIdOverride),_=re(e=>e.widthPx),v=re(e=>e.setWidthPx),y=n?n.conversationId??null:g??c,b=n?n.projectId??null:!y&&a.startsWith(`/chat`)?new URLSearchParams(o).get(`projectId`):null,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)([]),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),L=Ec(e=>e.path),R=Ec(e=>e.setPath),z=(0,Z.useCallback)(e=>{R(e,null,b,y)},[y,R,b]),B=Eu(e=>e.agentId),V=n?.agentId??B,{tree:H,rootResource:U,loading:W,error:ee,loadRoot:G,loadChildren:K,refreshDirectory:q,reset:te}=Tu(V,y,b),ne=y?`session:${y}`:b?`project:${b}`:`agent:${V}`,ie=(0,Z.useMemo)(()=>b?{projectId:b}:y==null?V.trim()?{agentId:V.trim()}:void 0:{conversationId:y},[y,b,V]),ae=T.trim(),oe=Ol(),se=(0,Z.useCallback)((e,t)=>{ft(e.dataTransfer,{name:t.name,path:t.path,...ie})},[ie]),{dialogOpen:ce,loading:le,result:ue,error:de,pendingParams:fe,createShareLink:pe,confirmShareLink:me,handleOpenChange:he}=Qo(),ge=(0,Z.useCallback)(e=>{if(!u)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),S(!0);let r=e.clientX,i=re.getState().widthPx,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n?.style.setProperty(`--workspace-panel-px`,`${c}px`)},d=e=>{s=J(i+(r-e.clientX)),o===0&&(o=window.requestAnimationFrame(l))},f=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}S(!1),v(c),window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[u,v]);(0,Z.useEffect)(()=>{!t&&!a.startsWith(`/chat`)&&h(!1)},[t,a,h]),(0,Z.useEffect)(()=>{let e=f.current;if(f.current=u,!u){te(),e&&!t&&z(null);return}t||z(null),G()},[t,u,ne,G,te,z]),(0,Z.useEffect)(()=>{if(!u||t)return;let e=e=>{if(e.key===`Escape`){if(C){e.preventDefault(),e.stopPropagation(),E(``),w(!1);return}Ec.getState().path||h(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,C,u,h]),(0,Z.useEffect)(()=>{if(!u||!t&&!C||!ae){O([]),A(!1),M(null);return}let e=!1;A(!0),M(null),O([]);let n=window.setTimeout(()=>{_u(ae,ie,50).then(t=>{e||O(t)}).catch(t=>{e||M(t instanceof Error?t.message:String(t))}).finally(()=>{e||A(!1)})},180);return()=>{e=!0,window.clearTimeout(n)}},[t,C,ae,u,ie]),(0,Z.useEffect)(()=>{if(!u||t||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[t,u]);let _e=(0,Z.useCallback)(e=>{K(e)},[K]),ve=(0,Z.useCallback)(async(e,t,n)=>{switch(e){case`preview`:if(t.isDirectory)return;z(t.path);break;case`download`:if(t.isDirectory)return;try{let e=ei(t.path);if($r(ti(e))!==`text`)vu(e,await(await hu(t.path,ie)).arrayBuffer(),Hc(e)??`application/octet-stream`);else{let{content:n}=await gu(t.path,ie);bu(e,n)}}catch{}break;case`copyPath`:try{await xc(t.path)&&ii(`success`,i.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:await Su(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWith`:await Su(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),i.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await Su(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),i.workspace.openFileFailed);break;case`revealInFolder`:await Su(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),i.workspace.revealFileFailed);break;case`trash`:P(t);break;case`delete`:t.isDirectory||I(t);break;case`share`:await pe({path:t.path,...t.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...ie});break;default:break}},[pe,i.workspace.openFileFailed,i.workspace.pathCopied,i.workspace.revealFileFailed,z,ie]),ye=(0,Z.useCallback)(async()=>{let e=N;if(!e)return;let n=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!n?.ok){ii(`warning`,n?.error??i.workspace.trashFailed,void 0,{duration:4e3});return}!t&&L===e.path&&z(null),P(null),await G(),ii(`success`,i.workspace.trashSuccess,void 0,{duration:2500})},[t,G,i.workspace.trashFailed,i.workspace.trashSuccess,N,L,z]),be=(0,Z.useCallback)(async(e,t)=>{try{await Promise.all(e.map(e=>yu(e,t,ie))),await q(t).catch(()=>void 0),ii(`success`,i.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await q(t).catch(()=>void 0),ii(`warning`,`${i.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[i.workspace.uploadFailed,i.workspace.uploadSuccess,q,ie]),xe=(0,Z.useCallback)(async()=>{let e=F;if(e)try{await xu(e.fileId),!t&&L===e.path&&z(null),I(null);let n=e.path.lastIndexOf(`/`);await q(n<0?``:e.path.slice(0,n)).catch(()=>void 0),ii(`success`,i.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){ii(`warning`,`${i.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[t,i.workspace.deleteFailed,i.workspace.deleteSuccess,F,L,q,z]);return(0,$.jsxs)($.Fragment,{children:[u&&!t?(0,$.jsx)(`button`,{type:`button`,className:Y(`fixed inset-0 bg-scrim md:hidden`,e?`z-[109]`:`z-40`),"aria-label":i.closeMenu,onClick:()=>h(!1)}):null,(0,$.jsx)(`aside`,{id:t?void 0:`app-workspace-panel`,"aria-label":i.workspace.title,"aria-hidden":!u,className:t?`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-base`:Y(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:h-[100dvh] max-md:shadow-popover max-md:w-[min(20rem,92vw)]`,u?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,e&&u?`pointer-events-auto z-[110]`:`max-md:z-50`,!u&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,u&&`app-workspace-panel-expanded-width md:shrink-0`,u&&x&&`workspace-panel-rail-resizing`),style:!t&&u?{"--workspace-panel-px":`${_}px`}:void 0,children:u?(0,$.jsxs)(`div`,{className:Y(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[t?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i.workspace.resizeHandleAria,onPointerDown:ge,className:Y(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,x&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,sl)}),(0,$.jsxs)(`div`,{className:Y(`flex h-11 shrink-0 items-center gap-2 px-4`,!t&&`border-b border-edge dark:border-edge`),children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:i.workspace.title}),oe?U?(0,$.jsx)(pr,{resourceId:U.fileId,displayName:U.name}):null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(qr,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:i.workspace.title})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[t?null:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:Y(`size-9 shrink-0 rounded-md p-0`,C&&`bg-surface-hover text-fg`),"aria-label":i.workspace.search,title:i.workspace.search,"aria-pressed":C,onClick:()=>w(!0),children:(0,$.jsx)(Xa,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(mu,{className:`size-9 shrink-0 rounded-md p-0`,loading:W,label:i.cron.refresh,onClick:G}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":i.workspace.close,title:i.workspace.close,onClick:()=>h(!1),children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:1.75})})]})]}),t||C?(0,$.jsx)(`div`,{className:Y(`shrink-0 px-3 pb-2 pt-1`,!t&&`border-b border-edge`),children:(0,$.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(Xa,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:T,onChange:e=>E(e.target.value),placeholder:i.workspace.searchPlaceholder,"aria-label":i.workspace.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),!t||T?(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":i.workspace.clearSearch,title:i.workspace.clearSearch,onClick:()=>{E(``),w(!1)},children:(0,$.jsx)(wo,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,ee?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,ee]}):null,ae?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:k?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(Xo,{className:`h-11 w-full`}),(0,$.jsx)(Xo,{className:`h-11 w-full`}),(0,$.jsx)(Xo,{className:`h-11 w-full`})]}):j?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[i.workspace.loadError,`: `,j]}):D.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:i.workspace.noSearchResults}):D.map(e=>(0,$.jsxs)(`button`,{type:`button`,draggable:!0,className:Y(`flex w-full min-w-0 cursor-grab items-center gap-2 px-3 py-2 text-left active:cursor-grabbing hover:bg-surface-hover`,L===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>z(e.path),onDragStart:t=>se(t,e),title:e.path,children:[(0,$.jsx)(Dr,{name:e.name}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(kr,{tree:H,selectedPath:L,onSelectFile:e=>z(e),onExpandDir:_e,onAction:ve,onFileDragStart:se,onUploadFiles:(e,t)=>void be(e,t),uploadDropHint:i.workspace.dropToUpload,actionLabels:{preview:i.workspace.preview,download:i.workspace.download,copyPath:i.workspace.copyPath,share:i.workspace.shareLink,delete:i.workspace.deleteFile,...oe?{openDefault:i.workspace.openSystemApp,openDirectory:i.workspace.openInFileManager,openWith:i.workspace.chooseApp,revealInFolder:i.workspace.revealInFolder,trash:i.workspace.moveToTrash,recommendedApps:i.workspace.recommendedApps,desktopUpdateRequired:i.workspace.desktopUpdateRequired}:{}},emptyHint:i.workspace.emptyDir})]}):null}),(0,$.jsx)(So,{open:ce,onOpenChange:he,loading:le,error:de,result:ue,pendingParams:fe,onConfirm:e=>void me(e)}),(0,$.jsx)(pu,{open:!!N,title:i.workspace.trashConfirmTitle,description:i.workspace.trashConfirmDescription.replace(`{{name}}`,N?.name??``),confirmLabel:i.workspace.moveToTrash,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void ye(),onCancel:()=>P(null)}),(0,$.jsx)(pu,{open:!!F,title:i.workspace.deleteConfirmTitle,description:i.workspace.deleteConfirmDescription.replace(`{{name}}`,F?.name??``),confirmLabel:i.workspace.deleteFile,cancelLabel:i.workspace.cancel,destructive:!0,onConfirm:()=>void xe(),onCancel:()=>I(null)})]})}),XH=`xopc:side-chat-client-id`;function ZH(){let e=sessionStorage.getItem(XH);if(e)return e;let t=crypto.randomUUID();return sessionStorage.setItem(XH,t),t}function QH(){return{"x-xopc-client-instance-id":ZH()}}async function $H(e,t){return(await Bo(Lo(`/api/sessions/${encodeURIComponent(e)}/side-chats`),{method:`POST`,headers:QH(),body:JSON.stringify({clientInstanceId:ZH(),selections:t})})).sideChat}async function eU(e){return(await Bo(Lo(`/api/side-chats/${e}`),{headers:QH()})).sideChat}async function tU(e){return(await Bo(Lo(`/api/side-chats/${e}/messages`),{headers:QH()})).messages}async function nU(e,t){return(await Bo(Lo(`/api/side-chats/${e}/config`),{method:`PATCH`,headers:QH(),body:JSON.stringify(t)})).sideChat}async function rU(e,t,n){return(await Bo(Lo(`/api/side-chats/${e}/inputs`),{method:`POST`,headers:QH(),body:JSON.stringify({content:t,attachments:n})})).payload.runId}async function iU(e,t){await Bo(Lo(`/api/side-chats/${e}/abort`),{method:`POST`,headers:QH(),body:JSON.stringify({runId:t})})}async function aU(e,t,n){await Bo(Lo(`/api/side-chats/${e}/clarify/${t}`),{method:`POST`,headers:QH(),body:JSON.stringify(n)})}async function oU(e){await Bo(Lo(`/api/side-chats/${e}`),{method:`DELETE`,headers:QH()})}async function sU(e){return(await Bo(Lo(`/api/side-chats/${e}/heartbeat`),{method:`POST`,headers:QH()})).sideChat}async function cU(e){return(await Bo(Lo(`/api/side-chats/${e}/extend`),{method:`POST`,headers:QH()})).sideChat}async function lU(e){return Bo(Lo(`/api/side-chats/${e}/promote`),{method:`POST`,headers:QH()})}var uU=`xopc:side-chat-close-confirm-disabled:v1`,dU=()=>{},fU=[];function pU(){try{return localStorage.getItem(uU)===`true`}catch{return!1}}function mU(){try{localStorage.setItem(uU,`true`)}catch{}}function hU(e){return e.role===`user`?e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
7
7
|
`).trim():``}function gU(e){return(e.attachments??[]).map(e=>e.name??``).filter(Boolean).join(`
|
|
8
8
|
`)}function _U(e,t){let n=e?.body?.code;return n===`INVALID_REQUEST`?t.errorInvalidRequest:n===`NOT_FOUND`?t.errorNotFound:n===`CONFLICT`?t.errorConflict:n===`LIMIT_REACHED`?t.errorLimitReached:n===`CAPACITY_REACHED`?t.errorCapacity:n===`PARENT_NOT_FOUND`?t.parentMissing:n===`INTERNAL_ERROR`?t.failed:e instanceof Error?e.message:String(e)}function vU(e,t){let n=[...e];for(let[e,r]of t){let i=hU(r),a=gU(r),o=r.timestamp??0;if(n.some(e=>e.role===`user`&&hU(e)===i&&gU(e)===a&&Math.abs((e.timestamp??o)-o)<6e4)){t.delete(e);continue}let s=n.findIndex(e=>(e.timestamp??1/0)>o);s<0?n.push(r):n.splice(s,0,r)}return n}function yU({parentConversationId:e,embedded:t=!1,visible:n=!0}){let r=ns(t=>t.panes[e]),i=Do(zo(e=>e.language)).sideChat,a=Qe(t=>t.panes[e]?.open===!0),o=Qe(e=>e.tabs),s=Qe(e=>e.readings),c=(0,Z.useMemo)(()=>o.filter(t=>t.parentConversationId===e),[o,e]),l=Qe(t=>t.panes[e]?.activeId??null),u=t?r?.activeId?.replace(/^side:/,``):l,d=Qe(e=>e.pendingCreate),f=Qe(e=>e.requestCreate),p=Qe(e=>e.claimPendingCreate),m=Qe(e=>e.finishCreate),h=Qe(e=>e.addTab),g=Qe(e=>e.removeTab),_=Qe(e=>e.setActive),v=Qe(e=>e.setOpen),y=Qe(e=>e.widthPx),b=Qe(e=>e.setWidthPx),x=Qe(e=>e.setTabRunId),S=Ro(e=>e.conversationId),C=c.find(e=>e.id===u)??null,w=Qe(t=>!!t.creatingRequests[e]),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!d||d.parentConversationId!==e)return;let n=p(e,d.requestId);if(!n)return;E(null);let r=Ro.getState();ns.getState().setNotice(e,``);let a=ns.getState().panes[e]?.activeId;$H(n.parentConversationId,n.selections).then(n=>{if(Ro.getState().conversationId!==r.conversationId||Ro.getState().baseUrl!==r.baseUrl)return;let i=Qe.getState().panes[n.parentConversationId]?.open===!0,o=ns.getState(),s=!t||o.scope===e&&o.panes[e]?.open===!0&&o.panes[e]?.activeId===a;h({id:n.id,parentConversationId:n.parentConversationId,title:`Side chat`},s),i||v(n.parentConversationId,!1)}).catch(n=>{E(_U(n,i)),t&&ns.getState().setNotice(e,_U(n,i))}).finally(()=>{m(n.parentConversationId,n.requestId)})},[h,p,t,m,i,e,d,v]);let[N,P]=(0,Z.useState)(!1),F=(0,Z.useCallback)(async n=>{let r=Qe.getState().tabs.find(e=>e.id===n)?.promotedConversationId;P(!0);try{r||await oU(n),g(n),A(null)}catch(r){let a=r?.status;a===404||a===410?(g(n),A(null)):(E(_U(r,i)),t&&ns.getState().setNotice(e,_U(r,i)))}finally{P(!1)}},[t,i,e,g]),I=(0,Z.useCallback)(e=>{let t=Qe.getState(),n=t.tabs.find(t=>t.id===e),r=t.readings[e],i=t.drafts[e];if(n?.promotedConversationId){F(e);return}if(r&&!r.messages.length&&!r.truncated&&!i?.text.trim()&&!i?.attachments.length&&!n?.runId||pU()){F(e);return}M(!1),A(e)},[F]),L=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=Qe.getState().widthPx,r=e.pointerId;e.currentTarget.setPointerCapture(r),O(!0);let i=e=>{let r=Math.min(760,Math.max(360,n+t-e.clientX));document.getElementById(`app-side-chat-panel`)?.style.setProperty(`--side-chat-panel-px`,`${r}px`)},a=e=>{let r=Math.min(760,Math.max(360,n+t-e.clientX));b(r),O(!1),window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},[b]);return(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.detail;c.some(e=>e.id===t)&&!N&&I(t)};return window.addEventListener(`workspace-close-sidechat`,e),()=>window.removeEventListener(`workspace-close-sidechat`,e)},[N,t,I,c]),!t&&!a?null:(0,$.jsxs)(`aside`,{id:!t||n?`app-side-chat-panel`:void 0,"aria-label":i.paneAria,className:Y(t?`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`:`relative flex min-h-0 shrink-0 flex-col overflow-hidden border-l border-edge bg-surface-base`,!t&&`max-md:fixed max-md:inset-y-0 max-md:right-0 max-md:z-50 max-md:w-[min(92vw,34rem)] max-md:shadow-popover`,!t&&`app-side-chat-expanded-width app-side-chat-panel-enter`,t&&!n&&`hidden`,D&&`side-chat-panel-resizing`),style:{"--side-chat-panel-px":`${y}px`},children:[t?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i.resizeAria,onPointerDown:L,className:`absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize touch-none md:block`}),(0,$.jsxs)(`div`,{"data-side-chat-header":!0,className:Y(`h-11 shrink-0 items-center gap-1 overflow-x-auto px-2`,t?`hidden`:`flex`),children:[c.map(e=>(0,$.jsxs)(`div`,{className:Y(`flex h-8 shrink-0 items-center rounded-lg pl-3 text-sm`,e.id===u?`bg-surface-hover text-fg`:`text-fg-muted`),children:[(0,$.jsxs)(`button`,{type:`button`,className:`max-w-40 truncate`,onClick:()=>_(e.id),children:[e.title===`Side chat`?i.title:e.title,e.ended?` · ${e.ended===`promoted`?i.savedLabel:i.endedLabel}`:``]}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-md hover:bg-surface-active`,"aria-label":i.closeAria,onClick:()=>I(e.id),children:(0,$.jsx)(wo,{className:`size-3.5`})})]},e.id)),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.newAria,title:i.newAria,disabled:w,onClick:()=>f(e),children:(0,$.jsx)(Ra,{className:`size-4`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`ml-auto size-8 shrink-0 p-0`,"aria-label":i.closePaneAria,onClick:()=>v(e,!1),children:(0,$.jsx)(vn,{className:`size-4`})})]}),T&&(C||t)?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-2 text-xs text-fg-muted`,role:`status`,children:[(0,$.jsx)(`p`,{children:T}),o.filter(e=>!e.ended).map(e=>(0,$.jsx)(`button`,{type:`button`,className:`mr-2 mt-1 rounded border border-edge px-2 py-1`,onClick:()=>{_(e.id),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e.parentConversationId}}))},children:e.title===`Side chat`?i.title:e.title},e.id))]}):null,t?c.filter(e=>!e.ended||s[e.id]||n&&r?.activeId===`side:${e.id}`).map(t=>(0,$.jsx)(bU,{sideChatId:t.id,token:S??void 0,initialRunId:t.runId,onRunIdChange:x,parentConversationId:e,visible:n&&r?.activeId===`side:${t.id}`},`${t.id}:${S??``}`)):C?(0,$.jsx)(bU,{sideChatId:C.id,token:S??void 0,initialRunId:C.runId,onRunIdChange:x,parentConversationId:e},`${C.id}:${S??``}`):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-8 text-center`,children:[(0,$.jsx)(oa,{className:`mb-4 size-10 text-fg-muted`,strokeWidth:1.5}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:i.title}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm leading-6 text-fg-muted`,children:i.temporaryDescription}),w?(0,$.jsx)(Xo,{className:`mt-4 h-4 w-32`}):null,T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-4 text-xs text-red-600 dark:text-red-400`,role:`alert`,children:T}),(0,$.jsx)(X,{className:`mt-3`,disabled:w,onClick:()=>f(e),children:i.retryCreate})]}):null]}),(0,$.jsx)(pu,{open:k!==null,title:c.find(e=>e.id===k)?.runId?i.stopCloseTitle:i.closeConfirmTitle,description:c.find(e=>e.id===k)?.runId?i.stopCloseDescription:i.closeConfirmDescription,confirmLabel:c.find(e=>e.id===k)?.runId?i.stopCloseAction:i.closeConfirmAction,cancelLabel:i.closeConfirmCancel,checkboxLabel:i.closeConfirmDontAskAgain,checkboxChecked:j,onCheckboxCheckedChange:M,destructive:!0,onConfirm:()=>{if(N)return;let e=k;e&&(j&&mU(),M(!1),F(e))},onCancel:()=>{A(null),M(!1)}})]})}function bU({sideChatId:e,token:t,initialRunId:n,onRunIdChange:r,parentConversationId:i,visible:a=!0}){let o=p(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(()=>Qe.getState().readings[e]?.messages??[]),d=Qe(t=>t.drafts[e]?.text??``),f=Qe(t=>t.drafts[e]?.attachments??fU),m=(0,Z.useCallback)(t=>Qe.getState().setDraftText(e,t),[e]),h=(0,Z.useCallback)(t=>{Qe.getState().setDraftAttachments(e,t)},[e]),[g,_]=(0,Z.useState)(()=>Qe.getState().tabs.find(t=>t.id===e)?.ended),[v,y]=(0,Z.useState)(!g),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(()=>Qe.getState().tabs.find(t=>t.id===e)?.promotedConversationId),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(Date.now),[R,z]=(0,Z.useState)(0),B=Qe(t=>t.tabs.find(t=>t.id===e)?.fresh),V=Qe(t=>t.readings[e]?.truncated??!1),H=(0,Z.useRef)(!0),U=(0,Z.useRef)(g),W=(0,Z.useRef)(Ro.getState()),ee=(0,Z.useCallback)(()=>W.current.conversationId===Ro.getState().conversationId&&W.current.baseUrl===Ro.getState().baseUrl,[]),G=(0,Z.useCallback)(()=>H.current&&ee(),[ee]);(0,Z.useEffect)(()=>(H.current=!0,()=>{H.current=!1}),[]);let[K,q]=(0,Z.useState)(!!n),[te,re]=(0,Z.useState)(n),[ie,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(!1),[ue,de]=(0,Z.useState)(null),fe=(0,Z.useRef)(!1),pe=(0,Z.useRef)(0),me=(0,Z.useRef)(0),he=(0,Z.useRef)(!1),ge=(0,Z.useRef)(!1),_e=(0,Z.useRef)(new Map),ve=Do(zo(e=>e.language)),J=ve.sideChat,ye=jc({conversationId:e,chat:ve.chat,initialAttachments:f,onAttachmentsChange:h}),be=Ae({receiveExternalFill:!1,conversationId:e,disabled:!a||!!g||b,initialValue:d,onValueChange:m,autoFocusKey:a?e:null,shouldSyncSelectionRef:fe}),xe=(0,Z.useRef)({}),{scrollRef:Se,atBottom:Ce,registerListContentRef:we,scrollToBottom:Te,onScroll:De}=Ne({hasToken:!0,showSessionLoading:!1,conversationId:e,chatMessages:l,streaming:K,hasMore:!1,loadingMore:!1,loadMoreMessages:dU});(0,Z.useEffect)(()=>{G()&&(l.length||!v)&&Qe.getState().rememberMessages(e,l)},[l,v,e,G]);let Oe=(0,Z.useCallback)(t=>{!G()||U.current||(U.current=t,pe.current+=1,_(t),q(!1),re(void 0),se(null),c(null),F(``),ae(null),x(!1),y(!1),u(e=>je(e).messages),Qe.getState().markEnded(e,t))},[G,e]),ke=(0,Z.useCallback)(e=>{if(!G()||ge.current)return;let t=e;t.body?.code===`EXPIRED`||t.status===410?Oe(t.body?.reason===`waiting`?`waiting`:`idle`):t.status===404||t.body?.code===`NOT_FOUND`?Oe(`unavailable`):x(!0),y(!1)},[Oe,G]),Me=(0,Z.useCallback)(t=>{if(!G()||U.current)return;let n=t.serverNow?Date.parse(t.serverNow):0;n&&n<me.current||(me.current=n,c(t),x(!1),t.serverNow&&z(Date.parse(t.serverNow)-Date.now()),L(Date.now()),q(t.status!==`idle`),re(t.runId),r(e,t.runId),se(t.clarification??null))},[G,r,e]),Pe=(0,Z.useCallback)(async()=>{let t=pe.current;try{let[n,r]=await Promise.all([eU(e),tU(e)]);if(!G()||U.current)return;pe.current===t&&(Me(n),u(vU(cc(r),_e.current))),y(!1)}catch(e){ke(e)}},[Me,ke,G,e]);(0,Z.useEffect)(()=>{if(g)return;Pe();let t=!1,n=async()=>{if(t||U.current)return;t=!0;let n=pe.current;try{let t=await sU(e);t&&n===pe.current&&Me(t)}catch(e){ke(e)}finally{t=!1}},r=window.setInterval(()=>{L(Date.now()),n()},3e4),i=()=>{document.visibilityState!==`hidden`&&Pe()};return window.addEventListener(`online`,i),window.addEventListener(`pageshow`,i),document.addEventListener(`visibilitychange`,i),()=>{window.clearInterval(r),window.removeEventListener(`online`,i),window.removeEventListener(`pageshow`,i),document.removeEventListener(`visibilitychange`,i)}},[g,Pe,Me,ke,e]),(0,Z.useEffect)(()=>{if(!g)return Uc(`side-chat:${ZH()}:${e}`,{onEvent:e=>{e.event===`expired`&&Oe(e.data?.reason===`waiting`?`waiting`:`idle`)},onGap:()=>Pe()})},[g,Oe,Pe,e]),(0,Z.useEffect)(()=>{if(!P)return;let e=window.setTimeout(()=>F(``),5e3);return()=>window.clearTimeout(e)},[P]);let Fe=(0,Z.useRef)(0),Le=(0,Z.useRef)(a);Le.current=a;let ze=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{a&&(Fe.current=l.length,ze.current=!1),Qe.getState().setTabStatus(e,{waiting:!!oe,disconnected:b,unread:!a&&(ze.current||l.length>Fe.current)})},[oe,b,l,te,e,a]);let Ve=s?.expiresAt?Date.parse(s.expiresAt)-(I+R):1/0,He=!g&&!b&&Ve<=5*6e4,Ue=async()=>{if(!(S||U.current)){C(!0);try{let t=await cU(e);if(!G()||U.current)return;Me(t),ae(null),F(J.extended)}catch(e){let t=e.status;(t===404||t===410)&&ke(e),U.current||ae(J.extendFailed)}finally{C(!1)}}},We=async()=>{let t=i??Qe.getState().tabs.find(t=>t.id===e)?.parentConversationId;if(!(!t||w)){T(!0),ae(null);try{let n=await $H(t,[]);if(!ee())return;Qe.getState().replaceTab(e,{id:n.id,parentConversationId:t,title:`Side chat`})}catch(e){if(!G())return;e.body?.code===`PARENT_NOT_FOUND`&&N(!0),ae(_U(e,J))}finally{T(!1)}}},Ge=(0,Z.useCallback)(e=>{pe.current+=1,u(t=>{let n=structuredClone(t),r=n.at(-1);return r?.role!==`assistant`&&(r={role:`assistant`,content:[],timestamp:Date.now()},n.push(r)),e(r),n})},[]);(0,Z.useEffect)(()=>{if(!(!te||g))return Uc(`run:${te}`,{onEvent:t=>{if(!G()||U.current)return;Le.current||(ze.current=!0);let n=t.data?.payload??{};t.event===`assistant_message_start`?Ge(()=>{}):t.event===`assistant_delta`?Ge(e=>Qs(e.content,String(n.delta??``),String(n.messageId??``))):t.event===`thinking_delta`?Ge(e=>ac(e.content,String(n.delta??``),!0)):t.event===`thinking_end`?Ge(e=>Xs(e.content)):t.event===`tool_start`?Ge(e=>Ys(e.content,String(n.toolName??`tool`),n.args,String(n.toolCallId??``),Date.now(),n.activity)):t.event===`tool_end`?Ge(e=>Zs(e.content,String(n.toolName??`tool`),n.status===`error`,n.result,String(n.toolCallId??``),Date.now(),n.activity)):t.event===`clarify_request`?(se({...rc(n),expiresAt:typeof n.expiresAt==`number`?n.expiresAt:void 0,requestId:String(n.requestId??``),kind:n.kind===`approval`?`approval`:`input`,question:String(n.question??``)}),de(null),Pe()):t.event===`error`?ae(String(n.message??J.failed)):t.event===`run_end`&&(q(!1),re(void 0),r(e,void 0),se(null),Pe())},onGap:()=>Pe()})},[g,G,Ge,r,Pe,te,e,J.failed]);let qe=()=>{let t=d.trim(),n=ye.wireAttachmentsPayload();if(!t&&n.length===0||K||he.current||U.current||b)return;if(ct(t)>262144){ae(J.draftTooLong);return}let i={text:d,attachments:[...ye.attachmentsRef.current]};he.current=!0,be.resetEditor(),ye.clearAttachments(),ae(null),pe.current+=1;let a=crypto.randomUUID(),o={role:`user`,content:[{type:`text`,text:t}],attachments:i.attachments,timestamp:Date.now(),renderKey:`side-chat-user:${a}`};_e.current.set(a,o),u(e=>[...e,o]),q(!0),rU(e,t,n).then(t=>{!ee()||U.current||(Qe.getState().setTabRunId(e,t),G()&&(re(t),r(e,t)))}).catch(t=>{if(!ee())return;let n=Qe.getState();if(!G()&&!n.tabs.some(t=>t.id===e))return;let r=Qe.getState().drafts[e]??{text:``,attachments:[]},s={text:r.text?`${i.text}\n${r.text}`:i.text,attachments:[...i.attachments,...r.attachments]};G()?(be.resetEditor({nextText:s.text}),ye.setAttachments(s.attachments)):(m(s.text),h(s.attachments)),_e.current.delete(a);let c=n.readings[e];if(c&&n.rememberMessages(e,c.messages.filter(e=>e.renderKey!==o.renderKey)),!G())return;u(e=>e.filter(e=>e.renderKey!==o.renderKey)),q(!1);let l=t.status;l===404||l===410?ke(t):ae(_U(t,J))}).finally(()=>{he.current=!1})},Ye=async t=>{if(!(!oe||U.current)){le(!0),de(null);try{await aU(e,oe.requestId,t),se(null),Pe()}catch(e){e.status===410?ke(e):de(_U(e,J))}finally{le(!1)}}},Xe=async()=>{try{await iU(e,te),G()&&se(null)}catch(e){if(!G())return;let t=e.status;t===404||t===410?ke(e):ae(_U(e,J))}},Ze=(0,Z.useCallback)(e=>{be.resetEditor({nextText:e,focus:!0})},[be.resetEditor]),$e=`${o.pathname}${o.search}`,tt=(0,Z.useCallback)(async e=>{try{let t=await mi(e.trim(),`web`);ii(`success`,ve.chat.messageSavedToNote,void 0,{href:ta($e,t.id)})}catch(e){throw ii(`error`,e instanceof Error?e.message:ve.notes.quickCaptureFailed),e}},[$e,ve.chat.messageSavedToNote,ve.notes.quickCaptureFailed]),nt=(0,Z.useCallback)(async()=>{if(!(ge.current||K||U.current||l.length===0)){ge.current=!0,D(!0),k(!1),ae(null);try{let t=await lU(e);if(!ee())return;U.current=`promoted`,_(`promoted`),j(t.conversationId),q(!1),re(void 0),se(null),c(null),r(e,void 0),Qe.getState().markPromoted(e,t.conversationId),ii(`success`,J.savedTitle,void 0,{href:`/chat/${encodeURIComponent(t.conversationId)}`})}catch(e){if(!G())return;ae(_U(e,J)||J.saveFailed)}finally{ge.current=!1,G()&&D(!1)}}},[G,l.length,r,K,ee,e,J]),rt=(0,Z.useCallback)(()=>{if(d.trim()||f.length){k(!0);return}nt()},[f.length,d,nt]),at=(0,Z.useCallback)(async t=>{let n=await nU(e,t);G()&&!U.current&&c(n)},[G,e]);return xe.current={adapters:[],send:qe,runBusy:K,pendingFollowUpsCount:0,editingFollowUpId:null,onCancelEditFollowUp:()=>{},attachmentsLen:ye.attachments.length,contextRefsLen:0,isComposing:be.isComposing,valueRef:be.valueRef,adjustHeight:be.adjustHeight,editorRef:be.editorRef},(0,$.jsxs)(`div`,{hidden:!a,className:Y(`relative min-h-0 flex-1 flex-col`,a?`flex`:`hidden`),children:[(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{ref:Se,"data-side-chat-scroll-viewport":!0,onScroll:De,className:`chat-messages h-full overflow-y-auto overflow-x-hidden px-5 py-4 [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,children:[v&&!l.length?(0,$.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-label":J.creating,children:[(0,$.jsx)(Xo,{className:`ml-auto h-12 w-3/4`}),(0,$.jsx)(Xo,{className:`h-4 w-full`}),(0,$.jsx)(Xo,{className:`h-4 w-4/5`})]}):l.length&&a?(0,$.jsx)(et,{messages:l,authToken:t,conversationId:e,workspaceConversationId:i,streaming:K,progress:null,reasoningLevel:`on`,registerListContentRef:we,deleteRoundDisabled:K||!!g,onSaveAssistantAsNote:tt,onEditUserMessage:g?void 0:e=>Ze(hU(e)),responseFeedbackEnabled:!1}):g?null:(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center text-center`,children:[(0,$.jsx)(oa,{className:`mb-4 size-9 text-fg-muted`,strokeWidth:1.5}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:J.title}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:B?J.freshContext:J.emptyDescription}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-xs leading-5 text-fg-muted`,children:J.temporaryDescription})]}),V&&g?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:J.partialReading}):null]}),(0,$.jsx)(Ie,{visible:!Ce,onClick:()=>Te(!0),edge:`bottom`,running:K})]}),b&&!g?(0,$.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 py-2 text-xs text-fg-muted`,children:J.connectionLost}):null,P?(0,$.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 py-2 text-xs text-fg-muted`,children:P}):null,He?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-4 py-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:Ve<=0?J.verifying:J.expiring.replace(`{{minutes}}`,String(Math.max(1,Math.ceil(Ve/6e4))))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`ml-auto h-8 text-xs`,disabled:S||Ve<=0,onClick:()=>void Ue(),children:J.keepAlive})]}):null,oe&&!g?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-3 pt-3`,children:(0,$.jsx)(ne,{prompt:{...oe,durable:!1},submitting:ce,submitError:ue,labels:ve.chat,onSubmit:Ye,onAgentDecide:()=>Ye({response:{text:`Use your best judgment and continue without additional user input.`}}),onCancel:Xe})}):null,ie?(0,$.jsx)(`p`,{className:`border-t border-edge px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:ie}):null,g===`promoted`&&A?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge p-3`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,"aria-live":`polite`,children:J.savedTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:J.savedDescription}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:A}}))},children:J.openSavedChat})]})}):g?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge p-3`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,"aria-live":`polite`,children:g===`unavailable`?J.unavailableTitle:J.expiredTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:M?J.parentMissing:g===`waiting`?J.waitExpired:l.length?J.expiredDescription:J.unavailableDescription}),d||f.length?(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`label`,{htmlFor:`side-chat-draft-${e}`,className:`text-xs text-fg-muted`,children:J.unsentDraft}),(0,$.jsx)(Oc,{attachments:f,topPadded:!1,onRemove:ye.removeAttachment,className:`mt-1 rounded-t-lg`}),d?(0,$.jsx)(`textarea`,{id:`side-chat-draft-${e}`,value:d,onChange:e=>m(Ke(e.target.value)),rows:3,className:`mt-1 w-full resize-y rounded-lg border border-edge bg-surface-base p-2 text-sm`}):null]}):null,(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,disabled:w,onClick:()=>{M?i&&Qe.getState().setOpen(i,!1):We()},children:M?J.closePaneAria:w?J.creating:d.trim()||f.length?J.newWithDraft:J.newAria}),l.length&&!M?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:J.replaceHint}):null]})}):(0,$.jsx)(`form`,{"data-side-chat-composer":!0,onSubmit:e=>{e.preventDefault(),qe()},className:`shrink-0 p-3`,children:(0,$.jsxs)(ut,{dragging:ye.isDragging,onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,ye.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&ye.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),ye.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&ye.processFiles(Array.from(t))},children:[(0,$.jsx)(`input`,{ref:ye.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&ye.processFiles(Array.from(t)),e.target.value=``}}),(0,$.jsx)(Oc,{attachments:ye.attachments,topPadded:!1,onRemove:ye.removeAttachment}),s?.context.selections.length?(0,$.jsxs)(`div`,{className:`mx-3 mt-3 inline-flex h-8 max-w-[calc(100%-1.5rem)] self-start items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 text-xs font-medium text-fg-muted sm:mx-4`,title:s.context.selections.map(e=>e.label||e.text).join(`
|
|
9
9
|
`),children:[(0,$.jsx)(it,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:(s.context.selections.length===1?J.selectionCount_one:J.selectionCount_other).replace(`{{count}}`,String(s.context.selections.length))})]}):null,(0,$.jsx)(`div`,{className:s?.context.selections.length?`px-3 sm:px-4`:`px-3 pt-1 sm:px-4`,children:(0,$.jsx)(mt,{editorRef:be.editorRef,disabled:b,placeholder:ve.chat.typeMessage,onWireInput:(e,t)=>{let n=Ke(e);ct(e)>262144&&ae(J.draftTooLong),be.onWireInput(n,Math.min(t,n.length))},adjustHeight:be.adjustHeight,processFiles:ye.processFiles,processPastedText:ye.processPastedText,setIsComposing:be.setIsComposing,kbdRef:xe,chatMessages:ve.chat})}),(0,$.jsxs)(Re,{children:[(0,$.jsx)(Je,{disabled:b,runBusy:K,attachmentCount:ye.attachments.length,maxAttachments:10,chat:ve.chat,onPickFiles:()=>ye.fileInputRef.current?.click()}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,"aria-label":J.saveAsChat,title:K?J.saveBusy:J.saveAsChat,disabled:E||K||b||l.length===0,onClick:rt,children:[(0,$.jsx)(Ya,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`max-sm:hidden`,children:E?J.savingChat:J.saveAsChat})]}),(0,$.jsx)(`div`,{className:`ml-auto min-w-0`,children:s?(0,$.jsx)(Ee,{chat:ve.chat,sessionModel:s.config.modelRef,modelDisabled:b,onModelChange:(e,t)=>at({modelRef:e,thinkingLevel:t}),thinkingLevel:s.config.thinkingLevel,thinkingDisabled:b,onThinkingChange:e=>at({thinkingLevel:e})}):null}),(0,$.jsx)(Be,{disabled:b||ct(d)>262144,voiceActive:!1,runBusy:K,hasDraft:!!d.trim()||ye.attachments.length>0,showSteeringInterrupt:!1,chat:ve.chat,onSend:qe,onAbort:()=>void Xe()})]})]})}),(0,$.jsx)(pu,{open:O,title:J.saveDraftTitle,description:J.saveDraftDescription,confirmLabel:J.saveDraftAction,cancelLabel:J.closeConfirmCancel,onConfirm:()=>void nt(),onCancel:()=>k(!1)})]})}function xU(e,t,n){let r=(0,Q.c)(16),{pathname:i,search:a}=p(),o=b(),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(!1),u,d;r[0]!==t.activeId||r[1]!==t.open||r[2]!==t.tabs||r[3]!==i||r[4]!==e||r[5]!==a?(u=()=>{let n=new URLSearchParams(a).toString(),r=s.current;if(s.current={pathname:i,search:a,scope:e},r?.pathname===i&&r.scope===e&&r.search===a)return;if(c.current===`${i}?${n}`){c.current=null;return}let o=new URLSearchParams(a).get(`workspaceTab`),u=r?.pathname===i&&r.scope===e&&new URLSearchParams(r.search).get(`workspaceTab`)!==o;if(o&&t.tabs.some(e=>e.id===o)&&(o!==t.activeId||!t.open)||u){l.current=!0;let n=ns.getState();o&&t.tabs.some(e=>e.id===o)?n.activate(o,e):t.activeId!==null&&n.activate(null,e)}},d=[t.activeId,t.open,t.tabs,i,e,a],r[0]=t.activeId,r[1]=t.open,r[2]=t.tabs,r[3]=i,r[4]=e,r[5]=a,r[6]=u,r[7]=d):(u=r[6],d=r[7]),(0,Z.useEffect)(u,d);let f,m;r[8]!==n||r[9]!==o||r[10]!==t.activeId||r[11]!==t.open||r[12]!==i||r[13]!==a?(f=()=>{if(!n)return;if(l.current){l.current=!1;return}let e=new URLSearchParams(a);t.open&&t.activeId?e.set(`workspaceTab`,t.activeId):e.delete(`workspaceTab`);let r=e.toString();r!==new URLSearchParams(a).toString()&&(c.current=`${i}?${r}`,o({pathname:i,search:r?`?${r}`:``}))},m=[n,o,t.activeId,t.open,i,a],r[8]=n,r[9]=o,r[10]=t.activeId,r[11]=t.open,r[12]=i,r[13]=a,r[14]=f,r[15]=m):(f=r[14],m=r[15]),(0,Z.useEffect)(f,m)}function SU(e,t){let n=(0,Q.c)(5),[r,i]=(0,Z.useState)(t),a=(0,Z.useRef)(!1),o=(0,Z.useRef)(null),s,c;return n[0]!==t||n[1]!==r||n[2]!==e?(s=()=>{let n=e.current;if(!n)return;if(t&&!r){i(!0);return}let s=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(s?.matches||typeof n.animate!=`function`){a.current=t,r!==t&&i(t);return}let c=a.current!==t;a.current=t;let l,u=!1;if((c||!t)&&r){let e=o.current??(t?{opacity:0,transform:`translateX(16px)`}:{opacity:1,transform:`translateX(0)`});o.current=null,l=n.animate([e,t?{opacity:1,transform:`translateX(0)`}:{opacity:0,transform:`translateX(16px)`}],{duration:t?220:150,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`both`}),t||l.finished.then(()=>{u||i(!1)}).catch(CU)}let d=()=>{s?.matches&&(l?.cancel(),t||i(!1))};return s?.addEventListener(`change`,d),()=>{if(u=!0,(c||!t)&&l?.playState===`running`){let e=window.getComputedStyle(n);o.current={opacity:e.opacity,transform:e.transform}}l?.cancel(),s?.removeEventListener(`change`,d)}},c=[t,r,e],n[0]=t,n[1]=r,n[2]=e,n[3]=s,n[4]=c):(s=n[3],c=n[4]),(0,Z.useLayoutEffect)(s,c),r}function CU(){}function wU(e,t,n){let r=(0,Q.c)(7),[i,a]=(0,Z.useState)(0),o;r[0]!==t||r[1]!==e?(o=()=>{let n=e.current?.querySelector(`#workspace-content`),r=n&&[...n.querySelectorAll(`[data-workspace-toolbar]`)].find(TU);if(!t||!n||!r){a(0);return}let i=()=>a(Math.max(0,r.getBoundingClientRect().bottom-n.getBoundingClientRect().top));i();let o=typeof ResizeObserver<`u`?new ResizeObserver(i):null;return o?.observe(r),o?.observe(n),()=>o?.disconnect()},r[0]=t,r[1]=e,r[2]=o):o=r[2];let s;return r[3]!==n||r[4]!==t||r[5]!==e?(s=[n,t,e],r[3]=n,r[4]=t,r[5]=e,r[6]=s):s=r[6],(0,Z.useLayoutEffect)(o,s),i}function TU(e){return e.getClientRects().length>0}function EU(e){let t=(0,Q.c)(59),{tabs:n,canCreateSideChat:r,creating:i,onFiles:a,onSideChat:o,onActivate:s,onTerminal:c,onBrowser:l}=e,u=zo(kU)===`zh`,d,f,p,m,h,g,_;if(t[0]!==r||t[1]!==i||t[2]!==s||t[3]!==l||t[4]!==a||t[5]!==o||t[6]!==c||t[7]!==n||t[8]!==u){let e=n.filter(OU).sort(DU).slice(0,4);g=`min-h-0 flex-1 overflow-y-auto bg-surface-base/70 px-6 py-10 sm:px-8`,_=!0,d=`mx-auto max-w-3xl`;let v=u?`工具`:`Tools`;t[16]===v?f=t[17]:(f=(0,$.jsx)(`h2`,{className:`mb-5 text-sm font-medium text-fg`,children:v}),t[16]=v,t[17]=f);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Kr,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[18]=y):y=t[18];let b=u?`文件`:`Files`,x;t[19]===b?x=t[20]:(x=(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:b}),t[19]=b,t[20]=x);let S;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(yt,{className:`size-4 text-fg-subtle opacity-0 group-hover:opacity-100`,"aria-hidden":!0}),t[21]=S):S=t[21];let C;t[22]!==a||t[23]!==x?(C=(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,onClick:a,children:[y,x,S]}),t[22]=a,t[23]=x,t[24]=C):C=t[24];let w=!r||i,T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(oa,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[25]=T):T=t[25];let E=u?`侧聊`:`Side chat`,D;t[26]===E?D=t[27]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:E}),t[26]=E,t[27]=D);let O;t[28]===i?O=t[29]:(O=i?(0,$.jsx)(`span`,{className:`h-3 w-10 animate-pulse rounded bg-surface-active`}):(0,$.jsx)(yt,{className:`size-4 text-fg-subtle opacity-0 group-hover:opacity-100`,"aria-hidden":!0}),t[28]=i,t[29]=O);let k;t[30]!==o||t[31]!==w||t[32]!==D||t[33]!==O?(k=(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,disabled:w,onClick:o,children:[T,D,O]}),t[30]=o,t[31]=w,t[32]=D,t[33]=O,t[34]=k):k=t[34];let A;t[35]!==l||t[36]!==u?(A=l?(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,onClick:l,children:[(0,$.jsx)(ci,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:u?`浏览器`:`Browser`}),(0,$.jsx)(yt,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})]}):null,t[35]=l,t[36]=u,t[37]=A):A=t[37];let j;t[38]!==c||t[39]!==u?(j=c?(0,$.jsxs)(`button`,{className:`group flex min-h-16 min-w-0 items-center gap-3 rounded-xl border border-transparent bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45`,onClick:c,title:u?`打开主聊天的终端面板`:`Open the main chat terminal panel`,children:[(0,$.jsx)(po,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1 text-base`,children:u?`终端`:`Terminal`}),(0,$.jsx)(yt,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})]}):null,t[38]=c,t[39]=u,t[40]=j):j=t[40],t[41]!==C||t[42]!==k||t[43]!==A||t[44]!==j?(p=(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,13rem),1fr))] gap-3`,children:[C,k,A,j]}),t[41]=C,t[42]=k,t[43]=A,t[44]=j,t[45]=p):p=t[45],t[46]!==r||t[47]!==u?(m=r?null:(0,$.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:u?`开始主聊天后,可以在这里新建临时侧聊。`:`Start a main conversation to create a temporary side chat here.`}),t[46]=r,t[47]=u,t[48]=m):m=t[48],h=e.length?(0,$.jsxs)(`section`,{className:`mt-12`,children:[(0,$.jsx)(`h2`,{className:`mb-5 text-sm font-medium text-fg`,children:u?`继续查看`:`Continue with`}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,$.jsxs)(`button`,{onClick:()=>s(e.id),title:e.kind===`file`&&e.path||e.title,className:`flex min-w-0 flex-col items-center gap-3 rounded-xl px-2 py-4 text-sm text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-xl border border-edge-subtle bg-surface-panel`,children:e.kind===`file`?(0,$.jsx)(Hr,{className:`size-5 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(oa,{className:`size-5 text-fg-muted`,"aria-hidden":!0})}),(0,$.jsx)(`span`,{className:`w-full truncate text-center`,children:e.title===`Side chat`?u?`侧聊`:`Side chat`:e.title})]},e.id))})]}):null,t[0]=r,t[1]=i,t[2]=s,t[3]=l,t[4]=a,t[5]=o,t[6]=c,t[7]=n,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[49]!==d||t[50]!==f||t[51]!==p||t[52]!==m||t[53]!==h?(v=(0,$.jsxs)(`div`,{className:d,children:[f,p,m,h]}),t[49]=d,t[50]=f,t[51]=p,t[52]=m,t[53]=h,t[54]=v):v=t[54];let y;return t[55]!==g||t[56]!==_||t[57]!==v?(y=(0,$.jsx)(`div`,{className:g,"data-workspace-start":_,children:v}),t[55]=g,t[56]=_,t[57]=v,t[58]=y):y=t[58],y}function DU(e,t){return t.visitedAt-e.visitedAt}function OU(e){return e.kind===`file`||e.kind===`sidechat`}function kU(e){return e.language}var AU=`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function jU({scope:e,enabled:t=!0,elevated:n=!1,onDockedWidthChange:r}){let i=zo(e=>e.language)===`zh`,a=ns(e=>e.panes),o=a[e]??es,s=o.tabs.find(e=>e.id===o.activeId),c=ns(e=>e.width),l=ns(e=>e.treeWidth),u=ns(e=>e.fileTreeOpen),d=ns(e=>e.sideTreeOpen),f=ns(t=>t.notices[e]),m=ns(e=>e.fileStatus),h=Qe(e=>e.tabs),g=Qe(e=>e.pendingCreate),_=Qe(t=>t.creatingRequests[e]),v=!!(_||g?.parentConversationId===e),y=Ro(e=>e.conversationId),{search:b}=p(),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),[C,w]=(0,Z.useState)(1200),T=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>T.current?.(),[]);let[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),A=wU(x,O,o.activeId),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(null),[V,H]=(0,Z.useState)(!1),U=ns.getState(),W=t&&o.open,ee=SU(x,W);(0,Z.useLayoutEffect)(()=>{if(!W&&x.current?.contains(document.activeElement)){let e=document.querySelector(`[data-workspace-trigger]`);if(e)e.focus();else{let e=requestAnimationFrame(()=>document.querySelector(`[data-workspace-trigger]`)?.focus());return()=>cancelAnimationFrame(e)}}},[W]);let G=Te(e,t),K=(0,Z.useRef)(new Set);(0,Z.useEffect)(()=>{let t=G.data?.report;if(!t||de(t.status)||K.current.has(t.sessionId))return;K.current.add(t.sessionId);let n=ns.getState().panes[e];ns.getState().openPhone(t.sessionId,t.deviceName,e,C>=900&&(!n?.open||n.tabs.find(e=>e.id===n.activeId)?.kind===`home`))},[G.data,e,C]);let q=s?.kind===`phone`,te=q?360:460,ne=q?420:380,re=C<(q?900:840),ie=s?.kind===`browser`?j:s?.kind===`sidechat`?d:u,ae=s?Math.max(te,Math.min(c||(q?420:C*.6),C-ne)):320;(0,Z.useLayoutEffect)(()=>{r?.(W&&!re&&!N?ae:0)},[N,r,ae,re,W]);let oe=s?.kind===`files`,se=oe||s?.kind===`file`,ce=re||N?C:ae,le=se?240:460,ue=Math.min(l,Math.max(200,ce-le-8)),fe=ce>=le+ue+8,pe=oe||(s?.kind===`file`||s?.kind===`sidechat`||s?.kind===`browser`)&&ie&&fe,me=oe&&!fe,he=pe||O,ge=s?.kind===`file`?s:void 0,_e=(0,Z.useMemo)(()=>({conversationId:ge?.path?ge.conversationId:e===`new`?void 0:e,projectId:ge?.path?ge.projectId:new URLSearchParams(b).get(`projectId`)??void 0,agentId:ge?.agentId}),[ge?.agentId,ge?.conversationId,ge?.path,ge?.projectId,e,b]),ve=JSON.stringify(_e),[J,ye]=(0,Z.useState)({});(0,Z.useLayoutEffect)(()=>{U.setScope(e)},[e,U]),(0,Z.useEffect)(()=>{W&&ye(e=>e[ve]?e:{...e,[ve]:_e})},[ve,_e,W]),(0,Z.useLayoutEffect)(()=>{let e=x.current?.parentElement;if(!e)return;let t=()=>w(e.clientWidth||window.innerWidth);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,Z.useEffect)(()=>{for(let e of h)ns.getState().panes[e.parentConversationId]?.tabs.some(t=>t.id===`side:${e.id}`)||U.addSideChat(e.id,e.title,e.parentConversationId,!1)},[h,U]),(0,Z.useEffect)(()=>{k(!1)},[o.activeId,e]),(0,Z.useEffect)(()=>{fe&&k(!1)},[fe]),(0,Z.useEffect)(()=>{B(null),H(!1),R(``)},[e]),(0,Z.useEffect)(()=>{(S.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[C,N,o.activeId]),(0,Z.useEffect)(()=>{Ec.setState({path:ge?.path??null,projectId:ge?.projectId??null,conversationId:ge?.conversationId??null,line:ge?.line??null})},[ge]),(0,Z.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&!e.defaultPrevented){if(V){e.preventDefault(),H(!1);return}(N||O)&&(e.preventDefault(),P(!1),k(!1))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[V,N,O]),xU(e,o,t),WH();async function be(t){if(!F){I(t),R(``);try{await PH(t)&&U.remove(t,e)}catch(e){R(e instanceof Error?e.message:String(e))}finally{I(null)}}}async function xe(t,n=!1){if(!F){I(t);try{if(!n&&!await Cu(t)){B(t);return}U.remove(t,e),B(null),H(!1)}finally{I(null)}}}function Se(e){return e.kind===`home`?i?`新标签页`:`New tab`:e.kind===`browser`&&e.title===`Browser`?i?`浏览器`:`Browser`:e.kind===`files`?i?`文件`:`Files`:e.title===`Side chat`?i?`侧聊`:`Side chat`:e.title}function Ce(t){U.activate(t,e)}function we(){s&&(O?k(!1):!pe&&!fe?k(!0):s.kind===`browser`?M(!j):U.setTreeOpen(s.kind===`sidechat`?`sidechat`:`file`,!ie))}let Ee=s&&!oe&&s.kind!==`home`&&s.kind!==`phone`?(0,$.jsx)(`button`,{type:`button`,className:Y(AU,`rounded-full border border-edge-subtle`,he&&`border-accent/20 bg-accent-soft text-accent-fg`),"aria-label":i?`切换文件树`:`Toggle file tree`,"aria-pressed":he,onClick:we,children:(0,$.jsx)(Yr,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null;function De(e,t=!1){e.preventDefault();let n=e.clientX,r=t?ue:ae;e.currentTarget.setPointerCapture?.(e.pointerId),D(!0);let i=r,a=e=>{let a=r+n-e.clientX;i=t?Math.max(200,Math.min(320,ce-le-8,a)):Math.max(te,Math.min(C-ne,a));let o=t?x.current?.querySelector(`[data-workspace-tree]`):x.current;o&&(o.style.width=`${i}px`)},o=()=>{t?U.setTreeWidth(i):U.setWidth(i),T.current=null,D(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};T.current?.(),T.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)}let Oe=[...new Set([...h.map(e=>e.parentConversationId),...g?[g.parentConversationId]:[],...e===`new`?[]:[e]])],ke=Object.entries(a).flatMap(([e,t])=>t.tabs.filter(e=>e.kind===`file`).map(t=>({owner:e,tab:t}))),Ae=new Set([...ke].sort((e,t)=>t.tab.visitedAt-e.tab.visitedAt).slice(0,8).map(({tab:e})=>e.id));return(0,$.jsxs)(`aside`,{id:`app-workspace-panel`,ref:x,"aria-label":i?`文件与侧聊工作区`:`Files and side chats`,"data-right-workspace":!0,"aria-hidden":!W,inert:!W,className:Y(`relative min-h-0 shrink-0 flex-col overflow-hidden bg-surface-base`,ee?`flex`:`hidden`,ee&&(re||N)&&`absolute inset-0`,n?`z-[110]`:`z-40`),style:{width:re||N?void 0:ae},children:[!re&&!N&&s?(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":i?`调整工作区宽度`:`Resize workspace`,"aria-valuemin":te,"aria-valuemax":Math.max(te,C-ne),"aria-valuenow":Math.round(ae),className:`absolute left-0 top-0 z-20 h-full w-2 -translate-x-1/2 cursor-col-resize touch-none focus-visible:bg-accent/30`,onPointerDown:e=>De(e),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),U.setWidth(Math.max(te,Math.min(C-ne,ae+(e.key===`ArrowLeft`?20:-20))))),e.key===`Home`&&U.setWidth(0)}}):null,E?(0,$.jsx)(`div`,{"data-browser-occluder":!0,className:`fixed inset-0 z-[120] cursor-col-resize`}):null,(0,$.jsxs)(`div`,{"data-workspace-tab-bar":!0,className:`flex h-14 shrink-0 items-center gap-1 bg-surface-base px-2`,children:[(0,$.jsx)(su,{ref:S,role:`tablist`,"aria-label":i?`工作区标签`:`Workspace tabs`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`[role="tab"]`)],n=t.indexOf(document.activeElement),r=e.key===`ArrowRight`?(n+1)%t.length:e.key===`ArrowLeft`?(n-1+t.length)%t.length:e.key===`Home`?0:e.key===`End`?t.length-1:-1;r>=0&&(e.preventDefault(),t[r]?.focus())},indicatorClassName:`rounded-md bg-surface-panel`,children:o.tabs.map(t=>{let n=t.kind===`sidechat`?h.find(e=>e.id===t.sideChatId):void 0,r=Se(t),a=n?.waiting?i?`待处理`:`Needs attention`:n?.disconnected?i?`连接中断`:`Disconnected`:n?.ended?i?`已结束`:`Ended`:n?.runId?i?`运行中`:`Running`:n?.unread?i?`未读`:`Unread`:m[t.id]?i?`未保存`:`Unsaved`:``;return(0,$.jsxs)(`div`,{"data-sliding-active":t.id===o.activeId,className:Y(`group flex h-9 shrink-0 items-center rounded-md transition-colors`,t.id===o.activeId?`bg-surface-panel text-fg`:`text-fg-muted hover:bg-surface-hover`),children:[(0,$.jsxs)(`button`,{role:`tab`,id:`workspace-tab-${t.id}`,"aria-controls":`workspace-content`,"aria-selected":t.id===o.activeId,tabIndex:t.id===o.activeId?0:-1,title:t.kind===`file`&&t.path||r,className:`flex max-w-56 items-center gap-1.5 rounded-md px-2 py-1 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ce(t.id),onDoubleClick:()=>{t.kind===`file`&&U.keepFileOpen(t.id)},children:[t.kind===`phone`?(0,$.jsx)(ro,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`browser`?(0,$.jsx)(ci,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`sidechat`?(0,$.jsx)(sa,{className:`size-4 shrink-0`,"aria-hidden":!0}):t.kind===`files`?(0,$.jsx)(Kr,{className:`size-4 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(Dr,{name:t.title}),(0,$.jsx)(`span`,{className:Y(`truncate`,t.kind===`file`&&t.preview&&`italic`),children:r}),a?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:a}):null]}),(0,$.jsx)(`button`,{className:Y(AU,`size-7`),tabIndex:t.id===o.activeId?0:-1,"aria-label":`${i?`关闭`:`Close`} ${r}`,disabled:F===t.id,onClick:()=>{t.kind===`file`?xe(t.id):t.kind===`browser`?be(t.id):t.kind===`sidechat`?window.dispatchEvent(new CustomEvent(`workspace-close-sidechat`,{detail:t.sideChatId})):U.remove(t.id,e)},children:(0,$.jsx)(wo,{className:`size-3.5`,"aria-hidden":!0})})]},t.id)})}),(0,$.jsx)(`button`,{className:AU,"aria-label":i?`新建标签`:`New tab`,title:i?`新建标签`:`New tab`,onClick:()=>U.openTools(e),children:(0,$.jsx)(Ra,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{className:AU,"aria-label":N?i?`还原工作区`:`Restore workspace`:i?`放大工作区`:`Expand workspace`,onClick:()=>P(!N),children:N?(0,$.jsx)(ua,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(Zi,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{className:AU,title:i?`收起工作区 · ${o.tabs.length} 个标签`:`Collapse workspace · ${o.tabs.length} tabs`,"aria-label":re?i?`返回聊天`:`Back to chat`:i?`收起工作区`:`Collapse workspace`,onClick:()=>U.setOpen(!1,e),children:(0,$.jsx)(ya,{className:`size-5`,"aria-hidden":!0})})]}),f?(0,$.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:[f,` `,(0,$.jsx)(`button`,{className:`text-accent`,onClick:()=>Qe.getState().requestCreate(e),children:i?`重试新建侧聊`:`Retry new side chat`})]}):null,L?(0,$.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-edge px-3 py-2 text-sm text-fg-muted`,children:[L,` `,(0,$.jsx)(`button`,{className:`text-accent`,onClick:()=>R(``),children:i?`关闭提示`:`Dismiss`})]}):null,_?(0,$.jsx)(`div`,{role:`status`,className:`h-1 shrink-0 animate-pulse bg-surface-active`,"aria-label":i?`正在创建侧聊`:`Creating side chat`}):null,z?(0,$.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{children:i?`文件未保存,可能已被外部修改。编辑内容已保留。`:`File could not be saved; it may have changed externally. Your edits are retained.`}),(0,$.jsx)(`button`,{className:`mr-3 text-accent`,onClick:()=>void xe(z),children:i?`重试保存并关闭`:`Retry save and close`}),(0,$.jsx)(`button`,{className:`mr-3`,onClick:()=>{B(null),H(!1)},children:i?`继续编辑`:`Keep editing`}),(0,$.jsx)(`button`,{className:`text-red-600`,onClick:()=>H(!0),children:i?`放弃修改`:`Discard edits`}),V?(0,$.jsxs)(`div`,{role:`alertdialog`,"aria-label":i?`确认放弃修改`:`Confirm discard edits`,className:`mt-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(`p`,{children:i?`放弃此文件未保存的修改?`:`Discard unsaved edits to this file?`}),(0,$.jsxs)(`div`,{className:`mt-2 flex gap-3`,children:[(0,$.jsx)(`button`,{className:`text-accent`,onClick:()=>H(!1),children:i?`保留草稿`:`Keep draft`}),(0,$.jsx)(`button`,{onClick:()=>void xe(z,!0),children:i?`确认放弃`:`Confirm discard`})]})]}):null]}):null,(0,$.jsx)(ai.Provider,{value:Ee?{button:Ee,label:i?he?`隐藏文件树`:`显示文件树`:he?`Hide file tree`:`Show file tree`,active:he,onToggle:we}:null,children:(0,$.jsxs)(`div`,{id:`workspace-content`,role:`tabpanel`,"aria-labelledby":s?`workspace-tab-${s.id}`:void 0,className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:Y(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,me?`hidden`:`flex`),children:[W&&q?(0,$.jsx)(`div`,{id:`phone-workspace-slot`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`}):null,oe&&!me?(0,$.jsxs)(`div`,{"data-workspace-file-placeholder":!0,className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(Hr,{className:`size-9 text-fg-muted`,strokeWidth:1.25,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i?`选择文件预览`:`Select a file to preview`}),(0,$.jsx)(`p`,{className:`max-w-64 text-sm text-fg-muted`,children:i?`从右侧文件列表打开文件,在这里查看内容。`:`Open a file from the list on the right to view its contents here.`})]}):null,s?.kind===`home`&&!v?(0,$.jsx)(EU,{tabs:o.tabs,canCreateSideChat:e!==`new`,creating:!!_,onBrowser:window.electronAPI?.browser?()=>U.openBrowser(void 0,e):void 0,onFiles:()=>U.openFiles(e),onSideChat:()=>Qe.getState().requestCreate(e),onActivate:Ce,onTerminal:window.electronAPI?.terminal?()=>e===`new`?window.dispatchEvent(new Event(`workspace-open-terminal`)):qu.getState().open(e):void 0}):null,Object.entries(a).flatMap(([t,n])=>n.tabs.filter(e=>e.kind===`browser`).map(n=>(0,$.jsx)(VH,{tab:n,scope:t,active:W&&t===e&&s?.id===n.id},n.id))),(0,$.jsx)(Qr.Provider,{value:[{id:e,label:i?`引用到主聊天`:`Reference in main chat`},...ge?.returnTo?.startsWith(`side:`)?[{id:ge.returnTo.slice(5),label:i?`引用到来源侧聊`:`Reference in source side chat`}]:[]],children:ke.map(({owner:t,tab:n})=>{let r=ee&&t===e&&s?.id===n.id;if(n.attachment)return r?(0,$.jsx)(Ac,{tabId:n.id,embedded:!0,open:!0,attachment:n.attachment,images:n.images,onAttachmentChange:e=>U.openFile({attachment:e,images:n.images,conversationId:n.conversationId},t),authToken:y,conversationId:n.conversationId,onClose:()=>void xe(n.id)},n.id):null;let i=[`code`,`text`,`markdown`,`html`].includes(ti(n.title));return!r&&(!i||!Ae.has(n.id)&&!m[n.id])?null:(0,$.jsx)(wu,{tabId:n.id,active:r,filePath:n.path??null,projectId:n.projectId,conversationId:n.conversationId,agentId:n.agentId,targetLine:n.line,resultRevision:n.resultRevision,onClose:()=>void xe(n.id)},n.id)})}),Oe.map(t=>(0,$.jsx)(ni.Provider,{value:t,children:(0,$.jsx)(yU,{parentConversationId:t,embedded:!0,visible:ee&&e===t&&(s?.kind===`sidechat`||(!s||s.kind===`home`)&&v)})},t))]}),pe&&!me&&!O?(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":i?`调整文件树宽度`:`Resize file tree`,"aria-valuemin":200,"aria-valuemax":Math.min(320,ce-le-8),"aria-valuenow":ue,className:`z-10 w-2 shrink-0 cursor-col-resize touch-none bg-surface-base transition-colors duration-150 hover:bg-accent/20 focus-visible:bg-accent/30`,onPointerDown:e=>De(e,!0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),U.setTreeWidth(Math.min(ce-le-8,ue+(e.key===`ArrowLeft`?20:-20))))}}):null,O?(0,$.jsx)(`button`,{"data-browser-occluder":!0,style:{top:A},className:`absolute inset-0 z-20 bg-scrim`,"aria-label":i?`关闭文件树`:`Close file tree`,onClick:()=>k(!1)}):null,(0,$.jsx)(`div`,{"data-workspace-tree":!0,className:Y(`min-h-0 min-w-0 flex-col overflow-hidden border-l border-edge-subtle bg-surface-base`,he?`flex`:`hidden`,me&&`flex-1`,O&&`absolute inset-y-0 right-0 z-30 bg-surface-base shadow-popover`),style:me?void 0:{width:O?l:ue,...O?{top:A}:{}},children:Object.entries(J).map(([t,n])=>(0,$.jsx)(`div`,{className:Y(`h-full min-h-0 flex-col`,t===ve?`flex`:`hidden`),children:(0,$.jsx)(YH,{embedded:!0,scope:n,onCloseTree:()=>O?k(!1):oe?s&&U.remove(s.id,e):s?.kind===`browser`?M(!1):U.setTreeOpen(s?.kind===`sidechat`?`sidechat`:`file`,!1)})},t))})]})})]})}function MU(e){pt(e)}var NU=32e3,PU=264,FU=10;function IU(e){let t=(0,Q.c)(36),{conversationId:n}=e,{pathname:r}=p(),i=zo(BU),a;t[0]===i?a=t[1]:(a=Do(i),t[0]=i,t[1]=a);let o=a.sideChat,s=Qe(zU),c=Qe(RU),[l,u]=(0,Z.useState)(null),d;t[2]!==n||t[3]!==c?(d=()=>{if(!n||n===`new`||c){u(null);return}let e=window.getSelection(),t=e?.toString().trim()??``;if(!e||e.rangeCount===0||!t||t.length>NU){u(null);return}let r=e.getRangeAt(0),i=VU(e.anchorNode),a=VU(e.focusNode),o=document.getElementById(`app-main-content`),s=document.getElementById(`app-side-chat-panel`),l=!!(s?.contains(i)&&s?.contains(a));if(!i||!a||!l&&(!o?.contains(i)||!o.contains(a))||!i.closest(`[data-chat-message-index]`)||!a.closest(`[data-chat-message-index]`)){u(null);return}let d=r.getBoundingClientRect();if(d.width===0&&d.height===0){u(null);return}let f=Math.min(window.innerWidth-PU-FU,Math.max(FU,d.left+d.width/2-PU/2)),p=d.bottom+8,m=p+38<window.innerHeight?p:Math.max(FU,d.top-42);u({text:t,left:f,top:m,fromSide:l})},t[2]=n,t[3]=c,t[4]=d):d=t[4];let f=d,m;t[5]!==n||t[6]!==f?(m=()=>{if(u(null),!n)return;let e=()=>window.requestAnimationFrame(f),t=()=>u(null);return document.addEventListener(`pointerup`,e),document.addEventListener(`keyup`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`pointerup`,e),document.removeEventListener(`keyup`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},t[5]=n,t[6]=f,t[7]=m):m=t[7];let h;if(t[8]!==n||t[9]!==f||t[10]!==r?(h=[n,f,r],t[8]=n,t[9]=f,t[10]=r,t[11]=h):h=t[11],(0,Z.useEffect)(m,h),!l||!n||n===`new`)return null;let g=l.fromSide?PU/2:PU,_;t[12]!==l.left||t[13]!==l.top||t[14]!==g?(_={left:l.left,top:l.top,width:g},t[12]=l.left,t[13]=l.top,t[14]=g,t[15]=_):_=t[15];let v;t[16]===l.text?v=t[17]:(v=()=>{MU(l.text),window.getSelection()?.removeAllRanges(),u(null)},t[16]=l.text,t[17]=v);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Ra,{className:`size-3.5 shrink-0`}),t[18]=y):y=t[18];let b;t[19]===o.addToChat?b=t[20]:(b=(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:o.addToChat}),t[19]=o.addToChat,t[20]=b);let x;t[21]!==v||t[22]!==b?(x=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex flex-1 items-center justify-center gap-1.5 px-3 transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:v,children:[y,b]}),t[21]=v,t[22]=b,t[23]=x):x=t[23];let S;t[24]!==n||t[25]!==o.askInSideChat||t[26]!==o.selectedText||t[27]!==l.fromSide||t[28]!==l.text||t[29]!==s?(S=l.fromSide?null:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex flex-1 items-center justify-center gap-1.5 border-l border-edge px-3 transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>{s(n,[{id:crypto.randomUUID(),type:`text`,text:l.text,label:o.selectedText}]),window.getSelection()?.removeAllRanges(),u(null)},children:[(0,$.jsx)(oa,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:o.askInSideChat})]}),t[24]=n,t[25]=o.askInSideChat,t[26]=o.selectedText,t[27]=l.fromSide,t[28]=l.text,t[29]=s,t[30]=S):S=t[30];let C;return t[31]!==o.selectedTextActionsAria||t[32]!==x||t[33]!==S||t[34]!==_?(C=(0,$.jsxs)(`div`,{role:`group`,"aria-label":o.selectedTextActionsAria,className:`fixed z-[70] flex h-9 overflow-hidden rounded-lg border border-edge bg-surface-overlay text-xs font-medium text-fg shadow-popover`,style:_,onPointerDown:LU,children:[x,S]}),t[31]=o.selectedTextActionsAria,t[32]=x,t[33]=S,t[34]=_,t[35]=C):C=t[35],C}function LU(e){return e.preventDefault()}function RU(e){return e.pendingCreate}function zU(e){return e.requestCreate}function BU(e){return e.language}function VU(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function HU(e){let t=(0,Q.c)(8),n=Ro(UU),r;t[0]===e?r=t[1]:(r=l(`/chat/task/:taskId`,e),t[0]=e,t[1]=r);let i=r,a=i?decodeURIComponent(i.params.taskId??``):``,o;t[2]!==a||t[3]!==n?(o=ce(a,n),t[2]=a,t[3]=n,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s={keepPreviousData:!1},t[5]=s):s=t[5];let{data:c}=qo(o,null,s);if(i)return c?.conversation.activeConversationId??null;let u;t[6]===e?u=t[7]:(u=l(`/chat/:conversationId`,e),t[6]=e,t[7]=u);let d=u?.params.conversationId;return d&&d!==`new`?decodeURIComponent(d):null}function UU(e){return e.conversationId}function WU(){let e=(0,Q.c)(28),t=(0,Z.useRef)(null),n=Ro(ZU),r=Ro(XU),i=Ro(YU),a=Ro(JU),o=Ro(qU),s=Ro(KU),c=zo(GU),l;e[0]===c?l=e[1]:(l=Do(c),e[0]=c,e[1]=l);let u=l.token,d=!!s&&!i,f;e[2]!==d||e[3]!==o?(f=e=>{!e&&!d||e||o()},e[2]=d,e[3]=o,e[4]=f):f=e[4];let p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(rs,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[2px]`,vs)}),e[5]=p):p=e[5];let m,h;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4`,gs,`dark:border-edge`),h=e=>{e.preventDefault(),t.current?.focus()},e[6]=m,e[7]=h):(m=e[6],h=e[7]);let g;e[8]===u.title?g=e[9]:(g=(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:u.title}),e[8]=u.title,e[9]=g);let _;e[10]===u.description?_=e[11]:(_=(0,$.jsx)(as,{className:`mt-1 text-sm text-fg-muted`,children:u.description}),e[10]=u.description,e[11]=_);let v;e[12]!==d||e[13]!==o||e[14]!==c?(v=d?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=d,e[13]=o,e[14]=c,e[15]=v):v=e[15];let y;e[16]!==r||e[17]!==a||e[18]!==v?(y=(0,$.jsx)(Ez,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:v}),e[16]=r,e[17]=a,e[18]=v,e[19]=y):y=e[19];let b;e[20]!==g||e[21]!==_||e[22]!==y?(b=(0,$.jsxs)(ss,{children:[p,(0,$.jsxs)(cs,{className:m,onOpenAutoFocus:h,children:[g,_,y]})]}),e[20]=g,e[21]=_,e[22]=y,e[23]=b):b=e[23];let x;return e[24]!==n||e[25]!==f||e[26]!==b?(x=(0,$.jsx)(us,{open:n,onOpenChange:f,children:b}),e[24]=n,e[25]=f,e[26]=b,e[27]=x):x=e[27],x}function GU(e){return e.language}function KU(e){return e.conversationId}function qU(e){return e.closeTokenDialog}function JU(e){return e.setBrowserSession}function YU(e){return e.tokenExpired}function XU(e){return e.baseUrl}function ZU(e){return e.tokenDialogOpen}function QU(e){return e?e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `):null}function $U(e){let t=(0,Q.c)(15),{item:n,onInvoke:r}=e;if(n.type===`separator`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ju,{className:`my-1 h-px bg-edge-subtle`}),t[0]=e):e=t[0],e}let i;t[1]===n.accelerator?i=t[2]:(i=QU(n.accelerator),t[1]=n.accelerator,t[2]=i);let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=Y(`flex min-h-7 cursor-default select-none items-center gap-6 rounded-md px-2 py-1.5 text-xs text-fg outline-none`,`data-[highlighted]:bg-surface-hover data-[highlighted]:text-fg`),t[3]=o):o=t[3];let s;t[4]!==n.id||t[5]!==r?(s=()=>r(n.id),t[4]=n.id,t[5]=r,t[6]=s):s=t[6];let c;t[7]===n.label?c=t[8]:(c=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),t[7]=n.label,t[8]=c);let l;t[9]===a?l=t[10]:(l=a?(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-mono text-[11px] text-fg-subtle`,children:a}):null,t[9]=a,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,$.jsxs)(Au,{className:o,onSelect:s,children:[c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function eW(e){let t=(0,Q.c)(6),{groups:n}=e,r=tW,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=Y(`windows-titlebar-interactive flex min-w-0 items-center gap-1`,sl),t[0]=i):i=t[0];let a;if(t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>(0,$.jsxs)(ku,{modal:!1,children:[(0,$.jsx)(Ou,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 shrink-0 items-center rounded-md px-3 text-sm font-normal text-fg-muted`,`outline-none transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent/60 data-[state=open]:bg-surface-hover data-[state=open]:text-fg`,sl),role:`menuitem`,children:e.label})}),(0,$.jsx)(Du,{children:(0,$.jsx)(Mu,{align:`start`,sideOffset:4,className:Y(`windows-titlebar-interactive z-[90] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,sl),children:e.items.map((t,n)=>(0,$.jsx)($U,{item:t,onInvoke:r},t.type===`item`?t.id:`${e.id}-separator-${n}`))})})]},e.id),t[3]=e):e=t[3],a=n.map(e),t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:i,role:`menubar`,children:a}),t[4]=a,t[5]=o),o}function tW(e){window.electronAPI?.menu?.invoke(e)}var nW=(0,Z.memo)(function(){let e=(0,Q.c)(11),t=zo(rW),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0];let[r,i]=(0,Z.useState)(n),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{if(!$o())return;let e=!1;return window.electronAPI?.menu?.getModel().then(t=>{e||i(t)}).catch(()=>{e||i([])}),()=>{e=!0}},e[1]=a):a=e[1];let o;if(e[2]===t?o=e[3]:(o=[t],e[2]=t,e[3]=o),(0,Z.useEffect)(a,o),!$o())return null;let s,c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=Y(`windows-titlebar flex h-9 min-w-0 shrink-0 items-center gap-2 border-b border-edge-subtle`),c=(0,$.jsx)(`div`,{className:Y(`windows-titlebar-interactive flex shrink-0 items-center gap-0.5`,sl),children:(0,$.jsx)(qz,{sidebarToggleVariant:`main`})}),e[4]=s,e[5]=c):(s=e[4],c=e[5]);let l;e[6]===r?l=e[7]:(l=(0,$.jsx)(eW,{groups:r}),e[6]=r,e[7]=l);let u;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:Y(`min-w-8 flex-1 self-stretch`,ol),"aria-hidden":!0}),e[8]=u):u=e[8];let d;return e[9]===l?d=e[10]:(d=(0,$.jsxs)(`header`,{className:s,children:[c,l,u]}),e[9]=l,e[10]=d),d});function rW(e){return e.language}function iW(){let e=(0,Q.c)(16),t=zo(aW),n;e[0]===t?n=e[1]:(n=Do(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,Z.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!Ol())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Z.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,$.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let u;e[7]===r.gatewayExitBody?u=e[8]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=u);let d=i.code??`—`,f=i.signal??`—`,p;e[9]!==d||e[10]!==f?(p=(0,$.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,d,` · signal `,f]}),e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==p?(m=(0,$.jsxs)(`div`,{className:c,role:`alert`,children:[l,u,p]}),e[12]=l,e[13]=u,e[14]=p,e[15]=m):m=e[15],m}function aW(e){return e.language}function oW(e){return{content:[{type:`text`,text:e}]}}function sW(e,t,n){if(Object.keys(e).length!==1||typeof e[t]!=`string`)throw TypeError(`Expected exactly one string argument: ${t}`);let r=e[t];if(!r||r.length>n)throw TypeError(`Invalid ${t}`);return r}function cW(e){let t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function lW(e){return[{descriptor:tl(`desktop`,`state`),async execute(t){if(Object.keys(t).length)throw TypeError(`Expected no arguments`);let n=e().device;if(!n)throw Error(`Device environment is unavailable`);return{content:[{type:`json`,value:{...await n.readState(),capturedAt:Date.now()}}]}}},{descriptor:{name:`desktop.file.pick`,title:`Choose a local file`,description:`Ask the user to choose one local file and make it available to the agent.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},outputSchema:Zc,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-read`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`file`]},async execute(t,n){if(Object.keys(t).length!==0)throw TypeError(`Expected no arguments`);let r=await e().file.pickEndpointFile();if(!r)throw new DOMException(`File selection cancelled`,`AbortError`);let i=cW(r.dataBase64);if(i.byteLength!==r.size||i.byteLength>26214400)throw Error(`Selected file payload is invalid`);return{content:[await n.uploadFile({name:r.name,mimeType:r.mimeType,bytes:i})]}}},{descriptor:{name:`desktop.file.save`,title:`Save a text file`,description:`Ask the user where to save UTF-8 text generated by the agent.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`suggestedName`,`content`],properties:{suggestedName:{type:`string`,minLength:1,maxLength:255},content:{type:`string`,maxLength:2e5}}},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-write`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=t.suggestedName,r=t.content;if(Object.keys(t).length!==2||typeof n!=`string`||!n||n.length>255||typeof r!=`string`||r.length>2e5||new TextEncoder().encode(r).byteLength>200*1024)throw TypeError(`Invalid file save arguments`);let i=await e().file.saveEndpointText({suggestedName:n,content:r});if(!i.saved)throw new DOMException(`File save cancelled`,`AbortError`);return oW(`Saved ${i.name}`)}},{descriptor:{name:`desktop.notification.show`,title:`Show a notification`,description:`Show a bounded native desktop notification after user confirmation.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`title`,`body`],properties:{title:{type:`string`,minLength:1,maxLength:120},body:{type:`string`,minLength:1,maxLength:500}}},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`notifications`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=t.title,r=t.body;if(Object.keys(t).length!==2||typeof n!=`string`||!n.trim()||n.length>120||typeof r!=`string`||!r.trim()||r.length>500)throw TypeError(`Invalid notification arguments`);let i=e().system;if(!i)throw Error(`Desktop notifications are unavailable`);let a=await i.showEndpointNotification({title:n,body:r});if(!a.ok)throw a.error===`PERMISSION_DENIED`||a.error===`NOTIFICATIONS_DISABLED`?new DOMException(`Desktop notification permission is not granted`,`NotAllowedError`):Error(`Desktop notification failed: ${a.error}`);return oW(`Notification shown.`)}},{descriptor:{name:`desktop.clipboard.read`,title:`Read the clipboard`,description:`Read plain text from the desktop clipboard.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},outputSchema:Wc,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-read`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(t){if(Object.keys(t).length!==0)throw TypeError(`Expected no arguments`);let n=e().clipboard;if(!n?.readText)throw Error(`Clipboard read is unavailable`);return oW(await n.readText())}},{descriptor:{name:`desktop.clipboard.write`,title:`Write to the clipboard`,description:`Replace the desktop clipboard with plain text.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`text`],properties:{text:{type:`string`,minLength:1,maxLength:1e5}}},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-write`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(t){let n=sW(t,`text`,1e5),r=e().clipboard;if(!r?.writeText||!await r.writeText(n))throw Error(`Clipboard write failed`);return oW(`Clipboard updated.`)}},{descriptor:{name:`desktop.app.open_external`,title:`Open an external URL`,description:`Open an HTTP or HTTPS URL in the default desktop application.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,maxLength:2048}}},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`open-external-url`],timeoutMs:15e3,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=sW(t,`url`,2048),r=new URL(n);if(r.protocol!==`http:`&&r.protocol!==`https:`)throw TypeError(`Only HTTP and HTTPS URLs are allowed`);let i=e().shell;if(!i?.openExternalUrl)throw Error(`External URL opening is unavailable`);let a=await i.openExternalUrl(r.href);if(!a.ok)throw Error(a.error);return oW(`Opened ${r.href}`)}}]}var uW=lW(()=>{if(!window.electronAPI)throw Error(`Desktop bridge is unavailable`);return{...window.electronAPI,device:{readState:async()=>({platform:window.electronAPI.platform,systemVersion:``,locale:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}}}),dW=600,fW=[],pW=new Set;function mW(){for(let e of pW)e()}function hW(){return fW[0]}function gW(e){return pW.add(e),()=>pW.delete(e)}function _W(e){let t=JSON.stringify(e,null,2);return t.length<=dW?t:`${t.slice(0,dW)}\n…`}function vW(e){return e.deadlineAt<=Date.now()?Promise.resolve(!1):new Promise(t=>{let n=window.setTimeout(()=>yW(e.invocationId,!1),e.deadlineAt-Date.now());fW.push({invocationId:e.invocationId,title:e.title,toolName:e.toolName,argumentsPreview:_W(e.args),resolve:t,timeout:n}),mW()})}function yW(e,t){let n=fW.findIndex(t=>t.invocationId===e);if(n<0)return;let[r]=fW.splice(n,1);window.clearTimeout(r.timeout),r.resolve(t),mW()}function bW(){let e=fW;fW=[];for(let t of e)window.clearTimeout(t.timeout),t.resolve(!1);mW()}function xW(){return(0,Z.useSyncExternalStore)(gW,hW,hW)}function SW(){let e=(0,Q.c)(42),t=xW(),n=zo(CW)===`zh`,r;e[0]===t?.toolName?r=e[1]:(r=t?.toolName?.endsWith(`.device.get_location`),e[0]=t?.toolName,e[1]=r);let i=r,a;e[2]!==i||e[3]!==t?(a=i?JSON.parse(t.argumentsPreview):void 0,e[2]=i,e[3]=t,e[4]=a):a=e[4];let o=a,s=!!t,c;e[5]===t?c=e[6]:(c=e=>{!e&&t&&yW(t.invocationId,!1)},e[5]=t,e[6]=c);let l;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[140] bg-scrim backdrop-blur-[2px]`}),e[7]=l):l=e[7];let u=i?n?`允许本次使用位置?`:`Use location once?`:n?`允许端侧工具执行?`:`Allow endpoint tool?`,d;e[8]===u?d=e[9]:(d=(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:u}),e[8]=u,e[9]=d);let f=t?.title??``,p;e[10]===f?p=e[11]:(p=(0,$.jsx)(as,{className:`mt-1 text-sm text-fg-muted`,children:f}),e[10]=f,e[11]=p);let m;e[12]!==d||e[13]!==p?(m=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-5 py-4`,children:[d,p]}),e[12]=d,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==o?.precision||e[16]!==o?.purpose||e[17]!==i||e[18]!==t?.argumentsPreview||e[19]!==n?(h=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:i?(0,$.jsxs)(`div`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[n?`用途:`:`Purpose: `,o?.purpose===`weather`?n?`查询天气`:`Weather`:n?`查询附近地点`:`Nearby places`]}),(0,$.jsxs)(`p`,{children:[n?`精度:`:`Precision: `,o?.precision===`precise`?n?`精确位置`:`Precise`:n?`大致位置`:`Approximate`]}),(0,$.jsxs)(`p`,{children:[n?`此浏览器的位置仅用于本次查询。坐标将发送给 `:`This browser’s location is used only for this query. Coordinates are sent to `,o?.purpose===`weather`?`Open-Meteo`:`OpenStreetMap`,n?`,原始坐标不进入聊天历史。系统权限开启后,每次调用仍需确认。`:`; raw coordinates are excluded from chat history. Each call requires consent even when OS permission is enabled.`]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n?`实际参数`:`Arguments`}),(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-lg border border-edge bg-surface-base p-3 font-mono text-xs leading-5 text-fg`,children:t?.argumentsPreview??`{}`})]})}),e[15]=o?.precision,e[16]=o?.purpose,e[17]=i,e[18]=t?.argumentsPreview,e[19]=n,e[20]=h):h=e[20];let g;e[21]===t?g=e[22]:(g=()=>t&&yW(t.invocationId,!1),e[21]=t,e[22]=g);let _=n?`拒绝`:`Deny`,v;e[23]!==g||e[24]!==_?(v=(0,$.jsx)(X,{onClick:g,children:_}),e[23]=g,e[24]=_,e[25]=v):v=e[25];let y;e[26]===t?y=e[27]:(y=()=>t&&yW(t.invocationId,!0),e[26]=t,e[27]=y);let b=n?`允许一次`:`Allow once`,x;e[28]!==y||e[29]!==b?(x=(0,$.jsx)(X,{variant:`primary`,onClick:y,children:b}),e[28]=y,e[29]=b,e[30]=x):x=e[30];let S;e[31]!==v||e[32]!==x?(S=(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[v,x]}),e[31]=v,e[32]=x,e[33]=S):S=e[33];let C;e[34]!==h||e[35]!==S||e[36]!==m?(C=(0,$.jsxs)(ss,{children:[l,(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[150] flex h-[min(26rem,calc(100vh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[m,h,S]})]}),e[34]=h,e[35]=S,e[36]=m,e[37]=C):C=e[37];let w;return e[38]!==C||e[39]!==s||e[40]!==c?(w=(0,$.jsx)(us,{open:s,onOpenChange:c,children:C}),e[38]=C,e[39]=s,e[40]=c,e[41]=w):w=e[41],w}function CW(e){return e.language}function wW(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function TW(e,...t){if(!wW(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function EW(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function DW(e,t){TW(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function OW(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function kW(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function AW(e,t){return e<<32-t|e>>>t}function jW(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function MW(e){return typeof e==`string`&&(e=jW(e)),TW(e),e}var NW=class{};function PW(e){let t=t=>e().update(MW(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function FW(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function IW(e,t,n){return e&t^~e&n}function LW(e,t,n){return e&t^e&n^t&n}var RW=class extends NW{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=kW(this.buffer)}update(e){EW(this),e=MW(e),TW(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=kW(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){EW(this),DW(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,OW(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;FW(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=kW(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},zW=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),BW=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),VW=new Uint32Array(64),HW=class extends RW{constructor(e=32){super(64,e,8,!1),this.A=zW[0]|0,this.B=zW[1]|0,this.C=zW[2]|0,this.D=zW[3]|0,this.E=zW[4]|0,this.F=zW[5]|0,this.G=zW[6]|0,this.H=zW[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)VW[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=VW[e-15],n=VW[e-2],r=AW(t,7)^AW(t,18)^t>>>3;VW[e]=(AW(n,17)^AW(n,19)^n>>>10)+VW[e-7]+r+VW[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=AW(o,6)^AW(o,11)^AW(o,25),u=l+t+IW(o,s,c)+BW[e]+VW[e]|0,d=(AW(n,2)^AW(n,13)^AW(n,22))+LW(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){OW(VW)}destroy(){this.set(0,0,0,0,0,0,0,0),OW(this.buffer)}},UW=PW(()=>new HW),WW=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`EndpointToolClientError`}};function GW(e){return[...UW(new TextEncoder().encode(Jc(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var KW=class{tools=new Map;constructor(e){for(let t of e){let e=t.descriptor.name;if(this.tools.has(e))throw Error(`Duplicate endpoint tool: ${e}`);this.tools.set(e,{definition:t,revision:GW(t.descriptor)})}}descriptors(){return[...this.tools.values()].map(({definition:e})=>e.descriptor)}get(e){return this.tools.get(e)}},qW=class{options;active=new Map;now;sendMessage;generation=0;constructor(e){this.options=e,this.now=e.now??Date.now}connect(e){this.disconnect(),this.sendMessage=e}disconnect(){this.generation+=1,this.sendMessage=void 0;for(let e of this.active.values())e.controller.abort();this.active.clear()}publishAvailability(){this.send(`endpoint.availability_changed`,{availability:this.options.getAvailability()})}async handleMessage(e){if(e.type===`tool.cancel`){this.cancel(e.payload.invocationId);return}await this.invoke(e)}async invoke(e){let{invocationId:t,toolName:n,arguments:r,descriptorRevision:i,confirmationRequired:a,deadlineAt:o,uploadGrant:s}=e.payload;if(this.active.has(t)){this.sendError(t,`PROTOCOL_ERROR`,`Endpoint invocation is already running`);return}this.send(`tool.received`,{invocationId:t});let c=this.options.registry.get(n);if(!c){this.sendError(t,`TOOL_NOT_FOUND`,`Endpoint tool is not registered`);return}if(c.revision!==i){this.sendError(t,`TOOL_REVISION_MISMATCH`,`Endpoint tool contract changed`);return}let l=c.definition.descriptor,u=l.confirmation===`always`;if(a!==u){this.sendError(t,`PROTOCOL_ERROR`,`Endpoint confirmation policy mismatch`);return}let d={controller:new AbortController,generation:this.generation};this.active.set(t,d);try{this.assertExecutable(t,d,l,o);let e={invocationId:t,descriptor:l,arguments:r,deadlineAt:o,signal:d.controller.signal};if(await this.options.authorize?.(e),this.assertExecutable(t,d,l,o),u){this.send(`tool.progress`,{invocationId:t,message:`Waiting for approval`});let n=await this.options.confirm(e);if(this.assertExecutable(t,d,l,o),!n)throw new WW(`USER_DENIED`,`User denied the endpoint tool call`)}let n=await c.definition.execute(r,{invocationId:t,signal:d.controller.signal,reportProgress:e=>{this.isCurrent(t,d)&&this.send(`tool.progress`,{invocationId:t,...e})},uploadFile:e=>(this.assertExecutable(t,d,l,o),this.options.uploadFile(s,e,{signal:d.controller.signal,invocationId:t}))});this.assertExecutable(t,d,l,o);let i=Kc.array().min(1).max(20).parse(n.content);if(this.send(`tool.result`,{invocationId:t,content:i,...n.details?{details:n.details}:{}}),this.active.delete(t),n.afterSend){let e=d.generation;setTimeout(()=>{this.generation===e&&this.now()<o&&(!l.requiresForeground||this.options.getAvailability()===`foreground`)&&n.afterSend?.()},this.options.afterSendDelayMs??50)}}catch(e){if(!this.isCurrent(t,d))return;this.active.delete(t);let n=this.normalizeError(e);this.sendError(t,n.code,n.message)}}cancel(e){let t=this.active.get(e);t&&(this.active.delete(e),t.controller.abort(),this.send(`tool.cancelled`,{invocationId:e}))}assertExecutable(e,t,n,r){if(!this.isCurrent(e,t)||t.controller.signal.aborted)throw new WW(`TOOL_CANCELLED`,`Endpoint tool call was cancelled`);if(this.now()>=r)throw new WW(`TOOL_TIMEOUT`,`Endpoint tool deadline expired`);if(n.requiresForeground&&this.options.getAvailability()!==`foreground`)throw new WW(`ENDPOINT_NOT_FOREGROUND`,`Endpoint is not foreground`)}isCurrent(e,t){return this.active.get(e)===t&&t.generation===this.generation&&this.sendMessage!==void 0}normalizeError(e){return e instanceof WW?e:e instanceof Error&&e.name===`RealtimeFrameTooLargeError`?new WW(`RESULT_TOO_LARGE`,e.message):e instanceof TypeError?new WW(`INVALID_ARGUMENTS`,e.message):e instanceof Error&&e.name===`AbortError`?new WW(`USER_DENIED`,e.message):e instanceof Error&&e.name===`NotAllowedError`?new WW(`PERMISSION_DENIED`,e.message):new WW(`PROTOCOL_ERROR`,e instanceof Error?e.message:String(e))}sendError(e,t,n){this.send(`tool.error`,{invocationId:e,code:t,message:n})}send(e,t){this.sendMessage?.({protocolVersion:2,messageId:this.options.createMessageId(),type:e,sentAt:this.now(),payload:t})}},JW=`xopc-endpoint-tools`,YW=`identity`,XW=`xopc.endpoint-tools.endpoint-id`,ZW;function QW(e){if(ZW?.startsWith(`${e}:`))return ZW;let t=sessionStorage.getItem(XW);return t?.startsWith(`${e}:`)?(ZW=t,t):(ZW=`${e}:${crypto.randomUUID()}`,sessionStorage.setItem(XW,ZW),ZW)}function $W(e){let t=String.fromCharCode(...new Uint8Array(e));return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/u,``)}function eG(){return new Promise((e,t)=>{let n=indexedDB.open(JW,1);n.onupgradeneeded=()=>n.result.createObjectStore(YW),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Endpoint identity database failed`))})}async function tG(e){let t=await eG();try{return await new Promise((n,r)=>{let i=t.transaction(YW).objectStore(YW).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error??Error(`Endpoint identity read failed`))})}finally{t.close()}}async function nG(e,t){let n=await eG();try{await new Promise((r,i)=>{let a=n.transaction(YW,`readwrite`);a.objectStore(YW).put(t,e),a.oncomplete=()=>r(),a.onerror=()=>i(a.error??Error(`Endpoint identity write failed`))})}finally{n.close()}}async function rG(e){let t=await eG();try{await new Promise((n,r)=>{let i=t.transaction(YW,`readwrite`);i.objectStore(YW).delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error??Error(`Endpoint identity deletion failed`))})}finally{t.close()}}async function iG(e){let t=await tG(e);if(t)return t;let n=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!0,[`sign`,`verify`]),r=$W(await crypto.subtle.exportKey(`spki`,n.publicKey)),i=await crypto.subtle.importKey(`pkcs8`,await crypto.subtle.exportKey(`pkcs8`,n.privateKey),{name:`ECDSA`,namedCurve:`P-256`},!1,[`sign`]),a={principalId:crypto.randomUUID(),publicKey:r,privateKey:i};return await nG(e,a),a}async function aG(e){return await rG(e),ZW=void 0,sessionStorage.removeItem(XW),iG(e)}async function oG(e,t){return $W(await crypto.subtle.sign({name:`ECDSA`,hash:`SHA-256`},e,new TextEncoder().encode(t)))}var sG=2e3;function cG(){return document.visibilityState===`visible`&&document.hasFocus()?`foreground`:`background`}async function lG(e){if(e.signal.aborted)return!1;let t=()=>yW(e.invocationId,!1);e.signal.addEventListener(`abort`,t,{once:!0});try{return await vW({invocationId:e.invocationId,title:e.descriptor.title,toolName:e.descriptor.name,args:e.arguments,deadlineAt:e.deadlineAt})}finally{e.signal.removeEventListener(`abort`,t)}}var uG=class{config;reconnectTimer;connectPromise;detachRealtime;stopped=!1;registrationBlocked=!1;endpointId;supportsDeviceState=!1;supportsLocationTasks=!1;turnToken;registry;controller;constructor(e){this.config=e,this.registry=new KW(e.definitions),this.controller=new qW({registry:this.registry,getAvailability:cG,confirm:lG,uploadFile:(e,t)=>this.uploadFile(e,t),createMessageId:()=>crypto.randomUUID()})}async start(){this.stopped=!1,this.registrationBlocked=!1,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`gateway-authenticated`,this.onTokenSaved),await this.connect()}stop(){this.stopped=!0,dc(!1),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`gateway-authenticated`,this.onTokenSaved),window.clearTimeout(this.reconnectTimer),this.detachRealtime?.(),this.detachRealtime=void 0,this.controller.disconnect(),ic(this.turnToken),this.turnToken=void 0,this.endpointId=void 0,bW()}onTokenSaved=()=>{this.registrationBlocked=!1,this.connect()};onVisibilityChange=()=>{this.controller.publishAvailability()};connect(e=!0){if(this.connectPromise)return this.connectPromise;let t=this.connectOnce(e).finally(()=>{this.connectPromise===t&&(this.connectPromise=void 0)});return this.connectPromise=t,t}async connectOnce(e){if(!(this.stopped||this.registrationBlocked)){window.clearTimeout(this.reconnectTimer);try{let t=await Po(Lo(`/api/endpoint-tools/compatibility`)),n=await t.json().catch(()=>null);dc(t.ok&&n?.payload?.turnDeviceContextV1===!0),this.supportsLocationTasks=t.ok&&n?.payload?.deviceLocationTasksV1===!0,this.supportsDeviceState=t.ok&&n?.payload?.deviceStateToolsV1===!0;let r=await iG(this.config.kind);if(this.stopped)return;let i=await Po(Lo(`/api/endpoint-tools/principals`),{method:`POST`,body:JSON.stringify({principalId:r.principalId,displayName:this.config.displayName,kind:this.config.kind,platform:this.config.platform,publicKey:r.publicKey})});if(!i.ok){if((await i.json().catch(()=>null))?.error?.code===`PRINCIPAL_REVOKED`){if(!e){this.registrationBlocked=!0;return}let t=await this.config.confirmReenrollment();if(this.stopped)return;if(!t){this.registrationBlocked=!0;return}await aG(this.config.kind),this.stopped||await this.connectOnce(!1);return}if(i.status>=400&&i.status<500){this.registrationBlocked=!0;return}throw Error(`Endpoint registration failed: ${i.status}`)}if(this.stopped)return;let a={createHello:()=>this.createHello(r),onReady:({endpointId:e,turnToken:t})=>{this.endpointId=e,this.turnToken=t,sc(e,t),this.controller.connect(Qc)},onMessage:e=>{this.controller.handleMessage(e)},onDisconnected:()=>{this.controller.disconnect(),ic(this.turnToken),this.turnToken=void 0,bW()}};this.detachRealtime?.(),this.detachRealtime=el(a)}catch{this.scheduleReconnect()}}}scheduleReconnect(){this.stopped||this.reconnectTimer!==void 0||(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=void 0,this.connect()},sG))}async createHello(e){let t=QW(e.principalId);this.endpointId=t;let n={principalId:e.principalId,endpointId:t,connectionInstanceId:crypto.randomUUID(),displayName:this.config.displayName,kind:this.config.kind,platform:this.config.platform,appVersion:this.config.appVersion,availability:cG(),nonce:crypto.randomUUID(),signedAt:Date.now(),signature:`pending`,tools:this.registry.descriptors().filter(e=>e.name.endsWith(`.device.get_location`)?this.supportsLocationTasks:this.supportsDeviceState||!e.name.includes(`.device.get_`))},r=await oG(e.privateKey,Gc(n));return{...n,signature:r}}async uploadFile(e,t){if(!e||!this.endpointId)throw Error(`Endpoint file upload grant is unavailable`);if(!t.name||t.name.length>255||!t.mimeType||t.mimeType.length>255||t.bytes.byteLength>e.maxBytes||e.expiresAt<=Date.now())throw TypeError(`Endpoint file is invalid`);let n=new URL(Lo(e.path),window.location.href);n.searchParams.set(`name`,t.name);let r=t.bytes.buffer.slice(t.bytes.byteOffset,t.bytes.byteOffset+t.bytes.byteLength),i=await Po(n,{method:`POST`,headers:{"Content-Type":t.mimeType,"x-endpoint-id":this.endpointId,"x-endpoint-upload-token":e.token},body:r}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error?.message??`Endpoint file upload failed: ${i.status}`);let o=Kc.safeParse(a?.payload);if(!o.success||o.data.type!==`file`)throw Error(`Endpoint file upload returned an invalid response`);return o.data}},dG,fG=new Set;function pG(){for(let e of fG)e()}function mG(e){return fG.add(e),()=>fG.delete(e)}function hG(){return!!dG}function gG(){return dG?Promise.resolve(!1):new Promise(e=>{dG={resolve:e},pG()})}function _G(e){let t=dG;t&&(dG=void 0,t.resolve(e),pG())}function vG(){return(0,Z.useSyncExternalStore)(mG,hG,hG)}function yG(){let e=(0,Q.c)(21),t=vG(),n=zo(CG)===`zh`,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[140] bg-scrim backdrop-blur-[2px]`}),e[0]=r):r=e[0];let i=n?`重新注册此端?`:`Re-enroll this endpoint?`,a;e[1]===i?a=e[2]:(a=(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:i}),e[1]=i,e[2]=a);let o=n?`此端身份已被撤销。继续会删除旧密钥并生成一个新的端身份,然后重新连接 Gateway。`:`This endpoint identity was revoked. Continuing deletes the old key, creates a new endpoint identity, and reconnects to the Gateway.`,s;e[3]===o?s=e[4]:(s=(0,$.jsx)(as,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:o}),e[3]=o,e[4]=s);let c;e[5]!==a||e[6]!==s?(c=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:[a,s]}),e[5]=a,e[6]=s,e[7]=c):c=e[7];let l=n?`取消`:`Cancel`,u;e[8]===l?u=e[9]:(u=(0,$.jsx)(X,{onClick:xG,children:l}),e[8]=l,e[9]=u);let d=n?`生成新身份`:`Create new identity`,f;e[10]===d?f=e[11]:(f=(0,$.jsx)(X,{variant:`primary`,onClick:bG,children:d}),e[10]=d,e[11]=f);let p;e[12]!==u||e[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[u,f]}),e[12]=u,e[13]=f,e[14]=p):p=e[14];let m;e[15]!==p||e[16]!==c?(m=(0,$.jsxs)(ss,{children:[r,(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[150] flex h-[min(22rem,calc(100vh-2rem))] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[c,p]})]}),e[15]=p,e[16]=c,e[17]=m):m=e[17];let h;return e[18]!==t||e[19]!==m?(h=(0,$.jsx)(us,{open:t,onOpenChange:SG,children:m}),e[18]=t,e[19]=m,e[20]=h):h=e[20],h}function bG(){return _G(!0)}function xG(){return _G(!1)}function SG(e){return!e&&_G(!1)}function CG(e){return e.language}var wG={descriptor:gz(`web`),async execute(e,t){let n=pz.parse(e);if(!navigator.geolocation)throw new WW(`PERMISSION_DENIED`,`Location is unavailable in this browser`);return{content:[{type:`json`,value:await new Promise((e,r)=>{let i=!1,a=(a,s)=>{if(i)return;if(i=!0,t.signal.removeEventListener(`abort`,o),s){r(s);return}let c=n.precision===`approximate`||a.coords.accuracy>1e3;e({capturedAt:a.timestamp,latitude:c?Math.round(a.coords.latitude*50)/50:a.coords.latitude,longitude:c?Math.round(a.coords.longitude*50)/50:a.coords.longitude,accuracyMeters:c?Math.max(3e3,a.coords.accuracy):a.coords.accuracy,coordinateSystem:`WGS84`,precision:c?`approximate`:`precise`})},o=()=>a(void 0,new WW(`TOOL_CANCELLED`,`Location request cancelled`));if(t.signal.addEventListener(`abort`,o,{once:!0}),t.signal.aborted){o();return}navigator.geolocation.getCurrentPosition(e=>a(e),e=>a(void 0,new WW(e.code===1?`PERMISSION_DENIED`:e.code===3?`TOOL_TIMEOUT`:`PROTOCOL_ERROR`,e.code===1?`Location permission denied`:`Location is unavailable`)),{maximumAge:0,timeout:2e4,enableHighAccuracy:n.precision===`precise`})})}]}}};function TG(e){return{content:[{type:`text`,text:e}]}}function EG(){if(!navigator.userActivation?.isActive)throw new DOMException(`A current user gesture is required`,`NotAllowedError`)}function DG(e){return new DOMException(e,`AbortError`)}function OG(e){let t=e.suggestedName,n=e.content;if(Object.keys(e).length!==2||typeof t!=`string`||!t||t===`.`||t===`..`||t.length>255||t.includes(`/`)||t.includes(`\\`)||typeof n!=`string`||n.length>2e5||new TextEncoder().encode(n).byteLength>200*1024)throw TypeError(`Invalid file download arguments`);return{suggestedName:t,content:n}}function kG(){return EG(),new Promise((e,t)=>{let n=document.createElement(`input`);n.type=`file`,n.multiple=!1,n.onchange=()=>{let r=n.files?.[0];r?e(r):t(DG(`File selection cancelled`))},n.oncancel=()=>t(DG(`File selection cancelled`)),n.click()})}function AG(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw TypeError(`${t} must be a non-empty string`);return n}function jG(e,t){let n=Object.keys(e).toSorted(),r=t.toSorted();if(n.length!==r.length||n.some((e,t)=>e!==r[t]))throw TypeError(`arguments must contain exactly: ${r.join(`, `)||`no fields`}`)}var MG=[wG,{descriptor:tl(`web`,`state`),async execute(e){if(Object.keys(e).length)throw TypeError(`Expected no arguments`);return{content:[{type:`json`,value:{capturedAt:Date.now(),platform:`web`,systemVersion:``,locale:navigator.language.slice(0,80),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,online:navigator.onLine}}]}}},{descriptor:{name:`web.file.pick`,title:`Choose a local file`,description:`Ask the user to choose one browser-accessible file and make it available to the agent.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:Zc,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-read`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`file`]},async execute(e,t){jG(e,[]);let n=await kG();if(n.size>26214400)throw TypeError(`Selected file exceeds ${$c} bytes`);let r=new Uint8Array(await n.arrayBuffer());if(r.byteLength!==n.size||r.byteLength>26214400)throw Error(`Selected file payload is invalid`);return{content:[await t.uploadFile({name:n.name,mimeType:n.type||`application/octet-stream`,bytes:r})]}}},{descriptor:{name:`web.file.download`,title:`Download a text file`,description:`Download bounded UTF-8 text generated by the agent through this browser.`,inputSchema:{type:`object`,properties:{suggestedName:{type:`string`,minLength:1,maxLength:255},content:{type:`string`,maxLength:2e5}},required:[`suggestedName`,`content`],additionalProperties:!1},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-download`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(e){let{suggestedName:t,content:n}=OG(e);EG();let r=URL.createObjectURL(new Blob([n],{type:`text/plain;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=r,e.download=t,e.click()}finally{URL.revokeObjectURL(r)}return TG(`Download started: ${t}`)}},{descriptor:{name:`web.page.get_selection`,title:`Read selected text`,description:`Read the text currently selected in this browser tab.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:Wc,policyId:`public.foreground-read`,sensitivity:`public`,effect:`read`,confirmation:`never`,requiresForeground:!0,requiredPermissions:[],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(e){return jG(e,[]),TG(window.getSelection()?.toString()??``)}},{descriptor:{name:`web.clipboard.write`,title:`Write clipboard`,description:`Write text to the clipboard from this browser tab.`,inputSchema:{type:`object`,properties:{text:{type:`string`,maxLength:1e5}},required:[`text`],additionalProperties:!1},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-write`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(e){if(jG(e,[`text`]),!navigator.clipboard||!document.hasFocus())throw new DOMException(`Clipboard access requires a focused browser tab`,`NotAllowedError`);let t=AG(e,`text`);if(t.length>1e5)throw TypeError(`text exceeds 100000 characters`);return await navigator.clipboard.writeText(t),TG(`Clipboard updated.`)}},{descriptor:{name:`web.page.navigate`,title:`Navigate page`,description:`Navigate this browser tab to an HTTP or HTTPS URL.`,inputSchema:{type:`object`,properties:{url:{type:`string`,maxLength:4096}},required:[`url`],additionalProperties:!1},outputSchema:Wc,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`destructive`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`navigation`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(e){jG(e,[`url`]);let t=AG(e,`url`);if(t.length>4096)throw TypeError(`url exceeds 4096 characters`);let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw TypeError(`url must use HTTP or HTTPS`);return{content:[{type:`text`,text:`Navigating to ${n.href}`}],afterSend:()=>window.location.assign(n.href)}}}];function NG(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(PG,t);let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(SW,{}),(0,$.jsx)(yG,{})]}),e[1]=n):n=e[1],n}function PG(){let e=Ol();if(e&&window.electronAPI?.computer){let e=!1;Po(Lo(`/api/endpoint-tools/compatibility`)).then(async t=>{let n=await t.json();e||dc(t.ok&&n?.payload?.turnDeviceContextV1===!0)}).catch(()=>{e||dc(!1)});let t=async()=>{try{let t=await window.electronAPI.computer.status();if(e)return;t.claim?sc(t.claim.endpointId,t.claim.token):ic()}catch{e||ic()}};t();let n=window.setInterval(()=>{t()},1e3);return()=>{e=!0,dc(!1),window.clearInterval(n),ic()}}let t=new uG(e?{kind:`desktop`,platform:window.electronAPI?.platform??`desktop`,displayName:`xopc Desktop`,appVersion:`1`,definitions:uW,confirmReenrollment:gG}:{kind:`web`,platform:`web`,displayName:`Web browser`,appVersion:`1`,definitions:MG,confirmReenrollment:gG});return t.start(),()=>{_G(!1),t.stop()}}function FG(){let e=(0,Q.c)(3),t=b(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!Ol())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(RG),i=e.menu.onQuickCapture(LG),a=e.menu.onToggleSidebar(IG),o=e.menu.onHistoryNavigate(e=>{t(e)});return()=>{n(),r(),i(),a(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function IG(){le.getState().toggleCollapsed()}function LG(){O()}function RG(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var zG=1500,BG=9e4;function VG(){let e=(0,Q.c)(16),t=zo(WG),n;e[0]===t?n=e[1]:(n=Do(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(UG);let t=Date.now()+BG;for(;e===c.current&&Date.now()<t;){try{if((await fetch(Lo(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(HG)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let u=l,d,f;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=()=>u();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},f=[u],e[3]=d,e[4]=f):(d=e[3],f=e[4]),(0,Z.useEffect)(d,f);let p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{u()},e[5]=p):p=e[5];let m=p;if(!i)return null;let h=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,g;e[6]===h?g=e[7]:(g=Y(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,h),e[6]=h,e[7]=g);let _;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(_=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:r.restartPollTimeout}),(0,$.jsx)(`button`,{type:`button`,onClick:m,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-on-accent hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hi,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=_):_=e[12];let v;return e[13]!==g||e[14]!==_?(v=(0,$.jsx)(`div`,{className:g,children:_}),e[13]=g,e[14]=_,e[15]=v):v=e[15],v}function HG(e){return setTimeout(e,zG)}function UG(e){return setTimeout(e,2e3)}function WG(e){return e.language}function GG({reminder:e,compact:t}){let n=zo(e=>e.language),r=Do(n).updatePanel,{show:i,dismiss:a,electronQuitAndInstall:o,runNpmUpdate:s,npmUpdateRunning:c}=e,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=(0,Z.useCallback)(async()=>{u(!0),f(null);try{let e=await Ja();if(e.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}f(e.message??`Gateway restart failed`)}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]),m=(0,Z.useCallback)(async()=>{let e=Do(n).updatePanel;f(null);let t=await s();if(t.ok){Vc({tone:`success`,title:e.updateSuccess,message:mB(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}let r=t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed;f(`${r}: ${t.message}`)},[s,n]);if(i.kind===`none`)return null;let h=Y(`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`,sl);return i.kind===`electron-ready`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,ol,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(_r,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,$.jsxs)(`div`,{className:h,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90`,children:[(0,$.jsx)(Wa,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(wo,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-red-500/20 bg-red-500/10 px-10 py-2 text-sm text-fg sm:px-12`,ol,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,52rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(kn,{className:`size-4 shrink-0 text-red-500 dark:text-red-400`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:r.reminderElectronUpdateError.replace(`{{detail}}`,i.message)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(wo,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-panel px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,ol,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(_r,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,$.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-inset sm:max-w-[12rem]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:Y(h,`sm:right-2`),"aria-label":r.dismissAria,children:(0,$.jsx)(wo,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,ol,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,$.jsxs)(`button`,{type:`button`,onClick:p,disabled:l,className:Y(`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,sl),children:[l?(0,$.jsx)(Hi,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Wa,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]}),d?(0,$.jsx)(`span`,{className:`w-full text-xs text-danger`,role:`alert`,children:d}):null]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(wo,{className:`size-4`})})]}):i.kind===`npm-restarting`?(0,$.jsx)(`div`,{className:Y(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,ol,t&&`text-xs`),children:(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] items-center justify-center gap-2 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(Hi,{className:`size-4 shrink-0 animate-spin text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartingAutomatically.replace(`{{version}}`,i.version)})]})}):i.kind===`npm`?(0,$.jsxs)(`div`,{className:Y(`relative hidden min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm md:flex`,ol,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:Y(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,$.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,$.jsxs)(`button`,{type:`button`,onClick:m,disabled:c,className:Y(`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,sl),children:[c?(0,$.jsx)(Hi,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Wa,{className:`size-3 shrink-0`,"aria-hidden":!0}),c?r.updateRunning:r.updateNow]}),d?(0,$.jsx)(`span`,{className:`w-full text-xs text-danger`,role:`alert`,children:d}):null]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(wo,{className:`size-4`})})]}):null}function KG(e,t,n){let r=Do(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:local-app:create`,title:i.createLocalApp,subtitle:i.createLocalAppSubtitle,groupLabel:a,keywords:[`app`,`local app`,`create app`,`tool`,`workshop`,`coder`,`应用`,`创建应用`,`工具`,`工坊`],run:()=>{n(),t(`/local-apps/new`)}},{kind:`action`,id:`action:automation:create`,title:`Create automation`,subtitle:`Open automations to create a trigger and action`,groupLabel:a,keywords:[`automation`,`schedule`,`trigger`,`action`,`timer`],run:()=>{n(),t(`/automations?action=create`)}},{kind:`action`,id:`action:automation:manage`,title:`Manage automations`,subtitle:`View automations and run history`,groupLabel:a,keywords:[`automation`,`schedule`,`tasks`,`runs`],run:()=>{n(),t(`/automations`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/capabilities/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),s(async()=>{let{reloadSkills:e}=await import(`./skill-reload-api-Cff2GgZb.js`).then(e=>e.n);return{reloadSkills:e}},__vite__mapDeps([144,1,18,2,15,145])).then(({reloadSkills:e})=>e())}}]}function qG(e){if(e)return e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `)}async function JG(e,t){let n=window.electronAPI?.menu;if(!n)return[];try{let r=await n.getModel(),i=Do(e).commandPalette.groups.actions;return r.flatMap(e=>e.items.flatMap(r=>{if(r.type!==`item`||r.id.startsWith(`role.`))return[];let a=qG(r.accelerator);return[{kind:`action`,id:`desktop-menu:${r.id}`,title:r.label,subtitle:[e.label,a].filter(Boolean).join(` · `)||void 0,groupLabel:i,keywords:[r.id,e.id,e.label,r.accelerator??``],run:()=>{t(),n.invoke(r.id)}}]}))}catch{return[]}}function YG(e){return Do(e).commandPalette.groups}function XG(e){let t=YG(e);return{[t.navigate]:0,[t.projects]:1,[t.connectors]:2,[t.quickSettings]:3,[t.extensions]:4,[t.sessions]:5,[t.files]:6,[t.commands]:7,[t.skills]:8,[t.actions]:9}}function ZG(e){let t=YG(e);return{[t.navigate]:12,[t.projects]:8,[t.connectors]:6,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function QG(e,t){return XG(e)[t]??10}var $G=null;function eK(){$G=null}function tK(){return $G||($G=Promise.allSettled([zc(),Lc()]).then(([e,t])=>{if(e.status===`rejected`&&t.status===`rejected`)throw e.reason;let n={catalog:e.status===`fulfilled`?e.value:[],instances:t.status===`fulfilled`?t.value:[]};return(e.status===`rejected`||t.status===`rejected`)&&($G=null),n}).catch(e=>{throw $G=null,e}),$G)}function nK(e,t){return!e.enabled||e.status===`disabled`?t.disabled:e.status===`failed`||e.status===`degraded`||e.status===`not_configured`||e.status===`unauthorized`||e.connectionStatus===`error`||e.connectionStatus===`unauthorized`?t.needsSetup:e.status===`connected`||e.connectionStatus===`connected`?t.connected:t.installed}function rK(e){return e?[e.id,e.description,e.category,e.kind,...e.tags??[],...e.capabilities,...e.benefits??[]]:[]}function iK(e,t){return t?`${e} · ${t}`:e}function aK(e){if(!e.query.trim())return[];let t=new Map(e.catalog.map(e=>[e.id,e])),n=new Set(e.instances.map(e=>e.connectorId)),r=e.instances.map(n=>{let r=t.get(n.connectorId);return{kind:`connector`,id:`connector-instance:${n.instanceId}`,title:n.displayName,subtitle:iK(nK(n,e.labels),r?.description),groupLabel:e.labels.group,keywords:[n.connectorId,n.instanceId,n.materialized.type,...rK(r)],run:()=>{e.close(),e.navigate(`/capabilities/connectors?instance=${encodeURIComponent(n.instanceId)}&tab=connected`)}}}),i=e.catalog.flatMap(t=>t.source!==`builtin`||t.integrationStrategy?.preferred===!1||!Qn(t)||n.has(t.id)?[]:[{kind:`connector`,id:`connector:${t.id}`,title:t.displayName,subtitle:iK(e.labels.builtin,t.description),groupLabel:e.labels.group,keywords:rK(t),run:()=>{e.close(),e.navigate(`/capabilities/connectors?connector=${encodeURIComponent(t.id)}&tab=discover`)}}]);return[...r,...i]}function oK(e){return e.trim().toLowerCase()}function sK(e,t){let n=oK(e),r=oK(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function cK(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=sK(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`project`?-.12:e.kind===`connector`||e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function lK(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var uK=new Set([`logs`,`tracing`,`settingsRuntimes`]),dK=[`/settings/logs`,`/settings/tracing`,`/settings/runtimes`,`/settings/extensions/debug`,`/settings/ext/`];function fK(e,t){return t===`advanced`||!uK.has(e)}function pK(e,t){return t===`advanced`||!dK.some(t=>e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`))}var mK=[`settingsAgentBrowser`,`settingsComputerUse`,`settingsPhoneUse`],hK={settingsAgentBrowser:[`browser`,`playwright`,`automation`],settingsPhoneUse:[`phone use`,`Android`,`ADB`,`AutoGLM`,`手机控制`,`模拟器`],settingsComputerUse:[`computer use`,`compute use`,`desktop`,`电脑控制`,`电脑操作`,`桌面控制`,`GUI`,`BYOK`]};function gK(e,t){let n=Do(e).commandPalette.routes.agentsSubtitle;return mK.filter(e=>fK(e,t)&&(e!==`settingsComputerUse`||kl())).map(t=>({id:`route:settings:agent:${t}`,title:Eo(e,t),subtitle:n,path:xl(t),keywords:[`agent`,`manifest`,`preset`,`config`,...hK[t]??[]]}))}function _K(e,t){return e.filter(e=>pK(e.path.split(`?`)[0]??e.path,t))}function vK(e){let t=Do(e),n=t.commandPalette.routes,r=t.channelsSettings,i=Yu.getState().mode;return _K([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:Ju,keywords:[`agent`,`persona`,`switch`]},{id:`route:extensions`,title:t.nav.extensions,subtitle:n.extensionsSubtitle,path:Mo(`extensions`),keywords:[`extension`,`plugin`,`addon`]},{id:`route:local-apps`,title:t.nav.localApps,subtitle:n.localAppsSubtitle,path:`/local-apps`,keywords:[`app`,`apps`,`local app`,`tool`,`workshop`,`coder`,`应用`,`本地应用`,`工具`,`工坊`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:usage`,title:t.nav.usage,subtitle:n.usageSubtitle,path:`/settings/usage`,keywords:[`usage`,`cost`,`tokens`,`model`,`用量`,`费用`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:Mo(`skills`),keywords:[`tools`,`catalog`]},{id:`route:connectors`,title:t.nav.connectors,subtitle:n.connectorsSubtitle,path:Mo(`connectors`),keywords:[`connector`,`mcp`,`registry`,`integration`,`tools`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:Ua,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:`Telegram`,subtitle:n.channelsSubtitle,path:Ha(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:`Weixin`,subtitle:n.channelsSubtitle,path:Ha(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:`Feishu/Lark`,subtitle:n.channelsSubtitle,path:Ha(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`Telegram — ${r.hubPairingButton}`,subtitle:n.channelsSubtitle,path:Ha(`telegram`),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:automations`,title:`Automations`,subtitle:`Triggers, actions, and run history`,path:`/automations`,keywords:[`automation`,`automations`,`schedule`,`tasks`,`history`,`scheduler`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:capabilities:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:Sl(`models`),keywords:[`api`,`key`,`provider`,`openai`,`anthropic`,`google`,`gpt`,`claude`,`gemini`,`llm`,`模型`,`模型服务`,`语音`,`音色`,`听写`,`voice`,`stt`,`tts`,`image`,`服务商`,`密钥`]},{id:`route:settings:capabilities:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:Sl(`search`),keywords:[`search`,`web`,`tavily`,`serper`,`brave`,`搜索`,`网络搜索`,`联网搜索`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...gK(e,i)],i)}async function yK(e,t={}){let n=new URLSearchParams;return n.set(`q`,e.trim()),t.types?.length&&n.set(`types`,t.types.join(`,`)),t.limit&&n.set(`limit`,String(t.limit)),(await Bo(Lo(`/api/search?${n.toString()}`))).hits}function bK(e){gl.getState().setPreference(e)}function xK(e){zo.getState().setLanguage(e)}function SK(e,t){let n=Do(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`default model`,`默认模型`,`gpt`,`claude`,`gemini`,`llm`,`模型`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{bK(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{bK(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{bK(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{xK(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{xK(`zh`),t.closePalette()}}]}function CK(e){let t=e===`zh`;return[{advanced:!0,id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway?tab=network`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{advanced:!0,id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway?tab=network`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway?tab=access`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent-defaults:models`,title:t?`Agent 全局模型`:`Global agent models`,subtitle:t?`设置所有 Agent 继承的模型与回退`:`Set inherited models and fallbacks`,path:`/settings/capabilities/models`,keywords:[`agent defaults`,`model intents`,`fallbacks`,`llm`,`全局默认`,`模型意图`]},{id:`field:agent-defaults:skills`,title:t?`Agent 全局技能`:`Global agent skills`,subtitle:t?`设置所有 Agent 默认可用或排除的技能`:`Set skills enabled or excluded for every agent`,path:`/settings/agent-defaults?panel=skills`,keywords:[`agent defaults`,`skills`,`inherit`,`全局默认`,`技能`,`继承`]},{id:`field:agent-defaults:tools`,title:t?`Agent 全局工具权限`:`Global agent tool permissions`,subtitle:t?`设置所有 Agent 继承的 allow、ask 或 deny 策略`:`Set inherited allow, ask, or deny policies`,path:`/settings/agent-defaults?panel=tools`,keywords:[`agent defaults`,`tools`,`permissions`,`allow`,`ask`,`deny`,`工具权限`]},{advanced:!0,id:`field:agent-defaults:runtime`,title:t?`Agent 全局运行限制`:`Global agent runtime limits`,subtitle:t?`设置继承的轮次和超时`:`Set inherited turn and timeout limits`,path:`/settings/agent-defaults?panel=runtime`,keywords:[`agent defaults`,`runtime`,`turns`,`timeout`,`运行限制`]},{id:`field:agent:profile`,title:t?`Agent 个性`:`Agent personality`,subtitle:t?`设置名称、个性指令和可选覆盖`:`Set the name, personality, and optional overrides`,path:Ju,keywords:[`agent`,`profile`,`personality`,`instructions`,`agent 个性`,`指令`]},{id:`field:agent:workspace`,title:t?`Agent 工作目录`:`Agent workspace`,subtitle:t?`按需覆盖该 Agent 的自动工作目录`:`Optionally override the automatic workspace`,path:Ju,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/settings/agent-browser`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/settings/agent-browser`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/settings/agent-browser`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/settings/agent-browser`,keywords:[`headless`,`window`,`visible`,`无头`]},{advanced:!0,id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/settings/agent-browser`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/capabilities/models?configure=transcription`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/capabilities/models?configure=speech`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/capabilities/search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:automations:enabled`,title:t?`自动化`:`Automations`,subtitle:t?`创建和管理自动化`:`Create and manage automations`,path:`/automations`,keywords:[`automation`,`automations`,`scheduler`,`timer`,`自动化`,`调度`]},{id:`field:automations:runs`,title:t?`自动化运行记录`:`Automation Runs`,subtitle:t?`查看自动化执行历史`:`Review automation run history`,path:`/automations`,keywords:[`automation`,`runs`,`history`,`自动化`,`历史`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:Ua,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:Ua,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/capabilities/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function wK(e,t,n,r){return CK(e).map(i=>({kind:`setting`,id:i.id,title:i.title,subtitle:i.advanced?`${e===`zh`?`高级设置`:`Advanced settings`} · ${i.subtitle}`:i.subtitle,groupLabel:r,keywords:i.keywords,run:()=>{i.advanced&&Yu.getState().setMode(`advanced`),n(),t(i.path)}}))}function TK(){let{pathname:e}=p(),{conversationId:t}=d();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}async function EK(e){let{defaults:t}=await Qu();await Zu({...t,models:{...t.models,chat:{primary:e,fallbacks:[]}}})}function DK(e,t,n,r){let i=e.trim().toLowerCase();i&&(mc(i),t.startsWith(`/chat`)?window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:i}})):n(`/chat/new?projectScope=none`,{state:{agentId:i}}),r())}function OK(e){switch(e.kind){case`connector`:return(0,$.jsx)(fn,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`extension`:return(0,$.jsx)(Ba,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,$.jsx)(Kr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`project`:return(0,$.jsx)(Gr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,$.jsx)(Kr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,$.jsx)(Lr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,$.jsx)(po,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,$.jsx)(io,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,$.jsx)($a,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,$.jsx)(To,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function kK(e,t,n,r){if(r(),t.startsWith(`/chat`)){pt(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{pt(e)})}))}function AK(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/extensions/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function jK(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var MK={query:``,selectedIndex:0,paletteLayer:`main`};async function NK(){let e=await Bo(Lo(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function PK(e){let t=await il(),n=Do(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:Xu(e,n),subtitle:e.id}))}function FK({onClose:e}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=b(),{pathname:i}=p(),a=zo(e=>e.language),o=hc(),s=TK(),c=Eu(e=>e.agentId),l=Ec(e=>e.setPath),[u,d]=(0,Z.useReducer)(jK,MK),[f,m]=(0,Z.useState)(0),[h,g]=(0,Z.useState)(0),{query:_,selectedIndex:v,paletteLayer:y}=u,x=(0,Z.useMemo)(()=>vK(a),[a]),[S]=cu(_,120);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&t.section===`skills`&&m(e=>e+1),g(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let C=iu(tK,[h],{enabled:y===`main`&&!!S.trim(),initial:{catalog:[],instances:[]},errorData:{catalog:[],instances:[]}}),w=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`models`})},[]),T=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`agents`})},[]),E=iu(async()=>y===`models`?NK():y===`agents`?PK(a):[],[y,a],{enabled:y===`models`||y===`agents`,initial:[],errorData:[]}),D=iu(async()=>{let t=S.trim(),n=e,u=Do(a).commandPalette.groups,d=x.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=SK(a,{closePalette:n,openModelPalette:w,openAgentPalette:T}),p=KG(a,r,n),m=aK({query:t,...C.data,labels:{group:u.connectors,...Do(a).commandPalette.connectors},navigate:r,close:n}),h=AK({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:u.extensions}),[g,_,v,y,b,E]=await Promise.all([Nu(),Fu(),t?yK(t,{types:[`project`],limit:8}).catch(()=>[]):[],Js({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await He(t,{conversationId:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})(),JG(a,n)]),D=v.map(e=>({kind:`project`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.projects,keywords:[e.payload.project.slug,e.payload.project.workspaceRoot??``,e.payload.project.defaultAgentId??``,e.payload.project.brief??``],run:()=>{n(),r(e.href)}})),O=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:u.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{kK(Oe(e),i,r,n)}})),k=_.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:u.skills,keywords:[e.source??``,`skill`],run:()=>{kK(`/skill:${e.name} `,i,r,n)}}]),A=(y.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:u.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),j=b.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:u.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>l(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),M=wK(a,r,n,u.navigate),N=[...d,...f,...p,...E,...h,...M,...D,...m,...A,...j,...O,...k],P=[];for(let e of N){let n=cK(e,t);n!==null&&P.push({...e,rank:n})}let F=ZG(a),I=lK(P),L=[],R={};for(let e of I){let t=(R[e.groupLabel]??0)+1;if(!(t>(F[e.groupLabel]??6))&&(R[e.groupLabel]=t,L.push(e),L.length>=36))break}return L.sort((e,t)=>QG(a,e.groupLabel)-QG(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),L},[S,x,o,r,s,c,i,l,a,w,T,e,f,C.data],{enabled:y===`main`,initial:[],errorData:[]}),O=D.data,k=D.loading,A=D.error,j=(0,Z.useMemo)(()=>{let e=_.trim().toLowerCase(),t=E.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[E.data,_]),M=`${y}|${_}|${String(j.length)}|${String(O.length)}`,N=(0,Z.useRef)(M);if(N.current!==M){N.current=M;let e=y===`main`?Math.max(0,O.length-1):Math.max(0,j.length);v>e&&d({type:`setSelectedIndex`,value:e})}(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let P=(0,Z.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),y!==`main`){d({type:`resetMain`});return}e();return}let n=y===`main`?Math.max(0,O.length-1):Math.max(0,j.length);if(t.key===`ArrowDown`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),y===`models`){if(v===0){d({type:`resetMain`});return}let t=j[v-1];if(!t)return;(async()=>{await EK(t.id),Pc(),Xc(),e(),d({type:`resetMain`})})();return}if(y===`agents`){if(v===0){d({type:`resetMain`});return}let t=j[v-1];if(!t)return;DK(t.id,i,r,e),d({type:`resetMain`});return}let n=O[v];n&&n.run()}});(0,Z.useEffect)(()=>{let e=e=>{P(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Z.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(v)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[v,O,y,j.length]);let F=a===`zh`?`返回`:`Back`;if(y===`models`||y===`agents`){let o=j,s=E.loading;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:_,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:y===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,v===0?`bg-surface-hover`:`hover:bg-surface-inset`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:0}),onClick:()=>d({type:`resetMain`}),children:[`← `,F]})}),s?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):o.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):o.map((t,n)=>{let a=n+1;return(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,"data-global-palette-index":a,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,v===a?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-inset`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:a}),onClick:()=>{y===`models`?(async()=>{await EK(t.id),Pc(),Xc(),e(),d({type:`resetMain`})})():(DK(t.id,i,r,e),d({type:`resetMain`}))},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let I=``;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:_,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 连接 / 设置 / 命令)`:`Search… (sessions, files, connectors, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":O[v]?`global-hit-${O[v].id}`:void 0,children:O.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:k?a===`zh`?`搜索中…`:`Searching…`:A?A instanceof Error?A.message:String(A):a===`zh`?`无结果`:`No results`}):O.map((e,t)=>{let n=e.groupLabel===I?``:e.groupLabel;return I=e.groupLabel,(0,$.jsxs)(`li`,{children:[n?(0,$.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,$.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===v?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-inset`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,$.jsx)(`span`,{className:`mt-0.5`,children:OK(e)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function IK(){let e=(0,Q.c)(7),[t,n]=(0,Z.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(RK))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(LK);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,Z.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(FK,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function LK(e){return!e}function RK(e){return!e}function zK(e){let t=(0,Q.c)(47),{noteId:n,backgroundPath:r,onClose:i}=e,a=zo(VK),o=Ro(BK),s;t[0]!==n||t[1]!==o?(s=[`note-preview`,n,o],t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=()=>pi(n),t[3]=n,t[4]=c);let{data:l,error:u,isLoading:d}=qo(s,c),f=a===`zh`,p;t[5]!==l?.title||t[6]!==f?(p=l?.title?.trim()||(f?`笔记预览`:`Note preview`),t[5]=l?.title,t[6]=f,t[7]=p):p=t[7];let m=p,h=f?`关闭笔记预览`:`Close note preview`,g;t[8]===i?g=t[9]:(g=e=>{e||i()},t[8]=i,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(rs,{className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`}),t[10]=_):_=t[10];let v;t[11]===m?v=t[12]:(v=(0,$.jsx)(ls,{className:`min-w-0 flex-1 truncate font-medium text-fg`,title:m,children:m}),t[11]=m,t[12]=v);let b=f?`预览笔记内容,或打开独立页面。`:`Preview the note or open its full page.`,x;t[13]===b?x=t[14]:(x=(0,$.jsx)(as,{className:`sr-only`,children:b}),t[13]=b,t[14]=x);let S=`/notes/${encodeURIComponent(n)}`,C;t[15]!==r||t[16]!==S?(C=Gi(S,r),t[15]=r,t[16]=S,t[17]=C):C=t[17];let w;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(br,{className:`size-4`,"aria-hidden":!0}),t[18]=w):w=t[18];let T=f?`打开独立页面`:`Open full page`,E;t[19]===T?E=t[20]:(E=(0,$.jsx)(`span`,{children:T}),t[19]=T,t[20]=E);let D;t[21]!==C||t[22]!==E?(D=(0,$.jsxs)(y,{to:C,className:`flex shrink-0 items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm text-accent hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[w,E]}),t[21]=C,t[22]=E,t[23]=D):D=t[23];let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===h?k=t[26]:(k=(0,$.jsx)(os,{title:h,"aria-label":h,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:O}),t[25]=h,t[26]=k);let A;t[27]!==D||t[28]!==k||t[29]!==v||t[30]!==x?(A=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge bg-surface-panel px-5 py-3.5`,children:[v,x,D,k]}),t[27]=D,t[28]=k,t[29]=v,t[30]=x,t[31]=A):A=t[31];let j;t[32]!==u||t[33]!==d||t[34]!==l||t[35]!==n||t[36]!==f?(j=d?(0,$.jsxs)(`div`,{className:`space-y-4`,role:`status`,"aria-label":f?`正在加载笔记`:`Loading note`,children:[(0,$.jsx)(Xo,{className:`h-7 w-2/3`}),(0,$.jsx)(Xo,{className:`h-4 w-full`}),(0,$.jsx)(Xo,{className:`h-4 w-full`}),(0,$.jsx)(Xo,{className:`h-4 w-4/5`}),(0,$.jsx)(Xo,{className:`mt-8 h-32 w-full`})]}):u?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:f?`笔记加载失败,请重新打开预览。`:`Unable to load the note. Please reopen the preview.`}):l?l.markdown.trim()?(0,$.jsx)(fi,{noteId:n,content:l.markdown,mermaidActions:!1},n):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`暂无笔记内容。`:`This note has no content yet.`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`笔记不存在或已删除。`:`This note is unavailable or has been deleted.`}),t[32]=u,t[33]=d,t[34]=l,t[35]=n,t[36]=f,t[37]=j):j=t[37];let M;t[38]!==d||t[39]!==j?(M=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-8`,"aria-busy":d,children:j}),t[38]=d,t[39]=j,t[40]=M):M=t[40];let N;t[41]!==A||t[42]!==M?(N=(0,$.jsxs)(ss,{children:[_,(0,$.jsxs)(cs,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(48rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,children:[A,M]})]}),t[41]=A,t[42]=M,t[43]=N):N=t[43];let P;return t[44]!==N||t[45]!==g?(P=(0,$.jsx)(us,{open:!0,onOpenChange:g,children:N}),t[44]=N,t[45]=g,t[46]=P):P=t[46],P}function BK(e){return e.conversationId}function VK(e){return e.language}function HK(e){let t=(0,Q.c)(100),{onClose:n}=e,r=b(),i=zo(WK),a;t[0]===i?a=t[1]:(a=Do(i),t[0]=i,t[1]=a);let o=a.notes,s;t[2]===i?s=t[3]:(s=Do(i),t[2]=i,t[3]=s);let c=s.chat,l=Vu(UK),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),m=(0,Z.useRef)(null),h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>{d(t=>Cc(t,e)),window.setTimeout(()=>m.current?.focus(),0)},t[4]=h):h=t[4];let g;t[5]!==c||t[6]!==f?(g={disabled:f,chat:c,onTranscript:h},t[5]=c,t[6]=f,t[7]=g):g=t[7];let _=Sc(g),{phase:v,voiceActive:y,startVoiceInput:x,cancelVoiceInput:S,confirmVoiceInput:C}=_,w,T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=window.setTimeout(()=>m.current?.focus(),50);return()=>window.clearTimeout(e)},T=[],t[8]=w,t[9]=T):(w=t[8],T=t[9]),(0,Z.useEffect)(w,T);let E,D;t[10]!==S||t[11]!==C||t[12]!==f||t[13]!==x||t[14]!==y||t[15]!==v?(E=()=>{let e=e=>{e.detail?.target===`note`&&(e.preventDefault(),!f&&(v===`recording`?C():(v===`idle`||v===`error`)&&x()))},t=e=>{e.detail?.target!==`note`||!y||(e.preventDefault(),S(),m.current?.focus())};return window.addEventListener(Gu,e),window.addEventListener(Hu,t),()=>{window.removeEventListener(Gu,e),window.removeEventListener(Hu,t)}},D=[S,C,f,x,y,v],t[10]=S,t[11]=C,t[12]=f,t[13]=x,t[14]=y,t[15]=v,t[16]=E,t[17]=D):(E=t[16],D=t[17]),(0,Z.useEffect)(E,D);let k;t[18]!==r||t[19]!==n||t[20]!==f||t[21]!==u?(k=async e=>{let t=u.trim();if(!(!t||f)){p(!0);try{let i=await mi(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{p(!1)}}},t[18]=r,t[19]=n,t[20]=f,t[21]=u,t[22]=k):k=t[22];let A=k,j;t[23]!==A||t[24]!==n?(j=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),A(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),A(!1))},t[23]=A,t[24]=n,t[25]=j):j=t[25];let M=j,N=o.quickCapturePlaceholder,P;t[26]===n?P=t[27]:(P=e=>{e.target===e.currentTarget&&n()},t[26]=n,t[27]=P);let F;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(uo,{className:`size-4 text-accent`}),t[28]=F):F=t[28];let I;t[29]===o.quickCapturePlaceholder?I=t[30]:(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[F,(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[29]=o.quickCapturePlaceholder,t[30]=I);let L;t[31]!==c||t[32]!==M||t[33]!==o.quickCapturePlaceholder||t[34]!==f||t[35]!==u||t[36]!==_.audioLevel||t[37]!==_.cancelVoiceInput||t[38]!==_.confirmVoiceInput||t[39]!==_.elapsedLabel||t[40]!==_.error||t[41]!==_.finalTranscript||t[42]!==_.partialTranscript||t[43]!==_.phase||t[44]!==_.retryVoiceInput||t[45]!==_.settingsRequired||t[46]!==_.voiceActive?(L=_.voiceActive?(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(Tc,{phase:_.phase,elapsedLabel:_.elapsedLabel,audioLevel:_.audioLevel,partialTranscript:_.partialTranscript,finalTranscript:_.finalTranscript,error:_.error,settingsRequired:_.settingsRequired,disabled:f,chat:c,onCancel:_.cancelVoiceInput,onConfirm:_.confirmVoiceInput,onRetry:_.retryVoiceInput})}):(0,$.jsx)(`textarea`,{ref:m,value:u,onChange:e=>d(e.target.value),onKeyDown:M,placeholder:o.quickCapturePlaceholder,disabled:f,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`}}),t[31]=c,t[32]=M,t[33]=o.quickCapturePlaceholder,t[34]=f,t[35]=u,t[36]=_.audioLevel,t[37]=_.cancelVoiceInput,t[38]=_.confirmVoiceInput,t[39]=_.elapsedLabel,t[40]=_.error,t[41]=_.finalTranscript,t[42]=_.partialTranscript,t[43]=_.phase,t[44]=_.retryVoiceInput,t[45]=_.settingsRequired,t[46]=_.voiceActive,t[47]=L):L=t[47];let R=f||_.voiceActive,z;t[48]===n?z=t[49]:(z=()=>{n(),O()},t[48]=n,t[49]=z);let B;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(St,{className:`size-3.5`,"aria-hidden":!0}),t[50]=B):B=t[50];let V;t[51]===o.discussionCapture.title?V=t[52]:(V=(0,$.jsx)(`span`,{children:o.discussionCapture.title}),t[51]=o.discussionCapture.title,t[52]=V);let H;t[53]!==R||t[54]!==z||t[55]!==V?(H=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,disabled:R,onClick:z,children:[B,V]}),t[53]=R,t[54]=z,t[55]=V,t[56]=H):H=t[56];let U=f||_.voiceActive,W=c.voiceInput,ee;t[57]===l?ee=t[58]:(ee=Wu(l).join(`+`),t[57]=l,t[58]=ee);let G=`${W} (${ee})`,K=c.voiceInput,q;t[59]===l?q=t[60]:(q=Wu(l).join(`+`),t[59]=l,t[60]=q);let te=`${K} (${q})`,ne;t[61]===_?ne=t[62]:(ne=()=>void _.startVoiceInput(),t[61]=_,t[62]=ne);let re;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(la,{className:`size-3.5`,"aria-hidden":!0}),t[63]=re):re=t[63];let ie;t[64]===c.voiceInput?ie=t[65]:(ie=(0,$.jsx)(`span`,{children:c.voiceInput}),t[64]=c.voiceInput,t[65]=ie);let ae;t[66]!==U||t[67]!==G||t[68]!==te||t[69]!==ne||t[70]!==ie?(ae=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,disabled:U,title:G,"aria-label":te,onClick:ne,children:[re,ie]}),t[66]=U,t[67]=G,t[68]=te,t[69]=ne,t[70]=ie,t[71]=ae):ae=t[71];let oe;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[72]=oe):oe=t[72];let se;t[73]===o.quickCaptureHintEnter?se=t[74]:(se=(0,$.jsxs)(`span`,{children:[oe,` `,o.quickCaptureHintEnter]}),t[73]=o.quickCaptureHintEnter,t[74]=se);let ce;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[75]=ce):ce=t[75];let le;t[76]===o.quickCaptureHintShift?le=t[77]:(le=(0,$.jsxs)(`span`,{children:[ce,` `,o.quickCaptureHintShift]}),t[76]=o.quickCaptureHintShift,t[77]=le);let ue;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[78]=ue):ue=t[78];let de;t[79]===o.quickCaptureHintEsc?de=t[80]:(de=(0,$.jsxs)(`span`,{children:[ue,` `,o.quickCaptureHintEsc]}),t[79]=o.quickCaptureHintEsc,t[80]=de);let fe;t[81]!==H||t[82]!==ae||t[83]!==se||t[84]!==le||t[85]!==de?(fe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-fg-muted`,children:[H,ae,se,le,de]}),t[81]=H,t[82]=ae,t[83]=se,t[84]=le,t[85]=de,t[86]=fe):fe=t[86];let pe;t[87]===f?pe=t[88]:(pe=f&&(0,$.jsx)(`div`,{className:`size-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[87]=f,t[88]=pe);let me;t[89]!==fe||t[90]!==pe?(me=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[fe,pe]}),t[89]=fe,t[90]=pe,t[91]=me):me=t[91];let he;t[92]!==I||t[93]!==L||t[94]!==me?(he=(0,$.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[I,L,me]}),t[92]=I,t[93]=L,t[94]=me,t[95]=he):he=t[95];let ge;return t[96]!==o.quickCapturePlaceholder||t[97]!==P||t[98]!==he?(ge=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"data-voice-input-scope":`note`,"aria-label":N,onMouseDown:P,children:he}),t[96]=o.quickCapturePlaceholder,t[97]=P,t[98]=he,t[99]=ge):ge=t[99],ge}function UK(e){return e.shortcut}function WK(e){return e.language}function GK(){let e=(0,Q.c)(11),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),a=Ro(JK),o=zu(qK),s,c;e[0]!==r||e[1]!==o||e[2]!==a?(s=()=>{let e=e=>{r||Ru(e,o)&&(e.preventDefault(),a&&n(KK))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},c=[r,o,a],e[0]=r,e[1]=o,e[2]=a,e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l,u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=e=>{i(!!e.detail?.active)};return window.addEventListener(`quick-capture-shortcut-recording`,e),window.addEventListener(Ku,e),()=>{window.removeEventListener(`quick-capture-shortcut-recording`,e),window.removeEventListener(Ku,e)}},u=[],e[5]=l,e[6]=u):(l=e[5],u=e[6]),(0,Z.useEffect)(l,u);let d,f;if(e[7]===a?(d=e[8],f=e[9]):(d=()=>{let e=()=>{a&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},f=[a],e[7]=a,e[8]=d,e[9]=f),(0,Z.useEffect)(d,f),!t)return null;let p;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(HK,{onClose:()=>n(!1)}),e[10]=p):p=e[10],p}function KK(e){return!e}function qK(e){return e.shortcut}function JK(e){return e.conversationId}var YK=(0,Z.lazy)(()=>s(()=>import(`./capabilities-settings-panel-uOHSMQPZ.js`).then(e=>({default:e.CapabilitiesSettingsPanel})),__vite__mapDeps([146,1,2,4,3,147,6,148,5,64,32,16,17,22,65,21,24,34,35,25,7,149,150,151,33,116,42,36,49,45,152,41,74,75,61,14,15,18,19,20,23,44,80,79,153,86,82,154,155,156,157,38,37,10,158,159,160,48,124,60,107,125,126,161,77,162,163,164,165,28,166,167,78,168,169,170,171,108,109,172,93,173,46,88,174,89,175,176,177,91,92,39,94,95,96,97,47,98,99,178,179,180,181,182])));function XK(){let e=(0,Z.useId)(),t=(0,Z.useRef)(null),n=(0,Z.useRef)(!1),r=(0,Z.useRef)(null),i=(0,Z.useRef)(new Map),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(`settings`),[d,f]=(0,Z.useState)(!1);n.current=a;let p=zo(e=>e.language)===`zh`;(0,Z.useEffect)(()=>{let e=e=>{let r=e.detail,i=Nn(r?.use??null);i&&!d&&(n.current||(t.current=document.activeElement instanceof HTMLElement?document.activeElement:null),c(i),o(!0),u(r?.view===`services`?`services`:`settings`))};return window.addEventListener(`open-capability-settings`,e),()=>window.removeEventListener(`open-capability-settings`,e)},[d]),(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=`${s}:${l}`;return e.scrollTop=i.current.get(t)??0,()=>{i.current.set(t,e.scrollTop)}},[l,s]);let m=e=>{d||u(e)};return(0,$.jsx)(us,{open:a,onOpenChange:e=>{d||o(e)},children:(0,$.jsx)(ss,{forceMount:!0,children:(0,$.jsx)(`div`,{className:`contents`,children:(0,$.jsxs)(Z.Activity,{mode:a?`visible`:`hidden`,children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[150] bg-scrim`}),(0,$.jsxs)(cs,{forceMount:!0,onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>t.current?.focus())},className:`xopc-dialog-content fixed inset-x-3 top-1/2 z-[151] mx-auto flex h-[min(48rem,calc(100dvh-2rem))] w-[calc(100%-1.5rem)] max-w-3xl -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onEscapeKeyDown:e=>{d&&e.preventDefault()},onInteractOutside:e=>{d&&e.preventDefault()},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:s?Bn[s][+!p]:``}),(0,$.jsx)(as,{className:`mt-1 text-xs text-fg-muted`,children:s?In[s][+!p]:``})]}),(0,$.jsx)(X,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":p?`关闭设置`:`Close settings`,disabled:d,onClick:()=>o(!1),children:(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge px-5 py-3`,children:(0,$.jsx)(su,{role:`tablist`,"aria-label":p?`能力配置`:`Capability configuration`,className:`inline-flex gap-1 rounded-xl bg-surface-inset p-1`,indicatorClassName:`rounded-md bg-surface-panel shadow-sm`,children:[`settings`,`services`].map(t=>(0,$.jsx)(X,{id:`${e}-${t}`,role:`tab`,"aria-selected":l===t,"aria-controls":`${e}-panel`,tabIndex:l===t?0:-1,variant:`ghost`,className:l===t?`bg-surface-panel text-fg shadow-sm hover:bg-surface-panel`:``,disabled:d,onClick:()=>m(t),onKeyDown:n=>{if(d||![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(n.key))return;n.preventDefault();let r=n.key===`Home`?`settings`:n.key===`End`||t===`settings`?`services`:`settings`;m(r),document.getElementById(`${e}-${r}`)?.focus()},children:t===`settings`?p?`模型与参数`:`Model and parameters`:p?`管理服务`:`Manage services`},t))})}),(0,$.jsx)(`div`,{ref:r,id:`${e}-panel`,role:`tabpanel`,"aria-labelledby":`${e}-${l}`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:s?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(ed,{}),children:(0,$.jsx)(YK,{inlineUse:s,inlineView:l,onViewChange:u,onPendingChange:f},s)}):null}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-4 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:d?p?`完成保存后即可关闭。`:`Finish saving before closing.`:l===`settings`?p?`参数更改会自动保存。`:`Parameter changes are saved automatically.`:p?`选择服务,为当前能力配置模型。`:`Choose a service for this capability.`}),(0,$.jsx)(X,{variant:`secondary`,disabled:d,onClick:()=>o(!1),children:p?`完成`:`Done`})]})]})]})})})})}var ZK=()=>`xopc-recording-consent:${Ro.getState().baseUrl}`;function QK(e){if(e.consentAcknowledgedAt!=null)try{localStorage.setItem(ZK(),JSON.stringify(e))}catch{}}function $K(){try{let e=JSON.parse(localStorage.getItem(ZK())??`null`);return e&&Number.isSafeInteger(e.consentPolicyVersion)&&e.consentPolicyVersion>0&&typeof e.consentAcknowledgedAt==`number`&&Number.isFinite(e.consentAcknowledgedAt)&&e.consentAcknowledgedAt>0?e:null}catch{return null}}var eq=3e4;function tq(e,t){let n=e?.retryAfterMs;return typeof n==`number`&&Number.isFinite(n)?Math.min(eq,Math.max(0,n)):Math.min(eq,1e3*2**Math.min(t,5))}function nq(e){let t=e?.status;return typeof t!=`number`||t===408||t===429||t>=500}function rq(e,t){return t.throwIfAborted(),new Promise((n,r)=>{let i=()=>{globalThis.clearTimeout(a),r(t.reason??new DOMException(`Aborted`,`AbortError`))},a=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.addEventListener(`abort`,i,{once:!0})})}async function iq(e,t,n){let r=0;for(;!n.aborted;){let i=await t.list(e.draftId);t.onPendingCount?.(i.length);let a=i[0];if(!a)return;try{let n=await t.upload(e.discussionId,a);await t.remove(e.draftId,a),t.onTranscript?.(n),r=0}catch(e){if(n.aborted)throw n.reason??e;if(!nq(e))throw e;await rq(tq(e,r),n),r+=1}}}var aq=`xopc:recording-window-position:v1`,oq=()=>({x:window.visualViewport?.offsetLeft??0,y:window.visualViewport?.offsetTop??0,width:window.visualViewport?.width??window.innerWidth,height:window.visualViewport?.height??window.innerHeight});function sq(e,t,n){let r=oq();return{x:Math.max(r.x+12,Math.min(e.x,r.x+r.width-t-12)),y:Math.max(r.y+12,Math.min(e.y,r.y+r.height-n-12))}}function cq(){try{let e=JSON.parse(sessionStorage.getItem(aq)??`null`);return e&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e:null}catch{return null}}function lq(e){let t=(0,Q.c)(68),{compact:n,onCompactChange:r,title:i,subtitle:a,compactActions:o,children:s,language:c}=e,l=c===`zh`,u=(0,Z.useRef)(null),[d,f]=(0,Z.useState)(cq),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(oq),y=(0,Z.useRef)(null),b=(0,Z.useRef)(!1),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=function(e){let t=u.current?.getBoundingClientRect();if(!t)return;let n=sq(e,t.width,t.height);f(n);try{sessionStorage.setItem(aq,JSON.stringify(n))}catch{}},t[0]=x):x=t[0];let S=x,C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{let e=u.current;if(!e)return;let t=()=>{v(oq());let t=e.getBoundingClientRect();f(e=>{if(!e)return e;let n=sq(e,t.width,t.height);return n.x===e.x&&n.y===e.y?e:n})};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),window.visualViewport?.addEventListener(`resize`,t),window.visualViewport?.addEventListener(`scroll`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t),window.visualViewport?.removeEventListener(`resize`,t),window.visualViewport?.removeEventListener(`scroll`,t)}},t[1]=C):C=t[1];let w;t[2]===n?w=t[3]:(w=[n],t[2]=n,t[3]=w),(0,Z.useLayoutEffect)(C,w);let T=l?`录音浮窗`:`Recording window`,E=n?`compact`:`expanded`,D=Math.min(n?340:400,_.width-24),O=_.height-24,k;t[4]===d?k=t[5]:(k=d?{left:d.x,top:d.y}:{right:12,bottom:12},t[4]=d,t[5]=k);let A=p?`grabbing`:void 0,j;t[6]!==D||t[7]!==O||t[8]!==k||t[9]!==A?(j={width:D,maxHeight:O,...k,cursor:A},t[6]=D,t[7]=O,t[8]=k,t[9]=A,t[10]=j):j=t[10];let M=`flex shrink-0 items-center gap-1 ${n?`p-2`:`border-b border-edge-subtle px-3 py-2`}`,N=l?`移动录音窗`:`Move recording window`,P=l?`拖动移动,也可使用方向键或点击选择位置`:`Drag, use arrow keys, or click to choose a position`,F,I,L,R,z,B;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{if(e.button!==0||!e.isPrimary)return;let t=u.current?.getBoundingClientRect();t&&(y.current={id:e.pointerId,start:{x:e.clientX,y:e.clientY},origin:{x:t.left,y:t.top},moved:!1},e.currentTarget.setPointerCapture(e.pointerId))},I=e=>{let t=y.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.start.x,r=e.clientY-t.start.y;!t.moved&&Math.hypot(n,r)<4||(t.moved=!0,g(!1),m(!0),S({x:t.origin.x+n,y:t.origin.y+r}))},L=e=>{let t=y.current;!t||t.id!==e.pointerId||(b.current=t.moved,y.current=null,m(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},R=()=>{y.current=null,b.current=!0,m(!1)},z=()=>{y.current=null,m(!1)},B=()=>{if(b.current){b.current=!1;return}g(uq)},t[11]=F,t[12]=I,t[13]=L,t[14]=R,t[15]=z,t[16]=B):(F=t[11],I=t[12],L=t[13],R=t[14],z=t[15],B=t[16]);let V;t[17]!==_.height||t[18]!==_.width||t[19]!==_.x||t[20]!==_.y?(V=e=>{let t=e.shiftKey?48:16,n=u.current?.getBoundingClientRect();if(!n)return;let r={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];r&&(e.preventDefault(),S({x:n.left+r[0],y:n.top+r[1]})),e.key===`Escape`&&g(!1),e.key===`Home`&&(e.preventDefault(),S({x:_.x+_.width,y:_.y+_.height}))},t[17]=_.height,t[18]=_.width,t[19]=_.x,t[20]=_.y,t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),t[22]=H):H=t[22];let U;t[23]!==h||t[24]!==N||t[25]!==P||t[26]!==V?(U=(0,$.jsx)(`button`,{type:`button`,"aria-label":N,title:P,"aria-expanded":h,className:`flex size-10 shrink-0 touch-none items-center justify-center rounded-lg text-fg-muted outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent active:cursor-grabbing`,onPointerDown:F,onPointerMove:I,onPointerUp:L,onPointerCancel:R,onLostPointerCapture:z,onClick:B,onKeyDown:V,children:H}),t[23]=h,t[24]=N,t[25]=P,t[26]=V,t[27]=U):U=t[27];let W=`${n?`text-lg`:`text-sm`} font-medium tabular-nums`,ee;t[28]!==W||t[29]!==i?(ee=(0,$.jsx)(`div`,{className:W,children:i}),t[28]=W,t[29]=i,t[30]=ee):ee=t[30];let G;t[31]===a?G=t[32]:(G=a?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:a}):null,t[31]=a,t[32]=G);let K;t[33]!==ee||t[34]!==G?(K=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[ee,G]}),t[33]=ee,t[34]=G,t[35]=K):K=t[35];let q=n?o:null,te=n?l?`展开录音窗`:`Expand recording window`:l?`缩小录音窗`:`Minimize recording window`,ne=!n,re;t[36]!==n||t[37]!==r?(re=()=>{r(!n),g(!1)},t[36]=n,t[37]=r,t[38]=re):re=t[38];let ie;t[39]===n?ie=t[40]:(ie=n?(0,$.jsx)(Zi,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(ua,{className:`size-4`,"aria-hidden":!0}),t[39]=n,t[40]=ie);let ae;t[41]!==te||t[42]!==ne||t[43]!==re||t[44]!==ie?(ae=(0,$.jsx)(`button`,{type:`button`,"aria-label":te,"aria-expanded":ne,className:`flex size-10 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:re,children:ie}),t[41]=te,t[42]=ne,t[43]=re,t[44]=ie,t[45]=ae):ae=t[45];let oe;t[46]!==M||t[47]!==U||t[48]!==K||t[49]!==q||t[50]!==ae?(oe=(0,$.jsxs)(`header`,{className:M,children:[U,K,q,ae]}),t[46]=M,t[47]=U,t[48]=K,t[49]=q,t[50]=ae,t[51]=oe):oe=t[51];let se;t[52]!==h||t[53]!==_.height||t[54]!==_.width||t[55]!==_.x||t[56]!==_.y||t[57]!==l?(se=h?(0,$.jsx)(`div`,{className:`grid shrink-0 grid-cols-2 gap-1 border-b border-edge-subtle p-2`,"aria-label":l?`选择浮窗位置`:`Choose window position`,children:[[!1,!1],[!0,!1],[!1,!0],[!0,!0]].map((e,t)=>{let[n,r]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 rounded-lg px-3 text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{S({x:n?_.x+_.width:_.x,y:r?_.y+_.height:_.y}),g(!1)},children:(l?[`左上角`,`右上角`,`左下角`,`右下角`]:[`Top left`,`Top right`,`Bottom left`,`Bottom right`])[t]},t)})}):null,t[52]=h,t[53]=_.height,t[54]=_.width,t[55]=_.x,t[56]=_.y,t[57]=l,t[58]=se):se=t[58];let ce;t[59]===s?ce=t[60]:(ce=(0,$.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain`,children:s}),t[59]=s,t[60]=ce);let le;return t[61]!==j||t[62]!==oe||t[63]!==se||t[64]!==ce||t[65]!==T||t[66]!==E?(le=(0,$.jsxs)(`aside`,{ref:u,"aria-label":T,"data-recording-window":E,className:`fixed z-[125] flex flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay text-fg shadow-elevated`,style:j,children:[oe,se,ce]}),t[61]=j,t[62]=oe,t[63]=se,t[64]=ce,t[65]=T,t[66]=E,t[67]=le):le=t[67],le}function uq(e){return!e}function dq(e,t){let n=t===`zh`,r=Do(t).notes.discussionCapture.status;return e.save===`saveFailed`?e.savedThroughMs?`${n?`保存遇到问题,已保留至`:`Save interrupted; retained through`} ${fq(e.savedThroughMs)}`:r.saveFailed:e.localComplete?r.localComplete:e.savedThroughMs!==null&&e.savedThroughMs>0?r.savedThrough.replace(`{{time}}`,fq(e.savedThroughMs)):e.save===`savedUnknown`?n?`原音已暂存,保存时长确认中`:`Audio retained; checking saved duration`:n?`正在保存录音`:`Saving recording`}function fq(e){return`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`}function pq(e){let t=(0,Q.c)(66),{status:n,language:r,compact:i}=e,a=i!==void 0&&i,o;t[0]===r?o=t[1]:(o=Do(r),t[0]=r,t[1]=o);let s=o.notes.discussionCapture.status,c=r===`zh`,l;t[2]!==r||t[3]!==n?(l=dq(n,r),t[2]=r,t[3]=n,t[4]=l):l=t[4];let u=l;if(a){let e=`px-3 pb-2 text-xs ${n.save===`saveFailed`?`text-danger`:`text-fg-muted`}`,r=n.sync===`offline`?c?`离线录音 · `:`Recording offline · `:``,i;return t[5]!==u||t[6]!==e||t[7]!==r?(i=(0,$.jsxs)(`p`,{className:e,children:[r,u]}),t[5]=u,t[6]=e,t[7]=r,t[8]=i):i=t[8],i}let d;t[9]!==s.localComplete||t[10]!==n.localComplete?(d=n.localComplete?(0,$.jsx)(`p`,{role:`status`,className:`font-medium leading-5 text-fg`,children:s.localComplete}):null,t[9]=s.localComplete,t[10]=n.localComplete,t[11]=d):d=t[11];let f;t[12]!==n.hasInterruptions||t[13]!==c?(f=n.hasInterruptions?(0,$.jsx)(`p`,{children:c?`包含中断与续录;中断期间没有录音。`:`Contains interruptions and resumed audio. Nothing was captured during the interruptions.`}):null,t[12]=n.hasInterruptions,t[13]=c,t[14]=f):f=t[14];let p=`flex cursor-pointer list-none items-center gap-2 py-1 outline-none focus-visible:rounded focus-visible:ring-2 focus-visible:ring-accent ${n.save===`saveFailed`?`text-danger`:``}`,m=n.localComplete?c?`查看保存与整理进度`:`View saving and summary progress`:u,h;t[15]===m?h=t[16]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 leading-5`,children:m}),t[15]=m,t[16]=h);let g=c?`详情`:`Details`,_;t[17]===g?_=t[18]:(_=(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:g}),t[17]=g,t[18]=_);let v;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(gn,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[19]=v):v=t[19];let y;t[20]!==_||t[21]!==p||t[22]!==h?(y=(0,$.jsxs)(`summary`,{className:p,children:[h,_,v]}),t[20]=_,t[21]=p,t[22]=h,t[23]=y):y=t[23];let b=c?`录音`:`Recording`,x;t[24]===b?x=t[25]:(x=(0,$.jsx)(`dt`,{children:b}),t[24]=b,t[25]=x);let S=s[n.capture],C;t[26]===S?C=t[27]:(C=(0,$.jsx)(`dd`,{children:S}),t[26]=S,t[27]=C);let w=c?`本机保存`:`On this device`,T;t[28]===w?T=t[29]:(T=(0,$.jsx)(`dt`,{children:w}),t[28]=w,t[29]=T);let E;t[30]===u?E=t[31]:(E=(0,$.jsx)(`dd`,{children:u}),t[30]=u,t[31]=E);let D=c?`云端备份`:`Cloud backup`,O;t[32]===D?O=t[33]:(O=(0,$.jsx)(`dt`,{children:D}),t[32]=D,t[33]=O);let k=n.sync===`pending`?c?`录音结束后自动备份`:`Backs up after recording`:s[n.sync],A;t[34]===k?A=t[35]:(A=(0,$.jsx)(`dd`,{children:k}),t[34]=k,t[35]=A);let j=c?`文字与笔记`:`Text and notes`,M;t[36]===j?M=t[37]:(M=(0,$.jsx)(`dt`,{children:j}),t[36]=j,t[37]=M);let N=n.ai===`waitingSource`?c?`录音保存后继续整理`:`Continues after the recording is saved`:s[n.ai],P;t[38]===N?P=t[39]:(P=(0,$.jsx)(`dd`,{children:N}),t[38]=N,t[39]=P);let F;t[40]!==x||t[41]!==C||t[42]!==T||t[43]!==E||t[44]!==O||t[45]!==A||t[46]!==M||t[47]!==P?(F=(0,$.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-2 rounded-lg bg-surface-inset p-3 leading-5`,children:[x,C,T,E,O,A,M,P]}),t[40]=x,t[41]=C,t[42]=T,t[43]=E,t[44]=O,t[45]=A,t[46]=M,t[47]=P,t[48]=F):F=t[48];let I;t[49]!==s.timingPending||t[50]!==n.timingUncertain?(I=n.timingUncertain?(0,$.jsx)(`p`,{className:`mt-2 leading-5`,children:s.timingPending}):null,t[49]=s.timingPending,t[50]=n.timingUncertain,t[51]=I):I=t[51];let L;t[52]!==s.leaveHint||t[53]!==n.localComplete||t[54]!==n.sync?(L=n.localComplete&&n.sync!==`available`?(0,$.jsx)(`p`,{className:`mt-2 leading-5`,children:s.leaveHint}):null,t[52]=s.leaveHint,t[53]=n.localComplete,t[54]=n.sync,t[55]=L):L=t[55];let R;t[56]!==y||t[57]!==F||t[58]!==I||t[59]!==L?(R=(0,$.jsxs)(`details`,{className:`group`,children:[y,F,I,L]}),t[56]=y,t[57]=F,t[58]=I,t[59]=L,t[60]=R):R=t[60];let z;return t[61]!==s.label||t[62]!==R||t[63]!==d||t[64]!==f?(z=(0,$.jsxs)(`section`,{"aria-label":s.label,className:`space-y-2 text-xs text-fg-muted`,children:[d,f,R]}),t[61]=s.label,t[62]=R,t[63]=d,t[64]=f,t[65]=z):z=t[65],z}async function mq(e){return navigator.locks?new Promise((t,n)=>{navigator.locks.request(`xopc-recording:${e}`,{ifAvailable:!0},async e=>{if(!e){n(Error(`This recording is open in another tab. Close it before recovery.`));return}await new Promise(e=>t(e))}).catch(n)}):()=>{}}function hq(e,t){let n=new Uint8Array(512),r=(e,t)=>n.set(new TextEncoder().encode(t),e);return r(0,e),r(100,`0000600\0`),r(108,`0000000\0`),r(116,`0000000\0`),r(124,t.toString(8).padStart(11,`0`)+`\0`),r(136,`00000000000\0`),n.fill(32,148,156),r(156,`0`),r(257,`ustar\0`),r(263,`00`),r(148,n.reduce((e,t)=>e+t,0).toString(8).padStart(6,`0`)+`\0 `),n}async function*gq(e){let t=[];for(let n=0;n<e.chunkCount;n++){let r=await _i(e.id,n);if(!r){t.push({index:n,missing:!0});continue}let i=new Uint8Array(await r.blob.arrayBuffer()),a=await crypto.subtle.digest(`SHA-256`,i);t.push({index:n,bytes:i.length,sha256:[...new Uint8Array(a)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}),yield hq(`chunks/${String(n).padStart(6,`0`)}.bin`,i.length),yield i,i.length%512&&(yield new Uint8Array(512-i.length%512))}let n,r=await V(e.id).catch(e=>(n=String(e),[])),i=new TextEncoder().encode(JSON.stringify({version:1,draft:e,chunks:t,annotations:r,annotationReadError:n,reconstruction:`Concatenate chunk bytes in index order within each epoch only. Epochs are independent containers. Missing chunks must never be skipped when reconstructing media.`},null,2));yield hq(`manifest.json`,i.length),yield i,i.length%512&&(yield new Uint8Array(512-i.length%512)),yield new Uint8Array(1024)}function _q(e){return(e.epochs?.length??1)===1&&e.saveOutcome===`complete`&&e.mediaCoverage?.status===`verified`&&e.mediaCoverage.committedChunkCount===e.chunkCount&&e.mediaCoverage.verifiedThroughMs>0}async function*vq(e){for(let t=0;t<e.chunkCount;t++){let n=await _i(e.id,t);if(!n)throw Error(`Original audio has missing chunks; export a recovery package instead.`);let r=n.blob.stream().getReader();try{for(;;){let e=await r.read();if(e.done)break;yield e.value}}finally{r.releaseLock()}}}async function yq(e){let t=window.showSaveFilePicker,n=await V(e.id).catch(()=>null),r=_q(e)&&n!==null&&n.length===0,i=e.mimeType.includes(`mp4`)?`m4a`:e.mimeType.includes(`ogg`)?`ogg`:`webm`,a=`recording-${e.id}.${r?i:`tar`}`,o=()=>r?vq(e):gq(e);if(t){let e=await(await t.call(window,{suggestedName:a})).createWritable();try{for await(let t of o())await e.write(t);await e.close()}catch(t){throw await e.abort().catch(()=>void 0),t}return}let s=[],c=0;for await(let e of o()){if(c+=e.length,c>64*1024*1024)throw Error(`Use Chrome or Edge file saving to export recordings over 64 MB. Your original audio is retained.`);s.push(e)}let l=URL.createObjectURL(new Blob(s,{type:r?e.mimeType:`application/x-tar`})),u=document.createElement(`a`);u.href=l,u.download=a,u.click(),window.setTimeout(()=>URL.revokeObjectURL(l),6e4)}var bq=class{now;accumulated=0;started=null;constructor(e=()=>performance.now()){this.now=e}get elapsedMs(){return this.accumulated+(this.started===null?0:Math.max(0,this.now()-this.started))}resume(){this.started===null&&(this.started=this.now())}pause(){this.accumulated=this.elapsedMs,this.started=null}reset(e=0){this.accumulated=e,this.started=null}},xq=4,Sq=15,Cq=.6,wq=.5,Tq=.5,Eq=.015;function Dq(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function Oq(e){let t=await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer());return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var kq=class{sampleRate;chunks=[];bufferedSamples=0;segmentStartSample=0;sequence=0;silenceSamples=0;hasSpeech=!1;constructor(e){this.sampleRate=e}add(e){if(e.length===0)return[];this.chunks.push(e),this.bufferedSamples+=e.length,Ss(e)>=Eq?(this.hasSpeech=!0,this.silenceSamples=0):this.silenceSamples+=e.length;let t=this.sampleRate*Sq;return this.bufferedSamples>=t?this.hasSpeech?[this.emit(`max`)]:(this.discardBuffered(),[]):this.hasSpeech&&this.bufferedSamples>=this.sampleRate*xq&&this.silenceSamples>=this.sampleRate*Cq?[this.emit(`silence`)]:[]}finish(){return!this.hasSpeech||this.bufferedSamples<this.sampleRate*Tq?(this.discardBuffered(),[]):[this.emit(`final`)]}cancel(){this.chunks=[],this.bufferedSamples=0}get lastSequence(){return this.sequence-1}emit(e){let t=Dq(this.chunks),n=e===`max`?Math.min(t.length,this.sampleRate*Sq):t.length,r=t.slice(0,n),i=e===`max`?Math.min(n,this.sampleRate*wq):0,a=t.slice(n-i),o=Math.round(this.segmentStartSample/this.sampleRate*1e3),s=Math.round((this.segmentStartSample+n)/this.sampleRate*1e3),c={sequence:this.sequence++,samples:r,startedAtMs:o,endedAtMs:s};return this.segmentStartSample+=n-i,this.chunks=a.length?[a]:[],this.bufferedSamples=a.length,this.hasSpeech=a.length>0&&Ss(a)>=Eq,this.silenceSamples=this.hasSpeech?0:a.length,c}discardBuffered(){this.segmentStartSample+=this.bufferedSamples,this.chunks=[],this.bufferedSamples=0,this.silenceSamples=0,this.hasSpeech=!1}},Aq=class e{capture;accumulator;emitState;onSegment;stopped=!1;constructor(e,t,n,r){this.capture=e,this.accumulator=t,this.emitState=n,this.onSegment=r}static async start(t,n,r){let i={pending:new Set},a,o=[],s=await ws.start(t,{onSamples:e=>{if(e.length&&r?.(Ss(e)),!a){o.push(e);return}for(let t of a.accumulator.add(e))a.emit(t)}});a=new e(s,new kq(s.sampleRate),i,n);for(let e of o)for(let t of a.accumulator.add(e))a.emit(t);return a}pause(){this.capture.pause()}resume(){this.capture.resume()}async stop(){if(this.stopped)return this.accumulator.lastSequence;this.stopped=!0,await this.capture.stop();for(let e of this.accumulator.finish())this.emit(e);if(await Promise.all(this.emitState.pending),this.emitState.error)throw this.emitState.error;return this.accumulator.lastSequence}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.accumulator.cancel())}emit(e){let t=bs(e.samples,this.capture.sampleRate),n=new Blob([Ts(t)],{type:`audio/wav`}),r=(async()=>{await this.onSegment({sequence:e.sequence,blob:n,startedAtMs:e.startedAtMs,endedAtMs:e.endedAtMs,sha256:await Oq(n)})})().catch(e=>{this.emitState.error??=e});this.emitState.pending.add(r),r.then(()=>this.emitState.pending.delete(r))}},jq=gi,Mq=100*1024*1024,Nq=32*1024*1024;function Pq(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/ogg;codecs=opus`,`audio/webm`].find(e=>MediaRecorder.isTypeSupported(e))}function Fq(e){try{e?.cancel()}catch{}}function Iq(){let e=(0,Z.useRef)(null),t=()=>{e.current?.(),e.current=null},n=(0,Z.useRef)([]),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=(0,Z.useRef)(Symbol(`meeting-capture`)),c=(0,Z.useRef)(0),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(`idle`),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!0),S=(0,Z.useRef)(null),C=(0,Z.useRef)(Promise.resolve()),w=(0,Z.useRef)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useRef)(0),O=(0,Z.useRef)(new bq),k=(0,Z.useRef)(Promise.resolve()),A=(0,Z.useRef)(0),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),P=(0,Z.useRef)(!1),F=(0,Z.useRef)(!1),I=(0,Z.useRef)(0),[L,z]=(0,Z.useState)(null),V=(0,Z.useRef)(null),H=(0,Z.useRef)(null),U=(0,Z.useRef)(!1),W=(0,Z.useRef)(()=>Promise.resolve(null)),ee=(0,Z.useCallback)(async()=>{try{h(await Di())}catch{h([])}},[]);(0,Z.useEffect)(()=>{ee()},[ee]);let G=(0,Z.useCallback)(()=>{V.current!=null&&window.clearInterval(V.current),V.current=null,H.current?.(),H.current=null,Dc(s.current),T.current?.getTracks().forEach(e=>e.stop()),T.current=null,S.current=null},[]);(0,Z.useEffect)(()=>()=>{c.current+=1,E.current||G(),W.current().catch(()=>void 0)},[G]);let K=(0,Z.useCallback)(e=>{j.current??=e instanceof Error?e:Error(`Local recording storage failed`),O.current.pause(),y(`Local recording storage failed. Only previously saved audio can be recovered.`),Fq(w.current),W.current().catch(()=>void 0)},[]),q=(0,Z.useCallback)(e=>{let t=E.current;if(!t||!F.current||j.current)return;if(e.size===0){let e=performance.now();k.current=k.current.then(()=>{let r=M.current?.packetClock();if(E.current?.id===t.id&&r?.verified)for(let t of n.current)t.at<=e&&(t.target??=r.durationMs)});return}if(A.current+e.size>Nq){K(Error(`Local storage cannot keep up with recording`));return}let r=O.current.elapsedMs,i=performance.now();A.current+=e.size;let a=D.current;D.current+=Math.ceil(e.size/Si),k.current=k.current.then(async()=>{let s=M.current?.packetClock().durationMs??0;for(let c=0,l=a;c<e.size;c+=Si,l+=1){if(j.current)return;let a=E.current;if(!a||a.id!==t.id)return;let u=e.slice(c,c+Si),f=M.current?.snapshot().observedThroughMs??0,m=M.current?.append(new Uint8Array(await u.arrayBuffer()));m&&m.observedThroughMs>f&&(I.current=Math.max(I.current,i),performance.now()-i<15e3&&S.current?.state===`recording`&&d(e=>e===`waiting_for_audio`?`recording`:e));let h={...a,chunkCount:l+1,durationMs:c+8388608>=e.size?Math.max(a.durationMs,r):a.durationMs,updatedAt:Date.now(),...m?{mediaCoverage:{...m,committedChunkCount:l+1}}:{}};if(await ji({draftId:t.id,index:l,blob:u,createdAt:Date.now()},h),E.current?.id!==t.id)return;E.current=h,p(h);let g=M.current?.packetClock();if(g?.verified&&c+8388608>=e.size){let e=n.current.filter(e=>e.at<=i);if(g.durationMs<=s)for(let t of e)t.target??=g.durationMs;else{let r=e.filter(e=>e.target===void 0||e.target<g.durationMs),i=new Set(r.map(e=>e.id));n.current=n.current.filter(e=>!i.has(e.id));for(let e of r){let n=e.target??Math.max(0,g.durationMs-1);e.saved.then(()=>N(t.id,e.id,n)).catch(e=>o(e instanceof Error?e.message:`Could not locate the saved highlight`))}}}}}).catch(e=>{K(e)}).finally(()=>{A.current-=e.size})},[K]),te=(0,Z.useCallback)(async()=>{let e=S.current;if(!E.current)return null;if(!e&&E.current.state!==`recording`)return E.current;++c.current,d(`stopping`),O.current.pause(),_(O.current.elapsedMs);let n=w.current;w.current=null,Fq(n);let r;try{e&&await new Promise((t,n)=>{let r=window.setTimeout(()=>{n(Error(`Recording stopped responding. Previously saved audio is available for recovery.`))},5e3);C.current.then(()=>{window.clearTimeout(r),t()});try{e.state!==`inactive`&&e.stop()}catch(e){window.clearTimeout(r),n(e)}})}catch(e){r=e instanceof Error?e:Error(`Recording could not finish`)}finally{F.current=!1,G(),z(null)}await k.current;let i=E.current;if(!i)return null;let a={...i,state:`stopped`,lastSequence:-1,durationMs:i.durationMs,updatedAt:Date.now(),endedAt:Date.now(),saveOutcome:j.current||r||!i.chunkCount?`incomplete`:P.current?`interrupted`:`complete`};try{if(await wi(a),E.current=a,p(a),_(a.durationMs),j.current)throw j.current;if(r)throw r;if(!i.chunkCount)throw Error(`No audio was saved`);return d(`stopped`),a}catch(e){throw d(`error`),y(j.current?`Local storage failed. Recover the previously saved portion after freeing space.`:e instanceof Error?e.message:`Recording could not finish`),e}finally{t(),await ee()}},[ee,G]),ne=(0,Z.useCallback)(()=>{if(l.current)return l.current;let e=Promise.resolve().then(te).finally(()=>{l.current=null});return l.current=e,e},[te]);W.current=ne;let re=(0,Z.useCallback)(async r=>{if(U.current||S.current||l.current)return null;if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`)return y(`Audio recording is not supported in this environment.`),d(`error`),null;if(!wc(s.current))return y(`The microphone is being used by a voice call. End the call before recording.`),null;U.current=!0;let a=++c.current;y(null),d(`requesting_permission`);try{await k.current,j.current=null,P.current=!1,F.current=!1,z(null),A.current=0,n.current=[],i(null),o(null),r.continuation&&(e.current=await mq(r.continuation.id));let u=r.continuation?await yi(r.continuation.id):null;if(u?.sealRequested)throw Error(`Recording has already been submitted. Recover and sync it first.`);if(u&&u.gatewayUrl!==r.gatewayUrl)throw Error(`Return to the original Gateway before continuing this recording.`);let f=await navigator.storage?.estimate?.();if(f?.quota!=null&&f.usage!=null&&f.quota-f.usage<Mq)throw Error(`Not enough local storage for a discussion recording.`);let m=await navigator.mediaDevices.getUserMedia({audio:!0});if(a!==c.current)return m.getTracks().forEach(e=>e.stop()),Dc(s.current),t(),null;T.current=m;let h=Pq(),g=h?new MediaRecorder(m,{mimeType:h,audioBitsPerSecond:64e3}):new MediaRecorder(m,{audioBitsPerSecond:64e3}),v=Date.now(),b=g.mimeType||h||`audio/webm`,N=u?[...u.epochs??[{firstChunk:0,mimeType:u.mimeType,startedAt:u.startedAt}]]:[{firstChunk:0,mimeType:b,startedAt:v}];u&&(N[N.length-1]={...N[N.length-1],savedThroughMs:u.mediaCoverage?.committedChunkCount===u.chunkCount?u.mediaCoverage.verifiedThroughMs:void 0},N.push({firstChunk:u.chunkCount,mimeType:b,startedAt:v,previousEndedAt:u.endedAt??u.updatedAt}));let L={id:u?.id??crypto.randomUUID(),...u,gatewayUrl:r.gatewayUrl,epochs:N,mediaCoverage:void 0,endedAt:void 0,saveOutcome:void 0,consentPolicyVersion:r.consentPolicyVersion??u?.consentPolicyVersion,...r.projectId?{projectId:r.projectId}:{},mimeType:b,startedAt:u?.startedAt??v,updatedAt:v,durationMs:u?.durationMs??0,chunkCount:u?.chunkCount??0,lastSequence:-1,state:`recording`};if(e.current||=await mq(L.id),await wi(L),navigator.storage?.persist?.().catch(()=>!1),a!==c.current)return G(),t(),null;S.current=g,E.current=L,D.current=L.chunkCount,M.current=new xi(L.mimeType),F.current=!0,I.current=performance.now(),O.current.reset(L.durationMs),O.current.resume(),k.current=Promise.resolve(),g.ondataavailable=e=>{E.current?.id===L.id&&S.current===g&&q(e.data)};let R=()=>{E.current?.id!==L.id||S.current!==g||!F.current||(P.current=!0,O.current.pause(),d(`stopping`),y(`The microphone stopped unexpectedly. Recover the saved audio.`),ne().catch(()=>void 0))};g.onerror=R,C.current=new Promise(e=>{g.onstop=()=>{e(),l.current||R()}});let B=m.getAudioTracks(),U=()=>{B.some(e=>e.muted||e.readyState===`ended`)&&R()};B.forEach(e=>{e.addEventListener(`ended`,R),e.addEventListener(`mute`,R)}),document.addEventListener(`freeze`,R),document.addEventListener(`visibilitychange`,U),window.addEventListener(`pageshow`,U),H.current=()=>{B.forEach(e=>{e.removeEventListener(`ended`,R),e.removeEventListener(`mute`,R)}),document.removeEventListener(`freeze`,R),document.removeEventListener(`visibilitychange`,U),window.removeEventListener(`pageshow`,U)},g.start(5e3);let W=-1/0;return Aq.start(m,e=>{if(!u)return r.onLiveSegment(L.id,e)},e=>{a!==c.current||g.state!==`recording`||(I.current=performance.now(),d(e=>e===`waiting_for_audio`?`recording`:e),performance.now()-W>=200&&(W=performance.now(),z(e)))}).then(e=>{if(a!==c.current||g.state===`inactive`){Fq(e);return}w.current=e,x(!u)}).catch(()=>x(!1)),p(L),_(L.durationMs),d(`waiting_for_audio`),U(),V.current=window.setInterval(()=>{if(g.state===`inactive`&&!l.current){R();return}g.state===`recording`&&performance.now()-I.current>=15e3&&(d(e=>e===`recording`?`waiting_for_audio`:e),z(null));let e=O.current.elapsedMs;_(e),e>=jq&&ne().catch(()=>void 0)},1e3),L}catch(e){return Fq(w.current),F.current=!1,w.current=null,G(),t(),y(e instanceof Error?e.message:`Microphone permission was denied.`),d(`error`),null}finally{U.current=!1}},[q,ne,G]),ie=(0,Z.useCallback)(async()=>{let e=E.current,t=S.current;if(!e||!t||t.state!==`recording`)return;let r=R({type:`time`,capturedAt:Date.now(),epoch:(e.epochs?.length??1)-1,coordinate:`pcm`});o(null);let a=B(e.id,r);n.current.push({id:r.id,at:performance.now(),saved:a});try{t.requestData()}catch{}try{await a,i(`saved`)}catch(e){n.current=n.current.filter(e=>e.id!==r.id),o(e instanceof Error?e.message:`Highlight could not be saved`)}},[]),ae=(0,Z.useCallback)(()=>{S.current?.state===`recording`&&(O.current.pause(),_(O.current.elapsedMs),S.current.pause(),w.current?.pause(),d(`paused`),z(null))},[]),oe=(0,Z.useCallback)(()=>{S.current?.state===`paused`&&(O.current.resume(),S.current.resume(),w.current?.resume(),d(`waiting_for_audio`))},[]),se=(0,Z.useCallback)(async e=>{k.current=k.current.then(async()=>{let t=E.current;if(!t)return;let n={...t,serverDiscussionId:e,updatedAt:Date.now()};await wi(n),E.current=n,p(n)}).catch(K),await k.current},[K]);return{phase:u,draft:f,recoverableDrafts:m,elapsedMs:g,error:v,liveTranscriptionAvailable:b,inputLevel:L,mark:ie,markerMessage:r,markerError:a,start:re,pause:ae,resume:oe,stop:ne,restore:(0,Z.useCallback)(async e=>{if(S.current||U.current||l.current)throw Error(`Stop the active recording before recovery.`);await k.current,j.current=null;let t=await yi(e.id),n={...t,endedAt:t.endedAt??t.updatedAt,state:`stopped`,updatedAt:Date.now()};return await wi(n),E.current=n,O.current.reset(n.durationMs),p(n),_(n.durationMs),y(null),d(`stopped`),n},[]),discard:(0,Z.useCallback)(async e=>{if(S.current||U.current||l.current)throw Error(`Stop the active recording before discarding.`);await k.current,await ki(e),E.current?.id===e&&(E.current=null,p(null),_(0),d(`idle`)),await ee()},[ee]),markUploadFailed:(0,Z.useCallback)(async e=>{let t=e??E.current?.id;if(!t)return;let n=(await Di()).find(e=>e.id===t);if(!n||n.state===`recording`)return;let r={...n,state:`upload_failed`,updatedAt:Date.now()};await wi(r),E.current?.id===t&&(E.current=r,p(r)),await ee()},[ee]),reset:(0,Z.useCallback)(()=>{E.current=null,O.current.reset(),p(null),_(0),y(null),d(`idle`)},[]),setServerDiscussionId:se,refreshRecoverableDrafts:ee}}function Lq(e){let t=Math.max(0,Math.floor(e/1e3));return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`}function Rq(){let e=b(),{pathname:t}=p(),n=Ro(e=>e.conversationId),r=Ro(e=>e.baseUrl),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u=zo(e=>e.language),d=Do(u).notes.discussionCapture,f=Iq(),m=(0,Z.useRef)(!1),h=(0,Z.useRef)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(),[D,O]=(0,Z.useState)(null),[k,N]=(0,Z.useState)(null),[R,B]=(0,Z.useState)(!1),[V,G]=(0,Z.useState)(!1),[q,te]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(0),[ie,ae]=(0,Z.useState)(0),[oe,se]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(`pending`),[fe,pe]=(0,Z.useState)(!1),[me,he]=(0,Z.useState)(null),[ge,_e]=(0,Z.useState)(()=>navigator.onLine);(0,Z.useEffect)(()=>{let e=()=>_e(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let ve=Oi({phase:f.phase,draft:fe?null:f.draft,locallyFinalized:fe?null:me,online:ge,syncStage:ue,detail:D,transcript:k,pendingText:ie,liveAvailable:f.liveTranscriptionAvailable}),J=[`recording`,`waiting_for_audio`,`requesting_permission`,`paused`,`stopping`].includes(f.phase),ye=(0,Z.useRef)(!1),be=(0,Z.useRef)(null),xe=(0,Z.useRef)(!1),Se=(0,Z.useRef)(!1),Ce=(0,Z.useRef)(null),we=(0,Z.useRef)(null),Te=(0,Z.useRef)(null),Ee=(0,Z.useRef)(null),De=(0,Z.useRef)(()=>{}),Oe=(0,Z.useCallback)(()=>{let e=Ee.current;if(e)return e;let t=we.current;if(!t)return Promise.resolve();let n=new AbortController;Te.current=n;let r=iq(t,{list:Ai,upload:(e,t)=>ee(e,t.sequence,t),remove:(e,t)=>Ci(e,t.sequence),onTranscript:N,onPendingCount:ae},n.signal).finally(()=>{Ee.current===r&&(Ee.current=null,Te.current===n&&(Te.current=null))});return Ee.current=r,r.then(()=>{window.setTimeout(()=>De.current(),0)}).catch(e=>{n.signal.aborted||se(e instanceof Error?e.message:d.saveFailed)}),r},[]);De.current=()=>{let e=we.current;!e||Ee.current||Ai(e.draftId).then(e=>{ae(e.length),e.length>0&&Oe()})};let ke=(0,Z.useCallback)((e,t)=>{let n=we.current;return n&&(n.draftId!==e||n.discussionId!==t)&&(Te.current?.abort(),Ee.current=null),we.current={draftId:e,discussionId:t},Oe()},[Oe]),Ae=(0,Z.useCallback)(async(e,t)=>{await bi({draftId:e,...t,createdAt:Date.now()}),ae(e=>e+1),Oe()},[Oe]),je=(0,Z.useCallback)(async(e,t)=>{m.current=!1,se(null),y(!1),w(null),E(void 0),S(!0),le(null),N(null),O(null),re(0),pe(!1),a(!1),he(null),de(`pending`);let n=await f.start({...e?{projectId:e}:{},consentPolicyVersion:t,gatewayUrl:r,onLiveSegment:Ae});if(!n)return;Se.current=!0;let i=F({clientRequestId:n.id,...e?{contextProjectId:e}:{},consentPolicyVersion:t,source:Ol()?`electron`:`web`,recordedAt:n.startedAt});Ce.current=i;try{let e=await i;O(e),await f.setServerDiscussionId(e.discussion.id),ke(n.id,e.discussion.id)}catch(e){de(`failed`),se(e instanceof Error?e.message:d.saveFailed)}},[ke,d.saveFailed,f,Ae,r]);(0,Z.useEffect)(()=>()=>Te.current?.abort(),[]);let Me=(0,Z.useCallback)(async e=>{if(!(!n||h.current||R)){if([`recording`,`waiting_for_audio`,`requesting_permission`,`paused`,`stopping`].includes(f.phase)){S(!0),y(!1);return}h.current=!0,_(!0),S(!0),le(null);try{let t=$K()??await W();if(QK(t),t.consentAcknowledgedAt==null){E(e),w(t.consentPolicyVersion);return}await je(e,t.consentPolicyVersion)}catch(e){le(e instanceof Error?e.message:d.saveFailed)}finally{h.current=!1,_(!1)}}},[je,d.saveFailed,R,f.phase,n]);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.projectId;Me(t)};return window.addEventListener(A,e),()=>window.removeEventListener(A,e)},[Me]),(0,Z.useEffect)(()=>{let e=f.draft,t=D?.discussion.id;if(!e||!t||!e.chunkCount||R||be.current||![`recording`,`waiting_for_audio`,`paused`].includes(f.phase))return;let n=Ei(e,t,re,!1,de).catch(e=>{de(`failed`),se(e instanceof Error?e.message:d.saveFailed)}).finally(()=>{be.current=null});be.current=n},[f.draft,f.phase,D?.discussion.id,R,d.saveFailed]);let Ne=(0,Z.useCallback)(async()=>{let e=D?.discussion.id;if(!e)return;let[t,n]=await Promise.all([z(e),I(e)]);O(t),N(n)},[D?.discussion.id]);(0,Z.useEffect)(()=>{let e=()=>void Ne().catch(()=>void 0);return window.addEventListener(`discussion-segment-updated`,e),window.addEventListener(`discussion-updated`,e),()=>{window.removeEventListener(`discussion-segment-updated`,e),window.removeEventListener(`discussion-updated`,e)}},[Ne]),(0,Z.useEffect)(()=>{if(!D||![`stopping`,`sealing`,`organizing`].includes(D.discussion.status)&&![`queued`,`running`].includes(D.recordingJob?.state??``))return;let e=window.setInterval(()=>void Ne().catch(()=>void 0),3e3);return()=>window.clearInterval(e)},[D,Ne]);let Pe=async()=>{if(!(C==null||h.current)){h.current=!0,_(!0);try{QK(await H(C)),await je(T,C)}catch(e){le(e instanceof Error?e.message:d.saveFailed)}finally{h.current=!1,_(!1)}}},Fe=async()=>{if(xe.current)return;xe.current=!0,Se.current=!1,B(!0),le(null);let e;try{let t=await f.stop();if(!t)throw Error(d.emptyRecording);pe(!1),he(t),e=await mq(t.id);let n=await Ce.current?.catch(()=>null)??await F({clientRequestId:t.id,...t.projectId?{contextProjectId:t.projectId}:{},consentPolicyVersion:t.consentPolicyVersion??(await W()).consentPolicyVersion,source:Ol()?`electron`:`web`,recordedAt:t.startedAt});Ce.current=Promise.resolve(n),O(n),await f.setServerDiscussionId(n.discussion.id),G(!0),await be.current;let r=await Ei(t,n.discussion.id,re,!0,de);if(Te.current?.abort(),!r?.discussion.audioAttachmentId||r.discussion.audioDeletedAt)throw Error(`Original audio attachment is not confirmed`);O(r);try{await U(t.id,n.discussion.id),a(!1),await f.discard(t.id),pe(!0)}catch{a(!0)}we.current=null,ae(0)}catch(e){de(`failed`),await f.markUploadFailed().catch(()=>void 0),le(e instanceof Error?e.message:d.saveFailed),S(!0)}finally{e?.(),xe.current=!1,B(!1),G(!1)}};(0,Z.useEffect)(()=>{f.phase===`stopped`&&f.draft?.saveOutcome===`complete`&&Se.current&&Fe()}),(0,Z.useEffect)(()=>{(m.current||t===`/notes/${encodeURIComponent(D?.note.id??``)}`)&&!i&&D?.discussion.audioAttachmentId&&!D.discussion.audioDeletedAt&&![`recording`,`paused`,`waiting_for_audio`,`requesting_permission`].includes(f.phase)&&S(!1)},[D,f.phase,i,t]);let Ie=()=>{D&&(m.current=![`recording`,`paused`,`waiting_for_audio`,`requesting_permission`].includes(f.phase),y(!0),m.current&&D.discussion.audioAttachmentId&&!D.discussion.audioDeletedAt&&!i&&S(!1),e(`/notes/${encodeURIComponent(D.note.id)}`))},Le=async()=>{if(D)try{O(await M(D.discussion.id))}catch(e){le(e instanceof Error?e.message:d.saveFailed)}},Re=async e=>{let t=e??f.recoverableDrafts[0];if(!t||q||ye.current||xe.current||J)return;ye.current=!0,Se.current=!1,te(!0),S(!0),le(null),re(0);let n;try{if(n=await mq(t.id),t.gatewayUrl!==r)throw Error(u===`zh`?`请切回录制时的 Gateway 后恢复`:`Return to the original Gateway to recover`);t=await f.restore(t),pe(!1),he(t);let e=$K()??await W();if(QK(e),e.consentAcknowledgedAt==null)throw Error(d.consent);let i=t.serverDiscussionId?await z(t.serverDiscussionId):null;i||=await F({clientRequestId:t.id,...t.projectId?{contextProjectId:t.projectId}:{},consentPolicyVersion:e.consentPolicyVersion,source:Ol()?`electron`:`web`,recordedAt:t.startedAt}),Ce.current=Promise.resolve(i),O(i),await f.setServerDiscussionId(i.discussion.id);let o=!1;try{await U(t.id,i.discussion.id),o=!0,a(!1)}catch{a(!0)}if(i.discussion.audioDeletedAt)throw Error(`Original recording was deleted`);if(i.discussion.audioAttachmentId&&[`sealing`,`organizing`,`completed`].includes(i.discussion.status)){o&&(await f.discard(t.id),pe(!0));return}if(i.discussion.status===`cancelled`)throw Error(`This recording was cancelled`);i.discussion.audioAttachmentId||await Ei(t,i.discussion.id,re,!0,de),Te.current?.abort();let s=await z(i.discussion.id);if(!s.discussion.audioAttachmentId||s.discussion.audioDeletedAt)throw Error(`Original audio attachment is not confirmed`);s.discussion.status===`needs_attention`?O(await L(i.discussion.id)):O(s),o&&(await f.discard(t.id),pe(!0))}catch(e){await f.markUploadFailed(t.id).catch(()=>void 0),de(`failed`),le(e instanceof Error?e.message:d.saveFailed)}finally{n?.(),ye.current=!1,te(!1)}},ze=async e=>{if(!(ye.current||xe.current||[`recording`,`waiting_for_audio`,`paused`,`requesting_permission`,`stopping`].includes(f.phase))){ye.current=!0,te(!0),le(null);try{if(e.gatewayUrl!==r)throw Error(`Return to the original Gateway before continuing.`);if(e.sealRequested)throw Error(`Recover and sync this submitted recording first.`);let t=e.serverDiscussionId?await z(e.serverDiscussionId):null;if(t&&(t.discussion.audioAttachmentId||t.recordingJob||![`recording`,`needs_attention`].includes(t.discussion.status)))throw Error(`Recover and sync this submitted recording first.`);if(!await f.start({continuation:e,gatewayUrl:r,onLiveSegment:Ae}))return;Ce.current=t?Promise.resolve(t):null,O(t),N(null),pe(!1),a(!1),he(null),de(`pending`),l(!1),S(!0),Se.current=!0}catch(e){le(e instanceof Error?e.message:d.saveFailed)}finally{ye.current=!1,te(!1)}}},Be=async e=>{if(xe.current||q||J)return;let t=e??f.recoverableDrafts[0];if(!t)return;let n;try{n=await mq(t.id),await f.discard(t.id)}catch(e){le(e instanceof Error?e.message:d.saveFailed)}finally{n?.()}},Ve=async e=>{if(ye.current||xe.current||J)return;ye.current=!0,te(!0),le(null);let t;try{t=await mq(e.id);let n=(await Di()).find(t=>t.id===e.id);if(!n)throw Error(`Recording is no longer available on this device.`);await yq(n)}catch(e){e instanceof DOMException&&e.name===`AbortError`||le(e instanceof Error?e.message:d.saveFailed)}finally{t?.(),ye.current=!1,te(!1)}};if((0,Z.useEffect)(()=>{let e=()=>{f.refreshRecoverableDrafts(),l(!0)};return window.addEventListener(`open-recording-recoveries`,e),()=>window.removeEventListener(`open-recording-recoveries`,e)},[f.refreshRecoverableDrafts]),c)return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[135] flex items-center justify-center bg-black/45 p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":d.recoveredTitle,children:(0,$.jsxs)(`section`,{className:`flex h-[min(40rem,85vh)] w-[min(40rem,95vw)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(`h2`,{children:d.recoveredTitle}),(0,$.jsx)(X,{onClick:()=>l(!1),children:d.close})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[ce?(0,$.jsx)(`p`,{role:`alert`,className:`mb-3 text-danger`,children:ce}):null,f.recoverableDrafts.length?null:(0,$.jsx)(`p`,{children:u===`zh`?`没有待恢复录音`:`No recordings to recover`}),f.recoverableDrafts.map(e=>(0,$.jsxs)(`article`,{className:`mb-3 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{children:[new Date(e.startedAt).toLocaleString(),` · `,e.id.slice(0,8)]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.gatewayUrl,` · `,e.state===`upload_failed`?d.status.failed:e.sealRequested?d.status.verifying:d.status.pending]}),(0,$.jsxs)(`p`,{className:`text-sm`,children:[u===`zh`?`本机已保存`:`Saved locally`,` · `,Ti(e)===null?u===`zh`?`时长待核实`:`duration unverified`:Lq(Ti(e)),` · `,Lq(e.durationMs),` `,u===`zh`?`录制时长(中断处可能缺失)`:`capture duration (may contain interruptions)`]}),e.epochs?.slice(1).map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u===`zh`?`中断后续录`:`Resumed after interruption`,` · `,new Date(e.previousEndedAt??e.startedAt).toLocaleString(),` → `,new Date(e.startedAt).toLocaleString()]},e.firstChunk)),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{disabled:q||R||J,onClick:()=>void Re(e).then(()=>l(!1)),children:d.recover}),(0,$.jsx)(X,{disabled:q||R||J||e.sealRequested,onClick:()=>void ze(e),children:u===`zh`?`继续录制`:`Continue recording`}),(0,$.jsx)(X,{disabled:q||R||J,onClick:()=>void Ve(e),children:u===`zh`?`导出原音包`:`Export originals`}),(0,$.jsx)(X,{disabled:q||R||J,onClick:()=>void Be(e),children:u===`zh`?`丢弃本机副本`:`Discard local copy`})]})]},e.id))]})]})});if(!x)return V||me||!f.recoverableDrafts[0]?null:(0,$.jsxs)(`aside`,{className:`fixed bottom-5 right-5 z-[125] w-[min(24rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-4 shadow-elevated`,children:[(0,$.jsxs)(`button`,{className:`text-sm font-medium text-fg`,onClick:()=>l(!0),children:[d.recoveredTitle,` (`,f.recoverableDrafts.length,`)`]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.recoveredDescription}),(0,$.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,$.jsx)(X,{variant:`ghost`,disabled:q||R||J,onClick:()=>void Be(),children:d.discard}),(0,$.jsx)(X,{variant:`primary`,disabled:q||R||J,onClick:()=>void Re(),children:q?d.recovering:d.recover})]})]});if(C!=null)return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[130] flex items-center justify-center bg-black/45 p-4`,role:`dialog`,"aria-modal":`true`,children:(0,$.jsxs)(`div`,{className:`w-[min(28rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-5 shadow-elevated`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:d.consentTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:d.consent})]}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover`,onClick:()=>S(!1),children:(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0})})]}),ce?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:ce}):null,(0,$.jsxs)(X,{variant:`primary`,className:`mt-5 w-full`,disabled:g,onClick:()=>void Pe(),children:[(0,$.jsx)(la,{className:`size-4`,"aria-hidden":!0}),d.consentAction]})]})});if(g&&![`recording`,`paused`,`waiting_for_audio`,`requesting_permission`].includes(f.phase))return(0,$.jsx)(lq,{compact:v,onCompactChange:y,language:u,title:u===`zh`?`准备录音`:`Preparing to record`,children:(0,$.jsxs)(`div`,{className:`space-y-3 p-4`,role:`status`,children:[(0,$.jsx)(Xo,{className:`h-7 w-24`}),(0,$.jsx)(Xo,{className:`h-3 w-3/4`})]})});let He=[`recording`,`paused`,`requesting_permission`,`waiting_for_audio`].includes(f.phase);if(!He&&(R||me||f.phase===`stopping`||f.phase===`error`)){let e=K(D,ve.localComplete?`complete`:fe?`unknown`:f.phase===`stopping`?`saving`:(f.draft??me)?.chunkCount?`partial`:`failed`,ve.sync),t=async e=>{if(!(o||R||q)){s(!0),le(null);try{e===`sync`||e===`recover`?await Re(f.draft??me??void 0):D&&O(e===`analyze`?await Bo(Lo(`/api/discussions/${encodeURIComponent(D.discussion.id)}/organize`),{method:`POST`,body:`{}`}):await L(D.discussion.id,e===`regenerate`?`from_audio`:`resume`))}catch(e){le(String(e))}finally{s(!1)}}};return(0,$.jsx)(lq,{compact:v,onCompactChange:y,language:u,title:u===`zh`?`录音已结束`:`Recording ended`,subtitle:Lq(D?.discussion.durationMs??me?.durationMs??f.elapsedMs),children:(0,$.jsx)(`div`,{className:`p-3`,children:(0,$.jsxs)(P,{input:e,zh:u===`zh`,compact:v,busy:o||R||q,onRetry:e=>void t(e),children:[i?(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:u===`zh`?`重点同步未完成,原音和笔记处理不受影响。`:`Highlights are not synced yet. Audio and note processing are unaffected.`}),(0,$.jsx)(X,{disabled:o||R||q,onClick:()=>void(async()=>{if(!(!D||!me||o)){s(!0);try{await U(me.id,D.discussion.id),a(!1),D.discussion.audioAttachmentId&&!D.discussion.audioDeletedAt&&(await f.discard(me.id),pe(!0))}catch(e){le(String(e))}finally{s(!1)}}})(),children:u===`zh`?`重试重点同步`:`Retry highlights`})]}):null,ce?(0,$.jsxs)(`details`,{className:`text-xs text-danger`,children:[(0,$.jsx)(`summary`,{children:u===`zh`?`操作未完成,查看详情`:`Action incomplete. View details`}),ce]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!fe&&f.draft&&f.draft.saveOutcome!==`complete`&&!f.draft.sealRequested&&!R?(0,$.jsx)(X,{disabled:q||o,onClick:()=>void ze(f.draft),children:u===`zh`?`继续录制`:`Continue recording`}):null,D?(0,$.jsx)(X,{onClick:Ie,children:d.openNote}):null,!fe&&f.draft?.chunkCount&&!R?(0,$.jsx)(X,{onClick:()=>void Ve(f.draft),children:u===`zh`?`导出已录内容`:`Export saved audio`}):null,ve.localComplete||e.audioAvailable||e.localSave===`failed`?(0,$.jsx)(X,{onClick:()=>S(!1),children:e.localSave===`failed`?d.close:u===`zh`?`稍后查看`:`View later`}):null]})]})})})}let Ue=D?.discussion.projectId&&D.discussion.projectInferenceSource!==`context`,We=u===`zh`,Ge=ve.capture===`recording`?We?`录音中`:`Recording`:d.status[ve.capture],Ke=D?.note.title&&!/^Discussion [·•]/.test(D.note.title)?D.note.title:We?`语音笔记`:`Voice note`,qe=e=>(0,$.jsxs)($.Fragment,{children:[f.phase===`recording`?(0,$.jsxs)(X,{className:e?`size-10 shrink-0 px-0 shadow-none`:`min-w-0 whitespace-nowrap shadow-none`,title:We?`标重点`:`Highlight`,"aria-label":We?`标重点`:`Highlight`,onClick:()=>void f.mark(),children:[(0,$.jsx)(j,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:We?`标重点`:`Highlight`]}):null,f.phase===`recording`||f.phase===`waiting_for_audio`?(0,$.jsxs)(X,{className:e?`size-10 shrink-0 px-0 shadow-none`:`min-w-0 whitespace-nowrap shadow-none`,"aria-label":d.pause,title:d.pause,onClick:f.pause,children:[(0,$.jsx)(Da,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:d.pause]}):null,f.phase===`paused`?(0,$.jsxs)(X,{className:e?`size-10 shrink-0 px-0 shadow-none`:`min-w-0 whitespace-nowrap shadow-none`,"aria-label":d.resume,title:d.resume,onClick:f.resume,children:[(0,$.jsx)(Ia,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:d.resume]}):null,[`recording`,`waiting_for_audio`,`paused`].includes(f.phase)?(0,$.jsxs)(X,{variant:`primary`,className:e?`size-10 shrink-0 px-0`:`min-w-0 whitespace-nowrap`,"aria-label":d.stop,title:d.stop,disabled:R,onClick:()=>void Fe(),children:[(0,$.jsx)(so,{className:`size-4 shrink-0`,"aria-hidden":!0}),e?null:d.stop]}):null]}),Je=ce??f.error??f.markerError??(ge&&ve.sync===`failed`?oe:null),Ye=ve.capture===`interrupted`?We?`录音已中断,请展开查看已保存内容。`:`Recording interrupted. Review the saved content.`:f.markerError?We?`重点未能保存,请稍后重试。`:`Highlight could not be saved. Try again.`:ve.sync===`failed`?We?`暂时无法同步,请稍后重试。`:`Sync is unavailable. Please try again later.`:We?`操作未完成,请查看详情。`:`Could not complete this action. View details.`;return(0,$.jsx)(lq,{compact:v,onCompactChange:y,language:u,title:v?(0,$.jsx)(`span`,{className:`font-mono`,children:Lq(f.elapsedMs)}):(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${ve.capture===`recording`?`bg-danger`:`bg-accent`}`,"aria-hidden":!0}),Ge]}),subtitle:v?Ge:Ke,compactActions:qe(!0),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pq,{status:ve,language:u,compact:!0}),ve.capture===`interrupted`||Je?(0,$.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-danger`,children:Ye}):null,f.markerMessage?(0,$.jsx)(`p`,{role:`status`,className:`px-3 pb-2 text-xs text-accent-fg`,children:We?`已标记重点`:`Highlight saved`}):null]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-3 px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`p`,{className:`font-mono text-[2.5rem] leading-none tabular-nums tracking-tight text-fg`,children:Lq(f.elapsedMs)}),ve.capture===`recording`?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[f.inputLevel==null?null:(0,$.jsx)(`div`,{role:`meter`,"aria-label":d.status.level,"aria-valuemin":0,"aria-valuemax":1,"aria-valuenow":f.inputLevel,className:`flex h-6 items-center gap-0.5`,children:[0,1,2,3,4].map(e=>(0,$.jsx)(`span`,{className:`w-1 rounded-full ${f.inputLevel>e*.12?`bg-accent`:`bg-surface-active`}`,style:{height:6+Math.min(1,f.inputLevel*3)*(e%2?10:18)}},e))}),(0,$.jsx)(`span`,{children:f.inputLevel==null?d.status.levelUnknown:We?`声音输入`:`Sound input`})]}):null]}),(0,$.jsx)(pq,{status:ve,language:u}),ve.sync===`offline`?(0,$.jsx)(`p`,{role:`status`,className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:We?`离线录音,联网后自动同步。`:`Recording offline. Sync resumes when connected.`}):null,ve.ai===`textDelayed`?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:d.status.textDelayed}):null,(0,$.jsxs)(`details`,{className:`group rounded-xl bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:We?`查看实时文字`:`Live transcript`}),(0,$.jsx)(`div`,{className:`mt-2 max-h-32 overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-fg`,children:k?.text||(f.liveTranscriptionAvailable?We?`说话后,文字会陆续显示。`:`Text will appear as you speak.`:d.liveUnavailable)})]}),Ue?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:d.projectLinked}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-8 shrink-0 items-center gap-1 text-accent-fg`,onClick:()=>void Le(),children:[(0,$.jsx)(Kt,{className:`size-3`,"aria-hidden":!0}),d.undo]})]}):null,R&&ne>0?(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":We?`备份录音`:`Recording backup`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(ne),className:`h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full bg-accent motion-safe:transition-[width]`,style:{width:`${ne}%`}})}):null,f.markerMessage?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-accent-fg`,children:We?`已标记重点,可稍后回听。`:`Highlight saved for review.`}):null,Je?(0,$.jsx)(`div`,{role:`alert`,children:(0,$.jsxs)(`details`,{className:`text-sm leading-5 text-danger`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ye}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:Je})]})}):null]}),(0,$.jsxs)(`footer`,{className:`space-y-2 border-t border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-flow-col auto-cols-fr gap-2`,children:qe(!1)}),(f.phase===`error`||f.phase===`stopped`)&&f.draft&&!R?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{disabled:q||R||J,onClick:()=>void Re(f.draft),children:d.recover}),(0,$.jsx)(X,{disabled:q||R||J||f.draft.sealRequested,onClick:()=>void ze(f.draft),children:We?`继续录制`:`Continue recording`}),(0,$.jsx)(X,{disabled:q||R||J,onClick:()=>void Ve(f.draft),children:We?`导出原音包`:`Export originals`})]}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:d.maxDuration}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1 whitespace-nowrap text-accent-fg`,onClick:Ie,children:[(0,$.jsx)(Hr,{className:`size-3.5`,"aria-hidden":!0}),d.openNote]}):null,!He&&(!R||ve.localComplete)?(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded px-2 hover:bg-surface-hover`,"aria-label":d.close,onClick:()=>S(!1),children:d.close}):null]})]})]})]})})}var zq=4e3;function Bq(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function Vq(e){let t=Bq(e);if(!t||!e||typeof e!=`object`)return null;let n=e.status;return n!==`success`&&n!==`error`&&n!==`cancelled`&&n!==`suspended`?null:{...t,status:n}}async function Hq(){let e=await Po(Lo(`/api/session-runs`));if(!e.ok)throw Error(`Active session runs failed (${e.status})`);let t=await e.json();if(!Array.isArray(t.payload?.runs))throw Error(`Active session runs response is invalid`);return t.payload.runs.map(Bq).filter(e=>!!e)}function Uq(e){window.dispatchEvent(new CustomEvent(`session-transcript-updated`,{detail:{key:e}}))}function Wq(){let e=!1,t,n,r=new Map,i=({conversationId:e,runId:t})=>`${e}\u0000${t}`,a=({conversationId:e,runId:t},n=!1)=>{r.has(i({conversationId:e,runId:t}))||(nc(e)!==t&&oc(e,t),ec.setResumeRunId(e,t),he(e),n&&window.dispatchEvent(new CustomEvent(`run-started`,{detail:{conversationId:e,runId:t}})))},o=({conversationId:e,runId:t})=>{let n=ec.reconcileInactive(e,t),r=tc(e,t);!n&&r&&$s.getState().clearStreamingState(e),(n||r)&&(ye(e),Uq(e))},s=({conversationId:e,runId:t,status:n})=>{r.set(i({conversationId:e,runId:t}),Date.now());let a=ec.reconcileTerminal(e,t,n),o=tc(e,t);if(!a&&o){$s.getState().clearStreamingState(e);let t=$s.getState().focusedConversationId===e;n===`error`?ie(e,!t):n===`suspended`?Ge(e):n===`success`?ae(e,!t):ye(e),Uq(e)}},c=()=>{e||t!==void 0||lc().length===0||(t=window.setTimeout(()=>{t=void 0,l()},zq))},l=()=>{if(n)return n;let t=lc();return n=Hq().then(n=>{if(e)return;let i=Date.now()-10*6e4;for(let[e,t]of r)t<i&&r.delete(e);let s=new Map(n.map(e=>[e.conversationId,e.runId])),c=new Map(t.map(e=>[e.conversationId,e.runId]));for(let e of n){let t=nc(e.conversationId),n=c.get(e.conversationId);t&&t!==n&&t!==e.runId||a(e,!0)}for(let e of t)s.get(e.conversationId)!==e.runId&&o(e)}).catch(()=>{}).finally(()=>{n=void 0,c()}),n},u=e=>{let t=Bq(e.detail);t&&(a(t),c())},d=e=>{let t=Vq(e.detail);t&&s(t)},f=e=>{let t=Bq(e.detail);t&&(r.set(i(t),Date.now()),o(t))},p=()=>void l();return window.addEventListener(`session-input-interrupt`,f),window.addEventListener(`run-started`,u),window.addEventListener(`run-completed`,d),window.addEventListener(`agent-run-ended`,d),window.addEventListener(`gateway-realtime-connected`,p),l(),()=>{e=!0,t!==void 0&&window.clearTimeout(t),window.removeEventListener(`session-input-interrupt`,f),window.removeEventListener(`run-started`,u),window.removeEventListener(`run-completed`,d),window.removeEventListener(`agent-run-ended`,d),window.removeEventListener(`gateway-realtime-connected`,p)}}var Gq=new Set([`automation-chat-agents`,`channel-routing-agents`,`gateway-chat-agents`,`picker-agents-list`,`settings-gateway-agents`,`setup-checklist-agents`]);function Kq(e){let t=Array.isArray(e)?e[0]:e;return typeof t==`string`&&Gq.has(t)}function qq(){let e=(0,Q.c)(3),t=Ro(Qq),n;e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),(0,Z.useEffect)(Zq,n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[2]=r):r=e[2],(0,Z.useEffect)(Jq,r)}function Jq(){let e=Xq,t=Yq;return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}}function Yq(){document.visibilityState===`visible`&&Yc()}function Xq(){return Yc()}function Zq(){return qc()}function Qq(e){return e.conversationId}function $q(e){let t=new Set;return(n,r)=>{let i=fc.safeParse(r);if(!i.success)return;let a=i.data;n!==`resources:${a.kind}s`||t.has(a.eventId)||(t.add(a.eventId),t.size>1024&&t.delete(t.values().next().value),e(a))}}function eJ(e,t){let n=Array.isArray(e)?e[0]:e;return typeof n==`string`&&(n===t||n.startsWith(`${t}-`)||n.startsWith(`${t}s`))}function tJ(){qq();let{mutate:e}=Ko(),t=Ro(e=>e.conversationId);return(0,Z.useEffect)(()=>gc(),[]),(0,Z.useEffect)(()=>Wq(),[]),(0,Z.useEffect)(()=>{let n=(t,n)=>{e(e=>eJ(e,t)),t===`project`&&window.dispatchEvent(new CustomEvent(`project-resource-changed`,{detail:{id:n}})),t===`task`&&window.dispatchEvent(new CustomEvent(`task-updated`,{detail:{id:n}}))},r=$q(e=>{e.kind!==`note`&&e.kind!==`task`&&e.kind!==`project`||(n(e.kind,e.id),e.kind===`note`&&window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.id}})))}),i=0,a=[],o=async()=>{let e=++i;a.forEach(e=>e()),a=[];try{let{capabilities:t}=await Bo(Lo(`/api/capabilities/operations`));if(e!==i)return;a=[`note`,`task`,`project`].filter(e=>t.some(t=>t.id===`xopc.${e}s.list`)).map(e=>{let t=Uc(`resources:${e}s`,{onEvent:e=>{e.event===`resource.changed`&&r(e.topic,e.data)},onGap:()=>n(e)},0);return n(e),t})}catch{}},s=()=>{o()};return t&&o(),window.addEventListener(`gateway-realtime-connected`,s),()=>{i++,a.forEach(e=>e()),window.removeEventListener(`gateway-realtime-connected`,s)}},[e,t]),(0,Z.useEffect)(()=>{let t=()=>{Pu(),e(Kq)},n=e=>{eK();let t=Nc(e.detail);t===`skills`?Iu():t===`agents`&&Pu()},r=t=>{let n=t.detail?.topic;(n===`gateway`||n===`sessions`)&&e(()=>!0)};return window.addEventListener(`agent-catalog`,t),window.addEventListener(`config-reload`,n),window.addEventListener(`realtime-gap`,r),()=>{window.removeEventListener(`agent-catalog`,t),window.removeEventListener(`config-reload`,n),window.removeEventListener(`realtime-gap`,r)}},[e]),null}async function nJ(e){let t=window.electronAPI?.system;if(!Ol()||!t?.showProductNotification)return!1;let n=await t.getBehavior().catch(()=>null);if(!n||!kt({notification:e,preferences:{enabled:n.notifyEnabled,completed:!0,failed:!0},permissionGranted:!0,appFocused:e.waitId?Et(e):At(e),alreadyDelivered:Dt(e.id)}).notify)return!1;let r=await t.showProductNotification({id:e.id,title:e.title,body:e.body,target:e.target,...e.waitId&&!Et(e)?{allowWhenFocused:!0}:{}}).catch(()=>null);return r?.ok&&r.outcome===`shown`?(jt(e.id),!0):!1}var rJ=`xopc.notifications.cursor.v1`,iJ=`xopc.notifications.consumer.v1`;function aJ(e){try{return window.localStorage.getItem(e)}catch{return null}}function oJ(e,t){try{window.localStorage.setItem(e,t)}catch{}}function sJ(){return aJ(rJ)}function cJ(e){oJ(rJ,e)}function lJ(){let e=aJ(iJ);if(e)return e;let t=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`;return oJ(iJ,t),t}async function uJ(){let e=[],t=sJ();for(let n=0;n<10;n+=1){let n=new URLSearchParams({since:String(Date.now()-5*6e4),limit:`100`});t&&n.set(`after`,t);let r=await Po(`/api/notifications?${n}`);if(!r.ok)break;let i=await r.json().catch(()=>null);if(!Array.isArray(i?.items))break;let a=i.items.flatMap(e=>{let t=sz.safeParse(e);return t.success?[t.data]:[]});if(e.push(...a),t=a.at(-1)?.id??t,i.items.length<100||a.length===0)break}return e}async function dJ(e){await Po(`/api/notifications/${encodeURIComponent(e)}/ack`,{method:`POST`,body:JSON.stringify({consumerId:lJ(),surface:Ol()?`electron`:`web`})}).catch(()=>null)}async function fJ(e){if(e.type!==`chat.needs_input`)return!0;if(e.target.kind!==`chat`||typeof e.payload.waitId!=`string`)return!1;let t=await Po(`/api/sessions/${encodeURIComponent(e.target.conversationId)}/clarification`);if(t.status===404)return!1;if(!t.ok)throw Error(`Could not refresh clarification notification`);let n=(await t.json()).payload;return n.transcriptId===e.payload.transcriptId&&n.clarification?.id===e.payload.waitId&&n.clarification.status===`open`&&(n.clarification.expiresAt===void 0||n.clarification.expiresAt>Date.now())}function pJ(e){let t=sz.safeParse(e);return t.success?t.data:null}function mJ(e,t){let n=cz(e,t),r=e.type===`chat.failed`||e.type===`task.blocked`||e.type===`task.failed`||e.type===`task.needs_input`||e.type===`automation.failed`||e.type===`work_discovery.failed`,i=e.target.kind===`automation_run`?`automation`:e.target.kind===`work_discovery`?`understanding`:e.target.kind;return{systemAllowed:e.payload.deliveryMode!==`auto`&&(!e.payload.deliveryChannel||[`all`,`browser`].includes(String(e.payload.deliveryChannel))),id:e.id,title:n.localizedTitle,body:n.localizedBody??n.localizedTitle,route:lz(e.target,`web`),target:e.target,...e.type===`chat.needs_input`&&typeof e.payload.waitId==`string`?{waitId:e.payload.waitId}:{},status:e.type===`chat.needs_input`||e.type===`task.needs_input`?`attention`:r?`error`:`success`,source:i}}function hJ(){let e=(0,Q.c)(3),t=zo(bJ),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=!0,n=null,r=new Set,i=new Map,a=Promise.resolve(),o=(n,o,s)=>{let c=o===void 0||o,l=s===void 0||s;return a=a.catch(yJ).then(async()=>{if(!e)return;let a=pJ(n);if(!a)return;if(r.has(a.id)){l&&cJ(a.id);return}let o=await fJ(a);if(!e)return;if(r.add(a.id),!o){l&&cJ(a.id);return}let s=mJ(a,t);s.waitId&&i.set(s.waitId,a.id),(s.waitId?Et(s):At(s))||Vc({tone:s.status===`attention`?`warning`:s.status===`success`?`success`:`error`,title:s.title,message:s.body,source:s.source,href:s.route,dedupeKey:s.id}),c&&(a.type!==`chat.needs_input`||a.createdAt>=Date.now()-3e5)&&(nJ(s),Mt(s)),l&&cJ(a.id),dJ(a.id)}),a},s=()=>n||(n=uJ().then(async t=>{if(e){let e=Date.now()-3e5;for(let n of t)await o(n,n.createdAt>=e)}}).catch(vJ).finally(()=>{n=null}),n),c=e=>{o(e.detail,!0,!1).catch(_J),s().then(()=>s())},l=()=>void s(),u=e=>{let t=e.detail;if(!t||t.status===`open`)return;let n=i.get(t.id);if(!n)return;let r=Bc.getState();for(let e of r.items)e.dedupeKey===n&&r.remove(e.id);i.delete(t.id)};window.addEventListener(`clarification-updated`,u),window.addEventListener(`notification-created`,c),window.addEventListener(`realtime-gap`,l),s();let d=gJ;return navigator.serviceWorker?.addEventListener(`message`,d),()=>{e=!1,window.removeEventListener(`clarification-updated`,u),window.removeEventListener(`notification-created`,c),window.removeEventListener(`realtime-gap`,l),navigator.serviceWorker?.removeEventListener(`message`,d)}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function gJ(e){let t=e.data;t?.type!==`xopc:notification-click`||typeof t.route!=`string`||t.route.startsWith(`/`)&&!t.route.startsWith(`//`)&&(window.location.hash=t.route)}function _J(){}function vJ(){}function yJ(){}function bJ(e){return e.language}async function xJ(e){let t=await Bo(Lo(`/api/support/report`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});return{report:t.report,investigationPrompt:t.investigationPrompt}}function SJ(e){let t=new Date(e.capturedAt).toISOString().replace(/[:.]/g,`-`),n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`xopc-diagnostics-${t}.json`,i.click(),URL.revokeObjectURL(r)}function CJ(e,t){let n=6e3,r=e.markdown.length<=n?e.markdown:`${e.markdown.slice(0,n)}\n\n---\n${t}`;return`https://github.com/xopcai/xopc/issues/new?${new URLSearchParams({title:e.title,body:r}).toString()}`}async function wJ(e){let t=window.electronAPI?.shell?.openExternalUrl;if(t)try{return(await t(e)).ok}catch{return!1}return window.open(e,`_blank`,`noopener,noreferrer`)!==null}function TJ(e){let t=new TextEncoder().encode(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return{type:`file`,mimeType:`text/markdown`,data:btoa(n),name:`xopc-diagnostics.md`,size:t.byteLength}}async function EJ(e,t,n={}){let r=n.fetch??Bo,i=n.create?await n.create():(await new uc().createSession({agentId:`main`})).key;return await(n.send??_c)(i,t,[TJ(e.markdown)]),await r(Lo(`/api/sessions/${encodeURIComponent(i)}`),{method:`PATCH`,body:JSON.stringify({name:e.title,tags:[`support`],replaceTags:!0,customData:{kind:`support-investigation`,supportReportCapturedAt:e.capturedAt}})}).catch(()=>void 0),i}function DJ({open:e,onOpenChange:t,seed:n}){let r=Do(zo(e=>e.language)).supportReport,i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{e&&(o(n?.problem??``),c(n?.reproduction??``),u(n?.expected??``),f(null),m(``),g(!1),v(!1),b(null),S(null))},[e,n]);async function C(){let e=a.trim();if(!e){b(r.problemRequired);return}g(!0),b(null),S(null);try{let t=await xJ({...n,problem:e,reproduction:s.trim()||void 0,expected:l.trim()||void 0,occurredAt:n?.occurredAt??new Date().toISOString(),clientContext:{currentPage:window.location.href,surface:window.electronAPI?`electron`:`web`,userAgent:navigator.userAgent,...n?.clientContext}});f(t.report),m(t.investigationPrompt)}catch(e){b(e instanceof Error?e.message:r.collectFailed)}finally{g(!1)}}async function w(){if(!d)return!1;let e=await xc(d.markdown);return S(e?r.copied:r.copyFailed),e||(i.current?.focus(),i.current?.select()),e}async function T(){d&&(d.markdown.length>6e3&&await w(),await wJ(CJ(d,r.githubTruncated))||b(r.openFailed))}async function E(){if(!(!d||!p)){v(!0),b(null);try{let e=await EJ(d,p);t(!1),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e}}))}catch(e){b(e instanceof Error?e.message:r.sessionFailed)}finally{v(!1)}}}return(0,$.jsx)(us,{open:e,onOpenChange:t,children:(0,$.jsxs)(ss,{children:[(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[220] bg-scrim`}),(0,$.jsxs)(cs,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[221] flex h-[min(42rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover dark:border-edge`),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ls,{className:`text-base font-semibold text-fg`,children:r.title}),(0,$.jsx)(as,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,$.jsx)(os,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.close,children:(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:[h?(0,$.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.collecting,children:[(0,$.jsx)(Xo,{className:`h-20 w-full`}),(0,$.jsx)(Xo,{className:`h-24 w-full`}),(0,$.jsx)(Xo,{className:`h-32 w-full`})]}):d?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-accent-soft px-3 py-2.5 text-sm text-accent-fg`,children:[(0,$.jsx)(eo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium`,children:r.ready}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5`,children:r.readyDetail.replace(`{{checks}}`,String(d.doctor.length)).replace(`{{logs}}`,String(d.logs.length)).replace(`{{redactions}}`,String(d.redaction.replacements))})]})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-report-preview`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.preview}),(0,$.jsx)(`textarea`,{ref:i,id:`support-report-preview`,value:d.markdown,readOnly:!0,className:`h-96 w-full resize-none rounded-xl border border-edge bg-surface-base p-3 font-mono text-xs leading-5 text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(io,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),r.investigationHint]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-problem`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.problem}),(0,$.jsx)(`textarea`,{id:`support-problem`,value:a,onChange:e=>o(e.target.value),placeholder:r.problemPlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`,autoFocus:!0})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-reproduction`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.reproduction}),(0,$.jsx)(`textarea`,{id:`support-reproduction`,value:s,onChange:e=>c(e.target.value),placeholder:r.reproductionPlaceholder,className:`min-h-20 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-expected`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.expected}),(0,$.jsx)(`textarea`,{id:`support-expected`,value:l,onChange:e=>u(e.target.value),placeholder:r.expectedPlaceholder,className:`min-h-20 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`})]}),(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(eo,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),r.privacy]})]}),y?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-warning`,role:`alert`,children:y}):null,x?(0,$.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-accent-fg`,role:`status`,children:[(0,$.jsx)(hn,{className:`size-4`,"aria-hidden":!0}),x]}):null]}),(0,$.jsx)(`footer`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge px-5 py-3`,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:`ghost`,disabled:_,onClick:()=>{f(null),m(``)},children:r.back}),(0,$.jsxs)(X,{onClick:()=>void w(),children:[(0,$.jsx)(cv,{className:`size-4`,"aria-hidden":!0}),r.copy]}),(0,$.jsxs)(X,{onClick:()=>SJ(d),children:[(0,$.jsx)(_r,{className:`size-4`,"aria-hidden":!0}),r.download]}),(0,$.jsxs)(X,{onClick:()=>void T(),children:[(0,$.jsx)(br,{className:`size-4`,"aria-hidden":!0}),r.submit]}),(0,$.jsxs)(X,{variant:`primary`,disabled:_,onClick:()=>void E(),children:[_?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(io,{className:`size-4`,"aria-hidden":!0}),_?r.startingInvestigation:r.startInvestigation]})]}):(0,$.jsxs)(X,{variant:`primary`,disabled:h,onClick:()=>void C(),children:[h?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,h?r.collecting:r.collect]})})]})]})})}function OJ(e){if(!e.startsWith(`/chat/`)||e.startsWith(`/chat/task/`))return;let t=e.slice(6);if(!(!t||t===`new`))try{return decodeURIComponent(t)}catch{return}}function kJ(){let e=(0,Q.c)(6),{pathname:t}=p(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(),o,s;e[0]===t?(o=e[1],s=e[2]):(o=()=>{let e=e=>{let n=e.detail??{};a({conversationId:OJ(t),...n}),r(!0)};return window.addEventListener(YB,e),()=>window.removeEventListener(YB,e)},s=[t],e[0]=t,e[1]=o,e[2]=s),(0,Z.useEffect)(o,s);let c;return e[3]!==n||e[4]!==i?(c=(0,$.jsx)(DJ,{open:n,onOpenChange:r,seed:i}),e[3]=n,e[4]=i,e[5]=c):c=e[5],c}function AJ(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var jJ=`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent motion-safe:transition-colors`;function MJ(){let e=(0,Q.c)(29),t=zo(PJ)===`zh`,n=wt(),r=rt(),[i,a]=(0,Z.useState)(!1),o=(0,Z.useId)(),s=n.source&&n.status!==`idle`,c=n.status===`preparing`,l=n.status===`playing`,u=n.status===`error`,d=n.status===`ended`,f=c?t?`正在准备语音`:`Preparing audio`:u?t?`朗读失败,请重试`:`Unable to play. Try again`:d?t?`播放完毕`:`Finished`:l?t?`正在朗读`:`Reading aloud`:t?`已暂停`:`Paused`,p;e[0]===n.source?p=e[1]:(p=e=>{let t=n.source?.targetId?document.getElementById(n.source.targetId):null;t&&(e.preventDefault(),t.scrollIntoView({behavior:`smooth`,block:`center`}))},e[0]=n.source,e[1]=p);let m=p,h;e[2]!==o||e[3]!==r||e[4]!==d||e[5]!==i||e[6]!==u||e[7]!==l||e[8]!==c||e[9]!==m||e[10]!==n||e[11]!==f||e[12]!==s||e[13]!==t?(h=s?(0,$.jsx)(`section`,{"aria-label":t?`语音播报`:`Read aloud`,className:Y(`shrink-0`,r?`pb-2`:`px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-2`),children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-16 items-center gap-1 p-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),"aria-expanded":i,"aria-controls":o,className:`flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-lg px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.source?.title}),(0,$.jsxs)(`span`,{className:`block text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{role:`status`,children:f}),!u&&!c?(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,AJ(n.currentTime)]}):null]})]}),(0,$.jsx)(gn,{"aria-hidden":!0,className:Y(`size-4 shrink-0 text-fg-muted`,i&&`rotate-180`)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:l?n.pause:n.resume,disabled:c,className:Y(jJ,`disabled:opacity-50`),"aria-label":d?t?`重新播放`:`Replay`:u?t?`重试朗读`:`Retry reading`:l?t?`暂停朗读`:`Pause reading`:t?`继续朗读`:`Resume reading`,children:c?(0,$.jsx)(Xo,{className:`size-5 rounded-full`}):u?(0,$.jsx)(Ga,{className:`size-5`,"aria-hidden":!0}):l?(0,$.jsx)(Da,{className:`size-5`,"aria-hidden":!0}):(0,$.jsx)(Ia,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:n.stop,className:jJ,"aria-label":t?`停止朗读`:`Stop reading`,children:(0,$.jsx)(wo,{className:`size-5`,"aria-hidden":!0})})]}),n.durationComplete&&!i?(0,$.jsx)(`div`,{className:`h-0.5 bg-surface-active`,"aria-hidden":!0,children:(0,$.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${Math.min(100,n.currentTime/n.duration*100)}%`}})}):null,i?(0,$.jsxs)(`div`,{id:o,className:`space-y-3 border-t border-edge-subtle p-4`,children:[n.durationComplete?(0,$.jsx)(FJ,{duration:n.duration,currentTime:n.currentTime,disabled:c,onSeek:n.seek,label:t?`播放进度`:`Playback position`},`${n.source?.type}:${n.source?.id}`):null,n.currentText?(0,$.jsx)(`p`,{className:`max-h-28 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.currentText}):null,n.source?.href?(0,$.jsx)(`a`,{href:n.source.href,onClick:m,className:`inline-flex min-h-11 items-center rounded-lg text-sm text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t?`返回来源`:`Return to source`}):null,u?(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:n.error}):null,(0,$.jsx)(On,{contentClassName:`[&_button]:min-h-11`,value:String(n.rate),allowEmpty:!1,placeholder:`1×`,ariaLabel:t?`播放速度`:`Playback speed`,options:[.75,1,1.25,1.5,2].map(NJ),triggerClassName:`min-h-11 w-28`,onChange:e=>n.setRate(Number(e))})]}):null]})}):null,e[2]=o,e[3]=r,e[4]=d,e[5]=i,e[6]=u,e[7]=l,e[8]=c,e[9]=m,e[10]=n,e[11]=f,e[12]=s,e[13]=t,e[14]=h):h=e[14];let g=h,_;e[15]!==r||e[16]!==g?(_=r?(0,fd.createPortal)(g,r):g,e[15]=r,e[16]=g,e[17]=_):_=e[17];let v=t?`使用在线朗读`:`Use online read aloud`,y=t?`朗读默认使用 Microsoft Edge 在线语音服务,待朗读文本会发送至 Microsoft 进行语音合成。`:`Read aloud uses Microsoft Edge online speech by default. The text will be sent to Microsoft for speech synthesis.`,b=t?`同意并朗读`:`Agree and read`,x=t?`取消`:`Cancel`,S;e[18]!==n.acceptConsent||e[19]!==n.consentRequired||e[20]!==n.declineConsent||e[21]!==v||e[22]!==y||e[23]!==b||e[24]!==x?(S=(0,$.jsx)(pu,{open:n.consentRequired,title:v,description:y,confirmLabel:b,cancelLabel:x,onConfirm:n.acceptConsent,onCancel:n.declineConsent}),e[18]=n.acceptConsent,e[19]=n.consentRequired,e[20]=n.declineConsent,e[21]=v,e[22]=y,e[23]=b,e[24]=x,e[25]=S):S=e[25];let C;return e[26]!==_||e[27]!==S?(C=(0,$.jsxs)($.Fragment,{children:[_,S]}),e[26]=_,e[27]=S,e[28]=C):C=e[28],C}function NJ(e){return{value:String(e),label:`${e}×`}}function PJ(e){return e.language}function FJ(e){let t=(0,Q.c)(25),{duration:n,currentTime:r,disabled:i,onSeek:a,label:o}=e,[s,c]=(0,Z.useState)(null),l;t[0]!==a||t[1]!==s?(l=()=>{s!==null&&(a(s),c(null))},t[0]=a,t[1]=s,t[2]=l):l=t[2];let u=l,d;t[3]===o?d=t[4]:(d=(0,$.jsx)(`span`,{children:o}),t[3]=o,t[4]=d);let f=s??r,p;t[5]===f?p=t[6]:(p=AJ(f),t[5]=f,t[6]=p);let m;t[7]===n?m=t[8]:(m=AJ(n),t[7]=n,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[p,` / `,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==h?(g=(0,$.jsxs)(`span`,{className:`flex justify-between gap-3`,children:[d,h]}),t[12]=d,t[13]=h,t[14]=g):g=t[14];let _=s??Math.min(r,n),v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>c(Number(e.target.value)),t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>c(null),t[16]=y):y=t[16];let b;t[17]!==u||t[18]!==i||t[19]!==n||t[20]!==_?(b=(0,$.jsx)(`input`,{type:`range`,min:0,max:n,step:.1,value:_,disabled:i,onChange:v,onPointerUp:u,onKeyUp:u,onBlur:u,onPointerCancel:y,className:`block h-11 w-full accent-accent`}),t[17]=u,t[18]=i,t[19]=n,t[20]=_,t[21]=b):b=t[21];let x;return t[22]!==b||t[23]!==g?(x=(0,$.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[g,b]}),t[22]=b,t[23]=g,t[24]=x):x=t[24],x}function IJ(){let e=(0,Q.c)(11),t=b(),n=Ro(RJ),r=Vu(LJ),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(!1),o,s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=e=>{i.current=!!e.detail?.active};return window.addEventListener(Ku,e),()=>window.removeEventListener(Ku,e)},s=[],e[0]=o,e[1]=s):(o=e[0],s=e[1]),(0,Z.useEffect)(o,s);let c,l;e[2]!==t||e[3]!==n?(c=()=>{let e=window.electronAPI?.voiceInputHotkey;if(typeof e?.onEvent!=`function`)return;let r=e.onEvent(e=>{if(e===`press`){if(i.current||!n)return;a.current=!0}else{if(!a.current)return;a.current=!1}Lu(`xopc-voice-input-toggle`,document.querySelector(`[data-voice-input-scope="note"]`)?`note`:`chat`)||(e===`press`?(Uu(),t(`/chat`)):Bu())});return()=>{a.current=!1,r()}},l=[t,n],e[2]=t,e[3]=n,e[4]=c,e[5]=l):(c=e[4],l=e[5]),(0,Z.useEffect)(c,l);let u,d;return e[6]!==t||e[7]!==r||e[8]!==n?(u=()=>{let e=e=>{if(i.current||e.repeat||e.isComposing)return;let a=document.querySelector(`[data-voice-input-scope="note"]`)?`note`:`chat`;if(e.key===`Escape`){Lu(`xopc-voice-input-cancel`,a)&&(e.preventDefault(),e.stopPropagation());return}Ru(e,r)&&(e.preventDefault(),e.stopPropagation(),n&&(Lu(`xopc-voice-input-toggle`,a)||(Uu(),t(`/chat`))))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},d=[t,r,n],e[6]=t,e[7]=r,e[8]=n,e[9]=u,e[10]=d):(u=e[9],d=e[10]),(0,Z.useEffect)(u,d),null}function LJ(e){return e.shortcut}function RJ(e){return e.conversationId}var zJ=[{value:`en`,label:`EN`},{value:`zh`,label:`中文`}];function BJ(e){let t=(0,Q.c)(5),{value:n,onChange:r}=e,i;t[0]!==r||t[1]!==n?(i=zJ.map(e=>{let t=e.value===n;return(0,$.jsx)(`button`,{type:`button`,"aria-pressed":t,className:Y(td,`h-9 min-w-11 px-2`,t?Y(rd,`text-fg`):`text-fg-subtle hover:text-fg`),onClick:()=>r(e.value),children:e.label},e.value)}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(su,{className:nd,role:`group`,"aria-label":`Language / 语言`,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:i}),t[3]=i,t[4]=a),a}var VJ=new Set([`anthropic`,`deepseek`,`google`,`kimi-coding`,`minimax`,`openai`,`xopc-cloud`]);function HJ(e){return VJ.has(e)}function UJ(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Y(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,className:a,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function WJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#5786FE`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(UJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function GJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#E73562`,d:`M11.43 3.92a.86.86 0 1 0-1.718 0v14.236a1.999 1.999 0 0 1-3.997 0V9.022a.86.86 0 1 0-1.718 0v3.87a1.999 1.999 0 0 1-3.997 0V11.49a.57.57 0 0 1 1.139 0v1.404a.86.86 0 0 0 1.719 0V9.022a1.999 1.999 0 0 1 3.997 0v9.134a.86.86 0 0 0 1.719 0V3.92a1.998 1.998 0 1 1 3.996 0v11.788a.57.57 0 1 1-1.139 0zm10.572 3.105a2 2 0 0 0-1.999 1.997v7.63a.86.86 0 0 1-1.718 0V3.923a1.999 1.999 0 0 0-3.997 0v16.16a.86.86 0 0 1-1.719 0V18.08a.57.57 0 1 0-1.138 0v2a1.998 1.998 0 0 0 3.996 0V3.92a.86.86 0 0 1 1.719 0v12.73a1.999 1.999 0 0 0 3.996 0V9.023a.86.86 0 1 1 1.72 0v6.686a.57.57 0 0 0 1.138 0V9.022a2 2 0 0 0-1.998-1.997`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(UJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function KJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(UJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function qJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M22.28 9.82a5.98 5.98 0 0 0-.516-4.91 6.04 6.04 0 0 0-6.51-2.9A6.06 6.06 0 0 0 4.98 4.18a5.98 5.98 0 0 0-3.99 2.9 6.04 6.04 0 0 0 .743 7.09 5.98 5.98 0 0 0 .511 4.91 6.05 6.05 0 0 0 6.51 2.9A5.98 5.98 0 0 0 13.26 24a6.05 6.05 0 0 0 5.77-4.20 5.98 5.98 0 0 0 3.99-2.9 6.05 6.05 0 0 0-.748-7.07zm-9.02 12.60a4.47 4.47 0 0 1-2.87-1.04l.142-.08 4.77-2.75a.795.79 0 0 0 .393-.681v-6.73l2.02 1.16a.071.07 0 0 1 .038.05v5.58a4.50 4.50 0 0 1-4.49 4.49zm-9.66-4.12a4.47 4.47 0 0 1-.535-3.01l.142.08 4.78 2.75a.771.77 0 0 0 .781 0l5.84-3.36v2.33a.08.08 0 0 1-.033.06L9.74 19.95a4.49 4.49 0 0 1-6.14-1.64zM2.34 7.89a4.48 4.48 0 0 1 2.36-1.97V11.6a.766.76 0 0 0 .388.67l5.81 3.35-2.02 1.16a.076.07 0 0 1-.071 0l-4.83-2.78A4.50 4.50 0 0 1 2.34 7.87zm16.59 3.85L13.10 8.36 15.11 7.2a.076.07 0 0 1 .071 0l4.83 2.79a4.49 4.49 0 0 1-.677 8.10v-5.67a.79.79 0 0 0-.407-.667zm2.01-3.02-.142-.085-4.77-2.78a.776.77 0 0 0-.785 0L9.40 9.23V6.89a.066.06 0 0 1 .028-.062l4.83-2.78a4.49 4.49 0 0 1 6.68 4.66zM8.30 12.86l-2.02-1.16a.08.08 0 0 1-.038-.057V6.07a4.49 4.49 0 0 1 7.37-3.45l-.142.08L8.70 5.45a.795.79 0 0 0-.393.68zm1.09-2.36 2.60-1.5 2.60 1.5v2.99l-2.59 1.5-2.60-1.5Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(UJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function JJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#D4A27F`,d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(UJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function YJ(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,$.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,$.jsx)(`path`,{fill:`url(#gemini-grad)`,d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`}),t[3]=i,t[4]=a):(i=t[3],a=t[4]);let o;return t[5]!==n||t[6]!==r?(o=(0,$.jsxs)(UJ,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function XJ(e){let t=(0,Q.c)(22),{providerId:n,className:r}=e,i;t[0]===r?i=t[1]:(i={className:r,"aria-hidden":!0},t[0]=r,t[1]=i);let a=i;switch(n){case`xopc-cloud`:{let e;return t[2]===r?e=t[3]:(e=(0,$.jsx)(ll,{className:r,"aria-hidden":!0}),t[2]=r,t[3]=e),e}case`deepseek`:{let e;return t[4]===a?e=t[5]:(e=(0,$.jsx)(WJ,{...a}),t[4]=a,t[5]=e),e}case`minimax`:{let e;return t[6]===a?e=t[7]:(e=(0,$.jsx)(GJ,{...a}),t[6]=a,t[7]=e),e}case`kimi-coding`:{let e;return t[8]===a?e=t[9]:(e=(0,$.jsx)(KJ,{...a}),t[8]=a,t[9]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[10]===a?e=t[11]:(e=(0,$.jsx)(KJ,{...a}),t[10]=a,t[11]=e),e}case`openai`:{let e;return t[12]===a?e=t[13]:(e=(0,$.jsx)(qJ,{...a}),t[12]=a,t[13]=e),e}case`anthropic`:{let e;return t[14]===a?e=t[15]:(e=(0,$.jsx)(JJ,{...a}),t[14]=a,t[15]=e),e}case`google`:{let e;return t[16]===a?e=t[17]:(e=(0,$.jsx)(YJ,{...a}),t[16]=a,t[17]=e),e}default:{let e;t[18]===r?e=t[19]:(e=Y(`flex items-center justify-center text-2xl`,r),t[18]=r,t[19]=e);let n;return t[20]===e?n=t[21]:(n=(0,$.jsx)(`span`,{className:e,children:`🤖`}),t[20]=e,t[21]=n),n}}}var ZJ={id:`xopc-cloud`,name:`XOPC Cloud`,category:`common`,supportsOAuth:!0,supportsApiKey:!1,configured:!1,onboardingFeatured:!0,hint:`Connect your XOPC account. No API key required.`},QJ=[{id:`deepseek`,name:`DeepSeek`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`openai`,name:`OpenAI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`anthropic`,name:`Anthropic`,category:`common`,supportsOAuth:!0,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`google`,name:`Google AI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0}],$J=new Map([ZJ,...QJ].map((e,t)=>[e.id,t]));function eY(e,t){let n=e?.filter(e=>e.onboardingFeatured&&HJ(e.id)),r=n?.length?n:QJ;return(t?[e?.find(e=>e.id===`xopc-cloud`)??ZJ,...r.filter(e=>e.id!==`google`&&e.id!==`xopc-cloud`)]:r).slice().sort((e,t)=>($J.get(e.id)??999)-($J.get(t.id)??999))[0]}function tY(e){let t=e.recommendedModels?.map(e=>e.name||e.id).filter(Boolean).slice(0,2);return t?.length?t.join(`, `):e.hint}function nY(e){let t=(0,Q.c)(24),{onSelect:n,onBrowseProviders:r,disabled:i,browseDisabled:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=zo(rY),l;t[0]===c?l=t[1]:(l=Do(c),t[0]=c,t[1]=l);let u=l.onboarding.providerRecommended,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},t[2]=d):d=t[2];let{data:f}=qo(`onboarding-provider-meta`,id,d),p;if(t[3]!==f||t[4]!==o||t[5]!==n||t[6]!==u){let e=eY(f,Ol());p=e?(0,$.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>n(e.id),className:`group flex w-full items-center gap-3.5 rounded-xl border border-accent/30 bg-accent-soft/45 p-3.5 text-left transition-[border-color,background-color] duration-200 hover:border-accent/55 hover:bg-accent-soft/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,children:[(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-edge-subtle bg-surface-base/70`,children:(0,$.jsx)(XJ,{providerId:e.id,className:`size-7`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-on-accent`,children:u})]}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:tY(e)})]}),(0,$.jsx)(vn,{className:`size-4.5 shrink-0 text-accent-fg/80`,"aria-hidden":!0})]}):null,t[3]=f,t[4]=o,t[5]=n,t[6]=u,t[7]=p}else p=t[7];let m=o||s,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-edge-subtle bg-surface-panel text-fg-muted`,children:(0,$.jsx)(Fi,{className:`size-5`,"aria-hidden":!0})}),t[8]=h):h=t[8];let g=c===`zh`?`连接我自己的模型服务`:`Connect my own model service`,_;t[9]===g?_=t[10]:(_=(0,$.jsx)(`span`,{className:`block text-base font-semibold text-fg`,children:g}),t[9]=g,t[10]=_);let v=s&&!o?c===`zh`?`正在加载可用的模型服务…`:`Loading available model services…`:c===`zh`?`使用自己的账号、API Key、本地模型或私有接口。`:`Use your own account, API key, local model, or private endpoint.`,y;t[11]===v?y=t[12]:(y=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:v}),t[11]=v,t[12]=y);let b;t[13]!==y||t[14]!==_?(b=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[_,y]}),t[13]=y,t[14]=_,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(vn,{className:`size-4.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[16]=x):x=t[16];let S;t[17]!==r||t[18]!==b||t[19]!==m?(S=(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:r,className:`mt-3 flex min-h-16 w-full items-center gap-3.5 rounded-xl border border-edge bg-surface-base/65 p-3.5 text-left transition-[border-color,background-color] duration-200 hover:border-edge-strong hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,children:[h,b,x]}),t[17]=r,t[18]=b,t[19]=m,t[20]=S):S=t[20];let C;return t[21]!==S||t[22]!==p?(C=(0,$.jsxs)(`div`,{children:[p,S]}),t[21]=S,t[22]=p,t[23]=C):C=t[23],C}function rY(e){return e.language}var iY={step:`callName`,selectedProvider:null,busy:!1,error:null,callName:``};function aY(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`prefillCallName`:return e.callName.trim()?e:{...e,callName:t.value}}}var oY=[`callName`,`provider`,`success`],sY=e=>oY.indexOf(e)+1;function cY(e){let t=(0,Q.c)(5),{step:n,label:r}=e,i=sY(n)-1,a;t[0]===i?a=t[1]:(a=oY.map((e,t)=>(0,$.jsx)(`span`,{className:Y(`h-1.5 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none`,t===i?`w-5 bg-accent`:`w-1.5`,t<i?`bg-accent/45`:t>i?`bg-edge-strong`:void 0),"aria-hidden":!0},e)),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-label":r,children:a}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function lY({onComplete:e,onDismiss:t,canDismiss:n=!0,onPendingChange:r}){let i=zo(e=>e.language),a=zo(e=>e.setLanguage),o=Do(i).onboarding,[s,c]=(0,Z.useReducer)(aY,iY),[l,u]=(0,Z.useState)(!1),d=Rn(),f=Ol(),p=(0,Z.useRef)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v=m||d.cards.some(e=>e.id===`xopc-cloud`&&e.configured),{step:y,selectedProvider:b,busy:x,error:S,callName:C}=s;(0,Z.useEffect)(()=>(r?.(x),()=>r?.(!1)),[x,r]);let w=(0,Z.useMemo)(()=>o.stepOf.replace(`{{current}}`,String(sY(y))).replace(`{{total}}`,String(oY.length)),[o.stepOf,y]);(0,Z.useEffect)(()=>{let e=!1,t;return(async()=>{for(let n=0;n<3;n+=1)try{let{profile:t,suggestedCallName:n}=await sn();if(e)return;let r=t.callName.trim()||n?.trim();r&&c({type:`prefillCallName`,value:r});return}catch{n<2&&await new Promise(e=>{t=setTimeout(e,250*(n+1))})}})(),()=>{e=!0,t!==void 0&&clearTimeout(t)}},[]);let T=async()=>{let e=C.trim();c({type:`patch`,patch:{busy:!0,error:null}});try{await nn({...e?{callName:e}:{},timezone:an(),locale:i===`zh`?`zh-CN`:`en-US`}),c({type:`patch`,patch:{step:`provider`}})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{busy:!1}})}},E=async()=>{if(!p.current){p.current=!0,c({type:`patch`,patch:{busy:!0,error:null}});try{let e={mode:`replace`},t=await Vn(`xopc-cloud`,e);if(!t.configured||!t.uses.find(e=>e.id===`chat`)?.recommended)throw Error(i===`zh`?`XOPC Cloud 尚未就绪,请稍后重试。`:`XOPC Cloud is not ready yet. Please retry.`);let n=t.uses.filter(e=>e.selected&&e.recommended).map(e=>e.id);await Ln(`xopc-cloud`,{...e,selected:n},t.revision),_(t),c({type:`patch`,patch:{step:`success`}})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{p.current=!1,c({type:`patch`,patch:{busy:!1}})}}},D=async()=>{c({type:`patch`,patch:{busy:!0,error:null}});try{await e()}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{busy:!1}})}};return(0,$.jsxs)(`div`,{className:`xopc-onboarding-experience relative flex h-full min-h-0 w-full flex-col overflow-hidden`,"data-step":y,children:[(0,$.jsx)(`header`,{className:`relative z-20 flex h-18 shrink-0 items-center justify-end px-5 sm:px-8 lg:px-10`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(BJ,{value:i,onChange:e=>{c({type:`patch`,patch:{error:null}}),a(e)}}),n?(0,$.jsx)(`button`,{type:`button`,"aria-label":o.skipSetup,disabled:x,className:`inline-flex size-10 items-center justify-center rounded-xl text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:t,children:(0,$.jsx)(wo,{className:`size-4`,"aria-hidden":!0})}):null]})}),(0,$.jsxs)(`main`,{className:`xopc-onboarding-scroll relative z-10 grid min-h-0 flex-1 overflow-y-auto lg:grid-cols-[minmax(18rem,0.8fr)_minmax(30rem,1.2fr)]`,children:[(0,$.jsx)(`section`,{className:`xopc-onboarding-visual relative hidden min-h-0 items-center justify-center overflow-hidden lg:flex`,children:(0,$.jsx)(au,{className:`size-72 text-fg-muted`,interactive:!0,language:i,mood:S?`care`:x?`work`:y===`success`?`done`:y===`callName`?`listen`:`decision`})}),(0,$.jsx)(`section`,{className:`app-main-surface xopc-onboarding-scroll flex min-h-[30rem] items-center overflow-y-auto bg-surface-panel px-5 py-8 sm:px-10 lg:min-h-0 lg:px-[clamp(3rem,6vw,6rem)]`,children:(0,$.jsxs)(`div`,{className:`xopc-onboarding-stage w-full max-w-[30rem]`,children:[(0,$.jsx)(`div`,{className:`mb-3 lg:hidden`,children:(0,$.jsx)(au,{className:`size-20`,mood:S?`care`:x?`work`:y===`success`?`done`:`listen`})}),y===`callName`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:o.title}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:o.step0Title}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:o.step0Subtitle}),(0,$.jsxs)(`label`,{className:`mt-9 block`,children:[(0,$.jsxs)(`span`,{className:`mb-2 flex items-center justify-between text-[13px] font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:o.profileCallNameLabel}),(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i===`zh`?`可选`:`Optional`})]}),(0,$.jsx)(`input`,{autoFocus:!0,autoComplete:`name`,value:C,onChange:e=>c({type:`patch`,patch:{callName:e.target.value}}),onKeyDown:e=>{e.key===`Enter`&&!x&&T()},placeholder:o.profileCallNamePlaceholder,className:`h-12 w-full rounded-xl border border-edge bg-surface-base/80 px-3.5 text-[15px] text-fg outline-none transition-[border-color,box-shadow,background-color] duration-200 placeholder:text-fg-subtle hover:border-edge-strong focus:border-accent focus:bg-surface-base focus:ring-4 focus:ring-accent/10 motion-reduce:transition-none`})]}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:S?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:S}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(cY,{step:y,label:w}),(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:x,onClick:()=>void T(),children:[x?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,x?o.savingProfile:o.continue,x?null:(0,$.jsx)(vn,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,y===`provider`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:f?`XOPC Cloud`:i===`zh`?`模型设置`:`Model setup`}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:f?i===`zh`?`连接 XOPC Cloud`:`Connect XOPC Cloud`:o.step1Title}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:f?i===`zh`?`登录后自动配置聊天、图片、语音和任务模型,开启可用能力。电脑操作默认关闭,无需 API Key。`:`Sign in to set up chat, image, voice, and task models and enable available capabilities. Computer control stays off by default. No API key required.`:o.step1Subtitle}),(0,$.jsx)(`div`,{className:`mt-8`,children:f?(0,$.jsx)(`fieldset`,{disabled:x,className:`min-w-0`,children:(0,$.jsx)(sd,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:v,onConnected:()=>{h(!0),E()}})}):(0,$.jsx)(nY,{onSelect:e=>{c({type:`patch`,patch:{selectedProvider:e,error:null}}),u(!0)},onBrowseProviders:()=>{c({type:`patch`,patch:{selectedProvider:null}}),u(!0)},disabled:x,browseDisabled:d.loading})}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:S?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:S}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-8`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`justify-self-start`,disabled:x,onClick:()=>c({type:`patch`,patch:{step:`callName`,error:null}}),children:o.back}),(0,$.jsx)(cY,{step:y,label:w}),f&&v?(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:x,onClick:()=>void E(),children:[x?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,S?i===`zh`?`重试`:`Retry`:o.continue]}):(0,$.jsx)(`span`,{})]})]}):null,y===`success`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,$.jsx)(Mn,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`mt-6 text-xs font-medium tracking-wide text-accent-fg`,children:i===`zh`?`模型设置完成`:`Model setup complete`}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:i===`zh`?`一切准备好了`:`You’re ready to go`}),(0,$.jsxs)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:[g?i===`zh`?`已配置并开启账号可用的模型能力,电脑操作默认关闭。`:`Available model capabilities are configured and enabled. Computer control stays off by default.`:i===`zh`?`模型服务配置已保存,可以开始对话。`:`Model service settings are saved. You can start a conversation.`,g?.uses.some(e=>!e.selected)?i===`zh`?` 部分能力暂无可用模型,可稍后在模型设置中查看。`:` Some capabilities have no available model. Review them in Model settings.`:null]}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:S?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:S}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(cY,{step:y,label:w}),(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:x,onClick:()=>void D(),children:[x?(0,$.jsx)(Hi,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,i===`zh`?`开始使用 XOPC`:`Start using XOPC`,x?null:(0,$.jsx)(vn,{className:`size-4`,"aria-hidden":!0})]})]})]}):null]},y)})]}),f?null:(0,$.jsx)(zn,{open:l,initialProviderId:b??void 0,onOpenChange:u,builtinRows:d.builtinRows,customConfig:d.customConfig,labels:Do(i).capabilitiesSettings.addProviderDialog,language:i,onSaved:e=>{if(e===`xopc-cloud`){u(!1),E();return}nn({...C.trim()?{callName:C.trim()}:{},timezone:an(),locale:i===`zh`?`zh-CN`:`en-US`}).then(()=>{u(!1),c({type:`patch`,patch:{step:`success`,error:null}})}).catch(e=>c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}}))}})]})}function uY(e){return e?.enabled===!0&&(e.state.status===`not_started`||e.state.status===`in_progress`)}function dY(e){let t=!e.settingsRoute&&e.modelSetupReady&&e.needsModelSetup&&!e.modelGuideDismissed,n=e.cloudOnboardingReady&&e.cloudOnboardingPending&&(!e.desktop||e.modelSetupReady)&&!(e.desktop&&t),r=t&&!n,i=!n&&!e.settingsRoute&&e.modelSetupReady&&!e.needsModelSetup&&uY(e.workDiscovery);return{open:e.authenticated&&!e.closed&&(r||n||i),stage:n?`cloud`:r?`setup`:`work`}}function fY(e){if(!e||typeof e!=`object`||Array.isArray(e))return!0;let t=e.agents;if(!t)return!0;let n=t.defaults?.models?.chat?.primary?.trim()??``;return!((t.list?.find(e=>e.enabled!==!1&&e.id===t.default))?.models?.chat?.primary?.trim()||n)}function pY(e){let{enabled:t,ready:n,configError:r,modelsError:i,config:a,modelsData:o}=e;if(!t||!n||r||i)return!1;let s=fY(a),c=!Array.isArray(o)||o.length===0;return s||c}function mY(e){let t=(0,Q.c)(21),[n,r]=(0,Z.useState)(hY),{data:i,error:a,isLoading:o,mutate:s}=Fc(e),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},t[0]=c):c=t[0];let{data:l,isLoading:u,error:d,mutate:f}=qo(e?rl:null,nl,c),p=!e||!o&&!u,m=i?.payload?.config,h;t[1]!==a||t[2]!==e||t[3]!==l||t[4]!==d||t[5]!==p||t[6]!==m?(h=pY({enabled:e,ready:p,configError:a,modelsError:d,config:m,modelsData:l}),t[1]=a,t[2]=e,t[3]=l,t[4]=d,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g=h,_;t[8]!==s||t[9]!==f?(_=async()=>{await Promise.all([s(),f()])},t[8]=s,t[9]=f,t[10]=_):_=t[10];let v=_,y,b;t[11]!==e||t[12]!==f?(y=()=>{if(!e)return;let t=()=>{f()};return window.addEventListener(`config-reload`,t),()=>window.removeEventListener(`config-reload`,t)},b=[e,f],t[11]=e,t[12]=f,t[13]=y,t[14]=b):(y=t[13],b=t[14]),(0,Z.useEffect)(y,b);let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{try{localStorage.setItem(od,`1`)}catch{}r(!0)},t[15]=x):x=t[15];let S=x,C;return t[16]!==n||t[17]!==g||t[18]!==p||t[19]!==v?(C={needsSetup:g,ready:p,refresh:v,guideDismissed:n,dismissPermanently:S},t[16]=n,t[17]=g,t[18]=p,t[19]=v,t[20]=C):C=t[20],C}function hY(){return typeof localStorage<`u`&&localStorage.getItem(`xopc-onboarding-model-setup-dismissed`)===`1`}var gY=ad;async function _Y(){let e=await Po(Lo(gY));if(!e.ok)throw Error(`Cloud onboarding: ${e.status}`);return(await e.json()).payload}function vY(e){let t=(0,Q.c)(9),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!1},t[0]=n):n=t[0];let{data:r,error:i,mutate:a}=qo(e?gY:null,_Y,n),o=!!r&&!i,s=r?.status===`unseen`&&!r.hasGrant,c,l;t[1]===a?(c=t[2],l=t[3]):(c=()=>a(),l=async()=>{let e=await Po(Lo(gY),{method:`PUT`});if(!e.ok)throw Error(`Cloud onboarding dismissal: ${e.status}`);await a({status:`dismissed`,hasGrant:!1},{revalidate:!1})},t[1]=a,t[2]=c,t[3]=l);let u;return t[4]!==o||t[5]!==s||t[6]!==c||t[7]!==l?(u={ready:o,pending:s,refresh:c,dismiss:l},t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8],u}function yY({context:e,onDismiss:t,onConnected:n}){let r=zo(e=>e.language)===`zh`,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),u=e===`chat`?r?`为对话连接更多模型`:`Connect more models for chat`:e===`personal`?r?`为个人 Agent 一次配好模型`:`Set up models for your personal agent`:r?`连接 XOPC Cloud,省去逐个配置模型`:`Connect XOPC Cloud to simplify model setup`,d=e===`chat`?r?`连接 XOPC Cloud 后,此账号可用的聊天、图片和语音模型会自动同步。你可以继续使用当前聊天模型,稍后再切换。`:`Connect XOPC Cloud to sync the chat, image, and voice models available to your account. You can keep using your current chat model and switch later.`:e===`personal`?r?`连接一次即可为个人 Agent 准备此账号可用的聊天、图片和语音模型。已有模型和明确设置不会改变。`:`Connect once to make the chat, image, and voice models available to your personal agent. Your current model and explicit settings stay in place.`:r?`授权后会同步此账号可用的聊天、图片和语音等模型。已有的默认聊天模型及明确设置保持不变,之后可自行切换。`:`Authorize once to sync the chat, image, and voice models available to your account. Your current default chat model and explicit settings stay in place.`,f=async()=>{a(!0);try{let e=await Po(Lo(`/api/models/catalog`));if(!e.ok)throw Error(`Readiness unavailable`);let t=(await e.json()).payload.sources[`xopc-cloud`]?.models.filter(e=>e.availability===`available`)??[],n=new Set(t.map(e=>e.kind));s([...n.has(`language`)?[r?`聊天`:`chat`]:[],...t.some(e=>e.kind===`language`&&e.input.includes(`image`))?[r?`视觉理解`:`vision`]:[],...n.has(`image`)?[r?`图片生成`:`image generation`]:[],...n.has(`stt`)?[r?`语音识别`:`speech recognition`]:[],...n.has(`tts`)?[r?`语音合成`:`speech synthesis`]:[]]),l(t.length===0)}catch{l(!0)}};return(0,$.jsx)(`div`,{className:`p-5 sm:p-6`,children:(0,$.jsxs)(`div`,{className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(rr,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,"aria-label":i?r?`继续`:`Continue`:r?`暂时不用`:`Maybe later`,onClick:i?n:t,children:(0,$.jsx)(wo,{className:`size-4`})})]}),(0,$.jsx)(`h1`,{className:`mt-6 text-2xl font-semibold text-fg`,children:i?r?`XOPC Cloud 已连接`:`XOPC Cloud is connected`:u}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:i?c?r?`授权已完成,模型目录暂不可用。稍后可在模型设置中刷新。`:`Authorization completed, but the model catalog is temporarily unavailable. Refresh it later in model settings.`:r?`已同步可用能力:${o.join(`、`)||`模型目录`}。你可以稍后在模型设置中选择默认模型。`:`Available capabilities: ${o.join(`, `)||`model catalog`}. You can choose a default model later in model settings.`:d}),i?(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-7`,onClick:n,children:r?`继续聊天`:`Continue to chat`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-7`,children:(0,$.jsx)(sd,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:!1,onConnected:()=>void f()})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`mt-5`,onClick:t,children:r?`暂时不用,继续使用现有模型`:`Maybe later, keep using my current model`})]})]})})}function bY(){let e=(0,Q.c)(75),t=Ro(kY),n=zo(OY),r;e[0]===n?r=e[1]:(r=Do(n),e[0]=n,e[1]=r);let i=r,{pathname:a}=p(),o=b(),s=mY(!!t),c=vY(!!t),l=a.startsWith(`/settings`)||a===`/personal`,[u,d]=(0,Z.useState)(null),[f,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),y;e[2]!==m||e[3]!==g||e[4]!==d||e[5]!==t?(y=()=>{if(m(!1),g(!1),!t){d(null);return}let e=!1;return Ar().then(t=>{e||d(t)}).catch(DY),()=>{e=!0}},e[2]=m,e[3]=g,e[4]=d,e[5]=t,e[6]=y):y=e[6];let x;e[7]===t?x=e[8]:(x=[t],e[7]=t,e[8]=x),(0,Z.useEffect)(y,x);let S=dY({authenticated:!!t,desktop:Ol(),settingsRoute:l,modelSetupReady:s.ready,needsModelSetup:s.needsSetup||h,modelGuideDismissed:s.guideDismissed,cloudOnboardingReady:c.ready,cloudOnboardingPending:c.pending,workDiscovery:u,closed:f}),C;e[9]!==S.open||e[10]!==S.stage||e[11]!==g?(C=()=>{S.open&&S.stage===`setup`&&g(!0)},e[9]=S.open,e[10]=S.stage,e[11]=g,e[12]=C):C=e[12];let w;e[13]!==S.open||e[14]!==S.stage?(w=[S.open,S.stage],e[13]=S.open,e[14]=S.stage,e[15]=w):w=e[15],(0,Z.useEffect)(C,w);let T;e[16]!==m||e[17]!==g?(T=()=>{g(!1),m(!0)},e[16]=m,e[17]=g,e[18]=T):T=e[18];let E=T,D;e[19]!==E||e[20]!==o?(D=()=>{E(),o(`/chat`)},e[19]=E,e[20]=o,e[21]=D):D=e[21];let O=D,k;e[22]!==E||e[23]!==s?(k=()=>{E(),s.dismissPermanently(),jr().catch(EY)},e[22]=E,e[23]=s,e[24]=k):k=e[24];let A=k,j;e[25]!==E||e[26]!==c||e[27]!==s.needsSetup||e[28]!==s.ready||e[29]!==u?(j=async()=>{await c.dismiss(),s.ready&&!s.needsSetup&&!uY(u)&&E()},e[25]=E,e[26]=c,e[27]=s.needsSetup,e[28]=s.ready,e[29]=u,e[30]=j):j=e[30];let M=j,N=S.stage!==`cloud`,P=S.open,F;e[31]!==E||e[32]!==M||e[33]!==A||e[34]!==S.stage||e[35]!==O||e[36]!==_?(F=e=>{e||(S.stage===`setup`?_||A():S.stage===`cloud`?M().catch(E):O())},e[31]=E,e[32]=M,e[33]=A,e[34]=S.stage,e[35]=O,e[36]=_,e[37]=F):F=e[37];let I;e[38]===S.stage?I=e[39]:(I=S.stage===`cloud`?null:(0,$.jsx)(rs,{className:`xopc-dialog-overlay fixed inset-0 z-[55] bg-scrim backdrop-blur-md`}),e[38]=S.stage,e[39]=I);let L=S.stage===`cloud`?`bottom-4 right-4 max-h-[calc(100vh-2rem)] w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay shadow-xl`:`xopc-onboarding-dialog inset-0 overflow-hidden`,R;e[40]===L?R=e[41]:(R=Y(`app-chrome-shell fixed z-[56] outline-none`,L),e[40]=L,e[41]=R);let z;e[42]!==S.stage||e[43]!==_?(z=e=>{S.stage===`setup`&&_&&e.preventDefault()},e[42]=S.stage,e[43]=_,e[44]=z):z=e[44];let B;e[45]===i.onboarding.title?B=e[46]:(B=(0,$.jsx)(ls,{className:`sr-only`,children:i.onboarding.title}),e[45]=i.onboarding.title,e[46]=B);let V;e[47]===i.onboarding.subtitle?V=e[48]:(V=(0,$.jsx)(as,{className:`sr-only`,children:i.onboarding.subtitle}),e[47]=i.onboarding.subtitle,e[48]=V);let H;e[49]!==E||e[50]!==c||e[51]!==M||e[52]!==A||e[53]!==S.stage||e[54]!==O||e[55]!==s||e[56]!==a||e[57]!==g||e[58]!==v||e[59]!==d?(H=S.stage===`setup`?(0,$.jsx)(lY,{onComplete:async()=>{let e=await Ar().catch(CY);d(e),await s.refresh();let t=await c.refresh().catch(SY),n=t?.status===`unseen`&&!t.hasGrant;Ol()&&n&&(await c.dismiss().catch(xY),n=!1),g(!1),!uY(e)&&!n&&O()},onPendingChange:v,onDismiss:A,canDismiss:!0}):S.stage===`cloud`?(0,$.jsx)(yY,{context:a.startsWith(`/chat`)?`chat`:a===`/personal`?`personal`:`general`,onDismiss:()=>void M().catch(E),onConnected:()=>{c.refresh().catch(E)}}):(0,$.jsx)(`div`,{className:`xopc-onboarding-work-stage h-full overflow-hidden`,children:(0,$.jsx)(Yt,{embedded:!0,onRequestClose:O,onNavigateAway:E})}),e[49]=E,e[50]=c,e[51]=M,e[52]=A,e[53]=S.stage,e[54]=O,e[55]=s,e[56]=a,e[57]=g,e[58]=v,e[59]=d,e[60]=H):H=e[60];let U;e[61]!==R||e[62]!==z||e[63]!==B||e[64]!==V||e[65]!==H?(U=(0,$.jsxs)(cs,{className:R,onEscapeKeyDown:z,onPointerDownOutside:TY,onOpenAutoFocus:wY,children:[B,V,H]}),e[61]=R,e[62]=z,e[63]=B,e[64]=V,e[65]=H,e[66]=U):U=e[66];let W;e[67]!==I||e[68]!==U?(W=(0,$.jsxs)(ss,{children:[I,U]}),e[67]=I,e[68]=U,e[69]=W):W=e[69];let ee;return e[70]!==S.open||e[71]!==F||e[72]!==W||e[73]!==N?(ee=(0,$.jsx)(us,{modal:N,open:P,onOpenChange:F,children:W}),e[70]=S.open,e[71]=F,e[72]=W,e[73]=N,e[74]=ee):ee=e[74],ee}function xY(){}function SY(){return null}function CY(){return null}function wY(e){return e.preventDefault()}function TY(e){return e.preventDefault()}function EY(){}function DY(){}function OY(e){return e.language}function kY(e){return e.conversationId}function AY(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`shrink-0`,children:n}),t[0]=n,t[1]=r),r}function jY(){let e=(0,Q.c)(3),t=on(NY),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=MY;e();let n=window.setInterval(e,t?1500:3e4);return window.addEventListener(`understanding-refresh-updated`,e),window.addEventListener(`focus`,e),()=>{window.clearInterval(n),window.removeEventListener(`understanding-refresh-updated`,e),window.removeEventListener(`focus`,e)}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function MY(){on.getState().poll()}function NY(e){return e.sources.some(PY)}function PY(e){return e.status===`queued`||e.status===`running`}var FY=new Set([`queued`,`probing`,`analyzing`]),IY=[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`];function LY(){let e=(0,Q.c)(7),t=Fr(GY),n=Fr(WY),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[0]=r):r=e[0],(0,Z.useEffect)(HY,r);let i,a;e[1]!==t||e[2]!==n?(i=()=>{if(!t||!n||!FY.has(n))return;let e=!1,r=async()=>{try{let n=await Nr(t);e||Fr.getState().updateDirectoryRun(n)}catch{}};r();let i=window.setInterval(()=>void r(),1200);return()=>{e=!0,window.clearInterval(i)}},a=[t,n],e[1]=t,e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),(0,Z.useEffect)(i,a);let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],e[5]=o):o=e[5],(0,Z.useEffect)(RY,o);let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(jY,{}),e[6]=s):s=e[6],s}function RY(){let e=zY;for(let t of IY)window.addEventListener(t,e);return()=>{for(let t of IY)window.removeEventListener(t,e)}}function zY(e){let t=e.detail?.runId;t&&Nr(t).then(VY).catch(BY)}function BY(){}function VY(e){return Fr.getState().updateDirectoryRun(e)}function HY(){let e=!1;return Ar().then(async t=>{let{state:n}=t;if(n.status!==`in_progress`||!n.activeRunId)return;let r=await Nr(n.activeRunId);e||Fr.getState().updateDirectoryRun(r)}).catch(UY),()=>{e=!0}}function UY(){}function WY(e){return e.directoryRun?.status}function GY(e){return e.directoryRun?.id}var KY=`workDiscovery`;function qY(e){return new URLSearchParams(e).get(KY)===`new`}function JY(e){let t=new URLSearchParams(e);t.delete(KY);let n=t.toString();return n?`?${n}`:``}var YY=(0,Z.lazy)(()=>Pl().then(e=>({default:e.WorkDiscoveryOverlay}))),XY=(0,Z.lazy)(()=>Il().then(e=>({default:e.TaskDetailModal})));function ZY(){let e=(0,Q.c)(3),t=b(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail;n?.conversationId&&t(`/chat/${encodeURIComponent(n.conversationId)}`)};return window.addEventListener(`navigate-to-chat`,e),()=>window.removeEventListener(`navigate-to-chat`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function QY(){let e=(0,Q.c)(3),t=b(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail,r=typeof n?.path==`string`?n.path.trim():``;r&&t(r.startsWith(`/`)?r:`/${r}`)};return window.addEventListener(`extension-navigate`,e),()=>window.removeEventListener(`extension-navigate`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function $Y(){let e=(0,Q.c)(3),t=Ro(tX),n=`${Ro(eX)}:${t??``}`,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Xe,{children:(0,$.jsx)(nX,{})}),e[0]=r):r=e[0];let i;return e[1]===n?i=e[2]:(i=(0,$.jsx)(vz,{children:r},n),e[1]=n,e[2]=i),i}function eX(e){return e.baseUrl}function tX(e){return e.conversationId}function nX(){let e=(0,Q.c)(149),t=Ro(oX),{pathname:n,search:r}=p(),i=b(),a;e[0]===n?a=e[1]:(a=n.startsWith(`/settings`),e[0]=n,e[1]=a);let o=a,s=n===`/onboarding/workspace`,c=zo(aX),l=AB(),u=re(iX),[d,m]=(0,Z.useState)(0),h=HU(n),g;e[2]!==n||e[3]!==r?(g=n===`/user-model`&&qY(r),e[2]=n,e[3]=r,e[4]=g):g=e[4];let _=g,v;e[5]!==n||e[6]!==r?(v=n.startsWith(`/tasks/`)?null:new URLSearchParams(r).get(Wi),e[5]=n,e[6]=r,e[7]=v):v=e[7];let y=v,x;e[8]!==h||e[9]!==n||e[10]!==y||e[11]!==u?(x=y&&u?u:h??(n.startsWith(`/chat`)?`new`:u??`new`),e[8]=h,e[9]=n,e[10]=y,e[11]=u,e[12]=x):x=e[12];let S=x,C;if(e[13]!==n||e[14]!==r||e[15]!==y){let t=Yi(n)?new URLSearchParams(r).get(Ki):null;C=t&&!y?ra(t):null,e[13]=n,e[14]=r,e[15]=y,e[16]=C}else C=e[16];let w=C,T;e[17]!==n||e[18]!==r?(T=$i(n,r),e[17]=n,e[18]=r,e[19]=T):T=e[19];let E=T,D;e[20]!==n||e[21]!==w||e[22]!==r||e[23]!==y?(D=!y&&!w&&Yi(n)?new URLSearchParams(r).get(Xi):null,e[20]=n,e[21]=w,e[22]=r,e[23]=y,e[24]=D):D=e[24];let O=D,k;e[25]!==n||e[26]!==r?(k=Qi(n,r),e[25]=n,e[26]=r,e[27]=k):k=e[27];let A=k,j;e[28]!==n||e[29]!==r?(j=na(n,r),e[28]=n,e[29]=r,e[30]=j):j=e[30];let M=j,[N,P]=(0,Z.useState)(_),F,I;e[31]===_?(F=e[32],I=e[33]):(I=()=>{_&&P(!0)},F=[_],e[31]=_,e[32]=F,e[33]=I),(0,Z.useEffect)(I,F);let L;e[34]!==i||e[35]!==n||e[36]!==r?(L=()=>{i({pathname:n,search:JY(r)},{replace:!0})},e[34]=i,e[35]=n,e[36]=r,e[37]=L):L=e[37];let R=L,z;e[38]!==R||e[39]!==_?(z=()=>{P(!1),_&&R(),window.requestAnimationFrame(rX)},e[38]=R,e[39]=_,e[40]=z):z=e[40];let B=z,V;e[41]!==i||e[42]!==M?(V=()=>{i(M,{replace:!0})},e[41]=i,e[42]=M,e[43]=V):V=e[43];let H=V;if(!t){let t=c===`zh`?`跳到主要内容`:`Skip to main content`,n;e[44]===t?n=e[45]:(n=(0,$.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t}),e[44]=t,e[45]=n);let r,i;e[46]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(nW,{}),i=(0,$.jsx)(FG,{}),e[46]=r,e[47]=i):(r=e[46],i=e[47]);let a;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Dz,{})}),e[48]=a):a=e[48];let o;return e[49]===n?o=e[50]:(o=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[n,r,i,a]}),e[49]=n,e[50]=o),o}let U;e[51]===n?U=e[52]:(U=n.split(`/`)[1]||`root`,e[51]=n,e[52]=U);let W=U,ee=W===`chat`||W===`notes`||W===`personal`;if(s){let t,n,r,i,a,o,s;e[53]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(NG,{}),n=(0,$.jsx)(tJ,{}),r=(0,$.jsx)(LY,{}),i=(0,$.jsx)(hJ,{}),a=(0,$.jsx)(FG,{}),o=(0,$.jsx)(nW,{}),s=ts()?(0,$.jsx)(`div`,{className:Y(`w-full`,cl,ol),"aria-hidden":`true`}):null,e[53]=t,e[54]=n,e[55]=r,e[56]=i,e[57]=a,e[58]=o,e[59]=s):(t=e[53],n=e[54],r=e[55],i=e[56],a=e[57],o=e[58],s=e[59]);let c;return e[60]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[t,n,r,i,a,o,s,(0,$.jsx)(`main`,{id:`app-main-content`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,$.jsx)(f,{})})]}),e[60]=c):c=e[60],c}let G;e[61]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(NG,{}),e[61]=G):G=e[61];let K=c===`zh`?`跳到主要内容`:`Skip to main content`,q;e[62]===K?q=e[63]:(q=(0,$.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:K}),e[62]=K,e[63]=q);let te,ne,ie,ae,oe,se,ce,le,ue,de,fe,pe,me;e[64]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(tJ,{}),ne=(0,$.jsx)(LY,{}),ie=(0,$.jsx)(hJ,{}),ae=(0,$.jsx)(FG,{}),oe=(0,$.jsx)(ZY,{}),se=(0,$.jsx)(QY,{}),ce=(0,$.jsx)(IK,{}),le=(0,$.jsx)(GK,{}),ue=(0,$.jsx)(rz,{}),de=(0,$.jsx)(Rq,{}),fe=(0,$.jsx)(XK,{}),pe=(0,$.jsx)(kJ,{}),me=(0,$.jsx)(IJ,{}),e[64]=te,e[65]=ne,e[66]=ie,e[67]=ae,e[68]=oe,e[69]=se,e[70]=ce,e[71]=le,e[72]=ue,e[73]=de,e[74]=fe,e[75]=pe,e[76]=me):(te=e[64],ne=e[65],ie=e[66],ae=e[67],oe=e[68],se=e[69],ce=e[70],le=e[71],ue=e[72],de=e[73],fe=e[74],pe=e[75],me=e[76]);let he;e[77]===h?he=e[78]:(he=(0,$.jsx)(IU,{conversationId:h}),e[77]=h,e[78]=he);let ge,_e;e[79]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(WU,{}),_e=(0,$.jsx)(bY,{}),e[79]=ge,e[80]=_e):(ge=e[79],_e=e[80]);let ve;e[81]!==i||e[82]!==E||e[83]!==w?(ve=w?(0,$.jsx)($u,{target:w,backgroundPath:E,onClose:()=>i(E,{replace:!0})}):null,e[81]=i,e[82]=E,e[83]=w,e[84]=ve):ve=e[84];let J;e[85]!==i||e[86]!==A||e[87]!==O?(J=O?(0,$.jsx)(zK,{noteId:O,backgroundPath:A,onClose:()=>i(A,{replace:!0})}):null,e[85]=i,e[86]=A,e[87]=O,e[88]=J):J=e[88];let ye;e[89]!==H||e[90]!==M||e[91]!==y||e[92]!==d?(ye=y?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(XY,{taskId:y,backgroundPath:M,workspacePanelWidth:d,onClose:H})}):null,e[89]=H,e[90]=M,e[91]=y,e[92]=d,e[93]=ye):ye=e[93];let be;e[94]!==B||e[95]!==_||e[96]!==N?(be=N?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(YY,{requestedOpen:_,onExited:B})}):null,e[94]=B,e[95]=_,e[96]=N,e[97]=be):be=e[97];let xe;e[98]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(nW,{}),e[98]=xe):xe=e[98];let Se;e[99]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(iW,{}),e[99]=Se):Se=e[99];let Ce;e[100]===l?Ce=e[101]:(Ce=(0,$.jsx)(GG,{reminder:l}),e[100]=l,e[101]=Ce);let we;e[102]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,$.jsx)(VG,{}),e[102]=we):we=e[102];let Te;e[103]===Ce?Te=e[104]:(Te=(0,$.jsxs)(AY,{children:[Se,Ce,we]}),e[103]=Ce,e[104]=Te);let Ee;e[105]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(wH,{}),e[105]=Ee):Ee=e[105];let De;e[106]===o?De=e[107]:(De=o?null:(0,$.jsx)(iB,{}),e[106]=o,e[107]=De);let Oe=W!==`settings`&&`page-enter`,ke=W===`settings`||ee?`overflow-hidden`:`overflow-y-auto overscroll-contain [scrollbar-gutter:stable_both-edges]`,Ae;e[108]!==Oe||e[109]!==ke?(Ae=Y(`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,Oe,ke),e[108]=Oe,e[109]=ke,e[110]=Ae):Ae=e[110];let je;e[111]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,$.jsx)(f,{}),e[111]=je):je=e[111];let Me;e[112]!==W||e[113]!==Ae?(Me=(0,$.jsx)(`main`,{id:`app-main-content`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(`div`,{className:Ae,children:je},W)}),e[112]=W,e[113]=Ae,e[114]=Me):Me=e[114];let Ne;e[115]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsx)(MJ,{}),e[115]=Ne):Ne=e[115];let Pe;e[116]!==o||e[117]!==n?(Pe=!o&&!n.startsWith(`/chat`)?(0,$.jsx)(XR,{}):null,e[116]=o,e[117]=n,e[118]=Pe):Pe=e[118];let Fe;e[119]!==De||e[120]!==Me||e[121]!==Pe?(Fe=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[De,Me,Ne,Pe]}),e[119]=De,e[120]=Me,e[121]=Pe,e[122]=Fe):Fe=e[122];let Ie;e[123]!==o||e[124]!==n||e[125]!==y||e[126]!==u?(Ie=!o&&(n.startsWith(`/chat`)||n===`/personal`||(!!y||n.startsWith(`/tasks/`))&&!!u),e[123]=o,e[124]=n,e[125]=y,e[126]=u,e[127]=Ie):Ie=e[127];let Le=!!y,Re;e[128]!==Ie||e[129]!==Le||e[130]!==S?(Re=(0,$.jsx)(jU,{scope:S,onDockedWidthChange:m,enabled:Ie,elevated:Le}),e[128]=Ie,e[129]=Le,e[130]=S,e[131]=Re):Re=e[131];let ze;e[132]!==Fe||e[133]!==Re?(ze=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[Ee,(0,$.jsx)(`div`,{className:`app-main-surface relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[Fe,Re]})})]}),e[132]=Fe,e[133]=Re,e[134]=ze):ze=e[134];let Be;e[135]!==Te||e[136]!==ze?(Be=(0,$.jsxs)(`div`,{className:`app-chrome-shell flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[xe,Te,ze]}),e[135]=Te,e[136]=ze,e[137]=Be):Be=e[137];let Ve;e[138]!==Be||e[139]!==S?(Ve=(0,$.jsx)(ni.Provider,{value:S,children:Be}),e[138]=Be,e[139]=S,e[140]=Ve):Ve=e[140];let He;return e[141]!==q||e[142]!==he||e[143]!==ve||e[144]!==J||e[145]!==ye||e[146]!==be||e[147]!==Ve?(He=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[G,q,te,ne,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e,ve,J,ye,be,Ve]}),e[141]=q,e[142]=he,e[143]=ve,e[144]=J,e[145]=ye,e[146]=be,e[147]=Ve,e[148]=He):He=e[148],He}function rX(){document.querySelector(`[data-work-discovery-trigger]`)?.focus({preventScroll:!0})}function iX(e){return e.conversationIdOverride}function aX(e){return e.language}function oX(e){return e.conversationId}var sX={en:`https://xopc.ai/en#download`,zh:`https://xopc.ai/zh#download`};function cX(e){if(e instanceof Error)return e.stack||e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function lX(e=Ho()){return sX[e]}function uX(){let e=window.location.hash.replace(/^#\/?/,``).split(/[/?]/,1)[0];return`${window.location.origin}${window.location.pathname}${e?`#/${e}`:``}`}function dX({error:e,source:t,componentStack:n,capturedAt:r=new Date}){let i=window.electronAPI?`Electron desktop app`:`Gateway web UI`,a=window.electronAPI?.platform??navigator.platform??`unknown`,o=jB.commit===`unknown`?`unknown`:jB.commit.slice(0,12),s=[`# xopc renderer error report`,``,`- xopc web version: ${jB.version}`,`- Commit: ${o}`,`- Build time: ${jB.buildTimeIso}`,`- Captured at: ${r.toISOString()}`,`- Source: ${t}`,`- Surface: ${i}`,`- Platform: ${a}`,`- Language: ${Ho()}`,`- Page: ${uX()}`,`- User agent: ${navigator.userAgent}`,``,`## Error`,``,"```text",cX(e),"```"];return n?.trim()&&s.push(``,`## React component stack`,``,"```text",n.trim(),"```"),s.join(`
|