@openchambery/web 1.18.5 → 1.18.6-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/assets/AssistantView-LPfaliRV.js +1 -0
  2. package/dist/assets/{ChatContainer-B7H_fTkm.js → ChatContainer-BYdx_DXz.js} +12 -12
  3. package/dist/assets/ContextPanel-BwwT_VfC.js +288 -0
  4. package/dist/assets/DiagramView-DvFv9-nP.js +1 -0
  5. package/dist/assets/{MarkdownRendererImpl-DOpja779.js → MarkdownRendererImpl-Cm08lbud.js} +2 -2
  6. package/dist/assets/{MobileDetailNavigation-k1tBlKW5.js → MobileDetailNavigation-BB2pDQj8.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-HxyfCuga.js → MobileShareBridge-DlWPsLUN.js} +1 -1
  8. package/dist/assets/MobileSurface-CN0sClQE.js +2 -0
  9. package/dist/assets/{MultiRunWindow-CwzxTb3p.js → MultiRunWindow-DB8M7hTi.js} +1 -1
  10. package/dist/assets/{SettingsView-Bx9tuWxH.js → SettingsView-DGLS2Mg6.js} +8 -8
  11. package/dist/assets/{SettingsWindow-sVzjzaGh.js → SettingsWindow-C30XBMKE.js} +1 -1
  12. package/dist/assets/{TerminalView-DSwK1UwL.js → TerminalView-4tdrrTVF.js} +1 -1
  13. package/dist/assets/{ToolOutputDialog-D9di4LaC.js → ToolOutputDialog-CkkvQ6I2.js} +1 -1
  14. package/dist/assets/appThemeRegistry-BNiZ1vQk.js +2 -0
  15. package/dist/assets/fileQueries-B_fTkH6s.js +1 -0
  16. package/dist/assets/{gitApi-C_tpQa_z.js → gitApi-DfuIaByA.js} +1 -1
  17. package/dist/assets/{insertionBoundaries-CzVPcHK4.js → insertionBoundaries-C642g-Iw.js} +1 -1
  18. package/dist/assets/main-C0AmH89S.js +29 -0
  19. package/dist/assets/{main-BJBQp1tB.js → main-M0K2vB13.js} +2 -2
  20. package/dist/assets/{miniChat-BLtGuyQZ.js → miniChat-B3KVwxjN.js} +2 -2
  21. package/dist/assets/{mobile-0Sb3IsCl.js → mobile-rzYyWvdR.js} +2 -2
  22. package/dist/assets/{multirun-BC-EFVZ0.js → multirun-qDXHE6q-.js} +1 -1
  23. package/dist/assets/{projectMeta-CYvQd9iC.js → projectMeta-CyhrgevV.js} +1 -1
  24. package/dist/assets/radio-J9GiJ7x9.js +1 -0
  25. package/dist/assets/renderElectronMiniChatApp-DASrZbVL.js +2 -0
  26. package/dist/assets/{renderMobileApp-upKrXoPH.js → renderMobileApp-OOhkEOlN.js} +5 -5
  27. package/dist/assets/{runtimeConfig-BAx9ix2e.js → runtimeConfig-D8mh3gFs.js} +1 -1
  28. package/dist/assets/runtimeEndpointReset-BSJKTLkz.js +4 -0
  29. package/dist/assets/shikiHighlight-BcXbHYOl.js +1 -0
  30. package/dist/assets/{useAppFontEffects-Bo__MTWV.js → useAppFontEffects-Bgx8zwRg.js} +4 -4
  31. package/dist/assets/{useDesktopWindowControlsLayout-DkmRLrOT.js → useDesktopWindowControlsLayout-D8rr0PdL.js} +1 -1
  32. package/dist/assets/{useEffectiveDirectory-ByQPsbk0.js → useEffectiveDirectory-Dfo_EXBo.js} +1 -1
  33. package/dist/assets/{useMobileNavigationStore-DLYb8f5L.js → useMobileNavigationStore-hrmD9bA5.js} +3 -3
  34. package/dist/assets/useSessionAutoCleanup-B2TGbr2W.js +1 -0
  35. package/dist/assets/{useWorkerHighlightedLines-Ce2Bs8_N.js → useWorkerHighlightedLines-0_GDJima.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/mini-chat.html +2 -2
  38. package/dist/mobile.html +2 -2
  39. package/package.json +1 -1
  40. package/dist/assets/AssistantView-n8llxdCo.js +0 -1
  41. package/dist/assets/DiagramView-DK5RkG9r.js +0 -1
  42. package/dist/assets/MobileSurface-BRouCuNF.js +0 -2
  43. package/dist/assets/appThemeRegistry-CN1tLL9G.js +0 -2
  44. package/dist/assets/context-menu-BrLPLxWa.js +0 -1
  45. package/dist/assets/diagram-CHfginjS.js +0 -1
  46. package/dist/assets/fileQueries-BrUKKgPW.js +0 -1
  47. package/dist/assets/main-BUGDfAIY.js +0 -172
  48. package/dist/assets/radio-CEt2UjvA.js +0 -1
  49. package/dist/assets/renderElectronMiniChatApp-ByA4BElP.js +0 -2
  50. package/dist/assets/runtimeEndpointReset-Dst0Yqyz.js +0 -147
  51. package/dist/assets/useSessionAutoCleanup-C5knpuh5.js +0 -1
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{j as t,t as n}from"./useUIStore-DzwCfRqr.js";import{Kt as r,kn as i,qt as a,u as o}from"./persistence-6sclr7B6.js";import{h as s}from"./desktopHosts-Txp4xOVQ.js";import{i as c,n as l,r as u}from"./desktopRelayRestore-C_FSEHKM.js";import{nt as d,rt as f}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as p}from"./platform-CbeLpKPk.js";import{n as m}from"./vendor-react-DLPElpoQ.js";import{n as h}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as g,r as _}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as v}from"./clipboard-DWuULPzo.js";import{i as y,t as b}from"./store-DQY8Fkb0.js";import{_r as x,br as ee,ca as S,cr as C,l as w,mr as te}from"./useMobileNavigationStore-hrmD9bA5.js";import{t as ne}from"./utils-B1EK5zKa.js";import{i as re,n as ie,r as ae,t as oe}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{n as se,r as ce}from"./radio-J9GiJ7x9.js";var T=m(),E=[`desktopHostSwitch`],D=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},le=(e,t)=>b(y.getState().dictionary,e,t),ue=async e=>{let{host:n}=e;if(n.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new D({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},n);return t({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:u(n)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}let r=await c(n,{cachedProbe:e.cachedProbe});if(!r.ok)throw new D(r,n);return r},O=null,de=()=>O||(O=new h(o,{mutationKey:E,mutationFn:ue,onError:(e,t)=>{e instanceof D&&e.result.reason!==`unsupported`&&ee.error(le(`desktopHostSwitcher.toast.instanceUnreachable`,{host:s(t.host.label)}))}}),O.subscribe(()=>void 0),O),fe=async e=>{if(l(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:E})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await de().mutate(e)}catch(e){if(e instanceof D)return e.result;throw e}},pe=()=>{let e=(0,T.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:E},e[0]=t):t=e[0],_(t)>0},me=()=>{let e=(0,T.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:E,status:`pending`},select:he},e[0]=t):t=e[0],g(t)[0]?.host.id??null};function he(e){return e.state.variables}var k=e=>typeof e==`object`&&!!e,A=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},j=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},M=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},N=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],P=()=>r()?(e,t)=>a(e,t):null,F=e=>{if(!k(e))return;let t=M(e,`enabled`)??!1,n=A(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=A(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},ge=e=>e===`remote`||e===`dynamic`?e:`local`,_e=e=>{if(!k(e))return null;let t=A(e,`id`);if(!t)return null;let n=M(e,`enabled`)??!0,r=ge(A(e,`type`)),i=A(e,`localHost`)||A(e,`local_host`)||void 0,a=j(e,`localPort`)??j(e,`local_port`)??void 0,o=A(e,`remoteHost`)||A(e,`remote_host`)||void 0,s=j(e,`remotePort`)??j(e,`remote_port`)??void 0;return{id:t,enabled:n,type:r,...i?{localHost:i}:{},...typeof a==`number`?{localPort:a}:{},...o?{remoteHost:o}:{},...typeof s==`number`?{remotePort:s}:{}}},ve=e=>{if(!k(e))return null;let t=A(e,`id`),n=A(e,`sshCommand`)||A(e,`ssh_command`);if(!t||!n)return null;let r=A(e,`nickname`),i=e.sshParsed,a=k(i)?{destination:A(i,`destination`)||``,args:N(i.args)}:void 0,o=k(e.remoteOpenchamber)?e.remoteOpenchamber:k(e.remote_openchamber)?e.remote_openchamber:{},s=k(e.localForward)?e.localForward:k(e.local_forward)?e.local_forward:{},c=k(e.auth)?e.auth:{},l=A(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=A(o,`installMethod`)||A(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=A(s,`bindHost`)||A(s,`bind_host`)||`127.0.0.1`,p=f===`localhost`||f===`0.0.0.0`?f:`127.0.0.1`,m=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(e=>_e(e)).filter(e=>!!e),h=j(o,`preferredPort`)??j(o,`preferred_port`),g=j(s,`preferredLocalPort`)??j(s,`preferred_local_port`),_=F(c.sshPassword||c.ssh_password),v=F(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:j(e,`connectionTimeoutSec`)??j(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:M(o,`keepRunning`)??M(o,`keep_running`)??!0,relayHost:M(o,`relayHost`)??M(o,`relay_host`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:M(o,`uploadBundleOverSsh`)??M(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},ye=e=>{switch(e){case`config_resolved`:case`auth_check`:case`master_connecting`:case`remote_probe`:case`installing`:case`updating`:case`server_detecting`:case`server_starting`:case`forwarding`:case`ready`:case`degraded`:case`error`:return e;default:return`idle`}},I=e=>{if(!k(e))return null;let t=A(e,`id`);return t?{id:t,phase:ye(A(e,`phase`)),...A(e,`detail`)?{detail:A(e,`detail`)||void 0}:{},...A(e,`localUrl`)||A(e,`local_url`)?{localUrl:A(e,`localUrl`)||A(e,`local_url`)||void 0}:{},...typeof(j(e,`localPort`)??j(e,`local_port`))==`number`?{localPort:j(e,`localPort`)??j(e,`local_port`)??void 0}:{},...typeof(j(e,`remotePort`)??j(e,`remote_port`))==`number`?{remotePort:j(e,`remotePort`)??j(e,`remote_port`)??void 0}:{},startedByUs:M(e,`startedByUs`)??M(e,`started_by_us`)??!1,retryAttempt:j(e,`retryAttempt`)??j(e,`retry_attempt`)??0,requiresUserAction:M(e,`requiresUserAction`)??M(e,`requires_user_action`)??!1,...A(e,`errorCode`)||A(e,`error_code`)?{errorCode:A(e,`errorCode`)||A(e,`error_code`)||void 0}:{},updatedAtMs:j(e,`updatedAtMs`)??j(e,`updated_at_ms`)??Date.now()}:null},be=e=>{if(!k(e))return null;let t=A(e,`host`),n=A(e,`source`),r=A(e,`sshCommand`)||A(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:M(e,`pattern`)??!1}},xe=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,relayHost:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),Se=async()=>{let e=P();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return k(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>ve(e)).filter(e=>!!e)}:{instances:[]}},Ce=async e=>{let t=P();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},we=async()=>{let e=P();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>be(e)).filter(e=>!!e):[]},Te=async e=>{let t=P();t&&await t(`desktop_ssh_connect`,{id:e})},Ee=async e=>{let t=P();t&&await t(`desktop_ssh_disconnect`,{id:e})},De=async e=>{let t=P();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>I(e)).filter(e=>!!e):[]},Oe=async(e,t)=>{let n=P();if(!n)return[];let r=await n(`desktop_ssh_logs`,{id:e,...typeof t==`number`?{limit:t}:{}});return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]},ke=async e=>{let t=P();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Ae=(e,t)=>{let n=Math.max(0,Math.trunc(Number(e.fileGroups)||0)),r=Math.max(0,Math.trunc(Number(e.singleFiles)||0)),i=Math.max(0,Math.trunc(Number(e.directories)||0));return{fileGroups:Array.from({length:n},()=>!0),singleFiles:Array.from({length:r},()=>!0),directories:Array.from({length:i},()=>!0),agentsRoot:!0,authFile:t?.includeAuthFile===!0}},je=e=>{if(!k(e))return null;let t=A(e,`path`),n=j(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Me=e=>{if(!k(e))return null;let t=A(e,`path`),n=j(e,`fileCount`)??j(e,`file_count`),r=j(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Ne=e=>{if(e==null||!k(e))return null;let t=j(e,`fileCount`)??j(e,`file_count`),n=j(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},L=e=>{if(e==null||!k(e))return null;let t=j(e,`bytes`);return t===null?null:{bytes:t}},R=e=>{if(!k(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=N(e.deletes),i=j(e,`totalBytes`)??j(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>je(e)).filter(e=>!!e),o=n.map(e=>Me(e)).filter(e=>!!e);if(a.length!==t.length||o.length!==n.length)return null;let s=e.agentsRoot??e.agents_root,c=s==null?null:Ne(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:L(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=k(f)?{fileGroups:Array.isArray(f.fileGroups)?f.fileGroups.map(e=>e!==!1):[],singleFiles:Array.isArray(f.singleFiles)?f.singleFiles.map(e=>e!==!1):[],directories:Array.isArray(f.directories)?f.directories.map(e=>e!==!1):[],agentsRoot:f.agentsRoot!==!1,authFile:f.authFile===!0}:void 0,m=z(e.selectionShape??e.selection_shape);return{files:a,directories:o,agentsRoot:c,authFile:u,deletes:r,totalBytes:i,...d?{direction:d}:{},...p?{selections:p}:{},...m?{selectionShape:m}:{}}},z=e=>{if(!k(e))return null;let t=j(e,`fileGroups`)??j(e,`file_groups`),n=j(e,`singleFiles`)??j(e,`single_files`),r=j(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Pe=e=>{if(!k(e))return null;let t=R(e.plan);if(!t)return null;let n=z(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:N(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:M(e,`remoteAgentsRootExists`)??M(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:M(e,`remoteAuthFileExists`)??M(e,`remote_auth_file_exists`)??!1,...typeof e.credentialAuthorized==`boolean`?{credentialAuthorized:e.credentialAuthorized}:{},...n?{selectionShape:n}:{}}},Fe=e=>{if(!k(e)||M(e,`ok`)!==!0)return null;let t=j(e,`files`),n=j(e,`directories`),r=j(e,`deletes`),i=j(e,`totalBytes`)??j(e,`total_bytes`);if(t===null||n===null||r===null||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=e.agentsRoot??e.agents_root,o=null;if(a!=null){if(!k(a))return null;let e=j(a,`fileCount`)??j(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:L(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Ie=async(e={})=>{let t=P();if(!t)return console.error(`[desktopSsh] config sync local scan skipped: desktop IPC bridge is unavailable in this window`),null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!k(n))return console.error(`[desktopSsh] config sync local scan returned a non-object payload`,n),null;let r=R(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=z(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Le=async(e,t={})=>{let n=P();if(!n)return console.error(`[desktopSsh] config sync preview skipped: desktop IPC bridge is unavailable in this window`),null;let r=await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}}),i=Pe(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},Re=async(e,t={})=>{let n=P();if(!n)return console.error(`[desktopSsh] config sync apply skipped: desktop IPC bridge is unavailable in this window`),null;let r=await n(`desktop_ssh_sync_opencode_config`,{id:e,apply:!0,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}}),i=Fe(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},ze=async(e,t={})=>{let n=P();if(!n)return[];let r=await n(`desktop_ssh_sync_runs_list`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}});return Array.isArray(r)?r.filter(e=>k(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},B=e=>{if(!k(e))return null;let t=typeof e.targetId==`string`?e.targetId.trim():``;if(!t)return null;let n=e.authorized===!0,r=typeof e.grantedAt==`string`&&e.grantedAt.trim()?e.grantedAt.trim():void 0,i=typeof e.channel==`string`&&e.channel.trim()?e.channel.trim():void 0;return{targetId:t,authorized:n,...r?{grantedAt:r}:{},...i?{channel:i}:{}}},Be=async(e,t={})=>{let n=P();return n?B(await n(`desktop_ssh_credential_sync_get`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ve=async(e,t={})=>{let n=P();return n?B(await n(`desktop_ssh_credential_sync_grant`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},He=async(e,t={})=>{let n=P();return n?B(await n(`desktop_ssh_credential_sync_revoke`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}})):null},Ue=async e=>{if(!r())return async()=>{};let t=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof t!=`function`)return async()=>{};let n=await t(`openchamber:ssh-instance-status`,t=>{let n=I(t?.payload);n&&e(n)});return async()=>{await n()}},We=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),Ge=e=>typeof e==`string`&&We.has(e),Ke=e=>{let t=String(e||``);return/requires Node\.js \d+|no supported Node runtime/i.test(t)?`nodeRuntimeMissing`:/neither bun nor npm/i.test(t)?`packageManagerMissing`:/better-sqlite3|node_gyp_bins|gyp ERR|failed to prepare better-sqlite3/i.test(t)?`nativeBinding`:/OpenChamber installation completed but the executable is unavailable/i.test(t)?`openchamberCliMissing`:/could not reach the npm registry|ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN|CERT_HAS_EXPIRED|UNABLE_TO_GET_ISSUER_CERT|self-signed certificate|registry\.npmjs|npm error code E404|npm ERR! code E404|getaddrinfo/i.test(t)?`openchamberRegistry`:/Failed to install OpenChamber/i.test(t)?`openchamberInstall`:/Unknown option:\s*--relay-host|does not advertise --relay-host|does not support --relay-host/i.test(t)||/Unknown option:/i.test(t)?`openchamberCliIncompatible`:/Failed to install OpenCode|OpenCode CLI/i.test(t)?`opencodeInstall`:/failed to become reachable|Managed OpenChamber server failed/i.test(t)?`serverStart`:/Permission denied|Authentication failed|publickey|keyboard-interactive/i.test(t)?`sshAuth`:/Could not resolve hostname|Connection refused|Connection timed out|ControlMaster connection timed out|SSH master process exited|Network is unreachable/i.test(t)?`sshUnreachable`:/Timed out waiting for SSH|Timed out waiting for forwarded/i.test(t)?`timeout`:`unknown`},V=(e,t)=>Ge(e)?e:Ke(t),qe=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.title`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.title`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.title`;case`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.title`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.title`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.title`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.title`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.title`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.title`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.title`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.title`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.title`;default:return`desktopHostSwitcher.sshError.unknown.title`}},H=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.guidance`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.guidance`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.guidance`;case`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.guidance`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.guidance`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.guidance`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.guidance`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.guidance`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.guidance`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.guidance`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.guidance`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.guidance`;default:return`desktopHostSwitcher.sshError.unknown.guidance`}},U=e=>e===`unknown`||e===`openchamberCliIncompatible`,Je=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!U(t)||!r||r===e?e:`${e}\n${r}`},W=d();function Ye(e){let t=(0,T.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=v(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=V(n,r);o=a(H(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=U(e)&&!!s&&s!==o,t[12]===i?d=t[13]:(d=ne(`space-y-1`,i),t[12]=i,t[13]=d),l=`typography-ui-label text-[var(--status-error)]`,u=a(qe(e)),t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9];let f;t[14]!==l||t[15]!==u?(f=(0,W.jsx)(`p`,{className:l,children:u}),t[14]=l,t[15]=u,t[16]=f):f=t[16];let p;t[17]===o?p=t[18]:(p=(0,W.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),t[17]=o,t[18]=p);let m;t[19]!==s||t[20]!==c?(m=c?(0,W.jsx)(`p`,{className:`typography-meta break-words text-muted-foreground`,children:s}):null,t[19]=s,t[20]=c,t[21]=m):m=t[21];let h;return t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,W.jsxs)(`div`,{className:d,children:[f,p,m]}),t[22]=d,t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}var Xe=`/auth/passkey/authenticate/options`,Ze=`/auth/passkey/authenticate/verify`,Qe=`/auth/passkey/register/options`,$e=`/auth/passkey/register/verify`,G=`/api/passkeys`,et=`/auth/passkey/status`,tt=`/api/auth/reset`,K={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},q=async(e,t)=>i(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),J=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},nt=e=>e instanceof re&&e.code===`ERROR_CEREMONY_ABORTED`,rt=()=>{ae.cancelCeremony()},Y=()=>typeof window>`u`?{supported:!1,reason:`Passkeys are unavailable outside the browser.`}:window.isSecureContext?{supported:!0,reason:``}:{supported:!1,reason:`Passkeys require HTTPS or localhost.`},it=async()=>{let e=Y();if(!e.supported)throw Error(e.reason);let t=await q(Qe,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await J(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await q($e,{requestId:n,response:await ie({optionsJSON:r})});if(!i.ok)throw Error(await J(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},at=async(e,t={})=>{let n=Y();if(!n.supported)throw Error(n.reason);let r=await q(Xe);if(!r.ok)throw Error(await J(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await q(Ze,{requestId:i,response:await oe({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await J(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},ot=async()=>{let e=await i(et,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return K;let t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount==`number`?t.passkeyCount:0,rpID:typeof t?.rpID==`string`&&t.rpID?t.rpID:null}},st=async()=>{let e=await i(G,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await J(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},ct=async e=>{let t=await i(`${G}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await J(t,`Could not remove passkey.`));return t.json().catch(()=>null)},lt=async()=>{let e=await q(tt);if(!e.ok)throw Error(await J(e,`Could not clear saved authentication.`));return e.json().catch(()=>null)},X=e=>b(y.getState().dictionary,e),ut=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),dt=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,ft=(e,t)=>e??dt(t),pt=(e,t,n=`auto`)=>{if(!e)return t??``;try{let r=new Date(e);if(!Number.isFinite(r.getTime()))return t??``;let i=new Date;return r.toDateString()===i.toDateString()?ce(r,n,{fallback:t??``}):se(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},mt=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,ht=e=>e===`5h`?X(`quota.window.5h`):e===`7d`?X(`quota.window.7d`):e===`7d-sonnet`?X(`quota.window.7dSonnet`):e===`7d-opus`?X(`quota.window.7dOpus`):e===`weekly`?X(`quota.window.weekly`):e===`daily`?X(`quota.window.daily`):e===`monthly`?X(`quota.window.monthly`):e===`credits`?X(`quota.window.credits`):e===`credits_balance`?X(`quota.window.creditsBalance`):e===`billing_cycle`?X(`quota.window.billingCycle`):e===`auto`?X(`quota.window.auto`):e===`api`?X(`quota.window.api`):e===`plan_limit`?X(`quota.window.planLimit`):e===`on_demand`?X(`quota.window.onDemand`):e===`session`?X(`quota.window.session`):e===`premium`?X(`quota.window.premium`):e===`chat`?X(`quota.window.chat`):e===`completions`?X(`quota.window.completions`):e===`premium_interactions`?X(`quota.window.premiumInteractions`):e,gt=e=>{let t=e.toLowerCase().trim();if(t===`5h`)return 18e3;if(t===`7d`||t===`weekly`||t===`7d-sonnet`||t===`7d-opus`)return 604800;if(t===`monthly`)return 2592e3;if(t===`24h`||t===`daily`)return 86400;if(t===`1h`)return 3600;let n=t.match(/^(\d+)h$/);if(n)return parseInt(n[1],10)*3600;let r=t.match(/^(\d+)d$/);return r?parseInt(r[1],10)*86400:null},_t=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=gt(r)),e===null||t===null||i===null||i<=0)return null;let a=Math.max(0,(t-Date.now())/1e3),o=Math.max(0,Math.min(i,i-a)),s=Math.max(0,Math.min(1,o/i)),c=e/100,l=e>=100&&a>0,u;u=s>.01?Math.min(999,c/s*100):e;let d;d=l?`exhausted`:c<=s?`on-track`:u<=130?`slightly-fast`:`too-fast`;let f=i>=432e3,p=f?86400:3600,m=f?`d`:`h`,h=i/p,g=e/Math.max(o/p,h*.01),_=Number.isFinite(g)?`${Math.min(999.9,Math.max(0,g)).toFixed(1)}%/${m}`:`-`,v=u>100?`+${Math.round(u)}%`:`${Math.round(u)}%`,y=null,b=i/86400;return b>=7&&(y=100/b),{elapsedRatio:s,usageRatio:c,predictedFinalPercent:u,remainingSeconds:a,isExhausted:l,elapsedSeconds:o,totalSeconds:i,status:d,paceRateText:_,predictText:v,dailyAllocationPercent:y}},vt=e=>{switch(e){case`exhausted`:case`too-fast`:return`var(--status-error)`;case`slightly-fast`:return`var(--status-warning)`;case`on-track`:return`var(--status-success)`}},yt=e=>{let t=Math.floor(Math.max(0,Math.floor(e))/60),n=Math.floor(t/60),r=Math.floor(n/24),i=n%24,a=t%60;return r>0?`${r}d ${i}h`:n>0?`${n}h`:t===0?`<1m`:`${a}m`},bt=e=>Math.min(100,Math.max(0,e*100)),xt=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],St=`openchamber.pwaRecentSessions`,Ct=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,wt=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:xt.find(e=>Ct(e))??`browser`,Z=e(f(),1),Tt=864e5,Q=5,Et=864e5,$=e=>e.time?.updated??e.time?.created??0,Dt=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Q,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*Tt,o=[...e].sort((e,t)=>$(t)-$(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=$(e);return n?n<a:!1}).map(e=>e.id)},Ot=e=>{let t=typeof e==`object`?e:void 0,r=t?.autoRun!==!1,i=typeof e==`boolean`?e:t?.enabled??!0,a=w(e=>e.currentSessionId),o=w(e=>e.isLoading),s=x(e=>e.activeSessions),c=x(e=>e.hasLoadedFullCatalog),l=n(e=>e.autoDeleteEnabled),u=n(e=>e.autoDeleteAfterDays),d=n(e=>e.sessionRetentionAction),f=n(e=>e.autoDeleteLastRunAt),m=n(e=>e.setAutoDeleteLastRunAt),[h,g]=Z.useState(!1),_=Z.useRef(!1);Z.useEffect(()=>{if(!i||!r||!l||u<=0)return;let e=window.setTimeout(()=>{C(S())},8e3);return()=>window.clearTimeout(e)},[u,l,r,i]);let v=Z.useMemo(()=>u<=0?[]:Dt({sessions:s,currentSessionId:a,cutoffDays:u}),[u,a,s]),y=Z.useCallback(async({force:e=!1}={})=>{if(_.current)return{completedIds:[],failedIds:[],action:d,skippedReason:`running`};if((!l||u<=0)&&!e)return{completedIds:[],failedIds:[],action:d,skippedReason:`disabled`};if(o)return{completedIds:[],failedIds:[],action:d,skippedReason:`loading`};let t=Date.now();if(!e&&f&&t-f<Et)return{completedIds:[],failedIds:[],action:d,skippedReason:`cooldown`};let{activeSessions:n}=await C(S());if(n.length===0)return{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};let r=Dt({sessions:n,currentSessionId:a,cutoffDays:u,now:t});if(r.length===0)return m(t),{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};_.current=!0,g(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?te(r):null;if(!a){i.push(n);continue}try{d===`archive`?await p.updateSession(n,{time:{archived:Date.now()}},a):await p.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return d===`archive`?x.getState().archiveSessions(t):x.getState().removeSessions(t),{completedIds:t,failedIds:i,action:d}}finally{_.current=!1,g(!1),m(Date.now())}},[u,l,f,a,o,d,m]);return Z.useEffect(()=>{i&&r&&(!l||u<=0||o||!c||s.length===0||f&&Date.now()-f<Et||y())},[u,l,f,r,i,c,s.length,o,y]),{candidates:v,isRunning:h,runCleanup:y,keepRecentCount:Q,action:d}};export{Te as A,De as B,Ye as C,qe as D,H as E,we as F,Ue as G,Ie as H,Se as I,me as J,fe as K,Ce as L,Ve as M,He as N,Ae as O,Ee as P,Oe as R,ct as S,V as T,Le as U,Re as V,ze as W,st as _,_t as a,it as b,ft as c,vt as d,mt as f,ot as g,K as h,bt as i,Be as j,xe as k,yt as l,rt as m,St as n,ut as o,at as p,pe as q,wt as r,pt as s,Ot as t,ht as u,Y as v,Je as w,lt as x,nt as y,ke as z};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t}from"./useUIStore-DzwCfRqr.js";import{$t as n,kn as r,xn as i}from"./persistence-6sclr7B6.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{n as s}from"./platform-CbeLpKPk.js";import{a as c,n as l}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{n as d}from"./clipboard-DWuULPzo.js";import{t as f}from"./utils-B1EK5zKa.js";import{n as p}from"./Icon-DpjYnXxn.js";import{t as m}from"./button-C7OXr4ae.js";import{i as h,n as g,t as _}from"./tooltip-D_orJMYd.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{c as y,n as b,o as x,r as S,s as C}from"./markdownTheme-B89dbj3N.js";import{i as w}from"./appThemeRegistry-CN1tLL9G.js";import{d as T,n as E,t as D,u as ee}from"./markdown-worker-W06-MhF5.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(o(),1),k=u(),A=a(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(p,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(p,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(p,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let m=u,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==m||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:m})}),t[7]=m,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=c(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await S(e,t??new AbortController().signal),await G(n,t)}finally{n&&C(n)}},he=async(e,t)=>{let n=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,t)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,t);else{let e=y(a,n);if(x(e))try{i=await me(e.path,t)}catch{let n=await r(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:t});if(!n.ok)throw Error(`Image source request failed with status ${n.status}`);i=await n.blob()}else i=await G(e.source,t)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!s()||l===void 0?!1:l.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:r,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(r);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(n()){let e=i()?.vscode;if(e?.saveImage){let t=await W(r);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(r,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=b(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return D(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let y;t[13]===i?y=t[14]:(y=f(`typography-code`,i),t[13]=i,t[14]=y);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==y||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:y,style:S}),t[18]=y,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):T(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t}from"./useUIStore-DzwCfRqr.js";import{$t as n,kn as r,xn as i}from"./persistence-6sclr7B6.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{n as s}from"./platform-CbeLpKPk.js";import{a as c,n as l}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{n as d}from"./clipboard-DWuULPzo.js";import{t as f}from"./utils-B1EK5zKa.js";import{n as p}from"./Icon-DpjYnXxn.js";import{t as m}from"./button-C7OXr4ae.js";import{i as h,n as g,t as _}from"./tooltip-D_orJMYd.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{c as y,n as b,o as x,r as S,s as C}from"./markdownTheme-B89dbj3N.js";import{i as w}from"./appThemeRegistry-BNiZ1vQk.js";import{d as T,n as E,t as D,u as ee}from"./markdown-worker-W06-MhF5.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(o(),1),k=u(),A=a(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=d(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===o?u=t[4]:(u=o===`in_progress`?(0,A.jsx)(p,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(p,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(p,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=u);let m=u,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==m||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:m})}),t[7]=m,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=c(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await S(e,t??new AbortController().signal),await G(n,t)}finally{n&&C(n)}},he=async(e,t)=>{let n=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,t)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,t);else{let e=y(a,n);if(x(e))try{i=await me(e.path,t)}catch{let n=await r(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:t});if(!n.ok)throw Error(`Image source request failed with status ${n.status}`);i=await n.blob()}else i=await G(e.source,t)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!s()||l===void 0?!1:l.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:r,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(r);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(n()){let e=i()?.vscode;if(e?.saveImage){let t=await W(r);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(r,a),`downloaded`},ve=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=b(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return D(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let y;t[13]===i?y=t[14]:(y=f(`typography-code`,i),t[13]=i,t[14]=y);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==y||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:y,style:S}),t[18]=y,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):T(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},je=(e,n)=>{try{let r=e.trim().split(`
4
4
  `).filter(Boolean);if(r.length===0)return null;let i=[];return r.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,A.jsx)(`div`,{className:f(`w-full min-w-0 font-mono space-y-0.5`,n?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:t.tool.popup,children:i.map((e,t)=>(0,A.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,A.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,A.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Me={backgroundColor:`var(--status-info)`,opacity:.6},Ne=(e,n,r)=>{try{let i=e.trim().split(`
package/dist/index.html CHANGED
@@ -552,7 +552,7 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-BJBQp1tB.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-M0K2vB13.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -569,7 +569,7 @@
569
569
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
570
570
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
571
571
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
572
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BAx9ix2e.js">
572
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D8mh3gFs.js">
573
573
  <link rel="stylesheet" crossorigin href="/assets/src-BDOLh3pc.css">
574
574
  </head>
575
575
  <body class="h-full bg-background text-foreground">
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-BLtGuyQZ.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-B3KVwxjN.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -91,7 +91,7 @@
91
91
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
94
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BAx9ix2e.js">
94
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D8mh3gFs.js">
95
95
  <link rel="stylesheet" crossorigin href="/assets/src-BDOLh3pc.css">
96
96
  </head>
97
97
  <body class="h-full bg-background text-foreground">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-0Sb3IsCl.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-rzYyWvdR.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -80,7 +80,7 @@
80
80
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
83
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BAx9ix2e.js">
83
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D8mh3gFs.js">
84
84
  <link rel="stylesheet" crossorigin href="/assets/src-BDOLh3pc.css">
85
85
  </head>
86
86
  <body class="h-full bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "1.18.5",
3
+ "version": "1.18.6-beta.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{A as n,E as r,t as i,w as a}from"./useUIStore-DzwCfRqr.js";import{Ot as o,et as s,rt as c,yt as l}from"./persistence-6sclr7B6.js";import{nt as u,rt as d}from"./vendor-base-ui-CnHfUmDN.js";import{r as f}from"./platform-CbeLpKPk.js";import{n as p}from"./vendor-react-DLPElpoQ.js";import{r as m}from"./vendor-sonner-DVzioF3d.js";import{n as h}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as g}from"./clipboard-DWuULPzo.js";import{a as _,n as v,s as y}from"./MobileShareBridge-HxyfCuga.js";import{Fo as b,Ja as x,Si as S,Vi as C,Xr as w,Za as T,_n as E,bo as D,cn as O,ei as k,gn as A,hn as j,o as M,rn as N,ua as P,xo as F}from"./useMobileNavigationStore-DLYb8f5L.js";import{_ as I,a as L,c as R,d as ee,f as te,g as ne,l as re,n as ie,o as ae,p as oe,r as se,t as z,v as ce,x as B,y as le}from"./MobileDetailNavigation-k1tBlKW5.js";import{i as ue,r as de}from"./useAssistantUIStore-BHsHXCKE.js";import{t as fe}from"./AgentAvatar-DDcjamcJ.js";import{t as pe}from"./utils-B1EK5zKa.js";import{n as me}from"./Icon-DpjYnXxn.js";import{a as V,i as he,n as ge,o as H,r as U,t as W}from"./dialog-DPS0W9eS.js";import{t as _e}from"./button-C7OXr4ae.js";import{i as ve}from"./OverlayScrollbar-Ch3J6ASR.js";import{J as ye,L as be,N as xe,P as G,R as Se,t as K}from"./ChatContainer-B7H_fTkm.js";import{a as Ce,i as we,n as Te,r as Ee,t as De}from"./context-menu-BrLPLxWa.js";var q=p(),J=e(d(),1),Y=u(),Oe=e=>{let t=(0,q.c)(46),{assistant:n,sessionID:r,warning:i,surface:a,onRevertMessage:o,onEditMessage:s,pendingUserMessages:c,onPendingUserMessagesMaterialized:l}=e,u=n.effectiveWorkspacePath,d;t[0]!==n.sessionGeneration||t[1]!==r?(d={sessionID:r,sessionGeneration:n.sessionGeneration},t[0]=n.sessionGeneration,t[1]=r,t[2]=d):d=t[2];let p=ce(n.id,d,a.active);p.data?.pages;let m;t[3]===p.data?.pages?m=t[4]:(m=p.data?.pages??[],t[3]=p.data?.pages,t[4]=m);let g;t[5]===m?g=t[6]:(g=S(m),t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_){v=new Map;for(let e of _){let t=v.get(e.sessionID);v.set(e.sessionID,t===void 0||t===e.directory?e.directory:null)}t[7]=_,t[8]=v}else v=t[8];let y=v,b;t[9]===p?b=t[10]:(b=async()=>{(p.hasNextPage||p.isFetchNextPageError)&&await p.fetchNextPage()},t[9]=p,t[10]=b);let x=h(b),C=n.mode===`continuous`,w=xe(),T;t[11]!==u||t[12]!==y||t[13]!==w||t[14]!==r?(T=(e,t)=>{let n=e===r?u:y.get(e);if(!n||n!==t){A(e,`missing-directory`);return}E(e,t,{phoneShell:!!(w&&!f()),switchToChat:!0})},t[11]=u,t[12]=y,t[13]=w,t[14]=r,t[15]=T):T=t[15];let D=h(T),O;t[16]===C?O=t[17]:(O={...G,forkSession:!1,navigateNestedSession:!1,mutateSession:C},t[16]=C,t[17]=O);let k;t[18]===s?k=t[19]:(k=s?{onEditMessage:s}:{},t[18]=s,t[19]=k);let j;t[20]!==u||t[21]!==o||t[22]!==D||t[23]!==r||t[24]!==a.active||t[25]!==a.surfaceID||t[26]!==O||t[27]!==k?(j={kind:`embedded`,surfaceId:a.surfaceID,sessionId:r,directory:u,active:a.active,capabilities:O,onRevertMessage:o,...k,openSourceSession:D},t[20]=u,t[21]=o,t[22]=D,t[23]=r,t[24]=a.active,t[25]=a.surfaceID,t[26]=O,t[27]=k,t[28]=j):j=t[28];let M=j,N=p.isError||p.isSuccess&&!p.hasNextPage,P=p.isLoading||p.isFetchingNextPage,F;t[29]!==x||t[30]!==N||t[31]!==_||t[32]!==P?(F={entries:_,complete:N,loading:P,fetchPrevious:x},t[29]=x,t[30]=N,t[31]=_,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==u||t[35]!==l||t[36]!==o||t[37]!==c||t[38]!==r||t[39]!==M||t[40]!==a||t[41]!==F||t[42]!==i?(I={sessionId:r,directory:u,composerSurface:a,sessionSurface:M,warning:i,pendingUserMessages:c,onPendingUserMessagesMaterialized:l,assistantHistory:F,onRevertMessage:o},t[34]=u,t[35]=l,t[36]=o,t[37]=c,t[38]=r,t[39]=M,t[40]=a,t[41]=F,t[42]=i,t[43]=I):I=t[43];let L=I,R;return t[44]===L?R=t[45]:(R=(0,Y.jsx)(K,{autoOpenDraft:!1,host:L}),t[44]=L,t[45]=R),R},ke=class extends Error{constructor(){super(`assistant_selection_stale`)}},Ae=(e,t)=>e.assistantID===t.assistantID&&e.transportIdentity===t.transportIdentity&&e.runtimeGeneration===t.runtimeGeneration,je=class{onBusyChange;onError;flight=null;authoritativeIdentity=null;constructor(e,t){this.onBusyChange=e,this.onError=t}activate(e){this.authoritativeIdentity&&!Ae(this.authoritativeIdentity,e)&&this.flight&&this.retire(this.flight),this.authoritativeIdentity=e}enqueue(e,t,n){if(!this.isAuthoritative(e))return Promise.reject(new ke);let r=this.flight;r||(r={identity:e,controller:new AbortController,running:!1,desired:null,waiters:[],activeWaiters:[],idleWaiters:[],retired:!1},this.flight=r),r.desired=t;let i=new Promise((e,t)=>{r.waiters.push({resolve:e,reject:t})});return r.running||(r.running=!0,this.onBusyChange(!0),this.run(r,n)),i}async flush(e){if(!this.isAuthoritative(e))throw new ke;let t=this.flight;t?.running&&await new Promise((e,n)=>t.idleWaiters.push({resolve:e,reject:n}))}assertAuthoritative(e){if(!this.isAuthoritative(e))throw new ke}dispose(){this.flight&&this.retire(this.flight),this.authoritativeIdentity=null}async run(e,t){for(;!e.retired&&e.desired;){let n=e.desired;e.desired=null;let r=e.waiters.splice(0);e.activeWaiters=r;try{if(await t({identity:e.identity,selection:n,signal:e.controller.signal}),!e.retired)for(let e of r)e.resolve()}catch(t){if(!e.retired){this.onError(t);for(let e of r)e.reject(t)}}e.activeWaiters=[]}e.running=!1;for(let t of e.idleWaiters.splice(0))t.resolve();this.flight===e&&this.onBusyChange(!1)}retire(e){e.retired=!0,e.controller.abort();let t=new ke;for(let n of e.activeWaiters.splice(0))n.reject(t);for(let n of e.waiters.splice(0))n.reject(t);for(let n of e.idleWaiters.splice(0))n.reject(t);this.flight===e&&(this.flight=null,this.onBusyChange(!1))}isAuthoritative(e){return this.authoritativeIdentity!==null&&Ae(this.authoritativeIdentity,e)}},X=(e,t)=>{let n=t.providerID??e.providerID,r=t.modelID??e.modelID,i=n!==e.providerID||r!==e.modelID;return{enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:n,modelID:r,agent:t.agent??null,variant:i?null:t.variant??null,mode:e.mode}},Me=async(e,t,n)=>{n.assertAuthoritative();let r=n.readSnapshot()?.assistants.find(t=>t.id===e.assistantID);if(!r)throw Error(`assistant_unavailable`);try{n.assertAuthoritative(),await n.updateAssistant(r,X(r,t)),n.assertAuthoritative()}catch(i){if(n.assertAuthoritative(),n.signal.aborted)throw new ke;if(!(i instanceof B)||i.code!==`revision_conflict`)throw i;if(n.assertAuthoritative(),r=(await n.ensureSnapshot(n.signal)).assistants.find(t=>t.id===e.assistantID),n.assertAuthoritative(),!r)throw new B(`revision_conflict`,409);n.assertAuthoritative(),await n.updateAssistant(r,X(r,t)),n.assertAuthoritative()}};async function Z(e){await L(e);let t=ue.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await R();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&ue.getState().setDefaultShareAssistant(null)}function Ne({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=g(),[a,o]=J.useState(!1),s=e?_(e.name).displayName||e.name:``,c=h(e=>{a&&!e||n(e)}),l=h(()=>{a||n(!1)}),u=h(async()=>{if(!(!e||a)){o(!0);try{await Z(e),r?.(e.id),n(!1),m.success(i(`assistants.settings.toast.deleted`))}catch{m.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,Y.jsx)(W,{open:t&&e!==null,onOpenChange:c,children:(0,Y.jsxs)(ge,{className:`max-w-md`,children:[(0,Y.jsxs)(V,{children:[(0,Y.jsx)(H,{children:i(`assistants.settings.delete`)}),(0,Y.jsx)(U,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,Y.jsxs)(he,{children:[(0,Y.jsx)(_e,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,Y.jsx)(_e,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var Pe=[0,500,1500,4e3],Fe=(e,t,n)=>{let r=!1,i=e.map(e=>e.info.id!==t||e.info.sessionID===n?e:(r=!0,{...e,info:{...e.info,sessionID:n}}));return r?i:e},Ie=e=>{let t=e.refreshDelaysMs??Pe,n=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));(async()=>{for(let r of t){if(r>0&&await n(r),!e.isCurrent())return;try{await e.refresh(e.binding);break}catch{}}})()},Le=e=>`${e.transport}\u0000${e.assistantID}`,Re=e=>({transport:e.transport,assistantID:e.assistantID}),ze=(e,t)=>e.assistantID===t.assistantID&&e.sessionID===t.sessionID&&e.directory===t.directory&&e.sessionGeneration===t.sessionGeneration&&e.transport===t.transport&&e.runtimeGeneration===t.runtimeGeneration,Be=(e,t)=>e.assistantID===t.assistantID&&e.sessionID===t.sessionID&&e.directory===t.directory&&e.sessionGeneration===t.sessionGeneration&&e.messageID===t.messageID&&e.transport===t.transport&&e.runtimeGeneration===t.runtimeGeneration,Ve=()=>{let e=new Map,t=new Map,n=1,r=e=>Le(e),i=async(e,n)=>{let i=r(e),a=t.get(i)??Promise.resolve(),o,s=new Promise(e=>{o=e}),c=a.catch(()=>void 0).then(()=>s);t.set(i,c),await a.catch(()=>void 0);try{return await n()}finally{o(),t.get(i)===c&&t.delete(i)}},a=(t,i)=>{let a=r(Re(t)),o=n++;return e.set(a,{identity:t,rollback:i,token:o}),o},o=t=>e.get(r(t))?.identity,s=t=>e.delete(r(t)),c=async e=>i(e,()=>s(e)),l=async t=>{let n=r(t),i=e.get(n);if(!i)return{kind:`none`};let a=i.token,o=i.identity,s;try{s=await i.rollback()}catch{return{kind:`blocked`,status:`failed`}}let c=e.get(n);return!c||c.token!==a||!Be(c.identity,o)?{kind:`superseded`}:s.status===`rolled-back`||s.status===`conflict`?(e.delete(n),{kind:`cleared`,status:s.status}):{kind:`blocked`,status:s.status}},u=async(t,n)=>{let i=r(t),a=e.get(i);if(!a)return{kind:`none`};if(ze(a.identity,n))return{kind:`match`};let o=a.token,s=a.identity,c=await a.rollback(),l=e.get(i);return!l||l.token!==o||!Be(l.identity,s)?{kind:`superseded`}:c.status===`rolled-back`||c.status===`conflict`?(e.delete(i),{kind:`cleared`,status:c.status}):{kind:`rollback_failed`,retained:!0,status:c.status}};return{register:a,read:o,clear:s,clearExclusive:c,retireCurrent:l,rollbackAndClearIfBindingMismatch:async(e,t)=>i(e,()=>u(e,t)),rollbackAllBestEffort:async t=>{let n=[...e.entries()];await Promise.all(n.map(async([,n])=>{if(t?.excludeTransport!==void 0&&n.identity.transport===t.excludeTransport)return;let a=Re(n.identity);await i(a,async()=>{let t=r(a),i=e.get(t);if(!i||i.token!==n.token)return;let o=i.token,s=i.identity;try{let n=await i.rollback(),r=e.get(t);if(!r||r.token!==o||!Be(r.identity,s))return;(n.status===`rolled-back`||n.status===`conflict`)&&e.delete(t)}catch{}})}))},stageExclusive:async(e,t)=>i(e,async()=>{let n=await l(e);if(n.kind===`blocked`)return{kind:`blocked`,status:n.status};let r=await t();if(!r)return{kind:`skipped`};let i=a(r.identity,r.rollback);return r.protectOnStale?{kind:`stale_protected`,token:i,identity:r.identity}:{kind:`registered`,token:i,identity:r.identity}})}},He=(e,t)=>!e?.attachments?.length||!t?[]:e.attachments.flatMap(e=>{let n=t[e.attachmentRefID];return n?[n]:[]}),Ue=(e,t)=>{let n=t??{};return e.map(e=>({partID:e.partID,text:e.text,...e.synthetic===!0?{synthetic:!0}:{},attachments:e.attachments.flatMap(e=>n[e.attachmentRefID]?[n[e.attachmentRefID]]:[])}))},We=(e,t)=>{if(t.length===0)return[...e];let n=new Map;for(let t of e)n.set(t.partID,t);for(let e of t)n.set(e.partID,e);let r=new Set,i=[];for(let t of e){let e=n.get(t.partID);e&&(i.push(e),r.add(t.partID))}for(let e of t)r.has(e.partID)||(i.push(e),r.add(e.partID));return i},Ge=t({AssistantView:()=>Qe}),Ke={},qe=[],Je=[],Ye=(e,t,n)=>[...e===void 0?[]:[{type:`text`,text:e}],...(t??[]).flatMap(e=>[{type:`text`,text:e.text,...e.synthetic===!0?{synthetic:!0}:{}},...(e.attachments??[]).map(e=>({type:`file`,mime:e.mimeType,url:e.dataUrl}))]),...(n??[]).map(e=>({type:`file`,mime:e.mimeType,url:e.dataUrl}))],Xe=e=>{let t=(0,q.c)(11),{assistant:n,onBack:r}=e,{t:i}=g(),a;t[0]===n?a=t[1]:(a=n?_(n.name):null,t[0]=n,t[1]=a);let o=a,s=n&&o?o.displayName||n.name:``,c;t[2]!==s||t[3]!==i?(c=s||i(`assistants.title`),t[2]=s,t[3]=i,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i(`assistants.actions.backToChat`),t[5]=i,t[6]=l);let u;return t[7]!==r||t[8]!==c||t[9]!==l?(u=(0,Y.jsx)(z,{title:c,backAriaLabel:l,onBack:r}),t[7]=r,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Ze=e=>{let t=(0,q.c)(45),{assistantID:n,displayName:r,avatarEmoji:i,modeLabel:a,selected:o,enabled:s,editLabel:c,deleteLabel:l,onSelect:u,onEdit:d,onDelete:f}=e,[p,m]=J.useState(!1),g;t[0]===u?g=t[1]:(g=()=>u(),t[0]=u,t[1]=g);let _=h(g),v;t[2]===d?v=t[3]:(v=()=>{m(!1),d()},t[2]=d,t[3]=v);let y=h(v),b;t[4]===f?b=t[5]:(b=()=>{m(!1),f()},t[4]=f,t[5]=b);let x=h(b),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e.preventDefault(),m(!0)},t[6]=S):S=t[6];let C=o?`border-border/50 bg-[var(--surface-elevated)]`:`border-transparent hover:bg-interactive-hover`,w=!s&&`opacity-65`,T;t[7]!==C||t[8]!==w?(T=pe(`flex w-full min-h-11 items-center gap-3 rounded-xl border px-3 py-3 text-left outline-none transition-[background-color,border-color,transform,opacity] duration-150 ease-out active:scale-[0.995] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,C,w),t[7]=C,t[8]=w,t[9]=T):T=t[9];let E;t[10]!==_||t[11]!==o||t[12]!==T?(E=(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":o,onClick:_,onContextMenu:S,className:T}),t[10]=_,t[11]=o,t[12]=T,t[13]=E):E=t[13];let D;t[14]!==n||t[15]!==i||t[16]!==r?(D=(0,Y.jsx)(fe,{name:n,emoji:i,size:24,label:r}),t[14]=n,t[15]=i,t[16]=r,t[17]=D):D=t[17];let O;t[18]===r?O=t[19]:(O=(0,Y.jsx)(`span`,{className:`block truncate typography-ui-label font-medium`,children:r}),t[18]=r,t[19]=O);let k;t[20]===a?k=t[21]:(k=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate typography-micro text-muted-foreground`,children:a}),t[20]=a,t[21]=k);let A;t[22]!==O||t[23]!==k?(A=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[O,k]}),t[22]=O,t[23]=k,t[24]=A):A=t[24];let j;t[25]!==A||t[26]!==E||t[27]!==D?(j=(0,Y.jsxs)(Ce,{render:E,children:[D,A]}),t[25]=A,t[26]=E,t[27]=D,t[28]=j):j=t[28];let M;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Y.jsx)(me,{name:`edit`,className:`size-4`}),t[29]=M):M=t[29];let N;t[30]!==c||t[31]!==y?(N=(0,Y.jsxs)(Ee,{onClick:y,children:[M,c]}),t[30]=c,t[31]=y,t[32]=N):N=t[32];let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Y.jsx)(we,{}),t[33]=P):P=t[33];let F;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Y.jsx)(me,{name:`delete-bin`,className:`size-4`}),t[34]=F):F=t[34];let I;t[35]!==l||t[36]!==x?(I=(0,Y.jsxs)(Ee,{onClick:x,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,children:[F,l]}),t[35]=l,t[36]=x,t[37]=I):I=t[37];let L;t[38]!==N||t[39]!==I?(L=(0,Y.jsxs)(Te,{className:`min-w-[10rem]`,children:[N,P,I]}),t[38]=N,t[39]=I,t[40]=L):L=t[40];let R;return t[41]!==p||t[42]!==j||t[43]!==L?(R=(0,Y.jsxs)(De,{open:p,onOpenChange:m,children:[j,L]}),t[41]=p,t[42]=j,t[43]=L,t[44]=R):R=t[44],R},Qe=({activeOverride:e,onMobileBack:t})=>{let{t:u}=g(),{isMobile:d}=ve(),f=xe(),p=J.useSyncExternalStore(n,r,r),S=a(),E=i(e=>e.activeMainTab===`assistant`),A=e??E,L=i(e=>e.isMobile),R=d||L,z=I(),ce=le(),B=ce.data,V=ue(e=>e.assistantByTransport[p]??null),he=ue(e=>e.selectAssistant),ge=ue(e=>e.requestCreate),H=B?.assistants.find(e=>e.id===V)??null,U=H?.id??``,W=H?.sessionID??``,G=H?.effectiveWorkspacePath??``,K=J.useMemo(()=>o({transportIdentity:p},`assistant:${U}`),[U,p]),Ce=l(K),we=b(e=>e.draftAttachmentViews[Ce]??Ke),Te=b(e=>e.drafts[Ce]),Ee=J.useMemo(()=>{let e=He(Te,we);return e.length===0?qe:e},[we,Te]),De=Te?.attachments,q=Te?.syntheticParts,Ae=J.useMemo(()=>!De||!q?``:`${De.map(e=>e.attachmentRefID).join(``)}\u0004${q.map(e=>`${e.partID}\u0002${e.attachments.map(e=>e.attachmentRefID).join(``)}`).join(``)}`,[De,q]);J.useEffect(()=>{U&&b.getState().hydrateDraftAttachments(K)},[U,K,Ae]);let X=F(G||null,{enabled:!!G&&A}),Z=D(G||null,{enabled:!!G&&A}),Pe=N(W,G||void 0),Le=O(W,G||void 0),ze=j(W),Be=ye(),[Ge,Qe]=J.useState(()=>new Map),$e=J.useRef(0),et=J.useRef(Ve()),tt=Ge.get(U)??Je,[,nt]=J.useState(!1),rt=J.useRef(()=>{});rt.current=()=>{m.error(u(`assistants.composer.selectionSaveFailed`))};let it=J.useRef(null);it.current||=new je(nt,e=>rt.current(e));let at=J.useMemo(()=>({assistantID:U,transportIdentity:p,runtimeGeneration:S}),[U,S,p]),Q=it.current,ot=J.useMemo(()=>({transport:p,assistantID:U}),[U,p]),st=h(async(e,t=p)=>{await et.current.clearExclusive({transport:t,assistantID:e})}),ct=h(e=>{et.current.rollbackAllBestEffort(e).catch(()=>void 0)});J.useEffect(()=>{!V&&B?.assistants[0]&&he(B.assistants[0].id)},[he,V,B?.assistants]),J.useEffect(()=>{ce.isSuccess&&V&&!H&&he(B?.assistants[0]?.id??null)},[H,he,V,B?.assistants,ce.isSuccess]),J.useEffect(()=>{A&&U&&!W&&ae(U)},[A,U,W]),J.useEffect(()=>{$e.current++,Qe(new Map),ct({excludeTransport:p})},[p,S,ct]),J.useEffect(()=>()=>{$e.current++,ct()},[ct]),J.useEffect(()=>{Q.activate(at)},[Q,at]),J.useEffect(()=>()=>{Q.dispose()},[Q]),J.useEffect(()=>{U&&et.current.rollbackAndClearIfBindingMismatch(ot,{assistantID:U,sessionID:W,directory:G,sessionGeneration:H?.sessionGeneration??-1,transport:p,runtimeGeneration:S}).catch(()=>void 0)},[H?.sessionGeneration,U,G,S,W,ot,p]);let lt=h(e=>at.assistantID?Q.enqueue(at,e,async({identity:e,selection:t,signal:n})=>{await Me(e,t,{readSnapshot:()=>te(void 0,e.transportIdentity),ensureSnapshot:e=>re(e),updateAssistant:ne,signal:n,assertAuthoritative:()=>{if(Q.assertAuthoritative(e),r()!==e.transportIdentity||a()!==e.runtimeGeneration)throw new ke}})}):Promise.reject(Error(`assistant_unavailable`))),ut=J.useMemo(()=>Se(Z.data),[Z.data]),dt=h(e=>{if(!H)return;let t=x(ut,H.agent??void 0,e);if(t){let e=T({providerID:H.providerID,modelID:H.modelID,agent:H.agent},t,ut,X.data??[]),n=e.providerID===H.providerID&&e.modelID===H.modelID;lt({...e,agent:e.agent??void 0,variant:n?H.variant??void 0:void 0})}}),$=h(async(e,t)=>{e.sessionID&&await Be.ensureSessionRenderable(e.sessionID,{directory:e.directory,...t?.force?{force:!0}:{}})}),ft=H?.sessionGeneration;J.useEffect(()=>{!A||!U||!W||!G||ft===void 0||$({sessionID:W,directory:G,sessionGeneration:ft},{force:!0})},[A,U,G,$,ft,W]);let pt=h((e,t)=>{if(t.length===0)return;let n=new Set(t);Qe(t=>{let r=t.get(e);if(!r?.some(e=>n.has(e.info.id)))return t;let i=new Map(t),a=r.filter(e=>!n.has(e.info.id));return a.length>0?i.set(e,a):i.delete(e),i})}),mt=h((e,t,n)=>{Qe(r=>{let i=r.get(e);if(!i)return r;let a=Fe(i,t,n);if(a===i)return r;let o=new Map(r);return o.set(e,a),o})}),ht=h(e=>{pt(U,e)}),gt=h(async e=>{if(!W||!G)throw Error(`assistant_unavailable`);P(W,G).some(t=>t?.id===e)&&(await w(W,e,{directory:G,draftKey:K,restorePrimaryInput:!1}),await st(U))}),_t=h(async(e,t)=>{if(!H||H.mode!==`continuous`)return;if(!W||!G)throw Error(`assistant_unavailable`);if(!P(W,G).some(t=>t?.id===e))return;if(t.info.id!==e||t.info.sessionID!==W||t.info.role!==`user`)throw Error(`The selected user message is unavailable`);let n={assistantID:H.id,sessionID:W,directory:G,sessionGeneration:H.sessionGeneration,messageID:e,transport:p,runtimeGeneration:S},i=Re(n),o=await et.current.stageExclusive(i,async()=>{let i=await k(W,e,t,{directory:G,draftKey:K}),o=r()===n.transport&&a()===n.runtimeGeneration,s=o?te(void 0,n.transport)?.assistants.find(e=>e.id===n.assistantID):void 0,c=!!(s&&s.mode===`continuous`&&s.sessionID===n.sessionID&&s.sessionGeneration===n.sessionGeneration&&(s.effectiveWorkspacePath??``)===n.directory);if(o&&c)return{identity:n,rollback:()=>i.rollback()};let l=await i.rollback();return l.status===`failed`||l.status===`skipped`?{identity:n,rollback:()=>i.rollback(),protectOnStale:!0}:null});if(o.kind===`blocked`)throw Error(`assistant_stage_message_edit_prior_blocked`);if(o.kind===`stale_protected`)throw Error(`assistant_stage_message_edit_rollback_failed`)}),vt=J.useMemo(()=>{let e=C(K,()=>b.getState());return{busy:!1,attachments:Ee,addAttachment:t=>e.addLocal(t),removeAttachment:t=>e.removeByAttachmentID(t),clearAttachments:()=>e.clearRootAttachments(),restoreAttachments:t=>e.restoreRootAttachments(t),pendingInput:null,consumePendingInput:()=>null,pendingPreset:null,consumePendingPreset:()=>null,consumeSyntheticParts:()=>{let e=b.getState(),t=e.draftAttachmentViews[l(K)]??Ke,n=e.consumeDraftSyntheticParts(K,y);return n?Ue(n,t):null},restoreSyntheticParts:e=>{(async()=>{let t=b.getState(),n=e.map(e=>({partID:e.partID??s(),text:e.text,attachments:[],...e.synthetic===!0?{synthetic:!0}:{}})),r=We(t.getDraft(K)?.syntheticParts??[],n);t.setDraftSyntheticParts(K,r);for(let r=0;r<n.length;r++){let i=n[r].partID;for(let n of e[r]?.attachments??[])n.source===`server`&&n.dataUrl?t.addDraftDurableAttachment(K,{attachmentID:n.id,filename:n.filename,mimeType:n.mimeType,size:n.size,source:`server`,url:n.dataUrl,serverPath:n.serverPath,partID:i}):await t.addDraftLocalAttachment(K,n.file,{attachmentID:n.id,filename:n.filename,source:n.source===`vscode`?`vscode`:`local`,vscodePath:n.vscodePath,vscodeSource:n.vscodeSource===`selection`?`selection`:void 0,partID:i})}})()},inlineDrafts:[],removeInlineDraft:()=>{},restoreInlineDrafts:()=>{},history:ze,captureRuntime:()=>b.getState().captureDraftRuntime(),getDraft:e=>b.getState().getDraft(e),abortPrompt:{sessionID:null,clear:()=>{}}}},[Ee,K,ze]),yt=J.useMemo(()=>{let e=(X.data??[]).find(e=>e.id===H?.providerID)?.models?.find(e=>e.id===H?.modelID);return be(e)},[H?.modelID,H?.providerID,X.data]),bt=Pe.length>0,xt=J.useMemo(()=>{if(!H||!W||!G)return null;let e={sessionID:W,directory:G,sessionGeneration:H.sessionGeneration};return{kind:`secondary`,surfaceID:`assistant:${H.id}`,active:A,sessionID:W,directory:G,draftKey:K,transportIdentity:p,runtimeGeneration:S,deliveryTarget:{kind:`assistant`,assistantID:H.id},resources:vt,...H.mode===`stateless`?{queueSessionID:`assistant:${H.id}`}:{},selection:{value:{providerID:H.providerID,modelID:H.modelID,agent:H.agent??void 0,variant:H.variant??void 0},catalog:{providers:X.data??[],agents:ut,variants:yt,variantsReady:X.isSuccess,ready:X.isSuccess&&Z.isSuccess,loading:X.isPending||Z.isPending,error:X.isError||Z.isError},change:lt,flush:()=>Q.flush(at)},activity:{phase:Le?.type===`busy`?`busy`:Le?.type===`retry`?`retry`:`idle`,canAbort:Le?.type===`busy`||Le?.type===`retry`},commands:{sessionID:W,hasMessages:bt,hasNewDraft:!1},commandPolicy:e=>e.name!==`fork`&&e.name!==`thread`,backend:{send:async t=>{let n;for(let t of P(e.sessionID,e.directory)){let e=typeof t?.id==`string`?t.id:``;/^msg_[0-9a-f]{12}[0-9A-Za-z]{14}$/.test(e)&&(!n||e>n)&&(n=e)}let r=c(`msg`,n);t.options?.commitStagedMessageEdit&&et.current.clear({transport:p,assistantID:H.id});let i=M({messageID:r,sessionID:e.sessionID,providerID:t.providerID??H.providerID,modelID:t.modelID??H.modelID,agent:t.agent??H.agent??void 0,text:t.text,attachments:t.attachments,additionalParts:t.parts});Qe(e=>{let t=new Map(e);return t.set(H.id,[...e.get(H.id)??[],i]),t});let a;try{a=await oe(H.id,e,r,Ye(t.text,t.parts,t.attachments))}catch(e){throw pt(H.id,[r]),e}if(z.data?.serverInstanceID){let e=_(H.name);v({serverInstanceID:z.data.serverInstanceID,assistantID:H.id,name:e.displayName||H.name,avatarSeed:H.id,...e.avatarEmoji?{avatarEmoji:e.avatarEmoji}:{}}).catch(()=>void 0)}a.binding.sessionID&&mt(H.id,r,a.binding.sessionID);let o=$e.current;Ie({binding:a.binding,refresh:t=>$(t,{force:t.sessionID!==e.sessionID||t.sessionGeneration!==e.sessionGeneration}),isCurrent:()=>$e.current===o})},sendQueued:async()=>{throw Error(`assistant-server-queue-required`)},create:async()=>{let e=await ee(H.id);await st(H.id),await $(e,{force:!0})},compact:async()=>{let t=await se(H.id,e);await st(H.id),await $(t.binding,{force:!0})},abort:async()=>{await ie(H.id,e)}},shortcuts:{cycle:dt,new:async()=>{let e=await ee(H.id);await st(H.id),await $(e,{force:!0})},abort:async()=>{await ie(H.id,e)},submit:()=>{}}}},[A,H,z.data?.serverInstanceID,lt,st,dt,G,K,bt,X.data,X.isError,X.isPending,X.isSuccess,Z.isError,Z.isPending,Z.isSuccess,$,mt,pt,vt,S,Q,at,W,Le,p,yt,ut]),St=h(()=>{if(ge(),f){f.openSettings();return}let e=i.getState();e.setSettingsPage(`assistants`),e.setSettingsDialogOpen(!0)}),Ct=h(e=>{de(e,f?{openMobileSettings:f.openSettings}:void 0)}),[wt,Tt]=J.useState(null),Et=h(e=>{Tt(e)}),Dt=h(e=>{e||Tt(null)}),Ot=h(()=>{i.getState().setActiveMainTab(`chat`)}),kt=h(()=>{if(t){t();return}Ot()}),At=(e,t,n,r)=>(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[R?(0,Y.jsx)(Xe,{assistant:H,onBack:kt}):null,(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:[(0,Y.jsx)(me,{name:e,className:`size-6 text-muted-foreground`}),(0,Y.jsx)(`h1`,{className:`mt-4 typography-ui-header font-semibold`,children:t}),n?(0,Y.jsx)(`p`,{className:`mt-2 max-w-md typography-ui text-muted-foreground`,children:n}):null,r?(0,Y.jsx)(`div`,{className:`mt-5`,children:r}):null]})]});if(z.isPending||ce.isPending)return At(`ai-agent`,u(`assistants.state.unavailable`));if(z.isError||!z.data?.supported||!z.data.enabled||!B?.enabled)return At(`cloud-off`,u(`assistants.state.unavailable`));if(!B.assistants.length)return At(`ai-agent`,u(`assistants.onboarding.title`),u(`assistants.onboarding.description`),(0,Y.jsx)(_e,{onClick:St,children:u(`assistants.onboarding.action`)}));if(!H)return At(`ai-agent`,u(`assistants.state.unavailable`));if(!xt)return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[R?(0,Y.jsx)(Xe,{assistant:H,onBack:kt}):null,(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 px-6`,"aria-busy":`true`,"aria-label":u(`assistants.state.unavailable`),children:[(0,Y.jsx)(`div`,{className:`size-10 animate-pulse rounded-xl bg-[var(--surface-muted)] motion-reduce:animate-none`}),(0,Y.jsx)(`div`,{className:`h-3.5 w-36 animate-pulse rounded-md bg-[var(--surface-muted)] motion-reduce:animate-none`})]})]});let jt=_(H.name),Mt=H.enabled?ce.isError?u(`assistants.state.staleSnapshot`):null:u(`assistants.state.assistantDisabled`);return(0,Y.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden bg-background`,"data-presentation":`workspace`,children:[R?null:(0,Y.jsxs)(`section`,{className:`flex h-full min-h-0 w-[clamp(16rem,22vw,20rem)] shrink-0 flex-col overflow-hidden`,children:[(0,Y.jsx)(`header`,{className:`shrink-0 px-4 pb-3 pt-4 sm:px-5`,children:(0,Y.jsx)(`h1`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:u(`assistants.title`)})}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 sm:px-4`,role:`listbox`,"aria-label":u(`assistants.listAria`),children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 border-t border-border/40 pt-3`,children:B.assistants.map(e=>{let t=e.id===V,n=_(e.name);return(0,Y.jsx)(Ze,{assistantID:e.id,displayName:n.displayName,avatarEmoji:n.avatarEmoji??void 0,modeLabel:e.mode===`stateless`?u(`assistants.mode.stateless`):u(`assistants.mode.continuous`),selected:t,enabled:e.enabled,editLabel:u(`assistants.menu.edit`),deleteLabel:u(`assistants.settings.delete`),onSelect:()=>he(e.id),onEdit:()=>Ct(e.id),onDelete:()=>Et(e)},e.id)})})})]}),(0,Y.jsx)(Ne,{assistant:wt,open:wt!==null,onOpenChange:Dt}),(0,Y.jsxs)(`div`,{className:pe(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,!R&&`border-l border-border/60`),children:[R?(0,Y.jsx)(Xe,{assistant:H,onBack:kt}):(0,Y.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-3 border-b border-border/40 px-4 sm:px-5`,children:[(0,Y.jsx)(fe,{name:H.id,emoji:jt.avatarEmoji,size:24,label:jt.displayName||H.name}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate typography-ui-label font-medium`,children:jt.displayName}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate typography-micro leading-none text-muted-foreground/70`,children:H.mode===`stateless`?u(`assistants.conversation.statelessHint`):u(`assistants.conversation.continuousHint`)})]})]}),(0,Y.jsx)(Oe,{onRevertMessage:gt,onEditMessage:H.mode===`continuous`?_t:void 0,assistant:H,sessionID:W,warning:Mt,surface:xt,pendingUserMessages:tt,onPendingUserMessagesMaterialized:ht})]})]})};export{Ge as n,Ne as r,Qe as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{E as t,t as n}from"./useUIStore-DzwCfRqr.js";import{nt as r,rt as i}from"./vendor-base-ui-CnHfUmDN.js";import{l as a}from"./vendor-tanstack-react-query-D7pys_c9.js";import{r as o}from"./vendor-sonner-DVzioF3d.js";import{n as s}from"./clipboard-DWuULPzo.js";import{n as c}from"./Icon-DpjYnXxn.js";import{n as l}from"./useRuntimeAPIs-DSLXJybW.js";import{n as u}from"./useEffectiveDirectory-ByQPsbk0.js";import{n as d,r as f,t as p}from"./fileQueries-BrUKKgPW.js";import{t as m}from"./diagram-CHfginjS.js";var h=e(i(),1),g=r();function _(){let{t:e}=s(),{files:r}=l(),i=a(),_=u()??null,v=t(),[y,b]=h.useState(null),[x,S]=h.useState(``),C=h.useRef(null),w=h.useRef(!1),T=h.useRef(null),E=h.useRef(0),D=h.useRef(Promise.resolve()),O=n(e=>e.pendingDiagramFile),k=f({scopeDirectory:_,path:y},{enabled:!!y});if(y&&(T.current?.path!==y||T.current.transport!==v||T.current.scopeDirectory!==_)){let e=E.current+1;E.current=e,T.current={path:y,generation:e,transport:v,scopeDirectory:_}}h.useEffect(()=>(w.current=!0,()=>{w.current=!1,E.current+=1}),[]),h.useEffect(()=>{if(!O)return;let e=n.getState().consumePendingDiagramFile();if(e){let t=E.current+1;E.current=t,T.current={path:e,generation:t,transport:v,scopeDirectory:_},b(e)}},[_,O,v]),h.useEffect(()=>{let e=T.current;if(!(!e||e.path!==y||e.transport!==v||e.scopeDirectory!==_)){if(k.data!==void 0){S(k.data);return}k.isError&&S(``)}},[_,y,k.data,k.isError,v]);let A=h.useCallback(async()=>{let t=C.current?.getXml(),n=T.current,a=r?.writeFile;if(!y||!a||!t||t===x||n?.path!==y)return;let{path:s,generation:c,scopeDirectory:l,transport:u}=n,f=D.current.then(async()=>{try{if(!(await a(s,t))?.success)throw Error(e(`filesView.toast.writeFileFailed`));let n={scopeDirectory:l,path:s};await i.cancelQueries({queryKey:p(n,u),exact:!0}),d(i,n,u,t);let r=T.current;w.current&&r?.path===s&&r.generation===c&&r.transport===u&&r.scopeDirectory===l&&S(t)}catch(t){o.error(t instanceof Error?t.message:e(`filesView.toast.saveFailed`))}});D.current=f.catch(()=>void 0),await f},[y,r,i,e,x]),j=y?y.split(`/`).pop()||y:``;return y?k.isPending?(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center p-3`,children:(0,g.jsx)(c,{name:`loader-4`,className:`size-4 animate-spin`})}):(0,g.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/30 px-3 py-1.5`,children:[(0,g.jsx)(c,{name:`file`,className:`size-4 shrink-0 text-muted-foreground`}),(0,g.jsx)(`span`,{className:`typography-ui text-muted-foreground truncate flex-1`,children:j}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>void A(),className:`size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,title:e(`filesView.diagram.saveDiagram`),children:(0,g.jsx)(c,{name:`save-3`,className:`size-4`})}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>n.getState().setActiveMainTab(`chat`),className:`size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,title:e(`filesView.diagram.closeDiagramView`),children:(0,g.jsx)(c,{name:`close`,className:`size-4`})})]}),(0,g.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,g.jsx)(m,{ref:C,xml:x,className:`h-full`})})]}):(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center p-3`,children:(0,g.jsx)(`div`,{className:`typography-ui text-muted-foreground`,children:e(`filesView.editor.pickFileFromTree`)})})}export{_ as DiagramView};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-PzT84wSx.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,O as r,t as i,y as a}from"./useUIStore-DzwCfRqr.js";import{$t as o,It as s,Lt as c,Xt as l,Yt as u,Zt as d,d as f,dn as p,en as m,et as h,kn as g,nn as _,p as v,r as y,s as b,tn as x,u as S,xn as C}from"./persistence-6sclr7B6.js";import{a as w,i as T,r as E}from"./vendor-zustand-B4dlGEM2.js";import{nt as D,rt as O,tt as k}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as A,Nt as j,n as M,t as N}from"./platform-CbeLpKPk.js";import{o as P}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as F}from"./vendor-react-DLPElpoQ.js";import{s as ee}from"./vendor-tanstack-react-query-D7pys_c9.js";import{t as I}from"./types-BuiqMmh_.js";import{A as L,G as R,H as z,K as te,L as ne,P as B,Q as re,T as ie,V,W as H,X as ae,Z as oe,a as se,g as ce,ht as le,lt as ue,mt as de,pt as fe,q as pe,st as U,tt as me}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{n as W}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as he,r as ge,t as _e}from"./clipboard-DWuULPzo.js";import{Eo as G,Fn as ve,Kn as ye,Rn as be,Un as xe,Va as Se,_r as Ce,br as K,l as we,oi as Te,pn as Ee,qn as De,zn as Oe}from"./useMobileNavigationStore-DLYb8f5L.js";import{r as ke,t as q}from"./utils-B1EK5zKa.js";import{n as J}from"./Icon-DpjYnXxn.js";import{n as Ae,o as je,t as Me}from"./dialog-DPS0W9eS.js";import{n as Ne,t as Y}from"./button-C7OXr4ae.js";import{L as Pe,_ as Fe,b as Ie,c as Le,n as Re,s as ze,u as Be}from"./gitApi-C_tpQa_z.js";import{A as Ve,N as He,S as Ue,a as We,g as Ge,h as Ke,l as qe,n as Je,o as Ye,r as Xe,t as Ze,v as Qe,x as $e}from"./projectMeta-CYvQd9iC.js";import{t as et}from"./input-BzYA603C.js";import{i as tt,n as nt,t as rt}from"./tooltip-D_orJMYd.js";import{B as it,F as at,G as ot,H as st,P as ct,V as lt,X as ut,d as dt,f as ft,l as pt,o as mt,r as ht,z as gt}from"./useSessionAutoCleanup-C5knpuh5.js";import{n as _t}from"./useThemeSystem-DMzWVJaW.js";import{D as vt,O as yt,P as bt,d as xt,l as St,p as Ct,u as wt}from"./radio-CEt2UjvA.js";import{i as Tt,n as Et}from"./OverlayScrollbar-Ch3J6ASR.js";import{i as Dt}from"./appThemeRegistry-CN1tLL9G.js";import{a as Ot}from"./url-BsaBG5-1.js";import{r as kt}from"./markdown-worker-W06-MhF5.js";import{n as At,r as jt,t as Mt}from"./collapsible-DaEya6b6.js";import{a as Nt,d as Pt,o as Ft,s as It}from"./vendor-codemirror-commands-C9DCaJ0C.js";import{a as Lt,c as Rt,i as zt,o as Bt,r as Vt,s as Ht}from"./vendor-codemirror-search-D2SOgzph.js";import{n as Ut,t as Wt}from"./vendor-replit-codemirror-vim-CEibx3EP.js";import{i as Gt,n as Kt,r as qt,t as Jt}from"./projectActions-CWvNGKfA.js";var Yt=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],X=F(),Z=D();function Xt(e){let t=(0,X.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Z.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var Q=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`);return n.length>1?n.replace(/\/+$/,``):n},Zt=()=>{let e=G.getState().getActiveProject?.();return Q(e?.path)??Q(j.getDirectory())},Qt=(e,t=n())=>f.mcp.configs(e,t),$t=(e,t=n())=>f.mcp.status(e,t),en=e=>e?j.getScopedApiClient(e):j.getApiClient(),tn=(e=Zt(),t=n())=>{let r=Q(e);return{queryKey:Qt(r,t),queryFn:async({signal:e})=>{let t=r?`?directory=${encodeURIComponent(r)}`:``,n=await g(`/api/config/mcp${t}`,{headers:r?{"x-opencode-directory":r}:void 0,signal:e});if(!n.ok)throw Error(`Failed to load MCP configs`);let i=await n.json();if(!Array.isArray(i))throw Error(`Invalid MCP configs response`);return i},staleTime:5e3,retry:2}},nn=(e,t=n())=>{let r=Q(e);return{queryKey:$t(r,t),queryFn:async()=>(await en(r).mcp.status({},{throwOnError:!0})).data,staleTime:2e3,retry:1}},rn=(e,t)=>{let n=(0,X.c)(9),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let i=r,a=G(un),o,s;if(n[2]!==a||n[3]!==e){let t=e===void 0?Q(a)??Q(j.getDirectory()):Q(e);s=ee,o=tn(t),n[2]=a,n[3]=e,n[4]=o,n[5]=s}else o=n[4],s=n[5];let c;return n[6]!==i.enabled||n[7]!==o?(c={...o,enabled:i.enabled},n[6]=i.enabled,n[7]=o,n[8]=c):c=n[8],s(c)},an=(e,t)=>{let n=(0,X.c)(7),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let i=r,a=A(dn),o=e===void 0?a:e,s;n[2]===o?s=n[3]:(s=nn(Q(o)),n[2]=o,n[3]=s);let c;return n[4]!==i.enabled||n[5]!==s?(c={...s,enabled:i.enabled},n[4]=i.enabled,n[5]=s,n[6]=c):c=n[6],ee(c)},on=(e=S,t=Zt(),r=n())=>e.getQueryData(Qt(Q(t),r))??[],sn=(e=S,t,r=n())=>e.getQueryData($t(Q(t),r))??{},cn=async(e,t,r)=>{let i=Q(t);return n()===r?e.fetchQuery({...tn(i,r),staleTime:0}):on(e,i,r)},ln=async(e,t,r)=>{let i=Q(t);return n()===r?e.fetchQuery({...nn(i,r),staleTime:0}):sn(e,i,r)};function un(e){return e.getActiveProject?.()?.path??null}function dn(e){return e.currentDirectory}var fn={},pn=(e,t=n())=>JSON.stringify([t,Q(e)]),mn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},hn=e=>{let t=Q(e);return t?j.getScopedApiClient(t):j.getApiClient()},gn=e=>Q(e===void 0?A.getState().currentDirectory:e),_n=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=pn(gn(e));return t().diagnosticsByDirectory[n]??fn},clearDiagnostic:(t,n,r)=>{let i=pn(gn(n),r);e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a),s=hn(i);try{await s.mcp.connect({name:t},{throwOnError:!0})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await ln(S,i,a),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a);await hn(i).mcp.disconnect({name:t},{throwOnError:!0}),await ln(S,i,a),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=(await hn(gn(t)).mcp.auth.start({name:e},{throwOnError:!0})).data?.authorizationUrl;if(!n)throw Error(`Authorization URL was not returned`);return n},completeAuth:async(t,r,i)=>{let a=gn(i),o=n(),s=pn(a,o);await hn(a).mcp.auth.callback({name:t,code:r},{throwOnError:!0}),await ln(S,a,o),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,s,t)}))},clearAuth:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a);await hn(i).mcp.auth.remove({name:t},{throwOnError:!0}),await ln(S,i,a),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)}))},testConnection:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a),s=hn(i),c=sn(S,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({name:t},{throwOnError:!0})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await ln(S,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({name:t},{throwOnError:!0})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await ln(S,i,a)}return l||e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)})),{status:f??sn(S,i,a)[t],error:l,warning:u}}}))),$=e(O(),1),vn=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,yn=()=>vn(`1.18.5`),bn=(e,t)=>vn(t)||vn(e),xn=(e,t)=>{let n=vn(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},Sn=async()=>{let e=yn();if(!M())return e;try{let{App:t}=await P(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return bn((await t.getInfo()).version,e)}catch{return e}},Cn=async()=>{if(!M())return null;try{let{App:e}=await P(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.getInfo(),n=typeof t.build==`string`?t.build.trim():``;if(n.length===0)return null;let r=Number.parseInt(n,10);return Number.isFinite(r)?r:null}catch{return null}},wn=`https://openchamber.xiaobe.top/v1/update/check`,Tn=`https://openchamber-update.vercel.app/v1/update/check`,En=`https://github.com/yee94/openchamber/releases/latest`,Dn=`https://github.com/yee94/openchamber/releases`,On=`https://testflight.apple.com/join/ZCENBHtm`,kn=1e4;function An(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function jn(e,t){let n=An(e),r=An(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Mn(){return[wn,Tn]}function Nn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Pn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Fn(e,t,n,r){try{if(M())try{let{CapacitorHttp:r}=await P(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function In(e,t){return e===`ios`?On:`${Dn}/download/v${t}/app-release.apk`}function Ln(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=jn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Dn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():In(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Rn(e,t,n,r){let i=await Fn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Pn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Ln(a,t.currentVersion,t.platform)}async function zn(e,t,n,r){let i=await Fn(En,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:En,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=jn(s,e),l=`${Dn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:In(t,s)}}async function Bn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Mn(),a=r()+kn;for(let[t,o]of i.entries()){let s=Nn(a,i.length-t+1,r);if(s===null)break;let c=await Rn(o,e,s,n);if(c)return c}let o=Nn(a,1,r);if(o!==null){let r=await zn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Vn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Et();return e}catch{return`unknown`}}function Hn(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function Un(){let e=N();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function Wn(e){let t=i.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Vn()),n.set(`arch`,Hn()),n.set(`platform`,Un()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,u()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function Gn(e,t){let n=t??`unknown`;try{let r=Wn(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let a=await g(`/api/openchamber/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=null;try{o=await a.json()}catch{o=null}if(!a.ok)return{available:!1,currentVersion:n,error:typeof o?.error==`string`&&o.error.trim().length>0?o.error.trim():`Server responded with ${a.status}`};if(!o)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let s=typeof o.error==`string`&&o.error.trim().length>0?o.error.trim():void 0;return{available:o.available===!0,version:typeof o.version==`string`?o.version:void 0,currentVersion:typeof o.currentVersion==`string`?o.currentVersion:n,body:typeof o.body==`string`?o.body:void 0,releaseUrl:typeof o.releaseUrl==`string`?o.releaseUrl:void 0,downloadUrl:typeof o.downloadUrl==`string`?o.downloadUrl:void 0,nextSuggestedCheckInSec:typeof o.nextSuggestedCheckInSec==`number`&&Number.isFinite(o.nextSuggestedCheckInSec)?o.nextSuggestedCheckInSec:void 0,packageManager:typeof o.packageManager==`string`?o.packageManager:void 0,updateCommand:typeof o.updateCommand==`string`?o.updateCommand:void 0,error:s}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function Kn(){return M()?`mobile`:d()?`desktop`:o()?`vscode`:m()?`web`:null}var qn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function Jn(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var Yn=w()((e,t)=>({...qn,checkForUpdates:async()=>{let n=Kn();if(!n)return null;e({checking:!0,error:null,runtimeType:n});try{let r=null,a=null;if(n===`desktop`){let t=await s(),n=t?.downloaded===!0;return e({checking:!1,available:t?.available??!1,downloaded:n,...n?{downloading:!1,progress:null}:{},info:t,error:null,lastChecked:Date.now(),nextCheckInSec:null}),a}if(n===`web`)r=await Gn(`web`),a=r?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await Gn(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await Sn()??`unknown`,o=M()?C()?.mobileUpdates:void 0,s=i.getState().otaChannelOverride;if(o)try{let r=t().lastOtaChannelOverride!==s;e(r?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let i=await o.checkForOtaUpdate(s===`beta`||s===`stable`?{channelOverride:s}:void 0),a=Jn(i,n),c=(r?void 0:t().otaDecision?.ota.bundle?.bundleId)!==i.ota.bundle?.bundleId,l=!r&&t().downloaded&&!c;return e({checking:!1,available:a.available,info:a.info,error:a.info.error??null,lastChecked:Date.now(),nextCheckInSec:i.nextCheckInSec,otaDecision:i,otaPhase:l?`pending_restart`:a.otaPhase,lastOtaChannelOverride:s,...c||r?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),i.nextCheckInSec}catch(t){if(!(t instanceof I)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:s}),null}}return r=await Bn({currentVersion:n,platform:Un()===`ios`?`ios`:`android`,deviceClass:Vn(),arch:Hn(),reportUsage:i.getState().reportUsage}),a=r?.nextSuggestedCheckInSec??null,e({checking:!1,available:r?.available??!1,info:r,error:r?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:r?.available??!1,info:n===`vscode`?null:r,error:n===`vscode`?null:r?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(t){return e({checking:!1,error:t instanceof Error?t.message:`Failed to check for updates`}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=C()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=await s();if(!n?.available)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...n,body:e.info.body||n.body,available:e.info.available}:n})),n.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(n.downloading&&e({downloading:!0,progress:n.progress??{downloaded:0}}),!await c(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!d())return()=>{};let n=[],r=await x(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await _(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=C()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await p())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{let n=t();(n.runtimeType!==`mobile`||n.otaPhase!==`pending_restart`)&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(qn)}})),Xn=`https://github.com/yee94/openchamber/releases`;function Zn(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(ge(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Qn(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function $n(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function er(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function tr(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var nr=2e3,rr=6e5;async function ir(){try{let e=await g(`/api/openchamber/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function ar(){try{return(await g(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function or(e,t=Math.ceil(rr/nr),n=nr){for(let r=0;r<t;r++){try{let t=await g(`/api/openchamber/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await ar())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var sr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=he(),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(`idle`),[h,g]=(0,$.useState)(null),_=Yn(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${Xn}/tag/v${n.version}`:Xn),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`openchamber update`,D=W(e=>{!e&&w&&i&&Yn.getState().dismiss(),t(e)}),O=W(()=>{Yn.getState().dismiss(),t(!1)});(0,$.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await _e(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,$.useCallback)(async e=>{await Ot(e)},[]),j=(0,$.useCallback)(async()=>{m(`updating`),g(null);let e=await ir();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await or(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,$.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,$.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=tr(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:$n(e)};let r=[...t].sort((e,t)=>er(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:Zn(t.date),content:$n(Qn(t.raw)||e)}))}},[n?.body,u]);return(0,Z.jsx)(Me,{open:e,onOpenChange:N?void 0:D,children:(0,Z.jsxs)(Ae,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Z.jsxs)(je,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(J,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(J,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Z.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Z.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Z.jsx)(Ve,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Z.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Dt,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Z.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Z.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Z.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Dt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Z.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(J,{name:`terminal`,className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Z.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Z.jsx)(`button`,{onClick:k,className:q(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Z.jsx)(J,{name:`check`,className:`h-4 w-4`}):(0,Z.jsx)(J,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Z.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Z.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Z.jsx)(J,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Z.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Z.jsx)(J,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Z.jsxs)(Y,{onClick:s,size:`default`,children:[(0,Z.jsx)(J,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Z.jsxs)(Y,{onClick:()=>void A(v),size:`default`,children:[(0,Z.jsx)(J,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(Y,{disabled:!0,size:`default`,children:[(0,Z.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Z.jsx)(Y,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Z.jsxs)(Y,{onClick:c,size:`default`,children:[(0,Z.jsx)(J,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Z.jsxs)(Y,{onClick:M,size:`default`,children:[(0,Z.jsx)(J,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Z.jsxs)(Y,{onClick:j,size:`default`,children:[(0,Z.jsx)(J,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Z.jsxs)(Y,{disabled:!0,size:`default`,children:[(0,Z.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},cr=e(k(),1);function lr(e){let t=(0,X.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=q(`oc-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Z.jsx)(`div`,{className:`oc-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=q(`oc-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Z.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Z.jsx)(`p`,{className:`oc-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function ur(e){let t=(0,X.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Z.jsx)(dr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Z.jsx)(lr,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function dr(e){let t=(0,X.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=q(`oc-settings-group-row oc-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=q(`oc-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Z.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=q(`oc-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Z.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function fr(e){let t=(0,X.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=pr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=q(`oc-settings-group-row oc-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Z.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Z.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,Z.jsx)(He,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Z.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function pr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}function mr(e,t,n){return Math.min(n,Math.max(t,e))}function hr(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function gr(e,t){let n=hr(t);return n<=0?e:Number(e.toFixed(n))}var _r=$.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=he(),[h,g]=$.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Tt(),v=$.useRef(!1),y=$.useRef(null),b=$.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);$.useEffect(()=>()=>{y.current?.()},[]),$.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=$.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=$.useRef(x);$.useEffect(()=>{S.current=x},[x]);let C=$.useCallback(e=>{let a=gr(mr(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=$.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=$.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=gr(mr(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:q(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:q(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Z.jsx)(J,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:q(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:q(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Z.jsx)(J,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:q(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:q(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(J,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:q(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:q(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(J,{name:`add`,className:`block h-3.5 w-3.5`})})]})});_r.displayName=`NumberInput`;var vr=`/mcp/oauth/callback`,yr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},br=e=>{let t=Sr(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},xr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Sr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=yr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Cr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,wr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=Wt(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Cr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Tr(e){return e?[Ut(),me.of(wr),pe()]:[]}var Er={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Dr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Or(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Er)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Dr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var kr=new WeakMap;function Ar(e,t){let n=zt(e.state);if(!n.valid)return kr.delete(e),0;let r=kr.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return kr.set(e,{query:n,doc:e.state.doc,total:a}),a}function jr(e){let t=zt(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Mr(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Ar(t,n),o=a===0?0:jr(t);i.textContent=a===0?``:`${o}/${a}`}var Nr=new U,Pr=new U,Fr=new U,Ir=new U,Lr=new U,Rr=new U,zr=new U,Br=e=>e,Vr=ie,Hr=Lt,Ur=Vt,Wr=class extends te{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`oc-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},Gr=(e,t)=>!e||e.length===0?[]:le.define({create(n){let r=new fe,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,z.widget({widget:new Wr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>H.decorations.from(e)}),Kr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return R.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new fe;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,z.line({class:`oc-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function qr({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--oc-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__OPENCHAMBER_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=ue.create({doc:g.current,extensions:[...e?[H.cspNonce.of(e)]:[],ae({fixed:!0}),Nr.of(re(a)),Ft(),L.of(` `),zr.of(Tr(p)),oe.of([Pt,...Nt,...It]),H.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=Rt(e.startState),n=Rt(e.state);t!==n&&b.current?.(n);let r=!zt(e.startState).eq(zt(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Mr(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Pr.of(H.editable.of(!i)),Fr.of(n??[]),Ir.of(Kr(o)),Lr.of(Gr(l,C.current)),Rr.of(u?[Bt({top:!0}),oe.of(Br(Ht))]:[])]});return h.current=new H({state:t,parent:m.current}),Vr(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Nr.reconfigure(re(a)),Pr.reconfigure(H.editable.of(!i)),Fr.reconfigure(n??[]),Ir.reconfigure(Kr(o)),Lr.reconfigure(Gr(l,C.current)),Rr.reconfigure(u?[Bt({top:!0}),oe.of(Br(Ht))]:[])]}),Vr(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:zr.reconfigure(Tr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Hr(e),requestAnimationFrame(()=>{Or(e.dom),Mr(e.dom,e,!0)})):Ur(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Vr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:m,className:q(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,cr.createPortal)(e.content,e.container,e.id))]})}function Jr(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=H.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=se.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],class:`cm-comment`},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],class:`cm-keyword`},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],class:`cm-operator`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],class:`cm-punctuation`},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],class:`cm-string`},{tag:V.escape,class:`cm-string-2`},{tag:[V.number,V.bool,V.atom,V.null,V.self],class:`cm-number`},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],class:`cm-builtin`},{tag:V.definition(V.variableName),class:`cm-def`},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],class:`cm-variable`},{tag:V.propertyName,class:`cm-property`},{tag:V.attributeName,class:`cm-attribute`},{tag:[V.className,V.typeName,V.namespace],class:`cm-variable-3`},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],class:`cm-tag`},{tag:V.link,class:`cm-link`},{tag:[V.heading,V.heading1,V.heading2,V.heading3,V.heading4,V.heading5,V.heading6],class:`cm-keyword`}]),l=se.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],color:e.colors.syntax.base.comment},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],color:e.colors.syntax.base.keyword},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],color:e.colors.syntax.base.operator},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],color:e.colors.syntax.base.string},{tag:V.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[V.number,V.bool,V.atom,V.null,V.self],color:e.colors.syntax.base.number},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],color:e.colors.syntax.base.function},{tag:V.definition(V.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],color:e.colors.syntax.base.variable},{tag:V.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:V.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[V.className,V.typeName,V.namespace],color:e.colors.syntax.base.type},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:V.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,B(ce,{fallback:!0}),B(ne),B(c),B(l)]}var Yr=180,Xr=de.define(),Zr=1,Qr=2,$r=4,ei=new Map,ti=(e,t)=>{let n=`${e}|${t}`,r=ei.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Zr&&(i+=`font-style:italic;`),t&Qr&&(i+=`font-weight:bold;`),t&$r&&(i+=`text-decoration:underline;`);let a=z.mark({attributes:{style:i}});return ei.set(n,a),a},ni=(e,t)=>{let n=new fe,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,ti(t,r)))}}return n.finish()},ri=le.define({create(){return z.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Xr)&&(n=e.value);return n},provide:e=>H.decorations.from(e)}),ii=e=>R.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Yr)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await kt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Xr.of(ni(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),ai=e=>[ri,ii(e)],oi=e=>{let t=(0,X.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Z.jsx)(J,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Z.jsx)(J,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Z.jsx)(tt,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Z.jsx)(nt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(rt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},si=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await Fe(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await Ie();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await Be()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=C()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await g(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await y({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await ze(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await Pe(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await Le(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:a(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=si);var ci=`w-full max-w-[30rem]`,li=e=>{let t=(0,X.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=q(`oc-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Z.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Z.jsx)(lr,{className:`oc-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Z.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},ui=450,di=({projectRef:e=null})=>{let{t}=he(),{isMobile:n,isTablet:r}=Tt(),i=n||r,a=G(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=we(e=>e.getWorktreeMetadata),c=Ee(),l=A(e=>e.homeDirectory),[u,d]=$.useState([]),[f,p]=$.useState(!1),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null),[b,x]=$.useState([]),[S,C]=$.useState(!1),w=$.useRef(!1),T=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=$.useCallback(async()=>{if(!(!T||v===!1))try{let e=await qe(T);x(e)}catch{}},[T,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await Re(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),$.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await qe(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),$.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([be(T),Oe(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=$.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await ye(T,n)?(_(JSON.stringify(e)),!0):(K.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1)}catch{return K.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},ui);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=$.useCallback(()=>{d(e=>[...e,``])},[]),M=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=$.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=$.useCallback(e=>{p(e),T&&De(T,e)},[T]),F=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...Ce.getState().activeSessions,...Ce.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Te.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),ee=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&E()},[ee,v,o,E]);let I=(0,Z.jsxs)(rt,{children:[(0,Z.jsx)(tt,{asChild:!0,children:(0,Z.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsxs)(nt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.openchamber.worktrees.setup.tooltipPrefix`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.openchamber.worktrees.setup.tooltipSuffix`)]})]}),L=(0,Z.jsxs)(rt,{children:[(0,Z.jsx)(tt,{asChild:!0,children:(0,Z.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(nt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.openchamber.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(li,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.gitOnly`)})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(li,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:I,children:m?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.setup.loading`)}):(0,Z.jsxs)(`div`,{className:q(`flex flex-col gap-2`,ci),children:[u.map((e,n)=>(0,Z.jsxs)(`div`,{className:`oc-settings-group-row flex w-full items-center gap-2`,children:[(0,Z.jsx)(et,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.openchamber.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.openchamber.worktrees.setup.removeCommandAria`),children:(0,Z.jsx)(J,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Z.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.openchamber.worktrees.setup.addCommand`)]}),(0,Z.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Z.jsx)(He,{checked:f,onChange:P,ariaLabel:t(`settings.openchamber.worktrees.setup.waitForCommandsAria`)}),(0,Z.jsx)(`span`,{className:q(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.openchamber.worktrees.setup.waitForCommands`)})]})]})}),(0,Z.jsx)(li,{title:t(`settings.openchamber.worktrees.list.title`),titleAccessory:L,children:S?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.list.loading`)}):b.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.openchamber.worktrees.list.empty`)}):(0,Z.jsx)(`div`,{className:q(`space-y-1`,ci),children:b.map(e=>(0,Z.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.openchamber.worktrees.list.detachedHead`)}),(0,Z.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Z.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:ke(e.path,l)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:q(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.openchamber.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Z.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Z.jsx)(li,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.selectProject`)})})},fi=(e,t)=>t.updatedAtMs-e.updatedAtMs,pi=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([lt(),ot()]),i={};for(let e of r.sort(fi))i[e.id]=e;t().listenerReady||await ut(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await it(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await ot(),n={};for(let e of t.sort(fi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await st({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=ct(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await gt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await at(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await gt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),mi=450,hi=()=>h(),gi=()=>({id:hi(),name:``,command:``,icon:`play`}),_i=({projectRef:e})=>{let{t}=he(),n=$.useMemo(()=>l(),[]),r=pi(e=>e.instances),i=pi(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[u,d]=$.useState(null),[f,p]=$.useState({}),m=$.useRef(!1),h=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await ve(e);if(t)return;o(n.actions),d(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),d(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=$.useMemo(()=>n?Gt(r):[],[r,n]),_=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=$.useMemo(()=>u!==null&&u!==JSON.stringify({actions:a}),[a,u]),y=$.useCallback(async n=>await xe(e,{actions:n,primaryActionId:null})?(d(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(Jt,{detail:{projectId:e.id}})),!0):(K.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!v||s||_||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{await y(a)}finally{m.current=!1}})())},mi);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),$.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,K.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=$.useCallback(()=>{let e=gi();o(t=>[...t,e]),p(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),p(t=>{let n={...t};return delete n[e],n})},[]),S=$.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Z.jsxs)(li,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Z.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Z.jsx)(`div`,{className:q(`space-y-0`,ci),children:a.map(e=>{let r=e.icon||`play`,i=qt[r]||`play`,a=f[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(Mt,{open:a,onOpenChange:t=>{p(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsxs)(jt,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Z.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(J,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Z.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(At,{className:`pt-1.5`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsxs)(vt,{children:[(0,Z.jsx)(bt,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Z.jsx)(J,{name:i,className:`h-4 w-4`})})}),(0,Z.jsx)(yt,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:Kt.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:q(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Z.jsx)(J,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Z.jsx)(et,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Z.jsx)(Ye,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Z.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Z.jsx)(He,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Z.jsxs)(`div`,{className:`mt-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(et,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Z.jsxs)(rt,{children:[(0,Z.jsx)(tt,{asChild:!0,children:(0,Z.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(nt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Z.jsxs)(Ke,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Z.jsx)($e,{className:`h-7 w-full`,children:(0,Z.jsx)(Ue,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(Ge,{children:[(0,Z.jsx)(Qe,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(Qe,{value:e.id,children:e.label},e.id))]})]}):(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},vi=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=he(),{currentTheme:i}=_t(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?Je[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let ee;t[4]===r?ee=t[5]:(ee=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=ee);let I;t[6]!==a||t[7]!==F||t[8]!==ee?(I=(0,Z.jsx)(et,{value:a,onChange:F,placeholder:ee}),t[6]=a,t[7]=F,t[8]=ee,t[9]=I):I=t[9];let L;t[10]!==P||t[11]!==I?(L=(0,Z.jsx)(ur,{label:P,itemId:`projects.name`,children:I}),t[10]=P,t[11]=I,t[12]=L):L=t[12];let R;t[13]===r?R=t[14]:(R=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=R);let z;t[15]===r?z=t[16]:(z=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=z);let te;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(te=(0,Z.jsx)(Ct,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`oc-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=te):te=t[20];let ne;t[21]!==R||t[22]!==z||t[23]!==te?(ne=(0,Z.jsx)(ur,{label:R,description:z,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:te}),t[21]=R,t[22]=z,t[23]=te,t[24]=ne):ne=t[24];let B;t[25]===r?B=t[26]:(B=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=B);let re;t[27]===u?re=t[28]:(re=()=>u(null),t[27]=u,t[28]=re);let ie=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,V;t[29]===ie?V=t[30]:(V=q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ie),t[29]=ie,t[30]=V);let H;t[31]===r?H=t[32]:(H=r(`settings.projects.page.field.none`),t[31]=r,t[32]=H);let ae;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(J,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=ae):ae=t[33];let oe;t[34]!==re||t[35]!==V||t[36]!==H?(oe=(0,Z.jsx)(`button`,{type:`button`,onClick:re,className:V,title:H,children:ae}),t[34]=re,t[35]=V,t[36]=H,t[37]=oe):oe=t[37];let se;t[38]!==l||t[39]!==u?(se=Ze.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:q(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=se):se=t[40];let ce;t[41]!==oe||t[42]!==se?(ce=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[oe,se]}),t[41]=oe,t[42]=se,t[43]=ce):ce=t[43];let le;t[44]!==B||t[45]!==ce?(le=(0,Z.jsx)(ur,{label:B,itemId:`projects.accent-color`,children:ce}),t[44]=B,t[45]=ce,t[46]=le):le=t[46];let ue;t[47]===r?ue=t[48]:(ue=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=ue);let de;t[49]===O?de=t[50]:(de=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=de);let fe;t[51]!==D||t[52]!==de?(fe=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:de}),t[51]=D,t[52]=de,t[53]=fe):fe=t[53];let pe;t[54]===c?pe=t[55]:(pe=()=>c(null),t[54]=c,t[55]=pe);let U=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,me;t[56]===U?me=t[57]:(me=q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,U),t[56]=U,t[57]=me);let W;t[58]===r?W=t[59]:(W=r(`settings.projects.page.field.none`),t[58]=r,t[59]=W);let ge;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(J,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=ge):ge=t[60];let _e;t[61]!==pe||t[62]!==me||t[63]!==W?(_e=(0,Z.jsx)(`button`,{type:`button`,onClick:pe,className:me,title:W,children:ge}),t[61]=pe,t[62]=me,t[63]=W,t[64]=_e):_e=t[64];let G;t[65]!==N||t[66]!==s||t[67]!==c?(G=Xe.map(e=>{let t=e.Icon;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Z.jsx)(J,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=G):G=t[68];let ve;t[69]!==_e||t[70]!==G?(ve=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[_e,G]}),t[69]=_e,t[70]=G,t[71]=ve):ve=t[71];let ye;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(ye=w&&E&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Z.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Z.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Z.jsx)(We,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=ye):ye=t[82];let be;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(be=w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Z.jsx)(et,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Z.jsx)(Y,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Z.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=be):be=t[87];let xe;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(xe=!C&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Z.jsx)(Y,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=xe):xe=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Z.jsx)(Y,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let Ce;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(Ce=v&&(0,Z.jsx)(Y,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=Ce):Ce=t[104];let K;t[105]!==xe||t[106]!==Se||t[107]!==Ce?(K=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[xe,Se,Ce]}),t[105]=xe,t[106]=Se,t[107]=Ce,t[108]=K):K=t[108];let we;t[109]!==fe||t[110]!==ve||t[111]!==ye||t[112]!==be||t[113]!==K?(we=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[fe,ve,ye,be,K]}),t[109]=fe,t[110]=ve,t[111]=ye,t[112]=be,t[113]=K,t[114]=we):we=t[114];let Te;t[115]!==ue||t[116]!==we?(Te=(0,Z.jsx)(ur,{label:ue,itemId:`projects.icon`,children:we}),t[115]=ue,t[116]=we,t[117]=Te):Te=t[117];let Ee;return t[118]!==le||t[119]!==Te||t[120]!==L||t[121]!==ne?(Ee=(0,Z.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[L,ne,le,Te]}),t[118]=le,t[119]=Te,t[120]=L,t[121]=ne,t[122]=Ee):Ee=t[122],Ee},yi=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,bi=e=>{if(!e)return null;let t=e.trim();return t&&yi.test(t)?t.toLowerCase():null},xi=e=>{let{t}=he(),n=G(e=>e.uploadProjectIcon),r=G(e=>e.removeProjectIcon),i=G(e=>e.discoverProjectIcon),a=G(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>Se(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),ee=e?.iconImage?.source===`custom`,I=P&&!S||F,L=I,R=!!(e&&P&&!S),z=!O&&(F||R),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),re=$.useCallback(()=>{!e||!L||v||(F&&j(),C(!!P),k(!1))},[j,F,L,P,v,e]),ie=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){K.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){K.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}K.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),V=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return K.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||K.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return K.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||K.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:bi(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:ee,effectiveHasImageIcon:I,hasRemovableImageIcon:L,showStoredImagePreview:R,showImagePreview:z,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:B,handleRemoveImageIcon:re,handleDiscoverIcon:ie,hasChanges:te,prepareSaveData:V,currentIconImage:a,project:e}},Si=450,Ci=(e,t)=>{let{t:n}=he(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{K.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Si);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},wi=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=he(),a=xi(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),Ci(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Z.jsx)(vi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(_i,{projectRef:s}),g=(0,Z.jsx)(di,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Ti(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Ei={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function Di(e,t){let n=Ei[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Oi(e){return Ei[e]??[]}function ki(e){return[...e].sort((e,t)=>e.order-t.order)}function Ai(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Di(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function ji(e,t,n){let r=new Map;for(let i of e){let e=Di(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Mi(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var Ni=6e4,Pi=0,Fi=0,Ii=new Map,Li=e=>{let t=Yt.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):Ni,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&t.includes(e)):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Ri=async()=>{let e=C()?.settings;if(e)try{let t=(await e.load())?.settings;return Li(t??null)}catch{}if(!o()){let e=await g(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Li(await e.json().catch(()=>null))}return{autoRefresh:!1,refreshIntervalMs:Ni,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Yt.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},zi=async(e,t)=>{let n=Fi;Ii.set(e,(Ii.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await S.fetchQuery({queryKey:f.quota(e),queryFn:({signal:t})=>b(e,t),staleTime:0,retry:!1});return n===Fi?(t(t=>{let n=t.results.filter(t=>t.providerId!==e);return n.push(r),{results:n}}),{providerId:e,result:r}):{providerId:e,stale:!0}}catch(t){return n===Fi?{providerId:e,error:t instanceof Error?t.message:`Failed to fetch quota`}:{providerId:e,stale:!0}}finally{if(n===Fi){let n=(Ii.get(e)??1)-1;n>0?Ii.set(e,n):Ii.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},Bi=()=>{Fi+=1,Pi+=1,Ii.clear(),Vi.setState({results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Vi=w()(E((e,t)=>({results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Ni,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Yt.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{try{e(await Ri())}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let t=++Pi;e({isLoading:!0,error:null});let n=Yt.map(e=>e.id),r=await Promise.all(n.map(t=>zi(t,e)));if(t===Pi){let t=r.find(e=>`error`in e);e({isLoading:!1,...r.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async t=>{let n=await zi(t,e);`stale`in n||e({error:`error`in n?n.error:null})},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:t=>e({dropdownProviderIds:t}),setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),y({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),y({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Mi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),y({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Hi=()=>{let e=(0,X.c)(5),t=Vi(Ui),n=Vi(Wi),r=Vi(Gi),i,a;e[0]!==t||e[1]!==r||e[2]!==n?(i=()=>{if(!t)return;let e=window.setInterval(()=>{r()},n);return()=>window.clearInterval(e)},a=[t,n,r],e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),$.useEffect(i,a)};function Ui(e){return e.autoRefresh}function Wi(e){return e.refreshIntervalMs}function Gi(e){return e.fetchAllQuotas}var Ki=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=mt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=ft(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=q(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Z.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Z.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},qi=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=he(),s;t[0]===n.status?s=t[1]:(s=dt(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=q(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.wait`,{duration:pt(n.remainingSeconds)})}):(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Z.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=q(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:pt(n.remainingSeconds)})]}):(0,Z.jsxs)(`span`,{title:f,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Z.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Ji=e=>e instanceof Error&&e.name===`CancelledError`,Yi=w(()=>({setStatus:e=>xt(S,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await S.cancelQueries({queryKey:f.github.auth(r),exact:!0});try{return await wt(S,e,r)}catch(e){if(Ji(e))return St(S,r);throw e}}})),Xi={displayMode:`browser`,installed:!1,browserTab:!0},Zi=new Set,Qi=Xi,$i=!1,ea,ta=()=>{let e=ht();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},na=()=>(!$i&&typeof window<`u`&&(Qi=ta(),$i=!0),Qi),ra=()=>{let e=ta();$i=!0,e.displayMode!==Qi.displayMode&&(Qi=e,Zi.forEach(e=>e()))},ia=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,ra):typeof t.addListener==`function`&&t.addListener(ra);return window.addEventListener(`appinstalled`,ra),window.addEventListener(`focus`,ra),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,ra):typeof t.removeListener==`function`&&t.removeListener(ra);window.removeEventListener(`appinstalled`,ra),window.removeEventListener(`focus`,ra)}},aa=e=>(Zi.add(e),ea??=ia(),ra(),()=>{Zi.delete(e),Zi.size===0&&(ea?.(),ea=void 0)}),oa=()=>$.useSyncExternalStore(aa,na,sa);function sa(){return Xi}var ca=`OPEN CHAMBER`,la=w()(T(e=>({sidebarBrandName:ca,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:v(),version:2,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n=e;return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=ca),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=ca),n}}));typeof window<`u`&&t(e=>{r(e)&&la.persist.rehydrate()});var ua=[`connection`,`personalization`,`workspace`,`opencode`,`content`,`system`],da=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`summary-ai`,`shortcuts`,`projects`,`git`,`remote-instances`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`global-config`,`magic-prompts`,`snippets`,`skills.installed`,`skills.catalog`,`usage`,`voice`,`about`],fa=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`summary-ai`,`projects`,`git`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`magic-prompts`,`snippets`,`skills.installed`,`usage`,`voice`,`about`],pa=[{slug:`home`,title:`Settings`,group:`personalization`,kind:`single`,description:`Search and jump to common pages.`,keywords:[`search`,`settings`]},{slug:`projects`,title:`Projects`,group:`workspace`,kind:`split`,keywords:[`project`,`projects`,`worktree`,`worktrees`,`repo`,`repository`,`directory`]},{slug:`instances`,title:`Switch instance`,group:`connection`,kind:`single`,keywords:[`instance`,`instances`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{slug:`remote-instances`,title:`Remote Instances`,group:`workspace`,kind:`single`,keywords:[`ssh`,`remote`,`instances`,`forwarding`,`connection`],isAvailable:e=>!e.isVSCode},{slug:`providers`,title:`Providers`,group:`opencode`,kind:`split`,keywords:[`provider`,`providers`,`models`,`model`,`api key`,`api keys`,`openai`,`anthropic`,`ollama`,`credentials`]},{slug:`usage`,title:`Usage`,group:`system`,kind:`split`,keywords:[`quota`,`billing`,`tokens`,`usage`,`limits`]},{slug:`agents`,title:`Agents`,group:`opencode`,kind:`split`,keywords:[`agent`,`agents`,`prompts`,`tools`,`permissions`]},{slug:`assistants`,title:`Assistants`,group:`opencode`,kind:`split`,keywords:[`assistant`,`assistants`,`sharing`]},{slug:`behavior`,title:`Behavior`,group:`opencode`,kind:`single`,keywords:[`behavior`,`agents.md`,`system prompt`,`global rules`,`instructions`,`override`]},{slug:`commands`,title:`Commands`,group:`opencode`,kind:`split`,keywords:[`command`,`commands`,`slash`,`macros`,`automation`]},{slug:`mcp`,title:`MCP`,group:`opencode`,kind:`split`,keywords:[`mcp`,`model context protocol`,`servers`,`tools`,`remote`,`stdio`]},{slug:`plugins`,title:`Plugins`,group:`opencode`,kind:`split`,keywords:[`plugin`,`plugins`,`extensions`,`addons`,`npm`,`opencode-wakatime`]},{slug:`global-config`,title:`Global Configuration`,group:`opencode`,kind:`single`,keywords:[`global`,`configuration`,`opencode.json`,`opencode.jsonc`,`oh-my-opencode`,`oh-my-openagent`]},{slug:`skills.installed`,title:`Skills`,group:`content`,kind:`split`,keywords:[`skill`,`skills`,`instructions`,`install`,`catalog`]},{slug:`skills.catalog`,title:`Skills Catalog`,group:`content`,kind:`single`,keywords:[`install`,`catalog`,`external`,`repository`,`skills catalog`]},{slug:`git`,title:`Git`,group:`workspace`,kind:`single`,keywords:[`git`,`github`,`identity`,`identities`,`ssh`,`profiles`,`credentials`,`keys`,`commit`,`gitmoji`,`oauth`,`prs`,`issues`],isAvailable:e=>!e.isVSCode},{slug:`appearance`,title:`Appearance`,group:`personalization`,kind:`single`,keywords:[`theme`,`font`,`spacing`,`padding`,`corner radius`,`radius`,`input bar`,`keyboard`,`viewport`,`mobile`,`terminal`,`pwa`,`install name`,`app shortcuts`]},{slug:`chat`,title:`Chat`,group:`personalization`,kind:`single`,keywords:[`tools`,`diff`,`reasoning`,`dotfiles`,`draft`,`queue`,`output`,`copy`,`image`,`split messages`,`message actions`]},{slug:`shortcuts`,title:`Shortcuts`,group:`personalization`,kind:`single`,keywords:[`keyboard`,`hotkeys`,`shortcuts`,`bindings`],isAvailable:e=>!e.isVSCode},{slug:`sessions`,title:`Sessions`,group:`personalization`,kind:`single`,keywords:[`defaults`,`default agent`,`default model`,`retention`,`memory`,`limits`,`zen`]},{slug:`summary-ai`,title:`Summary AI`,group:`personalization`,kind:`single`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{slug:`magic-prompts`,title:`Magic Prompts`,group:`content`,kind:`split`,keywords:[`prompts`,`templates`,`git`,`github`,`review`,`commit`,`pull request`],isAvailable:e=>!e.isVSCode},{slug:`snippets`,title:`Snippets`,group:`content`,kind:`split`,keywords:[`prompt`,`templates`,`multi-run`,`strategy`,`approach`]},{slug:`notifications`,title:`Notifications`,group:`personalization`,kind:`single`,keywords:[`alerts`,`native`,`summary`,`summarization`]},{slug:`voice`,title:`Voice`,group:`system`,kind:`single`,keywords:[`tts`,`speech`,`voice`],isAvailable:e=>!e.isVSCode},{slug:`about`,title:`About`,group:`system`,kind:`single`,keywords:[`about`,`version`,`updates`,`release`,`changelog`],isAvailable:e=>e.isMobile}];function ma(e){let t=new Map(da.map((e,t)=>[e,t])),n=new Map;for(let t of e){let e=n.get(t.group)??[];e.push(t),n.set(t.group,e)}return ua.flatMap(e=>{let r=n.get(e);return r?.length?[{group:e,pages:r.sort((e,n)=>(t.get(e.slug)??999)-(t.get(n.slug)??999))}]:[]})}var ha={sessions:`sessions`,agents:`agents`,commands:`commands`,mcp:`mcp`,skills:`skills.installed`,providers:`providers`,usage:`usage`,"git-identities":`git`,settings:`home`};function ga(e){let t=e.trim().toLowerCase();return pa.find(e=>e.slug===t)??null}function _a(e){let t=(e??``).trim().toLowerCase();if(!t)return`home`;let n=ha[t];if(n)return n;let r=ga(t);return r?r.slug:`home`}var va=48;function ya({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=W(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/va)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--oc-mobile-title-collapse`,r.toFixed(4)))}),u=W(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.oc-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`header`,{ref:i,className:q(`oc-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Z.jsxs)(`div`,{className:`oc-mobile-collapsing-header-inner`,children:[(0,Z.jsxs)(`div`,{className:`oc-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Z.jsx)(`p`,{className:`oc-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Z.jsx)(`h1`,{className:`oc-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Z.jsx)(`div`,{className:`oc-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Z.jsx)(`div`,{className:`oc-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}function ba(e){let t=(0,X.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ne:`div`,o;t[4]===n?o=t[5]:(o=q(`oc-mobile-floating-surface`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function xa(e){let t=(0,X.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({as:o,children:n,className:r,variant:s,surfaceProps:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`div`:o,l=s===void 0?`actions`:s,u;t[7]===r?u=t[8]:(u=q(`oc-mobile-floating-bottom-bar-frame`,r),t[7]=r,t[8]=u);let d=l===`navigation`?`oc-mobile-floating-bottom-bar-navigation`:`oc-mobile-floating-bottom-bar-actions`,f;t[9]===d?f=t[10]:(f=q(`oc-mobile-floating-bottom-bar`,d),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==f?(p=(0,Z.jsx)(ba,{...a,className:f,children:n}),t[11]=n,t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==i||t[17]!==u||t[18]!==p?(m=(0,Z.jsx)(c,{className:u,...i,children:p}),t[15]=c,t[16]=i,t[17]=u,t[18]=p,t[19]=m):m=t[19],m}function Sa(e){let t=(0,X.c)(17),{title:n,children:r,surface:i,scrollsWithPage:a,showHeader:o,trailing:s,className:c,surfaceClassName:l,surfaceAriaLabel:u}=e,d=i===void 0||i,f=a!==void 0&&a,p=o===void 0||o,m=f&&`oc-mobile-tab-page-flow`,h=!p&&`gap-0`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=q(`oc-mobile-tab-page`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _;t[4]!==p||t[5]!==n||t[6]!==s?(_=p?(0,Z.jsx)(ya,{title:n,trailing:s}):null,t[4]=p,t[5]=n,t[6]=s,t[7]=_):_=t[7];let v;t[8]!==r||t[9]!==d||t[10]!==u||t[11]!==l?(v=d?(0,Z.jsx)(ba,{className:q(`oc-mobile-tab-page-surface`,l),"aria-label":u,children:r}):(0,Z.jsx)(`div`,{className:q(`oc-mobile-tab-page-content`,l),"aria-label":u,children:r}),t[8]=r,t[9]=d,t[10]=u,t[11]=l,t[12]=v):v=t[12];let y;return t[13]!==g||t[14]!==_||t[15]!==v?(y=(0,Z.jsxs)(`div`,{className:g,children:[_,v]}),t[13]=g,t[14]=_,t[15]=v,t[16]=y):y=t[16],y}function Ca(e){let t=(0,X.c)(12),{label:n,children:r,className:i,cardClassName:a,ariaLabel:o}=e,s;t[0]!==a||t[1]!==i?(s=q(`oc-mobile-labeled-surface-group`,a,i),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,Z.jsx)(`div`,{className:`oc-mobile-labeled-surface-group-label`,children:n}),t[3]=n,t[4]=c);let l;t[5]===r?l=t[6]:(l=r?(0,Z.jsx)(`div`,{className:`oc-mobile-labeled-surface-group-content`,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,Z.jsxs)(`section`,{className:s,"aria-label":o,children:[c,l]}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}export{Yt as $,qr as A,Yn as B,ki as C,oi as D,si as E,ur as F,on as G,Cn as H,lr as I,ln as J,sn as K,dr as L,br as M,xr as N,ai as O,_r as P,Xt as Q,fr as R,ji as S,pi as T,Sn as U,xn as V,_n as W,rn as X,Zt as Y,an as Z,Hi as _,ya as a,Ti as b,ga as c,la as d,oa as f,Bi as g,Ki as h,Sa as i,vr as j,Jr as k,ma as l,qi as m,ba as n,fa as o,Yi as p,cn as q,Ca as r,pa as s,xa as t,_a as u,Vi as v,wi as w,Ai as x,Oi as y,sr as z};