@spencer-kit/coder-studio 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/esm/bin.mjs +2604 -895
- package/dist/esm/bin.mjs.map +4 -4
- package/dist/esm/server-runner.mjs +2576 -867
- package/dist/esm/server-runner.mjs.map +4 -4
- package/dist/web/assets/{components-BC_6z_aX.css → components-D5qT9_xF.css} +1 -1
- package/dist/web/assets/{components-ynft7c9H.js → components-DmD8Ga_M.js} +7 -7
- package/dist/web/assets/components-DmD8Ga_M.js.map +1 -0
- package/dist/web/assets/{main-BMKYuTcM.js → main-C9Cqb7HD.js} +2 -2
- package/dist/web/assets/{main-BMKYuTcM.js.map → main-C9Cqb7HD.js.map} +1 -1
- package/dist/web/assets/{ui-preview-BC1JKu3-.js → ui-preview-DOaeyhSh.js} +2 -2
- package/dist/web/assets/{ui-preview-BC1JKu3-.js.map → ui-preview-DOaeyhSh.js.map} +1 -1
- package/dist/web/index.html +3 -3
- package/dist/web/ui-preview.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/components-ynft7c9H.js.map +0 -1
|
@@ -92,18 +92,18 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
92
92
|
|
|
93
93
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Ro,s=!Co.jitless,c=s&&zo.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ol([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ll(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!es(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>is(e,r,wo())))}),t)}var ul=q(`$ZodUnion`,(e,t)=>{Sc.init(e,t),Mo(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Mo(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Mo(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Mo(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ko(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ll(t,r,e,i)):ll(o,r,e,i)}}),dl=q(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ul.init(e,t);let n=e._zod.parse;Mo(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Do(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Ro(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),fl=q(`$ZodIntersection`,(e,t)=>{Sc.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>ml(e,t,n)):ml(e,i,a)}});function pl(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Bo(e)&&Bo(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pl(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pl(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ml(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),es(e))return e;let o=pl(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var hl=q(`$ZodRecord`,(e,t)=>{Sc.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Bo(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>is(e,r,wo())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ns(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ns(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&$s.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>is(e,r,wo())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ns(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ns(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),gl=q(`$ZodEnum`,(e,t)=>{Sc.init(e,t);let n=To(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ho.has(typeof e)).map(e=>typeof e==`string`?Uo(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),_l=q(`$ZodLiteral`,(e,t)=>{if(Sc.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Uo(e):e?Uo(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),vl=q(`$ZodTransform`,(e,t)=>{Sc.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new So(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new xo;return n.value=i,n.fallback=!0,n}});function yl(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var bl=q(`$ZodOptional`,(e,t)=>{Sc.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Mo(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Mo(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ko(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>yl(e,r)):yl(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),xl=q(`$ZodExactOptional`,(e,t)=>{bl.init(e,t),Mo(e._zod,`values`,()=>t.innerType._zod.values),Mo(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sl=q(`$ZodNullable`,(e,t)=>{Sc.init(e,t),Mo(e._zod,`optin`,()=>t.innerType._zod.optin),Mo(e._zod,`optout`,()=>t.innerType._zod.optout),Mo(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ko(e.source)}|null)$`):void 0}),Mo(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Cl=q(`$ZodDefault`,(e,t)=>{Sc.init(e,t),e._zod.optin=`optional`,Mo(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>wl(e,t)):wl(r,t)}});function wl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Tl=q(`$ZodPrefault`,(e,t)=>{Sc.init(e,t),e._zod.optin=`optional`,Mo(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),El=q(`$ZodNonOptional`,(e,t)=>{Sc.init(e,t),Mo(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Dl(t,e)):Dl(i,e)}});function Dl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Ol=q(`$ZodCatch`,(e,t)=>{Sc.init(e,t),e._zod.optin=`optional`,Mo(e._zod,`optout`,()=>t.innerType._zod.optout),Mo(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>is(e,n,wo()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>is(e,n,wo()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),kl=q(`$ZodPipe`,(e,t)=>{Sc.init(e,t),Mo(e._zod,`values`,()=>t.in._zod.values),Mo(e._zod,`optin`,()=>t.in._zod.optin),Mo(e._zod,`optout`,()=>t.out._zod.optout),Mo(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Al(e,t.in,n)):Al(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Al(e,t.out,n)):Al(r,t.out,n)}});function Al(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var jl=q(`$ZodReadonly`,(e,t)=>{Sc.init(e,t),Mo(e._zod,`propValues`,()=>t.innerType._zod.propValues),Mo(e._zod,`values`,()=>t.innerType._zod.values),Mo(e._zod,`optin`,()=>t.innerType?._zod?.optin),Mo(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ml):Ml(r)}});function Ml(e){return e.value=Object.freeze(e.value),e}var Nl=q(`$ZodCustom`,(e,t)=>{rc.init(e,t),Sc.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Pl(t,n,r,e));Pl(i,n,r,e)}});function Pl(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(os(e))}}var Fl,Il=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ll(){return new Il}(Fl=globalThis).__zod_globalRegistry??(Fl.__zod_globalRegistry=Ll());var Rl=globalThis.__zod_globalRegistry;function zl(e,t){return new e({type:`string`,...J(t)})}function Bl(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...J(t)})}function Vl(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...J(t)})}function Hl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...J(t)})}function Ul(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...J(t)})}function Wl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...J(t)})}function Gl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...J(t)})}function Kl(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...J(t)})}function ql(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...J(t)})}function Jl(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...J(t)})}function Yl(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...J(t)})}function Xl(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...J(t)})}function Zl(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...J(t)})}function Ql(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...J(t)})}function $l(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...J(t)})}function eu(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...J(t)})}function tu(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...J(t)})}function nu(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...J(t)})}function ru(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...J(t)})}function iu(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...J(t)})}function au(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...J(t)})}function ou(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...J(t)})}function su(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...J(t)})}function cu(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...J(t)})}function lu(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...J(t)})}function uu(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...J(t)})}function du(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...J(t)})}function fu(e,t){return new e({type:`number`,checks:[],...J(t)})}function pu(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...J(t)})}function mu(e,t){return new e({type:`boolean`,...J(t)})}function hu(e){return new e({type:`unknown`})}function gu(e,t){return new e({type:`never`,...J(t)})}function _u(e,t){return new ac({check:`less_than`,...J(t),value:e,inclusive:!1})}function vu(e,t){return new ac({check:`less_than`,...J(t),value:e,inclusive:!0})}function yu(e,t){return new oc({check:`greater_than`,...J(t),value:e,inclusive:!1})}function bu(e,t){return new oc({check:`greater_than`,...J(t),value:e,inclusive:!0})}function xu(e,t){return new sc({check:`multiple_of`,...J(t),value:e})}function Su(e,t){return new lc({check:`max_length`,...J(t),maximum:e})}function Cu(e,t){return new uc({check:`min_length`,...J(t),minimum:e})}function wu(e,t){return new dc({check:`length_equals`,...J(t),length:e})}function Tu(e,t){return new pc({check:`string_format`,format:`regex`,...J(t),pattern:e})}function Eu(e){return new mc({check:`string_format`,format:`lowercase`,...J(e)})}function Du(e){return new hc({check:`string_format`,format:`uppercase`,...J(e)})}function Ou(e,t){return new gc({check:`string_format`,format:`includes`,...J(t),includes:e})}function ku(e,t){return new _c({check:`string_format`,format:`starts_with`,...J(t),prefix:e})}function Au(e,t){return new vc({check:`string_format`,format:`ends_with`,...J(t),suffix:e})}function ju(e){return new yc({check:`overwrite`,tx:e})}function Mu(e){return ju(t=>t.normalize(e))}function Nu(){return ju(e=>e.trim())}function Pu(){return ju(e=>e.toLowerCase())}function Fu(){return ju(e=>e.toUpperCase())}function Iu(){return ju(e=>Io(e))}function Lu(e,t,n){return new e({type:`array`,element:t,...J(n)})}function Ru(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...J(n)})}function zu(e,t){let n=Bu(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(os(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(os(r))}},e(t.value,t)),t);return n}function Bu(e,t){let n=new rc({check:`custom`,...J(t)});return n._zod.check=e,n}function Vu(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Rl,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Hu(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Hu(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Gu(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Uu(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
94
94
|
|
|
95
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Wu(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:qu(t,`input`,e.processors),output:qu(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Gu(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Gu(r.element,n);if(r.type===`set`)return Gu(r.valueType,n);if(r.type===`lazy`)return Gu(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Gu(r.innerType,n);if(r.type===`intersection`)return Gu(r.left,n)||Gu(r.right,n);if(r.type===`record`||r.type===`map`)return Gu(r.keyType,n)||Gu(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Gu(r.in,n)||Gu(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Gu(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Gu(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Gu(e,n))return!0;return!!(r.rest&&Gu(r.rest,n))}return!1}var Ku=(e,t={})=>n=>{let r=Vu({...n,processors:t});return Hu(e,r),Uu(r,e),Wu(r,e)},qu=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vu({...i??{},target:a,io:t,processors:n});return Hu(e,o),Uu(o,e),Wu(o,e)},Ju={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yu=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ju[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xu=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zu=(e,t,n,r)=>{n.type=`boolean`},Qu=(e,t,n,r)=>{n.not={}},$u=(e,t,n,r)=>{let i=e._zod.def,a=To(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ed=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},td=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},nd=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},rd=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Hu(a.element,t,{...r,path:[...r.path,`items`]})},id=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Hu(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Hu(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ad=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Hu(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},od=(e,t,n,r)=>{let i=e._zod.def,a=Hu(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Hu(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},sd=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Hu(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Hu(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Hu(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},cd=(e,t,n,r)=>{let i=e._zod.def,a=Hu(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ld=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ud=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},dd=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fd=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},pd=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Hu(o,t,r);let s=t.seen.get(e);s.ref=o},md=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hd=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gd=q(`ZodISODateTime`,(e,t)=>{Ic.init(e,t),Ud.init(e,t)});function _d(e){return cu(gd,e)}var vd=q(`ZodISODate`,(e,t)=>{Lc.init(e,t),Ud.init(e,t)});function yd(e){return lu(vd,e)}var bd=q(`ZodISOTime`,(e,t)=>{Rc.init(e,t),Ud.init(e,t)});function xd(e){return uu(bd,e)}var Sd=q(`ZodISODuration`,(e,t)=>{zc.init(e,t),Ud.init(e,t)});function Cd(e){return du(Sd,e)}var wd=q(`ZodError`,(e,t)=>{cs.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ds(e,t)},flatten:{value:t=>us(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Eo,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Eo,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Td=fs(wd),Ed=ps(wd),Dd=ms(wd),Od=gs(wd),kd=vs(wd),Ad=ys(wd),jd=bs(wd),Md=xs(wd),Nd=Ss(wd),Pd=Cs(wd),Fd=ws(wd),Id=Ts(wd),Ld=new WeakMap;function Rd(e,t,n){let r=Object.getPrototypeOf(e),i=Ld.get(r);if(i||(i=new Set,Ld.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zd=q(`ZodType`,(e,t)=>(Sc.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qu(e,`input`),output:qu(e,`output`)}}),e.toJSONSchema=Ku(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Td(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Dd(e,t,n),e.parseAsync=async(t,n)=>Ed(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Od(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>kd(e,t,n),e.decode=(t,n)=>Ad(e,t,n),e.encodeAsync=async(t,n)=>jd(e,t,n),e.decodeAsync=async(t,n)=>Md(e,t,n),e.safeEncode=(t,n)=>Nd(e,t,n),e.safeDecode=(t,n)=>Pd(e,t,n),e.safeEncodeAsync=async(t,n)=>Fd(e,t,n),e.safeDecodeAsync=async(t,n)=>Id(e,t,n),Rd(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Po(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Wo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rp(e,t))},superRefine(e,t){return this.check(ip(e,t))},overwrite(e){return this.check(ju(e))},optional(){return zf(this)},exactOptional(){return Vf(this)},nullable(){return Uf(this)},nullish(){return zf(Uf(this))},nonoptional(e){return Yf(this,e)},array(){return xf(this)},or(e){return Tf([this,e])},and(e){return kf(this,e)},transform(e){return $f(this,Lf(e))},default(e){return Gf(this,e)},prefault(e){return qf(this,e)},catch(e){return Zf(this,e)},pipe(e){return $f(this,e)},readonly(){return tp(this)},describe(e){let t=this.clone();return Rl.add(t,{description:e}),t},meta(...e){if(e.length===0)return Rl.get(this);let t=this.clone();return Rl.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return Rl.get(e)?.description},configurable:!0}),e)),Bd=q(`_ZodString`,(e,t)=>{Cc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yu(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rd(e,`_ZodString`,{regex(...e){return this.check(Tu(...e))},includes(...e){return this.check(Ou(...e))},startsWith(...e){return this.check(ku(...e))},endsWith(...e){return this.check(Au(...e))},min(...e){return this.check(Cu(...e))},max(...e){return this.check(Su(...e))},length(...e){return this.check(wu(...e))},nonempty(...e){return this.check(Cu(1,...e))},lowercase(e){return this.check(Eu(e))},uppercase(e){return this.check(Du(e))},trim(){return this.check(Nu())},normalize(...e){return this.check(Mu(...e))},toLowerCase(){return this.check(Pu())},toUpperCase(){return this.check(Fu())},slugify(){return this.check(Iu())}})}),Vd=q(`ZodString`,(e,t)=>{Cc.init(e,t),Bd.init(e,t),e.email=t=>e.check(Bl(Wd,t)),e.url=t=>e.check(Kl(qd,t)),e.jwt=t=>e.check(su(lf,t)),e.emoji=t=>e.check(ql(Jd,t)),e.guid=t=>e.check(Vl(Gd,t)),e.uuid=t=>e.check(Hl(Kd,t)),e.uuidv4=t=>e.check(Ul(Kd,t)),e.uuidv6=t=>e.check(Wl(Kd,t)),e.uuidv7=t=>e.check(Gl(Kd,t)),e.nanoid=t=>e.check(Jl(Yd,t)),e.guid=t=>e.check(Vl(Gd,t)),e.cuid=t=>e.check(Yl(Xd,t)),e.cuid2=t=>e.check(Xl(Zd,t)),e.ulid=t=>e.check(Zl(Qd,t)),e.base64=t=>e.check(iu(of,t)),e.base64url=t=>e.check(au(sf,t)),e.xid=t=>e.check(Ql($d,t)),e.ksuid=t=>e.check($l(ef,t)),e.ipv4=t=>e.check(eu(tf,t)),e.ipv6=t=>e.check(tu(nf,t)),e.cidrv4=t=>e.check(nu(rf,t)),e.cidrv6=t=>e.check(ru(af,t)),e.e164=t=>e.check(ou(cf,t)),e.datetime=t=>e.check(_d(t)),e.date=t=>e.check(yd(t)),e.time=t=>e.check(xd(t)),e.duration=t=>e.check(Cd(t))});function Hd(e){return zl(Vd,e)}var Ud=q(`ZodStringFormat`,(e,t)=>{wc.init(e,t),Bd.init(e,t)}),Wd=q(`ZodEmail`,(e,t)=>{Dc.init(e,t),Ud.init(e,t)}),Gd=q(`ZodGUID`,(e,t)=>{Tc.init(e,t),Ud.init(e,t)}),Kd=q(`ZodUUID`,(e,t)=>{Ec.init(e,t),Ud.init(e,t)}),qd=q(`ZodURL`,(e,t)=>{Oc.init(e,t),Ud.init(e,t)}),Jd=q(`ZodEmoji`,(e,t)=>{kc.init(e,t),Ud.init(e,t)}),Yd=q(`ZodNanoID`,(e,t)=>{Ac.init(e,t),Ud.init(e,t)}),Xd=q(`ZodCUID`,(e,t)=>{jc.init(e,t),Ud.init(e,t)}),Zd=q(`ZodCUID2`,(e,t)=>{Mc.init(e,t),Ud.init(e,t)}),Qd=q(`ZodULID`,(e,t)=>{Nc.init(e,t),Ud.init(e,t)}),$d=q(`ZodXID`,(e,t)=>{Pc.init(e,t),Ud.init(e,t)}),ef=q(`ZodKSUID`,(e,t)=>{Fc.init(e,t),Ud.init(e,t)}),tf=q(`ZodIPv4`,(e,t)=>{Bc.init(e,t),Ud.init(e,t)}),nf=q(`ZodIPv6`,(e,t)=>{Vc.init(e,t),Ud.init(e,t)}),rf=q(`ZodCIDRv4`,(e,t)=>{Hc.init(e,t),Ud.init(e,t)}),af=q(`ZodCIDRv6`,(e,t)=>{Uc.init(e,t),Ud.init(e,t)}),of=q(`ZodBase64`,(e,t)=>{Gc.init(e,t),Ud.init(e,t)}),sf=q(`ZodBase64URL`,(e,t)=>{qc.init(e,t),Ud.init(e,t)}),cf=q(`ZodE164`,(e,t)=>{Jc.init(e,t),Ud.init(e,t)}),lf=q(`ZodJWT`,(e,t)=>{Xc.init(e,t),Ud.init(e,t)}),uf=q(`ZodNumber`,(e,t)=>{Zc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xu(e,t,n,r),Rd(e,`ZodNumber`,{gt(e,t){return this.check(yu(e,t))},gte(e,t){return this.check(bu(e,t))},min(e,t){return this.check(bu(e,t))},lt(e,t){return this.check(_u(e,t))},lte(e,t){return this.check(vu(e,t))},max(e,t){return this.check(vu(e,t))},int(e){return this.check(pf(e))},safe(e){return this.check(pf(e))},positive(e){return this.check(yu(0,e))},nonnegative(e){return this.check(bu(0,e))},negative(e){return this.check(_u(0,e))},nonpositive(e){return this.check(vu(0,e))},multipleOf(e,t){return this.check(xu(e,t))},step(e,t){return this.check(xu(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function df(e){return fu(uf,e)}var ff=q(`ZodNumberFormat`,(e,t)=>{Qc.init(e,t),uf.init(e,t)});function pf(e){return pu(ff,e)}var mf=q(`ZodBoolean`,(e,t)=>{$c.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zu(e,t,n,r)});function hf(e){return mu(mf,e)}var gf=q(`ZodUnknown`,(e,t)=>{el.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _f(){return hu(gf)}var vf=q(`ZodNever`,(e,t)=>{tl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qu(e,t,n,r)});function yf(e){return gu(vf,e)}var bf=q(`ZodArray`,(e,t)=>{rl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rd(e,t,n,r),e.element=t.element,Rd(e,`ZodArray`,{min(e,t){return this.check(Cu(e,t))},nonempty(e){return this.check(Cu(1,e))},max(e,t){return this.check(Su(e,t))},length(e,t){return this.check(wu(e,t))},unwrap(){return this.element}})});function xf(e,t){return Lu(bf,e,t)}var Sf=q(`ZodObject`,(e,t)=>{cl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>id(e,t,n,r),Mo(e,`shape`,()=>t.shape),Rd(e,`ZodObject`,{keyof(){return Nf(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:_f()})},loose(){return this.clone({...this._zod.def,catchall:_f()})},strict(){return this.clone({...this._zod.def,catchall:yf()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Yo(this,e)},safeExtend(e){return Xo(this,e)},merge(e){return Zo(this,e)},pick(e){return qo(this,e)},omit(e){return Jo(this,e)},partial(...e){return Qo(Rf,this,e[0])},required(...e){return $o(Jf,this,e[0])}})});function Cf(e,t){return new Sf({type:`object`,shape:e??{},...J(t)})}var wf=q(`ZodUnion`,(e,t)=>{ul.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ad(e,t,n,r),e.options=t.options});function Tf(e,t){return new wf({type:`union`,options:e,...J(t)})}var Ef=q(`ZodDiscriminatedUnion`,(e,t)=>{wf.init(e,t),dl.init(e,t)});function Df(e,t,n){return new Ef({type:`union`,options:t,discriminator:e,...J(n)})}var Of=q(`ZodIntersection`,(e,t)=>{fl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>od(e,t,n,r)});function kf(e,t){return new Of({type:`intersection`,left:e,right:t})}var Af=q(`ZodRecord`,(e,t)=>{hl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sd(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function jf(e,t,n){return!t||!t._zod?new Af({type:`record`,keyType:Hd(),valueType:e,...J(t)}):new Af({type:`record`,keyType:e,valueType:t,...J(n)})}var Mf=q(`ZodEnum`,(e,t)=>{gl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$u(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Mf({...t,checks:[],...J(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Mf({...t,checks:[],...J(r),entries:i})}});function Nf(e,t){return new Mf({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...J(t)})}var Pf=q(`ZodLiteral`,(e,t)=>{_l.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ed(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ff(e,t){return new Pf({type:`literal`,values:Array.isArray(e)?e:[e],...J(t)})}var If=q(`ZodTransform`,(e,t)=>{vl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nd(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new So(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(os(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(os(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Lf(e){return new If({type:`transform`,transform:e})}var Rf=q(`ZodOptional`,(e,t)=>{bl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zf(e){return new Rf({type:`optional`,innerType:e})}var Bf=q(`ZodExactOptional`,(e,t)=>{xl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vf(e){return new Bf({type:`optional`,innerType:e})}var Hf=q(`ZodNullable`,(e,t)=>{Sl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uf(e){return new Hf({type:`nullable`,innerType:e})}var Wf=q(`ZodDefault`,(e,t)=>{Cl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ud(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gf(e,t){return new Wf({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vo(t)}})}var Kf=q(`ZodPrefault`,(e,t)=>{Tl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qf(e,t){return new Kf({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vo(t)}})}var Jf=q(`ZodNonOptional`,(e,t)=>{El.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ld(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yf(e,t){return new Jf({type:`nonoptional`,innerType:e,...J(t)})}var Xf=q(`ZodCatch`,(e,t)=>{Ol.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zf(e,t){return new Xf({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Qf=q(`ZodPipe`,(e,t)=>{kl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pd(e,t,n,r),e.in=t.in,e.out=t.out});function $f(e,t){return new Qf({type:`pipe`,in:e,out:t})}var ep=q(`ZodReadonly`,(e,t)=>{jl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>md(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tp(e){return new ep({type:`readonly`,innerType:e})}var np=q(`ZodCustom`,(e,t)=>{Nl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>td(e,t,n,r)});function rp(e,t={}){return Ru(np,e,t)}function ip(e,t){return zu(e,t)}var ap={Output:1,Replay:2,Input:3,Snapshot:4},op=e=>{let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<16)throw Error(`Terminal binary frame is too short`);let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:n.getUint8(0),type:n.getUint8(1),flags:n.getUint16(2),meta:n.getUint32(4),streamId:n.getUint32(8),payloadSize:n.getUint32(12)},i=t.subarray(16);if(i.byteLength!==r.payloadSize)throw Error(`Terminal binary frame payload length mismatch`);return{header:r,payload:i}},sp=e=>{let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<16)throw Error(`Terminal output frame is too short`);let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint8(0);if(r!==2)throw Error(`Expected output frame version 2, got ${r}`);let i=n.getUint16(2,!1),a=n.getUint32(4,!1),o=n.getUint32(8,!1),s=n.getUint32(12,!1);if(t.byteLength<16+i)throw Error(`Terminal output frame topic is truncated`);let c=new TextDecoder().decode(t.subarray(16,16+i)),l=t.subarray(16+i);if(l.byteLength!==s)throw Error(`Terminal output frame payload length mismatch`);return{topic:c,seq:a,streamId:o,payload:l}},cp=Cf({kind:Ff(`command`),id:Hd().uuid(),op:Hd(),args:_f()}),lp=Cf({kind:Ff(`result`),id:Hd().uuid(),ok:hf(),data:_f().optional(),error:Cf({code:Hd(),message:Hd(),details:_f().optional()}).optional()}),up=Cf({kind:Ff(`event`),topic:Hd(),seq:df().int().nonnegative(),timestamp:df().int().positive(),data:_f()});Df(`kind`,[cp,Cf({kind:Ff(`subscribe`),topics:xf(Hd())}),Cf({kind:Ff(`unsubscribe`),topics:xf(Hd())}),Cf({kind:Ff(`resync`),lastSeen:jf(Hd(),df())})]),Df(`kind`,[lp,up]);var dp={connectionStatus:`connection.status`,connectionReady:`connection.ready`,workspaceMeta:e=>`workspace.${e}.meta`,workspaceFsDirty:e=>`workspace.${e}.fs.dirty`,workspaceGitState:e=>`workspace.${e}.git.state`,workspaceLspDiagnostics:e=>`workspace.${e}.lsp.diagnostics`,workspaceAll:e=>`workspace.${e}.*`,sessionState:(e,t)=>`workspace.${e}.session.${t}.state`,sessionLifecycle:(e,t)=>`workspace.${e}.session.${t}.lifecycle`,sessionProgress:(e,t)=>`workspace.${e}.session.${t}.progress`,sessionsAll:e=>`workspace.${e}.session.*`,terminalCreated:(e,t)=>`workspace.${e}.terminal.${t}.created`,terminalOutput:(e,t)=>`workspace.${e}.terminal.${t}.output`,terminalContinuityLost:(e,t)=>`workspace.${e}.terminal.${t}.continuity_lost`,terminalExit:(e,t)=>`workspace.${e}.terminal.${t}.exit`,terminalsAll:e=>`workspace.${e}.terminal.*`,notificationToast:`notification.toast`,updateStateChanged:`update.state.changed`,supervisorState:(e,t)=>`workspace.${e}.session.${t}.supervisor.state`};function fp(e,t){if(e===t||e===`*`)return!0;let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<n.length;e++){let t=n[e];if(t===`*`){if(e===n.length-1)return!0;continue}if(e>=r.length||t!==r[e])return!1}return n.length<=r.length}var pp=class extends Error{constructor(e){super(e.message),this.name=`CommandResultError`,this.code=e.code,this.details=e.details}},mp={maxAttempts:1/0,baseDelayMs:1e3,maxDelayMs:3e4},hp=3e4,gp=2500,_p=()=>{if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join(`-`)},vp=class{constructor(e,t={}){this.ws=null,this.connectDeferred=null,this.pendingCommands=new Map,this.eventListeners=new Map,this.statusListeners=new Set,this.lastSeenSeq=new Map,this.pendingBinaryStreamIds=new Map,this.orphanBinaryPayloads=new Map,this.nextTerminalInputStreamId=1,this.pendingProbe=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.isManualClose=!1,this.status=`disconnected`,this.url=e,this.reconnectConfig={...mp,...t}}async connect(){if(this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`)return Promise.resolve();if(this.connectDeferred)return this.connectDeferred.promise;this.isManualClose=!1,this.setStatus(`connecting`);let e,t,n=new Promise((n,r)=>{e=n,t=r});this.connectDeferred={promise:n,resolve:e,reject:t};try{let e=new WebSocket(this.url);this.ws=e,e.binaryType=`arraybuffer`,e.onopen=()=>{if(this.ws!==e)return;this.setStatus(`connected`),this.reconnectAttempts=0;let t=Array.from(this.eventListeners.keys());if(t.length>0){let n={kind:`subscribe`,topics:t};e.send(JSON.stringify(n))}this.lastSeenSeq.size>0&&this.resync(),this.resolveConnectDeferred()},e.onmessage=t=>{if(this.ws===e)try{if(typeof t.data==`string`){let e=JSON.parse(t.data);this.handleMessage(e);return}if(t.data instanceof ArrayBuffer){this.handleBinaryMessage(new Uint8Array(t.data));return}console.error(`Unsupported WebSocket message type:`,typeof t.data)}catch(e){console.error(`Failed to parse WebSocket message:`,e)}},e.onclose=t=>{this.ws===e&&((t.reason===`single_active_displaced`||t.reason===`activation_required`||t.reason===`activation_revoked`)&&(this.isManualClose=!0),this.handleClose(t.code,t.reason),this.rejectConnectDeferred(Error(`WebSocket closed: ${t.reason||t.code}`)))},e.onerror=t=>{this.ws===e&&console.error(`WebSocket error:`,t)}}catch(e){this.rejectConnectDeferred(e instanceof Error?e:Error(String(e)))}return n}disconnect(e){this.isManualClose=!0,this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.rejectConnectDeferred(Error(`WebSocket disconnected`)),this.rejectPendingCommands(Error(`WebSocket disconnected`)),this.clearBinaryCommandState(),this.clearPendingProbe(),this.ws&&=(this.ws.close(1e3,e||`client_disconnect`),null),this.setStatus(`disconnected`)}recoverConnection(e=`manual_retry`){let t=this.getStatus();if(t!==`rejected`){if(t===`connected`){this.probeConnection(e).catch(()=>{});return}t!==`connecting`&&(this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.reconnectAttempts=0,console.log(`[WsClient] Recovering connection after ${e}`),this.connect().catch(e=>{console.error(`Recovery connect failed:`,e)}))}}async probeConnection(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw this.forceReconnect(`probe_${e}_socket_unavailable`),Error(`WebSocket not connected`);return this.pendingProbe?new Promise((e,t)=>{let n=this.pendingProbe;if(!n){t(Error(`Connection probe unavailable`));return}this.pendingProbe={...n,resolve:e,reject:t}}):new Promise((t,n)=>{let r=_p(),i=setTimeout(()=>{this.pendingProbe?.id===r&&(this.forceReconnect(`probe_timeout`),n(Error(`Connection probe timeout`)))},gp);this.pendingProbe={id:r,resolve:t,reject:n,timeoutId:i,trigger:e},this.pendingCommands.set(r,{resolve:()=>{this.pendingProbe?.id===r&&(this.clearPendingProbe(),t({ok:!0}))},reject:e=>{this.pendingProbe?.id===r&&(this.clearPendingProbe(),this.forceReconnect(`probe_rejected`),n(e))},timeoutId:i});let a={kind:`command`,id:r,op:`connection.probe`,args:{}};this.ws.send(JSON.stringify(a))})}async sendCommand(e,t,n={}){return new Promise((r,i)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){i(Error(`WebSocket not connected`));return}let a=_p(),o=n.timeoutMs??hp,s=setTimeout(()=>{this.cleanupTimedOutBinaryCommand(a),this.pendingCommands.delete(a),i(Error(`Command timeout: ${e}`))},o);this.pendingCommands.set(a,{resolve:r,reject:i,timeoutId:s});let c={kind:`command`,id:a,op:e,args:t};this.ws.send(JSON.stringify(c))})}async sendTerminalInput(e,t,n,r){return new Promise((i,a)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){a(Error(`WebSocket not connected`));return}let o=_p(),s=this.allocateTerminalInputStreamId(),c=setTimeout(()=>{this.cleanupTimedOutBinaryCommand(o),this.pendingCommands.delete(o),a(Error(`Command timeout: terminal.input`))},hp);this.pendingCommands.set(o,{resolve:i,reject:a,timeoutId:c});let l={kind:`command`,id:o,op:`terminal.input`,args:{terminalId:e,transport:`binary`,streamId:s,size:t.byteLength,activity:n,submittedText:r}};this.ws.send(JSON.stringify(l)),this.ws.send(t)})}subscribe(e,t){let n=[];for(let r of e)this.eventListeners.has(r)||(this.eventListeners.set(r,new Set),n.push(r)),this.eventListeners.get(r).add(t);if(n.length>0&&this.ws&&this.ws.readyState===WebSocket.OPEN){let e={kind:`subscribe`,topics:n};this.ws.send(JSON.stringify(e))}return()=>{let n=[];for(let r of e){let e=this.eventListeners.get(r);e&&(e.delete(t),e.size===0&&(this.eventListeners.delete(r),n.push(r)))}if(n.length>0&&this.ws&&this.ws.readyState===WebSocket.OPEN){let e={kind:`unsubscribe`,topics:n};this.ws.send(JSON.stringify(e))}}}onStatus(e){return this.statusListeners.add(e),()=>this.statusListeners.delete(e)}getStatus(){return this.status}handleMessage(e){if(e.kind===`result`){let t=this.pendingCommands.get(e.id);if(t){if(e.ok&&this.isTerminalBinaryCommandResult(e.data)){let n=this.getExpectedFrameType(e.data),r=this.orphanBinaryPayloads.get(e.data.streamId);if(r){if(this.orphanBinaryPayloads.delete(e.data.streamId),clearTimeout(r.timeoutId),r.frameType===n){clearTimeout(t.timeoutId),this.pendingCommands.delete(e.id),t.resolve({...e.data,bytes:r.bytes});return}console.warn(`Discarding terminal binary frame with unexpected type`,{streamId:e.data.streamId,expectedFrameType:n,actualFrameType:r.frameType})}t.terminalBinary=e.data,t.binaryStreamId=e.data.streamId,this.pendingBinaryStreamIds.set(e.data.streamId,{commandId:e.id,expectedFrameType:n});return}clearTimeout(t.timeoutId),this.pendingCommands.delete(e.id),e.ok?t.resolve(e.data):t.reject(new pp({code:e.error?.code??`command_failed`,message:e.error?.message??`Command failed`,details:e.error?.details}))}}else e.kind===`event`&&(this.lastSeenSeq.set(e.topic,e.seq),this.notifyEventListeners(e.topic,e.data,e.seq))}handleBinaryMessage(e){if(e.length===0)return;if(e[0]===2){let t=sp(e);this.notifyEventListeners(t.topic,{transport:`binary`,streamId:t.streamId,size:t.payload.byteLength,bytes:t.payload},t.seq);return}let{header:t,payload:n}=op(e),r=this.pendingBinaryStreamIds.get(t.streamId);if(!r){let e=this.orphanBinaryPayloads.get(t.streamId);e&&clearTimeout(e.timeoutId),this.orphanBinaryPayloads.set(t.streamId,{frameType:t.type,bytes:n,timeoutId:setTimeout(()=>{this.orphanBinaryPayloads.delete(t.streamId)},hp)});return}if(t.type!==r.expectedFrameType){console.warn(`Discarding terminal binary frame with unexpected type`,{streamId:t.streamId,expectedFrameType:r.expectedFrameType,actualFrameType:t.type});return}this.pendingBinaryStreamIds.delete(t.streamId);let i=this.pendingCommands.get(r.commandId);i?.terminalBinary&&(clearTimeout(i.timeoutId),this.pendingCommands.delete(r.commandId),i.resolve({...i.terminalBinary,bytes:n}))}notifyEventListeners(e,t,n){for(let[r,i]of this.eventListeners.entries())if(fp(r,e))for(let r of i)try{r(e,t,n)}catch(t){console.error(`Error in event listener for ${e}:`,t)}}isTerminalBinaryCommandResult(e){return typeof e==`object`&&!!e&&`status`in e&&`transport`in e&&`streamId`in e&&`size`in e&&e.status===`ok`&&e.transport===`binary`}getExpectedFrameType(e){return`source`in e?ap.Snapshot:ap.Replay}cleanupTimedOutBinaryCommand(e){let t=this.pendingCommands.get(e)?.binaryStreamId;if(t==null)return;this.pendingBinaryStreamIds.delete(t);let n=this.orphanBinaryPayloads.get(t);n&&(clearTimeout(n.timeoutId),this.orphanBinaryPayloads.delete(t))}clearBinaryCommandState(){this.pendingBinaryStreamIds.clear();for(let e of this.orphanBinaryPayloads.values())clearTimeout(e.timeoutId);this.orphanBinaryPayloads.clear()}resolveConnectDeferred(){let e=this.connectDeferred;e&&(this.connectDeferred=null,e.resolve())}rejectConnectDeferred(e){let t=this.connectDeferred;t&&(this.connectDeferred=null,t.reject(e))}rejectPendingCommands(e){for(let[t,n]of this.pendingCommands)clearTimeout(n.timeoutId),n.reject(e),this.pendingCommands.delete(t)}allocateTerminalInputStreamId(){let e=this.nextTerminalInputStreamId;return this.nextTerminalInputStreamId+=1,e}handleClose(e,t){if(this.ws=null,this.rejectPendingCommands(Error(`WebSocket disconnected`)),this.clearBinaryCommandState(),this.clearPendingProbe(),e===4001||e===4002){this.setStatus(`rejected`);return}this.isManualClose||this.scheduleReconnect()}scheduleReconnect(){if(this.reconnectAttempts>=this.reconnectConfig.maxAttempts){console.error(`Max reconnect attempts reached`),this.setStatus(`disconnected`);return}this.setStatus(`reconnecting`);let e=Math.min(this.reconnectConfig.baseDelayMs*2**this.reconnectAttempts,this.reconnectConfig.maxDelayMs);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect().catch(e=>{console.error(`Reconnect failed:`,e)})},e)}resync(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||this.lastSeenSeq.size===0)return;let e={kind:`resync`,lastSeen:Object.fromEntries(this.lastSeenSeq)};this.ws.send(JSON.stringify(e))}setStatus(e){this.status=e;for(let t of this.statusListeners)try{t(e)}catch(e){console.error(`Error in status listener:`,e)}}forceReconnect(e){if(this.clearPendingProbe(),this.ws){let t=this.ws;this.ws=null;try{t.close(4e3,e)}catch{}}this.handleClose(1006,e)}clearPendingProbe(){this.pendingProbe&&=(clearTimeout(this.pendingProbe.timeoutId),this.pendingCommands.delete(this.pendingProbe.id),null)}};function yp(){return typeof window>`u`?`ws://127.0.0.1:4173/ws`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/ws`}var bp=V(null),xp=V(`connecting`),Sp=V(null),Cp=V(!1),wp=V(null),Tp=V(0),Ep=V(null),Dp=V(null),Op=V(e=>{let t=e(bp);return async(e,n,r)=>{if(!t)return{ok:!1,error:{code:`no_client`,message:`WebSocket client not initialized`}};try{return{ok:!0,data:await t.sendCommand(e,n,r)}}catch(e){return e instanceof pp?{ok:!1,error:{code:e.code,message:e.message,details:e.details}}:{ok:!1,error:{code:`command_error`,message:e instanceof Error?e.message:`Unknown error`}}}}});V(`tab_${Date.now()}_${Math.random().toString(36).substring(2,9)}`);var kp=V(new Map);V(e=>t=>e(kp).get(t)?.isController??!1),V(e=>t=>e(kp).get(t)?.reason),V(e=>{let t=e(kp);for(let e of t.values())if(!e.isController)return!0;return!1});function Ap(e,t){let n=null,r=new Map,i=new Set;function a(i){let s;if(t===void 0)s=r.get(i);else for(let[e,n]of r)if(t(e,i)){s=n;break}if(s!==void 0)if(n?.(s[1],i))a.remove(i);else return s[0];let c=e(i);return r.set(i,[c,Date.now()]),o(`CREATE`,i,c),c}function o(e,t,n){for(let r of i)r({type:e,param:t,atom:n})}return a.unstable_listen=e=>(i.add(e),()=>{i.delete(e)}),a.getParams=()=>r.keys(),a.remove=e=>{if(t===void 0){if(!r.has(e))return;let[t]=r.get(e);r.delete(e),o(`REMOVE`,e,t)}else for(let[n,[i]]of r)if(t(n,e)){r.delete(n),o(`REMOVE`,n,i);break}},a.setShouldRemove=e=>{if(n=e,n)for(let[e,[t,i]]of r)n(i,e)&&(r.delete(e),o(`REMOVE`,e,t))},a}var jp=V(null),Mp=V({}),Np=V([]),Pp=V(`idle`),Fp=V(null),Ip=Ap(e=>V(t=>t(Mp)[e])),Lp=V(e=>{let t=e(Np),n=e(Mp),r=new Set(Object.keys(n)),i=t.filter(e=>r.has(e)),a=new Set(i),o=Object.keys(n).filter(e=>!a.has(e));return[...i,...o]}),Rp=V(e=>e(Lp).map(t=>e(Ip(t))).filter(e=>!!e)),zp=V(e=>{if(e(Pp)!==`ready`)return null;let t=e(jp),n=e(Mp);return t&&n[t]?t:e(Lp)[0]??null}),Bp=V(e=>{let t=e(zp);return t?e(Ip(t)):null}),Vp=V({}),Hp=Ap(e=>V(t=>{let n=t(Vp);return Object.values(n).filter(t=>t.workspaceId===e)})),Up=Ap(e=>V(t=>t(Vp)[e]));V(e=>{let t=e(zp);return t?e(Hp(t)).find(e=>e.state===`running`||e.state===`idle`)??null:null}),Ap(e=>V(t=>{let n=t(Hp(e)),r={draft:0,starting:0,running:0,idle:0,ended:0};for(let e of n)r[e.state]++;return r}));function Wp(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Wp(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Y(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Wp(e))&&(r&&(r+=` `),r+=t);return r}function Gp(e){return e.target===e.currentTarget}function Kp(e){return e.key===`Escape`}var qp=[`a[href]`,`area[href]`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`iframe:not([tabindex="-1"])`,`object:not([tabindex="-1"])`,`embed:not([tabindex="-1"])`,`[contenteditable="true"]`,`[tabindex]:not([tabindex="-1"])`].join(`, `);function Jp(e){return e instanceof HTMLElement}function Yp(e){return Array.from(e.querySelectorAll(qp)).filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`)}function Xp(e,t){let n=typeof t==`function`?t():t;return n&&e.contains(n)&&!n.hasAttribute(`disabled`)?n:Yp(e)[0]??e}function Zp(e,t){if(t.key!==`Tab`)return;let n=Yp(e);if(n.length===0){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],a=Jp(document.activeElement)?document.activeElement:null;if(t.shiftKey){(!a||a===r||!e.contains(a))&&(t.preventDefault(),i.focus());return}(!a||a===i||!e.contains(a))&&(t.preventDefault(),r.focus())}function Qp(e){e instanceof HTMLElement&&e.isConnected&&e.focus()}function $p({children:e}){let t=typeof document>`u`?null:document.body;return t?(0,Fr.createPortal)(e,t):null}var em=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),tm=t(((e,t)=>{t.exports=em()})),X=tm();function nm({title:e,onBack:t,backLabel:n=`Back`,backAriaLabel:r,kicker:i,rightSlot:a,titleAs:o=`h2`,level:s=`secondary`,className:c}){let l=o;return(0,X.jsxs)(`div`,{className:Y(`page-header`,`page-header--${s}`,c),"data-level":s,children:[(0,X.jsxs)(`div`,{className:`page-header__leading`,children:[t?(0,X.jsxs)(`button`,{type:`button`,className:`page-header__back`,onClick:t,"aria-label":r??n,children:[(0,X.jsx)(di,{size:16}),(0,X.jsx)(`span`,{children:n})]}):null,(0,X.jsxs)(`div`,{className:`page-header__copy`,children:[i?(0,X.jsx)(`div`,{className:`page-header__kicker`,children:i}):null,(0,X.jsx)(l,{className:`page-header__title`,children:e})]})]}),a?(0,X.jsx)(`div`,{className:`page-header__actions`,children:a}):null]})}function rm({className:e,kicker:t,showKicker:n=!1,...r}){return(0,X.jsx)(nm,{...r,kicker:n?t:void 0,className:Y(`mobile-page-header`,e)})}var im={datetime:{today:`Today`,tomorrow:`Tomorrow`,next_week:`Next Week`,prev_month:`Previous Month`,next_month:`Next Month`,clear:`Clear`,confirm:`Confirm`,select_date:`Select Date`,select_time:`Select Time`,hour:`Hour`,minute:`Minute`,january:`January`,february:`February`,march:`March`,april:`April`,may:`May`,june:`June`,july:`July`,august:`August`,september:`September`,october:`October`,november:`November`,december:`December`,sun:`Sun`,mon:`Mon`,tue:`Tue`,wed:`Wed`,thu:`Thu`,fri:`Fri`,sat:`Sat`},app:{name:`Coder Studio`,description:`Agent-First Development Environment`},common:{loading:`Loading...`,error:`Error`,success:`Success`,warning:`Warning`,info:`Info`,enabled:`Enabled`,disabled:`Disabled`,confirm:`Confirm`,cancel:`Cancel`,save:`Save`,delete:`Delete`,edit:`Edit`,view:`View`,close:`Close`,yes:`Yes`,no:`No`,ok:`OK`,all:`All`},action:{open:`Open`,open_workspace:`Open Workspace`,close_workspace:`Close Workspace`,create_session:`Create Session`,stop_session:`Stop Session`,resume_session:`Resume Session`,save_file:`Save File`,save_all:`Save All`,save:`Save`,discard_changes:`Discard Changes`,commit:`Commit`,push:`Push`,pull:`Pull`,refresh:`Refresh`,settings:`Settings`,cancel:`Cancel`,confirm:`Confirm`,close:`Close`,apply:`Apply`,reset:`Reset`,search:`Search`,search_files:`Search Files`,search_commands:`Search Commands`,back:`Back`,expand:`Expand`,collapse:`Collapse`,close_all:`Close all`},label:{workspace:`Workspace`,agent:`Agent`,session:`Session`,terminal:`Terminal`,file:`File`,git:`Git`,settings:`Settings`,provider:`Provider`,status:`Status`,progress:`Progress`},provider:{install:{cta:{start:`Start Session`,install_and_start:`Install & Start`,installing:`Installing...`,manual:`View Install Steps`},status:{installing:`Installing provider CLI...`,failed:`Automatic install failed`},open_docs:`Open official docs`,nodejs:{manual:`Install Node.js from the official download page.`},claude:{manual:`Then run npm install -g @anthropic-ai/claude-code.`},codex:{manual:`Then run npm install -g @openai/codex.`}}},status:{starting:`Starting`,running:`Running`,idle:`Idle`,busy:`Busy`,ended:`Ended`,unavailable:`Unavailable`,connecting:`Connecting`,connected:`Connected`,disconnected:`Disconnected`,reconnecting:`Reconnecting`,rejected:`Rejected`},workspace:{title:`Workspace`,tabs:`Workspace tabs`,open:`Open`,close:`Close`,path:`Path`,no_workspace:`No workspace open`,refresh_partial_title:`Workspace refresh incomplete`,refresh_partial_body:`Updated what we could, but these sections failed: {sections}`,fullscreen:{unsupported_title:`Fullscreen unavailable`,unsupported_body:`Fullscreen is not available in this browser.`,enter_failed_title:`Could not enter fullscreen`,enter_failed_body:`The browser denied the fullscreen request.`,exit_failed_title:`Could not exit fullscreen`,exit_failed_body:`The browser could not exit fullscreen right now.`},open_hint:`Click the button below to open a project directory`,loading_title:`Loading workspaces`,loading_description:`Preparing your workspace list and restoring the last active session.`,load_failed_title:`Failed to load workspaces`,load_failed_description:`Failed to fetch workspace list`,sidebar:{label:`Workspace activity bar`,explorer:`Explorer`,search:`Search`,source_control:`Source Control`,open_editors:`Open Editors`,workspace:`Workspace`},quick_jump:{title:`Quick Jump`,placeholder:`Type a filename or path`,no_results:`No matching files found.`,failed:`File search failed. Try again.`},open_editors:{title_with_count:`{title} ({count})`,close_path:`Close {path}`,expand_label:`Expand Open Editors`,collapse_label:`Collapse Open Editors`},search:{empty:`Type to search across file contents.`,placeholder:`Search across file contents`,results_count:`{count} results in {files} files`,no_results:`No content matches found.`,truncated:`Results limited to keep search responsive.`,file_match_count:`{count}{suffix} matches`,failed:`Search failed. Try again.`,retry:`Retry`},launch:{kicker:`START WORKSPACE`,title:`Open Workspace`,home_directory:`Home Directory`,go_up:`Go Up`,no_directories:`No directories found`,items_count:`{count} items`,enter_folder:`Enter {name}`,enter_folder_action:`Enter folder →`,cancel:`Cancel`,start:`Start Workspace`,starting:`Starting...`,hint:`Select a directory to use as the workspace root.`,browse_failed:`Failed to browse directories`,select_required:`Please select a directory`,open_failed:`Failed to open workspace`},runtime_check:{title:`Runtime Check`,checking:`Checking runtime environment...`,success:`Runtime environment check passed`,failed:`Runtime environment check failed`,missing_git:`Git command not found`,missing_node:`Node.js not found`,missing_provider:`{provider} CLI not found`}},quick_open:{title:`Go to File`,placeholder:`Type a filename or path`,empty:`Type to search by filename or path.`,no_results:`No matching files found.`,failed:`File search failed. Try again.`,command_label:`Go to File...`,command_description:`Quickly open a file in the current workspace`},mobile:{dock:{aria_label:`Mobile dock`,open_agent:`Open Agent sheet`,open_files:`Open Files sheet`,open_terminal:`Open Terminal sheet`},agent:{title:`Agent Sessions`,close_current_session:`Close Current Session`,providers:`Session providers`,start_session:`Start {provider} session`,starting:`Starting...`,start_new_session:`Start new session`,active_agents:`Active agents`,switch_to_agent:`Switch to agent {name}`,empty:`No active sessions`},supervisor:{open_sheet:`Open Supervisor sheet`},topbar:{switch_workspace:`Switch workspace`,open_settings:`Open settings`},sheet:{dismiss:`Dismiss current sheet`,region:`{title} sheet`},files:{tabs:`Files sheet tabs`,git_diff:`Git`,editor_fallback:`Editor`},workspace_drawer:{aria_label:`Workspace drawer`,close:`Close workspace drawer`,select_title:`Select workspace`,switch_to_workspace:`Switch to workspace {name}`,close_workspace:`Close workspace {name}`},empty:{start_session:`Start a new agent session for this workspace.`,files_terminal_hint:`Files and Terminal stay available from the bottom bar.`}},session:{title:`Session`,create:`Create Session`,stop:`Stop`,resume:`Resume`,no_session:`No active session`,provider_select:`Select Agent`,state:{starting:`Starting...`,running:`Running`,idle:`Waiting for input`,busy:`Executing`,ended:`Stopped`,unavailable:`Unavailable`},resume_unavailable:`This session cannot be resumed`,progress:{thinking:`Thinking...`,executing:`Executing...`,waiting:`Waiting for response...`}},terminal:{title:`Terminal`,kicker:`TERMINAL`,new_terminal:`New Terminal`,close_terminal:`Close Terminal`,shell:`Shell Terminal`,agent:`Agent Terminal`,reconnect_hint:`Connection lost, reconnecting...`,no_terminal:`No terminals`,empty_hint:`Launch a shell to inspect files, run commands, and verify changes without leaving the workspace.`,load_failed_title:`Could not load terminals`,load_failed_body:`Refresh the workspace connection and try again.`,create_failed_title:`Could not create terminal`,create_failed_body:`The shell process could not be started. Check the server runtime and shell configuration.`,create_unavailable_title:`No workspace selected`,create_unavailable_body:`Open or switch to a workspace before creating a terminal.`,copied_current_line:`Copied current line`,mobile_copy_current_line_failed_title:`Current line copy failed`,mobile_copy_current_line_failed_body:`Try long-pressing the current line again`,paste_dialog_title:`Paste Text`,paste_dialog_placeholder:`Paste your text here...`,paste_dialog_submit:`Send`,hide:`Hide Terminal`,show:`Show Terminal`,selector:{switch:`Switch terminal`,title:`Terminal Sessions`,current:`Current terminal`,indexed:`Terminal {index}`},mobile_input:{paste:`Paste`,upload:`Upload`,shortcuts:`Terminal shortcut keys`,ctrl:`Ctrl`,ctrl_armed:`Ctrl armed`,ctrl_locked:`Ctrl locked`,shift:`Shift`,shift_armed:`Shift armed`,escape:`Escape`,tab:`Tab`,enter:`Enter`,up:`Up arrow`,down:`Down arrow`,left:`Left arrow`,right:`Right arrow`},replay:{queued_title:`Waiting in queue ({count} ahead)`,up_next:`Up next...`,loading_title:`Restoring terminal output...`,loading_body:`This terminal is unavailable while history is being restored. Please wait until recovery finishes before continuing. Larger histories may take longer to restore.`,failed_title:`Terminal history was not restored yet`,failed_body:`The terminal is still usable, but older output still could not be filled back in. Try again later or after a refresh; if the server still retains the history, it may still come back.`,retryable_title:`Terminal history was not restored yet`,retryable_body:`The terminal is still usable, but older output was not filled back in this time. You can retry recovery; if the server still retains the history, it may still come back later or after a refresh.`,retry_action:`Retry recovery`,unrecoverable_title:`Earlier history can no longer be restored`,unrecoverable_body:`Older terminal output has already fallen out of the replay buffer and there is no usable snapshot available now. Only later output can still be viewed.`,unknown_title:`This terminal can no longer be restored`,unknown_body:`This terminal session is no longer present on the server, so its history cannot be recovered. Open a new terminal to continue.`,unknown_body_with_provider:`This terminal session is no longer present on the server. Reopen a {provider} session to continue?`,closed_title:`This session has ended`,closed_body:`Reopen a new session to continue?`,closed_body_with_provider:`Reopen a {provider} session to continue?`,truncated_title:`Terminal history is partial`,truncated_body:`Older output has already fallen out of the replay buffer, but new output will continue to stream.`}},file:{title:`Files`,modified:`Modified`,unsaved:`Unsaved`,dirty:`Has unsaved changes`,visible_count:`{count} files`,empty_directory:`Empty directory`,new_file:`New File`,new_folder:`New Folder`,collapse_all:`Collapse All`,rename:`Rename`,rename_name:`Name`,rename_helper:`Rename within the current directory only.`,rename_required:`Name is required.`,rename_invalid_name:`Name cannot contain / or \\.`,rename_failed:`Could not rename file`,delete:`Delete`,delete_confirm:`Are you sure you want to delete "{name}"?`,copy_relative_path:`Copy Relative Path`,copy_absolute_path:`Copy Absolute Path`,open_in_terminal:`Open in Terminal`,context_menu_title:`File actions`,context_section_create:`Create`,context_section_edit:`Edit`,context_section_path:`Path`,context_section_terminal:`Terminal`,path:`Path`,path_required:`Enter a path`,invalid_file_path:`File paths cannot end with /`,path_helper_file:`Enter a workspace-relative path, for example src/demo/new-file.ts`,path_helper_folder:`Enter a workspace-relative path, for example src/demo/new-folder`,create_failed:`Failed to create item`,delete_failed:`Failed to delete file`,conflict:`File has been modified externally`,conflict_message:`The file may have been modified outside the editor. Discard local changes and reload?`},code_editor:{saving:`Saving...`,edit_as_text:`Edit as text`,preview_as_image:`Preview as image`,preview_loading:`Loading preview...`,preview_unavailable:`Preview unavailable`,preview_retry:`Retry`,mode_text:`Text`,mode_image:`Image`,mode_preview:`Preview`,mode_edit:`Edit`,mode_diff:`Diff`,diff_saved_only:`Diff preview is based on saved file contents.`,open_failed_title:`Failed to open file`,empty_hint:`Select a file on the left to open it in the editor.`,modified_on_disk:`This file changed on disk after you opened it. Save carefully or reload the file.`,deleted_on_disk:`This file was deleted on disk after you opened it.`},git:{title:`Git`,changes:`Changes`,staged:`Staged`,modified:`Modified`,deleted:`Deleted`,unstaged:`Unstaged`,untracked:`Untracked`,no_changes:`No changes`,commit:`Commit`,commit_message:`Commit Message`,commit_placeholder:`Enter commit message...`,commit_summary_placeholder:`Enter commit message...`,commit_staged_count:`{count} staged`,nothing_staged:`Nothing staged`,latest_commit:`Latest Commit`,history:`History`,show_all_history:`Show all history`,change_count:`{count} changes`,no_commits:`No commits yet`,stage:`Stage`,unstage:`Unstage`,stage_all:`Stage All`,unstage_all:`Unstage All`,stage_failed_title:`Stage failed`,unstage_failed_title:`Unstage failed`,discard:`Discard`,discard_all:`Discard All`,discard_failed_title:`Discard failed`,discard_file_confirm_title:`Discard File Changes`,discard_file_confirm_message:`Are you sure you want to discard changes in "{path}"?`,discard_all_confirm_title:`Discard All Changes`,discard_all_confirm_message:`Are you sure you want to discard changes in {count} files?`,discard_confirm_irreversible:`This action cannot be undone.`,commit_failed_title:`Commit failed`,branch:`Branch`,switch_branch:`Switch Branch`,current_branch:`Current Branch`,no_branch:`Not on any branch`,ahead:`{count} commits ahead`,behind:`{count} commits behind`,synced:`Synced with remote`,push_confirm_title:`Push Changes`,push_confirm_message:`Do you want to push {count} local commits to the remote?`,pull_confirm_title:`Pull Changes`,pull_confirm_message:`Do you want to pull {count} remote commits into your local branch?`,sync_confirm_helper:`This action updates your current branch and workspace state.`,push_success_title:`Push completed`,push_success_body:`Local commits were pushed to the remote.`,push_success_target:`Pushed to {target}`,pull_success_title:`Pull completed`,pull_success_body:`Latest remote commits were pulled into your local branch.`,pull_success_target:`Pulled updates from {target}`,sync_up_to_date:`{target} is already up to date`,push_in_progress:`Pushing...`,pull_in_progress:`Pulling...`,push_failed_title:`Push failed`,pull_failed_title:`Pull failed`,fetch_success_title:`Fetched from remote`,fetch_success_body:`Remote tracking branches are up to date.`,fetch_failed_title:`Fetch failed`,fetch_refresh_failed_body:`Fetched from remote, but refreshing local git state failed.`,fetch_in_progress:`Fetching...`,fetch_label:`Fetch`,fetch_last_at:`Last fetched {when}`,fetch_last_never:`Never fetched`,operation_push:`push`,operation_pull:`pull`,operation_fetch:`fetch`,auth_required_message:`Authentication is required for {remote}.`,auth_failed_invalid:`Credentials for {remote} were rejected. Enter a valid username and password or personal access token to continue.`,auth_failed_forbidden:`Credentials for {remote} were accepted, but this account is not allowed to {operation}.`,auth_failed_unsupported:`Authentication failed for {remote}. Configure SSH keys or a credential helper, then try again.`,auth_helper_http:`Enter your Git username and password or a personal access token to retry this operation.`,auth_helper_unsupported:`This remote does not support in-app authentication. Configure SSH keys or a credential helper, then try again.`,auth_username:`Username`,auth_password:`Password or token`,auth_username_placeholder:`Git username`,auth_password_placeholder:`Password or personal access token`,branch_remote:`Remote`,quick_pick:{search_placeholder:`Search branches or create new branch...`,loading:`Loading branches...`,empty_filtered:`No branches found`,empty_idle:`Type to search branches`,in_use:`In Use`,worktree_in_use:`Checked out in another worktree`,checkout_failed_title:`Failed to switch branch`,checkout_failed_body:`Could not switch to {name}.`,create_failed_title:`Failed to create branch`,create_failed_body:`Could not create {name}.`,create_label:`Create branch`,confirm_create_label:`Confirm create branch`,create:`Create branch: {name}`,confirm_create:`Confirm create branch: {name}`},statusbar:{changes:`Uncommitted file changes`,ahead:`Local commits to push`,behind:`Remote commits to pull`}},worktree:{title:`Worktree`,status_tab:`Status`,diff_tab:`Diff`,tree_tab:`Tree`,path:`Path`,branch:`Branch`,changes:`Changes`,loading:`Loading...`,empty_tree:`Empty tree`,clean:`Clean`,dirty:`Dirty`,dirty_status:`Has changes`,staged_count:`Staged: {count}`,modified_count:`Modified: {count}`,untracked_count:`Untracked: {count}`,list_title:`Worktrees`,list_empty:`No worktrees`,list_open_label:`Open worktree list`,list_error:`Failed to load: {error}`,manage:`Manage`,new:`New`,current:`Current`,summary_total:`{count} worktrees`,summary_dirty:`{count} dirty`,summary_current:`Current: {name}`,summary_no_current:`Current: unavailable`,create_title:`Create Worktree`,create_submit:`Create`,create_path_hint:`Path must be absolute. The suggested path is derived from the current workspace path.`,create_path_absolute_required:`Path must be an absolute path.`,create_failed_title:`Failed to create worktree`,create_success_title:`Worktree created`,create_success_body:`{name} is ready.`,remove_confirm:`Remove worktree?`,remove_force_confirm:`Force remove dirty worktree?`,remove_failed_title:`Failed to remove worktree`,remove_success_title:`Worktree removed`,remove_success_body:`Worktree removed.`,force_remove:`Force Remove`,remove_row_label:`Remove {name}`,selection_removed:`The selected worktree is no longer available.`},settings:JSON.parse(`{"title":"Settings","general":"General","appearance":"Appearance","providers":"Agents","mobile_groups":{"workspace_runtime":"Workspace & Runtime","interface_interaction":"Interface & Interaction"},"about":{"title":"About","description":"View basic app details, version status, and update actions.","product_name":"Product","current_version":"Current Version","server_instance_id":"Server Instance ID","install_support":"Install Support","install_supported":"In-app update supported","install_unsupported":"This install shape does not support in-app updates","update_group":"Update","update_group_hint":"Check for new releases manually and start updates when the install shape supports it.","latest_version":"Latest Version","last_checked":"Last Checked","availability":"Availability","availability_unknown":"Not checked yet","availability_up_to_date":"Up to date","availability_update_available":"Update available","availability_check_failed":"Check failed","update_status":"Workflow Status","update_status_unknown":"Unknown","update_status_idle":"Idle","update_status_checking":"Checking","update_status_installing":"Installing","update_status_restarting":"Restarting service","update_status_succeeded":"Update succeeded","update_status_failed":"Update failed","update_status_manual_required":"Manual action required","error_summary":"Error Summary","manual_command":"Manual Command","check_now":"Check Now","checking":"Checking","check_failed":"Failed to check for updates","update_now":"Update Now","installing":"Working","auto_check_group":"Automatic Checks","auto_check_group_hint":"Configure the npm polling cadence. These preferences are persisted in the settings file.","auto_check_enabled":"Automatically check for updates","auto_check_enabled_hint":"When enabled, the service polls for the latest version on the selected interval.","check_interval":"Check Interval","interval_3600":"1 hour","interval_21600":"6 hours","interval_43200":"12 hours","interval_86400":"24 hours","confirm_update_title":"Confirm Update","confirm_update_message":"Updating installs a new version and restarts the service. Running terminals, agent sessions, or supervisor tasks may be interrupted.","confirm_update_activity":"{terminals} terminals, {sessions} sessions, and {supervisors} supervisor tasks are still active.","footer_update_available":"New version detected {version}","footer_installing":"Updating...","footer_restarting":"Restarting service...","footer_failed":"Update failed","footer_manual_required":"Manual action required","footer_view_details":"View details","footer_succeeded":"Updated to {version}"},"help_diagnostics":"Help & Diagnostics","autosave_hint":"Settings saved automatically","load_failed":"Failed to load settings","load_failed_unknown":"Server did not return settings data","notifications":"Notifications","notifications_channel_hint":"No notification while you are in the originating workspace; an in-app banner if you are in another workspace; a system notification when the window is hidden.","notifications_enabled":"Enable completion notifications","notifications_enabled_hint":"Send notification when Agent session completes","notification_sound":"Notification sound","notification_sound_hint":"Play a completion chime when a notification fires","notification_status":"Notification Status","notification_status_available":"Available","notification_status_limited":"Limited","notification_status_limited_hint":"System notifications on this mobile browser are inconsistent; browser permission does not guarantee delivery.","notification_status_unsupported":"Unsupported","notification_status_unsupported_hint":"This browser environment does not support this notification path.","notification_permission":"Notification Permission","permission_granted":"Granted","permission_denied":"Denied","permission_request":"Request Permission","permission_unavailable":"Unavailable","permission_limited_hint":"Even with notification permission allowed, this mobile browser may still fail to show system notifications reliably.","supervisor":{"title":"Supervisor","hint":"Configure supervisor evaluation timeout and global retry behavior. Retry rules apply to all supervisors.","evaluation_timeout":"Supervisor Evaluation Timeout (seconds)","validation_error":"Enter a whole number between 1 and {max} seconds.","retry_enabled":"Enable Supervisor Retries","retry_enabled_hint":"Automatically retry when evaluation times out or the evaluator fails.","retry_max_count":"Max Retry Count","retry_max_count_validation_error":"Enter a whole number between 0 and {max}.","retry_delay_sec":"Retry Delay (seconds)","retry_delay_validation_error":"Enter a whole number between 1 and {max} seconds.","retry_on_timeout":"Retry On Timeout","retry_on_timeout_hint":"Retry automatically after evaluation timeout.","retry_on_evaluator_error":"Retry On Evaluator Error","retry_on_evaluator_error_hint":"Retry automatically when the evaluator process or runtime fails."},"terminal_renderer":"Terminal Renderer","terminal_renderer_hint":"Choose terminal rendering mode","lsp_runtime_mode":"LSP Runtime Mode","lsp_runtime_mode_hint":"Control code intelligence memory usage. Turning it off immediately stops active language service processes, so diagnostics, go-to-definition, hover, and similar features become temporarily unavailable.","lsp_runtime_mode_auto":"Auto","lsp_runtime_mode_off":"Off","appearance_background_material":"Background & Material","appearance_background_material_hint":"Configure account-synced wallpapers, glass effects, and surface opacity, with optional desktop and mobile overrides.","appearance_background_mode":"Background mode","appearance_background_mode_off":"Off","appearance_background_mode_image":"Image","appearance_background_upload":"Background image","appearance_background_replace":"Replace background image","appearance_background_remove":"Remove background image","appearance_background_fit":"Background fit","appearance_background_fit_cover":"Cover","appearance_background_fit_contain":"Contain","appearance_background_dimness":"Background dimness","appearance_background_blur":"Background blur","appearance_glass_enabled":"Enable glass effect","appearance_glass_intensity":"Glass intensity","appearance_surface_opacity":"Surface opacity","appearance_override_desktop":"Desktop override","appearance_override_mobile":"Mobile override","appearance_override_enabled":"Custom value enabled","appearance_uses_shared_value":"Using the shared value","appearance_asset_upload_failed":"Failed to upload background image","appearance_asset_delete_failed":"Failed to remove background image","terminal_appearance":"Terminal Appearance","copy_on_select":"Copy on select","copy_on_select_hint":"Automatically copy selected text to the system clipboard","terminal_font_size":"Terminal font size","terminal_font_size_hint":"Set separate terminal font sizes for desktop and mobile. Open terminals update immediately.","desktop_terminal_font_size":"Desktop terminal font size","desktop_terminal_font_size_hint":"Applies to desktop and other pointer-precise terminals.","mobile_terminal_font_size":"Mobile terminal font size","mobile_terminal_font_size_hint":"Applies to phones, tablets, and other mobile terminals.","terminal_font_size_validation_error":"Enter a whole number between {min} and {max}.","copy_on_select_failed_title":"Copy on select failed","copy_on_select_failed_body":"Use Ctrl/Cmd+C to copy manually","terminal_standard":"Standard","terminal_compatibility":"Compatibility Mode","provider":{"title":"Agent Settings","status":"Status","capability":"Capability Level","capability_full":"Full Support","capability_limited":"Limited Support","capability_unsupported":"Unsupported","hooks_registered":"Hooks Registered","hooks_unregistered":"Hooks Not Registered","hooks_error":"Hooks Registration Failed","hooks":"Hooks Integration","hooks_hint":"Inject agent-specific hooks into current workspace","hooks_inject":"Inject Hooks","configure":"Configure","reset":"Reset","config":"Configuration","base":"Base Settings","config_file":"Config File","open_config_file_editor":"Open Config File Editor","back_to_base":"Back to Base Settings","startup_args":"Startup Command Args","startup_args_hint":"Enter one startup argument per line. Each saved line is appended to the agent launch command.","startup_args_placeholder":"--verbose\\n--debug","command_preview_title":"Command Preview","command_preview_hint":"Preview the effective agent launch command"},"theme":{"title":"Theme","dark":"Dark","light":"Light","system":"System","hint":"Choose app theme","family":"Theme Family","variant":"Variant","family_mint":"Mint","family_graphite":"Graphite","family_nord":"Nord","family_hc":"High Contrast","mint_dark":"Mint Dark","mint_light":"Mint Light","graphite_dark":"Graphite Dark","graphite_light":"Graphite Light","nord_dark":"Nord Dark","nord_light":"Nord Light","hc_dark":"High Contrast Dark","hc_light":"High Contrast Light","variant_dark":"Dark","variant_light":"Light"},"language":{"title":"Language","zh":"中文","en":"English","hint":"Select interface language"},"auth":{"title":"Authentication","password":"Password","password_set":"Set Password","password_change":"Change Password","password_remove":"Remove Password"},"shortcuts":{"title":"Keyboard Shortcuts","hint":"Review and adjust common keyboard actions","reset_all":"Reset All","capture_hint":"Press new shortcut combination","reset_hint":"Reset to default"},"config_files":{"title":"Config Files","codex_config":"Codex Config","claude_config":"Claude Config","path_label":"Path","unsaved_changes":"Unsaved changes","saving":"Saving...","save_success":"Config saved successfully","save_success_with_backup":"Updated {configPath} and created backup {backupPath}","backup_created":"Backup saved to {path}","save_failed":"Failed to save config","load_failed":"Failed to load config","file_not_found":"Config file does not exist. Edit and save to create it.","status_saved":"Saved","collapse":"Collapse","format":"Format","format_hint":"Format JSON code","file_not_found_hint":"Edit and save to create the config file."},"permission_denied_hint":"Browser or system notification permission may be blocked. Check site settings and device notification settings.","permission_unavailable_hint":"This environment cannot request browser notification permission"}`),auth:{description:`Enter your password to continue to the current workspace.`,hint:`Enter the access password configured for this deployment.`,blocked_until:`Too many attempts. Try again after {time}, or ask an administrator to unblock access.`,blocked_generic:`Too many attempts. Try again later, or ask an administrator to unblock access.`,status_title:`Access verification`,status_loading:`Checking the access state for this deployment.`,status_unavailable:`The authentication service is temporarily unavailable. Please try again shortly.`,status_not_configured:`Authentication is not configured on this deployment.`,session_gate_title:`SESSION GATE`,session_gate_description:`This tab was displaced by another tab and must re-enter before continuing.`,session_gate_detail:`The websocket connection has been closed. Recovery will reload fresh server state.`,session_gate_reenter:`Re-enter`,session_gate_reentering:`Re-entering`},connection:{title:`Connection`,status:`Status`,reconnecting:`Reconnecting...`,reconnect_failed:`Reconnection failed`,another_tab:`Another tab is active`,takeover:`Take Control`,server_shutdown:`Server has shut down`,backpressure_warning:`Network congested, some output may be lost`},supervisor:{title:`Supervisor`,empty:`Supervisor is not enabled`,completed_cycles:`Cycles {count}`,latest_evaluation:`Latest evaluation`,state:{inactive:`Inactive`,idle:`Idle`,evaluating:`Evaluating`,injecting:`Injecting`,paused:`Paused`,error:`Error`,stopped:`Stopped`},trigger:{manual:`MANUAL`,auto:`AUTO`,scheduled:`SCHEDULED`},cycle:{no_guidance:`No guidance injected this cycle`,evaluating:`Evaluating...`,waiting:`Waiting for evaluation result`,waiting_evaluator:`Waiting for evaluator response`,retry_wait:`Retrying evaluator in {seconds}s`,injecting:`Injecting guidance`,cancelled:`Cancelled`},stop_reason:{objective_complete:`Objective complete. Supervisor stopped automatically.`,max_supervision_count_reached:`Reached the configured max supervision count.`,supervisor_uncertain:`Supervisor could not determine the next step and stopped automatic supervision.`},target_memory:{title:`Target memory`,target:`Target`,stalled:`Stalled`,decomposition_ready:`Decomposition ready`,decomposition_pending:`Decomposition pending`,decomposition_mode_title:`Mode`,decomposition_title:`Decomposition`,basic_info_title:`Basic Info`,runtime_title:`Runtime Status`,runtime_status_label:`Status`,error_reason_label:`Error reason`,cycles_title:`Cycles`,progress_list_title:`Progress List`,item_objective_title:`Stage objective`,item_deliverable_title:`Deliverable`,active_item:`Active item`,progress_title:`Target progress`,progress_badge:`PROGRESS`,reasoning_title:`Target cycle reasoning`,runtime_status:{idle:`Idle`,running:`Running`,error:`Error`},decomposition_mode:{stage:`Stages`,subtarget:`Subtargets`},cycle_result:{continue:`CONTINUE`,stop:`STOP`,error:`ERROR`},step_status:{pending:`Not started`,in_progress:`In progress`,done:`Completed`}},meta:{title:`Execution policy`,no_cap:`No cap`},field:{objective:`Objective`,current_objective:`Current objective`,objective_placeholder:`Describe what Supervisor should watch, for example:
|
|
95
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Wu(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:qu(t,`input`,e.processors),output:qu(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Gu(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Gu(r.element,n);if(r.type===`set`)return Gu(r.valueType,n);if(r.type===`lazy`)return Gu(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Gu(r.innerType,n);if(r.type===`intersection`)return Gu(r.left,n)||Gu(r.right,n);if(r.type===`record`||r.type===`map`)return Gu(r.keyType,n)||Gu(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Gu(r.in,n)||Gu(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Gu(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Gu(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Gu(e,n))return!0;return!!(r.rest&&Gu(r.rest,n))}return!1}var Ku=(e,t={})=>n=>{let r=Vu({...n,processors:t});return Hu(e,r),Uu(r,e),Wu(r,e)},qu=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vu({...i??{},target:a,io:t,processors:n});return Hu(e,o),Uu(o,e),Wu(o,e)},Ju={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yu=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ju[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xu=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zu=(e,t,n,r)=>{n.type=`boolean`},Qu=(e,t,n,r)=>{n.not={}},$u=(e,t,n,r)=>{let i=e._zod.def,a=To(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ed=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},td=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},nd=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},rd=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Hu(a.element,t,{...r,path:[...r.path,`items`]})},id=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Hu(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Hu(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ad=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Hu(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},od=(e,t,n,r)=>{let i=e._zod.def,a=Hu(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Hu(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},sd=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Hu(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Hu(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Hu(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},cd=(e,t,n,r)=>{let i=e._zod.def,a=Hu(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ld=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ud=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},dd=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fd=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},pd=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Hu(o,t,r);let s=t.seen.get(e);s.ref=o},md=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hd=(e,t,n,r)=>{let i=e._zod.def;Hu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gd=q(`ZodISODateTime`,(e,t)=>{Ic.init(e,t),Ud.init(e,t)});function _d(e){return cu(gd,e)}var vd=q(`ZodISODate`,(e,t)=>{Lc.init(e,t),Ud.init(e,t)});function yd(e){return lu(vd,e)}var bd=q(`ZodISOTime`,(e,t)=>{Rc.init(e,t),Ud.init(e,t)});function xd(e){return uu(bd,e)}var Sd=q(`ZodISODuration`,(e,t)=>{zc.init(e,t),Ud.init(e,t)});function Cd(e){return du(Sd,e)}var wd=q(`ZodError`,(e,t)=>{cs.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ds(e,t)},flatten:{value:t=>us(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Eo,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Eo,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Td=fs(wd),Ed=ps(wd),Dd=ms(wd),Od=gs(wd),kd=vs(wd),Ad=ys(wd),jd=bs(wd),Md=xs(wd),Nd=Ss(wd),Pd=Cs(wd),Fd=ws(wd),Id=Ts(wd),Ld=new WeakMap;function Rd(e,t,n){let r=Object.getPrototypeOf(e),i=Ld.get(r);if(i||(i=new Set,Ld.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zd=q(`ZodType`,(e,t)=>(Sc.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qu(e,`input`),output:qu(e,`output`)}}),e.toJSONSchema=Ku(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Td(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Dd(e,t,n),e.parseAsync=async(t,n)=>Ed(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Od(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>kd(e,t,n),e.decode=(t,n)=>Ad(e,t,n),e.encodeAsync=async(t,n)=>jd(e,t,n),e.decodeAsync=async(t,n)=>Md(e,t,n),e.safeEncode=(t,n)=>Nd(e,t,n),e.safeDecode=(t,n)=>Pd(e,t,n),e.safeEncodeAsync=async(t,n)=>Fd(e,t,n),e.safeDecodeAsync=async(t,n)=>Id(e,t,n),Rd(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Po(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Wo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rp(e,t))},superRefine(e,t){return this.check(ip(e,t))},overwrite(e){return this.check(ju(e))},optional(){return zf(this)},exactOptional(){return Vf(this)},nullable(){return Uf(this)},nullish(){return zf(Uf(this))},nonoptional(e){return Yf(this,e)},array(){return xf(this)},or(e){return Tf([this,e])},and(e){return kf(this,e)},transform(e){return $f(this,Lf(e))},default(e){return Gf(this,e)},prefault(e){return qf(this,e)},catch(e){return Zf(this,e)},pipe(e){return $f(this,e)},readonly(){return tp(this)},describe(e){let t=this.clone();return Rl.add(t,{description:e}),t},meta(...e){if(e.length===0)return Rl.get(this);let t=this.clone();return Rl.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return Rl.get(e)?.description},configurable:!0}),e)),Bd=q(`_ZodString`,(e,t)=>{Cc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yu(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rd(e,`_ZodString`,{regex(...e){return this.check(Tu(...e))},includes(...e){return this.check(Ou(...e))},startsWith(...e){return this.check(ku(...e))},endsWith(...e){return this.check(Au(...e))},min(...e){return this.check(Cu(...e))},max(...e){return this.check(Su(...e))},length(...e){return this.check(wu(...e))},nonempty(...e){return this.check(Cu(1,...e))},lowercase(e){return this.check(Eu(e))},uppercase(e){return this.check(Du(e))},trim(){return this.check(Nu())},normalize(...e){return this.check(Mu(...e))},toLowerCase(){return this.check(Pu())},toUpperCase(){return this.check(Fu())},slugify(){return this.check(Iu())}})}),Vd=q(`ZodString`,(e,t)=>{Cc.init(e,t),Bd.init(e,t),e.email=t=>e.check(Bl(Wd,t)),e.url=t=>e.check(Kl(qd,t)),e.jwt=t=>e.check(su(lf,t)),e.emoji=t=>e.check(ql(Jd,t)),e.guid=t=>e.check(Vl(Gd,t)),e.uuid=t=>e.check(Hl(Kd,t)),e.uuidv4=t=>e.check(Ul(Kd,t)),e.uuidv6=t=>e.check(Wl(Kd,t)),e.uuidv7=t=>e.check(Gl(Kd,t)),e.nanoid=t=>e.check(Jl(Yd,t)),e.guid=t=>e.check(Vl(Gd,t)),e.cuid=t=>e.check(Yl(Xd,t)),e.cuid2=t=>e.check(Xl(Zd,t)),e.ulid=t=>e.check(Zl(Qd,t)),e.base64=t=>e.check(iu(of,t)),e.base64url=t=>e.check(au(sf,t)),e.xid=t=>e.check(Ql($d,t)),e.ksuid=t=>e.check($l(ef,t)),e.ipv4=t=>e.check(eu(tf,t)),e.ipv6=t=>e.check(tu(nf,t)),e.cidrv4=t=>e.check(nu(rf,t)),e.cidrv6=t=>e.check(ru(af,t)),e.e164=t=>e.check(ou(cf,t)),e.datetime=t=>e.check(_d(t)),e.date=t=>e.check(yd(t)),e.time=t=>e.check(xd(t)),e.duration=t=>e.check(Cd(t))});function Hd(e){return zl(Vd,e)}var Ud=q(`ZodStringFormat`,(e,t)=>{wc.init(e,t),Bd.init(e,t)}),Wd=q(`ZodEmail`,(e,t)=>{Dc.init(e,t),Ud.init(e,t)}),Gd=q(`ZodGUID`,(e,t)=>{Tc.init(e,t),Ud.init(e,t)}),Kd=q(`ZodUUID`,(e,t)=>{Ec.init(e,t),Ud.init(e,t)}),qd=q(`ZodURL`,(e,t)=>{Oc.init(e,t),Ud.init(e,t)}),Jd=q(`ZodEmoji`,(e,t)=>{kc.init(e,t),Ud.init(e,t)}),Yd=q(`ZodNanoID`,(e,t)=>{Ac.init(e,t),Ud.init(e,t)}),Xd=q(`ZodCUID`,(e,t)=>{jc.init(e,t),Ud.init(e,t)}),Zd=q(`ZodCUID2`,(e,t)=>{Mc.init(e,t),Ud.init(e,t)}),Qd=q(`ZodULID`,(e,t)=>{Nc.init(e,t),Ud.init(e,t)}),$d=q(`ZodXID`,(e,t)=>{Pc.init(e,t),Ud.init(e,t)}),ef=q(`ZodKSUID`,(e,t)=>{Fc.init(e,t),Ud.init(e,t)}),tf=q(`ZodIPv4`,(e,t)=>{Bc.init(e,t),Ud.init(e,t)}),nf=q(`ZodIPv6`,(e,t)=>{Vc.init(e,t),Ud.init(e,t)}),rf=q(`ZodCIDRv4`,(e,t)=>{Hc.init(e,t),Ud.init(e,t)}),af=q(`ZodCIDRv6`,(e,t)=>{Uc.init(e,t),Ud.init(e,t)}),of=q(`ZodBase64`,(e,t)=>{Gc.init(e,t),Ud.init(e,t)}),sf=q(`ZodBase64URL`,(e,t)=>{qc.init(e,t),Ud.init(e,t)}),cf=q(`ZodE164`,(e,t)=>{Jc.init(e,t),Ud.init(e,t)}),lf=q(`ZodJWT`,(e,t)=>{Xc.init(e,t),Ud.init(e,t)}),uf=q(`ZodNumber`,(e,t)=>{Zc.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xu(e,t,n,r),Rd(e,`ZodNumber`,{gt(e,t){return this.check(yu(e,t))},gte(e,t){return this.check(bu(e,t))},min(e,t){return this.check(bu(e,t))},lt(e,t){return this.check(_u(e,t))},lte(e,t){return this.check(vu(e,t))},max(e,t){return this.check(vu(e,t))},int(e){return this.check(pf(e))},safe(e){return this.check(pf(e))},positive(e){return this.check(yu(0,e))},nonnegative(e){return this.check(bu(0,e))},negative(e){return this.check(_u(0,e))},nonpositive(e){return this.check(vu(0,e))},multipleOf(e,t){return this.check(xu(e,t))},step(e,t){return this.check(xu(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function df(e){return fu(uf,e)}var ff=q(`ZodNumberFormat`,(e,t)=>{Qc.init(e,t),uf.init(e,t)});function pf(e){return pu(ff,e)}var mf=q(`ZodBoolean`,(e,t)=>{$c.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zu(e,t,n,r)});function hf(e){return mu(mf,e)}var gf=q(`ZodUnknown`,(e,t)=>{el.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _f(){return hu(gf)}var vf=q(`ZodNever`,(e,t)=>{tl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qu(e,t,n,r)});function yf(e){return gu(vf,e)}var bf=q(`ZodArray`,(e,t)=>{rl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rd(e,t,n,r),e.element=t.element,Rd(e,`ZodArray`,{min(e,t){return this.check(Cu(e,t))},nonempty(e){return this.check(Cu(1,e))},max(e,t){return this.check(Su(e,t))},length(e,t){return this.check(wu(e,t))},unwrap(){return this.element}})});function xf(e,t){return Lu(bf,e,t)}var Sf=q(`ZodObject`,(e,t)=>{cl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>id(e,t,n,r),Mo(e,`shape`,()=>t.shape),Rd(e,`ZodObject`,{keyof(){return Nf(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:_f()})},loose(){return this.clone({...this._zod.def,catchall:_f()})},strict(){return this.clone({...this._zod.def,catchall:yf()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Yo(this,e)},safeExtend(e){return Xo(this,e)},merge(e){return Zo(this,e)},pick(e){return qo(this,e)},omit(e){return Jo(this,e)},partial(...e){return Qo(Rf,this,e[0])},required(...e){return $o(Jf,this,e[0])}})});function Cf(e,t){return new Sf({type:`object`,shape:e??{},...J(t)})}var wf=q(`ZodUnion`,(e,t)=>{ul.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ad(e,t,n,r),e.options=t.options});function Tf(e,t){return new wf({type:`union`,options:e,...J(t)})}var Ef=q(`ZodDiscriminatedUnion`,(e,t)=>{wf.init(e,t),dl.init(e,t)});function Df(e,t,n){return new Ef({type:`union`,options:t,discriminator:e,...J(n)})}var Of=q(`ZodIntersection`,(e,t)=>{fl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>od(e,t,n,r)});function kf(e,t){return new Of({type:`intersection`,left:e,right:t})}var Af=q(`ZodRecord`,(e,t)=>{hl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sd(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function jf(e,t,n){return!t||!t._zod?new Af({type:`record`,keyType:Hd(),valueType:e,...J(t)}):new Af({type:`record`,keyType:e,valueType:t,...J(n)})}var Mf=q(`ZodEnum`,(e,t)=>{gl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$u(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Mf({...t,checks:[],...J(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Mf({...t,checks:[],...J(r),entries:i})}});function Nf(e,t){return new Mf({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...J(t)})}var Pf=q(`ZodLiteral`,(e,t)=>{_l.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ed(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ff(e,t){return new Pf({type:`literal`,values:Array.isArray(e)?e:[e],...J(t)})}var If=q(`ZodTransform`,(e,t)=>{vl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nd(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new So(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(os(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(os(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Lf(e){return new If({type:`transform`,transform:e})}var Rf=q(`ZodOptional`,(e,t)=>{bl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zf(e){return new Rf({type:`optional`,innerType:e})}var Bf=q(`ZodExactOptional`,(e,t)=>{xl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vf(e){return new Bf({type:`optional`,innerType:e})}var Hf=q(`ZodNullable`,(e,t)=>{Sl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uf(e){return new Hf({type:`nullable`,innerType:e})}var Wf=q(`ZodDefault`,(e,t)=>{Cl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ud(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gf(e,t){return new Wf({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vo(t)}})}var Kf=q(`ZodPrefault`,(e,t)=>{Tl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qf(e,t){return new Kf({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vo(t)}})}var Jf=q(`ZodNonOptional`,(e,t)=>{El.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ld(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yf(e,t){return new Jf({type:`nonoptional`,innerType:e,...J(t)})}var Xf=q(`ZodCatch`,(e,t)=>{Ol.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fd(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zf(e,t){return new Xf({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Qf=q(`ZodPipe`,(e,t)=>{kl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pd(e,t,n,r),e.in=t.in,e.out=t.out});function $f(e,t){return new Qf({type:`pipe`,in:e,out:t})}var ep=q(`ZodReadonly`,(e,t)=>{jl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>md(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tp(e){return new ep({type:`readonly`,innerType:e})}var np=q(`ZodCustom`,(e,t)=>{Nl.init(e,t),zd.init(e,t),e._zod.processJSONSchema=(t,n,r)=>td(e,t,n,r)});function rp(e,t={}){return Ru(np,e,t)}function ip(e,t){return zu(e,t)}var ap={Output:1,Replay:2,Input:3,Snapshot:4},op=e=>{let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<16)throw Error(`Terminal binary frame is too short`);let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r={version:n.getUint8(0),type:n.getUint8(1),flags:n.getUint16(2),meta:n.getUint32(4),streamId:n.getUint32(8),payloadSize:n.getUint32(12)},i=t.subarray(16);if(i.byteLength!==r.payloadSize)throw Error(`Terminal binary frame payload length mismatch`);return{header:r,payload:i}},sp=e=>{let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<16)throw Error(`Terminal output frame is too short`);let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint8(0);if(r!==2)throw Error(`Expected output frame version 2, got ${r}`);let i=n.getUint16(2,!1),a=n.getUint32(4,!1),o=n.getUint32(8,!1),s=n.getUint32(12,!1);if(t.byteLength<16+i)throw Error(`Terminal output frame topic is truncated`);let c=new TextDecoder().decode(t.subarray(16,16+i)),l=t.subarray(16+i);if(l.byteLength!==s)throw Error(`Terminal output frame payload length mismatch`);return{topic:c,seq:a,streamId:o,payload:l}},cp=Cf({kind:Ff(`command`),id:Hd().uuid(),op:Hd(),args:_f()}),lp=Cf({kind:Ff(`result`),id:Hd().uuid(),ok:hf(),data:_f().optional(),error:Cf({code:Hd(),message:Hd(),details:_f().optional()}).optional()}),up=Cf({kind:Ff(`event`),topic:Hd(),seq:df().int().nonnegative(),timestamp:df().int().positive(),data:_f()});Df(`kind`,[cp,Cf({kind:Ff(`subscribe`),topics:xf(Hd())}),Cf({kind:Ff(`unsubscribe`),topics:xf(Hd())}),Cf({kind:Ff(`resync`),lastSeen:jf(Hd(),df())})]),Df(`kind`,[lp,up]);var dp={connectionStatus:`connection.status`,connectionReady:`connection.ready`,workspaceMeta:e=>`workspace.${e}.meta`,workspaceFsDirty:e=>`workspace.${e}.fs.dirty`,workspaceGitState:e=>`workspace.${e}.git.state`,workspaceLspDiagnostics:e=>`workspace.${e}.lsp.diagnostics`,workspaceAll:e=>`workspace.${e}.*`,sessionState:(e,t)=>`workspace.${e}.session.${t}.state`,sessionLifecycle:(e,t)=>`workspace.${e}.session.${t}.lifecycle`,sessionProgress:(e,t)=>`workspace.${e}.session.${t}.progress`,sessionsAll:e=>`workspace.${e}.session.*`,terminalCreated:(e,t)=>`workspace.${e}.terminal.${t}.created`,terminalOutput:(e,t)=>`workspace.${e}.terminal.${t}.output`,terminalContinuityLost:(e,t)=>`workspace.${e}.terminal.${t}.continuity_lost`,terminalExit:(e,t)=>`workspace.${e}.terminal.${t}.exit`,terminalsAll:e=>`workspace.${e}.terminal.*`,notificationToast:`notification.toast`,updateStateChanged:`update.state.changed`,supervisorState:(e,t)=>`workspace.${e}.session.${t}.supervisor.state`};function fp(e,t){if(e===t||e===`*`)return!0;let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<n.length;e++){let t=n[e];if(t===`*`){if(e===n.length-1)return!0;continue}if(e>=r.length||t!==r[e])return!1}return n.length<=r.length}var pp=class extends Error{constructor(e){super(e.message),this.name=`CommandResultError`,this.code=e.code,this.details=e.details}},mp={maxAttempts:1/0,baseDelayMs:1e3,maxDelayMs:3e4},hp=3e4,gp=2500,_p=()=>{if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join(`-`)},vp=class{constructor(e,t={}){this.ws=null,this.connectDeferred=null,this.pendingCommands=new Map,this.eventListeners=new Map,this.statusListeners=new Set,this.lastSeenSeq=new Map,this.pendingBinaryStreamIds=new Map,this.orphanBinaryPayloads=new Map,this.nextTerminalInputStreamId=1,this.pendingProbe=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.isManualClose=!1,this.status=`disconnected`,this.url=e,this.reconnectConfig={...mp,...t}}async connect(){if(this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`)return Promise.resolve();if(this.connectDeferred)return this.connectDeferred.promise;this.isManualClose=!1,this.setStatus(`connecting`);let e,t,n=new Promise((n,r)=>{e=n,t=r});this.connectDeferred={promise:n,resolve:e,reject:t};try{let e=new WebSocket(this.url);this.ws=e,e.binaryType=`arraybuffer`,e.onopen=()=>{if(this.ws!==e)return;this.setStatus(`connected`),this.reconnectAttempts=0;let t=Array.from(this.eventListeners.keys());if(t.length>0){let n={kind:`subscribe`,topics:t};e.send(JSON.stringify(n))}this.lastSeenSeq.size>0&&this.resync(),this.resolveConnectDeferred()},e.onmessage=t=>{if(this.ws===e)try{if(typeof t.data==`string`){let e=JSON.parse(t.data);this.handleMessage(e);return}if(t.data instanceof ArrayBuffer){this.handleBinaryMessage(new Uint8Array(t.data));return}console.error(`Unsupported WebSocket message type:`,typeof t.data)}catch(e){console.error(`Failed to parse WebSocket message:`,e)}},e.onclose=t=>{this.ws===e&&((t.reason===`single_active_displaced`||t.reason===`activation_required`||t.reason===`activation_revoked`)&&(this.isManualClose=!0),this.handleClose(t.code,t.reason),this.rejectConnectDeferred(Error(`WebSocket closed: ${t.reason||t.code}`)))},e.onerror=t=>{this.ws===e&&console.error(`WebSocket error:`,t)}}catch(e){this.rejectConnectDeferred(e instanceof Error?e:Error(String(e)))}return n}disconnect(e){this.isManualClose=!0,this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.rejectConnectDeferred(Error(`WebSocket disconnected`)),this.rejectPendingCommands(Error(`WebSocket disconnected`)),this.clearBinaryCommandState(),this.clearPendingProbe(),this.ws&&=(this.ws.close(1e3,e||`client_disconnect`),null),this.setStatus(`disconnected`)}recoverConnection(e=`manual_retry`){let t=this.getStatus();if(t!==`rejected`){if(t===`connected`){this.probeConnection(e).catch(()=>{});return}t!==`connecting`&&(this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.reconnectAttempts=0,console.log(`[WsClient] Recovering connection after ${e}`),this.connect().catch(e=>{console.error(`Recovery connect failed:`,e)}))}}async probeConnection(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw this.forceReconnect(`probe_${e}_socket_unavailable`),Error(`WebSocket not connected`);return this.pendingProbe?new Promise((e,t)=>{let n=this.pendingProbe;if(!n){t(Error(`Connection probe unavailable`));return}this.pendingProbe={...n,resolve:e,reject:t}}):new Promise((t,n)=>{let r=_p(),i=setTimeout(()=>{this.pendingProbe?.id===r&&(this.forceReconnect(`probe_timeout`),n(Error(`Connection probe timeout`)))},gp);this.pendingProbe={id:r,resolve:t,reject:n,timeoutId:i,trigger:e},this.pendingCommands.set(r,{resolve:()=>{this.pendingProbe?.id===r&&(this.clearPendingProbe(),t({ok:!0}))},reject:e=>{this.pendingProbe?.id===r&&(this.clearPendingProbe(),this.forceReconnect(`probe_rejected`),n(e))},timeoutId:i});let a={kind:`command`,id:r,op:`connection.probe`,args:{}};this.ws.send(JSON.stringify(a))})}async sendCommand(e,t,n={}){return new Promise((r,i)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){i(Error(`WebSocket not connected`));return}let a=_p(),o=n.timeoutMs??hp,s=setTimeout(()=>{this.cleanupTimedOutBinaryCommand(a),this.pendingCommands.delete(a),i(Error(`Command timeout: ${e}`))},o);this.pendingCommands.set(a,{resolve:r,reject:i,timeoutId:s});let c={kind:`command`,id:a,op:e,args:t};this.ws.send(JSON.stringify(c))})}async sendTerminalInput(e,t,n,r){return new Promise((i,a)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){a(Error(`WebSocket not connected`));return}let o=_p(),s=this.allocateTerminalInputStreamId(),c=setTimeout(()=>{this.cleanupTimedOutBinaryCommand(o),this.pendingCommands.delete(o),a(Error(`Command timeout: terminal.input`))},hp);this.pendingCommands.set(o,{resolve:i,reject:a,timeoutId:c});let l={kind:`command`,id:o,op:`terminal.input`,args:{terminalId:e,transport:`binary`,streamId:s,size:t.byteLength,activity:n,submittedText:r}};this.ws.send(JSON.stringify(l)),this.ws.send(t)})}subscribe(e,t){let n=[];for(let r of e)this.eventListeners.has(r)||(this.eventListeners.set(r,new Set),n.push(r)),this.eventListeners.get(r).add(t);if(n.length>0&&this.ws&&this.ws.readyState===WebSocket.OPEN){let e={kind:`subscribe`,topics:n};this.ws.send(JSON.stringify(e))}return()=>{let n=[];for(let r of e){let e=this.eventListeners.get(r);e&&(e.delete(t),e.size===0&&(this.eventListeners.delete(r),n.push(r)))}if(n.length>0&&this.ws&&this.ws.readyState===WebSocket.OPEN){let e={kind:`unsubscribe`,topics:n};this.ws.send(JSON.stringify(e))}}}onStatus(e){return this.statusListeners.add(e),()=>this.statusListeners.delete(e)}getStatus(){return this.status}handleMessage(e){if(e.kind===`result`){let t=this.pendingCommands.get(e.id);if(t){if(e.ok&&this.isTerminalBinaryCommandResult(e.data)){let n=this.getExpectedFrameType(e.data),r=this.orphanBinaryPayloads.get(e.data.streamId);if(r){if(this.orphanBinaryPayloads.delete(e.data.streamId),clearTimeout(r.timeoutId),r.frameType===n){clearTimeout(t.timeoutId),this.pendingCommands.delete(e.id),t.resolve({...e.data,bytes:r.bytes});return}console.warn(`Discarding terminal binary frame with unexpected type`,{streamId:e.data.streamId,expectedFrameType:n,actualFrameType:r.frameType})}t.terminalBinary=e.data,t.binaryStreamId=e.data.streamId,this.pendingBinaryStreamIds.set(e.data.streamId,{commandId:e.id,expectedFrameType:n});return}clearTimeout(t.timeoutId),this.pendingCommands.delete(e.id),e.ok?t.resolve(e.data):t.reject(new pp({code:e.error?.code??`command_failed`,message:e.error?.message??`Command failed`,details:e.error?.details}))}}else e.kind===`event`&&(this.lastSeenSeq.set(e.topic,e.seq),this.notifyEventListeners(e.topic,e.data,e.seq))}handleBinaryMessage(e){if(e.length===0)return;if(e[0]===2){let t=sp(e);this.notifyEventListeners(t.topic,{transport:`binary`,streamId:t.streamId,size:t.payload.byteLength,bytes:t.payload},t.seq);return}let{header:t,payload:n}=op(e),r=this.pendingBinaryStreamIds.get(t.streamId);if(!r){let e=this.orphanBinaryPayloads.get(t.streamId);e&&clearTimeout(e.timeoutId),this.orphanBinaryPayloads.set(t.streamId,{frameType:t.type,bytes:n,timeoutId:setTimeout(()=>{this.orphanBinaryPayloads.delete(t.streamId)},hp)});return}if(t.type!==r.expectedFrameType){console.warn(`Discarding terminal binary frame with unexpected type`,{streamId:t.streamId,expectedFrameType:r.expectedFrameType,actualFrameType:t.type});return}this.pendingBinaryStreamIds.delete(t.streamId);let i=this.pendingCommands.get(r.commandId);i?.terminalBinary&&(clearTimeout(i.timeoutId),this.pendingCommands.delete(r.commandId),i.resolve({...i.terminalBinary,bytes:n}))}notifyEventListeners(e,t,n){for(let[r,i]of this.eventListeners.entries())if(fp(r,e))for(let r of i)try{r(e,t,n)}catch(t){console.error(`Error in event listener for ${e}:`,t)}}isTerminalBinaryCommandResult(e){return typeof e==`object`&&!!e&&`status`in e&&`transport`in e&&`streamId`in e&&`size`in e&&e.status===`ok`&&e.transport===`binary`}getExpectedFrameType(e){return`source`in e?ap.Snapshot:ap.Replay}cleanupTimedOutBinaryCommand(e){let t=this.pendingCommands.get(e)?.binaryStreamId;if(t==null)return;this.pendingBinaryStreamIds.delete(t);let n=this.orphanBinaryPayloads.get(t);n&&(clearTimeout(n.timeoutId),this.orphanBinaryPayloads.delete(t))}clearBinaryCommandState(){this.pendingBinaryStreamIds.clear();for(let e of this.orphanBinaryPayloads.values())clearTimeout(e.timeoutId);this.orphanBinaryPayloads.clear()}resolveConnectDeferred(){let e=this.connectDeferred;e&&(this.connectDeferred=null,e.resolve())}rejectConnectDeferred(e){let t=this.connectDeferred;t&&(this.connectDeferred=null,t.reject(e))}rejectPendingCommands(e){for(let[t,n]of this.pendingCommands)clearTimeout(n.timeoutId),n.reject(e),this.pendingCommands.delete(t)}allocateTerminalInputStreamId(){let e=this.nextTerminalInputStreamId;return this.nextTerminalInputStreamId+=1,e}handleClose(e,t){if(this.ws=null,this.rejectPendingCommands(Error(`WebSocket disconnected`)),this.clearBinaryCommandState(),this.clearPendingProbe(),e===4001||e===4002){this.setStatus(`rejected`);return}this.isManualClose||this.scheduleReconnect()}scheduleReconnect(){if(this.reconnectAttempts>=this.reconnectConfig.maxAttempts){console.error(`Max reconnect attempts reached`),this.setStatus(`disconnected`);return}this.setStatus(`reconnecting`);let e=Math.min(this.reconnectConfig.baseDelayMs*2**this.reconnectAttempts,this.reconnectConfig.maxDelayMs);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect().catch(e=>{console.error(`Reconnect failed:`,e)})},e)}resync(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN||this.lastSeenSeq.size===0)return;let e={kind:`resync`,lastSeen:Object.fromEntries(this.lastSeenSeq)};this.ws.send(JSON.stringify(e))}setStatus(e){this.status=e;for(let t of this.statusListeners)try{t(e)}catch(e){console.error(`Error in status listener:`,e)}}forceReconnect(e){if(this.clearPendingProbe(),this.ws){let t=this.ws;this.ws=null;try{t.close(4e3,e)}catch{}}this.handleClose(1006,e)}clearPendingProbe(){this.pendingProbe&&=(clearTimeout(this.pendingProbe.timeoutId),this.pendingCommands.delete(this.pendingProbe.id),null)}};function yp(){return typeof window>`u`?`ws://127.0.0.1:4173/ws`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/ws`}var bp=V(null),xp=V(`connecting`),Sp=V(null),Cp=V(!1),wp=V(null),Tp=V(0),Ep=V(null),Dp=V(null),Op=V(e=>{let t=e(bp);return async(e,n,r)=>{if(!t)return{ok:!1,error:{code:`no_client`,message:`WebSocket client not initialized`}};try{return{ok:!0,data:await t.sendCommand(e,n,r)}}catch(e){return e instanceof pp?{ok:!1,error:{code:e.code,message:e.message,details:e.details}}:{ok:!1,error:{code:`command_error`,message:e instanceof Error?e.message:`Unknown error`}}}}});V(`tab_${Date.now()}_${Math.random().toString(36).substring(2,9)}`);var kp=V(new Map);V(e=>t=>e(kp).get(t)?.isController??!1),V(e=>t=>e(kp).get(t)?.reason),V(e=>{let t=e(kp);for(let e of t.values())if(!e.isController)return!0;return!1});function Ap(e,t){let n=null,r=new Map,i=new Set;function a(i){let s;if(t===void 0)s=r.get(i);else for(let[e,n]of r)if(t(e,i)){s=n;break}if(s!==void 0)if(n?.(s[1],i))a.remove(i);else return s[0];let c=e(i);return r.set(i,[c,Date.now()]),o(`CREATE`,i,c),c}function o(e,t,n){for(let r of i)r({type:e,param:t,atom:n})}return a.unstable_listen=e=>(i.add(e),()=>{i.delete(e)}),a.getParams=()=>r.keys(),a.remove=e=>{if(t===void 0){if(!r.has(e))return;let[t]=r.get(e);r.delete(e),o(`REMOVE`,e,t)}else for(let[n,[i]]of r)if(t(n,e)){r.delete(n),o(`REMOVE`,n,i);break}},a.setShouldRemove=e=>{if(n=e,n)for(let[e,[t,i]]of r)n(i,e)&&(r.delete(e),o(`REMOVE`,e,t))},a}var jp=V(null),Mp=V({}),Np=V([]),Pp=V(`idle`),Fp=V(null),Ip=Ap(e=>V(t=>t(Mp)[e])),Lp=V(e=>{let t=e(Np),n=e(Mp),r=new Set(Object.keys(n)),i=t.filter(e=>r.has(e)),a=new Set(i),o=Object.keys(n).filter(e=>!a.has(e));return[...i,...o]}),Rp=V(e=>e(Lp).map(t=>e(Ip(t))).filter(e=>!!e)),zp=V(e=>{if(e(Pp)!==`ready`)return null;let t=e(jp),n=e(Mp);return t&&n[t]?t:e(Lp)[0]??null}),Bp=V(e=>{let t=e(zp);return t?e(Ip(t)):null}),Vp=V({}),Hp=Ap(e=>V(t=>{let n=t(Vp);return Object.values(n).filter(t=>t.workspaceId===e)})),Up=Ap(e=>V(t=>t(Vp)[e]));V(e=>{let t=e(zp);return t?e(Hp(t)).find(e=>e.state===`running`||e.state===`idle`)??null:null}),Ap(e=>V(t=>{let n=t(Hp(e)),r={draft:0,starting:0,running:0,idle:0,ended:0};for(let e of n)r[e.state]++;return r}));function Wp(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Wp(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Y(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Wp(e))&&(r&&(r+=` `),r+=t);return r}function Gp(e){return e.target===e.currentTarget}function Kp(e){return e.key===`Escape`}var qp=[`a[href]`,`area[href]`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`iframe:not([tabindex="-1"])`,`object:not([tabindex="-1"])`,`embed:not([tabindex="-1"])`,`[contenteditable="true"]`,`[tabindex]:not([tabindex="-1"])`].join(`, `);function Jp(e){return e instanceof HTMLElement}function Yp(e){return Array.from(e.querySelectorAll(qp)).filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`)}function Xp(e,t){let n=typeof t==`function`?t():t;return n&&e.contains(n)&&!n.hasAttribute(`disabled`)?n:Yp(e)[0]??e}function Zp(e,t){if(t.key!==`Tab`)return;let n=Yp(e);if(n.length===0){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],a=Jp(document.activeElement)?document.activeElement:null;if(t.shiftKey){(!a||a===r||!e.contains(a))&&(t.preventDefault(),i.focus());return}(!a||a===i||!e.contains(a))&&(t.preventDefault(),r.focus())}function Qp(e){e instanceof HTMLElement&&e.isConnected&&e.focus()}function $p({children:e}){let t=typeof document>`u`?null:document.body;return t?(0,Fr.createPortal)(e,t):null}var em=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),tm=t(((e,t)=>{t.exports=em()})),X=tm();function nm({title:e,onBack:t,backLabel:n=`Back`,backAriaLabel:r,kicker:i,rightSlot:a,titleAs:o=`h2`,level:s=`secondary`,className:c}){let l=o;return(0,X.jsxs)(`div`,{className:Y(`page-header`,`page-header--${s}`,c),"data-level":s,children:[(0,X.jsxs)(`div`,{className:`page-header__leading`,children:[t?(0,X.jsxs)(`button`,{type:`button`,className:`page-header__back`,onClick:t,"aria-label":r??n,children:[(0,X.jsx)(di,{size:16}),(0,X.jsx)(`span`,{children:n})]}):null,(0,X.jsxs)(`div`,{className:`page-header__copy`,children:[i?(0,X.jsx)(`div`,{className:`page-header__kicker`,children:i}):null,(0,X.jsx)(l,{className:`page-header__title`,children:e})]})]}),a?(0,X.jsx)(`div`,{className:`page-header__actions`,children:a}):null]})}function rm({className:e,kicker:t,showKicker:n=!1,...r}){return(0,X.jsx)(nm,{...r,kicker:n?t:void 0,className:Y(`mobile-page-header`,e)})}var im={datetime:{today:`Today`,tomorrow:`Tomorrow`,next_week:`Next Week`,prev_month:`Previous Month`,next_month:`Next Month`,clear:`Clear`,confirm:`Confirm`,select_date:`Select Date`,select_time:`Select Time`,hour:`Hour`,minute:`Minute`,january:`January`,february:`February`,march:`March`,april:`April`,may:`May`,june:`June`,july:`July`,august:`August`,september:`September`,october:`October`,november:`November`,december:`December`,sun:`Sun`,mon:`Mon`,tue:`Tue`,wed:`Wed`,thu:`Thu`,fri:`Fri`,sat:`Sat`},app:{name:`Coder Studio`,description:`Agent-First Development Environment`},common:{loading:`Loading...`,error:`Error`,success:`Success`,warning:`Warning`,info:`Info`,enabled:`Enabled`,disabled:`Disabled`,confirm:`Confirm`,cancel:`Cancel`,save:`Save`,delete:`Delete`,edit:`Edit`,view:`View`,close:`Close`,yes:`Yes`,no:`No`,ok:`OK`,all:`All`},action:{open:`Open`,open_workspace:`Open Workspace`,close_workspace:`Close Workspace`,create_session:`Create Session`,stop_session:`Stop Session`,resume_session:`Resume Session`,save_file:`Save File`,save_all:`Save All`,save:`Save`,discard_changes:`Discard Changes`,commit:`Commit`,push:`Push`,pull:`Pull`,refresh:`Refresh`,settings:`Settings`,cancel:`Cancel`,confirm:`Confirm`,close:`Close`,apply:`Apply`,reset:`Reset`,search:`Search`,search_files:`Search Files`,search_commands:`Search Commands`,back:`Back`,expand:`Expand`,collapse:`Collapse`,close_all:`Close all`},label:{workspace:`Workspace`,agent:`Agent`,session:`Session`,terminal:`Terminal`,file:`File`,git:`Git`,settings:`Settings`,provider:`Provider`,status:`Status`,progress:`Progress`},provider:{install:{cta:{start:`Start Session`,install_and_start:`Install & Start`,installing:`Installing...`,manual:`View Install Steps`},status:{installing:`Installing provider CLI...`,failed:`Automatic install failed`},open_docs:`Open official docs`,nodejs:{manual:`Install Node.js from the official download page.`},claude:{manual:`Then run npm install -g @anthropic-ai/claude-code.`},codex:{manual:`Then run npm install -g @openai/codex.`}}},status:{starting:`Starting`,running:`Running`,idle:`Idle`,busy:`Busy`,ended:`Ended`,unavailable:`Unavailable`,connecting:`Connecting`,connected:`Connected`,disconnected:`Disconnected`,reconnecting:`Reconnecting`,rejected:`Rejected`},workspace:{title:`Workspace`,tabs:`Workspace tabs`,open:`Open`,close:`Close`,path:`Path`,no_workspace:`No workspace open`,refresh_partial_title:`Workspace refresh incomplete`,refresh_partial_body:`Updated what we could, but these sections failed: {sections}`,fullscreen:{unsupported_title:`Fullscreen unavailable`,unsupported_body:`Fullscreen is not available in this browser.`,enter_failed_title:`Could not enter fullscreen`,enter_failed_body:`The browser denied the fullscreen request.`,exit_failed_title:`Could not exit fullscreen`,exit_failed_body:`The browser could not exit fullscreen right now.`},open_hint:`Click the button below to open a project directory`,loading_title:`Loading workspaces`,loading_description:`Preparing your workspace list and restoring the last active session.`,load_failed_title:`Failed to load workspaces`,load_failed_description:`Failed to fetch workspace list`,sidebar:{label:`Workspace activity bar`,explorer:`Explorer`,search:`Search`,source_control:`Source Control`,open_editors:`Open Editors`,workspace:`Workspace`},quick_jump:{title:`Quick Jump`,placeholder:`Type a filename or path`,no_results:`No matching files found.`,failed:`File search failed. Try again.`},open_editors:{title_with_count:`{title} ({count})`,close_path:`Close {path}`,expand_label:`Expand Open Editors`,collapse_label:`Collapse Open Editors`},search:{empty:`Type to search across file contents.`,placeholder:`Search across file contents`,results_count:`{count} results in {files} files`,no_results:`No content matches found.`,truncated:`Results limited to keep search responsive.`,file_match_count:`{count}{suffix} matches`,failed:`Search failed. Try again.`,retry:`Retry`},launch:{kicker:`START WORKSPACE`,title:`Open Workspace`,home_directory:`Home Directory`,go_up:`Go Up`,no_directories:`No directories found`,items_count:`{count} items`,enter_folder:`Enter {name}`,enter_folder_action:`Enter folder →`,cancel:`Cancel`,start:`Start Workspace`,starting:`Starting...`,hint:`Select a directory to use as the workspace root.`,browse_failed:`Failed to browse directories`,select_required:`Please select a directory`,open_failed:`Failed to open workspace`},runtime_check:{title:`Runtime Check`,checking:`Checking runtime environment...`,success:`Runtime environment check passed`,failed:`Runtime environment check failed`,missing_git:`Git command not found`,missing_node:`Node.js not found`,missing_provider:`{provider} CLI not found`}},quick_open:{title:`Go to File`,placeholder:`Type a filename or path`,empty:`Type to search by filename or path.`,no_results:`No matching files found.`,failed:`File search failed. Try again.`,command_label:`Go to File...`,command_description:`Quickly open a file in the current workspace`},mobile:{dock:{aria_label:`Mobile dock`,open_agent:`Open Agent sheet`,open_files:`Open Files sheet`,open_terminal:`Open Terminal sheet`},agent:{title:`Agent Sessions`,close_current_session:`Close Current Session`,providers:`Session providers`,start_session:`Start {provider} session`,starting:`Starting...`,start_new_session:`Start new session`,active_agents:`Active agents`,switch_to_agent:`Switch to agent {name}`,empty:`No active sessions`},supervisor:{open_sheet:`Open Supervisor sheet`},topbar:{switch_workspace:`Switch workspace`,open_settings:`Open settings`},sheet:{dismiss:`Dismiss current sheet`,region:`{title} sheet`},files:{tabs:`Files sheet tabs`,git_diff:`Git`,editor_fallback:`Editor`},workspace_drawer:{aria_label:`Workspace drawer`,close:`Close workspace drawer`,select_title:`Select workspace`,switch_to_workspace:`Switch to workspace {name}`,close_workspace:`Close workspace {name}`},empty:{start_session:`Start a new agent session for this workspace.`,files_terminal_hint:`Files and Terminal stay available from the bottom bar.`}},session:{title:`Session`,create:`Create Session`,stop:`Stop`,resume:`Resume`,no_session:`No active session`,provider_select:`Select Agent`,state:{starting:`Starting...`,running:`Running`,idle:`Waiting for input`,busy:`Executing`,ended:`Stopped`,unavailable:`Unavailable`},resume_unavailable:`This session cannot be resumed`,progress:{thinking:`Thinking...`,executing:`Executing...`,waiting:`Waiting for response...`}},terminal:{title:`Terminal`,kicker:`TERMINAL`,new_terminal:`New Terminal`,close_terminal:`Close Terminal`,shell:`Shell Terminal`,agent:`Agent Terminal`,reconnect_hint:`Connection lost, reconnecting...`,no_terminal:`No terminals`,empty_hint:`Launch a shell to inspect files, run commands, and verify changes without leaving the workspace.`,load_failed_title:`Could not load terminals`,load_failed_body:`Refresh the workspace connection and try again.`,create_failed_title:`Could not create terminal`,create_failed_body:`The shell process could not be started. Check the server runtime and shell configuration.`,create_unavailable_title:`No workspace selected`,create_unavailable_body:`Open or switch to a workspace before creating a terminal.`,copied_current_line:`Copied current line`,mobile_copy_current_line_failed_title:`Current line copy failed`,mobile_copy_current_line_failed_body:`Try long-pressing the current line again`,paste_dialog_title:`Paste Text`,paste_dialog_placeholder:`Paste your text here...`,paste_dialog_submit:`Send`,hide:`Hide Terminal`,show:`Show Terminal`,selector:{switch:`Switch terminal`,title:`Terminal Sessions`,current:`Current terminal`,indexed:`Terminal {index}`},mobile_input:{paste:`Paste`,upload:`Upload`,shortcuts:`Terminal shortcut keys`,ctrl:`Ctrl`,ctrl_armed:`Ctrl armed`,ctrl_locked:`Ctrl locked`,shift:`Shift`,shift_armed:`Shift armed`,escape:`Escape`,tab:`Tab`,enter:`Enter`,up:`Up arrow`,down:`Down arrow`,left:`Left arrow`,right:`Right arrow`},replay:{queued_title:`Waiting in queue ({count} ahead)`,up_next:`Up next...`,loading_title:`Restoring terminal output...`,loading_body:`This terminal is unavailable while history is being restored. Please wait until recovery finishes before continuing. Larger histories may take longer to restore.`,failed_title:`Terminal history was not restored yet`,failed_body:`The terminal is still usable, but older output still could not be filled back in. Try again later or after a refresh; if the server still retains the history, it may still come back.`,reconcile_failed_title:`Terminal recovery check did not complete`,reconcile_failed_body:`Recovery inspection did not finish this time. The terminal is still usable, but it is temporarily unclear whether older history was filled back in. Try checking again shortly.`,recheck_action:`Check again`,retryable_title:`Terminal history was not restored yet`,retryable_body:`The terminal is still usable, but older output was not filled back in this time. You can retry recovery; if the server still retains the history, it may still come back later or after a refresh.`,retry_action:`Retry recovery`,unrecoverable_title:`Earlier history can no longer be restored`,unrecoverable_body:`Older terminal output has already fallen out of the replay buffer and there is no usable snapshot available now. Only later output can still be viewed.`,unknown_title:`This terminal can no longer be restored`,unknown_body:`This terminal session is no longer present on the server, so its history cannot be recovered. Open a new terminal to continue.`,unknown_body_with_provider:`This terminal session is no longer present on the server. Reopen a {provider} session to continue?`,closed_title:`This session has ended`,closed_body:`Reopen a new session to continue?`,closed_body_with_provider:`Reopen a {provider} session to continue?`}},file:{title:`Files`,modified:`Modified`,unsaved:`Unsaved`,dirty:`Has unsaved changes`,visible_count:`{count} files`,empty_directory:`Empty directory`,new_file:`New File`,new_folder:`New Folder`,collapse_all:`Collapse All`,rename:`Rename`,rename_name:`Name`,rename_helper:`Rename within the current directory only.`,rename_required:`Name is required.`,rename_invalid_name:`Name cannot contain / or \\.`,rename_failed:`Could not rename file`,delete:`Delete`,delete_confirm:`Are you sure you want to delete "{name}"?`,copy_relative_path:`Copy Relative Path`,copy_absolute_path:`Copy Absolute Path`,open_in_terminal:`Open in Terminal`,context_menu_title:`File actions`,context_section_create:`Create`,context_section_edit:`Edit`,context_section_path:`Path`,context_section_terminal:`Terminal`,path:`Path`,path_required:`Enter a path`,invalid_file_path:`File paths cannot end with /`,path_helper_file:`Enter a workspace-relative path, for example src/demo/new-file.ts`,path_helper_folder:`Enter a workspace-relative path, for example src/demo/new-folder`,create_failed:`Failed to create item`,delete_failed:`Failed to delete file`,conflict:`File has been modified externally`,conflict_message:`The file may have been modified outside the editor. Discard local changes and reload?`},code_editor:{saving:`Saving...`,edit_as_text:`Edit as text`,preview_as_image:`Preview as image`,preview_loading:`Loading preview...`,preview_unavailable:`Preview unavailable`,preview_retry:`Retry`,mode_text:`Text`,mode_image:`Image`,mode_preview:`Preview`,mode_edit:`Edit`,mode_diff:`Diff`,diff_saved_only:`Diff preview is based on saved file contents.`,open_failed_title:`Failed to open file`,empty_hint:`Select a file on the left to open it in the editor.`,modified_on_disk:`This file changed on disk after you opened it. Save carefully or reload the file.`,deleted_on_disk:`This file was deleted on disk after you opened it.`},git:{title:`Git`,changes:`Changes`,staged:`Staged`,modified:`Modified`,deleted:`Deleted`,unstaged:`Unstaged`,untracked:`Untracked`,no_changes:`No changes`,commit:`Commit`,commit_message:`Commit Message`,commit_placeholder:`Enter commit message...`,commit_summary_placeholder:`Enter commit message...`,commit_staged_count:`{count} staged`,nothing_staged:`Nothing staged`,latest_commit:`Latest Commit`,history:`History`,show_all_history:`Show all history`,change_count:`{count} changes`,no_commits:`No commits yet`,stage:`Stage`,unstage:`Unstage`,stage_all:`Stage All`,unstage_all:`Unstage All`,stage_failed_title:`Stage failed`,unstage_failed_title:`Unstage failed`,discard:`Discard`,discard_all:`Discard All`,discard_failed_title:`Discard failed`,discard_file_confirm_title:`Discard File Changes`,discard_file_confirm_message:`Are you sure you want to discard changes in "{path}"?`,discard_all_confirm_title:`Discard All Changes`,discard_all_confirm_message:`Are you sure you want to discard changes in {count} files?`,discard_confirm_irreversible:`This action cannot be undone.`,commit_failed_title:`Commit failed`,branch:`Branch`,switch_branch:`Switch Branch`,current_branch:`Current Branch`,no_branch:`Not on any branch`,ahead:`{count} commits ahead`,behind:`{count} commits behind`,synced:`Synced with remote`,push_confirm_title:`Push Changes`,push_confirm_message:`Do you want to push {count} local commits to the remote?`,pull_confirm_title:`Pull Changes`,pull_confirm_message:`Do you want to pull {count} remote commits into your local branch?`,sync_confirm_helper:`This action updates your current branch and workspace state.`,push_success_title:`Push completed`,push_success_body:`Local commits were pushed to the remote.`,push_success_target:`Pushed to {target}`,pull_success_title:`Pull completed`,pull_success_body:`Latest remote commits were pulled into your local branch.`,pull_success_target:`Pulled updates from {target}`,sync_up_to_date:`{target} is already up to date`,push_in_progress:`Pushing...`,pull_in_progress:`Pulling...`,push_failed_title:`Push failed`,pull_failed_title:`Pull failed`,fetch_success_title:`Fetched from remote`,fetch_success_body:`Remote tracking branches are up to date.`,fetch_failed_title:`Fetch failed`,fetch_refresh_failed_body:`Fetched from remote, but refreshing local git state failed.`,fetch_in_progress:`Fetching...`,fetch_label:`Fetch`,fetch_last_at:`Last fetched {when}`,fetch_last_never:`Never fetched`,operation_push:`push`,operation_pull:`pull`,operation_fetch:`fetch`,auth_required_message:`Authentication is required for {remote}.`,auth_failed_invalid:`Credentials for {remote} were rejected. Enter a valid username and password or personal access token to continue.`,auth_failed_forbidden:`Credentials for {remote} were accepted, but this account is not allowed to {operation}.`,auth_failed_unsupported:`Authentication failed for {remote}. Configure SSH keys or a credential helper, then try again.`,auth_helper_http:`Enter your Git username and password or a personal access token to retry this operation.`,auth_helper_unsupported:`This remote does not support in-app authentication. Configure SSH keys or a credential helper, then try again.`,auth_username:`Username`,auth_password:`Password or token`,auth_username_placeholder:`Git username`,auth_password_placeholder:`Password or personal access token`,branch_remote:`Remote`,quick_pick:{search_placeholder:`Search branches or create new branch...`,loading:`Loading branches...`,empty_filtered:`No branches found`,empty_idle:`Type to search branches`,in_use:`In Use`,worktree_in_use:`Checked out in another worktree`,checkout_failed_title:`Failed to switch branch`,checkout_failed_body:`Could not switch to {name}.`,create_failed_title:`Failed to create branch`,create_failed_body:`Could not create {name}.`,create_label:`Create branch`,confirm_create_label:`Confirm create branch`,create:`Create branch: {name}`,confirm_create:`Confirm create branch: {name}`},statusbar:{changes:`Uncommitted file changes`,ahead:`Local commits to push`,behind:`Remote commits to pull`}},worktree:{title:`Worktree`,status_tab:`Status`,diff_tab:`Diff`,tree_tab:`Tree`,path:`Path`,branch:`Branch`,changes:`Changes`,loading:`Loading...`,empty_tree:`Empty tree`,clean:`Clean`,dirty:`Dirty`,dirty_status:`Has changes`,staged_count:`Staged: {count}`,modified_count:`Modified: {count}`,untracked_count:`Untracked: {count}`,list_title:`Worktrees`,list_empty:`No worktrees`,list_open_label:`Open worktree list`,list_error:`Failed to load: {error}`,manage:`Manage`,new:`New`,current:`Current`,summary_total:`{count} worktrees`,summary_dirty:`{count} dirty`,summary_current:`Current: {name}`,summary_no_current:`Current: unavailable`,create_title:`Create Worktree`,create_submit:`Create`,create_path_hint:`Path must be absolute. The suggested path is derived from the current workspace path.`,create_path_absolute_required:`Path must be an absolute path.`,create_failed_title:`Failed to create worktree`,create_success_title:`Worktree created`,create_success_body:`{name} is ready.`,remove_confirm:`Remove worktree?`,remove_force_confirm:`Force remove dirty worktree?`,remove_failed_title:`Failed to remove worktree`,remove_success_title:`Worktree removed`,remove_success_body:`Worktree removed.`,force_remove:`Force Remove`,remove_row_label:`Remove {name}`,selection_removed:`The selected worktree is no longer available.`},settings:JSON.parse(`{"title":"Settings","general":"General","appearance":"Appearance","providers":"Agents","mobile_groups":{"workspace_runtime":"Workspace & Runtime","interface_interaction":"Interface & Interaction"},"about":{"title":"About","description":"View basic app details, version status, and update actions.","product_name":"Product","current_version":"Current Version","server_instance_id":"Server Instance ID","install_support":"Install Support","install_supported":"In-app update supported","install_unsupported":"This install shape does not support in-app updates","update_group":"Update","update_group_hint":"Check for new releases manually and start updates when the install shape supports it.","latest_version":"Latest Version","last_checked":"Last Checked","availability":"Availability","availability_unknown":"Not checked yet","availability_up_to_date":"Up to date","availability_update_available":"Update available","availability_check_failed":"Check failed","update_status":"Workflow Status","update_status_unknown":"Unknown","update_status_idle":"Idle","update_status_checking":"Checking","update_status_installing":"Installing","update_status_restarting":"Restarting service","update_status_succeeded":"Update succeeded","update_status_failed":"Update failed","update_status_manual_required":"Manual action required","error_summary":"Error Summary","manual_command":"Manual Command","check_now":"Check Now","checking":"Checking","check_failed":"Failed to check for updates","update_now":"Update Now","installing":"Working","auto_check_group":"Automatic Checks","auto_check_group_hint":"Configure the npm polling cadence. These preferences are persisted in the settings file.","auto_check_enabled":"Automatically check for updates","auto_check_enabled_hint":"When enabled, the service polls for the latest version on the selected interval.","check_interval":"Check Interval","interval_3600":"1 hour","interval_21600":"6 hours","interval_43200":"12 hours","interval_86400":"24 hours","confirm_update_title":"Confirm Update","confirm_update_message":"Updating installs a new version and restarts the service. Running terminals, agent sessions, or supervisor tasks may be interrupted.","confirm_update_activity":"{terminals} terminals, {sessions} sessions, and {supervisors} supervisor tasks are still active.","footer_update_available":"New version detected {version}","footer_installing":"Updating...","footer_restarting":"Restarting service...","footer_failed":"Update failed","footer_manual_required":"Manual action required","footer_view_details":"View details","footer_succeeded":"Updated to {version}"},"help_diagnostics":"Help & Diagnostics","autosave_hint":"Settings saved automatically","load_failed":"Failed to load settings","load_failed_unknown":"Server did not return settings data","notifications":"Notifications","notifications_channel_hint":"No notification while you are in the originating workspace; an in-app banner if you are in another workspace; a system notification when the window is hidden.","notifications_enabled":"Enable completion notifications","notifications_enabled_hint":"Send notification when Agent session completes","notification_sound":"Notification sound","notification_sound_hint":"Play a completion chime when a notification fires","notification_status":"Notification Status","notification_status_available":"Available","notification_status_limited":"Limited","notification_status_limited_hint":"System notifications on this mobile browser are inconsistent; browser permission does not guarantee delivery.","notification_status_unsupported":"Unsupported","notification_status_unsupported_hint":"This browser environment does not support this notification path.","notification_permission":"Notification Permission","permission_granted":"Granted","permission_denied":"Denied","permission_request":"Request Permission","permission_unavailable":"Unavailable","permission_limited_hint":"Even with notification permission allowed, this mobile browser may still fail to show system notifications reliably.","supervisor":{"title":"Supervisor","hint":"Configure supervisor evaluation timeout and global retry behavior. Retry rules apply to all supervisors.","evaluation_timeout":"Supervisor Evaluation Timeout (seconds)","validation_error":"Enter a whole number between 1 and {max} seconds.","retry_enabled":"Enable Supervisor Retries","retry_enabled_hint":"Automatically retry when evaluation times out or the evaluator fails.","retry_max_count":"Max Retry Count","retry_max_count_validation_error":"Enter a whole number between 0 and {max}.","retry_delay_sec":"Retry Delay (seconds)","retry_delay_validation_error":"Enter a whole number between 1 and {max} seconds.","retry_on_timeout":"Retry On Timeout","retry_on_timeout_hint":"Retry automatically after evaluation timeout.","retry_on_evaluator_error":"Retry On Evaluator Error","retry_on_evaluator_error_hint":"Retry automatically when the evaluator process or runtime fails."},"terminal_renderer":"Terminal Renderer","terminal_renderer_hint":"Choose terminal rendering mode","lsp_runtime_mode":"LSP Runtime Mode","lsp_runtime_mode_hint":"Control code intelligence memory usage. Turning it off immediately stops active language service processes, so diagnostics, go-to-definition, hover, and similar features become temporarily unavailable.","lsp_runtime_mode_auto":"Auto","lsp_runtime_mode_off":"Off","appearance_background_material":"Background & Material","appearance_background_material_hint":"Configure account-synced wallpapers, glass effects, and surface opacity, with optional desktop and mobile overrides.","appearance_background_mode":"Background mode","appearance_background_mode_off":"Off","appearance_background_mode_image":"Image","appearance_background_upload":"Background image","appearance_background_replace":"Replace background image","appearance_background_remove":"Remove background image","appearance_background_fit":"Background fit","appearance_background_fit_cover":"Cover","appearance_background_fit_contain":"Contain","appearance_background_dimness":"Background dimness","appearance_background_blur":"Background blur","appearance_glass_enabled":"Enable glass effect","appearance_glass_intensity":"Glass intensity","appearance_surface_opacity":"Surface opacity","appearance_override_desktop":"Desktop override","appearance_override_mobile":"Mobile override","appearance_override_enabled":"Custom value enabled","appearance_uses_shared_value":"Using the shared value","appearance_asset_upload_failed":"Failed to upload background image","appearance_asset_delete_failed":"Failed to remove background image","terminal_appearance":"Terminal Appearance","copy_on_select":"Copy on select","copy_on_select_hint":"Automatically copy selected text to the system clipboard","terminal_font_size":"Terminal font size","terminal_font_size_hint":"Set separate terminal font sizes for desktop and mobile. Open terminals update immediately.","desktop_terminal_font_size":"Desktop terminal font size","desktop_terminal_font_size_hint":"Applies to desktop and other pointer-precise terminals.","mobile_terminal_font_size":"Mobile terminal font size","mobile_terminal_font_size_hint":"Applies to phones, tablets, and other mobile terminals.","terminal_font_size_validation_error":"Enter a whole number between {min} and {max}.","copy_on_select_failed_title":"Copy on select failed","copy_on_select_failed_body":"Use Ctrl/Cmd+C to copy manually","terminal_standard":"Standard","terminal_compatibility":"Compatibility Mode","provider":{"title":"Agent Settings","status":"Status","capability":"Capability Level","capability_full":"Full Support","capability_limited":"Limited Support","capability_unsupported":"Unsupported","hooks_registered":"Hooks Registered","hooks_unregistered":"Hooks Not Registered","hooks_error":"Hooks Registration Failed","hooks":"Hooks Integration","hooks_hint":"Inject agent-specific hooks into current workspace","hooks_inject":"Inject Hooks","configure":"Configure","reset":"Reset","config":"Configuration","base":"Base Settings","config_file":"Config File","open_config_file_editor":"Open Config File Editor","back_to_base":"Back to Base Settings","startup_args":"Startup Command Args","startup_args_hint":"Enter one startup argument per line. Each saved line is appended to the agent launch command.","startup_args_placeholder":"--verbose\\n--debug","command_preview_title":"Command Preview","command_preview_hint":"Preview the effective agent launch command"},"theme":{"title":"Theme","dark":"Dark","light":"Light","system":"System","hint":"Choose app theme","family":"Theme Family","variant":"Variant","family_mint":"Mint","family_graphite":"Graphite","family_nord":"Nord","family_hc":"High Contrast","mint_dark":"Mint Dark","mint_light":"Mint Light","graphite_dark":"Graphite Dark","graphite_light":"Graphite Light","nord_dark":"Nord Dark","nord_light":"Nord Light","hc_dark":"High Contrast Dark","hc_light":"High Contrast Light","variant_dark":"Dark","variant_light":"Light"},"language":{"title":"Language","zh":"中文","en":"English","hint":"Select interface language"},"auth":{"title":"Authentication","password":"Password","password_set":"Set Password","password_change":"Change Password","password_remove":"Remove Password"},"shortcuts":{"title":"Keyboard Shortcuts","hint":"Review and adjust common keyboard actions","reset_all":"Reset All","capture_hint":"Press new shortcut combination","reset_hint":"Reset to default"},"config_files":{"title":"Config Files","codex_config":"Codex Config","claude_config":"Claude Config","path_label":"Path","unsaved_changes":"Unsaved changes","saving":"Saving...","save_success":"Config saved successfully","save_success_with_backup":"Updated {configPath} and created backup {backupPath}","backup_created":"Backup saved to {path}","save_failed":"Failed to save config","load_failed":"Failed to load config","file_not_found":"Config file does not exist. Edit and save to create it.","status_saved":"Saved","collapse":"Collapse","format":"Format","format_hint":"Format JSON code","file_not_found_hint":"Edit and save to create the config file."},"permission_denied_hint":"Browser or system notification permission may be blocked. Check site settings and device notification settings.","permission_unavailable_hint":"This environment cannot request browser notification permission"}`),auth:{description:`Enter your password to continue to the current workspace.`,hint:`Enter the access password configured for this deployment.`,blocked_until:`Too many attempts. Try again after {time}, or ask an administrator to unblock access.`,blocked_generic:`Too many attempts. Try again later, or ask an administrator to unblock access.`,status_title:`Access verification`,status_loading:`Checking the access state for this deployment.`,status_unavailable:`The authentication service is temporarily unavailable. Please try again shortly.`,status_not_configured:`Authentication is not configured on this deployment.`,session_gate_title:`SESSION GATE`,session_gate_description:`This tab was displaced by another tab and must re-enter before continuing.`,session_gate_detail:`The websocket connection has been closed. Recovery will reload fresh server state.`,session_gate_reenter:`Re-enter`,session_gate_reentering:`Re-entering`},connection:{title:`Connection`,status:`Status`,reconnecting:`Reconnecting...`,reconnect_failed:`Reconnection failed`,another_tab:`Another tab is active`,takeover:`Take Control`,server_shutdown:`Server has shut down`,backpressure_warning:`Network congested, some output may be lost`},supervisor:{title:`Supervisor`,empty:`Supervisor is not enabled`,completed_cycles:`Cycles {count}`,latest_evaluation:`Latest evaluation`,state:{inactive:`Inactive`,idle:`Idle`,evaluating:`Evaluating`,injecting:`Injecting`,paused:`Paused`,error:`Error`,stopped:`Stopped`},trigger:{manual:`MANUAL`,auto:`AUTO`,scheduled:`SCHEDULED`},cycle:{no_guidance:`No guidance injected this cycle`,evaluating:`Evaluating...`,waiting:`Waiting for evaluation result`,waiting_evaluator:`Waiting for evaluator response`,retry_wait:`Retrying evaluator in {seconds}s`,injecting:`Injecting guidance`,cancelled:`Cancelled`},stop_reason:{objective_complete:`Objective complete. Supervisor stopped automatically.`,max_supervision_count_reached:`Reached the configured max supervision count.`,supervisor_uncertain:`Supervisor could not determine the next step and stopped automatic supervision.`},target_memory:{title:`Target memory`,target:`Target`,stalled:`Stalled`,decomposition_ready:`Decomposition ready`,decomposition_pending:`Decomposition pending`,decomposition_mode_title:`Mode`,decomposition_title:`Decomposition`,basic_info_title:`Basic Info`,runtime_title:`Runtime Status`,runtime_status_label:`Status`,error_reason_label:`Error reason`,cycles_title:`Cycles`,progress_list_title:`Progress List`,item_objective_title:`Stage objective`,item_deliverable_title:`Deliverable`,active_item:`Active item`,progress_title:`Target progress`,progress_badge:`PROGRESS`,reasoning_title:`Target cycle reasoning`,runtime_status:{idle:`Idle`,running:`Running`,error:`Error`},decomposition_mode:{stage:`Stages`,subtarget:`Subtargets`},cycle_result:{continue:`CONTINUE`,stop:`STOP`,error:`ERROR`},step_status:{pending:`Not started`,in_progress:`In progress`,done:`Completed`}},meta:{title:`Execution policy`,no_cap:`No cap`},field:{objective:`Objective`,current_objective:`Current objective`,objective_placeholder:`Describe what Supervisor should watch, for example:
|
|
96
96
|
- Finish implementing user authentication
|
|
97
97
|
- Fix all failing unit tests
|
|
98
|
-
- Reduce P95 latency below 100ms`,objective_helper:`The more specific and measurable the target, the better the evaluation. Include completion criteria when possible.`,evaluator:`Evaluator`,evaluator_helper:`The provider that evaluates progress and suggests the next step. It can differ from the execution provider.`,evaluator_model:`Evaluator Model`,evaluator_model_placeholder:`Optional model override, for example o3 or gpt-5`,evaluator_model_helper:`Leave blank to use the provider's default supervisor evaluation model behavior.`,max_supervision_count:`Max Supervision Count`,max_supervision_count_helper:`Set to 0 for no explicit cap. Evaluation can still stop earlier if the objective is complete.`,scheduled_at_placeholder:`Choose when to run`,scheduled_at:`Scheduled Run Time`,scheduled_at_helper:`Specify when to run the first evaluation. After the scheduled time, evaluations will trigger automatically at the end of each conversation turn. Leave blank to trigger automatically at the end of each turn.`},action:{enable:`Enable Supervisor`,enable_objective:`Enable Objective`,details:`Supervisor Details`,edit_objective:`Edit Supervisor`,pause:`Pause`,resume:`Resume`,trigger:`Trigger Evaluation`,pause_failed:`Failed to pause Supervisor`,resume_failed:`Failed to resume Supervisor`,trigger_failed:`Failed to trigger evaluation`},dialog:{enable:{title:`Enable Supervisor`,subtitle:`Describe an objective and Supervisor will evaluate progress and suggest the next step after each turn.`,confirm:`Enable`},edit:{title:`Edit Supervisor`,subtitle:`Adjust the objective and restore a previous memory snapshot when needed.`,confirm:`Save`,reset_confirm_title:`Save and reset supervisor progress?`,reset_confirm_description:`Changing the objective will make Supervisor re-evaluate the goal. Existing supervisor memory and progress for this target will be reset.`},restore:{open:`Restore from Existing Memory`,hint:`Reuse supervisor memory from an existing target directory for this session.`,title:`Restore Supervisor Memory`,subtitle:`Choose a recoverable memory snapshot and attach it to the current session supervisor.`,back:`Back to Details`,confirm:`Restore`,empty:`No recoverable supervisor memory found.`,empty_hint:`Only target directories with readable supervisor memory can be restored.`,cycle_count:`{count} cycles`,updated_at:`Updated {time}`},details:{title:`Supervisor Details`}}},command:{palette:`Command Palette`,no_results:`No results found`,shortcut:{save:`Save`,save_all:`Save All`,search:`Search`,search_files:`Search Files`,command_palette:`Command Palette`,toggle_focus:`Toggle Focus Mode`,toggle_sidebar:`Toggle Sidebar`,toggle_terminal:`Toggle Terminal Panel`}},notification:{success:`Success`,error:`Error`,warning:`Warning`,info:`Info`,session_turn_completed:`Session turn completed`,file_saved:`File saved`,committed:`Committed`,session_completed_title:`{session} completed`,session_completed_body:`Agent session has finished executing`,session_ended:`Session ended`,session_ended_hint:`The session has stopped running`},error:{unknown:`Unknown error`,network:`Network error`,not_found:`Not found`,permission_denied:`Permission denied`,validation:`Validation failed`,conflict:`Resource conflict`},welcome:{kicker:`DEPLOY ONCE, CODE EVERYWHERE`,title:`Welcome to Coder Studio`,description:`Deploy your coding workspace once, then keep working from wherever you are. Same workspace, same context, across all your devices.`,features:{agent_first:{title:`Agent-first AI coding`,description:`Launch AI sessions that write, test, and deploy code.`},git_tools:{title:`Built-in Git tools`,description:`Stage, commit, and manage branches without leaving the IDE.`},terminals:{title:`Integrated terminals`,description:`Run commands and scripts alongside your AI sessions.`}}},diagnostics:{title:`Diagnostics`,settings_hint:`Diagnose the runtime environment to help identify and recover from issues.`,load_failed:`Diagnostics could not be refreshed right now.`,loading_description:`Checking the parts that matter for this task.`,status:{checking:`Checking`,ready:`Ready`,needs_attention:`Needs attention`},actions:{retry_workspace:`Retry Opening Workspace`,continue_session:`Continue Starting Session`,continue_phone:`Continue on Phone`,recheck:`Recheck`,open_diagnostics:`Open Diagnostics`,copy_details:`Copy error details`,copied:`Copied`,install_provider:`Install Provider`},details:{workspace:`Workspace`,provider:`Provider`,missing_commands:`Missing commands`,missing_prerequisites:`Missing prerequisites`,current_version:`Current version`},context:{workspace_open:{title:`We couldn't open your workspace`,description:`A few issues need attention before we can continue.`},session_start:{title:`Your session is not ready to start`,description:`We found a problem that would block session startup.`},mobile_continue:{title:`Phone continuation needs a few fixes`,description:`We checked the phone handoff path and found something to fix first.`},manual_check:{title:`Environment diagnostics`,description:`Review the current environment and refresh anything that looks off.`}},checks:{workspace_selection_missing:{title:`Workspace path needed`,description:`Choose a directory before retrying.`},workspace_path_ready:{title:`Workspace path is ready`,description:`The selected directory is reachable.`},workspace_path_not_found:{title:`Workspace path no longer exists`,description:`The selected directory could not be found.`},workspace_path_unreadable:{title:`Workspace path is not readable`,description:`The selected directory exists but cannot be opened right now.`},session_workspace_ready:{title:`Workspace is ready`,description:`The target workspace is available for session startup.`},session_workspace_missing:{title:`Workspace is missing`,description:`Select or reopen the workspace before starting a session.`},git_ready:{title:`Git is ready`,description:`Git is installed and available in the current environment.`},git_missing:{title:`Git is missing`,description:`Install Git before relying on workspace repository features.`},nodejs_ready:{title:`Node.js is ready`,description:`Node.js is installed and available in the current environment.`},nodejs_missing:{title:`Node.js is missing`,description:`Install Node.js before running local JavaScript and package tasks.`},provider_runtime_ready:{title:`{provider} is ready`,description:`{provider} can be launched from this workspace.`},provider_cli_missing:{title:`{provider} CLI is missing`,description:`The required provider command is not installed yet.`},provider_prerequisite_missing:{title:`{provider} prerequisites are missing`,description:`A prerequisite must be installed before the provider can run.`},provider_unknown:{title:`Provider is unknown`,description:`This provider could not be resolved from current settings.`},server_auth_ready:{title:`Password protection is enabled`,description:`Authentication is configured for this server.`},server_auth_not_required:{title:`Password protection is optional`,description:`Authentication is currently not required.`},mobile_host_ready:{title:`Network host is reachable`,description:`The current host looks suitable for phone continuation.`},mobile_host_local_only:{title:`Host is local-only`,description:`Phone continuation needs a LAN-reachable host instead of localhost.`},mobile_auth_disabled:{title:`Phone continuation needs auth`,description:`Enable authentication before continuing on your phone.`}}},not_found:{kicker:`ROUTE NOT FOUND`,title:`Page not found`,description:`The route you opened does not exist in this workspace shell.`,path_label:`Requested path`,go_home:`Go Home`},confirm:{save_changes:`Save changes?`,discard_changes:`Discard changes?`,delete_file:`Delete this file?`,stop_session:`Stop session?`,close_workspace:`Close workspace?`},placeholder:{search:`Type to search...`,command:`Type a command or shortcut...`,commit_message:`Enter commit message`},tooltip:{focus_mode:`Focus Mode: Hide sidebar and bottom panel`,split_horizontal:`Split panel horizontally`,split_vertical:`Split panel vertically`,close_pane:`Close panel`,new_workspace:`New workspace`,quick_actions:`Quick Actions`,enter_fullscreen:`Enter Fullscreen`,exit_fullscreen:`Exit Fullscreen`,show_terminal:`Show Terminal`,hide_terminal:`Hide Terminal`,show_files:`Show Files`,hide_files:`Hide Files`},time:{just_now:`Just now`,seconds_ago:`{count} seconds ago`,minutes_ago:`{count} minutes ago`,hours_ago:`{count} hours ago`,days_ago:`{count} days ago`},fencing:{observer_mode:`Read-only mode — another tab is the controller`,takeover:`Take over`,takeover_failed:`Takeover failed — controller is still active`}},am={datetime:{today:`今天`,tomorrow:`明天`,next_week:`下周`,prev_month:`上一月`,next_month:`下一月`,clear:`清空`,confirm:`确认`,select_date:`选择日期`,select_time:`选择时间`,hour:`小时`,minute:`分钟`,january:`一月`,february:`二月`,march:`三月`,april:`四月`,may:`五月`,june:`六月`,july:`七月`,august:`八月`,september:`九月`,october:`十月`,november:`十一月`,december:`十二月`,sun:`日`,mon:`一`,tue:`二`,wed:`三`,thu:`四`,fri:`五`,sat:`六`},app:{name:`Coder Studio`,description:`Agent-First Development Environment`},common:{loading:`加载中...`,error:`错误`,success:`成功`,warning:`警告`,info:`信息`,enabled:`已启用`,disabled:`已禁用`,confirm:`确认`,cancel:`取消`,save:`保存`,delete:`删除`,edit:`编辑`,view:`查看`,close:`关闭`,yes:`是`,no:`否`,ok:`确定`,all:`全部`},action:{open:`打开`,open_workspace:`打开工作区`,close_workspace:`关闭工作区`,create_session:`创建会话`,stop_session:`停止会话`,resume_session:`恢复会话`,save_file:`保存`,save_all:`保存全部`,save:`保存`,discard_changes:`放弃更改`,commit:`提交`,push:`推送`,pull:`拉取`,refresh:`刷新`,settings:`设置`,cancel:`取消`,confirm:`确认`,close:`关闭`,apply:`应用`,reset:`重置`,search:`搜索`,search_files:`搜索文件`,search_commands:`搜索命令`,back:`返回`,expand:`展开`,collapse:`收起`,close_all:`全部关闭`},label:{workspace:`工作区`,agent:`Agent`,session:`会话`,terminal:`终端`,file:`文件`,git:`Git`,settings:`设置`,provider:`Provider`,status:`状态`,progress:`进度`},provider:{install:{cta:{start:`启动会话`,install_and_start:`安装并启动`,installing:`安装中...`,manual:`查看安装步骤`},status:{installing:`正在安装 Provider CLI...`,failed:`自动安装失败`},open_docs:`打开官方文档`,nodejs:{manual:`请先从 Node.js 官方下载页安装 Node.js。`},claude:{manual:`然后执行 npm install -g @anthropic-ai/claude-code。`},codex:{manual:`然后执行 npm install -g @openai/codex。`}}},status:{starting:`启动中`,running:`运行中`,idle:`空闲`,busy:`忙碌`,ended:`已结束`,unavailable:`不可用`,connecting:`连接中`,connected:`已连接`,disconnected:`已断开`,reconnecting:`重连中`,rejected:`被拒绝`},workspace:{title:`工作区`,tabs:`工作区标签`,open:`打开`,close:`关闭`,path:`路径`,no_workspace:`未打开工作区`,refresh_partial_title:`工作区刷新未完全成功`,refresh_partial_body:`已完成可刷新的部分,但这些区域失败了:{sections}`,fullscreen:{unsupported_title:`当前无法全屏`,unsupported_body:`当前浏览器不支持全屏功能。`,enter_failed_title:`进入全屏失败`,enter_failed_body:`浏览器拒绝了全屏请求。`,exit_failed_title:`退出全屏失败`,exit_failed_body:`浏览器暂时无法退出全屏。`},open_hint:`点击下方按钮打开一个项目目录`,loading_title:`正在加载工作区`,loading_description:`正在准备工作区列表并恢复上次活跃的会话。`,load_failed_title:`工作区加载失败`,load_failed_description:`获取工作区列表失败`,sidebar:{label:`工作区活动栏`,explorer:`资源管理器`,search:`搜索`,source_control:`源代码管理`,open_editors:`打开的编辑器`,workspace:`工作区`},quick_jump:{title:`快速跳转`,placeholder:`输入文件名或路径`,no_results:`未找到匹配文件。`,failed:`文件搜索失败,请重试。`},open_editors:{title_with_count:`{title} ({count})`,close_path:`关闭 {path}`,expand_label:`展开打开的编辑器`,collapse_label:`收起打开的编辑器`},search:{empty:`输入关键词以搜索文件内容。`,placeholder:`搜索文件内容`,results_count:`在 {files} 个文件中找到 {count} 条结果`,no_results:`未找到内容匹配。`,truncated:`结果已截断,以保持搜索响应速度。`,file_match_count:`{count}{suffix} 条匹配`,failed:`搜索失败,请重试。`,retry:`重试`},launch:{kicker:`启动工作区`,title:`打开工作区`,home_directory:`主目录`,go_up:`返回上一级`,no_directories:`未找到目录`,items_count:`{count} 项`,enter_folder:`进入 {name}`,enter_folder_action:`进入文件夹 →`,cancel:`取消`,start:`启动工作区`,starting:`启动中...`,hint:`选择一个目录作为工作区根目录。`,browse_failed:`浏览目录失败`,select_required:`请选择一个目录`,open_failed:`打开工作区失败`},runtime_check:{title:`运行时检查`,checking:`正在检查运行时环境...`,success:`运行时环境检查通过`,failed:`运行时环境检查失败`,missing_git:`未找到 Git 命令`,missing_node:`未找到 Node.js`,missing_provider:`未找到 {provider} CLI`}},quick_open:{title:`跳转到文件`,placeholder:`输入文件名或路径`,empty:`输入内容以按文件名或路径搜索。`,no_results:`未找到匹配文件。`,failed:`文件搜索失败,请重试。`,command_label:`跳转到文件...`,command_description:`在当前工作区中快速打开文件`},mobile:{dock:{aria_label:`移动底栏`,open_agent:`打开 Agent 面板`,open_files:`打开文件面板`,open_terminal:`打开终端面板`},agent:{title:`Agent 会话`,close_current_session:`关闭当前会话`,providers:`会话提供方`,start_session:`启动 {provider} 会话`,starting:`正在启动…`,start_new_session:`启动新会话`,active_agents:`活跃 Agent`,switch_to_agent:`切换到 Agent {name}`,empty:`暂无活跃会话`},supervisor:{open_sheet:`打开 Supervisor 面板`},topbar:{switch_workspace:`切换工作区`,open_settings:`打开设置`},sheet:{dismiss:`关闭当前面板`,region:`{title}面板`},files:{tabs:`文件面板标签`,git_diff:`Git`,editor_fallback:`编辑器`},workspace_drawer:{aria_label:`工作区抽屉`,close:`关闭工作区抽屉`,select_title:`选择工作区`,switch_to_workspace:`切换到工作区 {name}`,close_workspace:`关闭工作区 {name}`},empty:{start_session:`为当前工作区启动一个新的 Agent 会话。`,files_terminal_hint:`文件和终端可继续通过底部栏访问。`}},session:{title:`会话`,create:`创建会话`,stop:`停止`,resume:`恢复`,no_session:`无活跃会话`,provider_select:`选择 Agent`,state:{starting:`启动中...`,running:`运行中`,idle:`等待指令`,busy:`执行中`,ended:`已停止`,unavailable:`不可用`},resume_unavailable:`此会话无法恢复`,progress:{thinking:`正在思考...`,executing:`正在执行...`,waiting:`等待响应...`}},terminal:{title:`终端`,kicker:`TERMINAL`,new_terminal:`新建终端`,close_terminal:`关闭终端`,shell:`Shell 终端`,agent:`Agent 终端`,reconnect_hint:`连接已断开,正在重连...`,no_terminal:`暂无终端`,empty_hint:`启动一个 Shell 来查看文件、运行命令,并在不离开工作区的情况下验证更改。`,load_failed_title:`加载终端失败`,load_failed_body:`请刷新工作区连接后重试。`,create_failed_title:`创建终端失败`,create_failed_body:`Shell 进程启动失败,请检查服务端运行环境和 Shell 配置。`,create_unavailable_title:`当前没有已选中的工作区`,create_unavailable_body:`请先打开或切换到一个工作区,再新建终端。`,copied_current_line:`已复制当前行`,mobile_copy_current_line_failed_title:`当前行复制失败`,mobile_copy_current_line_failed_body:`请重试长按当前行`,paste_dialog_title:`粘贴文本`,paste_dialog_placeholder:`在此粘贴您的文本...`,paste_dialog_submit:`发送`,hide:`隐藏终端`,show:`显示终端`,selector:{switch:`切换终端`,title:`终端会话`,current:`当前终端`,indexed:`终端 {index}`},mobile_input:{paste:`粘贴`,upload:`上传`,shortcuts:`终端快捷按键`,ctrl:`Ctrl`,ctrl_armed:`Ctrl 已待命`,ctrl_locked:`Ctrl 已锁定`,shift:`Shift`,shift_armed:`Shift 已待命`,escape:`Esc`,tab:`Tab`,enter:`Enter`,up:`上方向键`,down:`下方向键`,left:`左方向键`,right:`右方向键`},replay:{queued_title:`等待队列中(前方还有 {count} 个)`,up_next:`即将开始…`,loading_title:`正在恢复终端内容…`,loading_body:`恢复期间暂时无法使用当前终端;请耐心等待,历史内容恢复完成后再继续。内容较多时可能需要更久。`,failed_title:`终端历史暂未恢复`,failed_body:`当前终端可以继续使用,但较早输出这次仍未补齐。请稍后或刷新页面后再看;如果服务端仍保留历史,后续仍可能找回。`,retryable_title:`终端历史暂未恢复`,retryable_body:`当前终端可以继续使用,但较早输出这次没有补齐。你可以重试恢复;如果服务端仍保留历史,稍后或刷新页面后仍可能找回。`,retry_action:`重试恢复`,unrecoverable_title:`较早历史已无法恢复`,unrecoverable_body:`较早的终端输出已经从回放缓冲区中淘汰,而且当前也没有可用快照。现在只能继续查看后续输出。`,unknown_title:`当前终端已不可恢复`,unknown_body:`这个终端会话已经不在服务端,历史输出无法再补回。请重新打开一个新终端继续。`,unknown_body_with_provider:`这个终端会话已经不在服务端。是否重新打开一个 {provider} 会话继续?`,closed_title:`当前会话已结束`,closed_body:`是否重新打开一个新会话继续。`,closed_body_with_provider:`是否重新打开一个 {provider} 会话继续。`,truncated_title:`历史内容不完整`,truncated_body:`较早的终端输出已被回放缓冲区淘汰,后续输出仍会继续显示。`}},file:{title:`文件`,modified:`已修改`,unsaved:`未保存`,dirty:`有未保存更改`,visible_count:`{count} 个文件`,empty_directory:`空文件夹`,new_file:`新建文件`,new_folder:`新建文件夹`,collapse_all:`折叠全部`,rename:`重命名`,rename_name:`名称`,rename_helper:`当前版本仅支持在同级目录内重命名。`,rename_required:`请输入名称`,rename_invalid_name:`名称不能包含 / 或 \\。`,rename_failed:`重命名失败`,delete:`删除`,delete_confirm:`确定要删除 "{name}" 吗?`,copy_relative_path:`复制相对路径`,copy_absolute_path:`复制绝对路径`,open_in_terminal:`在终端中打开`,context_menu_title:`文件操作`,context_section_create:`创建`,context_section_edit:`编辑`,context_section_path:`路径`,context_section_terminal:`终端`,path:`路径`,path_required:`请输入路径`,invalid_file_path:`文件路径不能以 / 结尾`,path_helper_file:`输入工作区内的相对路径,例如 src/demo/new-file.ts`,path_helper_folder:`输入工作区内的相对路径,例如 src/demo/new-folder`,create_failed:`创建失败`,delete_failed:`删除失败`,conflict:`文件已被外部程序修改`,conflict_message:`文件可能已被编辑器外部修改。要放弃本地更改并重新加载吗?`},code_editor:{saving:`保存中...`,edit_as_text:`以文本编辑`,preview_as_image:`以图像预览`,preview_loading:`正在加载预览...`,preview_unavailable:`预览不可用`,preview_retry:`重试`,mode_text:`文本`,mode_image:`图像`,mode_preview:`预览`,mode_edit:`编辑`,mode_diff:`Diff`,diff_saved_only:`Diff 仅基于已保存到磁盘的文件内容。`,open_failed_title:`打开文件失败`,empty_hint:`从左侧选择一个文件以在编辑器中打开。`,modified_on_disk:`该文件在打开后已被磁盘上的其他操作修改。请谨慎保存或重新加载文件。`,deleted_on_disk:`该文件在打开后已被磁盘上的其他操作删除。`},git:{title:`Git`,changes:`更改`,staged:`已暂存`,modified:`已修改`,deleted:`已删除`,unstaged:`未暂存`,untracked:`未跟踪`,no_changes:`无更改`,commit:`提交`,commit_message:`提交信息`,commit_placeholder:`输入提交信息...`,commit_summary_placeholder:`输入提交信息...`,commit_staged_count:`已暂存 {count}`,nothing_staged:`没有可提交的已暂存更改`,latest_commit:`最新提交`,history:`历史`,show_all_history:`查看全部`,change_count:`{count} 处更改`,no_commits:`暂无提交`,stage:`暂存`,unstage:`取消暂存`,stage_all:`暂存全部`,unstage_all:`取消暂存全部`,stage_failed_title:`暂存失败`,unstage_failed_title:`取消暂存失败`,discard:`放弃`,discard_all:`放弃全部`,discard_failed_title:`放弃失败`,discard_file_confirm_title:`放弃文件更改`,discard_file_confirm_message:`确定要放弃 “{path}” 的更改吗?`,discard_all_confirm_title:`放弃所有更改`,discard_all_confirm_message:`确定要放弃 {count} 个文件的更改吗?`,discard_confirm_irreversible:`此操作不可恢复。`,commit_failed_title:`提交失败`,branch:`分支`,switch_branch:`切换分支`,current_branch:`当前分支`,no_branch:`不在任何分支上`,ahead:`领先 {count} 个提交`,behind:`落后 {count} 个提交`,synced:`与远程同步`,push_confirm_title:`推送更改`,push_confirm_message:`是否将 {count} 个本地提交推送到远端?`,pull_confirm_title:`拉取更改`,pull_confirm_message:`是否从远端拉取 {count} 个最新提交到本地?`,sync_confirm_helper:`该操作会更新当前分支和工作区状态。`,push_success_title:`推送完成`,push_success_body:`本地提交已推送到远端。`,push_success_target:`已推送到 {target}`,pull_success_title:`拉取完成`,pull_success_body:`已拉取远端最新提交到当前分支。`,pull_success_target:`已从 {target} 拉取更新`,sync_up_to_date:`{target} 已是最新`,push_in_progress:`推送中...`,pull_in_progress:`拉取中...`,push_failed_title:`推送失败`,pull_failed_title:`拉取失败`,fetch_success_title:`已从远端获取`,fetch_success_body:`远端跟踪分支已更新。`,fetch_failed_title:`获取失败`,fetch_refresh_failed_body:`已从远端获取,但刷新本地 Git 状态失败。`,fetch_in_progress:`获取中...`,fetch_label:`获取`,fetch_last_at:`上次获取于 {when}`,fetch_last_never:`尚未获取`,operation_push:`推送`,operation_pull:`拉取`,operation_fetch:`获取`,auth_required_message:`{remote} 需要认证。`,auth_failed_invalid:`{remote} 的凭证被拒绝,请输入有效的用户名和密码或个人访问令牌后重试。`,auth_failed_forbidden:`{remote} 已接受当前凭证,但该账号没有执行 {operation} 的权限。`,auth_failed_unsupported:`{remote} 认证失败。请先配置 SSH key 或 credential helper,再重试。`,auth_helper_http:`请输入 Git 用户名和密码,或个人访问令牌后重试。`,auth_helper_unsupported:`当前远端不支持应用内认证。请先配置 SSH key 或 credential helper,再重试。`,auth_username:`用户名`,auth_password:`密码或令牌`,auth_username_placeholder:`Git 用户名`,auth_password_placeholder:`密码或个人访问令牌`,branch_remote:`远程`,quick_pick:{search_placeholder:`搜索分支或创建新分支...`,loading:`正在加载分支...`,empty_filtered:`未找到分支`,empty_idle:`输入以搜索分支`,in_use:`占用中`,worktree_in_use:`已在其他工作区中签出`,checkout_failed_title:`切换分支失败`,checkout_failed_body:`无法切换到 {name}。`,create_failed_title:`创建分支失败`,create_failed_body:`无法创建 {name}。`,create_label:`创建分支`,confirm_create_label:`确认创建分支`,create:`创建分支:{name}`,confirm_create:`确认创建分支:{name}`},statusbar:{changes:`未提交的文件变更`,ahead:`待推送的本地提交`,behind:`远端有新提交待拉取`}},worktree:{title:`工作树`,status_tab:`状态`,diff_tab:`差异`,tree_tab:`树`,path:`路径`,branch:`分支`,changes:`更改`,loading:`加载中...`,empty_tree:`空目录树`,clean:`干净`,dirty:`有更改`,dirty_status:`有更改`,staged_count:`已暂存:{count}`,modified_count:`已修改:{count}`,untracked_count:`未跟踪:{count}`,list_title:`工作树列表`,list_empty:`暂无工作树`,list_open_label:`查看工作树`,list_error:`加载失败:{error}`,manage:`管理`,new:`新建`,current:`当前`,summary_total:`{count} 个工作树`,summary_dirty:`{count} 个有更改`,summary_current:`当前:{name}`,summary_no_current:`当前:不可用`,create_title:`新建工作树`,create_submit:`创建`,create_path_hint:`路径必须是绝对路径。默认建议路径会基于当前工作区路径生成。`,create_path_absolute_required:`路径必须是绝对路径。`,create_failed_title:`创建工作树失败`,create_success_title:`工作树已创建`,create_success_body:`{name} 已可用。`,remove_confirm:`确认删除这个工作树?`,remove_force_confirm:`强制删除有更改的工作树?`,remove_failed_title:`删除工作树失败`,remove_success_title:`工作树已删除`,remove_success_body:`工作树已删除。`,force_remove:`强制删除`,remove_row_label:`删除 {name}`,selection_removed:`所选工作树已不可用。`},settings:{title:`设置`,general:`通用`,appearance:`外观`,providers:`Agents`,mobile_groups:{workspace_runtime:`工作区与运行`,interface_interaction:`界面与交互`},about:{title:`关于`,description:`查看当前应用信息、版本状态以及更新能力。`,product_name:`产品名称`,current_version:`当前版本`,server_instance_id:`服务实例 ID`,install_support:`安装支持`,install_supported:`支持应用内更新`,install_unsupported:`当前安装方式不支持应用内更新`,update_group:`更新`,update_group_hint:`手动检查新版本,并在支持的安装方式下启动更新。`,latest_version:`最新版本`,last_checked:`上次检查`,availability:`版本状态`,availability_unknown:`尚未检查`,availability_up_to_date:`已是最新版本`,availability_update_available:`发现新版本`,availability_check_failed:`检查失败`,update_status:`更新流程`,update_status_unknown:`未知`,update_status_idle:`空闲`,update_status_checking:`检查中`,update_status_installing:`安装中`,update_status_restarting:`重启服务中`,update_status_succeeded:`更新成功`,update_status_failed:`更新失败`,update_status_manual_required:`需要手动处理`,error_summary:`错误摘要`,manual_command:`手动命令`,check_now:`立即检查`,checking:`检查中`,check_failed:`检查更新失败`,update_now:`立即更新`,installing:`处理中`,auto_check_group:`自动检查`,auto_check_group_hint:`配置后台轮询 npm 的节奏。相关偏好会持久化到设置文件。`,auto_check_enabled:`自动检查更新`,auto_check_enabled_hint:`开启后,服务会按所选间隔轮询最新版本。`,check_interval:`检查间隔`,interval_3600:`1 小时`,interval_21600:`6 小时`,interval_43200:`12 小时`,interval_86400:`24 小时`,confirm_update_title:`确认更新`,confirm_update_message:`更新会安装新版本并重启服务,当前运行中的终端、Agent 会话或 Supervisor 任务可能被中断。`,confirm_update_activity:`检测到 {terminals} 个终端、{sessions} 个会话、{supervisors} 个 Supervisor 任务仍在运行。`,footer_update_available:`检测到新版本 {version}`,footer_installing:`更新中...`,footer_restarting:`正在重启服务...`,footer_failed:`更新失败`,footer_manual_required:`需要手动处理`,footer_view_details:`查看详情`,footer_succeeded:`已更新到 {version}`},help_diagnostics:`帮助与诊断`,autosave_hint:`设置已自动保存`,load_failed:`设置加载失败`,load_failed_unknown:`未收到服务端返回的设置数据`,notifications:`通知`,notifications_channel_hint:`当前 workspace 处于活跃状态时不会通知;切换到其他 workspace 显示页面横幅;窗口不可见时使用系统通知。`,notifications_enabled:`启用完成通知`,notifications_enabled_hint:`当 Agent 会话完成时发送通知`,notification_sound:`通知声音`,notification_sound_hint:`通知触发时播放完成提示音`,notification_status:`通知状态`,notification_status_available:`可用`,notification_status_limited:`受限`,notification_status_limited_hint:`当前移动端浏览器中的系统通知支持不稳定,浏览器权限不代表一定能正常送达。`,notification_status_unsupported:`不支持`,notification_status_unsupported_hint:`当前浏览器环境不支持此通知方式。`,notification_permission:`通知权限`,permission_granted:`已授权`,permission_denied:`已拒绝`,permission_request:`请求授权`,permission_unavailable:`不可用`,permission_limited_hint:`当前移动端浏览器内即使允许通知权限,也可能无法稳定展示系统通知。`,supervisor:{title:`Supervisor`,hint:`配置 Supervisor 评估超时和全局重试策略。重试规则对所有 Supervisor 生效。`,evaluation_timeout:`Supervisor 超时(秒)`,validation_error:`请输入 1 到 {max} 秒之间的整数。`,retry_enabled:`启用 Supervisor 重试`,retry_enabled_hint:`当评估超时或评估器异常时,按全局规则自动重试。`,retry_max_count:`最大重试次数`,retry_max_count_validation_error:`请输入 0 到 {max} 之间的整数。`,retry_delay_sec:`重试间隔(秒)`,retry_delay_validation_error:`请输入 1 到 {max} 秒之间的整数。`,retry_on_timeout:`超时后重试`,retry_on_timeout_hint:`评估超时后按重试次数和间隔自动继续。`,retry_on_evaluator_error:`评估器异常后重试`,retry_on_evaluator_error_hint:`评估器进程或运行时报错时按规则自动重试。`},terminal_renderer:`终端渲染器`,terminal_renderer_hint:`选择终端渲染模式`,lsp_runtime_mode:`LSP 运行模式`,lsp_runtime_mode_hint:`控制代码智能的内存占用。关闭后会立即停止当前语言服务进程,诊断、跳转、hover 等能力将暂时不可用。`,lsp_runtime_mode_auto:`Auto`,lsp_runtime_mode_off:`Off`,appearance_background_material:`背景与材质`,appearance_background_material_hint:`为应用设置账号同步的背景图、毛玻璃和面板透明度,可按桌面端和移动端分别覆盖。`,appearance_background_mode:`背景模式`,appearance_background_mode_off:`关闭`,appearance_background_mode_image:`背景图`,appearance_background_upload:`背景图`,appearance_background_replace:`更换背景图`,appearance_background_remove:`移除背景图`,appearance_background_fit:`背景适配`,appearance_background_fit_cover:`铺满裁切`,appearance_background_fit_contain:`完整显示`,appearance_background_dimness:`背景压暗`,appearance_background_blur:`背景模糊`,appearance_glass_enabled:`启用毛玻璃`,appearance_glass_intensity:`毛玻璃强度`,appearance_surface_opacity:`面板不透明度`,appearance_override_desktop:`桌面端覆盖`,appearance_override_mobile:`移动端覆盖`,appearance_override_enabled:`已启用独立设置`,appearance_uses_shared_value:`当前使用共享设置`,appearance_asset_upload_failed:`背景图上传失败`,appearance_asset_delete_failed:`背景图移除失败`,terminal_appearance:`终端外观`,copy_on_select:`选中自动复制`,copy_on_select_hint:`选中文本后自动复制到系统剪贴板`,terminal_font_size:`终端字号`,terminal_font_size_hint:`分别设置桌面端和移动端终端字号,已打开的终端会立即更新。`,desktop_terminal_font_size:`桌面端终端字号`,desktop_terminal_font_size_hint:`应用于 PC 和其他桌面端终端。`,mobile_terminal_font_size:`移动端终端字号`,mobile_terminal_font_size_hint:`应用于手机和平板等移动端终端。`,terminal_font_size_validation_error:`请输入 {min} 到 {max} 之间的整数。`,copy_on_select_failed_title:`自动复制失败`,copy_on_select_failed_body:`请使用 Ctrl/Cmd+C 手动复制`,terminal_standard:`标准`,terminal_compatibility:`兼容模式`,provider:{title:`Agent 设置`,status:`状态`,capability:`能力等级`,capability_full:`完整支持`,capability_limited:`有限支持`,capability_unsupported:`不支持`,hooks_registered:`Hooks 已注册`,hooks_unregistered:`Hooks 未注册`,hooks_error:`Hooks 注册失败`,hooks:`Hooks 集成`,hooks_hint:`将 Agent 特定的 hooks 注入到当前工作区`,hooks_inject:`注入 Hooks`,configure:`配置`,reset:`重置`,config:`配置`,base:`基础配置`,config_file:`配置文件`,open_config_file_editor:`打开配置文件编辑`,back_to_base:`返回基础配置`,startup_args:`启动命令参数`,startup_args_hint:`每行填写一个启动参数,保存后会追加到 Agent 启动命令后面。`,startup_args_placeholder:`--verbose
|
|
98
|
+
- Reduce P95 latency below 100ms`,objective_helper:`The more specific and measurable the target, the better the evaluation. Include completion criteria when possible.`,evaluator:`Evaluator`,evaluator_helper:`The provider that evaluates progress and suggests the next step. It can differ from the execution provider.`,evaluator_model:`Evaluator Model`,evaluator_model_placeholder:`Optional model override, for example o3 or gpt-5`,evaluator_model_helper:`Leave blank to use the provider's default supervisor evaluation model behavior.`,max_supervision_count:`Max Supervision Count`,max_supervision_count_helper:`Set to 0 for no explicit cap. Evaluation can still stop earlier if the objective is complete.`,scheduled_at_placeholder:`Choose when to run`,scheduled_at:`Scheduled Run Time`,scheduled_at_helper:`Specify when to run the first evaluation. After the scheduled time, evaluations will trigger automatically at the end of each conversation turn. Leave blank to trigger automatically at the end of each turn.`},action:{enable:`Enable Supervisor`,enable_objective:`Enable Objective`,details:`Supervisor Details`,edit_objective:`Edit Supervisor`,pause:`Pause`,resume:`Resume`,trigger:`Trigger Evaluation`,pause_failed:`Failed to pause Supervisor`,resume_failed:`Failed to resume Supervisor`,trigger_failed:`Failed to trigger evaluation`},dialog:{enable:{title:`Enable Supervisor`,subtitle:`Describe an objective and Supervisor will evaluate progress and suggest the next step after each turn.`,confirm:`Enable`},edit:{title:`Edit Supervisor`,subtitle:`Adjust the objective and restore a previous memory snapshot when needed.`,confirm:`Save`,reset_confirm_title:`Save and reset supervisor progress?`,reset_confirm_description:`Changing the objective will make Supervisor re-evaluate the goal. Existing supervisor memory and progress for this target will be reset.`},restore:{open:`Restore from Existing Memory`,hint:`Reuse supervisor memory from an existing target directory for this session.`,title:`Restore Supervisor Memory`,subtitle:`Choose a recoverable memory snapshot and attach it to the current session supervisor.`,back:`Back to Details`,confirm:`Restore`,empty:`No recoverable supervisor memory found.`,empty_hint:`Only target directories with readable supervisor memory can be restored.`,cycle_count:`{count} cycles`,updated_at:`Updated {time}`},details:{title:`Supervisor Details`}}},command:{palette:`Command Palette`,no_results:`No results found`,shortcut:{save:`Save`,save_all:`Save All`,search:`Search`,search_files:`Search Files`,command_palette:`Command Palette`,toggle_focus:`Toggle Focus Mode`,toggle_sidebar:`Toggle Sidebar`,toggle_terminal:`Toggle Terminal Panel`}},notification:{success:`Success`,error:`Error`,warning:`Warning`,info:`Info`,session_turn_completed:`Session turn completed`,file_saved:`File saved`,committed:`Committed`,session_completed_title:`{session} completed`,session_completed_body:`Agent session has finished executing`,session_ended:`Session ended`,session_ended_hint:`The session has stopped running`},error:{unknown:`Unknown error`,network:`Network error`,not_found:`Not found`,permission_denied:`Permission denied`,validation:`Validation failed`,conflict:`Resource conflict`},welcome:{kicker:`LOCAL AI CODING WORKSPACE`,title:`Open a workspace. Start an AI coding session.`,description:`Choose a local project folder to get started. Once the workspace is open, you can launch Claude Code or Codex right where you review files, Git changes, and terminal output.`,workflow_title:`How it works`,step_1_label:`Step 1`,step_1_title:`Open your project folder`,step_1_detail:`Choose a local directory to become your active workspace.`,step_2_label:`Step 2`,step_2_title:`Start Claude or Codex`,step_2_detail:`Inside the workspace, launch an AI session for that project.`,settings_hint:`Need provider setup first?`,support_title:`Why use it here`,features:{git_tools:{title:`Review code and Git side by side`,description:`Inspect files and changes next to the agent instead of switching between tools.`},terminals:{title:`Run commands in the same workspace`,description:`Use integrated terminals alongside your AI session when you need manual control.`}}},diagnostics:{title:`Diagnostics`,settings_hint:`Diagnose the runtime environment to help identify and recover from issues.`,load_failed:`Diagnostics could not be refreshed right now.`,loading_description:`Checking the parts that matter for this task.`,status:{checking:`Checking`,ready:`Ready`,needs_attention:`Needs attention`},actions:{retry_workspace:`Retry Opening Workspace`,continue_session:`Continue Starting Session`,continue_phone:`Continue on Phone`,recheck:`Recheck`,open_diagnostics:`Open Diagnostics`,copy_details:`Copy error details`,copied:`Copied`,install_provider:`Install Provider`},details:{workspace:`Workspace`,provider:`Provider`,missing_commands:`Missing commands`,missing_prerequisites:`Missing prerequisites`,current_version:`Current version`},context:{workspace_open:{title:`We couldn't open your workspace`,description:`A few issues need attention before we can continue.`},session_start:{title:`Your session is not ready to start`,description:`We found a problem that would block session startup.`},mobile_continue:{title:`Phone continuation needs a few fixes`,description:`We checked the phone handoff path and found something to fix first.`},manual_check:{title:`Environment diagnostics`,description:`Review the current environment and refresh anything that looks off.`}},checks:{workspace_selection_missing:{title:`Workspace path needed`,description:`Choose a directory before retrying.`},workspace_path_ready:{title:`Workspace path is ready`,description:`The selected directory is reachable.`},workspace_path_not_found:{title:`Workspace path no longer exists`,description:`The selected directory could not be found.`},workspace_path_unreadable:{title:`Workspace path is not readable`,description:`The selected directory exists but cannot be opened right now.`},session_workspace_ready:{title:`Workspace is ready`,description:`The target workspace is available for session startup.`},session_workspace_missing:{title:`Workspace is missing`,description:`Select or reopen the workspace before starting a session.`},git_ready:{title:`Git is ready`,description:`Git is installed and available in the current environment.`},git_missing:{title:`Git is missing`,description:`Install Git before relying on workspace repository features.`},nodejs_ready:{title:`Node.js is ready`,description:`Node.js is installed and available in the current environment.`},nodejs_missing:{title:`Node.js is missing`,description:`Install Node.js before running local JavaScript and package tasks.`},provider_runtime_ready:{title:`{provider} is ready`,description:`{provider} can be launched from this workspace.`},provider_cli_missing:{title:`{provider} CLI is missing`,description:`The required provider command is not installed yet.`},provider_prerequisite_missing:{title:`{provider} prerequisites are missing`,description:`A prerequisite must be installed before the provider can run.`},provider_unknown:{title:`Provider is unknown`,description:`This provider could not be resolved from current settings.`},server_auth_ready:{title:`Password protection is enabled`,description:`Authentication is configured for this server.`},server_auth_not_required:{title:`Password protection is optional`,description:`Authentication is currently not required.`},mobile_host_ready:{title:`Network host is reachable`,description:`The current host looks suitable for phone continuation.`},mobile_host_local_only:{title:`Host is local-only`,description:`Phone continuation needs a LAN-reachable host instead of localhost.`},mobile_auth_disabled:{title:`Phone continuation needs auth`,description:`Enable authentication before continuing on your phone.`}}},not_found:{kicker:`ROUTE NOT FOUND`,title:`Page not found`,description:`The route you opened does not exist in this workspace shell.`,path_label:`Requested path`,go_home:`Go Home`},confirm:{save_changes:`Save changes?`,discard_changes:`Discard changes?`,delete_file:`Delete this file?`,stop_session:`Stop session?`,close_workspace:`Close workspace?`},placeholder:{search:`Type to search...`,command:`Type a command or shortcut...`,commit_message:`Enter commit message`},tooltip:{focus_mode:`Focus Mode: Hide sidebar and bottom panel`,split_horizontal:`Split panel horizontally`,split_vertical:`Split panel vertically`,close_pane:`Close panel`,new_workspace:`New workspace`,quick_actions:`Quick Actions`,enter_fullscreen:`Enter Fullscreen`,exit_fullscreen:`Exit Fullscreen`,show_terminal:`Show Terminal`,hide_terminal:`Hide Terminal`,show_files:`Show Files`,hide_files:`Hide Files`},time:{just_now:`Just now`,seconds_ago:`{count} seconds ago`,minutes_ago:`{count} minutes ago`,hours_ago:`{count} hours ago`,days_ago:`{count} days ago`},fencing:{observer_mode:`Read-only mode — another tab is the controller`,takeover:`Take over`,takeover_failed:`Takeover failed — controller is still active`}},am={datetime:{today:`今天`,tomorrow:`明天`,next_week:`下周`,prev_month:`上一月`,next_month:`下一月`,clear:`清空`,confirm:`确认`,select_date:`选择日期`,select_time:`选择时间`,hour:`小时`,minute:`分钟`,january:`一月`,february:`二月`,march:`三月`,april:`四月`,may:`五月`,june:`六月`,july:`七月`,august:`八月`,september:`九月`,october:`十月`,november:`十一月`,december:`十二月`,sun:`日`,mon:`一`,tue:`二`,wed:`三`,thu:`四`,fri:`五`,sat:`六`},app:{name:`Coder Studio`,description:`Agent-First Development Environment`},common:{loading:`加载中...`,error:`错误`,success:`成功`,warning:`警告`,info:`信息`,enabled:`已启用`,disabled:`已禁用`,confirm:`确认`,cancel:`取消`,save:`保存`,delete:`删除`,edit:`编辑`,view:`查看`,close:`关闭`,yes:`是`,no:`否`,ok:`确定`,all:`全部`},action:{open:`打开`,open_workspace:`打开工作区`,close_workspace:`关闭工作区`,create_session:`创建会话`,stop_session:`停止会话`,resume_session:`恢复会话`,save_file:`保存`,save_all:`保存全部`,save:`保存`,discard_changes:`放弃更改`,commit:`提交`,push:`推送`,pull:`拉取`,refresh:`刷新`,settings:`设置`,cancel:`取消`,confirm:`确认`,close:`关闭`,apply:`应用`,reset:`重置`,search:`搜索`,search_files:`搜索文件`,search_commands:`搜索命令`,back:`返回`,expand:`展开`,collapse:`收起`,close_all:`全部关闭`},label:{workspace:`工作区`,agent:`Agent`,session:`会话`,terminal:`终端`,file:`文件`,git:`Git`,settings:`设置`,provider:`Provider`,status:`状态`,progress:`进度`},provider:{install:{cta:{start:`启动会话`,install_and_start:`安装并启动`,installing:`安装中...`,manual:`查看安装步骤`},status:{installing:`正在安装 Provider CLI...`,failed:`自动安装失败`},open_docs:`打开官方文档`,nodejs:{manual:`请先从 Node.js 官方下载页安装 Node.js。`},claude:{manual:`然后执行 npm install -g @anthropic-ai/claude-code。`},codex:{manual:`然后执行 npm install -g @openai/codex。`}}},status:{starting:`启动中`,running:`运行中`,idle:`空闲`,busy:`忙碌`,ended:`已结束`,unavailable:`不可用`,connecting:`连接中`,connected:`已连接`,disconnected:`已断开`,reconnecting:`重连中`,rejected:`被拒绝`},workspace:{title:`工作区`,tabs:`工作区标签`,open:`打开`,close:`关闭`,path:`路径`,no_workspace:`未打开工作区`,refresh_partial_title:`工作区刷新未完全成功`,refresh_partial_body:`已完成可刷新的部分,但这些区域失败了:{sections}`,fullscreen:{unsupported_title:`当前无法全屏`,unsupported_body:`当前浏览器不支持全屏功能。`,enter_failed_title:`进入全屏失败`,enter_failed_body:`浏览器拒绝了全屏请求。`,exit_failed_title:`退出全屏失败`,exit_failed_body:`浏览器暂时无法退出全屏。`},open_hint:`点击下方按钮打开一个项目目录`,loading_title:`正在加载工作区`,loading_description:`正在准备工作区列表并恢复上次活跃的会话。`,load_failed_title:`工作区加载失败`,load_failed_description:`获取工作区列表失败`,sidebar:{label:`工作区活动栏`,explorer:`资源管理器`,search:`搜索`,source_control:`源代码管理`,open_editors:`打开的编辑器`,workspace:`工作区`},quick_jump:{title:`快速跳转`,placeholder:`输入文件名或路径`,no_results:`未找到匹配文件。`,failed:`文件搜索失败,请重试。`},open_editors:{title_with_count:`{title} ({count})`,close_path:`关闭 {path}`,expand_label:`展开打开的编辑器`,collapse_label:`收起打开的编辑器`},search:{empty:`输入关键词以搜索文件内容。`,placeholder:`搜索文件内容`,results_count:`在 {files} 个文件中找到 {count} 条结果`,no_results:`未找到内容匹配。`,truncated:`结果已截断,以保持搜索响应速度。`,file_match_count:`{count}{suffix} 条匹配`,failed:`搜索失败,请重试。`,retry:`重试`},launch:{kicker:`启动工作区`,title:`打开工作区`,home_directory:`主目录`,go_up:`返回上一级`,no_directories:`未找到目录`,items_count:`{count} 项`,enter_folder:`进入 {name}`,enter_folder_action:`进入文件夹 →`,cancel:`取消`,start:`启动工作区`,starting:`启动中...`,hint:`选择一个目录作为工作区根目录。`,browse_failed:`浏览目录失败`,select_required:`请选择一个目录`,open_failed:`打开工作区失败`},runtime_check:{title:`运行时检查`,checking:`正在检查运行时环境...`,success:`运行时环境检查通过`,failed:`运行时环境检查失败`,missing_git:`未找到 Git 命令`,missing_node:`未找到 Node.js`,missing_provider:`未找到 {provider} CLI`}},quick_open:{title:`跳转到文件`,placeholder:`输入文件名或路径`,empty:`输入内容以按文件名或路径搜索。`,no_results:`未找到匹配文件。`,failed:`文件搜索失败,请重试。`,command_label:`跳转到文件...`,command_description:`在当前工作区中快速打开文件`},mobile:{dock:{aria_label:`移动底栏`,open_agent:`打开 Agent 面板`,open_files:`打开文件面板`,open_terminal:`打开终端面板`},agent:{title:`Agent 会话`,close_current_session:`关闭当前会话`,providers:`会话提供方`,start_session:`启动 {provider} 会话`,starting:`正在启动…`,start_new_session:`启动新会话`,active_agents:`活跃 Agent`,switch_to_agent:`切换到 Agent {name}`,empty:`暂无活跃会话`},supervisor:{open_sheet:`打开 Supervisor 面板`},topbar:{switch_workspace:`切换工作区`,open_settings:`打开设置`},sheet:{dismiss:`关闭当前面板`,region:`{title}面板`},files:{tabs:`文件面板标签`,git_diff:`Git`,editor_fallback:`编辑器`},workspace_drawer:{aria_label:`工作区抽屉`,close:`关闭工作区抽屉`,select_title:`选择工作区`,switch_to_workspace:`切换到工作区 {name}`,close_workspace:`关闭工作区 {name}`},empty:{start_session:`为当前工作区启动一个新的 Agent 会话。`,files_terminal_hint:`文件和终端可继续通过底部栏访问。`}},session:{title:`会话`,create:`创建会话`,stop:`停止`,resume:`恢复`,no_session:`无活跃会话`,provider_select:`选择 Agent`,state:{starting:`启动中...`,running:`运行中`,idle:`等待指令`,busy:`执行中`,ended:`已停止`,unavailable:`不可用`},resume_unavailable:`此会话无法恢复`,progress:{thinking:`正在思考...`,executing:`正在执行...`,waiting:`等待响应...`}},terminal:{title:`终端`,kicker:`TERMINAL`,new_terminal:`新建终端`,close_terminal:`关闭终端`,shell:`Shell 终端`,agent:`Agent 终端`,reconnect_hint:`连接已断开,正在重连...`,no_terminal:`暂无终端`,empty_hint:`启动一个 Shell 来查看文件、运行命令,并在不离开工作区的情况下验证更改。`,load_failed_title:`加载终端失败`,load_failed_body:`请刷新工作区连接后重试。`,create_failed_title:`创建终端失败`,create_failed_body:`Shell 进程启动失败,请检查服务端运行环境和 Shell 配置。`,create_unavailable_title:`当前没有已选中的工作区`,create_unavailable_body:`请先打开或切换到一个工作区,再新建终端。`,copied_current_line:`已复制当前行`,mobile_copy_current_line_failed_title:`当前行复制失败`,mobile_copy_current_line_failed_body:`请重试长按当前行`,paste_dialog_title:`粘贴文本`,paste_dialog_placeholder:`在此粘贴您的文本...`,paste_dialog_submit:`发送`,hide:`隐藏终端`,show:`显示终端`,selector:{switch:`切换终端`,title:`终端会话`,current:`当前终端`,indexed:`终端 {index}`},mobile_input:{paste:`粘贴`,upload:`上传`,shortcuts:`终端快捷按键`,ctrl:`Ctrl`,ctrl_armed:`Ctrl 已待命`,ctrl_locked:`Ctrl 已锁定`,shift:`Shift`,shift_armed:`Shift 已待命`,escape:`Esc`,tab:`Tab`,enter:`Enter`,up:`上方向键`,down:`下方向键`,left:`左方向键`,right:`右方向键`},replay:{queued_title:`等待队列中(前方还有 {count} 个)`,up_next:`即将开始…`,loading_title:`正在恢复终端内容…`,loading_body:`恢复期间暂时无法使用当前终端;请耐心等待,历史内容恢复完成后再继续。内容较多时可能需要更久。`,failed_title:`终端历史暂未恢复`,failed_body:`当前终端可以继续使用,但较早输出这次仍未补齐。请稍后或刷新页面后再看;如果服务端仍保留历史,后续仍可能找回。`,reconcile_failed_title:`终端恢复检查未完成`,reconcile_failed_body:`这次没有完成恢复决策,当前终端仍可继续使用,但较早历史是否补齐暂时无法确认。请稍后重新检查。`,recheck_action:`重新检查`,retryable_title:`终端历史暂未恢复`,retryable_body:`当前终端可以继续使用,但较早输出这次没有补齐。你可以重试恢复;如果服务端仍保留历史,稍后或刷新页面后仍可能找回。`,retry_action:`重试恢复`,unrecoverable_title:`较早历史已无法恢复`,unrecoverable_body:`较早的终端输出已经从回放缓冲区中淘汰,而且当前也没有可用快照。现在只能继续查看后续输出。`,unknown_title:`当前终端已不可恢复`,unknown_body:`这个终端会话已经不在服务端,历史输出无法再补回。请重新打开一个新终端继续。`,unknown_body_with_provider:`这个终端会话已经不在服务端。是否重新打开一个 {provider} 会话继续?`,closed_title:`当前会话已结束`,closed_body:`是否重新打开一个新会话继续。`,closed_body_with_provider:`是否重新打开一个 {provider} 会话继续。`}},file:{title:`文件`,modified:`已修改`,unsaved:`未保存`,dirty:`有未保存更改`,visible_count:`{count} 个文件`,empty_directory:`空文件夹`,new_file:`新建文件`,new_folder:`新建文件夹`,collapse_all:`折叠全部`,rename:`重命名`,rename_name:`名称`,rename_helper:`当前版本仅支持在同级目录内重命名。`,rename_required:`请输入名称`,rename_invalid_name:`名称不能包含 / 或 \\。`,rename_failed:`重命名失败`,delete:`删除`,delete_confirm:`确定要删除 "{name}" 吗?`,copy_relative_path:`复制相对路径`,copy_absolute_path:`复制绝对路径`,open_in_terminal:`在终端中打开`,context_menu_title:`文件操作`,context_section_create:`创建`,context_section_edit:`编辑`,context_section_path:`路径`,context_section_terminal:`终端`,path:`路径`,path_required:`请输入路径`,invalid_file_path:`文件路径不能以 / 结尾`,path_helper_file:`输入工作区内的相对路径,例如 src/demo/new-file.ts`,path_helper_folder:`输入工作区内的相对路径,例如 src/demo/new-folder`,create_failed:`创建失败`,delete_failed:`删除失败`,conflict:`文件已被外部程序修改`,conflict_message:`文件可能已被编辑器外部修改。要放弃本地更改并重新加载吗?`},code_editor:{saving:`保存中...`,edit_as_text:`以文本编辑`,preview_as_image:`以图像预览`,preview_loading:`正在加载预览...`,preview_unavailable:`预览不可用`,preview_retry:`重试`,mode_text:`文本`,mode_image:`图像`,mode_preview:`预览`,mode_edit:`编辑`,mode_diff:`Diff`,diff_saved_only:`Diff 仅基于已保存到磁盘的文件内容。`,open_failed_title:`打开文件失败`,empty_hint:`从左侧选择一个文件以在编辑器中打开。`,modified_on_disk:`该文件在打开后已被磁盘上的其他操作修改。请谨慎保存或重新加载文件。`,deleted_on_disk:`该文件在打开后已被磁盘上的其他操作删除。`},git:{title:`Git`,changes:`更改`,staged:`已暂存`,modified:`已修改`,deleted:`已删除`,unstaged:`未暂存`,untracked:`未跟踪`,no_changes:`无更改`,commit:`提交`,commit_message:`提交信息`,commit_placeholder:`输入提交信息...`,commit_summary_placeholder:`输入提交信息...`,commit_staged_count:`已暂存 {count}`,nothing_staged:`没有可提交的已暂存更改`,latest_commit:`最新提交`,history:`历史`,show_all_history:`查看全部`,change_count:`{count} 处更改`,no_commits:`暂无提交`,stage:`暂存`,unstage:`取消暂存`,stage_all:`暂存全部`,unstage_all:`取消暂存全部`,stage_failed_title:`暂存失败`,unstage_failed_title:`取消暂存失败`,discard:`放弃`,discard_all:`放弃全部`,discard_failed_title:`放弃失败`,discard_file_confirm_title:`放弃文件更改`,discard_file_confirm_message:`确定要放弃 “{path}” 的更改吗?`,discard_all_confirm_title:`放弃所有更改`,discard_all_confirm_message:`确定要放弃 {count} 个文件的更改吗?`,discard_confirm_irreversible:`此操作不可恢复。`,commit_failed_title:`提交失败`,branch:`分支`,switch_branch:`切换分支`,current_branch:`当前分支`,no_branch:`不在任何分支上`,ahead:`领先 {count} 个提交`,behind:`落后 {count} 个提交`,synced:`与远程同步`,push_confirm_title:`推送更改`,push_confirm_message:`是否将 {count} 个本地提交推送到远端?`,pull_confirm_title:`拉取更改`,pull_confirm_message:`是否从远端拉取 {count} 个最新提交到本地?`,sync_confirm_helper:`该操作会更新当前分支和工作区状态。`,push_success_title:`推送完成`,push_success_body:`本地提交已推送到远端。`,push_success_target:`已推送到 {target}`,pull_success_title:`拉取完成`,pull_success_body:`已拉取远端最新提交到当前分支。`,pull_success_target:`已从 {target} 拉取更新`,sync_up_to_date:`{target} 已是最新`,push_in_progress:`推送中...`,pull_in_progress:`拉取中...`,push_failed_title:`推送失败`,pull_failed_title:`拉取失败`,fetch_success_title:`已从远端获取`,fetch_success_body:`远端跟踪分支已更新。`,fetch_failed_title:`获取失败`,fetch_refresh_failed_body:`已从远端获取,但刷新本地 Git 状态失败。`,fetch_in_progress:`获取中...`,fetch_label:`获取`,fetch_last_at:`上次获取于 {when}`,fetch_last_never:`尚未获取`,operation_push:`推送`,operation_pull:`拉取`,operation_fetch:`获取`,auth_required_message:`{remote} 需要认证。`,auth_failed_invalid:`{remote} 的凭证被拒绝,请输入有效的用户名和密码或个人访问令牌后重试。`,auth_failed_forbidden:`{remote} 已接受当前凭证,但该账号没有执行 {operation} 的权限。`,auth_failed_unsupported:`{remote} 认证失败。请先配置 SSH key 或 credential helper,再重试。`,auth_helper_http:`请输入 Git 用户名和密码,或个人访问令牌后重试。`,auth_helper_unsupported:`当前远端不支持应用内认证。请先配置 SSH key 或 credential helper,再重试。`,auth_username:`用户名`,auth_password:`密码或令牌`,auth_username_placeholder:`Git 用户名`,auth_password_placeholder:`密码或个人访问令牌`,branch_remote:`远程`,quick_pick:{search_placeholder:`搜索分支或创建新分支...`,loading:`正在加载分支...`,empty_filtered:`未找到分支`,empty_idle:`输入以搜索分支`,in_use:`占用中`,worktree_in_use:`已在其他工作区中签出`,checkout_failed_title:`切换分支失败`,checkout_failed_body:`无法切换到 {name}。`,create_failed_title:`创建分支失败`,create_failed_body:`无法创建 {name}。`,create_label:`创建分支`,confirm_create_label:`确认创建分支`,create:`创建分支:{name}`,confirm_create:`确认创建分支:{name}`},statusbar:{changes:`未提交的文件变更`,ahead:`待推送的本地提交`,behind:`远端有新提交待拉取`}},worktree:{title:`工作树`,status_tab:`状态`,diff_tab:`差异`,tree_tab:`树`,path:`路径`,branch:`分支`,changes:`更改`,loading:`加载中...`,empty_tree:`空目录树`,clean:`干净`,dirty:`有更改`,dirty_status:`有更改`,staged_count:`已暂存:{count}`,modified_count:`已修改:{count}`,untracked_count:`未跟踪:{count}`,list_title:`工作树列表`,list_empty:`暂无工作树`,list_open_label:`查看工作树`,list_error:`加载失败:{error}`,manage:`管理`,new:`新建`,current:`当前`,summary_total:`{count} 个工作树`,summary_dirty:`{count} 个有更改`,summary_current:`当前:{name}`,summary_no_current:`当前:不可用`,create_title:`新建工作树`,create_submit:`创建`,create_path_hint:`路径必须是绝对路径。默认建议路径会基于当前工作区路径生成。`,create_path_absolute_required:`路径必须是绝对路径。`,create_failed_title:`创建工作树失败`,create_success_title:`工作树已创建`,create_success_body:`{name} 已可用。`,remove_confirm:`确认删除这个工作树?`,remove_force_confirm:`强制删除有更改的工作树?`,remove_failed_title:`删除工作树失败`,remove_success_title:`工作树已删除`,remove_success_body:`工作树已删除。`,force_remove:`强制删除`,remove_row_label:`删除 {name}`,selection_removed:`所选工作树已不可用。`},settings:{title:`设置`,general:`通用`,appearance:`外观`,providers:`Agents`,mobile_groups:{workspace_runtime:`工作区与运行`,interface_interaction:`界面与交互`},about:{title:`关于`,description:`查看当前应用信息、版本状态以及更新能力。`,product_name:`产品名称`,current_version:`当前版本`,server_instance_id:`服务实例 ID`,install_support:`安装支持`,install_supported:`支持应用内更新`,install_unsupported:`当前安装方式不支持应用内更新`,update_group:`更新`,update_group_hint:`手动检查新版本,并在支持的安装方式下启动更新。`,latest_version:`最新版本`,last_checked:`上次检查`,availability:`版本状态`,availability_unknown:`尚未检查`,availability_up_to_date:`已是最新版本`,availability_update_available:`发现新版本`,availability_check_failed:`检查失败`,update_status:`更新流程`,update_status_unknown:`未知`,update_status_idle:`空闲`,update_status_checking:`检查中`,update_status_installing:`安装中`,update_status_restarting:`重启服务中`,update_status_succeeded:`更新成功`,update_status_failed:`更新失败`,update_status_manual_required:`需要手动处理`,error_summary:`错误摘要`,manual_command:`手动命令`,check_now:`立即检查`,checking:`检查中`,check_failed:`检查更新失败`,update_now:`立即更新`,installing:`处理中`,auto_check_group:`自动检查`,auto_check_group_hint:`配置后台轮询 npm 的节奏。相关偏好会持久化到设置文件。`,auto_check_enabled:`自动检查更新`,auto_check_enabled_hint:`开启后,服务会按所选间隔轮询最新版本。`,check_interval:`检查间隔`,interval_3600:`1 小时`,interval_21600:`6 小时`,interval_43200:`12 小时`,interval_86400:`24 小时`,confirm_update_title:`确认更新`,confirm_update_message:`更新会安装新版本并重启服务,当前运行中的终端、Agent 会话或 Supervisor 任务可能被中断。`,confirm_update_activity:`检测到 {terminals} 个终端、{sessions} 个会话、{supervisors} 个 Supervisor 任务仍在运行。`,footer_update_available:`检测到新版本 {version}`,footer_installing:`更新中...`,footer_restarting:`正在重启服务...`,footer_failed:`更新失败`,footer_manual_required:`需要手动处理`,footer_view_details:`查看详情`,footer_succeeded:`已更新到 {version}`},help_diagnostics:`帮助与诊断`,autosave_hint:`设置已自动保存`,load_failed:`设置加载失败`,load_failed_unknown:`未收到服务端返回的设置数据`,notifications:`通知`,notifications_channel_hint:`当前 workspace 处于活跃状态时不会通知;切换到其他 workspace 显示页面横幅;窗口不可见时使用系统通知。`,notifications_enabled:`启用完成通知`,notifications_enabled_hint:`当 Agent 会话完成时发送通知`,notification_sound:`通知声音`,notification_sound_hint:`通知触发时播放完成提示音`,notification_status:`通知状态`,notification_status_available:`可用`,notification_status_limited:`受限`,notification_status_limited_hint:`当前移动端浏览器中的系统通知支持不稳定,浏览器权限不代表一定能正常送达。`,notification_status_unsupported:`不支持`,notification_status_unsupported_hint:`当前浏览器环境不支持此通知方式。`,notification_permission:`通知权限`,permission_granted:`已授权`,permission_denied:`已拒绝`,permission_request:`请求授权`,permission_unavailable:`不可用`,permission_limited_hint:`当前移动端浏览器内即使允许通知权限,也可能无法稳定展示系统通知。`,supervisor:{title:`Supervisor`,hint:`配置 Supervisor 评估超时和全局重试策略。重试规则对所有 Supervisor 生效。`,evaluation_timeout:`Supervisor 超时(秒)`,validation_error:`请输入 1 到 {max} 秒之间的整数。`,retry_enabled:`启用 Supervisor 重试`,retry_enabled_hint:`当评估超时或评估器异常时,按全局规则自动重试。`,retry_max_count:`最大重试次数`,retry_max_count_validation_error:`请输入 0 到 {max} 之间的整数。`,retry_delay_sec:`重试间隔(秒)`,retry_delay_validation_error:`请输入 1 到 {max} 秒之间的整数。`,retry_on_timeout:`超时后重试`,retry_on_timeout_hint:`评估超时后按重试次数和间隔自动继续。`,retry_on_evaluator_error:`评估器异常后重试`,retry_on_evaluator_error_hint:`评估器进程或运行时报错时按规则自动重试。`},terminal_renderer:`终端渲染器`,terminal_renderer_hint:`选择终端渲染模式`,lsp_runtime_mode:`LSP 运行模式`,lsp_runtime_mode_hint:`控制代码智能的内存占用。关闭后会立即停止当前语言服务进程,诊断、跳转、hover 等能力将暂时不可用。`,lsp_runtime_mode_auto:`Auto`,lsp_runtime_mode_off:`Off`,appearance_background_material:`背景与材质`,appearance_background_material_hint:`为应用设置账号同步的背景图、毛玻璃和面板透明度,可按桌面端和移动端分别覆盖。`,appearance_background_mode:`背景模式`,appearance_background_mode_off:`关闭`,appearance_background_mode_image:`背景图`,appearance_background_upload:`背景图`,appearance_background_replace:`更换背景图`,appearance_background_remove:`移除背景图`,appearance_background_fit:`背景适配`,appearance_background_fit_cover:`铺满裁切`,appearance_background_fit_contain:`完整显示`,appearance_background_dimness:`背景压暗`,appearance_background_blur:`背景模糊`,appearance_glass_enabled:`启用毛玻璃`,appearance_glass_intensity:`毛玻璃强度`,appearance_surface_opacity:`面板不透明度`,appearance_override_desktop:`桌面端覆盖`,appearance_override_mobile:`移动端覆盖`,appearance_override_enabled:`已启用独立设置`,appearance_uses_shared_value:`当前使用共享设置`,appearance_asset_upload_failed:`背景图上传失败`,appearance_asset_delete_failed:`背景图移除失败`,terminal_appearance:`终端外观`,copy_on_select:`选中自动复制`,copy_on_select_hint:`选中文本后自动复制到系统剪贴板`,terminal_font_size:`终端字号`,terminal_font_size_hint:`分别设置桌面端和移动端终端字号,已打开的终端会立即更新。`,desktop_terminal_font_size:`桌面端终端字号`,desktop_terminal_font_size_hint:`应用于 PC 和其他桌面端终端。`,mobile_terminal_font_size:`移动端终端字号`,mobile_terminal_font_size_hint:`应用于手机和平板等移动端终端。`,terminal_font_size_validation_error:`请输入 {min} 到 {max} 之间的整数。`,copy_on_select_failed_title:`自动复制失败`,copy_on_select_failed_body:`请使用 Ctrl/Cmd+C 手动复制`,terminal_standard:`标准`,terminal_compatibility:`兼容模式`,provider:{title:`Agent 设置`,status:`状态`,capability:`能力等级`,capability_full:`完整支持`,capability_limited:`有限支持`,capability_unsupported:`不支持`,hooks_registered:`Hooks 已注册`,hooks_unregistered:`Hooks 未注册`,hooks_error:`Hooks 注册失败`,hooks:`Hooks 集成`,hooks_hint:`将 Agent 特定的 hooks 注入到当前工作区`,hooks_inject:`注入 Hooks`,configure:`配置`,reset:`重置`,config:`配置`,base:`基础配置`,config_file:`配置文件`,open_config_file_editor:`打开配置文件编辑`,back_to_base:`返回基础配置`,startup_args:`启动命令参数`,startup_args_hint:`每行填写一个启动参数,保存后会追加到 Agent 启动命令后面。`,startup_args_placeholder:`--verbose
|
|
99
99
|
--debug`,command_preview_title:`命令预览`,command_preview_hint:`预览当前 Agent 最终生效的启动命令`},theme:{title:`主题`,dark:`深色`,light:`浅色`,system:`跟随系统`,hint:`选择应用主题`,family:`主题系列`,variant:`明暗模式`,family_mint:`Mint`,family_graphite:`Graphite`,family_nord:`Nord`,family_hc:`高对比`,mint_dark:`Mint 深色`,mint_light:`Mint 浅色`,graphite_dark:`Graphite 深色`,graphite_light:`Graphite 浅色`,nord_dark:`Nord 深色`,nord_light:`Nord 浅色`,hc_dark:`高对比深色`,hc_light:`高对比浅色`,variant_dark:`深色`,variant_light:`浅色`},language:{title:`语言`,zh:`中文`,en:`English`,hint:`选择界面语言`},auth:{title:`认证`,password:`密码`,password_set:`设置密码`,password_change:`修改密码`,password_remove:`移除密码`},shortcuts:{title:`快捷键`,hint:`查看并调整常用键盘操作`,reset_all:`重置全部`,capture_hint:`按下新的快捷键组合`,reset_hint:`重置为默认`},config_files:{title:`配置文件`,codex_config:`Codex 配置`,claude_config:`Claude 配置`,path_label:`路径`,unsaved_changes:`未保存的更改`,saving:`保存中...`,save_success:`配置保存成功`,save_success_with_backup:`已更新 {configPath},并创建备份 {backupPath}`,backup_created:`备份已保存到 {path}`,save_failed:`配置保存失败`,load_failed:`配置加载失败`,file_not_found:`配置文件不存在,编辑并保存以创建。`,status_saved:`已保存`,collapse:`折叠`,format:`格式化`,format_hint:`格式化 JSON 代码`,file_not_found_hint:`编辑并保存以创建配置文件。`},permission_denied_hint:`浏览器或系统通知权限可能已阻止,请检查站点设置和设备通知设置`,permission_unavailable_hint:`当前环境无法请求浏览器通知权限`},auth:{description:`输入密码后继续进入当前工作区。`,hint:`请输入当前部署配置的访问密码。`,blocked_until:`尝试次数过多,请于 {time} 后再试,或联系管理员解禁。`,blocked_generic:`尝试次数过多,请稍后再试,或联系管理员解禁。`,status_title:`访问验证`,status_loading:`正在检查当前部署的访问状态。`,status_unavailable:`暂时无法连接鉴权服务,请稍后重试。`,status_not_configured:`当前部署未配置鉴权。`,session_gate_title:`SESSION GATE`,session_gate_description:`当前标签页已被其他标签页接管,需要重新进入才能继续操作。`,session_gate_detail:`已断开当前标签页连接,恢复后会重新同步最新数据。`,session_gate_reenter:`重新进入`,session_gate_reentering:`进入中`},connection:{title:`连接`,status:`状态`,reconnecting:`正在重新连接...`,reconnect_failed:`重连失败`,another_tab:`另一个标签页已激活`,takeover:`接管控制权`,server_shutdown:`服务器已关闭`,backpressure_warning:`网络拥堵,部分输出可能丢失`},supervisor:{title:`Supervisor`,empty:`Supervisor 未启用`,completed_cycles:`轮次 {count}`,latest_evaluation:`最近一次评估`,state:{inactive:`未启用`,idle:`空闲`,evaluating:`评估中`,injecting:`注入中`,paused:`已暂停`,error:`错误`,stopped:`已停止`},trigger:{manual:`手动`,auto:`自动`,scheduled:`定时`},cycle:{no_guidance:`本轮无需注入 guidance`,evaluating:`评估中…`,waiting:`等待评估结果`,waiting_evaluator:`等待 evaluator 响应`,retry_wait:`{seconds}s 后重试 evaluator`,injecting:`正在注入 guidance`,cancelled:`已取消`},stop_reason:{objective_complete:`目标已达成,Supervisor 已自动停止。`,max_supervision_count_reached:`已达到配置的最大监督次数。`,supervisor_uncertain:`Supervisor 暂时无法判断下一步,已停止自动监督。`},target_memory:{title:`目标记忆`,target:`目标`,stalled:`停滞`,decomposition_ready:`拆解已就绪`,decomposition_pending:`拆解待生成`,decomposition_mode_title:`模式`,decomposition_title:`拆解结构`,basic_info_title:`基本信息`,runtime_title:`运行状态`,runtime_status_label:`状态`,error_reason_label:`异常原因`,cycles_title:`轮次`,progress_list_title:`进展列表`,item_objective_title:`阶段目标`,item_deliverable_title:`交付产物`,active_item:`当前项`,progress_title:`目标进展`,progress_badge:`进展`,reasoning_title:`目标轮次判断`,runtime_status:{idle:`空闲`,running:`运行中`,error:`异常`},decomposition_mode:{stage:`阶段`,subtarget:`子目标`},cycle_result:{continue:`继续`,stop:`停止`,error:`错误`},step_status:{pending:`未开始`,in_progress:`进行中`,done:`已完成`}},meta:{title:`执行策略`,no_cap:`不设上限`},field:{objective:`目标描述`,current_objective:`当前目标`,objective_placeholder:`描述希望 Supervisor 盯住的目标,例如:
|
|
100
100
|
- 完成用户认证功能的实现
|
|
101
101
|
- 修复所有失败的单元测试
|
|
102
|
-
- 把 P95 响应时间压到 100ms 以内`,objective_helper:`越具体、越可衡量,评估效果越好。建议包含完成条件。`,evaluator:`评估方`,evaluator_helper:`用于评估进度并生成下一步指引的 provider,与执行方可不相同。`,evaluator_model:`评估模型`,evaluator_model_placeholder:`可选模型覆盖,例如 o3 或 gpt-5`,evaluator_model_helper:`留空则沿用该 provider 当前默认的 supervisor 评估模型逻辑。`,max_supervision_count:`最大监督次数`,max_supervision_count_helper:`填 0 表示不设上限。若目标已达成,评估仍可提前停止。`,scheduled_at_placeholder:`选择执行时间`,scheduled_at:`定时执行时间`,scheduled_at_helper:`指定首次执行时间。到达后开始执行评估,之后每轮对话结束自动触发。留空则每轮对话结束自动触发评估。`},action:{enable:`启用 Supervisor`,enable_objective:`启用目标`,details:`Supervisor 详情`,edit_objective:`编辑 Supervisor`,pause:`暂停`,resume:`恢复`,trigger:`触发评估`,pause_failed:`暂停失败`,resume_failed:`恢复失败`,trigger_failed:`触发评估失败`},dialog:{enable:{title:`启用 Supervisor`,subtitle:`描述一个目标,Supervisor 会在每轮结束后自动评估并提示下一步`,confirm:`启用`},edit:{title:`编辑 Supervisor`,subtitle:`调整目标描述,并在需要时恢复之前的记忆快照`,confirm:`保存`,reset_confirm_title:`确认保存并重置当前 Supervisor 进度?`,reset_confirm_description:`修改目标描述后,Supervisor 会重新评估目标。当前 target 的既有 supervisor 记忆和进度会被重置。`},restore:{open:`从已有记忆恢复`,hint:`复用现有 target 目录里的 supervisor 记忆到当前会话。`,title:`恢复 Supervisor 记忆`,subtitle:`选择一个可恢复的记忆快照,并将其关联到当前会话的 supervisor。`,back:`返回详情`,confirm:`恢复`,empty:`没有找到可恢复的 supervisor 记忆。`,empty_hint:`只有仍然可读的 target 目录记忆才会出现在这里。`,cycle_count:`{count} 次评估`,updated_at:`更新于 {time}`},details:{title:`Supervisor 详情`}}},command:{palette:`命令面板`,no_results:`未找到结果`,shortcut:{save:`保存`,save_all:`保存全部`,search:`搜索`,search_files:`搜索文件`,command_palette:`命令面板`,toggle_focus:`切换专注模式`,toggle_sidebar:`切换侧边栏`,toggle_terminal:`切换终端面板`}},notification:{success:`成功`,error:`错误`,warning:`警告`,info:`信息`,session_turn_completed:`会话回合完成`,file_saved:`文件已保存`,committed:`已提交`,session_completed_title:`{session} 已完成`,session_completed_body:`Agent 会话已完成执行`,session_ended:`会话已结束`,session_ended_hint:`会话已停止运行`},error:{unknown:`未知错误`,network:`网络错误`,not_found:`未找到`,permission_denied:`权限不足`,validation:`数据验证失败`,conflict:`资源冲突`},welcome:{kicker:`一次部署,随处编码`,title:`欢迎使用 Coder Studio`,description:`只需部署一次编码工作区,即可在任何地方继续工作。同一个工作区,同一个上下文,跨所有设备。`,features:{agent_first:{title:`以 Agent 为核心的 AI 编码`,description:`启动能够编写、测试和部署代码的 AI 会话。`},git_tools:{title:`内置 Git 工具`,description:`无需离开 IDE,就能暂存、提交并管理分支。`},terminals:{title:`集成终端`,description:`在 AI 会话旁边直接运行命令和脚本。`}}},diagnostics:{title:`诊断`,settings_hint:`诊断运行环境,便于排查和恢复问题。`,load_failed:`当前无法刷新诊断结果。`,loading_description:`正在检查这次任务真正相关的环境项。`,status:{checking:`检查中`,ready:`已就绪`,needs_attention:`需要处理`},actions:{retry_workspace:`重试打开工作区`,continue_session:`继续启动会话`,continue_phone:`继续在手机上打开`,recheck:`重新检查`,open_diagnostics:`打开诊断`,copy_details:`复制错误详情`,copied:`已复制`,install_provider:`安装 Provider`},details:{workspace:`工作区`,provider:`Provider`,missing_commands:`缺失命令`,missing_prerequisites:`缺失前置依赖`,current_version:`当前版本`},context:{workspace_open:{title:`暂时无法打开工作区`,description:`继续之前,需要先处理几个问题。`},session_start:{title:`当前会话还不能启动`,description:`我们发现了一个会阻塞启动的问题。`},mobile_continue:{title:`继续到手机前还需修复几项`,description:`手机继续使用这条链路里还有一些前置问题。`},manual_check:{title:`环境诊断`,description:`查看当前环境状态,并在需要时重新检查。`}},checks:{workspace_selection_missing:{title:`还没有选择工作区路径`,description:`先选择一个目录,再继续重试。`},workspace_path_ready:{title:`工作区路径可用`,description:`所选目录当前可以访问。`},workspace_path_not_found:{title:`工作区路径不存在`,description:`之前选择的目录当前已经找不到了。`},workspace_path_unreadable:{title:`工作区路径暂时不可读`,description:`目录存在,但当前还不能正常打开。`},session_workspace_ready:{title:`工作区已就绪`,description:`当前工作区可以用于启动会话。`},session_workspace_missing:{title:`工作区缺失`,description:`先选择或重新打开工作区,再启动会话。`},git_ready:{title:`Git 已就绪`,description:`当前环境已安装 Git,且可以正常使用。`},git_missing:{title:`Git 缺失`,description:`使用工作区仓库相关能力前,需要先安装 Git。`},nodejs_ready:{title:`Node.js 已就绪`,description:`当前环境已安装 Node.js,且可以正常使用。`},nodejs_missing:{title:`Node.js 缺失`,description:`运行本地 JavaScript 和包管理任务前,需要先安装 Node.js。`},provider_runtime_ready:{title:`{provider} 已就绪`,description:`{provider} 现在可以直接启动。`},provider_cli_missing:{title:`{provider} CLI 缺失`,description:`启动前还没有安装所需的 provider 命令。`},provider_prerequisite_missing:{title:`{provider} 前置依赖缺失`,description:`需要先补齐前置依赖,provider 才能运行。`},provider_unknown:{title:`无法识别 Provider`,description:`当前设置里无法解析这个 provider。`},server_auth_ready:{title:`密码保护已开启`,description:`当前服务端已经配置认证。`},server_auth_not_required:{title:`密码保护未开启`,description:`当前服务端没有要求认证。`},mobile_host_ready:{title:`网络地址可用于手机继续`,description:`当前 host 看起来适合手机访问。`},mobile_host_local_only:{title:`当前 host 仅限本机`,description:`手机继续需要可在局域网访问的地址,而不是 localhost。`},mobile_auth_disabled:{title:`手机继续前需要认证`,description:`请先开启认证,再继续到手机。`}}},not_found:{kicker:`路由不存在`,title:`页面不存在`,description:`你访问的路径不在当前工作台的前端路由中。`,path_label:`请求路径`,go_home:`返回首页`},confirm:{save_changes:`是否保存更改?`,discard_changes:`确定要放弃更改吗?`,delete_file:`确定要删除此文件吗?`,stop_session:`确定要停止会话吗?`,close_workspace:`确定要关闭工作区吗?`},placeholder:{search:`输入关键词搜索...`,command:`输入命令名称或快捷键...`,commit_message:`输入提交信息`},tooltip:{focus_mode:`专注模式:隐藏侧边栏和底部面板`,split_horizontal:`水平分割面板`,split_vertical:`垂直分割面板`,close_pane:`关闭面板`,new_workspace:`新建工作区`,quick_actions:`快捷操作`,enter_fullscreen:`进入全屏`,exit_fullscreen:`退出全屏`,show_terminal:`显示终端`,hide_terminal:`隐藏终端`,show_files:`显示文件`,hide_files:`隐藏文件`},time:{just_now:`刚刚`,seconds_ago:`{count} 秒前`,minutes_ago:`{count} 分钟前`,hours_ago:`{count} 小时前`,days_ago:`{count} 天前`},fencing:{observer_mode:`只读模式 — 另一个标签页正在控制`,takeover:`接管控制`,takeover_failed:`接管失败 — 控制器仍然活跃`}},om={zh:{name:`中文`,data:am},en:{name:`English`,data:im}};function sm(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return typeof r==`string`?r:void 0}function cm(e){let t=om[e]?.data??am;function n(e,n){let r=sm(t,e);if(r===void 0)return console.warn(`Translation missing for key: ${e}`),e;if(n)for(let[e,t]of Object.entries(n))r=r.replace(RegExp(`\\{${e}\\}`,`g`),String(t));return r}return n}var lm=V(e=>cm(e(Za)));function um(e,t){let n=Date.now()-e,r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24),s=new Intl.RelativeTimeFormat(t===`zh`?`zh-CN`:`en-US`,{numeric:`auto`});return o>0?s.format(-o,`day`):a>0?s.format(-a,`hour`):i>0?s.format(-i,`minute`):s.format(-r,`second`)}function dm(e,t,n){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,...n}).format(e)}function Z(){return U(lm)}function fm({title:e,body:t,onClose:n,kicker:r,onBack:i,footer:a,headerAction:o,bodyClassName:s,contentClassName:c,fullscreen:l=!1,backLabel:u}){let d=Z(),f=i??n,p=u??d(`action.back`);return(0,X.jsxs)(`div`,{className:`mobile-sheet-layer`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet-layer__backdrop`,"aria-label":d(`mobile.sheet.dismiss`),onClick:n}),(0,X.jsxs)(`section`,{className:Y(`mobile-sheet`,l?`mobile-sheet--fullscreen`:null,c),"aria-label":d(`mobile.sheet.region`,{title:e}),role:`region`,children:[l?null:(0,X.jsx)(`div`,{className:`mobile-sheet__handle`,"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`mobile-sheet__header`,children:(0,X.jsx)(rm,{title:e,kicker:r,onBack:f,backLabel:p,rightSlot:o,titleAs:`h2`})}),(0,X.jsx)(`div`,{className:Y(`mobile-sheet__body`,s),children:t}),a?(0,X.jsx)(`div`,{className:`mobile-sheet__footer`,children:a}):null]})]})}var pm={badge:`_badge_1yvj5_1`};function mm({className:e,count:t,max:n=99,...r}){if(t<=0)return null;let i=t>n?`${n}+`:String(t);return(0,X.jsx)(`span`,{...r,className:Y(pm.badge,`topbar-unread`,e),children:i})}var hm={btn:`_btn_ovn01_1`,primary:`_primary_ovn01_36`,secondary:`_secondary_ovn01_47`,ghost:`_ghost_ovn01_62`,danger:`_danger_ovn01_75`,sm:`_sm_ovn01_81`,lg:`_lg_ovn01_91`,label:`_label_ovn01_98`,icon:`_icon_ovn01_103`,loading:`_loading_ovn01_108`,spinner:`_spinner_ovn01_112`},gm={primary:hm.primary??``,secondary:hm.secondary??``,ghost:hm.ghost??``,danger:hm.danger??``},_m={sm:hm.sm,md:void 0,lg:hm.lg},vm={primary:`btn-primary`,secondary:`btn-secondary`,ghost:`btn-ghost`,danger:`btn-danger`},ym={sm:`btn-sm`,md:void 0,lg:`btn-lg`},bm=({children:e,leadingIcon:t,loading:n,trailingIcon:r})=>(0,X.jsxs)(X.Fragment,{children:[n?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Y(hm.spinner,`animate-spin`)}):null,t?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:hm.icon,children:t}):null,(0,X.jsx)(`span`,{className:hm.label,children:e}),r?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:hm.icon,children:r}):null]}),Q=e=>{let{as:t=`button`,children:n,className:r,variant:i=`secondary`,size:a=`md`,loading:o=!1,leadingIcon:s,trailingIcon:c}=e,l=Y(hm.btn,gm[i],_m[a],`btn`,vm[i],ym[a],o?hm.loading:void 0,r),u=(0,X.jsx)(bm,{children:n,leadingIcon:s,loading:o,trailingIcon:c});if(t===`a`){let{as:t,children:n,className:r,leadingIcon:i,loading:a,size:s,trailingIcon:c,variant:d,...f}=e;return(0,X.jsx)(`a`,{...f,"aria-busy":o?`true`:void 0,className:l,children:u})}let{as:d,children:f,className:p,disabled:m,leadingIcon:h,loading:g,size:_,trailingIcon:v,type:y,variant:b,...x}=e;return(0,X.jsx)(`button`,{...x,"aria-busy":o?`true`:void 0,className:l,disabled:m||o,type:y??`button`,children:u})},xm={root:`_root_x2vbk_1`,ghost:`_ghost_x2vbk_30`,filled:`_filled_x2vbk_40`,sm:`_sm_x2vbk_51`,lg:`_lg_x2vbk_57`,icon:`_icon_x2vbk_63`},Sm={ghost:xm.ghost,filled:xm.filled},Cm={sm:xm.sm,md:void 0,lg:xm.lg},wm={ghost:`btn-ghost`,filled:`btn-secondary`},Tm={sm:`btn-sm`,md:void 0,lg:`btn-lg`},Em=({"aria-label":e,className:t,icon:n,size:r=`md`,type:i,variant:a=`ghost`,...o})=>(0,X.jsx)(`button`,{...o,"aria-label":e,className:Y(xm.root,Sm[a],Cm[r],`btn`,wm[a],Tm[r],t),type:i??`button`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:xm.icon,children:n})}),Dm={overlay:`_overlay_1rr4b_1`,card:`_card_1rr4b_13`,sm:`_sm_1rr4b_28`,md:`_md_1rr4b_32`,lg:`_lg_1rr4b_36`,full:`_full_1rr4b_41`,header:`_header_1rr4b_46`,dialogHeader:`_dialogHeader_1rr4b_56`,title:`_title_1rr4b_97`,body:`_body_1rr4b_109`,footer:`_footer_1rr4b_118`},Om=(0,H.createContext)(null),km={sm:Dm.sm,md:Dm.md,lg:Dm.lg,full:Dm.full},Am={sm:void 0,md:void 0,lg:`modal-card-lg`,full:void 0};function jm({children:e,className:t,dismissible:n=!0,initialFocus:r,onOpenChange:i,open:a,size:o=`md`}){let s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useId)(),u=(0,H.useMemo)(()=>({titleId:l}),[l]);return(0,H.useLayoutEffect)(()=>{if(!a)return;c.current=document.activeElement;let e=s.current;if(e)return Xp(e,r).focus(),()=>{Qp(c.current),c.current=null}},[r,a]),a?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{className:Y(Dm.overlay,`modal-overlay`),onClick:e=>{n&&Gp(e)&&i(!1)},children:(0,X.jsx)(Om.Provider,{value:u,children:(0,X.jsx)(`div`,{"aria-labelledby":l,"aria-modal":`true`,className:Y(Dm.card,km[o],`modal-card`,Am[o],t),onKeyDown:e=>{if(Kp(e)){n&&(e.preventDefault(),e.stopPropagation(),i(!1));return}Zp(e.currentTarget,e)},ref:s,role:`dialog`,tabIndex:-1,children:e})})})}):null}function Mm({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.header,`modal-header`,e)})}function Nm({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.header,Dm.dialogHeader,`modal-header`,`dialog-header`,e)})}function Pm({className:e,...t}){let n=(0,H.useContext)(Om),r=(0,H.useId)(),i=n?.titleId??r;return(0,X.jsx)(`h2`,{...t,className:Y(Dm.title,`modal-title`,e),id:i})}function Fm({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.body,`modal-body`,e)})}function Im({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.footer,`modal-footer`,e)})}var Lm={root:`_root_1fg74_1`};function $({className:e,decorative:t=!0,role:n,semantic:r,size:i=14,...a}){let o=va(U(Xa),r),s=o.Icon;return(0,X.jsx)(`span`,{...a,"aria-hidden":t?!0:void 0,className:Y(Lm.root,`themed-icon`,`themed-icon--tone-${o.tone}`,`themed-icon--surface-${o.surface}`,e),"data-icon-semantic":r,"data-testid":a[`data-testid`]??`themed-icon`,role:t?void 0:n??`img`,children:(0,X.jsx)(s,{size:i,strokeWidth:o.strokeWidth})})}var Rm={body:`_body_261wh_1`,headerLeading:`_headerLeading_261wh_9`,headerCopy:`_headerCopy_261wh_17`,headerIcon:`_headerIcon_261wh_22`,titleDanger:`_titleDanger_261wh_31`,iconDanger:`_iconDanger_261wh_35`},zm={default:`primary`,danger:`danger`};function Bm({cancelDisabled:e=!1,cancelText:t,className:n,closeDisabled:r=!1,closeLabel:i=`Close`,confirmButtonProps:a,confirmDisabled:o=!1,confirmText:s,description:c,dismissible:l=!0,initialFocus:u,onConfirm:d,onOpenChange:f,open:p,title:m,tone:h=`default`}){let{className:g,disabled:_,...v}=a??{};return(0,X.jsxs)(jm,{className:n,dismissible:l,initialFocus:u,onOpenChange:f,open:p,children:[(0,X.jsxs)(Mm,{children:[h===`danger`?(0,X.jsxs)(`div`,{className:Y(`confirmDialogHeaderLeading`,Rm.headerLeading),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Y(`confirmDialogHeaderIcon`,Rm.headerIcon,Rm.iconDanger),children:(0,X.jsx)($,{semantic:`state.warning`,size:16})}),(0,X.jsx)(`div`,{className:Y(`confirmDialogHeaderCopy`,Rm.headerCopy),children:(0,X.jsx)(Pm,{className:Rm.titleDanger,children:m})})]}):(0,X.jsx)(Pm,{children:m}),l||r?(0,X.jsx)(Em,{"aria-label":i,className:`modal-close`,disabled:r,icon:(0,X.jsx)(pa,{size:14}),onClick:()=>f(!1),size:`sm`}):null]}),c?(0,X.jsx)(Fm,{className:Rm.body,children:c}):null,(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{disabled:e,onClick:()=>f(!1),children:t}),(0,X.jsx)(Q,{...v,className:g,disabled:o||_,onClick:d,variant:zm[h],children:s})]})]})}var Vm={triggerWrapper:`_triggerWrapper_upi96_1`,content:`_content_upi96_6`},Hm=8,Um=8;function Wm(e){return(0,H.isValidElement)(e)}function Gm({children:e,content:t,title:n,open:r,onOpenChange:i,forceMode:a=`auto`,placement:o=`bottom-start`,contentClassName:s,sheetBodyClassName:c}){let l=Br(),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(null),p=(0,H.useId)(),m=a===`desktop`?`desktop`:a===`mobile`?`mobile`:l,h=r&&m===`desktop`,g=r&&m===`mobile`,[_,v]=(0,H.useState)({left:Hm,top:Hm,visibility:`hidden`}),y=H.Children.only(e);if((0,H.useLayoutEffect)(()=>{if(r)return f.current=document.activeElement,()=>{Qp(f.current),f.current=null}},[r]),(0,H.useLayoutEffect)(()=>{if(!h||!u.current||!d.current){v(e=>e.visibility===`hidden`?e:{...e,visibility:`hidden`});return}let e=()=>{if(!u.current||!d.current)return;let e=u.current.getBoundingClientRect(),t=d.current.getBoundingClientRect(),n=o===`bottom-end`?e.right-t.width:e.left,r=Math.max(Hm,window.innerWidth-t.width-Hm),i=Math.min(r,Math.max(Hm,n)),a=e.bottom+Um;v({left:i,top:a+t.height<=window.innerHeight-Hm?a:Math.max(Hm,e.top-t.height-Um),visibility:`visible`})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[h,o]),(0,H.useLayoutEffect)(()=>{!h||!d.current||d.current.focus()},[h]),(0,H.useEffect)(()=>{if(!h)return;let e=e=>{e.target instanceof Node&&(u.current?.contains(e.target)||d.current?.contains(e.target)||i(!1))},t=e=>{Kp(e)&&(e.preventDefault(),i(!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[h,i]),!Wm(y))throw Error(`Popover requires a single trigger React element.`);let b=(0,H.cloneElement)(y,{"aria-controls":h?p:void 0,"aria-expanded":r,"aria-haspopup":`dialog`,onClick:e=>{y.props.onClick?.(e),e.defaultPrevented||i(!r)},onKeyDown:e=>{if(y.props.onKeyDown?.(e),!e.defaultPrevented){if(e.key===`ArrowDown`&&!r){e.preventDefault(),i(!0);return}Kp(e)&&r&&(e.preventDefault(),i(!1))}}});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Vm.triggerWrapper,ref:u,children:b}),h?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{"aria-label":n,"aria-modal":`false`,className:Y(Vm.content,s),id:p,onKeyDown:e=>{Kp(e)&&(e.preventDefault(),e.stopPropagation(),i(!1))},ref:d,role:`dialog`,style:{left:`${_.left}px`,top:`${_.top}px`,visibility:_.visibility},tabIndex:-1,children:t})}):null,g?(0,X.jsx)(fm,{body:(0,X.jsx)(`div`,{children:t}),bodyClassName:c,onClose:()=>i(!1),title:n}):null]})}var Km={trigger:`_trigger_v9p4r_1`,value:`_value_v9p4r_11`,icon:`_icon_v9p4r_19`,content:`_content_v9p4r_24`,header:`_header_v9p4r_31`,title:`_title_v9p4r_37`,body:`_body_v9p4r_44`,calendar:`_calendar_v9p4r_50`,time:`_time_v9p4r_63`,actions:`_actions_v9p4r_75`,action:`_action_v9p4r_75`,popoverContent:`_popoverContent_v9p4r_112`,sheetBody:`_sheetBody_v9p4r_116`,calendarGrid:`_calendarGrid_v9p4r_124`,calendarHeader:`_calendarHeader_v9p4r_130`,calendarTitle:`_calendarTitle_v9p4r_137`,calendarNav:`_calendarNav_v9p4r_144`,calendarWeekdays:`_calendarWeekdays_v9p4r_165`,calendarWeekday:`_calendarWeekday_v9p4r_165`,calendarDays:`_calendarDays_v9p4r_181`,calendarDay:`_calendarDay_v9p4r_181`,calendarDayToday:`_calendarDayToday_v9p4r_209`,calendarDaySelected:`_calendarDaySelected_v9p4r_214`,calendarDayDisabled:`_calendarDayDisabled_v9p4r_223`,calendarDayEmpty:`_calendarDayEmpty_v9p4r_229`,timeSelector:`_timeSelector_v9p4r_234`,timeField:`_timeField_v9p4r_240`,timeLabel:`_timeLabel_v9p4r_247`,timeSeparator:`_timeSeparator_v9p4r_254`,timeSection:`_timeSection_v9p4r_262`,timeInput:`_timeInput_v9p4r_272`},qm=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`],Jm=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`];function Ym(e,t){return new Date(e,t+1,0).getDate()}function Xm(e,t){return new Date(e,t,1).getDay()}function Zm(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Qm(e,t,n){return!!(t&&e<t||n&&e>n)}function $m({year:e,month:t,selectedDate:n,minDate:r,maxDate:i,onDateSelect:a,onMonthChange:o}){let s=Z(),c=Ym(e,t),l=Xm(e,t),u=()=>{t===0?o(e-1,11):o(e,t-1)},d=()=>{t===11?o(e+1,0):o(e,t+1)},f=n=>{let o=new Date(e,t,n);Qm(o,r,i)||a(o)},p=[];for(let e=0;e<l;e++)p.push((0,X.jsx)(`div`,{className:Km.calendarDayEmpty},`empty-${e}`));for(let a=1;a<=c;a++){let o=new Date(e,t,a),s=n&&Zm(o,n),c=Qm(o,r,i),l=Zm(o,new Date);p.push((0,X.jsx)(`button`,{type:`button`,disabled:c,className:Y(Km.calendarDay,s&&Km.calendarDaySelected,l&&!s&&Km.calendarDayToday,c&&Km.calendarDayDisabled),onClick:()=>f(a),children:a},a))}return(0,X.jsxs)(`div`,{className:Km.calendarGrid,children:[(0,X.jsxs)(`div`,{className:Km.calendarHeader,children:[(0,X.jsx)(`button`,{type:`button`,className:Km.calendarNav,onClick:u,"aria-label":s(`datetime.prev_month`),children:(0,X.jsx)(vi,{size:16})}),(0,X.jsxs)(`span`,{className:Km.calendarTitle,children:[s(`datetime.${Jm[t]}`),` `,e]}),(0,X.jsx)(`button`,{type:`button`,className:Km.calendarNav,onClick:d,"aria-label":s(`datetime.next_month`),children:(0,X.jsx)(yi,{size:16})})]}),(0,X.jsx)(`div`,{className:Km.calendarWeekdays,children:qm.map(e=>(0,X.jsx)(`div`,{className:Km.calendarWeekday,children:s(`datetime.${e}`)},e))}),(0,X.jsx)(`div`,{className:Km.calendarDays,children:p})]})}var eh={input:`_input_xkics_1`,sm:`_sm_xkics_29`,lg:`_lg_xkics_37`,invalid:`_invalid_xkics_42`},th={sm:eh.sm,md:void 0,lg:eh.lg},nh={sm:`input-sm`,md:void 0,lg:`input-lg`},rh=(0,H.forwardRef)(function({className:e,htmlSize:t,invalid:n,size:r=`md`,...i},a){let o=n===void 0?i[`aria-invalid`]:n?`true`:`false`;return(0,X.jsx)(`input`,{...i,ref:a,size:t,"aria-invalid":o,className:Y(eh.input,th[r],`input`,nh[r],n?eh.invalid:void 0,e)})});function ih({hour:e,minute:t,onHourChange:n,onMinuteChange:r,disabled:i=!1}){let a=Z(),o=(0,H.useId)(),s=(0,H.useId)(),c=String(e).padStart(2,`0`),l=String(t).padStart(2,`0`),u=e=>{let t=parseInt(e,10);!isNaN(t)&&t>=0&&t<=23&&n(t)},d=e=>{let t=parseInt(e,10);!isNaN(t)&&t>=0&&t<=59&&r(t)};return(0,X.jsxs)(`div`,{className:Km.timeSelector,children:[(0,X.jsxs)(`div`,{className:Km.timeField,children:[(0,X.jsx)(`label`,{htmlFor:o,className:Km.timeLabel,children:a(`datetime.hour`)}),(0,X.jsx)(rh,{id:o,type:`number`,min:0,max:23,"aria-label":a(`datetime.hour`),size:`sm`,value:c,onChange:e=>u(e.target.value),disabled:i,className:Km.timeInput})]}),(0,X.jsx)(`span`,{className:Km.timeSeparator,children:`:`}),(0,X.jsxs)(`div`,{className:Km.timeField,children:[(0,X.jsx)(`label`,{htmlFor:s,className:Km.timeLabel,children:a(`datetime.minute`)}),(0,X.jsx)(rh,{id:s,type:`number`,min:0,max:59,"aria-label":a(`datetime.minute`),size:`sm`,value:l,onChange:e=>d(e.target.value),disabled:i,className:Km.timeInput})]})]})}function ah(e){if(!e)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=Number(t[4]),o=Number(t[5]);return[n,r,i,a,o].some(Number.isNaN)?null:new Date(n,r-1,i,a,o)}function oh(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}function sh(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function ch(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes())}function lh(e,t){return new Date(e,t+1,0).getDate()}function uh(e,t,n){return Math.min(n,lh(e,t))}function dh(e){return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes()}}function fh(e){return new Date(e.year,e.month,e.day,e.hour,e.minute)}function ph(e,t,n){let r=e.getTime();return t!==void 0&&r<t?new Date(t):n!==void 0&&r>n?new Date(n):e}function mh(e,t,n){let r=e.getTime();return t!==void 0&&r<t||n!==void 0&&r>n}var hh={sm:`input-sm`,md:void 0,lg:`input-lg`};function gh({value:e,onValueChange:t,label:n,placeholder:r,disabled:i=!1,clearable:a=!1,minDate:o,maxDate:s,className:c,size:l=`md`,invalid:u=!1,"aria-describedby":d}){let f=Z(),p=U(Za),m=Br(),h=(0,H.useId)(),[g,_]=(0,H.useState)(!1),v=o?ch(o).getTime():void 0,y=s?ch(s).getTime():void 0,b=e=>dh(ah(e)||ph(ch(new Date),v,y)),[x,S]=(0,H.useState)(()=>b(e));(0,H.useEffect)(()=>{S(b(e))},[e]);let C=(0,H.useCallback)(e=>{S(t=>({...t,year:e.getFullYear(),month:e.getMonth(),day:e.getDate()}))},[]),w=(0,H.useCallback)((e,t)=>{S(n=>({...n,year:e,month:t,day:uh(e,t,n.day)}))},[]),T=(0,H.useCallback)(e=>{S(t=>({...t,hour:e}))},[]),E=(0,H.useCallback)(e=>{S(t=>({...t,minute:e}))},[]),D=mh(fh(x),v,y),O=(0,H.useCallback)(()=>{let e=fh(x);mh(e,v,y)||(t(oh(e)),_(!1))},[x,y,v,t]),k=(0,H.useCallback)(()=>{t(``),_(!1)},[t]),A=ah(e),j=A?dm(A.getTime(),p):r??f(`datetime.select_date`),M=m===`mobile`,N=Y(`input`,hh[l],Km.trigger,u?`input-invalid`:void 0,c),P=(0,X.jsxs)(`button`,{id:h,type:`button`,disabled:i,"aria-haspopup":M?`dialog`:`menu`,"aria-expanded":g,"aria-label":n,"aria-describedby":d,className:N,onClick:()=>_(!0),children:[(0,X.jsx)(`span`,{className:Km.value,children:j}),(0,X.jsx)(hi,{size:16,className:Km.icon,"aria-hidden":`true`})]}),F=new Date(x.year,x.month,x.day),ee=o?sh(o):void 0,I=s?sh(s):void 0,L=(0,X.jsxs)(`div`,{className:Km.content,children:[(0,X.jsxs)(`div`,{className:Km.body,children:[(0,X.jsx)($m,{year:x.year,month:x.month,selectedDate:F,minDate:ee,maxDate:I,onDateSelect:C,onMonthChange:w}),(0,X.jsxs)(`div`,{className:Km.timeSection,children:[(0,X.jsx)(`span`,{className:Km.timeLabel,children:f(`datetime.select_time`)}),(0,X.jsx)(ih,{hour:x.hour,minute:x.minute,onHourChange:T,onMinuteChange:E})]})]}),(0,X.jsxs)(`div`,{className:Km.actions,children:[a?(0,X.jsx)(`button`,{type:`button`,className:Km.action,onClick:k,children:f(`datetime.clear`)}):null,(0,X.jsx)(`button`,{type:`button`,className:Km.action,onClick:O,disabled:D,children:f(`datetime.confirm`)})]})]});return M?(0,X.jsxs)(X.Fragment,{children:[P,g?(0,X.jsx)(fm,{title:n,body:L,bodyClassName:Km.sheetBody,onClose:()=>_(!1),fullscreen:!0}):null]}):(0,X.jsx)(Gm,{open:g,onOpenChange:_,title:n,content:L,contentClassName:Km.popoverContent,sheetBodyClassName:Km.sheetBody,children:P})}var _h=0,vh=``;function yh(){return typeof document>`u`?()=>{}:(_h===0&&(vh=document.body.style.overflow,document.body.style.overflow=`hidden`),_h+=1,()=>{_h=Math.max(0,_h-1),_h===0&&(document.body.style.overflow=vh,vh=``)})}(0,H.createContext)(null);var bh={root:`_root_jtzwn_1`,icon:`_icon_jtzwn_13`,title:`_title_jtzwn_20`,description:`_description_jtzwn_27`,action:`_action_jtzwn_36`};function xh(e,t){if(e==null||typeof e==`boolean`)return null;if((0,H.isValidElement)(e)){let n=e;return(0,H.cloneElement)(n,{className:Y(n.props.className,t)})}return(0,X.jsx)(`div`,{className:t,children:e})}function Sh({action:e,className:t,description:n,icon:r,title:i,...a}){return(0,X.jsxs)(`div`,{...a,className:Y(bh.root,t),children:[xh(r,bh.icon),xh(i,bh.title),xh(n,bh.description),e?(0,X.jsx)(`div`,{className:bh.action,children:e}):null]})}var Ch={kbd:`_kbd_ilu4a_1`,interactive:`_interactive_ilu4a_19`,sm:`_sm_ilu4a_32`},wh={sm:Ch.sm,md:void 0},Th=({children:e,className:t,interactive:n=!1,onKeyDown:r,size:i=`md`,tabIndex:a,...o})=>(0,X.jsx)(`kbd`,{...o,className:Y(Ch.kbd,wh[i],n?Ch.interactive:void 0,`shortcuts-key`,t),onKeyDown:e=>{n&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.currentTarget.click()),r?.(e)},role:n?`button`:o.role,tabIndex:n?a??0:a,children:e}),Eh={overlay:`_overlay_1ofrz_1`,card:`_card_1ofrz_19`};function Dh({open:e,children:t,className:n,surfaceClassName:r,mode:i=`status`,interactive:a,onDismiss:o,ariaLabelledBy:s}){if(!e)return null;let c=a??i===`dialog`;return(0,X.jsx)(`div`,{"aria-labelledby":s,"aria-live":i===`status`?`polite`:void 0,"aria-modal":i===`dialog`?`true`:void 0,className:Y(Eh.overlay,`local-overlay`,n),"data-interactive":c?`true`:`false`,onClick:e=>{c&&o&&Gp(e)&&o()},role:i===`dialog`?`dialog`:`status`,children:(0,X.jsx)(`div`,{className:Y(Eh.card,`local-overlay__card`,r),children:t})})}var Oh={notice:`_notice_18fjp_1`,info:`_info_18fjp_14`,success:`_success_18fjp_19`,warning:`_warning_18fjp_24`,error:`_error_18fjp_29`,copy:`_copy_18fjp_34`,title:`_title_18fjp_42`,message:`_message_18fjp_51`,action:`_action_18fjp_59`},kh={info:Oh.info,success:Oh.success,warning:Oh.warning,error:Oh.error},Ah={info:void 0,success:void 0,warning:void 0,error:`settings-page__notice--error`};function jh({action:e,className:t,message:n,title:r,tone:i=`info`,...a}){return(0,X.jsxs)(`div`,{...a,className:Y(Oh.notice,kh[i],`settings-page__notice`,Ah[i],t),children:[r||n?(0,X.jsxs)(`div`,{className:Y(Oh.copy,`settings-page__notice-copy`),children:[r?(0,X.jsx)(`span`,{className:Y(Oh.title,`settings-page__notice-title`),children:r}):null,n?(0,X.jsx)(`span`,{className:Y(Oh.message,`settings-page__notice-message`),children:n}):null]}):null,e?(0,X.jsx)(`div`,{className:Oh.action,children:e}):null]})}var Mh={pill:`_pill_hhn3t_1`,active:`_active_hhn3t_35`,icon:`_icon_hhn3t_41`};function Nh({active:e=!1,children:t,className:n,disabled:r=!1,leadingIcon:i,selected:a=!1,...o}){let s=e||a;return(0,X.jsxs)(`button`,{...o,"aria-pressed":s,className:Y(Mh.pill,s?Mh.active:void 0,`settings-pill`,s?`settings-pill-active`:void 0,r?`settings-pill-disabled`:void 0,n),disabled:r,type:`button`,children:[i?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Mh.icon,children:i}):null,(0,X.jsx)(`span`,{children:t})]})}var Ph={root:`_root_162c6_1`,fill:`_fill_162c6_7`,success:`_success_162c6_14`,warning:`_warning_162c6_18`,error:`_error_162c6_22`,info:`_info_162c6_26`,neutral:`_neutral_162c6_30`,indeterminate:`_indeterminate_162c6_34`,progressBarIndeterminate:`_progressBarIndeterminate_162c6_1`};Ph.success,Ph.warning,Ph.error,Ph.info,Ph.neutral;var Fh={tabs:`_tabs_gpyk6_1`,tabList:`_tabList_gpyk6_5`,tab:`_tab_gpyk6_1`,tabActive:`_tabActive_gpyk6_69`,panel:`_panel_gpyk6_6`},Ih=(0,H.createContext)(null);function Lh(e){let t=(0,H.useContext)(Ih);if(!t)throw Error(`${e} must be used within Tabs`);return t}function Rh({children:e,className:t,orientation:n=`horizontal`,value:r,onValueChange:i,"aria-label":a,...o}){let s=(0,H.useId)(),c=(0,H.useRef)(new Map),[l,u]=(0,H.useState)({}),d=(0,H.useCallback)(e=>{let t=c.current.get(e);if(t)return t;let n={tabId:`${s}-tab-${c.current.size}`,panelId:`${s}-panel-${c.current.size}`};return c.current.set(e,n),n},[s]),f=(0,H.useCallback)(e=>{u(t=>t[e]?t:{...t,[e]:!0})},[]),p=(0,H.useCallback)(e=>{u(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),m=(0,H.useMemo)(()=>({value:r,onValueChange:i,orientation:n,listLabel:a,ensureTabIds:d,hasPanel:e=>!!l[e],registerPanel:f,unregisterPanel:p}),[a,d,i,n,l,f,p,r]);return(0,X.jsx)(Ih.Provider,{value:m,children:(0,X.jsx)(`div`,{...o,className:Y(Fh.tabs,t),"data-orientation":n,children:e})})}function zh({children:e,className:t,orientation:n,...r}){let i=Lh(`TabList`),a=n??i.orientation;return(0,X.jsx)(`div`,{...r,"aria-label":r[`aria-label`]??i.listLabel,"aria-orientation":a===`vertical`?`vertical`:void 0,className:Y(Fh.tabList,t),"data-orientation":a,role:`tablist`,children:e})}function Bh({children:e,className:t,value:n,onClick:r,onKeyDown:i,...a}){let o=Lh(`Tab`),s=o.value===n,c=o.ensureTabIds(n),l=e=>{if(i?.(e),e.defaultPrevented)return;let t=e.currentTarget.closest(`[role="tablist"]`);if(!t)return;let n=t.getAttribute(`aria-orientation`)===`vertical`?`vertical`:`horizontal`,r=Array.from(t.querySelectorAll(`button[role="tab"]:not(:disabled)`)),a=r.indexOf(e.currentTarget);if(a===-1)return;let s=t=>{let n=r[t];n?.focus();let i=n?.dataset.value;i&&o.onValueChange(i),e.preventDefault()};n===`horizontal`&&e.key===`ArrowRight`||n===`vertical`&&e.key===`ArrowDown`?s((a+1)%r.length):n===`horizontal`&&e.key===`ArrowLeft`||n===`vertical`&&e.key===`ArrowUp`?s((a-1+r.length)%r.length):e.key===`Home`?s(0):e.key===`End`&&s(r.length-1)};return(0,X.jsx)(`button`,{...a,"aria-controls":o.hasPanel(n)?c.panelId:void 0,"aria-selected":s,className:Y(Fh.tab,s?Fh.tabActive:void 0,s?`active`:void 0,t),"data-state":s?`active`:`inactive`,"data-value":n,id:c.tabId,onClick:e=>{r?.(e),e.defaultPrevented||o.onValueChange(n)},onKeyDown:l,role:`tab`,tabIndex:s?0:-1,type:`button`,children:e})}function Vh({children:e,className:t,value:n,...r}){let i=Lh(`TabPanel`),a=i.value===n,o=i.ensureTabIds(n),{registerPanel:s,unregisterPanel:c}=i;return(0,H.useLayoutEffect)(()=>(s(n),()=>{c(n)}),[s,c,n]),(0,X.jsx)(`div`,{...r,"aria-labelledby":o.tabId,className:Y(Fh.panel,t),hidden:!a,id:o.panelId,role:`tabpanel`,children:e})}var Hh={segmentedControl:`_segmentedControl_1ag6y_1`,segmentedControlOption:`_segmentedControlOption_1ag6y_18`};function Uh({options:e,value:t,onChange:n,size:r=`md`,className:i,optionClassName:a,...o}){return(0,X.jsx)(Rh,{onValueChange:n,value:e.some(e=>e.value===t)?t:e.find(e=>!e.disabled)?.value??t,children:(0,X.jsx)(zh,{...o,className:Y(Hh.segmentedControl,i),"data-size":r,children:e.map(e=>(0,X.jsx)(Bh,{className:Y(Hh.segmentedControlOption,a),"data-size":r,disabled:e.disabled,value:e.value,children:e.label},e.value))})})}var Wh={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},Gh={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},Kh={color:`var(--text-secondary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`},qh={color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`};function Jh({title:e,sections:t,className:n,selectedId:r,presentation:i=`sheet`,searchable:a=!1,searchPlaceholder:o,searchValue:s,onSearchValueChange:c,create:l,closeOnSelect:u=!0,loading:d=!1,loadingText:f,emptyText:p,kicker:m,onBack:h,onSelect:g,onClose:_}){let v=Z(),[y,b]=(0,H.useState)(``),x=(0,H.useId)(),S=s??y,C=S.trim(),w=S.trim().toLowerCase(),T=f??v(`common.loading`),E=p??v(`command.no_results`),D=o??v(`action.search`),O=e=>{s===void 0&&b(e),c?.(e)},k=(0,H.useMemo)(()=>w?t.map(e=>e.kind===`options`?{...e,items:e.items.filter(e=>[e.label,e.description??``,e.meta??``,...e.keywords??[]].join(` `).toLowerCase().includes(w))}:e):t,[w,t]),A=k.some(e=>e.items.length>0),j=!!(l?.visible&&C),M=!!(j&&l?.disabled?.(C)),N=(e,t)=>{Promise.resolve(t()).catch(t=>{console.error(`MobileSelectSheet ${e} failed`,t)})},P=e=>{N(`select`,async()=>{await g(e),u&&_()})},F=e=>{N(`action`,e)},ee=e=>{N(`action`,e)},I=()=>{!l||!C||N(`create`,()=>l.onCreate(C))},L=(0,X.jsxs)(X.Fragment,{children:[a?(0,X.jsxs)(`div`,{className:`mobile-select-sheet__search`,children:[(0,X.jsx)(`label`,{className:`mobile-select-sheet__search-label`,htmlFor:x,children:v(`action.search`)}),(0,X.jsx)(`input`,{id:x,type:`text`,className:`mobile-select-sheet__search-input`,placeholder:D,value:S,onChange:e=>O(e.target.value)})]}):null,(0,X.jsx)(`div`,{className:`mobile-select-sheet__content`,children:d?(0,X.jsx)(Sh,{className:`mobile-select-sheet__loading`,role:`status`,style:Gh,title:(0,X.jsx)(`div`,{style:Kh,children:T})}):(0,X.jsxs)(X.Fragment,{children:[k.map(e=>e.items.length===0&&e.kind===`options`?null:(0,X.jsxs)(`div`,{className:`mobile-select-sheet__section`,children:[e.title?(0,X.jsx)(`div`,{className:`mobile-select-sheet__section-title`,children:e.title}):null,(0,X.jsx)(`div`,{className:`mobile-select-sheet__list`,children:e.kind===`options`?e.items.map(t=>{let n=t.id===r,i=`${e.id}-${t.id}-label`,a=[t.description?`${e.id}-${t.id}-description`:null,t.meta?`${e.id}-${t.id}-meta`:null].filter(Boolean).join(` `),o=(0,X.jsxs)(`button`,{type:`button`,className:`mobile-select-sheet__item ${t.tone===`danger`?`mobile-select-sheet__item--danger`:``}`,"aria-pressed":n,"aria-labelledby":i,"aria-describedby":a||void 0,disabled:t.disabled,onClick:()=>P(t.id),children:[t.icon?(0,X.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,X.jsx)(`span`,{id:i,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,X.jsx)(`span`,{id:`${e.id}-${t.id}-description`,className:`mobile-select-sheet__item-description`,children:t.description}):null,t.meta?(0,X.jsx)(`span`,{id:`${e.id}-${t.id}-meta`,className:`mobile-select-sheet__item-meta`,children:t.meta}):null]}),t.badge?(0,X.jsx)(_g,{color:`neutral`,caps:!1,className:`mobile-select-sheet__item-badge`,children:t.badge}):null]});return t.trailingAction?(0,X.jsxs)(`div`,{className:`mobile-select-sheet__item-row`,"data-selected":n?`true`:`false`,children:[o,(0,X.jsx)(Em,{"aria-label":t.trailingAction.ariaLabel,className:`mobile-select-sheet__item-side-action ${t.trailingAction.tone===`danger`?`mobile-select-sheet__item-side-action--danger`:``}`,disabled:t.disabled||t.trailingAction.disabled,icon:(0,X.jsx)(`span`,{className:`mobile-select-sheet__item-side-action-icon`,children:t.trailingAction.icon}),onClick:()=>ee(t.trailingAction.onAction),size:`lg`,variant:`ghost`})]},t.id):(0,X.jsx)(`div`,{"data-selected":n?`true`:`false`,children:o},t.id)}):e.items.map(t=>{let n=`${e.id}-${t.id}-label`,r=t.description?`${e.id}-${t.id}-description`:void 0;return(0,X.jsxs)(`button`,{type:`button`,className:`mobile-select-sheet__item mobile-select-sheet__item--action ${t.tone===`danger`?`mobile-select-sheet__item--danger`:``}`,"aria-labelledby":n,"aria-describedby":r,disabled:t.disabled,onClick:()=>F(t.onAction),children:[t.icon?(0,X.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,X.jsx)(`span`,{id:n,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,X.jsx)(`span`,{id:r,className:`mobile-select-sheet__item-description`,children:t.description}):null]})]},t.id)})})]},e.id)),j?(0,X.jsx)(`div`,{className:`mobile-select-sheet__section`,children:(0,X.jsx)(`div`,{className:`mobile-select-sheet__list`,children:(()=>{let e=`mobile-select-create-label`,t=`mobile-select-create-description`,n=l?.description?.(C);return(0,X.jsx)(`button`,{type:`button`,className:`mobile-select-sheet__item mobile-select-sheet__item--create`,"aria-labelledby":e,"aria-describedby":n?t:void 0,disabled:M,onClick:I,children:(0,X.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,X.jsx)(`span`,{id:e,className:`mobile-select-sheet__item-label`,children:l?.label(C)}),n?(0,X.jsx)(`span`,{id:t,className:`mobile-select-sheet__item-description`,children:n}):null]})})})()})}):null,!A&&!j?(0,X.jsx)(Sh,{className:`mobile-select-sheet__empty`,style:Wh,title:(0,X.jsx)(`div`,{style:qh,children:E})}):null]})})]});return i===`inline`?(0,X.jsxs)(`div`,{className:`mobile-inline-sheet`,role:`dialog`,"aria-label":e,children:[(0,X.jsx)(`div`,{className:`mobile-inline-sheet__handle`,"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`mobile-inline-sheet__header`,children:(0,X.jsx)(rm,{title:e,titleAs:`h3`,onBack:h,backLabel:v(`action.back`)})}),(0,X.jsx)(`div`,{className:`mobile-inline-sheet__body`,children:(0,X.jsx)(`div`,{className:Y(`mobile-select-sheet`,`mobile-select-sheet--inline`,n),children:L})})]}):(0,X.jsx)(fm,{title:e,body:(0,X.jsx)(`div`,{className:Y(`mobile-select-sheet`,n),children:L}),onClose:_,kicker:m,onBack:h,bodyClassName:`mobile-sheet__body--flush`,fullscreen:!0})}var Yh={root:`_root_19636_1`,native:`_native_19636_6`,mobileTrigger:`_mobileTrigger_19636_11`,mobileValue:`_mobileValue_19636_20`,mobileIcon:`_mobileIcon_19636_25`,listbox:`_listbox_19636_30`,option:`_option_19636_46`,optionSelected:`_optionSelected_19636_60`,optionDisabled:`_optionDisabled_19636_64`},Xh={sm:eh.sm,md:void 0,lg:eh.lg},Zh={sm:`input-sm`,md:void 0,lg:`input-lg`};function Qh(e,t,n){return n||(t===void 0?``:e.find(e=>e.value===t)?.label??t)}function $h({className:e,invalid:t,size:n}){return Y(eh.input,Xh[n],`input`,Zh[n],`mobile-select-trigger`,Yh.mobileTrigger,t?eh.invalid:void 0,e)}function eg({ariaLabel:e,ariaLabelledBy:t,includeValueInAriaLabel:n,selectedLabel:r,valueId:i}){let a=t?`${t} ${i}`:void 0;return{resolvedAriaLabel:!t&&e&&n?`${e} ${r}`:e,resolvedAriaLabelledBy:a}}function tg(e){let t=Br(),n=(0,H.useId)(),[r,i]=(0,H.useState)(!1),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(`selected`),l=e.size??`md`,u=e.invalid===void 0?e[`aria-invalid`]:e.invalid?`true`:`false`,d=e.mobile!==!0&&e.desktopMode===`listbox`,f=d?t:`desktop`,p=d&&f===`desktop`;if((0,H.useEffect)(()=>{if(!r||!p)return;let e=e=>{e.target instanceof Node&&(a.current?.contains(e.target)||i(!1))};return document.addEventListener(`pointerdown`,e),()=>{document.removeEventListener(`pointerdown`,e)}},[r,p]),(0,H.useEffect)(()=>{if(!r||!p)return;let e=Array.from(s.current?.querySelectorAll(`[role="option"]:not([aria-disabled="true"])`)??[]);e.length!==0&&(c.current===`last`?e.at(-1):s.current?.querySelector(`[role="option"][aria-selected="true"]:not([aria-disabled="true"])`)??e[0])?.focus()},[r,p,e.options,e.value]),(0,H.useEffect)(()=>{i(!1)},[d,f]),e.mobile){let{"aria-label":t,"aria-labelledby":r,className:i,disabled:a,id:o,invalid:s,mobile:c,onClick:d,onOpen:f,options:p,size:m,value:h,valueLabel:g,includeValueInAriaLabel:_=!0,...v}=e,y=Qh(p,h,g),b=`${o??n}-value`,{resolvedAriaLabel:x,resolvedAriaLabelledBy:S}=eg({ariaLabel:t,ariaLabelledBy:r,includeValueInAriaLabel:_,selectedLabel:y,valueId:b});return(0,X.jsxs)(`button`,{...v,id:o,type:`button`,disabled:a,"aria-invalid":u,"aria-label":x,"aria-haspopup":v[`aria-haspopup`]??`dialog`,"aria-labelledby":S||void 0,className:$h({className:i,invalid:s,size:l}),onClick:e=>{d?.(e),!e.defaultPrevented&&!a&&!e.currentTarget.disabled&&f()},children:[(0,X.jsx)(`span`,{id:b,className:Y(`mobile-select-trigger__value`,Yh.mobileValue),children:y}),(0,X.jsx)(_i,{size:16,className:Y(`mobile-select-trigger__icon`,Yh.mobileIcon),"aria-hidden":`true`})]})}if(e.desktopMode===`listbox`){let{"aria-label":t,"aria-labelledby":d,className:m,desktopMode:h,disabled:g,id:_,invalid:v,mobileSheetPresentation:y=`sheet`,mobileSheetTitle:b,onClick:x,onKeyDown:S,onValueChange:C,options:w,size:T,value:E,...D}=e,O=Qh(w,E),k=`${_??n}-listbox`,A=`${_??n}-value`,{resolvedAriaLabel:j,resolvedAriaLabelledBy:M}=eg({ariaLabel:t,ariaLabelledBy:d,includeValueInAriaLabel:!0,selectedLabel:O,valueId:A}),N=(e=!1)=>{i(!1),e&&o.current?.focus()},P=e=>{C?.(e),N(!0)},F=()=>Array.from(s.current?.querySelectorAll(`[role="option"]:not([aria-disabled="true"])`)??[]),ee=e=>{if(e.key===`Tab`){N(!1);return}if(e.key===`Escape`){e.preventDefault(),N(!0);return}let t=F();if(t.length===0)return;let n=t.findIndex(e=>e===document.activeElement);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let r=e.key===`ArrowUp`?t.length-1:0;t[n===-1?r:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus();return}if(e.key===`Home`||e.key===`End`){e.preventDefault(),t[e.key===`Home`?0:t.length-1]?.focus();return}if(e.key!==`Enter`&&e.key!==` `)return;let r=e.target instanceof HTMLElement?e.target.closest(`[role="option"][data-option-value]`):null,i=r?.dataset.optionValue;!i||r?.getAttribute(`aria-disabled`)===`true`||(e.preventDefault(),P(i))},I=e=>{if(S?.(e),!(e.defaultPrevented||g||e.currentTarget.disabled)){if(e.key===`Escape`){N(!0);return}f===`desktop`&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),c.current=e.key===`ArrowUp`?`last`:`selected`,i(!0))}},L=y===`inline`?()=>i(!1):void 0;return(0,X.jsxs)(`div`,{ref:a,className:Yh.root,children:[(0,X.jsxs)(`button`,{...D,ref:o,id:_,type:`button`,disabled:g,"aria-controls":p&&r?k:void 0,"aria-expanded":r,"aria-invalid":u,"aria-label":j,"aria-haspopup":f===`mobile`?`dialog`:`listbox`,"aria-labelledby":M||void 0,className:$h({className:m,invalid:v,size:l}),onClick:e=>{x?.(e),!e.defaultPrevented&&!g&&!e.currentTarget.disabled&&(r||(c.current=`selected`),i(e=>!e))},onKeyDown:I,children:[(0,X.jsx)(`span`,{id:A,className:Y(`mobile-select-trigger__value`,Yh.mobileValue),children:O}),(0,X.jsx)(_i,{size:16,className:Y(`mobile-select-trigger__icon`,Yh.mobileIcon),"aria-hidden":`true`})]}),p&&r?(0,X.jsx)(`div`,{id:k,ref:s,role:`listbox`,"aria-label":t,"aria-labelledby":d,className:Yh.listbox,onKeyDown:ee,children:w.map(e=>{let t=e.value===E;return(0,X.jsx)(`div`,{role:`option`,id:`${k}-${e.value}`,"aria-disabled":e.disabled?`true`:void 0,"aria-selected":t,className:Y(Yh.option,t?Yh.optionSelected:void 0,e.disabled?Yh.optionDisabled:void 0),"data-option-value":e.value,tabIndex:-1,onClick:()=>{e.disabled||P(e.value)},children:e.label},e.value)})}):null,f===`mobile`&&r?(0,X.jsx)(Jh,{title:b,presentation:y,sections:[{kind:`options`,id:`${_??n}-options`,items:w.map(e=>({id:e.value,label:e.label,disabled:e.disabled}))}],selectedId:E,onBack:L,onClose:()=>i(!1),onSelect:e=>{C?.(e)}}):null]})}let{className:m,htmlSize:h,invalid:g,onChange:_,onValueChange:v,options:y,size:b,...x}=e;return(0,X.jsx)(`select`,{...x,size:h,"aria-invalid":u,className:Y(eh.input,Xh[l],`input`,Zh[l],Yh.native,g?eh.invalid:void 0,m),onChange:e=>{_?.(e),v?.(e.target.value)},children:y.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))})}var ng={spinner:`_spinner_hh7r3_1`},rg={sm:`12px`,md:`16px`,lg:`20px`};function ig({className:e,label:t,size:n=`md`,style:r,...i}){return(0,X.jsx)(`span`,{...i,"aria-label":t,className:Y(ng.spinner,`animate-spin`,e),role:`status`,style:{"--spinner-size":rg[n],...r}})}var ag={dot:`_dot_1dgyt_1`,pulse:`_pulse_1dgyt_13`,statusDotPulse:`_statusDotPulse_1dgyt_1`,statusDotRunningPulse:`_statusDotRunningPulse_1dgyt_1`,statusDotRunningRingGhost:`_statusDotRunningRingGhost_1dgyt_1`,statusDotRunningRing:`_statusDotRunningRing_1dgyt_1`},og={success:`var(--status-dot-complete)`,warning:`var(--status-dot-starting)`,error:`var(--status-dot-error)`,info:`var(--status-dot-running)`,neutral:`var(--status-dot-idle)`},sg={success:`var(--status-dot-complete-ring)`,warning:`var(--status-dot-starting-ring)`,error:`var(--status-dot-error-ring)`,info:`var(--status-dot-running-ring-1)`,neutral:`var(--status-dot-idle-ring)`},cg={sm:`6px`,md:`8px`,lg:`10px`};function lg({className:e,pulse:t=!1,size:n=`md`,style:r,tone:i=`neutral`,"aria-hidden":a=!0,...o}){return(0,X.jsx)(`span`,{...o,"aria-hidden":a,className:Y(ag.dot,t?ag.pulse:void 0,e),style:{"--status-dot-tone-color":og[i],"--status-dot-tone-ring":sg[i],"--status-dot-current-size":cg[n],...r}})}var ug={switch:`_switch_1li8z_1`,track:`_track_1li8z_26`,checked:`_checked_1li8z_52`,thumb:`_thumb_1li8z_57`},dg={sm:{trackWidth:`32px`,trackHeight:`18px`,thumbSize:`14px`,offset:`2px`},md:{trackWidth:`36px`,trackHeight:`20px`,thumbSize:`16px`,offset:`2px`}};function fg({checked:e,className:t,disabled:n=!1,onCheckedChange:r,onClick:i,size:a=`md`,style:o,...s}){let c=dg[a];return(0,X.jsx)(`button`,{...s,"aria-checked":e,className:Y(ug.switch,e?ug.checked:void 0,t),disabled:n,onClick:t=>{i?.(t),!(n||t.defaultPrevented)&&r(!e)},role:`switch`,style:{"--switch-track-width":c.trackWidth,"--switch-track-height":c.trackHeight,"--switch-thumb-size":c.thumbSize,"--switch-thumb-offset":c.offset,...o},type:`button`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:ug.track,children:(0,X.jsx)(`span`,{className:ug.thumb})})})}var pg={tag:`_tag_qp546_1`,sm:`_sm_qp546_26`,noCaps:`_noCaps_qp546_31`,blue:`_blue_qp546_35`,green:`_green_qp546_41`,amber:`_amber_qp546_47`,pink:`_pink_qp546_53`,purple:`_purple_qp546_59`,neutral:`_neutral_qp546_65`},mg={blue:pg.blue,green:pg.green,amber:pg.amber,pink:pg.pink,purple:pg.purple,neutral:pg.neutral},hg={blue:`badge-blue`,green:`badge-green`,amber:`badge-amber`,pink:`badge-pink`,purple:`badge-purple`,neutral:`badge-gray`},gg={sm:pg.sm,md:void 0};function _g({caps:e=!0,className:t,color:n=`neutral`,size:r=`md`,...i}){return(0,X.jsx)(`span`,{...i,className:Y(pg.tag,mg[n],gg[r],e?void 0:pg.noCaps,`badge`,hg[n],t)})}var vg={input:`_input_18qve_1`,textarea:`_textarea_18qve_29`,lg:`_lg_18qve_36`,invalid:`_invalid_18qve_41`},yg={md:void 0,lg:vg.lg},bg={md:void 0,lg:`textarea-lg`};function xg(e,t){if(typeof e==`function`){e(t);return}e&&(e.current=t)}function Sg(e){e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}var Cg=(0,H.forwardRef)(function({autoResize:e=!1,className:t,invalid:n,onChange:r,size:i=`md`,...a},o){let s=(0,H.useRef)(null),c=n===void 0?a[`aria-invalid`]:n?`true`:`false`;return(0,H.useEffect)(()=>{!e||!s.current||Sg(s.current)},[e,a.defaultValue,a.value]),(0,X.jsx)(`textarea`,{...a,"aria-invalid":c,className:Y(vg.input,vg.textarea,yg[i],`input`,`textarea`,bg[i],n?vg.invalid:void 0,t),onChange:t=>{e&&Sg(t.currentTarget),r?.(t)},ref:e=>{s.current=e,xg(o,e)}})}),wg={viewport:`_viewport_jjy5n_1`,mobile:`_mobile_jjy5n_14`,toast:`_toast_jjy5n_24`,slideIn:`_slideIn_jjy5n_1`,clickable:`_clickable_jjy5n_41`,success:`_success_jjy5n_50`,error:`_error_jjy5n_54`,warning:`_warning_jjy5n_58`,info:`_info_jjy5n_62`,icon:`_icon_jjy5n_66`,content:`_content_jjy5n_98`,title:`_title_jjy5n_106`,body:`_body_jjy5n_113`,action:`_action_jjy5n_122`,close:`_close_jjy5n_139`},Tg={success:wg.success,error:wg.error,warning:wg.warning,info:wg.info},Eg={success:`toast--success`,error:`toast--error`,warning:`toast--warning`,info:`toast--info`},Dg={success:`state.success`,error:`state.error`,warning:`state.warning`,info:`state.info`};function Og({children:e,className:t,mobile:n=!1,...r}){return(0,X.jsx)(`div`,{...r,className:Y(wg.viewport,n?wg.mobile:void 0,`toast-container`,n?`toast-container--mobile`:void 0,t),children:e})}function kg({actionLabel:e,className:t,closeLabel:n=`Dismiss`,description:r,icon:i,onAction:a,onClick:o,onDismiss:s,title:c,tone:l,...u}){let d=typeof o==`function`,{"aria-live":f,...p}=u,m=i??(0,X.jsx)($,{className:`toast__icon-symbol`,semantic:Dg[l],size:16});return(0,X.jsxs)(`div`,{...p,"aria-live":f,className:Y(wg.toast,Tg[l],d?wg.clickable:void 0,`toast`,Eg[l],t),onClick:o,role:`alert`,children:[m?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Y(wg.icon,`toast__icon`),children:m}):null,(0,X.jsxs)(`div`,{className:Y(wg.content,`toast__content`),children:[(0,X.jsx)(`span`,{className:Y(wg.title,`toast__title`),children:c}),r?(0,X.jsx)(`span`,{className:Y(wg.body,`toast__body`),children:r}):null]}),e&&a?(0,X.jsx)(`button`,{className:wg.action,onClick:e=>{e.stopPropagation(),a()},type:`button`,children:e}):null,(0,X.jsx)(Em,{"aria-label":n,className:Y(wg.close,`toast__close`),icon:(0,X.jsx)(pa,{size:14}),onClick:e=>{e.stopPropagation(),s()},size:`sm`})]})}var Ag={disabledTriggerWrapper:`_disabledTriggerWrapper_frz91_1`,tooltip:`_tooltip_frz91_5`},jg=new Set,Mg=null;function Ng(){if(Mg||typeof document>`u`)return;let e=e=>{for(let t of jg)t({target:e.target})};document.addEventListener(`pointerdown`,e,!0),Mg=()=>{document.removeEventListener(`pointerdown`,e,!0),Mg=null}}function Pg(e){return Ng(),jg.add(e),()=>{jg.delete(e),jg.size===0&&Mg?.()}}function Fg(e){return(0,H.isValidElement)(e)}function Ig({children:e,content:t,disabled:n=!1}){let r=H.Children.only(e),i=Br(),a=(0,H.useId)(),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)({left:0,top:0});if(!Fg(r))return r;let h=!n&&i===`desktop`,g=h&&(l||d),_=r.props.disabled===!0,v=r.props[`aria-describedby`],y=(0,H.useMemo)(()=>g?[v,a].filter(Boolean).join(` `):v,[v,g,a]);(0,H.useLayoutEffect)(()=>{if(!g||!o.current||!s.current)return;let e=o.current.getBoundingClientRect(),t=s.current.getBoundingClientRect(),n=e.left+e.width/2-t.width/2,r=Math.max(8,window.innerWidth-t.width-8),i=Math.min(r,Math.max(8,n)),a=e.top-t.height-8,c=e.bottom+8,l=Math.max(8,window.innerHeight-t.height-8);m({left:i,top:Math.max(8,a>=8?a:Math.min(l,c))})},[g]),(0,H.useEffect)(()=>{if(g)return Pg(({target:e})=>{if(!(e instanceof Node)){u(!1),f(!1);return}o.current?.contains(e)||(u(!1),f(!1))})},[g]);let b=_?(0,H.cloneElement)(r,{"aria-describedby":y}):(0,H.cloneElement)(r,{"aria-describedby":y,onBlur:e=>{r.props.onBlur?.(e),c.current=!1,f(!1)},onFocus:e=>{r.props.onFocus?.(e),!e.defaultPrevented&&h&&(o.current=e.currentTarget,f(!c.current))},onKeyDown:e=>{r.props.onKeyDown?.(e),c.current=!1},onMouseEnter:e=>{r.props.onMouseEnter?.(e),!e.defaultPrevented&&h&&(o.current=e.currentTarget,u(!0))},onMouseLeave:e=>{r.props.onMouseLeave?.(e),u(!1)},onPointerDown:e=>{r.props.onPointerDown?.(e),e.defaultPrevented||(c.current=!0)}});return(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(`span`,{className:Ag.disabledTriggerWrapper,onMouseEnter:e=>{!e.defaultPrevented&&h&&(o.current=e.currentTarget,u(!0))},onMouseLeave:()=>{u(!1)},children:b}):b,g?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{className:Y(Ag.tooltip),id:a,ref:s,role:`tooltip`,style:{left:`${p.left}px`,top:`${p.top}px`},children:t})}):null]})}var Lg={backdrop:`_backdrop_uo2rs_1`,surface:`_surface_uo2rs_14`};function Rg({children:e,open:t,onOpenChange:n,className:r,dismissible:i=!0,initialFocus:a,ariaLabel:o,ariaLabelledBy:s}){let c=(0,H.useRef)(null),l=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{if(!t)return;l.current=document.activeElement;let e=c.current,n=yh();return e?(Xp(e,a).focus(),()=>{n(),Qp(l.current),l.current=null}):n},[a,t]),t?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{className:Y(Lg.backdrop,`workbench-layer-backdrop`),onClick:e=>{i&&Gp(e)&&n(!1)},children:(0,X.jsx)(`div`,{"aria-label":o,"aria-labelledby":s,"aria-modal":`true`,className:Y(Lg.surface,`workbench-layer`,r),onClick:e=>{e.stopPropagation()},onKeyDown:e=>{if(Kp(e)){i&&(e.preventDefault(),e.stopPropagation(),n(!1));return}Zp(e.currentTarget,e)},ref:c,role:`dialog`,tabIndex:-1,children:e})})}):null}function zg({onAuthenticated:e}){let t=Z(),[,n]=Te(Qa),r=U(Za),i=U(Dp),a=Br()===`mobile`,[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(i===null),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(i!==null){p(!1),h(!1),_(i===!1),i===!1&&n(!0);return}(async()=>{try{let e=await(await fetch(`/auth/status`)).json();h(!1),_(e.authEnabled===!1),e.authEnabled===!1||e.authenticated===!0?n(!0):n(!1)}catch{h(!0),_(!1)}finally{p(!1)}})()},[i,n]);let v=t(f?`status.connecting`:m?`status.unavailable`:g?`auth.status_not_configured`:`auth.description`),y=t(f?`auth.status_loading`:m?`auth.status_unavailable`:g?`auth.status_not_configured`:`auth.hint`),b=`auth-status-panel${m||c?` auth-status-panel-error`:``}`,x=t(f||u?`status.connecting`:`action.confirm`),S=e=>typeof e!=`number`||Number.isNaN(e)?t(`auth.blocked_generic`):t(`auth.blocked_until`,{time:dm(e,r,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})});return(0,X.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,a?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsx)(`div`,{className:[`welcome-card`,`auth-card-shell`,a?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsxs)(`div`,{className:`auth-card-shell__content`,children:[(0,X.jsxs)(`section`,{className:`auth-hero`,children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:`CODER STUDIO`}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:t(`app.name`)}),(0,X.jsx)(`p`,{className:`welcome-body auth-card-desc meta-text`,children:v})]}),(0,X.jsxs)(`section`,{className:b,children:[(0,X.jsx)(`div`,{className:`auth-status-eyebrow`,children:t(`auth.status_title`)}),(0,X.jsx)(`p`,{className:`auth-status-detail`,children:c??y})]}),(0,X.jsxs)(`form`,{className:`auth-form`,onSubmit:async r=>{r.preventDefault(),d(!0),l(null);try{let t=await fetch(`/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:o})});if(!t.ok){let e=await t.json().catch(()=>({error:`Login failed`}));if(e?.blocked===!0){l(S(e.blockedUntil));return}l(e.error||`Login failed`);return}let r=await t.json();(r.authEnabled===!1||r.ok)&&(n(!0),e&&(await e()||n(!1)))}catch{l(t(`error.network`))}finally{d(!1)}},children:[(0,X.jsx)(rh,{className:`auth-input`,type:`password`,size:`lg`,value:o,onChange:e=>s(e.target.value),"aria-label":t(`settings.auth.password`),placeholder:t(`settings.auth.password`)}),(0,X.jsx)(Q,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`submit`,disabled:f||u||!o.trim(),children:x})]})]})})})}function Bg(){let e=Z(),t=Br()===`mobile`;return(0,X.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,t?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsx)(`div`,{className:[`welcome-card`,`auth-card-shell`,t?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsxs)(`div`,{className:`auth-card-shell__content`,children:[(0,X.jsxs)(`section`,{className:`auth-hero`,children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`auth.session_gate_title`)}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`app.name`)}),(0,X.jsx)(`p`,{className:`welcome-body auth-card-desc meta-text`,children:e(`auth.session_gate_description`)})]}),(0,X.jsxs)(`section`,{className:`auth-status-panel auth-status-panel-error`,children:[(0,X.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`auth.status_title`)}),(0,X.jsx)(`p`,{className:`auth-status-detail`,children:e(`auth.session_gate_detail`)})]}),(0,X.jsx)(`div`,{className:`auth-actions`,children:(0,X.jsx)(Q,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`button`,onClick:()=>window.location.replace(`/`),children:e(`auth.session_gate_reenter`)})})]})})})}var Vg={claude:`Claude`,codex:`Codex`};function Hg(e){return Vg[e]?Vg[e]:e?e.charAt(0).toUpperCase()+e.slice(1):`Agent`}function Ug(e){if(!e)return``;let t=e.name?.trim();if(t)return Wg(t);let n=e.path?.trim();return n?Wg(n):``}function Wg(e){let t=e.replace(/[/\\]+$/,``),n=t.split(/[/\\]/);return n[n.length-1]||t}function Gg(e){if(!Number.isFinite(e)||e<0)return``;if(e<1e3)return`<1s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?r===0?`${n}m`:`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var Kg=new WeakMap,qg=new WeakMap;function Jg(e){let t=qg.get(e);if(t)return t;let n=new WeakSet;return qg.set(e,n),n}function Yg(e){let t=e.get(no),n=Jg(e);return t&&!n.has(t)?(Kg.set(e,t),t):Kg.get(e)??null}function Xg(){let e=U(Op),t=W(no),n=ve();return(0,H.useCallback)(async({workspaceId:r,sessionId:i})=>{let a=n.get(no),o=Jg(n);if(Yg(n),!r)return null;if(a?.workspaceId===r&&(a.sessionId??void 0)===i)return a;let s={workspaceId:r,sessionId:i,updatedAt:Date.now()};o.add(s),t(s);let c=await e(`workspace.lastViewedTarget.set`,{workspaceId:r,sessionId:i}),l=n.get(no);if(c.ok&&c.data)return Kg.set(n,c.data),l===s?(o.delete(s),t(c.data),c.data):(o.delete(s),l);if(l===s){let e=Yg(n);return o.delete(s),t(e),e}return o.delete(s),l},[e,t,n])}function Zg(){let e=W(jp),t=Xg();return(0,H.useCallback)(async n=>n?(e(n),t({workspaceId:n})):null,[t,e])}var Qg=Ap(e=>V(null)),$g=Ap(e=>V(!1)),e_=Ap(e=>V(new Set)),t_=Ap(e=>V(null)),n_=/\.(avif|bmp|gif|ico|jpe?g|png|svg|tiff?|webp)$/i,r_=/\.(md|markdown|html?)$/i;function i_(e){return r_.test(e)}function a_(e){return/\.(md|markdown)$/i.test(e)?`markdown`:/\.html?$/i.test(e)?`html`:null}function o_(e){return n_.test(e)||i_(e)}function s_(e){return e.kind===`image`||i_(e.path)?`preview`:(e.viewingTextBackedImageAsText,`edit`)}function c_(e){return o_(e)?`preview`:`edit`}var l_=Ap(e=>V({})),u_=Ap(e=>V(null)),d_=Ap(e=>V(`preview`)),f_=Ap(e=>V(0));Ap(e=>V(t=>{let n=t(u_(e));return n?t(l_(e))[n]??null:null})),Ap(e=>V(t=>{let n=t(l_(e));return Object.values(n).filter(e=>e.isDirty).length}));var p_=Ap(e=>V(null)),m_=Ap(e=>V(null)),h_=Ap(e=>V(!1));Ap(e=>V(t=>{let n=t(p_(e));return n?n.staged.length>0||n.modified.length>0||n.untracked.length>0||n.deleted.length>0:!1})),Ap(e=>V(t=>{let n=t(p_(e));return n?{staged:n.staged.length,unstaged:n.modified.length+n.deleted.length,untracked:n.untracked.length,total:n.staged.length+n.modified.length+n.untracked.length+n.deleted.length}:{staged:0,unstaged:0,untracked:0,total:0}}));var g_=Ap(e=>V({current:``,branches:[],loading:!1})),__=V({visible:!1,inputValue:``}),v_=Ap(e=>Zr(`coder-studio:git-commit-draft:${e}`,``)),y_=Ap(e=>V({items:[],loading:!1})),b_=Ap(e=>V({status:`idle`})),x_=`__workspace_layout_global__`,S_=`explorer`,C_=new Set([`explorer`,`search`,`source-control`]),w_={focusMode:!1,leftPanelWidth:280,bottomPanelHeight:200,sidebarCollapsed:!1,desktopSidebarView:S_,terminalPanelVisible:!0};function T_(e){return typeof e==`string`&&C_.has(e)?e:S_}function E_(e,t){return typeof e==`boolean`?e:t}function D_(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:t}function O_(e){if(typeof window>`u`)return;let t=window.localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function k_(){return{focusMode:O_(`ui.focusMode`),leftPanelWidth:O_(`ui.leftPanelWidth`),bottomPanelHeight:O_(`ui.bottomPanelHeight`),sidebarCollapsed:O_(`ui.sidebarCollapsed`),desktopSidebarView:O_(`ui.desktopSidebarView`),terminalPanelVisible:O_(`ui.terminalPanelVisible`)}}function A_(e,t){let n=e&&typeof e==`object`?e:{},r={...w_,...t};return{focusMode:E_(n.focusMode,r.focusMode),leftPanelWidth:D_(n.leftPanelWidth,r.leftPanelWidth),bottomPanelHeight:D_(n.bottomPanelHeight,r.bottomPanelHeight),sidebarCollapsed:E_(n.sidebarCollapsed,r.sidebarCollapsed),desktopSidebarView:T_(n.desktopSidebarView??r.desktopSidebarView),terminalPanelVisible:E_(n.terminalPanelVisible,r.terminalPanelVisible)}}var j_=Yr(()=>window.localStorage),M_={...j_,getItem:(e,t)=>{let n=typeof window<`u`&&window.localStorage.getItem(e)===null?k_():void 0;return A_(j_.getItem(e,t),n)},setItem:(e,t)=>j_.setItem(e,A_(t))};function N_(e){return e(zp)??x_}function P_(e,t){return typeof t==`function`?t(e):t}function F_(e){return Ap(t=>V(n=>n(L_(t))[e],(n,r,i)=>{let a=n(L_(t)),o=P_(a[e],i);Object.is(o,a[e])||r(L_(t),{...a,[e]:o})}))}function I_(e){return V(t=>t(e(N_(t))),(t,n,r)=>{n(e(N_(t)),r)})}var L_=Ap(e=>Zr(`ui.workspaceLayout.${e}`,w_,M_,{getOnInit:!0})),R_=F_(`focusMode`),z_=F_(`leftPanelWidth`),B_=F_(`bottomPanelHeight`),V_=F_(`sidebarCollapsed`),H_=F_(`desktopSidebarView`),U_=F_(`terminalPanelVisible`),W_=I_(R_);I_(z_);var G_=I_(B_),K_=I_(V_),q_=I_(H_),J_=I_(U_),Y_=new Set([`workspace_open`,`session_start`,`mobile_continue`,`manual_check`]);function X_(e){let t=new URLSearchParams;t.set(`context`,e.context),e.workspaceId&&t.set(`workspaceId`,e.workspaceId),e.workspacePath&&t.set(`workspacePath`,e.workspacePath),e.providerId&&t.set(`providerId`,e.providerId),e.paneId&&t.set(`paneId`,e.paneId),e.launchMode&&t.set(`launchMode`,e.launchMode);let n=t.toString();return n.length>0?`/diagnostics?${n}`:`/diagnostics`}function Z_(e){let t=new URLSearchParams(e),n=t.get(`context`),r=Y_.has(n)?n:`manual_check`,i=t.get(`launchMode`);return{context:r,workspaceId:t.get(`workspaceId`)??void 0,workspacePath:t.get(`workspacePath`)??void 0,providerId:t.get(`providerId`)??void 0,paneId:t.get(`paneId`)??void 0,launchMode:i===`assign`||i===`replace`?i:void 0}}var Q_=`ui.paneLayout.`,$_=`ui.paneRatio.`,ev={id:`root`,type:`leaf`},tv=Ap(e=>V(ev));function nv(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function rv(e){let t=nv();if(!t)return null;try{let n=t.getItem(`${Q_}${e}`);return n?JSON.parse(n):null}catch{return null}}function iv(e){let t=nv();if(t)try{t.removeItem(`${Q_}${e}`)}catch{}}function av(e,t){let n=nv();if(!n)return null;try{let r=n.getItem(`${$_}${e}.${t}`);if(r===null)return null;let i=Number(r);return Number.isFinite(i)?i:null}catch{return null}}function ov(e,t,n){let r=nv();if(r)try{r.setItem(`${$_}${e}.${t}`,String(n))}catch{}}function sv(e){return{id:e,type:`leaf`}}function cv(e,t){return{id:e,type:`leaf`,sessionId:t}}function lv(e,t){return`split-${e}-${t}-${Date.now()}`}function uv(e,t){if(e.type===`leaf`)return e.id===t?e:null;for(let n of e.children??[]){let e=uv(n,t);if(e)return e}return null}function dv(e,t,n){if(e.type===`leaf`)return e.id===t?n(e):e;let r=e.children??[],i=!1,a=r.map(e=>{let r=dv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function fv(e,t){if(e.type===`leaf`)return e.id===t?null:e;let n=e.children??[],r=!1,i=[];for(let e of n){let n=fv(e,t);n!==e&&(r=!0),n!==null&&i.push(n)}return r?i.length===1?i[0]:i.length===0?null:{...e,children:i}:e}function pv(e,t,n){if(e.type===`leaf`){if(e.id!==t)return e;let r=`split-${e.id}-${n}-${Date.now()}`;return{id:r,type:`split`,direction:n,ratio:.5,children:[{...e},sv(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=pv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function mv(e,t,n){if(e.type===`leaf`){if(e.sessionId!==t)return e;let r=`split-${e.id}-${n}-${Date.now()}`;return{id:r,type:`split`,direction:n,ratio:.5,children:[{...e},sv(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=mv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function hv(e,t,n){if(e.type===`leaf`)return e.id===t?{...e,sessionId:n}:e;let r=e.children??[],i=!1,a=r.map(e=>{let r=hv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function gv(e,t,n){if(e.type===`leaf`)return e.sessionId===t?{...e,sessionId:n}:e;let r=e.children??[],i=!1,a=r.map(e=>{let r=gv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function _v(e,t,n){if(t===n)return e;let r=uv(e,t),i=uv(e,n);return!r?.sessionId||!i?.sessionId?e:dv(dv(e,t,e=>({...e,sessionId:i.sessionId})),n,e=>({...e,sessionId:r.sessionId}))}function vv(e,t,n){if(t===n)return e;let r=uv(e,t),i=uv(e,n);return!r?.sessionId||!i||i.sessionId?e:hv(fv(e,t)??{id:e.id,type:`leaf`},n,r.sessionId)}function yv(e,t,n,r){if(t===n)return e;let i=uv(e,t),a=uv(e,n);if(!i?.sessionId||!a?.sessionId)return e;let o=fv(e,t)??{id:e.id,type:`leaf`},s={id:i.id,type:`leaf`,sessionId:i.sessionId};return dv(o,n,e=>({id:lv(e.id,r),type:`split`,direction:r===`left`||r===`right`?`horizontal`:`vertical`,ratio:.5,children:r===`left`||r===`top`?[s,e]:[e,s]}))}function bv(e,t){return t.startsWith(`__draft__`)?Sv(e,t.replace(`__draft__`,``)):Cv(e,t)}function xv(e,t){if(e.type===`leaf`)return e.id===t&&!e.sessionId?null:e;let n=e.children??[],r=!1,i=[];for(let e of n){let n=xv(e,t);n!==e&&(r=!0),n!==null&&i.push(n)}return r?i.length===1?i[0]:i.length===0?null:{...e,children:i}:e}function Sv(e,t){return xv(e,t)??{id:e.id,type:`leaf`}}function Cv(e,t){if(e.type===`leaf`)return e.sessionId===t?{id:e.id,type:`leaf`}:e;let n=e.children??[],r=!1,i=n.map(e=>{let n=Cv(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function wv(e,t){return Tv(e,t)??{id:e.id,type:`leaf`}}function Tv(e,t){if(e.type===`leaf`)return e.sessionId===t?null:e;let n=e.children??[],r=!1,i=[];for(let e of n){let n=Tv(e,t);n!==e&&(r=!0),n!==null&&i.push(n)}return r?i.length===1?i[0]:i.length===0?null:{...e,children:i}:e}function Ev(e){return e.type===`leaf`?e.sessionId?[e.sessionId]:[]:e.children?.flatMap(e=>Ev(e))??[]}function Dv(e,t,n,r=`horizontal`){let i=jv(e,t);if(i)return i;if(n){let i=Mv(e,t,r,n);if(i)return i}return Mv(e,t,r)||(e.type===`leaf`&&!e.sessionId?{...e,sessionId:t}:{id:`root`,type:`leaf`,sessionId:t})}function Ov(e,t){return jv(e,t)||Nv(e,t)||Dv(e,t,void 0,`horizontal`)}function kv(e){if(e.length===0)return{id:`root`,type:`leaf`};if(e.length===1)return{id:`fallback-leaf-1`,type:`leaf`,sessionId:e[0]};let[t,...n]=e;return{id:`split-fallback-1`,type:`split`,direction:`horizontal`,ratio:.5,children:[{id:`fallback-leaf-1`,type:`leaf`,sessionId:t},Rv(n,2)]}}function Av(e,t){if(e.type===`leaf`)return e.sessionId&&!t.has(e.sessionId)?{id:e.id,type:`leaf`}:e;let n=e.children??[],r=!1,i=n.map(e=>{let n=Av(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function jv(e,t){if(e.type===`leaf`)return e.sessionId?null:{...e,sessionId:t};let n=e.children??[];for(let r=0;r<n.length;r+=1){let i=n[r],a=jv(i,t);if(a)return{...e,children:n.map((e,t)=>t===r?a:e)}}return null}function Mv(e,t,n,r){if(e.type===`leaf`){if(!e.sessionId||r&&e.sessionId!==r)return null;let i=`split-${e.id}-${n}-${Date.now()}`;return{id:i,type:`split`,direction:n,ratio:.5,children:[{...e},cv(`${i}-session`,t)]}}let i=e.children??[];for(let a=0;a<i.length;a+=1){let o=i[a],s=Mv(o,t,n,r);if(s)return{...e,children:i.map((e,t)=>t===a?s:e)}}return null}function Nv(e,t){let n=Pv(e);return n?Lv(e,n.path,e=>{let n=`split-${e.id}-horizontal-${Date.now()}`;return{id:n,type:`split`,direction:`horizontal`,ratio:.5,children:[{...e},cv(`${n}-session`,t)]}}):null}function Pv(e,t=1,n=[]){if(e.type===`leaf`)return e.sessionId?{path:n,width:t}:null;let r=e.children??[];if(r.length===0)return null;if(e.direction===`vertical`)return Fv(e)?{path:n,width:t}:null;let i=e.ratio??.5,a=t*i,o=t*(1-i);return Iv(Pv(r[0],a,[...n,0]),Pv(r[1],o,[...n,1]))}function Fv(e){return e.type===`leaf`?!!e.sessionId:(e.children??[]).some(e=>Fv(e))}function Iv(...e){let t=null;for(let n of e)n&&(!t||n.width>t.width)&&(t=n);return t}function Lv(e,t,n){if(t.length===0)return n(e);if(e.type===`leaf`)return e;let[r,...i]=t,a=e.children??[];return{...e,children:a.map((e,t)=>t===r?Lv(e,i,n):e)}}function Rv(e,t){if(e.length===1)return{id:`fallback-leaf-${t}`,type:`leaf`,sessionId:e[0]};let[n,...r]=e;return{id:`split-fallback-${t}`,type:`split`,direction:`horizontal`,ratio:.5,children:[{id:`fallback-leaf-${t}`,type:`leaf`,sessionId:n},Rv(r,t+1)]}}function zv(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.path==`string`&&typeof t.uiState==`object`&&t.uiState!==null}function Bv(e){let t=U(Op),n=W(Mp),r=ve();return{persistUiState:(0,H.useCallback)(async i=>{if(!e||e.startsWith(`__workspace_`))return!1;let a=r.get(Mp)[e];if(!a)return!1;let o={...a.uiState,leftPanelWidth:r.get(z_(e)),bottomPanelHeight:r.get(B_(e)),focusMode:r.get(R_(e)),...i};n(t=>{let n=t[e];return n?{...t,[e]:{...n,uiState:o}}:t});try{let r=await t(`workspace.uiState.set`,{workspaceId:e,uiState:o});return r.ok?(zv(r.data)&&n(t=>({...t,[e]:r.data})),!0):(console.error(`Failed to persist workspace ui state:`,r.error?.message),!1)}catch(e){return console.error(`Failed to persist workspace ui state:`,e),!1}},[t,n,r,e])}}function Vv(e){return e===`claude`?`Claude`:e===`codex`?`Codex`:e??`Provider`}function Hv(e){return Array.isArray(e)&&e.length>0?e.join(`, `):`—`}function Uv(e){if(typeof window>`u`||!e||e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`0.0.0.0`)return null;let t=window.location.protocol===`https:`||window.location.protocol===`http:`?window.location.protocol:`http:`,n=new URL(`${t}//${e}`);return window.location.port&&(n.port=window.location.port),n.pathname=`/workspace`,n.search=``,n.hash=``,n.toString()}function Wv(e,t){let n=Vv(t.providerId);switch(t.code){case`workspace_selection_missing`:return{title:e(`diagnostics.checks.workspace_selection_missing.title`),description:e(`diagnostics.checks.workspace_selection_missing.description`)};case`workspace_path_ready`:return{title:e(`diagnostics.checks.workspace_path_ready.title`),description:e(`diagnostics.checks.workspace_path_ready.description`)};case`workspace_path_not_found`:return{title:e(`diagnostics.checks.workspace_path_not_found.title`),description:e(`diagnostics.checks.workspace_path_not_found.description`)};case`workspace_path_unreadable`:return{title:e(`diagnostics.checks.workspace_path_unreadable.title`),description:e(`diagnostics.checks.workspace_path_unreadable.description`)};case`session_workspace_ready`:return{title:e(`diagnostics.checks.session_workspace_ready.title`),description:e(`diagnostics.checks.session_workspace_ready.description`)};case`session_workspace_missing`:return{title:e(`diagnostics.checks.session_workspace_missing.title`),description:e(`diagnostics.checks.session_workspace_missing.description`)};case`git_ready`:return{title:e(`diagnostics.checks.git_ready.title`),description:e(`diagnostics.checks.git_ready.description`)};case`git_missing`:return{title:e(`diagnostics.checks.git_missing.title`),description:e(`diagnostics.checks.git_missing.description`)};case`nodejs_ready`:return{title:e(`diagnostics.checks.nodejs_ready.title`),description:e(`diagnostics.checks.nodejs_ready.description`)};case`nodejs_missing`:return{title:e(`diagnostics.checks.nodejs_missing.title`),description:e(`diagnostics.checks.nodejs_missing.description`)};case`provider_runtime_ready`:return{title:e(`diagnostics.checks.provider_runtime_ready.title`,{provider:n}),description:e(`diagnostics.checks.provider_runtime_ready.description`,{provider:n})};case`provider_cli_missing`:return{title:e(`diagnostics.checks.provider_cli_missing.title`,{provider:n}),description:e(`diagnostics.checks.provider_cli_missing.description`,{provider:n})};case`provider_prerequisite_missing`:return{title:e(`diagnostics.checks.provider_prerequisite_missing.title`,{provider:n}),description:e(`diagnostics.checks.provider_prerequisite_missing.description`,{provider:n})};case`provider_unknown`:return{title:e(`diagnostics.checks.provider_unknown.title`),description:e(`diagnostics.checks.provider_unknown.description`)};case`server_auth_ready`:return{title:e(`diagnostics.checks.server_auth_ready.title`),description:e(`diagnostics.checks.server_auth_ready.description`)};case`server_auth_not_required`:return{title:e(`diagnostics.checks.server_auth_not_required.title`),description:e(`diagnostics.checks.server_auth_not_required.description`)};case`mobile_host_ready`:return{title:e(`diagnostics.checks.mobile_host_ready.title`),description:e(`diagnostics.checks.mobile_host_ready.description`)};case`mobile_host_local_only`:return{title:e(`diagnostics.checks.mobile_host_local_only.title`),description:e(`diagnostics.checks.mobile_host_local_only.description`)};case`mobile_auth_disabled`:return{title:e(`diagnostics.checks.mobile_auth_disabled.title`),description:e(`diagnostics.checks.mobile_auth_disabled.description`)};default:return{title:t.code,description:t.code}}}function Gv(){let e=Z(),t=Qt(),n=Yt(),r=Br()===`mobile`,i=Z_(n.search),a=ve(),o=U(Op),s=Aa(),c=U(xp),l=Xg(),u=W(jp),d=W(Np),f=W(Mp),p=W(Fp),m=W(Pp),h=W(Vp),g=U(no),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!0),[x,S]=(0,H.useState)(null),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(!1),D=(0,H.useRef)(null),O=Bv(i.workspaceId??_?.metadata.workspaceId??`__workspace_empty__`);function k(e,t,n,r){let i=a.get(tv(e));return r===`assign`&&n?hv(i??ev,n,t):{id:`root`,type:`leaf`,sessionId:t}}(0,H.useEffect)(()=>()=>{D.current!==null&&window.clearTimeout(D.current)},[]);let A={context:i.context,workspaceId:i.workspaceId,workspacePath:i.workspacePath,providerId:i.providerId},j=async t=>{if(c!==`connected`)return;b(!0),S(null);let n=await o(t,A);if(!n.ok||!n.data){v(null),S(n.error?.message??e(`diagnostics.load_failed`)),b(!1);return}v(n.data),S(null),b(!1)};(0,H.useEffect)(()=>{j(`diagnostics.get`)},[c,i.context,i.providerId,i.workspaceId,i.workspacePath]);let M=async()=>{let e={intent:i,response:_,loadError:x,actionError:C,lastViewedTarget:g};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),E(!0),D.current!==null&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{E(!1)},1500)},N=async()=>{if(!i.workspacePath)return;let n=await o(`workspace.open`,{path:i.workspacePath});if(!n.ok||!n.data?.id){w(n.error?.message??e(`workspace.launch.open_failed`)),await j(`diagnostics.recheck`);return}await l({workspaceId:n.data.id}),u(n.data.id),f(e=>({...e,[n.data.id]:n.data})),d(e=>e.includes(n.data.id)?e:[n.data.id,...e]),m(`ready`),p(null),t(`/workspace`)},P=async()=>{let n=i.workspaceId??_?.metadata.workspaceId,r=i.providerId??_?.metadata.providerId;if(!n||!r){w(e(`diagnostics.load_failed`));return}let c=await o(`session.create`,{workspaceId:n,providerId:r,themeBackground:s});if(!c.ok||!c.data){w(c.error?.message??e(`diagnostics.load_failed`)),await j(`diagnostics.recheck`);return}h(e=>({...e,[c.data.id]:c.data})),u(n),m(`ready`),p(null),d(e=>e.includes(n)?e:[n,...e]),await l({workspaceId:n,sessionId:c.data.id});let f=k(n,c.data.id,i.paneId,i.launchMode);a.set(tv(n),f),O.persistUiState({activeSessionId:c.data.id,paneLayout:f}),t(`/workspace`)},F=async()=>{let t=i.workspaceId??_?.metadata.workspaceId,n=t&&g?.workspaceId===t?g.sessionId??void 0:void 0;t&&await l({workspaceId:t,sessionId:n});let r=Uv(_?.metadata.host);if(!r){w(e(`diagnostics.load_failed`));return}if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(r);return}w(e(`diagnostics.load_failed`))},ee=async()=>{if(w(null),i.context===`workspace_open`){await N();return}if(i.context===`session_start`){if(_?.canContinue){await P();return}await j(`diagnostics.recheck`);return}if(i.context===`mobile_continue`){if(_?.canContinue){await F();return}await j(`diagnostics.recheck`);return}await j(`diagnostics.recheck`)},I=()=>i.context===`workspace_open`?e(`diagnostics.actions.retry_workspace`):i.context===`session_start`?_?.canContinue?e(`diagnostics.actions.continue_session`):e(`diagnostics.actions.recheck`):i.context===`mobile_continue`&&_?.canContinue?e(`diagnostics.actions.continue_phone`):e(`diagnostics.actions.recheck`),L=i.context===`workspace_open`?!!_?.canContinue:!0,R=e(`diagnostics.context.${i.context}.title`),z=e(`diagnostics.context.${i.context}.description`),te=typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`,ne=()=>{t(-1)};return(0,X.jsxs)(`div`,{className:`diagnostics-page ${r?`diagnostics-page--mobile`:``}`,children:[(0,X.jsx)(`header`,{className:`diagnostics-header`,children:r?(0,X.jsx)(rm,{title:e(`diagnostics.title`),titleAs:`div`,onBack:ne,backLabel:e(`action.back`)}):(0,X.jsx)(nm,{title:e(`diagnostics.title`),titleAs:`h1`,level:`secondary`,onBack:ne,backLabel:e(`action.back`)})}),(0,X.jsx)(`div`,{className:`diagnostics-body ${r?`diagnostics-body--mobile`:``}`,children:(0,X.jsx)(`main`,{className:`diagnostics-content ${r?`diagnostics-content--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`diagnostics-content-surface`,children:[(0,X.jsxs)(`section`,{className:`diagnostics-summary ${r?`diagnostics-summary--mobile`:``}`,children:[(0,X.jsxs)(`div`,{className:`diagnostics-summary__copy`,children:[r?null:(0,X.jsxs)(`div`,{className:`diagnostics-summary__eyebrow`,children:[(0,X.jsx)($,{semantic:`state.warning`,size:16}),(0,X.jsx)(`span`,{children:e(`diagnostics.title`)})]}),r?(0,X.jsx)(`h1`,{className:`diagnostics-summary__title`,children:R}):(0,X.jsx)(`h2`,{className:`diagnostics-summary__title`,children:R}),(0,X.jsx)(`p`,{className:`diagnostics-summary__description`,children:z})]}),(0,X.jsx)(`div`,{className:`diagnostics-actions ${r?`diagnostics-actions--mobile`:``}`,children:(0,X.jsx)(Q,{className:r?`diagnostics-actions__primary`:void 0,leadingIcon:(0,X.jsx)(ta,{size:16}),loading:y,disabled:!L,onClick:()=>{ee()},variant:`primary`,children:I()})})]}),x||C?(0,X.jsx)(jh,{role:`alert`,tone:`error`,title:e(`diagnostics.load_failed`),message:C??x??``}):null,(0,X.jsx)(`div`,{className:`diagnostics-toolbar ${r?`diagnostics-toolbar--mobile`:``}`,children:te?(0,X.jsx)(Q,{leadingIcon:(0,X.jsx)(Ci,{size:16}),onClick:()=>{M()},size:`sm`,variant:`ghost`,children:e(T?`diagnostics.actions.copied`:`diagnostics.actions.copy_details`)}):null}),y?(0,X.jsx)(`div`,{className:`diagnostics-loading`,children:e(`diagnostics.loading_description`)}):null,_?(0,X.jsx)(`section`,{className:`diagnostics-results`,"aria-label":e(`diagnostics.title`),children:(0,X.jsx)(`div`,{className:`diagnostics-issues`,children:_.checks.map(t=>{let n=Wv(e,t);return(0,X.jsxs)(`div`,{className:`diagnostics-issue`,children:[(0,X.jsxs)(`div`,{className:`diagnostics-issue__header`,children:[(0,X.jsx)(_g,{caps:!1,color:t.status===`ready`?`green`:t.status===`checking`?`blue`:`amber`,size:`sm`,children:e(`diagnostics.status.${t.status}`)}),(0,X.jsx)(`div`,{className:`diagnostics-issue__title`,children:n.title})]}),(0,X.jsx)(`p`,{className:`diagnostics-issue__description`,children:n.description}),(0,X.jsxs)(`div`,{className:`diagnostics-issue__meta`,children:[t.workspacePath?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.workspace`),`: `,t.workspacePath]}):null,t.providerId?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.provider`),`:`,` `,Vv(t.providerId)]}):null,t.missingCommands?.length?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.missing_commands`),`:`,` `,Hv(t.missingCommands)]}):null,t.missingPrerequisites?.length?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.missing_prerequisites`),`:`,` `,Hv(t.missingPrerequisites)]}):null,t.version?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.current_version`),`: `,t.version]}):null]}),t.manualGuideKeys?.length?(0,X.jsx)(`div`,{className:`diagnostics-issue__guides`,children:t.manualGuideKeys.map(t=>(0,X.jsx)(`span`,{children:e(t)},t))}):null,(0,X.jsx)(`div`,{className:`diagnostics-issue__actions`,children:t.docUrl?(0,X.jsx)(Q,{as:`a`,href:t.docUrl,rel:`noreferrer`,size:`sm`,target:`_blank`,variant:`ghost`,children:e(`provider.install.open_docs`)}):null})]},t.id)})})}):null]})})})]})}function Kv(e){let t=Z(),n=Yt(),r=Qt(),i=U(Op),a=W(jp),o=W(Mp),s=W(Np),c=W(Pp),l=W(Fp),u=Xg(),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)([]),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!0),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)([`/`]),[D,O]=(0,H.useState)(null),k=t(`workspace.launch.title`),A=t(`workspace.launch.hint`);(0,H.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let j=(0,H.useCallback)(async e=>{S(!0),w(null);try{let n=await i(`workspace.browse`,{path:e});if(!n.ok||!n.data){w(n.error?.message||t(`workspace.launch.browse_failed`));return}f(n.data.currentPath),m(n.data.directories),g(n.data.parentPath);let r=n.data.rootPaths?.filter(Boolean)??[`/`];E(r),O(r.find(e=>e!==`/`)??null)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},[i]);(0,H.useEffect)(()=>{j()},[j]);let M=(0,H.useCallback)(e=>{v(null),j(e)},[j]),N=(0,H.useCallback)(e=>{v(e)},[]),P=(0,H.useCallback)(async()=>{if(!_){w(t(`workspace.launch.select_required`));return}b(!0),w(null);try{let t=await i(`workspace.open`,{path:_});t.ok&&t.data?.id?(u({workspaceId:t.data.id}),a(t.data.id),o(e=>({...e,[t.data.id]:t.data})),s(e=>e.includes(t.data.id)?e:[t.data.id,...e]),c(`ready`),l(null),n.pathname!==`/workspace`&&r(`/workspace`),e()):r(X_({context:`workspace_open`,workspacePath:_}))}catch{r(X_({context:`workspace_open`,workspacePath:_}))}finally{b(!1)}},[i,n.pathname,r,e,_,a,u,s,o,l,c,t]);return{browsing:x,currentPath:d,directories:p,error:C,getShortPath:(0,H.useCallback)(e=>e===`/`?`/`:D&&e===D?`~`:D&&e.startsWith(`${D}/`)?`~${e.slice(D.length)}`:e,[D]),handleNavigate:M,handleOpen:P,handleSelect:N,launchHint:A,launchTitle:k,loading:y,parentPath:h,rootPaths:T,selectedPath:_}}function qv(e,t){let n=U(bp),[r,i]=(0,H.useState)(`status`),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)([]),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null);return(0,H.useEffect)(()=>{if(!t||!n||!e){o(null),c(``),u([]);return}f(!0),m(null),(async()=>{try{r===`status`?o((await n.sendCommand(`worktree.status`,{workspaceId:e,worktreePath:t.path})).status):r===`diff`?c((await n.sendCommand(`worktree.diff`,{workspaceId:e,worktreePath:t.path})).diff):r===`tree`&&u((await n.sendCommand(`worktree.tree`,{workspaceId:e,worktreePath:t.path})).tree)}catch(e){m(e instanceof Error?e.message:`Failed to load data`)}finally{f(!1)}})()},[r,e,t,n]),{activeTab:r,diff:s,error:p,handleTabChange:(0,H.useCallback)(e=>{i(e)},[]),loading:d,status:a,tree:l}}var Jv={minHeight:`auto`,padding:`var(--sp-6)`,gap:0},Yv={padding:`var(--sp-8)`,gap:`var(--sp-2)`},Xv={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},Zv={position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0};function Qv({onClose:e}){let t=Br()===`mobile`,n=Z(),{browsing:r,currentPath:i,directories:a,error:o,getShortPath:s,handleNavigate:c,handleOpen:l,handleSelect:u,launchHint:d,launchTitle:f,loading:p,parentPath:m,rootPaths:h,selectedPath:g}=Kv(e),_=(0,X.jsxs)(`div`,{className:`launch-body`,children:[(0,X.jsxs)(`div`,{className:`folder-picker`,children:[(0,X.jsxs)(`div`,{className:`fp-toolbar`,children:[(0,X.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(`~`),children:[(0,X.jsx)($,{semantic:`workspace.launch.home`,size:12}),n(`workspace.launch.home_directory`)]}),m&&(0,X.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(m),children:[(0,X.jsx)(pi,{size:12}),n(`workspace.launch.go_up`)]})]}),(0,X.jsxs)(`div`,{className:`fp-root-chips`,children:[h.map(e=>(0,X.jsx)(`span`,{className:`fp-chip ${i===e?`active`:``}`,onClick:()=>c(e),children:s(e)},e)),i&&!h.includes(i)&&(0,X.jsx)(`span`,{className:`fp-chip active`,children:s(i)})]}),(0,X.jsx)(`div`,{className:`fp-dir-list`,children:r?(0,X.jsx)(Sh,{className:`directory-loading`,icon:(0,X.jsx)(ig,{label:n(`common.loading`)}),style:Yv,title:(0,X.jsx)(`span`,{style:Zv,children:n(`common.loading`)})}):a.length===0?(0,X.jsx)(Sh,{className:`directory-empty`,style:Jv,title:(0,X.jsx)(`p`,{style:Xv,children:n(`workspace.launch.no_directories`)})}):a.map(e=>(0,X.jsxs)(`div`,{className:`fp-dir ${g===e.path?`selected`:``}`,onClick:()=>u(e.path),onDoubleClick:()=>c(e.path),children:[(0,X.jsx)(`span`,{className:`fp-dir-icon`,children:(0,X.jsx)($,{semantic:`file.folder.closed`,size:14})}),(0,X.jsx)(`span`,{className:`fp-dir-name ${g===e.path?`selected`:``}`,children:e.name}),e.itemCount!==void 0&&(0,X.jsx)(`span`,{className:`fp-dir-hint`,children:n(`workspace.launch.items_count`,{count:e.itemCount})}),g===e.path&&(0,X.jsx)(`button`,{className:`fp-dir-action`,type:`button`,"aria-label":n(`workspace.launch.enter_folder`,{name:e.name}),onClick:t=>{t.stopPropagation(),c(e.path)},children:n(`workspace.launch.enter_folder_action`)})]},e.path))})]}),o&&(0,X.jsx)(`div`,{className:`form-error`,style:{marginTop:`var(--sp-3)`},children:o})]}),v=(0,X.jsx)(`div`,{className:`mobile-launch-sheet__footer`,children:(0,X.jsx)(`button`,{className:`launch-start-btn launch-start-btn--mobile`,onClick:()=>void l(),disabled:p||!g,children:n(p?`workspace.launch.starting`:`workspace.launch.start`)})});return t?(0,X.jsx)(fm,{kicker:n(`workspace.launch.kicker`),title:f,body:_,footer:v,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen mobile-launch-sheet`,contentClassName:`mobile-sheet--launch`,onClose:e}):(0,X.jsx)(Rg,{ariaLabel:f,onOpenChange:t=>{t||e()},open:!0,children:(0,X.jsxs)(`div`,{className:`launch-modal`,children:[(0,X.jsxs)(`div`,{className:`launch-header`,children:[(0,X.jsxs)(`div`,{className:`launch-header-left`,children:[(0,X.jsx)(`div`,{className:`launch-kicker`,children:n(`workspace.launch.kicker`)}),(0,X.jsx)(`div`,{className:`launch-title`,children:f}),(0,X.jsx)(`div`,{className:`launch-hint`,children:d})]}),(0,X.jsx)(`div`,{className:`launch-header-right`,children:(0,X.jsx)(Em,{"aria-label":n(`action.close`),className:`launch-close-btn`,icon:(0,X.jsx)(pa,{size:16}),onClick:e,size:`sm`})})]}),_,(0,X.jsx)(`div`,{className:`launch-footer`,children:(0,X.jsx)(`button`,{className:`launch-start-btn launch-start-btn--desktop`,onClick:()=>void l(),disabled:p||!g,children:n(p?`workspace.launch.starting`:`workspace.launch.start`)})})]})})}var $v={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},ey={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function ty(){let e=Z(),t=Yt(),n=Qt(),r=Br()===`mobile`,[i,a]=Te($a),[o,s]=Te(W_),[c,l]=Te(K_),[u,d]=Te(J_),[f,p]=Te(G_),m=U(zp),h=W(jp),g=W(eo),_=Zg(),v=U(Rp),[y,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(0),[C,w]=(0,H.useState)(!1),T=(0,H.useRef)(null),E=ny({shellKind:r?`mobile`:`desktop`,focusMode:o,setFocusMode:s,sidebarCollapsed:c,setSidebarCollapsed:l,terminalPanelVisible:u,setTerminalPanelVisible:d,bottomPanelHeight:f,setBottomPanelHeight:p,activeWorkspaceId:m,setActiveWorkspaceId:h,selectWorkspaceTarget:_,workspaces:v,locationPathname:t.pathname,navigate:n,t:e,setQuickOpenOpen:g,setShowWorkspaceLaunch:e=>{e&&a(!1),w(e)}}).filter(e=>{let t=y.toLowerCase();return e.label.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.shortcut&&e.shortcut.toLowerCase().includes(t)});(0,H.useEffect)(()=>{i&&(T.current?.focus(),b(``),S(0))},[i]);let D=(0,H.useCallback)(e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),S(e=>e<E.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),S(e=>e>0?e-1:e);break;case`Enter`:e.preventDefault(),E[x]&&(E[x].action(),a(!1));break;case`Escape`:e.preventDefault(),a(!1);break}},[E,x,a]);(0,H.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),a(!i))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,a]);let O=e=>{e.action(),a(!1)},k=(0,X.jsxs)(`div`,{className:`command-palette-search`,children:[(0,X.jsx)($,{className:`command-palette-search-icon`,semantic:`nav.search`,size:16}),(0,X.jsx)(`input`,{ref:T,type:`text`,className:`command-palette-input`,placeholder:e(`placeholder.command`),value:y,onChange:e=>{b(e.target.value),S(0)}})]}),A=(0,X.jsx)(`div`,{className:`command-palette-list`,children:E.length>0?E.map((e,t)=>(0,X.jsxs)(`div`,{className:`command-palette-item ${t===x?`command-palette-item-selected`:``}`,onClick:()=>O(e),onMouseEnter:()=>S(t),children:[(0,X.jsxs)(`div`,{className:`command-palette-item-content`,children:[(0,X.jsx)(`span`,{className:`command-palette-item-label`,children:e.label}),(0,X.jsx)(`span`,{className:`command-palette-item-desc`,children:e.description})]}),e.shortcut?(0,X.jsx)(`span`,{className:`command-palette-item-shortcut`,children:e.shortcut}):null]},e.id)):(0,X.jsx)(Sh,{className:`command-palette-empty`,style:$v,title:(0,X.jsx)(`p`,{style:ey,children:e(`command.no_results`)})})});return C?(0,X.jsx)(Qv,{onClose:()=>w(!1)}):i?r?(0,X.jsx)(fm,{title:`Quick Actions`,kicker:e(`command.palette`).toUpperCase(),onClose:()=>a(!1),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`command-palette-sheet-layer`,body:(0,X.jsx)(`div`,{className:`command-palette-sheet-shell`,onKeyDown:D,children:(0,X.jsxs)(`div`,{className:`command-palette-sheet`,children:[(0,X.jsxs)(`div`,{className:`command-palette-sheet__search`,children:[k,(0,X.jsxs)(`div`,{className:`command-palette-sheet__meta`,children:[(0,X.jsx)(`span`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),(0,X.jsxs)(`span`,{className:`command-palette-meta`,children:[E.length,` actions`]})]})]}),A]})})}):(0,X.jsx)(Rg,{ariaLabel:e(`command.palette`),initialFocus:()=>T.current,onOpenChange:a,open:!0,children:(0,X.jsxs)(`div`,{className:`command-palette command-palette--desktop`,onKeyDown:D,children:[(0,X.jsxs)(`div`,{className:`command-palette-header`,children:[(0,X.jsx)(`span`,{className:`command-palette-kicker`,children:e(`command.palette`).toUpperCase()}),(0,X.jsxs)(`span`,{className:`command-palette-meta`,children:[E.length,` actions`]})]}),k,(0,X.jsx)(`div`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),A]})}):null}function ny(e){let{shellKind:t,focusMode:n,setFocusMode:r,sidebarCollapsed:i,setSidebarCollapsed:a,terminalPanelVisible:o,setTerminalPanelVisible:s,bottomPanelHeight:c,setBottomPanelHeight:l,activeWorkspaceId:u,setActiveWorkspaceId:d,selectWorkspaceTarget:f,workspaces:p,locationPathname:m,navigate:h,t:g,setQuickOpenOpen:_,setShowWorkspaceLaunch:v}=e,y=[{id:`new-workspace`,label:g(`workspace.open`),description:g(`workspace.open_hint`),shortcut:`Ctrl+N`,action:()=>{v(!0)}},{id:`open-home`,label:g(`workspace.title`),description:g(`action.back`),action:()=>h(`/`)},{id:`open-settings`,label:g(`action.settings`),description:g(`settings.title`),shortcut:`Ctrl+,`,action:()=>{h(`/settings`)}}];return t===`desktop`&&y.push(...u?[{id:`go-to-file`,label:g(`quick_open.command_label`),description:g(`quick_open.command_description`),shortcut:`Ctrl+P`,action:()=>_(!0)}]:[],{id:`toggle-focus-mode`,label:g(`tooltip.focus_mode`),description:g(n?`action.close`:`action.open`),shortcut:`F`,action:()=>r(!n)},{id:`enable-focus-mode`,label:`${g(`action.open`)} Focus Mode`,description:g(`tooltip.focus_mode`),action:()=>r(!0)},{id:`disable-focus-mode`,label:`${g(`action.close`)} Focus Mode`,description:g(`tooltip.focus_mode`),action:()=>r(!1)},{id:`toggle-sidebar`,label:g(`command.shortcut.toggle_sidebar`),description:g(i?`action.open`:`action.close`),action:()=>a(!i)},{id:`toggle-terminal`,label:g(`terminal.title`),description:g(o?`action.close`:`action.open`),action:()=>{s(!o),!o&&c===0&&l(200)}},{id:`show-terminal`,label:`${g(`action.open`)} ${g(`terminal.title`)}`,description:g(`command.shortcut.toggle_terminal`),action:()=>{s(!0),c===0&&l(200)}},{id:`hide-terminal`,label:`${g(`action.close`)} ${g(`terminal.title`)}`,description:g(`command.shortcut.toggle_terminal`),action:()=>s(!1)}),p.forEach(e=>{let t=Ug(e)||e.id;y.push({id:`switch-workspace-${e.id}`,label:`${g(`workspace.title`)}: ${t}`,description:e.path||e.id,action:()=>{f(e.id),m!==`/workspace`&&h(`/workspace`)}})}),u&&y.push({id:`go-home`,label:g(`action.back`),description:g(`workspace.no_workspace`),action:()=>{d(null),h(`/`)}}),y}var ry={minHeight:`auto`,padding:0,gap:`var(--sp-5)`};function iy(){let e=Z(),t=Qt(),n=Yt(),r=Br()===`mobile`;return(0,X.jsx)(`div`,{className:`welcome-container ${r?`welcome-container--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`welcome-card ${r?`welcome-card--mobile`:``}`,children:[(0,X.jsx)(`div`,{className:`welcome-card__hero`,children:(0,X.jsx)(Sh,{style:ry,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`not_found.kicker`)}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`not_found.title`)})]}),description:(0,X.jsx)(`div`,{className:`welcome-content`,children:(0,X.jsx)(`p`,{className:`welcome-body meta-text`,children:e(`not_found.description`)})})})}),(0,X.jsx)(`div`,{className:`welcome-card__actions`,children:(0,X.jsx)(`button`,{className:`welcome-btn`,onClick:()=>t(`/`),children:(0,X.jsx)(`span`,{children:e(`not_found.go_home`)})})}),(0,X.jsx)(`div`,{className:`welcome-card__panel`,children:(0,X.jsxs)(`div`,{className:`auth-status-panel`,children:[(0,X.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`not_found.path_label`)}),(0,X.jsx)(`p`,{className:`auth-status-detail`,children:n.pathname})]})})]})})}var ay=Zr(`ui.notificationPreferences`,{enabled:!0,soundEnabled:!0}),oy=V([]),sy=V(null,(e,t,n)=>{let r=`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,i={...n,id:r,createdAt:Date.now()};t(oy,e=>[...e.slice(-4),i])}),cy=V(null,(e,t,n)=>{t(oy,e=>e.filter(e=>e.id!==n))});function ly(e){let{workspaceId:t,sessionId:n,setPendingFocus:r,setActiveWorkspaceId:i,persistLastViewedTarget:a,navigate:o}=e;if(typeof window>`u`)return;a?.({workspaceId:t,sessionId:n}),i(t),r(n);let s=`/workspace`;window.location.pathname!==s&&(o?o(s):(window.history.pushState({},``,s),window.dispatchEvent(new PopStateEvent(`popstate`))))}function uy({toast:e}){let t=W(cy),n=W(jp),r=W(to),i=Qt(),a=Xg(),o=e.duration??5e3;(0,H.useEffect)(()=>{if(o<=0)return;let n=setTimeout(()=>t(e.id),o);return()=>clearTimeout(n)},[e.id,o,t]);let s=(0,H.useCallback)(()=>{e.workspaceId&&e.sessionId?ly({workspaceId:e.workspaceId,sessionId:e.sessionId,setPendingFocus:r,setActiveWorkspaceId:n,persistLastViewedTarget:e=>{a(e)},navigate:i}):e.workspaceId&&(n(e.workspaceId),window.location.pathname!==`/workspace`&&i(`/workspace`)),t(e.id)},[e.workspaceId,e.sessionId,i,t,n,r]);return(0,X.jsx)(kg,{description:e.body,onClick:e.workspaceId?s:void 0,onDismiss:()=>t(e.id),title:e.title,tone:e.kind})}function dy(){let e=U(oy),t=Br()===`mobile`;return e.length===0?null:(0,X.jsx)(Og,{"aria-live":`polite`,mobile:t,children:e.map(e=>(0,X.jsx)(uy,{toast:e},e.id))})}var fy=4e3,py=new Set([`running`]),my=new Set([`idle`,`ended`]);function hy(e,t,n,r,i){return n===e?r===`mobile`?i===t:!0:!1}function gy(e,t){return e?`system`:t?`none`:`toast`}function _y(){return!!(typeof document<`u`&&document.hidden)}async function vy(){try{let e=new Audio(`/task-complete.wav`);e.volume=.75,await e.play();return}catch{}try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e,n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type=`sine`,r.frequency.value=880,i.gain.setValueAtTime(.25,n),i.gain.exponentialRampToValueAtTime(.001,n+.3),r.connect(i).connect(t.destination),r.start(n),r.stop(n+.3);let a=t.createOscillator(),o=t.createGain();a.type=`sine`,a.frequency.value=660,o.gain.setValueAtTime(.25,n+.15),o.gain.exponentialRampToValueAtTime(.001,n+.5),a.connect(o).connect(t.destination),a.start(n+.15),a.stop(n+.5),setTimeout(()=>t.close(),2e3)}catch{}}function yy(e){if(`Notification`in window&&Notification.permission===`granted`)try{let t=new Notification(e.title,{body:e.body,tag:e.tag,silent:!0});t.onclick=()=>{window.focus(),ly({workspaceId:e.workspaceId,sessionId:e.sessionId,setActiveWorkspaceId:e.setActiveWorkspaceId,persistLastViewedTarget:e.persistLastViewedTarget,setPendingFocus:e.setPendingFocus}),t.close()}}catch{}}function by(){let e=U(Vp),t=U(xp),n=U(Op),r=U(ay),i=W(ay),a=U(zp),o=U(ro),s=W(jp),c=W(sy),l=W(to),u=Z(),d=Br(),f=Xg(),p=ve(),m=(0,H.useRef)(new Map);(0,H.useEffect)(()=>{if(t!==`connected`)return;let e=!1;return(async()=>{let t=await n(`settings.get`,{});e||!t.ok||!t.data||i({enabled:typeof t.data[`notifications.enabled`]==`boolean`?t.data[`notifications.enabled`]:!0,soundEnabled:typeof t.data[`notifications.soundEnabled`]==`boolean`?t.data[`notifications.soundEnabled`]:!0})})(),()=>{e=!0}},[t,n,i]),(0,H.useEffect)(()=>{let t=m.current;for(let n of Object.values(e)){let e=t.get(n.id),i=e?.state,m=n.state,h=py.has(m)&&(!e||!py.has(e.state)),g={state:m,activeSince:h?Date.now():e?.activeSince??(py.has(m)?Date.now():null),notifiedForTurn:h?!1:e?.notifiedForTurn??!1};if(t.set(n.id,g),!r.enabled||!i||!py.has(i)||!my.has(m)||g.notifiedForTurn)continue;if(m===`idle`&&g.activeSince!==null&&Date.now()-g.activeSince<fy){g.notifiedForTurn=!0;continue}g.notifiedForTurn=!0;let _=_y(),v=gy(_,_?!1:hy(n.workspaceId,n.id,a,d,o));if(v===`none`)continue;let y=u(`notification.session_completed_title`,{session:n.title?.trim()||xy(n.id)}),b=p.get(Mp)[n.workspaceId],x=[],S=Hg(n.providerId).replace(/\s+/g,` `).trim();S&&x.push(S);let C=Ug(b??null).replace(/\s+/g,` `).trim();C&&x.push(C);let w=g.activeSince===null?null:Date.now()-g.activeSince,T=w===null?``:Gg(w);T&&x.push(T);let E=x.join(` · `),D=u(m===`ended`?`notification.session_ended_hint`:`notification.session_turn_completed`),O=[];E&&O.push(E),O.push(D);let k=O.join(`
|
|
102
|
+
- 把 P95 响应时间压到 100ms 以内`,objective_helper:`越具体、越可衡量,评估效果越好。建议包含完成条件。`,evaluator:`评估方`,evaluator_helper:`用于评估进度并生成下一步指引的 provider,与执行方可不相同。`,evaluator_model:`评估模型`,evaluator_model_placeholder:`可选模型覆盖,例如 o3 或 gpt-5`,evaluator_model_helper:`留空则沿用该 provider 当前默认的 supervisor 评估模型逻辑。`,max_supervision_count:`最大监督次数`,max_supervision_count_helper:`填 0 表示不设上限。若目标已达成,评估仍可提前停止。`,scheduled_at_placeholder:`选择执行时间`,scheduled_at:`定时执行时间`,scheduled_at_helper:`指定首次执行时间。到达后开始执行评估,之后每轮对话结束自动触发。留空则每轮对话结束自动触发评估。`},action:{enable:`启用 Supervisor`,enable_objective:`启用目标`,details:`Supervisor 详情`,edit_objective:`编辑 Supervisor`,pause:`暂停`,resume:`恢复`,trigger:`触发评估`,pause_failed:`暂停失败`,resume_failed:`恢复失败`,trigger_failed:`触发评估失败`},dialog:{enable:{title:`启用 Supervisor`,subtitle:`描述一个目标,Supervisor 会在每轮结束后自动评估并提示下一步`,confirm:`启用`},edit:{title:`编辑 Supervisor`,subtitle:`调整目标描述,并在需要时恢复之前的记忆快照`,confirm:`保存`,reset_confirm_title:`确认保存并重置当前 Supervisor 进度?`,reset_confirm_description:`修改目标描述后,Supervisor 会重新评估目标。当前 target 的既有 supervisor 记忆和进度会被重置。`},restore:{open:`从已有记忆恢复`,hint:`复用现有 target 目录里的 supervisor 记忆到当前会话。`,title:`恢复 Supervisor 记忆`,subtitle:`选择一个可恢复的记忆快照,并将其关联到当前会话的 supervisor。`,back:`返回详情`,confirm:`恢复`,empty:`没有找到可恢复的 supervisor 记忆。`,empty_hint:`只有仍然可读的 target 目录记忆才会出现在这里。`,cycle_count:`{count} 次评估`,updated_at:`更新于 {time}`},details:{title:`Supervisor 详情`}}},command:{palette:`命令面板`,no_results:`未找到结果`,shortcut:{save:`保存`,save_all:`保存全部`,search:`搜索`,search_files:`搜索文件`,command_palette:`命令面板`,toggle_focus:`切换专注模式`,toggle_sidebar:`切换侧边栏`,toggle_terminal:`切换终端面板`}},notification:{success:`成功`,error:`错误`,warning:`警告`,info:`信息`,session_turn_completed:`会话回合完成`,file_saved:`文件已保存`,committed:`已提交`,session_completed_title:`{session} 已完成`,session_completed_body:`Agent 会话已完成执行`,session_ended:`会话已结束`,session_ended_hint:`会话已停止运行`},error:{unknown:`未知错误`,network:`网络错误`,not_found:`未找到`,permission_denied:`权限不足`,validation:`数据验证失败`,conflict:`资源冲突`},welcome:{kicker:`本地 AI 编码工作台`,title:`先打开工作区,再启动 AI 编码会话`,description:`先选择一个本地项目目录。打开工作区后,你就可以在同一个界面里启动 Claude Code 或 Codex,同时查看文件、Git 变更和终端输出。`,workflow_title:`使用步骤`,step_1_label:`第 1 步`,step_1_title:`打开你的项目目录`,step_1_detail:`先选择一个本地目录,作为当前工作区。`,step_2_label:`第 2 步`,step_2_title:`启动 Claude 或 Codex`,step_2_detail:`进入工作区后,再为当前项目启动一个 AI 会话。`,settings_hint:`如果要先配置 Provider,可以先去设置。`,support_title:`为什么在这里使用`,features:{git_tools:{title:`并排查看代码和 Git 变更`,description:`在 Agent 旁边直接查看文件和改动,不用在多个工具之间来回切换。`},terminals:{title:`在同一工作区运行命令`,description:`需要手动操作时,可以直接在集成终端里配合 AI 会话执行命令。`}}},diagnostics:{title:`诊断`,settings_hint:`诊断运行环境,便于排查和恢复问题。`,load_failed:`当前无法刷新诊断结果。`,loading_description:`正在检查这次任务真正相关的环境项。`,status:{checking:`检查中`,ready:`已就绪`,needs_attention:`需要处理`},actions:{retry_workspace:`重试打开工作区`,continue_session:`继续启动会话`,continue_phone:`继续在手机上打开`,recheck:`重新检查`,open_diagnostics:`打开诊断`,copy_details:`复制错误详情`,copied:`已复制`,install_provider:`安装 Provider`},details:{workspace:`工作区`,provider:`Provider`,missing_commands:`缺失命令`,missing_prerequisites:`缺失前置依赖`,current_version:`当前版本`},context:{workspace_open:{title:`暂时无法打开工作区`,description:`继续之前,需要先处理几个问题。`},session_start:{title:`当前会话还不能启动`,description:`我们发现了一个会阻塞启动的问题。`},mobile_continue:{title:`继续到手机前还需修复几项`,description:`手机继续使用这条链路里还有一些前置问题。`},manual_check:{title:`环境诊断`,description:`查看当前环境状态,并在需要时重新检查。`}},checks:{workspace_selection_missing:{title:`还没有选择工作区路径`,description:`先选择一个目录,再继续重试。`},workspace_path_ready:{title:`工作区路径可用`,description:`所选目录当前可以访问。`},workspace_path_not_found:{title:`工作区路径不存在`,description:`之前选择的目录当前已经找不到了。`},workspace_path_unreadable:{title:`工作区路径暂时不可读`,description:`目录存在,但当前还不能正常打开。`},session_workspace_ready:{title:`工作区已就绪`,description:`当前工作区可以用于启动会话。`},session_workspace_missing:{title:`工作区缺失`,description:`先选择或重新打开工作区,再启动会话。`},git_ready:{title:`Git 已就绪`,description:`当前环境已安装 Git,且可以正常使用。`},git_missing:{title:`Git 缺失`,description:`使用工作区仓库相关能力前,需要先安装 Git。`},nodejs_ready:{title:`Node.js 已就绪`,description:`当前环境已安装 Node.js,且可以正常使用。`},nodejs_missing:{title:`Node.js 缺失`,description:`运行本地 JavaScript 和包管理任务前,需要先安装 Node.js。`},provider_runtime_ready:{title:`{provider} 已就绪`,description:`{provider} 现在可以直接启动。`},provider_cli_missing:{title:`{provider} CLI 缺失`,description:`启动前还没有安装所需的 provider 命令。`},provider_prerequisite_missing:{title:`{provider} 前置依赖缺失`,description:`需要先补齐前置依赖,provider 才能运行。`},provider_unknown:{title:`无法识别 Provider`,description:`当前设置里无法解析这个 provider。`},server_auth_ready:{title:`密码保护已开启`,description:`当前服务端已经配置认证。`},server_auth_not_required:{title:`密码保护未开启`,description:`当前服务端没有要求认证。`},mobile_host_ready:{title:`网络地址可用于手机继续`,description:`当前 host 看起来适合手机访问。`},mobile_host_local_only:{title:`当前 host 仅限本机`,description:`手机继续需要可在局域网访问的地址,而不是 localhost。`},mobile_auth_disabled:{title:`手机继续前需要认证`,description:`请先开启认证,再继续到手机。`}}},not_found:{kicker:`路由不存在`,title:`页面不存在`,description:`你访问的路径不在当前工作台的前端路由中。`,path_label:`请求路径`,go_home:`返回首页`},confirm:{save_changes:`是否保存更改?`,discard_changes:`确定要放弃更改吗?`,delete_file:`确定要删除此文件吗?`,stop_session:`确定要停止会话吗?`,close_workspace:`确定要关闭工作区吗?`},placeholder:{search:`输入关键词搜索...`,command:`输入命令名称或快捷键...`,commit_message:`输入提交信息`},tooltip:{focus_mode:`专注模式:隐藏侧边栏和底部面板`,split_horizontal:`水平分割面板`,split_vertical:`垂直分割面板`,close_pane:`关闭面板`,new_workspace:`新建工作区`,quick_actions:`快捷操作`,enter_fullscreen:`进入全屏`,exit_fullscreen:`退出全屏`,show_terminal:`显示终端`,hide_terminal:`隐藏终端`,show_files:`显示文件`,hide_files:`隐藏文件`},time:{just_now:`刚刚`,seconds_ago:`{count} 秒前`,minutes_ago:`{count} 分钟前`,hours_ago:`{count} 小时前`,days_ago:`{count} 天前`},fencing:{observer_mode:`只读模式 — 另一个标签页正在控制`,takeover:`接管控制`,takeover_failed:`接管失败 — 控制器仍然活跃`}},om={zh:{name:`中文`,data:am},en:{name:`English`,data:im}};function sm(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return typeof r==`string`?r:void 0}function cm(e){let t=om[e]?.data??am;function n(e,n){let r=sm(t,e);if(r===void 0)return console.warn(`Translation missing for key: ${e}`),e;if(n)for(let[e,t]of Object.entries(n))r=r.replace(RegExp(`\\{${e}\\}`,`g`),String(t));return r}return n}var lm=V(e=>cm(e(Za)));function um(e,t){let n=Date.now()-e,r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24),s=new Intl.RelativeTimeFormat(t===`zh`?`zh-CN`:`en-US`,{numeric:`auto`});return o>0?s.format(-o,`day`):a>0?s.format(-a,`hour`):i>0?s.format(-i,`minute`):s.format(-r,`second`)}function dm(e,t,n){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,...n}).format(e)}function Z(){return U(lm)}function fm({title:e,body:t,onClose:n,kicker:r,onBack:i,footer:a,headerAction:o,bodyClassName:s,contentClassName:c,fullscreen:l=!1,backLabel:u}){let d=Z(),f=i??n,p=u??d(`action.back`);return(0,X.jsxs)(`div`,{className:`mobile-sheet-layer`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet-layer__backdrop`,"aria-label":d(`mobile.sheet.dismiss`),onClick:n}),(0,X.jsxs)(`section`,{className:Y(`mobile-sheet`,l?`mobile-sheet--fullscreen`:null,c),"aria-label":d(`mobile.sheet.region`,{title:e}),role:`region`,children:[l?null:(0,X.jsx)(`div`,{className:`mobile-sheet__handle`,"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`mobile-sheet__header`,children:(0,X.jsx)(rm,{title:e,kicker:r,onBack:f,backLabel:p,rightSlot:o,titleAs:`h2`})}),(0,X.jsx)(`div`,{className:Y(`mobile-sheet__body`,s),children:t}),a?(0,X.jsx)(`div`,{className:`mobile-sheet__footer`,children:a}):null]})]})}var pm={badge:`_badge_1yvj5_1`};function mm({className:e,count:t,max:n=99,...r}){if(t<=0)return null;let i=t>n?`${n}+`:String(t);return(0,X.jsx)(`span`,{...r,className:Y(pm.badge,`topbar-unread`,e),children:i})}var hm={btn:`_btn_ovn01_1`,primary:`_primary_ovn01_36`,secondary:`_secondary_ovn01_47`,ghost:`_ghost_ovn01_62`,danger:`_danger_ovn01_75`,sm:`_sm_ovn01_81`,lg:`_lg_ovn01_91`,label:`_label_ovn01_98`,icon:`_icon_ovn01_103`,loading:`_loading_ovn01_108`,spinner:`_spinner_ovn01_112`},gm={primary:hm.primary??``,secondary:hm.secondary??``,ghost:hm.ghost??``,danger:hm.danger??``},_m={sm:hm.sm,md:void 0,lg:hm.lg},vm={primary:`btn-primary`,secondary:`btn-secondary`,ghost:`btn-ghost`,danger:`btn-danger`},ym={sm:`btn-sm`,md:void 0,lg:`btn-lg`},bm=({children:e,leadingIcon:t,loading:n,trailingIcon:r})=>(0,X.jsxs)(X.Fragment,{children:[n?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Y(hm.spinner,`animate-spin`)}):null,t?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:hm.icon,children:t}):null,(0,X.jsx)(`span`,{className:hm.label,children:e}),r?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:hm.icon,children:r}):null]}),Q=e=>{let{as:t=`button`,children:n,className:r,variant:i=`secondary`,size:a=`md`,loading:o=!1,leadingIcon:s,trailingIcon:c}=e,l=Y(hm.btn,gm[i],_m[a],`btn`,vm[i],ym[a],o?hm.loading:void 0,r),u=(0,X.jsx)(bm,{children:n,leadingIcon:s,loading:o,trailingIcon:c});if(t===`a`){let{as:t,children:n,className:r,leadingIcon:i,loading:a,size:s,trailingIcon:c,variant:d,...f}=e;return(0,X.jsx)(`a`,{...f,"aria-busy":o?`true`:void 0,className:l,children:u})}let{as:d,children:f,className:p,disabled:m,leadingIcon:h,loading:g,size:_,trailingIcon:v,type:y,variant:b,...x}=e;return(0,X.jsx)(`button`,{...x,"aria-busy":o?`true`:void 0,className:l,disabled:m||o,type:y??`button`,children:u})},xm={root:`_root_x2vbk_1`,ghost:`_ghost_x2vbk_30`,filled:`_filled_x2vbk_40`,sm:`_sm_x2vbk_51`,lg:`_lg_x2vbk_57`,icon:`_icon_x2vbk_63`},Sm={ghost:xm.ghost,filled:xm.filled},Cm={sm:xm.sm,md:void 0,lg:xm.lg},wm={ghost:`btn-ghost`,filled:`btn-secondary`},Tm={sm:`btn-sm`,md:void 0,lg:`btn-lg`},Em=({"aria-label":e,className:t,icon:n,size:r=`md`,type:i,variant:a=`ghost`,...o})=>(0,X.jsx)(`button`,{...o,"aria-label":e,className:Y(xm.root,Sm[a],Cm[r],`btn`,wm[a],Tm[r],t),type:i??`button`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:xm.icon,children:n})}),Dm={overlay:`_overlay_1rr4b_1`,card:`_card_1rr4b_13`,sm:`_sm_1rr4b_28`,md:`_md_1rr4b_32`,lg:`_lg_1rr4b_36`,full:`_full_1rr4b_41`,header:`_header_1rr4b_46`,dialogHeader:`_dialogHeader_1rr4b_56`,title:`_title_1rr4b_97`,body:`_body_1rr4b_109`,footer:`_footer_1rr4b_118`},Om=(0,H.createContext)(null),km={sm:Dm.sm,md:Dm.md,lg:Dm.lg,full:Dm.full},Am={sm:void 0,md:void 0,lg:`modal-card-lg`,full:void 0};function jm({children:e,className:t,dismissible:n=!0,initialFocus:r,onOpenChange:i,open:a,size:o=`md`}){let s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useId)(),u=(0,H.useMemo)(()=>({titleId:l}),[l]);return(0,H.useLayoutEffect)(()=>{if(!a)return;c.current=document.activeElement;let e=s.current;if(e)return Xp(e,r).focus(),()=>{Qp(c.current),c.current=null}},[r,a]),a?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{className:Y(Dm.overlay,`modal-overlay`),onClick:e=>{n&&Gp(e)&&i(!1)},children:(0,X.jsx)(Om.Provider,{value:u,children:(0,X.jsx)(`div`,{"aria-labelledby":l,"aria-modal":`true`,className:Y(Dm.card,km[o],`modal-card`,Am[o],t),onKeyDown:e=>{if(Kp(e)){n&&(e.preventDefault(),e.stopPropagation(),i(!1));return}Zp(e.currentTarget,e)},ref:s,role:`dialog`,tabIndex:-1,children:e})})})}):null}function Mm({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.header,`modal-header`,e)})}function Nm({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.header,Dm.dialogHeader,`modal-header`,`dialog-header`,e)})}function Pm({className:e,...t}){let n=(0,H.useContext)(Om),r=(0,H.useId)(),i=n?.titleId??r;return(0,X.jsx)(`h2`,{...t,className:Y(Dm.title,`modal-title`,e),id:i})}function Fm({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.body,`modal-body`,e)})}function Im({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Y(Dm.footer,`modal-footer`,e)})}var Lm={root:`_root_1fg74_1`};function $({className:e,decorative:t=!0,role:n,semantic:r,size:i=14,...a}){let o=va(U(Xa),r),s=o.Icon;return(0,X.jsx)(`span`,{...a,"aria-hidden":t?!0:void 0,className:Y(Lm.root,`themed-icon`,`themed-icon--tone-${o.tone}`,`themed-icon--surface-${o.surface}`,e),"data-icon-semantic":r,"data-testid":a[`data-testid`]??`themed-icon`,role:t?void 0:n??`img`,children:(0,X.jsx)(s,{size:i,strokeWidth:o.strokeWidth})})}var Rm={body:`_body_261wh_1`,headerLeading:`_headerLeading_261wh_9`,headerCopy:`_headerCopy_261wh_17`,headerIcon:`_headerIcon_261wh_22`,titleDanger:`_titleDanger_261wh_31`,iconDanger:`_iconDanger_261wh_35`},zm={default:`primary`,danger:`danger`};function Bm({cancelDisabled:e=!1,cancelText:t,className:n,closeDisabled:r=!1,closeLabel:i=`Close`,confirmButtonProps:a,confirmDisabled:o=!1,confirmText:s,description:c,dismissible:l=!0,initialFocus:u,onConfirm:d,onOpenChange:f,open:p,title:m,tone:h=`default`}){let{className:g,disabled:_,...v}=a??{};return(0,X.jsxs)(jm,{className:n,dismissible:l,initialFocus:u,onOpenChange:f,open:p,children:[(0,X.jsxs)(Mm,{children:[h===`danger`?(0,X.jsxs)(`div`,{className:Y(`confirmDialogHeaderLeading`,Rm.headerLeading),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Y(`confirmDialogHeaderIcon`,Rm.headerIcon,Rm.iconDanger),children:(0,X.jsx)($,{semantic:`state.warning`,size:16})}),(0,X.jsx)(`div`,{className:Y(`confirmDialogHeaderCopy`,Rm.headerCopy),children:(0,X.jsx)(Pm,{className:Rm.titleDanger,children:m})})]}):(0,X.jsx)(Pm,{children:m}),l||r?(0,X.jsx)(Em,{"aria-label":i,className:`modal-close`,disabled:r,icon:(0,X.jsx)(pa,{size:14}),onClick:()=>f(!1),size:`sm`}):null]}),c?(0,X.jsx)(Fm,{className:Rm.body,children:c}):null,(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{disabled:e,onClick:()=>f(!1),children:t}),(0,X.jsx)(Q,{...v,className:g,disabled:o||_,onClick:d,variant:zm[h],children:s})]})]})}var Vm={triggerWrapper:`_triggerWrapper_upi96_1`,content:`_content_upi96_6`},Hm=8,Um=8;function Wm(e){return(0,H.isValidElement)(e)}function Gm({children:e,content:t,title:n,open:r,onOpenChange:i,forceMode:a=`auto`,placement:o=`bottom-start`,contentClassName:s,sheetBodyClassName:c}){let l=Br(),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(null),p=(0,H.useId)(),m=a===`desktop`?`desktop`:a===`mobile`?`mobile`:l,h=r&&m===`desktop`,g=r&&m===`mobile`,[_,v]=(0,H.useState)({left:Hm,top:Hm,visibility:`hidden`}),y=H.Children.only(e);if((0,H.useLayoutEffect)(()=>{if(r)return f.current=document.activeElement,()=>{Qp(f.current),f.current=null}},[r]),(0,H.useLayoutEffect)(()=>{if(!h||!u.current||!d.current){v(e=>e.visibility===`hidden`?e:{...e,visibility:`hidden`});return}let e=()=>{if(!u.current||!d.current)return;let e=u.current.getBoundingClientRect(),t=d.current.getBoundingClientRect(),n=o===`bottom-end`?e.right-t.width:e.left,r=Math.max(Hm,window.innerWidth-t.width-Hm),i=Math.min(r,Math.max(Hm,n)),a=e.bottom+Um;v({left:i,top:a+t.height<=window.innerHeight-Hm?a:Math.max(Hm,e.top-t.height-Um),visibility:`visible`})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[h,o]),(0,H.useLayoutEffect)(()=>{!h||!d.current||d.current.focus()},[h]),(0,H.useEffect)(()=>{if(!h)return;let e=e=>{e.target instanceof Node&&(u.current?.contains(e.target)||d.current?.contains(e.target)||i(!1))},t=e=>{Kp(e)&&(e.preventDefault(),i(!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[h,i]),!Wm(y))throw Error(`Popover requires a single trigger React element.`);let b=(0,H.cloneElement)(y,{"aria-controls":h?p:void 0,"aria-expanded":r,"aria-haspopup":`dialog`,onClick:e=>{y.props.onClick?.(e),e.defaultPrevented||i(!r)},onKeyDown:e=>{if(y.props.onKeyDown?.(e),!e.defaultPrevented){if(e.key===`ArrowDown`&&!r){e.preventDefault(),i(!0);return}Kp(e)&&r&&(e.preventDefault(),i(!1))}}});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:Vm.triggerWrapper,ref:u,children:b}),h?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{"aria-label":n,"aria-modal":`false`,className:Y(Vm.content,s),id:p,onKeyDown:e=>{Kp(e)&&(e.preventDefault(),e.stopPropagation(),i(!1))},ref:d,role:`dialog`,style:{left:`${_.left}px`,top:`${_.top}px`,visibility:_.visibility},tabIndex:-1,children:t})}):null,g?(0,X.jsx)(fm,{body:(0,X.jsx)(`div`,{children:t}),bodyClassName:c,onClose:()=>i(!1),title:n}):null]})}var Km={trigger:`_trigger_v9p4r_1`,value:`_value_v9p4r_11`,icon:`_icon_v9p4r_19`,content:`_content_v9p4r_24`,header:`_header_v9p4r_31`,title:`_title_v9p4r_37`,body:`_body_v9p4r_44`,calendar:`_calendar_v9p4r_50`,time:`_time_v9p4r_63`,actions:`_actions_v9p4r_75`,action:`_action_v9p4r_75`,popoverContent:`_popoverContent_v9p4r_112`,sheetBody:`_sheetBody_v9p4r_116`,calendarGrid:`_calendarGrid_v9p4r_124`,calendarHeader:`_calendarHeader_v9p4r_130`,calendarTitle:`_calendarTitle_v9p4r_137`,calendarNav:`_calendarNav_v9p4r_144`,calendarWeekdays:`_calendarWeekdays_v9p4r_165`,calendarWeekday:`_calendarWeekday_v9p4r_165`,calendarDays:`_calendarDays_v9p4r_181`,calendarDay:`_calendarDay_v9p4r_181`,calendarDayToday:`_calendarDayToday_v9p4r_209`,calendarDaySelected:`_calendarDaySelected_v9p4r_214`,calendarDayDisabled:`_calendarDayDisabled_v9p4r_223`,calendarDayEmpty:`_calendarDayEmpty_v9p4r_229`,timeSelector:`_timeSelector_v9p4r_234`,timeField:`_timeField_v9p4r_240`,timeLabel:`_timeLabel_v9p4r_247`,timeSeparator:`_timeSeparator_v9p4r_254`,timeSection:`_timeSection_v9p4r_262`,timeInput:`_timeInput_v9p4r_272`},qm=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`],Jm=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`];function Ym(e,t){return new Date(e,t+1,0).getDate()}function Xm(e,t){return new Date(e,t,1).getDay()}function Zm(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Qm(e,t,n){return!!(t&&e<t||n&&e>n)}function $m({year:e,month:t,selectedDate:n,minDate:r,maxDate:i,onDateSelect:a,onMonthChange:o}){let s=Z(),c=Ym(e,t),l=Xm(e,t),u=()=>{t===0?o(e-1,11):o(e,t-1)},d=()=>{t===11?o(e+1,0):o(e,t+1)},f=n=>{let o=new Date(e,t,n);Qm(o,r,i)||a(o)},p=[];for(let e=0;e<l;e++)p.push((0,X.jsx)(`div`,{className:Km.calendarDayEmpty},`empty-${e}`));for(let a=1;a<=c;a++){let o=new Date(e,t,a),s=n&&Zm(o,n),c=Qm(o,r,i),l=Zm(o,new Date);p.push((0,X.jsx)(`button`,{type:`button`,disabled:c,className:Y(Km.calendarDay,s&&Km.calendarDaySelected,l&&!s&&Km.calendarDayToday,c&&Km.calendarDayDisabled),onClick:()=>f(a),children:a},a))}return(0,X.jsxs)(`div`,{className:Km.calendarGrid,children:[(0,X.jsxs)(`div`,{className:Km.calendarHeader,children:[(0,X.jsx)(`button`,{type:`button`,className:Km.calendarNav,onClick:u,"aria-label":s(`datetime.prev_month`),children:(0,X.jsx)(vi,{size:16})}),(0,X.jsxs)(`span`,{className:Km.calendarTitle,children:[s(`datetime.${Jm[t]}`),` `,e]}),(0,X.jsx)(`button`,{type:`button`,className:Km.calendarNav,onClick:d,"aria-label":s(`datetime.next_month`),children:(0,X.jsx)(yi,{size:16})})]}),(0,X.jsx)(`div`,{className:Km.calendarWeekdays,children:qm.map(e=>(0,X.jsx)(`div`,{className:Km.calendarWeekday,children:s(`datetime.${e}`)},e))}),(0,X.jsx)(`div`,{className:Km.calendarDays,children:p})]})}var eh={input:`_input_xkics_1`,sm:`_sm_xkics_29`,lg:`_lg_xkics_37`,invalid:`_invalid_xkics_42`},th={sm:eh.sm,md:void 0,lg:eh.lg},nh={sm:`input-sm`,md:void 0,lg:`input-lg`},rh=(0,H.forwardRef)(function({className:e,htmlSize:t,invalid:n,size:r=`md`,...i},a){let o=n===void 0?i[`aria-invalid`]:n?`true`:`false`;return(0,X.jsx)(`input`,{...i,ref:a,size:t,"aria-invalid":o,className:Y(eh.input,th[r],`input`,nh[r],n?eh.invalid:void 0,e)})});function ih({hour:e,minute:t,onHourChange:n,onMinuteChange:r,disabled:i=!1}){let a=Z(),o=(0,H.useId)(),s=(0,H.useId)(),c=String(e).padStart(2,`0`),l=String(t).padStart(2,`0`),u=e=>{let t=parseInt(e,10);!isNaN(t)&&t>=0&&t<=23&&n(t)},d=e=>{let t=parseInt(e,10);!isNaN(t)&&t>=0&&t<=59&&r(t)};return(0,X.jsxs)(`div`,{className:Km.timeSelector,children:[(0,X.jsxs)(`div`,{className:Km.timeField,children:[(0,X.jsx)(`label`,{htmlFor:o,className:Km.timeLabel,children:a(`datetime.hour`)}),(0,X.jsx)(rh,{id:o,type:`number`,min:0,max:23,"aria-label":a(`datetime.hour`),size:`sm`,value:c,onChange:e=>u(e.target.value),disabled:i,className:Km.timeInput})]}),(0,X.jsx)(`span`,{className:Km.timeSeparator,children:`:`}),(0,X.jsxs)(`div`,{className:Km.timeField,children:[(0,X.jsx)(`label`,{htmlFor:s,className:Km.timeLabel,children:a(`datetime.minute`)}),(0,X.jsx)(rh,{id:s,type:`number`,min:0,max:59,"aria-label":a(`datetime.minute`),size:`sm`,value:l,onChange:e=>d(e.target.value),disabled:i,className:Km.timeInput})]})]})}function ah(e){if(!e)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=Number(t[4]),o=Number(t[5]);return[n,r,i,a,o].some(Number.isNaN)?null:new Date(n,r-1,i,a,o)}function oh(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}function sh(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function ch(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes())}function lh(e,t){return new Date(e,t+1,0).getDate()}function uh(e,t,n){return Math.min(n,lh(e,t))}function dh(e){return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes()}}function fh(e){return new Date(e.year,e.month,e.day,e.hour,e.minute)}function ph(e,t,n){let r=e.getTime();return t!==void 0&&r<t?new Date(t):n!==void 0&&r>n?new Date(n):e}function mh(e,t,n){let r=e.getTime();return t!==void 0&&r<t||n!==void 0&&r>n}var hh={sm:`input-sm`,md:void 0,lg:`input-lg`};function gh({value:e,onValueChange:t,label:n,placeholder:r,disabled:i=!1,clearable:a=!1,minDate:o,maxDate:s,className:c,size:l=`md`,invalid:u=!1,"aria-describedby":d}){let f=Z(),p=U(Za),m=Br(),h=(0,H.useId)(),[g,_]=(0,H.useState)(!1),v=o?ch(o).getTime():void 0,y=s?ch(s).getTime():void 0,b=e=>dh(ah(e)||ph(ch(new Date),v,y)),[x,S]=(0,H.useState)(()=>b(e));(0,H.useEffect)(()=>{S(b(e))},[e]);let C=(0,H.useCallback)(e=>{S(t=>({...t,year:e.getFullYear(),month:e.getMonth(),day:e.getDate()}))},[]),w=(0,H.useCallback)((e,t)=>{S(n=>({...n,year:e,month:t,day:uh(e,t,n.day)}))},[]),T=(0,H.useCallback)(e=>{S(t=>({...t,hour:e}))},[]),E=(0,H.useCallback)(e=>{S(t=>({...t,minute:e}))},[]),D=mh(fh(x),v,y),O=(0,H.useCallback)(()=>{let e=fh(x);mh(e,v,y)||(t(oh(e)),_(!1))},[x,y,v,t]),k=(0,H.useCallback)(()=>{t(``),_(!1)},[t]),A=ah(e),j=A?dm(A.getTime(),p):r??f(`datetime.select_date`),M=m===`mobile`,N=Y(`input`,hh[l],Km.trigger,u?`input-invalid`:void 0,c),P=(0,X.jsxs)(`button`,{id:h,type:`button`,disabled:i,"aria-haspopup":M?`dialog`:`menu`,"aria-expanded":g,"aria-label":n,"aria-describedby":d,className:N,onClick:()=>_(!0),children:[(0,X.jsx)(`span`,{className:Km.value,children:j}),(0,X.jsx)(hi,{size:16,className:Km.icon,"aria-hidden":`true`})]}),F=new Date(x.year,x.month,x.day),ee=o?sh(o):void 0,I=s?sh(s):void 0,L=(0,X.jsxs)(`div`,{className:Km.content,children:[(0,X.jsxs)(`div`,{className:Km.body,children:[(0,X.jsx)($m,{year:x.year,month:x.month,selectedDate:F,minDate:ee,maxDate:I,onDateSelect:C,onMonthChange:w}),(0,X.jsxs)(`div`,{className:Km.timeSection,children:[(0,X.jsx)(`span`,{className:Km.timeLabel,children:f(`datetime.select_time`)}),(0,X.jsx)(ih,{hour:x.hour,minute:x.minute,onHourChange:T,onMinuteChange:E})]})]}),(0,X.jsxs)(`div`,{className:Km.actions,children:[a?(0,X.jsx)(`button`,{type:`button`,className:Km.action,onClick:k,children:f(`datetime.clear`)}):null,(0,X.jsx)(`button`,{type:`button`,className:Km.action,onClick:O,disabled:D,children:f(`datetime.confirm`)})]})]});return M?(0,X.jsxs)(X.Fragment,{children:[P,g?(0,X.jsx)(fm,{title:n,body:L,bodyClassName:Km.sheetBody,onClose:()=>_(!1),fullscreen:!0}):null]}):(0,X.jsx)(Gm,{open:g,onOpenChange:_,title:n,content:L,contentClassName:Km.popoverContent,sheetBodyClassName:Km.sheetBody,children:P})}var _h=0,vh=``;function yh(){return typeof document>`u`?()=>{}:(_h===0&&(vh=document.body.style.overflow,document.body.style.overflow=`hidden`),_h+=1,()=>{_h=Math.max(0,_h-1),_h===0&&(document.body.style.overflow=vh,vh=``)})}(0,H.createContext)(null);var bh={root:`_root_jtzwn_1`,icon:`_icon_jtzwn_13`,title:`_title_jtzwn_20`,description:`_description_jtzwn_27`,action:`_action_jtzwn_36`};function xh(e,t){if(e==null||typeof e==`boolean`)return null;if((0,H.isValidElement)(e)){let n=e;return(0,H.cloneElement)(n,{className:Y(n.props.className,t)})}return(0,X.jsx)(`div`,{className:t,children:e})}function Sh({action:e,className:t,description:n,icon:r,title:i,...a}){return(0,X.jsxs)(`div`,{...a,className:Y(bh.root,t),children:[xh(r,bh.icon),xh(i,bh.title),xh(n,bh.description),e?(0,X.jsx)(`div`,{className:bh.action,children:e}):null]})}var Ch={kbd:`_kbd_ilu4a_1`,interactive:`_interactive_ilu4a_19`,sm:`_sm_ilu4a_32`},wh={sm:Ch.sm,md:void 0},Th=({children:e,className:t,interactive:n=!1,onKeyDown:r,size:i=`md`,tabIndex:a,...o})=>(0,X.jsx)(`kbd`,{...o,className:Y(Ch.kbd,wh[i],n?Ch.interactive:void 0,`shortcuts-key`,t),onKeyDown:e=>{n&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.currentTarget.click()),r?.(e)},role:n?`button`:o.role,tabIndex:n?a??0:a,children:e}),Eh={overlay:`_overlay_1ofrz_1`,card:`_card_1ofrz_19`};function Dh({open:e,children:t,className:n,surfaceClassName:r,mode:i=`status`,interactive:a,onDismiss:o,ariaLabelledBy:s}){if(!e)return null;let c=a??i===`dialog`;return(0,X.jsx)(`div`,{"aria-labelledby":s,"aria-live":i===`status`?`polite`:void 0,"aria-modal":i===`dialog`?`true`:void 0,className:Y(Eh.overlay,`local-overlay`,n),"data-interactive":c?`true`:`false`,onClick:e=>{c&&o&&Gp(e)&&o()},role:i===`dialog`?`dialog`:`status`,children:(0,X.jsx)(`div`,{className:Y(Eh.card,`local-overlay__card`,r),children:t})})}var Oh={notice:`_notice_18fjp_1`,info:`_info_18fjp_14`,success:`_success_18fjp_19`,warning:`_warning_18fjp_24`,error:`_error_18fjp_29`,copy:`_copy_18fjp_34`,title:`_title_18fjp_42`,message:`_message_18fjp_51`,action:`_action_18fjp_59`},kh={info:Oh.info,success:Oh.success,warning:Oh.warning,error:Oh.error},Ah={info:void 0,success:void 0,warning:void 0,error:`settings-page__notice--error`};function jh({action:e,className:t,message:n,title:r,tone:i=`info`,...a}){return(0,X.jsxs)(`div`,{...a,className:Y(Oh.notice,kh[i],`settings-page__notice`,Ah[i],t),children:[r||n?(0,X.jsxs)(`div`,{className:Y(Oh.copy,`settings-page__notice-copy`),children:[r?(0,X.jsx)(`span`,{className:Y(Oh.title,`settings-page__notice-title`),children:r}):null,n?(0,X.jsx)(`span`,{className:Y(Oh.message,`settings-page__notice-message`),children:n}):null]}):null,e?(0,X.jsx)(`div`,{className:Oh.action,children:e}):null]})}var Mh={pill:`_pill_hhn3t_1`,active:`_active_hhn3t_35`,icon:`_icon_hhn3t_41`};function Nh({active:e=!1,children:t,className:n,disabled:r=!1,leadingIcon:i,selected:a=!1,...o}){let s=e||a;return(0,X.jsxs)(`button`,{...o,"aria-pressed":s,className:Y(Mh.pill,s?Mh.active:void 0,`settings-pill`,s?`settings-pill-active`:void 0,r?`settings-pill-disabled`:void 0,n),disabled:r,type:`button`,children:[i?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Mh.icon,children:i}):null,(0,X.jsx)(`span`,{children:t})]})}var Ph={root:`_root_162c6_1`,fill:`_fill_162c6_7`,success:`_success_162c6_14`,warning:`_warning_162c6_18`,error:`_error_162c6_22`,info:`_info_162c6_26`,neutral:`_neutral_162c6_30`,indeterminate:`_indeterminate_162c6_34`,progressBarIndeterminate:`_progressBarIndeterminate_162c6_1`};Ph.success,Ph.warning,Ph.error,Ph.info,Ph.neutral;var Fh={tabs:`_tabs_gpyk6_1`,tabList:`_tabList_gpyk6_5`,tab:`_tab_gpyk6_1`,tabActive:`_tabActive_gpyk6_69`,panel:`_panel_gpyk6_6`},Ih=(0,H.createContext)(null);function Lh(e){let t=(0,H.useContext)(Ih);if(!t)throw Error(`${e} must be used within Tabs`);return t}function Rh({children:e,className:t,orientation:n=`horizontal`,value:r,onValueChange:i,"aria-label":a,...o}){let s=(0,H.useId)(),c=(0,H.useRef)(new Map),[l,u]=(0,H.useState)({}),d=(0,H.useCallback)(e=>{let t=c.current.get(e);if(t)return t;let n={tabId:`${s}-tab-${c.current.size}`,panelId:`${s}-panel-${c.current.size}`};return c.current.set(e,n),n},[s]),f=(0,H.useCallback)(e=>{u(t=>t[e]?t:{...t,[e]:!0})},[]),p=(0,H.useCallback)(e=>{u(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),m=(0,H.useMemo)(()=>({value:r,onValueChange:i,orientation:n,listLabel:a,ensureTabIds:d,hasPanel:e=>!!l[e],registerPanel:f,unregisterPanel:p}),[a,d,i,n,l,f,p,r]);return(0,X.jsx)(Ih.Provider,{value:m,children:(0,X.jsx)(`div`,{...o,className:Y(Fh.tabs,t),"data-orientation":n,children:e})})}function zh({children:e,className:t,orientation:n,...r}){let i=Lh(`TabList`),a=n??i.orientation;return(0,X.jsx)(`div`,{...r,"aria-label":r[`aria-label`]??i.listLabel,"aria-orientation":a===`vertical`?`vertical`:void 0,className:Y(Fh.tabList,t),"data-orientation":a,role:`tablist`,children:e})}function Bh({children:e,className:t,value:n,onClick:r,onKeyDown:i,...a}){let o=Lh(`Tab`),s=o.value===n,c=o.ensureTabIds(n),l=e=>{if(i?.(e),e.defaultPrevented)return;let t=e.currentTarget.closest(`[role="tablist"]`);if(!t)return;let n=t.getAttribute(`aria-orientation`)===`vertical`?`vertical`:`horizontal`,r=Array.from(t.querySelectorAll(`button[role="tab"]:not(:disabled)`)),a=r.indexOf(e.currentTarget);if(a===-1)return;let s=t=>{let n=r[t];n?.focus();let i=n?.dataset.value;i&&o.onValueChange(i),e.preventDefault()};n===`horizontal`&&e.key===`ArrowRight`||n===`vertical`&&e.key===`ArrowDown`?s((a+1)%r.length):n===`horizontal`&&e.key===`ArrowLeft`||n===`vertical`&&e.key===`ArrowUp`?s((a-1+r.length)%r.length):e.key===`Home`?s(0):e.key===`End`&&s(r.length-1)};return(0,X.jsx)(`button`,{...a,"aria-controls":o.hasPanel(n)?c.panelId:void 0,"aria-selected":s,className:Y(Fh.tab,s?Fh.tabActive:void 0,s?`active`:void 0,t),"data-state":s?`active`:`inactive`,"data-value":n,id:c.tabId,onClick:e=>{r?.(e),e.defaultPrevented||o.onValueChange(n)},onKeyDown:l,role:`tab`,tabIndex:s?0:-1,type:`button`,children:e})}function Vh({children:e,className:t,value:n,...r}){let i=Lh(`TabPanel`),a=i.value===n,o=i.ensureTabIds(n),{registerPanel:s,unregisterPanel:c}=i;return(0,H.useLayoutEffect)(()=>(s(n),()=>{c(n)}),[s,c,n]),(0,X.jsx)(`div`,{...r,"aria-labelledby":o.tabId,className:Y(Fh.panel,t),hidden:!a,id:o.panelId,role:`tabpanel`,children:e})}var Hh={segmentedControl:`_segmentedControl_1ag6y_1`,segmentedControlOption:`_segmentedControlOption_1ag6y_18`};function Uh({options:e,value:t,onChange:n,size:r=`md`,className:i,optionClassName:a,...o}){return(0,X.jsx)(Rh,{onValueChange:n,value:e.some(e=>e.value===t)?t:e.find(e=>!e.disabled)?.value??t,children:(0,X.jsx)(zh,{...o,className:Y(Hh.segmentedControl,i),"data-size":r,children:e.map(e=>(0,X.jsx)(Bh,{className:Y(Hh.segmentedControlOption,a),"data-size":r,disabled:e.disabled,value:e.value,children:e.label},e.value))})})}var Wh={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},Gh={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},Kh={color:`var(--text-secondary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`},qh={color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`};function Jh({title:e,sections:t,className:n,selectedId:r,presentation:i=`sheet`,searchable:a=!1,searchPlaceholder:o,searchValue:s,onSearchValueChange:c,create:l,closeOnSelect:u=!0,loading:d=!1,loadingText:f,emptyText:p,kicker:m,onBack:h,onSelect:g,onClose:_}){let v=Z(),[y,b]=(0,H.useState)(``),x=(0,H.useId)(),S=s??y,C=S.trim(),w=S.trim().toLowerCase(),T=f??v(`common.loading`),E=p??v(`command.no_results`),D=o??v(`action.search`),O=e=>{s===void 0&&b(e),c?.(e)},k=(0,H.useMemo)(()=>w?t.map(e=>e.kind===`options`?{...e,items:e.items.filter(e=>[e.label,e.description??``,e.meta??``,...e.keywords??[]].join(` `).toLowerCase().includes(w))}:e):t,[w,t]),A=k.some(e=>e.items.length>0),j=!!(l?.visible&&C),M=!!(j&&l?.disabled?.(C)),N=(e,t)=>{Promise.resolve(t()).catch(t=>{console.error(`MobileSelectSheet ${e} failed`,t)})},P=e=>{N(`select`,async()=>{await g(e),u&&_()})},F=e=>{N(`action`,e)},ee=e=>{N(`action`,e)},I=()=>{!l||!C||N(`create`,()=>l.onCreate(C))},L=(0,X.jsxs)(X.Fragment,{children:[a?(0,X.jsxs)(`div`,{className:`mobile-select-sheet__search`,children:[(0,X.jsx)(`label`,{className:`mobile-select-sheet__search-label`,htmlFor:x,children:v(`action.search`)}),(0,X.jsx)(`input`,{id:x,type:`text`,className:`mobile-select-sheet__search-input`,placeholder:D,value:S,onChange:e=>O(e.target.value)})]}):null,(0,X.jsx)(`div`,{className:`mobile-select-sheet__content`,children:d?(0,X.jsx)(Sh,{className:`mobile-select-sheet__loading`,role:`status`,style:Gh,title:(0,X.jsx)(`div`,{style:Kh,children:T})}):(0,X.jsxs)(X.Fragment,{children:[k.map(e=>e.items.length===0&&e.kind===`options`?null:(0,X.jsxs)(`div`,{className:`mobile-select-sheet__section`,children:[e.title?(0,X.jsx)(`div`,{className:`mobile-select-sheet__section-title`,children:e.title}):null,(0,X.jsx)(`div`,{className:`mobile-select-sheet__list`,children:e.kind===`options`?e.items.map(t=>{let n=t.id===r,i=`${e.id}-${t.id}-label`,a=[t.description?`${e.id}-${t.id}-description`:null,t.meta?`${e.id}-${t.id}-meta`:null].filter(Boolean).join(` `),o=(0,X.jsxs)(`button`,{type:`button`,className:`mobile-select-sheet__item ${t.tone===`danger`?`mobile-select-sheet__item--danger`:``}`,"aria-pressed":n,"aria-labelledby":i,"aria-describedby":a||void 0,disabled:t.disabled,onClick:()=>P(t.id),children:[t.icon?(0,X.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,X.jsx)(`span`,{id:i,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,X.jsx)(`span`,{id:`${e.id}-${t.id}-description`,className:`mobile-select-sheet__item-description`,children:t.description}):null,t.meta?(0,X.jsx)(`span`,{id:`${e.id}-${t.id}-meta`,className:`mobile-select-sheet__item-meta`,children:t.meta}):null]}),t.badge?(0,X.jsx)(_g,{color:`neutral`,caps:!1,className:`mobile-select-sheet__item-badge`,children:t.badge}):null]});return t.trailingAction?(0,X.jsxs)(`div`,{className:`mobile-select-sheet__item-row`,"data-selected":n?`true`:`false`,children:[o,(0,X.jsx)(Em,{"aria-label":t.trailingAction.ariaLabel,className:`mobile-select-sheet__item-side-action ${t.trailingAction.tone===`danger`?`mobile-select-sheet__item-side-action--danger`:``}`,disabled:t.disabled||t.trailingAction.disabled,icon:(0,X.jsx)(`span`,{className:`mobile-select-sheet__item-side-action-icon`,children:t.trailingAction.icon}),onClick:()=>ee(t.trailingAction.onAction),size:`lg`,variant:`ghost`})]},t.id):(0,X.jsx)(`div`,{"data-selected":n?`true`:`false`,children:o},t.id)}):e.items.map(t=>{let n=`${e.id}-${t.id}-label`,r=t.description?`${e.id}-${t.id}-description`:void 0;return(0,X.jsxs)(`button`,{type:`button`,className:`mobile-select-sheet__item mobile-select-sheet__item--action ${t.tone===`danger`?`mobile-select-sheet__item--danger`:``}`,"aria-labelledby":n,"aria-describedby":r,disabled:t.disabled,onClick:()=>F(t.onAction),children:[t.icon?(0,X.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,X.jsx)(`span`,{id:n,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,X.jsx)(`span`,{id:r,className:`mobile-select-sheet__item-description`,children:t.description}):null]})]},t.id)})})]},e.id)),j?(0,X.jsx)(`div`,{className:`mobile-select-sheet__section`,children:(0,X.jsx)(`div`,{className:`mobile-select-sheet__list`,children:(()=>{let e=`mobile-select-create-label`,t=`mobile-select-create-description`,n=l?.description?.(C);return(0,X.jsx)(`button`,{type:`button`,className:`mobile-select-sheet__item mobile-select-sheet__item--create`,"aria-labelledby":e,"aria-describedby":n?t:void 0,disabled:M,onClick:I,children:(0,X.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,X.jsx)(`span`,{id:e,className:`mobile-select-sheet__item-label`,children:l?.label(C)}),n?(0,X.jsx)(`span`,{id:t,className:`mobile-select-sheet__item-description`,children:n}):null]})})})()})}):null,!A&&!j?(0,X.jsx)(Sh,{className:`mobile-select-sheet__empty`,style:Wh,title:(0,X.jsx)(`div`,{style:qh,children:E})}):null]})})]});return i===`inline`?(0,X.jsxs)(`div`,{className:`mobile-inline-sheet`,role:`dialog`,"aria-label":e,children:[(0,X.jsx)(`div`,{className:`mobile-inline-sheet__handle`,"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`mobile-inline-sheet__header`,children:(0,X.jsx)(rm,{title:e,titleAs:`h3`,onBack:h,backLabel:v(`action.back`)})}),(0,X.jsx)(`div`,{className:`mobile-inline-sheet__body`,children:(0,X.jsx)(`div`,{className:Y(`mobile-select-sheet`,`mobile-select-sheet--inline`,n),children:L})})]}):(0,X.jsx)(fm,{title:e,body:(0,X.jsx)(`div`,{className:Y(`mobile-select-sheet`,n),children:L}),onClose:_,kicker:m,onBack:h,bodyClassName:`mobile-sheet__body--flush`,fullscreen:!0})}var Yh={root:`_root_19636_1`,native:`_native_19636_6`,mobileTrigger:`_mobileTrigger_19636_11`,mobileValue:`_mobileValue_19636_20`,mobileIcon:`_mobileIcon_19636_25`,listbox:`_listbox_19636_30`,option:`_option_19636_46`,optionSelected:`_optionSelected_19636_60`,optionDisabled:`_optionDisabled_19636_64`},Xh={sm:eh.sm,md:void 0,lg:eh.lg},Zh={sm:`input-sm`,md:void 0,lg:`input-lg`};function Qh(e,t,n){return n||(t===void 0?``:e.find(e=>e.value===t)?.label??t)}function $h({className:e,invalid:t,size:n}){return Y(eh.input,Xh[n],`input`,Zh[n],`mobile-select-trigger`,Yh.mobileTrigger,t?eh.invalid:void 0,e)}function eg({ariaLabel:e,ariaLabelledBy:t,includeValueInAriaLabel:n,selectedLabel:r,valueId:i}){let a=t?`${t} ${i}`:void 0;return{resolvedAriaLabel:!t&&e&&n?`${e} ${r}`:e,resolvedAriaLabelledBy:a}}function tg(e){let t=Br(),n=(0,H.useId)(),[r,i]=(0,H.useState)(!1),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(`selected`),l=e.size??`md`,u=e.invalid===void 0?e[`aria-invalid`]:e.invalid?`true`:`false`,d=e.mobile!==!0&&e.desktopMode===`listbox`,f=d?t:`desktop`,p=d&&f===`desktop`;if((0,H.useEffect)(()=>{if(!r||!p)return;let e=e=>{e.target instanceof Node&&(a.current?.contains(e.target)||i(!1))};return document.addEventListener(`pointerdown`,e),()=>{document.removeEventListener(`pointerdown`,e)}},[r,p]),(0,H.useEffect)(()=>{if(!r||!p)return;let e=Array.from(s.current?.querySelectorAll(`[role="option"]:not([aria-disabled="true"])`)??[]);e.length!==0&&(c.current===`last`?e.at(-1):s.current?.querySelector(`[role="option"][aria-selected="true"]:not([aria-disabled="true"])`)??e[0])?.focus()},[r,p,e.options,e.value]),(0,H.useEffect)(()=>{i(!1)},[d,f]),e.mobile){let{"aria-label":t,"aria-labelledby":r,className:i,disabled:a,id:o,invalid:s,mobile:c,onClick:d,onOpen:f,options:p,size:m,value:h,valueLabel:g,includeValueInAriaLabel:_=!0,...v}=e,y=Qh(p,h,g),b=`${o??n}-value`,{resolvedAriaLabel:x,resolvedAriaLabelledBy:S}=eg({ariaLabel:t,ariaLabelledBy:r,includeValueInAriaLabel:_,selectedLabel:y,valueId:b});return(0,X.jsxs)(`button`,{...v,id:o,type:`button`,disabled:a,"aria-invalid":u,"aria-label":x,"aria-haspopup":v[`aria-haspopup`]??`dialog`,"aria-labelledby":S||void 0,className:$h({className:i,invalid:s,size:l}),onClick:e=>{d?.(e),!e.defaultPrevented&&!a&&!e.currentTarget.disabled&&f()},children:[(0,X.jsx)(`span`,{id:b,className:Y(`mobile-select-trigger__value`,Yh.mobileValue),children:y}),(0,X.jsx)(_i,{size:16,className:Y(`mobile-select-trigger__icon`,Yh.mobileIcon),"aria-hidden":`true`})]})}if(e.desktopMode===`listbox`){let{"aria-label":t,"aria-labelledby":d,className:m,desktopMode:h,disabled:g,id:_,invalid:v,mobileSheetPresentation:y=`sheet`,mobileSheetTitle:b,onClick:x,onKeyDown:S,onValueChange:C,options:w,size:T,value:E,...D}=e,O=Qh(w,E),k=`${_??n}-listbox`,A=`${_??n}-value`,{resolvedAriaLabel:j,resolvedAriaLabelledBy:M}=eg({ariaLabel:t,ariaLabelledBy:d,includeValueInAriaLabel:!0,selectedLabel:O,valueId:A}),N=(e=!1)=>{i(!1),e&&o.current?.focus()},P=e=>{C?.(e),N(!0)},F=()=>Array.from(s.current?.querySelectorAll(`[role="option"]:not([aria-disabled="true"])`)??[]),ee=e=>{if(e.key===`Tab`){N(!1);return}if(e.key===`Escape`){e.preventDefault(),N(!0);return}let t=F();if(t.length===0)return;let n=t.findIndex(e=>e===document.activeElement);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let r=e.key===`ArrowUp`?t.length-1:0;t[n===-1?r:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus();return}if(e.key===`Home`||e.key===`End`){e.preventDefault(),t[e.key===`Home`?0:t.length-1]?.focus();return}if(e.key!==`Enter`&&e.key!==` `)return;let r=e.target instanceof HTMLElement?e.target.closest(`[role="option"][data-option-value]`):null,i=r?.dataset.optionValue;!i||r?.getAttribute(`aria-disabled`)===`true`||(e.preventDefault(),P(i))},I=e=>{if(S?.(e),!(e.defaultPrevented||g||e.currentTarget.disabled)){if(e.key===`Escape`){N(!0);return}f===`desktop`&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),c.current=e.key===`ArrowUp`?`last`:`selected`,i(!0))}},L=y===`inline`?()=>i(!1):void 0;return(0,X.jsxs)(`div`,{ref:a,className:Yh.root,children:[(0,X.jsxs)(`button`,{...D,ref:o,id:_,type:`button`,disabled:g,"aria-controls":p&&r?k:void 0,"aria-expanded":r,"aria-invalid":u,"aria-label":j,"aria-haspopup":f===`mobile`?`dialog`:`listbox`,"aria-labelledby":M||void 0,className:$h({className:m,invalid:v,size:l}),onClick:e=>{x?.(e),!e.defaultPrevented&&!g&&!e.currentTarget.disabled&&(r||(c.current=`selected`),i(e=>!e))},onKeyDown:I,children:[(0,X.jsx)(`span`,{id:A,className:Y(`mobile-select-trigger__value`,Yh.mobileValue),children:O}),(0,X.jsx)(_i,{size:16,className:Y(`mobile-select-trigger__icon`,Yh.mobileIcon),"aria-hidden":`true`})]}),p&&r?(0,X.jsx)(`div`,{id:k,ref:s,role:`listbox`,"aria-label":t,"aria-labelledby":d,className:Yh.listbox,onKeyDown:ee,children:w.map(e=>{let t=e.value===E;return(0,X.jsx)(`div`,{role:`option`,id:`${k}-${e.value}`,"aria-disabled":e.disabled?`true`:void 0,"aria-selected":t,className:Y(Yh.option,t?Yh.optionSelected:void 0,e.disabled?Yh.optionDisabled:void 0),"data-option-value":e.value,tabIndex:-1,onClick:()=>{e.disabled||P(e.value)},children:e.label},e.value)})}):null,f===`mobile`&&r?(0,X.jsx)(Jh,{title:b,presentation:y,sections:[{kind:`options`,id:`${_??n}-options`,items:w.map(e=>({id:e.value,label:e.label,disabled:e.disabled}))}],selectedId:E,onBack:L,onClose:()=>i(!1),onSelect:e=>{C?.(e)}}):null]})}let{className:m,htmlSize:h,invalid:g,onChange:_,onValueChange:v,options:y,size:b,...x}=e;return(0,X.jsx)(`select`,{...x,size:h,"aria-invalid":u,className:Y(eh.input,Xh[l],`input`,Zh[l],Yh.native,g?eh.invalid:void 0,m),onChange:e=>{_?.(e),v?.(e.target.value)},children:y.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))})}var ng={spinner:`_spinner_hh7r3_1`},rg={sm:`12px`,md:`16px`,lg:`20px`};function ig({className:e,label:t,size:n=`md`,style:r,...i}){return(0,X.jsx)(`span`,{...i,"aria-label":t,className:Y(ng.spinner,`animate-spin`,e),role:`status`,style:{"--spinner-size":rg[n],...r}})}var ag={dot:`_dot_1dgyt_1`,pulse:`_pulse_1dgyt_13`,statusDotPulse:`_statusDotPulse_1dgyt_1`,statusDotRunningPulse:`_statusDotRunningPulse_1dgyt_1`,statusDotRunningRingGhost:`_statusDotRunningRingGhost_1dgyt_1`,statusDotRunningRing:`_statusDotRunningRing_1dgyt_1`},og={success:`var(--status-dot-complete)`,warning:`var(--status-dot-starting)`,error:`var(--status-dot-error)`,info:`var(--status-dot-running)`,neutral:`var(--status-dot-idle)`},sg={success:`var(--status-dot-complete-ring)`,warning:`var(--status-dot-starting-ring)`,error:`var(--status-dot-error-ring)`,info:`var(--status-dot-running-ring-1)`,neutral:`var(--status-dot-idle-ring)`},cg={sm:`6px`,md:`8px`,lg:`10px`};function lg({className:e,pulse:t=!1,size:n=`md`,style:r,tone:i=`neutral`,"aria-hidden":a=!0,...o}){return(0,X.jsx)(`span`,{...o,"aria-hidden":a,className:Y(ag.dot,t?ag.pulse:void 0,e),style:{"--status-dot-tone-color":og[i],"--status-dot-tone-ring":sg[i],"--status-dot-current-size":cg[n],...r}})}var ug={switch:`_switch_1li8z_1`,track:`_track_1li8z_26`,checked:`_checked_1li8z_52`,thumb:`_thumb_1li8z_57`},dg={sm:{trackWidth:`32px`,trackHeight:`18px`,thumbSize:`14px`,offset:`2px`},md:{trackWidth:`36px`,trackHeight:`20px`,thumbSize:`16px`,offset:`2px`}};function fg({checked:e,className:t,disabled:n=!1,onCheckedChange:r,onClick:i,size:a=`md`,style:o,...s}){let c=dg[a];return(0,X.jsx)(`button`,{...s,"aria-checked":e,className:Y(ug.switch,e?ug.checked:void 0,t),disabled:n,onClick:t=>{i?.(t),!(n||t.defaultPrevented)&&r(!e)},role:`switch`,style:{"--switch-track-width":c.trackWidth,"--switch-track-height":c.trackHeight,"--switch-thumb-size":c.thumbSize,"--switch-thumb-offset":c.offset,...o},type:`button`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:ug.track,children:(0,X.jsx)(`span`,{className:ug.thumb})})})}var pg={tag:`_tag_qp546_1`,sm:`_sm_qp546_26`,noCaps:`_noCaps_qp546_31`,blue:`_blue_qp546_35`,green:`_green_qp546_41`,amber:`_amber_qp546_47`,pink:`_pink_qp546_53`,purple:`_purple_qp546_59`,neutral:`_neutral_qp546_65`},mg={blue:pg.blue,green:pg.green,amber:pg.amber,pink:pg.pink,purple:pg.purple,neutral:pg.neutral},hg={blue:`badge-blue`,green:`badge-green`,amber:`badge-amber`,pink:`badge-pink`,purple:`badge-purple`,neutral:`badge-gray`},gg={sm:pg.sm,md:void 0};function _g({caps:e=!0,className:t,color:n=`neutral`,size:r=`md`,...i}){return(0,X.jsx)(`span`,{...i,className:Y(pg.tag,mg[n],gg[r],e?void 0:pg.noCaps,`badge`,hg[n],t)})}var vg={input:`_input_18qve_1`,textarea:`_textarea_18qve_29`,lg:`_lg_18qve_36`,invalid:`_invalid_18qve_41`},yg={md:void 0,lg:vg.lg},bg={md:void 0,lg:`textarea-lg`};function xg(e,t){if(typeof e==`function`){e(t);return}e&&(e.current=t)}function Sg(e){e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}var Cg=(0,H.forwardRef)(function({autoResize:e=!1,className:t,invalid:n,onChange:r,size:i=`md`,...a},o){let s=(0,H.useRef)(null),c=n===void 0?a[`aria-invalid`]:n?`true`:`false`;return(0,H.useEffect)(()=>{!e||!s.current||Sg(s.current)},[e,a.defaultValue,a.value]),(0,X.jsx)(`textarea`,{...a,"aria-invalid":c,className:Y(vg.input,vg.textarea,yg[i],`input`,`textarea`,bg[i],n?vg.invalid:void 0,t),onChange:t=>{e&&Sg(t.currentTarget),r?.(t)},ref:e=>{s.current=e,xg(o,e)}})}),wg={viewport:`_viewport_jjy5n_1`,mobile:`_mobile_jjy5n_14`,toast:`_toast_jjy5n_24`,slideIn:`_slideIn_jjy5n_1`,clickable:`_clickable_jjy5n_41`,success:`_success_jjy5n_50`,error:`_error_jjy5n_54`,warning:`_warning_jjy5n_58`,info:`_info_jjy5n_62`,icon:`_icon_jjy5n_66`,content:`_content_jjy5n_98`,title:`_title_jjy5n_106`,body:`_body_jjy5n_113`,action:`_action_jjy5n_122`,close:`_close_jjy5n_139`},Tg={success:wg.success,error:wg.error,warning:wg.warning,info:wg.info},Eg={success:`toast--success`,error:`toast--error`,warning:`toast--warning`,info:`toast--info`},Dg={success:`state.success`,error:`state.error`,warning:`state.warning`,info:`state.info`};function Og({children:e,className:t,mobile:n=!1,...r}){return(0,X.jsx)(`div`,{...r,className:Y(wg.viewport,n?wg.mobile:void 0,`toast-container`,n?`toast-container--mobile`:void 0,t),children:e})}function kg({actionLabel:e,className:t,closeLabel:n=`Dismiss`,description:r,icon:i,onAction:a,onClick:o,onDismiss:s,title:c,tone:l,...u}){let d=typeof o==`function`,{"aria-live":f,...p}=u,m=i??(0,X.jsx)($,{className:`toast__icon-symbol`,semantic:Dg[l],size:16});return(0,X.jsxs)(`div`,{...p,"aria-live":f,className:Y(wg.toast,Tg[l],d?wg.clickable:void 0,`toast`,Eg[l],t),onClick:o,role:`alert`,children:[m?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Y(wg.icon,`toast__icon`),children:m}):null,(0,X.jsxs)(`div`,{className:Y(wg.content,`toast__content`),children:[(0,X.jsx)(`span`,{className:Y(wg.title,`toast__title`),children:c}),r?(0,X.jsx)(`span`,{className:Y(wg.body,`toast__body`),children:r}):null]}),e&&a?(0,X.jsx)(`button`,{className:wg.action,onClick:e=>{e.stopPropagation(),a()},type:`button`,children:e}):null,(0,X.jsx)(Em,{"aria-label":n,className:Y(wg.close,`toast__close`),icon:(0,X.jsx)(pa,{size:14}),onClick:e=>{e.stopPropagation(),s()},size:`sm`})]})}var Ag={disabledTriggerWrapper:`_disabledTriggerWrapper_frz91_1`,tooltip:`_tooltip_frz91_5`},jg=new Set,Mg=null;function Ng(){if(Mg||typeof document>`u`)return;let e=e=>{for(let t of jg)t({target:e.target})};document.addEventListener(`pointerdown`,e,!0),Mg=()=>{document.removeEventListener(`pointerdown`,e,!0),Mg=null}}function Pg(e){return Ng(),jg.add(e),()=>{jg.delete(e),jg.size===0&&Mg?.()}}function Fg(e){return(0,H.isValidElement)(e)}function Ig({children:e,content:t,disabled:n=!1}){let r=H.Children.only(e),i=Br(),a=(0,H.useId)(),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)({left:0,top:0});if(!Fg(r))return r;let h=!n&&i===`desktop`,g=h&&(l||d),_=r.props.disabled===!0,v=r.props[`aria-describedby`],y=(0,H.useMemo)(()=>g?[v,a].filter(Boolean).join(` `):v,[v,g,a]);(0,H.useLayoutEffect)(()=>{if(!g||!o.current||!s.current)return;let e=o.current.getBoundingClientRect(),t=s.current.getBoundingClientRect(),n=e.left+e.width/2-t.width/2,r=Math.max(8,window.innerWidth-t.width-8),i=Math.min(r,Math.max(8,n)),a=e.top-t.height-8,c=e.bottom+8,l=Math.max(8,window.innerHeight-t.height-8);m({left:i,top:Math.max(8,a>=8?a:Math.min(l,c))})},[g]),(0,H.useEffect)(()=>{if(g)return Pg(({target:e})=>{if(!(e instanceof Node)){u(!1),f(!1);return}o.current?.contains(e)||(u(!1),f(!1))})},[g]);let b=_?(0,H.cloneElement)(r,{"aria-describedby":y}):(0,H.cloneElement)(r,{"aria-describedby":y,onBlur:e=>{r.props.onBlur?.(e),c.current=!1,f(!1)},onFocus:e=>{r.props.onFocus?.(e),!e.defaultPrevented&&h&&(o.current=e.currentTarget,f(!c.current))},onKeyDown:e=>{r.props.onKeyDown?.(e),c.current=!1},onMouseEnter:e=>{r.props.onMouseEnter?.(e),!e.defaultPrevented&&h&&(o.current=e.currentTarget,u(!0))},onMouseLeave:e=>{r.props.onMouseLeave?.(e),u(!1)},onPointerDown:e=>{r.props.onPointerDown?.(e),e.defaultPrevented||(c.current=!0)}});return(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(`span`,{className:Ag.disabledTriggerWrapper,onMouseEnter:e=>{!e.defaultPrevented&&h&&(o.current=e.currentTarget,u(!0))},onMouseLeave:()=>{u(!1)},children:b}):b,g?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{className:Y(Ag.tooltip),id:a,ref:s,role:`tooltip`,style:{left:`${p.left}px`,top:`${p.top}px`},children:t})}):null]})}var Lg={backdrop:`_backdrop_uo2rs_1`,surface:`_surface_uo2rs_14`};function Rg({children:e,open:t,onOpenChange:n,className:r,dismissible:i=!0,initialFocus:a,ariaLabel:o,ariaLabelledBy:s}){let c=(0,H.useRef)(null),l=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{if(!t)return;l.current=document.activeElement;let e=c.current,n=yh();return e?(Xp(e,a).focus(),()=>{n(),Qp(l.current),l.current=null}):n},[a,t]),t?(0,X.jsx)($p,{children:(0,X.jsx)(`div`,{className:Y(Lg.backdrop,`workbench-layer-backdrop`),onClick:e=>{i&&Gp(e)&&n(!1)},children:(0,X.jsx)(`div`,{"aria-label":o,"aria-labelledby":s,"aria-modal":`true`,className:Y(Lg.surface,`workbench-layer`,r),onClick:e=>{e.stopPropagation()},onKeyDown:e=>{if(Kp(e)){i&&(e.preventDefault(),e.stopPropagation(),n(!1));return}Zp(e.currentTarget,e)},ref:c,role:`dialog`,tabIndex:-1,children:e})})}):null}function zg({onAuthenticated:e}){let t=Z(),[,n]=Te(Qa),r=U(Za),i=U(Dp),a=Br()===`mobile`,[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(i===null),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(i!==null){p(!1),h(!1),_(i===!1),i===!1&&n(!0);return}(async()=>{try{let e=await(await fetch(`/auth/status`)).json();h(!1),_(e.authEnabled===!1),e.authEnabled===!1||e.authenticated===!0?n(!0):n(!1)}catch{h(!0),_(!1)}finally{p(!1)}})()},[i,n]);let v=t(f?`status.connecting`:m?`status.unavailable`:g?`auth.status_not_configured`:`auth.description`),y=t(f?`auth.status_loading`:m?`auth.status_unavailable`:g?`auth.status_not_configured`:`auth.hint`),b=`auth-status-panel${m||c?` auth-status-panel-error`:``}`,x=t(f||u?`status.connecting`:`action.confirm`),S=e=>typeof e!=`number`||Number.isNaN(e)?t(`auth.blocked_generic`):t(`auth.blocked_until`,{time:dm(e,r,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})});return(0,X.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,a?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsx)(`div`,{className:[`welcome-card`,`auth-card-shell`,a?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsxs)(`div`,{className:`auth-card-shell__content`,children:[(0,X.jsxs)(`section`,{className:`auth-hero`,children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:`CODER STUDIO`}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:t(`app.name`)}),(0,X.jsx)(`p`,{className:`welcome-body auth-card-desc meta-text`,children:v})]}),(0,X.jsxs)(`section`,{className:b,children:[(0,X.jsx)(`div`,{className:`auth-status-eyebrow`,children:t(`auth.status_title`)}),(0,X.jsx)(`p`,{className:`auth-status-detail`,children:c??y})]}),(0,X.jsxs)(`form`,{className:`auth-form`,onSubmit:async r=>{r.preventDefault(),d(!0),l(null);try{let t=await fetch(`/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:o})});if(!t.ok){let e=await t.json().catch(()=>({error:`Login failed`}));if(e?.blocked===!0){l(S(e.blockedUntil));return}l(e.error||`Login failed`);return}let r=await t.json();(r.authEnabled===!1||r.ok)&&(n(!0),e&&(await e()||n(!1)))}catch{l(t(`error.network`))}finally{d(!1)}},children:[(0,X.jsx)(rh,{className:`auth-input`,type:`password`,size:`lg`,value:o,onChange:e=>s(e.target.value),"aria-label":t(`settings.auth.password`),placeholder:t(`settings.auth.password`)}),(0,X.jsx)(Q,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`submit`,disabled:f||u||!o.trim(),children:x})]})]})})})}function Bg(){let e=Z(),t=Br()===`mobile`;return(0,X.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,t?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsx)(`div`,{className:[`welcome-card`,`auth-card-shell`,t?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:(0,X.jsxs)(`div`,{className:`auth-card-shell__content`,children:[(0,X.jsxs)(`section`,{className:`auth-hero`,children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`auth.session_gate_title`)}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`app.name`)}),(0,X.jsx)(`p`,{className:`welcome-body auth-card-desc meta-text`,children:e(`auth.session_gate_description`)})]}),(0,X.jsxs)(`section`,{className:`auth-status-panel auth-status-panel-error`,children:[(0,X.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`auth.status_title`)}),(0,X.jsx)(`p`,{className:`auth-status-detail`,children:e(`auth.session_gate_detail`)})]}),(0,X.jsx)(`div`,{className:`auth-actions`,children:(0,X.jsx)(Q,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`button`,onClick:()=>window.location.replace(`/`),children:e(`auth.session_gate_reenter`)})})]})})})}var Vg={claude:`Claude`,codex:`Codex`};function Hg(e){return Vg[e]?Vg[e]:e?e.charAt(0).toUpperCase()+e.slice(1):`Agent`}function Ug(e){if(!e)return``;let t=e.name?.trim();if(t)return Wg(t);let n=e.path?.trim();return n?Wg(n):``}function Wg(e){let t=e.replace(/[/\\]+$/,``),n=t.split(/[/\\]/);return n[n.length-1]||t}function Gg(e){if(!Number.isFinite(e)||e<0)return``;if(e<1e3)return`<1s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?r===0?`${n}m`:`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var Kg=new WeakMap,qg=new WeakMap;function Jg(e){let t=qg.get(e);if(t)return t;let n=new WeakSet;return qg.set(e,n),n}function Yg(e){let t=e.get(no),n=Jg(e);return t&&!n.has(t)?(Kg.set(e,t),t):Kg.get(e)??null}function Xg(){let e=U(Op),t=W(no),n=ve();return(0,H.useCallback)(async({workspaceId:r,sessionId:i})=>{let a=n.get(no),o=Jg(n);if(Yg(n),!r)return null;if(a?.workspaceId===r&&(a.sessionId??void 0)===i)return a;let s={workspaceId:r,sessionId:i,updatedAt:Date.now()};o.add(s),t(s);let c=await e(`workspace.lastViewedTarget.set`,{workspaceId:r,sessionId:i}),l=n.get(no);if(c.ok&&c.data)return Kg.set(n,c.data),l===s?(o.delete(s),t(c.data),c.data):(o.delete(s),l);if(l===s){let e=Yg(n);return o.delete(s),t(e),e}return o.delete(s),l},[e,t,n])}function Zg(){let e=W(jp),t=Xg();return(0,H.useCallback)(async n=>n?(e(n),t({workspaceId:n})):null,[t,e])}var Qg=Ap(e=>V(null)),$g=Ap(e=>V(!1)),e_=Ap(e=>V(new Set)),t_=Ap(e=>V(null)),n_=/\.(avif|bmp|gif|ico|jpe?g|png|svg|tiff?|webp)$/i,r_=/\.(md|markdown|html?)$/i;function i_(e){return r_.test(e)}function a_(e){return/\.(md|markdown)$/i.test(e)?`markdown`:/\.html?$/i.test(e)?`html`:null}function o_(e){return n_.test(e)||i_(e)}function s_(e){return e.kind===`image`||i_(e.path)?`preview`:(e.viewingTextBackedImageAsText,`edit`)}function c_(e){return o_(e)?`preview`:`edit`}var l_=Ap(e=>V({})),u_=Ap(e=>V(null)),d_=Ap(e=>V(`preview`)),f_=Ap(e=>V(0));Ap(e=>V(t=>{let n=t(u_(e));return n?t(l_(e))[n]??null:null})),Ap(e=>V(t=>{let n=t(l_(e));return Object.values(n).filter(e=>e.isDirty).length}));var p_=Ap(e=>V(null)),m_=Ap(e=>V(null)),h_=Ap(e=>V(!1));Ap(e=>V(t=>{let n=t(p_(e));return n?n.staged.length>0||n.modified.length>0||n.untracked.length>0||n.deleted.length>0:!1})),Ap(e=>V(t=>{let n=t(p_(e));return n?{staged:n.staged.length,unstaged:n.modified.length+n.deleted.length,untracked:n.untracked.length,total:n.staged.length+n.modified.length+n.untracked.length+n.deleted.length}:{staged:0,unstaged:0,untracked:0,total:0}}));var g_=Ap(e=>V({current:``,branches:[],loading:!1})),__=V({visible:!1,inputValue:``}),v_=Ap(e=>Zr(`coder-studio:git-commit-draft:${e}`,``)),y_=Ap(e=>V({items:[],loading:!1})),b_=Ap(e=>V({status:`idle`})),x_=`__workspace_layout_global__`,S_=`explorer`,C_=new Set([`explorer`,`search`,`source-control`]),w_={focusMode:!1,leftPanelWidth:280,bottomPanelHeight:200,sidebarCollapsed:!1,desktopSidebarView:S_,terminalPanelVisible:!0};function T_(e){return typeof e==`string`&&C_.has(e)?e:S_}function E_(e,t){return typeof e==`boolean`?e:t}function D_(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:t}function O_(e){if(typeof window>`u`)return;let t=window.localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function k_(){return{focusMode:O_(`ui.focusMode`),leftPanelWidth:O_(`ui.leftPanelWidth`),bottomPanelHeight:O_(`ui.bottomPanelHeight`),sidebarCollapsed:O_(`ui.sidebarCollapsed`),desktopSidebarView:O_(`ui.desktopSidebarView`),terminalPanelVisible:O_(`ui.terminalPanelVisible`)}}function A_(e,t){let n=e&&typeof e==`object`?e:{},r={...w_,...t};return{focusMode:E_(n.focusMode,r.focusMode),leftPanelWidth:D_(n.leftPanelWidth,r.leftPanelWidth),bottomPanelHeight:D_(n.bottomPanelHeight,r.bottomPanelHeight),sidebarCollapsed:E_(n.sidebarCollapsed,r.sidebarCollapsed),desktopSidebarView:T_(n.desktopSidebarView??r.desktopSidebarView),terminalPanelVisible:E_(n.terminalPanelVisible,r.terminalPanelVisible)}}var j_=Yr(()=>window.localStorage),M_={...j_,getItem:(e,t)=>{let n=typeof window<`u`&&window.localStorage.getItem(e)===null?k_():void 0;return A_(j_.getItem(e,t),n)},setItem:(e,t)=>j_.setItem(e,A_(t))};function N_(e){return e(zp)??x_}function P_(e,t){return typeof t==`function`?t(e):t}function F_(e){return Ap(t=>V(n=>n(L_(t))[e],(n,r,i)=>{let a=n(L_(t)),o=P_(a[e],i);Object.is(o,a[e])||r(L_(t),{...a,[e]:o})}))}function I_(e){return V(t=>t(e(N_(t))),(t,n,r)=>{n(e(N_(t)),r)})}var L_=Ap(e=>Zr(`ui.workspaceLayout.${e}`,w_,M_,{getOnInit:!0})),R_=F_(`focusMode`),z_=F_(`leftPanelWidth`),B_=F_(`bottomPanelHeight`),V_=F_(`sidebarCollapsed`),H_=F_(`desktopSidebarView`),U_=F_(`terminalPanelVisible`),W_=I_(R_);I_(z_);var G_=I_(B_),K_=I_(V_),q_=I_(H_),J_=I_(U_),Y_=new Set([`workspace_open`,`session_start`,`mobile_continue`,`manual_check`]);function X_(e){let t=new URLSearchParams;t.set(`context`,e.context),e.workspaceId&&t.set(`workspaceId`,e.workspaceId),e.workspacePath&&t.set(`workspacePath`,e.workspacePath),e.providerId&&t.set(`providerId`,e.providerId),e.paneId&&t.set(`paneId`,e.paneId),e.launchMode&&t.set(`launchMode`,e.launchMode);let n=t.toString();return n.length>0?`/diagnostics?${n}`:`/diagnostics`}function Z_(e){let t=new URLSearchParams(e),n=t.get(`context`),r=Y_.has(n)?n:`manual_check`,i=t.get(`launchMode`);return{context:r,workspaceId:t.get(`workspaceId`)??void 0,workspacePath:t.get(`workspacePath`)??void 0,providerId:t.get(`providerId`)??void 0,paneId:t.get(`paneId`)??void 0,launchMode:i===`assign`||i===`replace`?i:void 0}}var Q_=`ui.paneLayout.`,$_=`ui.paneRatio.`,ev={id:`root`,type:`leaf`},tv=Ap(e=>V(ev));function nv(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function rv(e){let t=nv();if(!t)return null;try{let n=t.getItem(`${Q_}${e}`);return n?JSON.parse(n):null}catch{return null}}function iv(e){let t=nv();if(t)try{t.removeItem(`${Q_}${e}`)}catch{}}function av(e,t){let n=nv();if(!n)return null;try{let r=n.getItem(`${$_}${e}.${t}`);if(r===null)return null;let i=Number(r);return Number.isFinite(i)?i:null}catch{return null}}function ov(e,t,n){let r=nv();if(r)try{r.setItem(`${$_}${e}.${t}`,String(n))}catch{}}function sv(e){return{id:e,type:`leaf`}}function cv(e,t){return{id:e,type:`leaf`,sessionId:t}}function lv(e,t){return`split-${e}-${t}-${Date.now()}`}function uv(e,t){if(e.type===`leaf`)return e.id===t?e:null;for(let n of e.children??[]){let e=uv(n,t);if(e)return e}return null}function dv(e,t,n){if(e.type===`leaf`)return e.id===t?n(e):e;let r=e.children??[],i=!1,a=r.map(e=>{let r=dv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function fv(e,t){if(e.type===`leaf`)return e.id===t?null:e;let n=e.children??[],r=!1,i=[];for(let e of n){let n=fv(e,t);n!==e&&(r=!0),n!==null&&i.push(n)}return r?i.length===1?i[0]:i.length===0?null:{...e,children:i}:e}function pv(e,t,n){if(e.type===`leaf`){if(e.id!==t)return e;let r=`split-${e.id}-${n}-${Date.now()}`;return{id:r,type:`split`,direction:n,ratio:.5,children:[{...e},sv(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=pv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function mv(e,t,n){if(e.type===`leaf`){if(e.sessionId!==t)return e;let r=`split-${e.id}-${n}-${Date.now()}`;return{id:r,type:`split`,direction:n,ratio:.5,children:[{...e},sv(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=mv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function hv(e,t,n){if(e.type===`leaf`)return e.id===t?{...e,sessionId:n}:e;let r=e.children??[],i=!1,a=r.map(e=>{let r=hv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function gv(e,t,n){if(e.type===`leaf`)return e.sessionId===t?{...e,sessionId:n}:e;let r=e.children??[],i=!1,a=r.map(e=>{let r=gv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function _v(e,t,n){if(t===n)return e;let r=uv(e,t),i=uv(e,n);return!r?.sessionId||!i?.sessionId?e:dv(dv(e,t,e=>({...e,sessionId:i.sessionId})),n,e=>({...e,sessionId:r.sessionId}))}function vv(e,t,n){if(t===n)return e;let r=uv(e,t),i=uv(e,n);return!r?.sessionId||!i||i.sessionId?e:hv(fv(e,t)??{id:e.id,type:`leaf`},n,r.sessionId)}function yv(e,t,n,r){if(t===n)return e;let i=uv(e,t),a=uv(e,n);if(!i?.sessionId||!a?.sessionId)return e;let o=fv(e,t)??{id:e.id,type:`leaf`},s={id:i.id,type:`leaf`,sessionId:i.sessionId};return dv(o,n,e=>({id:lv(e.id,r),type:`split`,direction:r===`left`||r===`right`?`horizontal`:`vertical`,ratio:.5,children:r===`left`||r===`top`?[s,e]:[e,s]}))}function bv(e,t){return t.startsWith(`__draft__`)?Sv(e,t.replace(`__draft__`,``)):Cv(e,t)}function xv(e,t){if(e.type===`leaf`)return e.id===t&&!e.sessionId?null:e;let n=e.children??[],r=!1,i=[];for(let e of n){let n=xv(e,t);n!==e&&(r=!0),n!==null&&i.push(n)}return r?i.length===1?i[0]:i.length===0?null:{...e,children:i}:e}function Sv(e,t){return xv(e,t)??{id:e.id,type:`leaf`}}function Cv(e,t){if(e.type===`leaf`)return e.sessionId===t?{id:e.id,type:`leaf`}:e;let n=e.children??[],r=!1,i=n.map(e=>{let n=Cv(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function wv(e,t){return Tv(e,t)??{id:e.id,type:`leaf`}}function Tv(e,t){if(e.type===`leaf`)return e.sessionId===t?null:e;let n=e.children??[],r=!1,i=[];for(let e of n){let n=Tv(e,t);n!==e&&(r=!0),n!==null&&i.push(n)}return r?i.length===1?i[0]:i.length===0?null:{...e,children:i}:e}function Ev(e){return e.type===`leaf`?e.sessionId?[e.sessionId]:[]:e.children?.flatMap(e=>Ev(e))??[]}function Dv(e,t,n,r=`horizontal`){let i=jv(e,t);if(i)return i;if(n){let i=Mv(e,t,r,n);if(i)return i}return Mv(e,t,r)||(e.type===`leaf`&&!e.sessionId?{...e,sessionId:t}:{id:`root`,type:`leaf`,sessionId:t})}function Ov(e,t){return jv(e,t)||Nv(e,t)||Dv(e,t,void 0,`horizontal`)}function kv(e){if(e.length===0)return{id:`root`,type:`leaf`};if(e.length===1)return{id:`fallback-leaf-1`,type:`leaf`,sessionId:e[0]};let[t,...n]=e;return{id:`split-fallback-1`,type:`split`,direction:`horizontal`,ratio:.5,children:[{id:`fallback-leaf-1`,type:`leaf`,sessionId:t},Rv(n,2)]}}function Av(e,t){if(e.type===`leaf`)return e.sessionId&&!t.has(e.sessionId)?{id:e.id,type:`leaf`}:e;let n=e.children??[],r=!1,i=n.map(e=>{let n=Av(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function jv(e,t){if(e.type===`leaf`)return e.sessionId?null:{...e,sessionId:t};let n=e.children??[];for(let r=0;r<n.length;r+=1){let i=n[r],a=jv(i,t);if(a)return{...e,children:n.map((e,t)=>t===r?a:e)}}return null}function Mv(e,t,n,r){if(e.type===`leaf`){if(!e.sessionId||r&&e.sessionId!==r)return null;let i=`split-${e.id}-${n}-${Date.now()}`;return{id:i,type:`split`,direction:n,ratio:.5,children:[{...e},cv(`${i}-session`,t)]}}let i=e.children??[];for(let a=0;a<i.length;a+=1){let o=i[a],s=Mv(o,t,n,r);if(s)return{...e,children:i.map((e,t)=>t===a?s:e)}}return null}function Nv(e,t){let n=Pv(e);return n?Lv(e,n.path,e=>{let n=`split-${e.id}-horizontal-${Date.now()}`;return{id:n,type:`split`,direction:`horizontal`,ratio:.5,children:[{...e},cv(`${n}-session`,t)]}}):null}function Pv(e,t=1,n=[]){if(e.type===`leaf`)return e.sessionId?{path:n,width:t}:null;let r=e.children??[];if(r.length===0)return null;if(e.direction===`vertical`)return Fv(e)?{path:n,width:t}:null;let i=e.ratio??.5,a=t*i,o=t*(1-i);return Iv(Pv(r[0],a,[...n,0]),Pv(r[1],o,[...n,1]))}function Fv(e){return e.type===`leaf`?!!e.sessionId:(e.children??[]).some(e=>Fv(e))}function Iv(...e){let t=null;for(let n of e)n&&(!t||n.width>t.width)&&(t=n);return t}function Lv(e,t,n){if(t.length===0)return n(e);if(e.type===`leaf`)return e;let[r,...i]=t,a=e.children??[];return{...e,children:a.map((e,t)=>t===r?Lv(e,i,n):e)}}function Rv(e,t){if(e.length===1)return{id:`fallback-leaf-${t}`,type:`leaf`,sessionId:e[0]};let[n,...r]=e;return{id:`split-fallback-${t}`,type:`split`,direction:`horizontal`,ratio:.5,children:[{id:`fallback-leaf-${t}`,type:`leaf`,sessionId:n},Rv(r,t+1)]}}function zv(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.path==`string`&&typeof t.uiState==`object`&&t.uiState!==null}function Bv(e){let t=U(Op),n=W(Mp),r=ve();return{persistUiState:(0,H.useCallback)(async i=>{if(!e||e.startsWith(`__workspace_`))return!1;let a=r.get(Mp)[e];if(!a)return!1;let o={...a.uiState,leftPanelWidth:r.get(z_(e)),bottomPanelHeight:r.get(B_(e)),focusMode:r.get(R_(e)),...i};n(t=>{let n=t[e];return n?{...t,[e]:{...n,uiState:o}}:t});try{let r=await t(`workspace.uiState.set`,{workspaceId:e,uiState:o});return r.ok?(zv(r.data)&&n(t=>({...t,[e]:r.data})),!0):(console.error(`Failed to persist workspace ui state:`,r.error?.message),!1)}catch(e){return console.error(`Failed to persist workspace ui state:`,e),!1}},[t,n,r,e])}}function Vv(e){return e===`claude`?`Claude`:e===`codex`?`Codex`:e??`Provider`}function Hv(e){return Array.isArray(e)&&e.length>0?e.join(`, `):`—`}function Uv(e){if(typeof window>`u`||!e||e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`0.0.0.0`)return null;let t=window.location.protocol===`https:`||window.location.protocol===`http:`?window.location.protocol:`http:`,n=new URL(`${t}//${e}`);return window.location.port&&(n.port=window.location.port),n.pathname=`/workspace`,n.search=``,n.hash=``,n.toString()}function Wv(e,t){let n=Vv(t.providerId);switch(t.code){case`workspace_selection_missing`:return{title:e(`diagnostics.checks.workspace_selection_missing.title`),description:e(`diagnostics.checks.workspace_selection_missing.description`)};case`workspace_path_ready`:return{title:e(`diagnostics.checks.workspace_path_ready.title`),description:e(`diagnostics.checks.workspace_path_ready.description`)};case`workspace_path_not_found`:return{title:e(`diagnostics.checks.workspace_path_not_found.title`),description:e(`diagnostics.checks.workspace_path_not_found.description`)};case`workspace_path_unreadable`:return{title:e(`diagnostics.checks.workspace_path_unreadable.title`),description:e(`diagnostics.checks.workspace_path_unreadable.description`)};case`session_workspace_ready`:return{title:e(`diagnostics.checks.session_workspace_ready.title`),description:e(`diagnostics.checks.session_workspace_ready.description`)};case`session_workspace_missing`:return{title:e(`diagnostics.checks.session_workspace_missing.title`),description:e(`diagnostics.checks.session_workspace_missing.description`)};case`git_ready`:return{title:e(`diagnostics.checks.git_ready.title`),description:e(`diagnostics.checks.git_ready.description`)};case`git_missing`:return{title:e(`diagnostics.checks.git_missing.title`),description:e(`diagnostics.checks.git_missing.description`)};case`nodejs_ready`:return{title:e(`diagnostics.checks.nodejs_ready.title`),description:e(`diagnostics.checks.nodejs_ready.description`)};case`nodejs_missing`:return{title:e(`diagnostics.checks.nodejs_missing.title`),description:e(`diagnostics.checks.nodejs_missing.description`)};case`provider_runtime_ready`:return{title:e(`diagnostics.checks.provider_runtime_ready.title`,{provider:n}),description:e(`diagnostics.checks.provider_runtime_ready.description`,{provider:n})};case`provider_cli_missing`:return{title:e(`diagnostics.checks.provider_cli_missing.title`,{provider:n}),description:e(`diagnostics.checks.provider_cli_missing.description`,{provider:n})};case`provider_prerequisite_missing`:return{title:e(`diagnostics.checks.provider_prerequisite_missing.title`,{provider:n}),description:e(`diagnostics.checks.provider_prerequisite_missing.description`,{provider:n})};case`provider_unknown`:return{title:e(`diagnostics.checks.provider_unknown.title`),description:e(`diagnostics.checks.provider_unknown.description`)};case`server_auth_ready`:return{title:e(`diagnostics.checks.server_auth_ready.title`),description:e(`diagnostics.checks.server_auth_ready.description`)};case`server_auth_not_required`:return{title:e(`diagnostics.checks.server_auth_not_required.title`),description:e(`diagnostics.checks.server_auth_not_required.description`)};case`mobile_host_ready`:return{title:e(`diagnostics.checks.mobile_host_ready.title`),description:e(`diagnostics.checks.mobile_host_ready.description`)};case`mobile_host_local_only`:return{title:e(`diagnostics.checks.mobile_host_local_only.title`),description:e(`diagnostics.checks.mobile_host_local_only.description`)};case`mobile_auth_disabled`:return{title:e(`diagnostics.checks.mobile_auth_disabled.title`),description:e(`diagnostics.checks.mobile_auth_disabled.description`)};default:return{title:t.code,description:t.code}}}function Gv(){let e=Z(),t=Qt(),n=Yt(),r=Br()===`mobile`,i=Z_(n.search),a=ve(),o=U(Op),s=Aa(),c=U(xp),l=Xg(),u=W(jp),d=W(Np),f=W(Mp),p=W(Fp),m=W(Pp),h=W(Vp),g=U(no),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!0),[x,S]=(0,H.useState)(null),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)(!1),D=(0,H.useRef)(null),O=Bv(i.workspaceId??_?.metadata.workspaceId??`__workspace_empty__`);function k(e,t,n,r){let i=a.get(tv(e));return r===`assign`&&n?hv(i??ev,n,t):{id:`root`,type:`leaf`,sessionId:t}}(0,H.useEffect)(()=>()=>{D.current!==null&&window.clearTimeout(D.current)},[]);let A={context:i.context,workspaceId:i.workspaceId,workspacePath:i.workspacePath,providerId:i.providerId},j=async t=>{if(c!==`connected`)return;b(!0),S(null);let n=await o(t,A);if(!n.ok||!n.data){v(null),S(n.error?.message??e(`diagnostics.load_failed`)),b(!1);return}v(n.data),S(null),b(!1)};(0,H.useEffect)(()=>{j(`diagnostics.get`)},[c,i.context,i.providerId,i.workspaceId,i.workspacePath]);let M=async()=>{let e={intent:i,response:_,loadError:x,actionError:C,lastViewedTarget:g};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),E(!0),D.current!==null&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{E(!1)},1500)},N=async()=>{if(!i.workspacePath)return;let n=await o(`workspace.open`,{path:i.workspacePath});if(!n.ok||!n.data?.id){w(n.error?.message??e(`workspace.launch.open_failed`)),await j(`diagnostics.recheck`);return}await l({workspaceId:n.data.id}),u(n.data.id),f(e=>({...e,[n.data.id]:n.data})),d(e=>e.includes(n.data.id)?e:[n.data.id,...e]),m(`ready`),p(null),t(`/workspace`)},P=async()=>{let n=i.workspaceId??_?.metadata.workspaceId,r=i.providerId??_?.metadata.providerId;if(!n||!r){w(e(`diagnostics.load_failed`));return}let c=await o(`session.create`,{workspaceId:n,providerId:r,themeBackground:s});if(!c.ok||!c.data){w(c.error?.message??e(`diagnostics.load_failed`)),await j(`diagnostics.recheck`);return}h(e=>({...e,[c.data.id]:c.data})),u(n),m(`ready`),p(null),d(e=>e.includes(n)?e:[n,...e]),await l({workspaceId:n,sessionId:c.data.id});let f=k(n,c.data.id,i.paneId,i.launchMode);a.set(tv(n),f),O.persistUiState({activeSessionId:c.data.id,paneLayout:f}),t(`/workspace`)},F=async()=>{let t=i.workspaceId??_?.metadata.workspaceId,n=t&&g?.workspaceId===t?g.sessionId??void 0:void 0;t&&await l({workspaceId:t,sessionId:n});let r=Uv(_?.metadata.host);if(!r){w(e(`diagnostics.load_failed`));return}if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(r);return}w(e(`diagnostics.load_failed`))},ee=async()=>{if(w(null),i.context===`workspace_open`){await N();return}if(i.context===`session_start`){if(_?.canContinue){await P();return}await j(`diagnostics.recheck`);return}if(i.context===`mobile_continue`){if(_?.canContinue){await F();return}await j(`diagnostics.recheck`);return}await j(`diagnostics.recheck`)},I=()=>i.context===`workspace_open`?e(`diagnostics.actions.retry_workspace`):i.context===`session_start`?_?.canContinue?e(`diagnostics.actions.continue_session`):e(`diagnostics.actions.recheck`):i.context===`mobile_continue`&&_?.canContinue?e(`diagnostics.actions.continue_phone`):e(`diagnostics.actions.recheck`),L=i.context===`workspace_open`?!!_?.canContinue:!0,R=e(`diagnostics.context.${i.context}.title`),z=e(`diagnostics.context.${i.context}.description`),te=typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`,ne=()=>{t(-1)};return(0,X.jsxs)(`div`,{className:`diagnostics-page ${r?`diagnostics-page--mobile`:``}`,children:[(0,X.jsx)(`header`,{className:`diagnostics-header`,children:r?(0,X.jsx)(rm,{title:e(`diagnostics.title`),titleAs:`div`,onBack:ne,backLabel:e(`action.back`)}):(0,X.jsx)(nm,{title:e(`diagnostics.title`),titleAs:`h1`,level:`secondary`,onBack:ne,backLabel:e(`action.back`)})}),(0,X.jsx)(`div`,{className:`diagnostics-body ${r?`diagnostics-body--mobile`:``}`,children:(0,X.jsx)(`main`,{className:`diagnostics-content ${r?`diagnostics-content--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`diagnostics-content-surface`,children:[(0,X.jsxs)(`section`,{className:`diagnostics-summary ${r?`diagnostics-summary--mobile`:``}`,children:[(0,X.jsxs)(`div`,{className:`diagnostics-summary__copy`,children:[r?null:(0,X.jsxs)(`div`,{className:`diagnostics-summary__eyebrow`,children:[(0,X.jsx)($,{semantic:`state.warning`,size:16}),(0,X.jsx)(`span`,{children:e(`diagnostics.title`)})]}),r?(0,X.jsx)(`h1`,{className:`diagnostics-summary__title`,children:R}):(0,X.jsx)(`h2`,{className:`diagnostics-summary__title`,children:R}),(0,X.jsx)(`p`,{className:`diagnostics-summary__description`,children:z})]}),(0,X.jsx)(`div`,{className:`diagnostics-actions ${r?`diagnostics-actions--mobile`:``}`,children:(0,X.jsx)(Q,{className:r?`diagnostics-actions__primary`:void 0,leadingIcon:(0,X.jsx)(ta,{size:16}),loading:y,disabled:!L,onClick:()=>{ee()},variant:`primary`,children:I()})})]}),x||C?(0,X.jsx)(jh,{role:`alert`,tone:`error`,title:e(`diagnostics.load_failed`),message:C??x??``}):null,(0,X.jsx)(`div`,{className:`diagnostics-toolbar ${r?`diagnostics-toolbar--mobile`:``}`,children:te?(0,X.jsx)(Q,{leadingIcon:(0,X.jsx)(Ci,{size:16}),onClick:()=>{M()},size:`sm`,variant:`ghost`,children:e(T?`diagnostics.actions.copied`:`diagnostics.actions.copy_details`)}):null}),y?(0,X.jsx)(`div`,{className:`diagnostics-loading`,children:e(`diagnostics.loading_description`)}):null,_?(0,X.jsx)(`section`,{className:`diagnostics-results`,"aria-label":e(`diagnostics.title`),children:(0,X.jsx)(`div`,{className:`diagnostics-issues`,children:_.checks.map(t=>{let n=Wv(e,t);return(0,X.jsxs)(`div`,{className:`diagnostics-issue`,children:[(0,X.jsxs)(`div`,{className:`diagnostics-issue__header`,children:[(0,X.jsx)(_g,{caps:!1,color:t.status===`ready`?`green`:t.status===`checking`?`blue`:`amber`,size:`sm`,children:e(`diagnostics.status.${t.status}`)}),(0,X.jsx)(`div`,{className:`diagnostics-issue__title`,children:n.title})]}),(0,X.jsx)(`p`,{className:`diagnostics-issue__description`,children:n.description}),(0,X.jsxs)(`div`,{className:`diagnostics-issue__meta`,children:[t.workspacePath?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.workspace`),`: `,t.workspacePath]}):null,t.providerId?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.provider`),`:`,` `,Vv(t.providerId)]}):null,t.missingCommands?.length?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.missing_commands`),`:`,` `,Hv(t.missingCommands)]}):null,t.missingPrerequisites?.length?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.missing_prerequisites`),`:`,` `,Hv(t.missingPrerequisites)]}):null,t.version?(0,X.jsxs)(`span`,{children:[e(`diagnostics.details.current_version`),`: `,t.version]}):null]}),t.manualGuideKeys?.length?(0,X.jsx)(`div`,{className:`diagnostics-issue__guides`,children:t.manualGuideKeys.map(t=>(0,X.jsx)(`span`,{children:e(t)},t))}):null,(0,X.jsx)(`div`,{className:`diagnostics-issue__actions`,children:t.docUrl?(0,X.jsx)(Q,{as:`a`,href:t.docUrl,rel:`noreferrer`,size:`sm`,target:`_blank`,variant:`ghost`,children:e(`provider.install.open_docs`)}):null})]},t.id)})})}):null]})})})]})}function Kv(e){let t=Z(),n=Yt(),r=Qt(),i=U(Op),a=W(jp),o=W(Mp),s=W(Np),c=W(Pp),l=W(Fp),u=Xg(),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)([]),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!0),[C,w]=(0,H.useState)(null),[T,E]=(0,H.useState)([`/`]),[D,O]=(0,H.useState)(null),k=t(`workspace.launch.title`),A=t(`workspace.launch.hint`);(0,H.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let j=(0,H.useCallback)(async e=>{S(!0),w(null);try{let n=await i(`workspace.browse`,{path:e});if(!n.ok||!n.data){w(n.error?.message||t(`workspace.launch.browse_failed`));return}f(n.data.currentPath),m(n.data.directories),g(n.data.parentPath);let r=n.data.rootPaths?.filter(Boolean)??[`/`];E(r),O(r.find(e=>e!==`/`)??null)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},[i]);(0,H.useEffect)(()=>{j()},[j]);let M=(0,H.useCallback)(e=>{v(null),j(e)},[j]),N=(0,H.useCallback)(e=>{v(e)},[]),P=(0,H.useCallback)(async()=>{if(!_){w(t(`workspace.launch.select_required`));return}b(!0),w(null);try{let t=await i(`workspace.open`,{path:_});t.ok&&t.data?.id?(u({workspaceId:t.data.id}),a(t.data.id),o(e=>({...e,[t.data.id]:t.data})),s(e=>e.includes(t.data.id)?e:[t.data.id,...e]),c(`ready`),l(null),n.pathname!==`/workspace`&&r(`/workspace`),e()):r(X_({context:`workspace_open`,workspacePath:_}))}catch{r(X_({context:`workspace_open`,workspacePath:_}))}finally{b(!1)}},[i,n.pathname,r,e,_,a,u,s,o,l,c,t]);return{browsing:x,currentPath:d,directories:p,error:C,getShortPath:(0,H.useCallback)(e=>e===`/`?`/`:D&&e===D?`~`:D&&e.startsWith(`${D}/`)?`~${e.slice(D.length)}`:e,[D]),handleNavigate:M,handleOpen:P,handleSelect:N,launchHint:A,launchTitle:k,loading:y,parentPath:h,rootPaths:T,selectedPath:_}}function qv(e,t){let n=U(bp),[r,i]=(0,H.useState)(`status`),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)([]),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null);return(0,H.useEffect)(()=>{if(!t||!n||!e){o(null),c(``),u([]);return}f(!0),m(null),(async()=>{try{r===`status`?o((await n.sendCommand(`worktree.status`,{workspaceId:e,worktreePath:t.path})).status):r===`diff`?c((await n.sendCommand(`worktree.diff`,{workspaceId:e,worktreePath:t.path})).diff):r===`tree`&&u((await n.sendCommand(`worktree.tree`,{workspaceId:e,worktreePath:t.path})).tree)}catch(e){m(e instanceof Error?e.message:`Failed to load data`)}finally{f(!1)}})()},[r,e,t,n]),{activeTab:r,diff:s,error:p,handleTabChange:(0,H.useCallback)(e=>{i(e)},[]),loading:d,status:a,tree:l}}var Jv={minHeight:`auto`,padding:`var(--sp-6)`,gap:0},Yv={padding:`var(--sp-8)`,gap:`var(--sp-2)`},Xv={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},Zv={position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0};function Qv({onClose:e}){let t=Br()===`mobile`,n=Z(),{browsing:r,currentPath:i,directories:a,error:o,getShortPath:s,handleNavigate:c,handleOpen:l,handleSelect:u,launchHint:d,launchTitle:f,loading:p,parentPath:m,rootPaths:h,selectedPath:g}=Kv(e),_=(0,X.jsxs)(`div`,{className:`launch-body`,children:[(0,X.jsxs)(`div`,{className:`folder-picker`,children:[(0,X.jsxs)(`div`,{className:`fp-toolbar`,children:[(0,X.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(`~`),children:[(0,X.jsx)($,{semantic:`workspace.launch.home`,size:12}),n(`workspace.launch.home_directory`)]}),m&&(0,X.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(m),children:[(0,X.jsx)(pi,{size:12}),n(`workspace.launch.go_up`)]})]}),(0,X.jsxs)(`div`,{className:`fp-root-chips`,children:[h.map(e=>(0,X.jsx)(`span`,{className:`fp-chip ${i===e?`active`:``}`,onClick:()=>c(e),children:s(e)},e)),i&&!h.includes(i)&&(0,X.jsx)(`span`,{className:`fp-chip active`,children:s(i)})]}),(0,X.jsx)(`div`,{className:`fp-dir-list`,children:r?(0,X.jsx)(Sh,{className:`directory-loading`,icon:(0,X.jsx)(ig,{label:n(`common.loading`)}),style:Yv,title:(0,X.jsx)(`span`,{style:Zv,children:n(`common.loading`)})}):a.length===0?(0,X.jsx)(Sh,{className:`directory-empty`,style:Jv,title:(0,X.jsx)(`p`,{style:Xv,children:n(`workspace.launch.no_directories`)})}):a.map(e=>(0,X.jsxs)(`div`,{className:`fp-dir ${g===e.path?`selected`:``}`,onClick:()=>u(e.path),onDoubleClick:()=>c(e.path),children:[(0,X.jsx)(`span`,{className:`fp-dir-icon`,children:(0,X.jsx)($,{semantic:`file.folder.closed`,size:14})}),(0,X.jsx)(`span`,{className:`fp-dir-name ${g===e.path?`selected`:``}`,children:e.name}),e.itemCount!==void 0&&(0,X.jsx)(`span`,{className:`fp-dir-hint`,children:n(`workspace.launch.items_count`,{count:e.itemCount})}),g===e.path&&(0,X.jsx)(`button`,{className:`fp-dir-action`,type:`button`,"aria-label":n(`workspace.launch.enter_folder`,{name:e.name}),onClick:t=>{t.stopPropagation(),c(e.path)},children:n(`workspace.launch.enter_folder_action`)})]},e.path))})]}),o&&(0,X.jsx)(`div`,{className:`form-error`,style:{marginTop:`var(--sp-3)`},children:o})]}),v=(0,X.jsx)(`div`,{className:`mobile-launch-sheet__footer`,children:(0,X.jsx)(`button`,{className:`launch-start-btn launch-start-btn--mobile`,onClick:()=>void l(),disabled:p||!g,children:n(p?`workspace.launch.starting`:`workspace.launch.start`)})});return t?(0,X.jsx)(fm,{kicker:n(`workspace.launch.kicker`),title:f,body:_,footer:v,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen mobile-launch-sheet`,contentClassName:`mobile-sheet--launch`,onClose:e}):(0,X.jsx)(Rg,{ariaLabel:f,onOpenChange:t=>{t||e()},open:!0,children:(0,X.jsxs)(`div`,{className:`launch-modal`,children:[(0,X.jsxs)(`div`,{className:`launch-header`,children:[(0,X.jsxs)(`div`,{className:`launch-header-left`,children:[(0,X.jsx)(`div`,{className:`launch-kicker`,children:n(`workspace.launch.kicker`)}),(0,X.jsx)(`div`,{className:`launch-title`,children:f}),(0,X.jsx)(`div`,{className:`launch-hint`,children:d})]}),(0,X.jsx)(`div`,{className:`launch-header-right`,children:(0,X.jsx)(Em,{"aria-label":n(`action.close`),className:`launch-close-btn`,icon:(0,X.jsx)(pa,{size:16}),onClick:e,size:`sm`})})]}),_,(0,X.jsx)(`div`,{className:`launch-footer`,children:(0,X.jsx)(`button`,{className:`launch-start-btn launch-start-btn--desktop`,onClick:()=>void l(),disabled:p||!g,children:n(p?`workspace.launch.starting`:`workspace.launch.start`)})})]})})}var $v={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},ey={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function ty(){let e=Z(),t=Yt(),n=Qt(),r=Br()===`mobile`,[i,a]=Te($a),[o,s]=Te(W_),[c,l]=Te(K_),[u,d]=Te(J_),[f,p]=Te(G_),m=U(zp),h=W(jp),g=W(eo),_=Zg(),v=U(Rp),[y,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(0),[C,w]=(0,H.useState)(!1),T=(0,H.useRef)(null),E=ny({shellKind:r?`mobile`:`desktop`,focusMode:o,setFocusMode:s,sidebarCollapsed:c,setSidebarCollapsed:l,terminalPanelVisible:u,setTerminalPanelVisible:d,bottomPanelHeight:f,setBottomPanelHeight:p,activeWorkspaceId:m,setActiveWorkspaceId:h,selectWorkspaceTarget:_,workspaces:v,locationPathname:t.pathname,navigate:n,t:e,setQuickOpenOpen:g,setShowWorkspaceLaunch:e=>{e&&a(!1),w(e)}}).filter(e=>{let t=y.toLowerCase();return e.label.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.shortcut&&e.shortcut.toLowerCase().includes(t)});(0,H.useEffect)(()=>{i&&(T.current?.focus(),b(``),S(0))},[i]);let D=(0,H.useCallback)(e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),S(e=>e<E.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),S(e=>e>0?e-1:e);break;case`Enter`:e.preventDefault(),E[x]&&(E[x].action(),a(!1));break;case`Escape`:e.preventDefault(),a(!1);break}},[E,x,a]);(0,H.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),a(!i))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,a]);let O=e=>{e.action(),a(!1)},k=(0,X.jsxs)(`div`,{className:`command-palette-search`,children:[(0,X.jsx)($,{className:`command-palette-search-icon`,semantic:`nav.search`,size:16}),(0,X.jsx)(`input`,{ref:T,type:`text`,className:`command-palette-input`,placeholder:e(`placeholder.command`),value:y,onChange:e=>{b(e.target.value),S(0)}})]}),A=(0,X.jsx)(`div`,{className:`command-palette-list`,children:E.length>0?E.map((e,t)=>(0,X.jsxs)(`div`,{className:`command-palette-item ${t===x?`command-palette-item-selected`:``}`,onClick:()=>O(e),onMouseEnter:()=>S(t),children:[(0,X.jsxs)(`div`,{className:`command-palette-item-content`,children:[(0,X.jsx)(`span`,{className:`command-palette-item-label`,children:e.label}),(0,X.jsx)(`span`,{className:`command-palette-item-desc`,children:e.description})]}),e.shortcut?(0,X.jsx)(`span`,{className:`command-palette-item-shortcut`,children:e.shortcut}):null]},e.id)):(0,X.jsx)(Sh,{className:`command-palette-empty`,style:$v,title:(0,X.jsx)(`p`,{style:ey,children:e(`command.no_results`)})})});return C?(0,X.jsx)(Qv,{onClose:()=>w(!1)}):i?r?(0,X.jsx)(fm,{title:`Quick Actions`,kicker:e(`command.palette`).toUpperCase(),onClose:()=>a(!1),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`command-palette-sheet-layer`,body:(0,X.jsx)(`div`,{className:`command-palette-sheet-shell`,onKeyDown:D,children:(0,X.jsxs)(`div`,{className:`command-palette-sheet`,children:[(0,X.jsxs)(`div`,{className:`command-palette-sheet__search`,children:[k,(0,X.jsxs)(`div`,{className:`command-palette-sheet__meta`,children:[(0,X.jsx)(`span`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),(0,X.jsxs)(`span`,{className:`command-palette-meta`,children:[E.length,` actions`]})]})]}),A]})})}):(0,X.jsx)(Rg,{ariaLabel:e(`command.palette`),initialFocus:()=>T.current,onOpenChange:a,open:!0,children:(0,X.jsxs)(`div`,{className:`command-palette command-palette--desktop`,onKeyDown:D,children:[(0,X.jsxs)(`div`,{className:`command-palette-header`,children:[(0,X.jsx)(`span`,{className:`command-palette-kicker`,children:e(`command.palette`).toUpperCase()}),(0,X.jsxs)(`span`,{className:`command-palette-meta`,children:[E.length,` actions`]})]}),k,(0,X.jsx)(`div`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),A]})}):null}function ny(e){let{shellKind:t,focusMode:n,setFocusMode:r,sidebarCollapsed:i,setSidebarCollapsed:a,terminalPanelVisible:o,setTerminalPanelVisible:s,bottomPanelHeight:c,setBottomPanelHeight:l,activeWorkspaceId:u,setActiveWorkspaceId:d,selectWorkspaceTarget:f,workspaces:p,locationPathname:m,navigate:h,t:g,setQuickOpenOpen:_,setShowWorkspaceLaunch:v}=e,y=[{id:`new-workspace`,label:g(`workspace.open`),description:g(`workspace.open_hint`),shortcut:`Ctrl+N`,action:()=>{v(!0)}},{id:`open-home`,label:g(`workspace.title`),description:g(`action.back`),action:()=>h(`/`)},{id:`open-settings`,label:g(`action.settings`),description:g(`settings.title`),shortcut:`Ctrl+,`,action:()=>{h(`/settings`)}}];return t===`desktop`&&y.push(...u?[{id:`go-to-file`,label:g(`quick_open.command_label`),description:g(`quick_open.command_description`),shortcut:`Ctrl+P`,action:()=>_(!0)}]:[],{id:`toggle-focus-mode`,label:g(`tooltip.focus_mode`),description:g(n?`action.close`:`action.open`),shortcut:`F`,action:()=>r(!n)},{id:`enable-focus-mode`,label:`${g(`action.open`)} Focus Mode`,description:g(`tooltip.focus_mode`),action:()=>r(!0)},{id:`disable-focus-mode`,label:`${g(`action.close`)} Focus Mode`,description:g(`tooltip.focus_mode`),action:()=>r(!1)},{id:`toggle-sidebar`,label:g(`command.shortcut.toggle_sidebar`),description:g(i?`action.open`:`action.close`),action:()=>a(!i)},{id:`toggle-terminal`,label:g(`terminal.title`),description:g(o?`action.close`:`action.open`),action:()=>{s(!o),!o&&c===0&&l(200)}},{id:`show-terminal`,label:`${g(`action.open`)} ${g(`terminal.title`)}`,description:g(`command.shortcut.toggle_terminal`),action:()=>{s(!0),c===0&&l(200)}},{id:`hide-terminal`,label:`${g(`action.close`)} ${g(`terminal.title`)}`,description:g(`command.shortcut.toggle_terminal`),action:()=>s(!1)}),p.forEach(e=>{let t=Ug(e)||e.id;y.push({id:`switch-workspace-${e.id}`,label:`${g(`workspace.title`)}: ${t}`,description:e.path||e.id,action:()=>{f(e.id),m!==`/workspace`&&h(`/workspace`)}})}),u&&y.push({id:`go-home`,label:g(`action.back`),description:g(`workspace.no_workspace`),action:()=>{d(null),h(`/`)}}),y}var ry={minHeight:`auto`,padding:0,gap:`var(--sp-5)`};function iy(){let e=Z(),t=Qt(),n=Yt(),r=Br()===`mobile`;return(0,X.jsx)(`div`,{className:`welcome-container ${r?`welcome-container--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`welcome-card ${r?`welcome-card--mobile`:``}`,children:[(0,X.jsx)(`div`,{className:`welcome-card__hero`,children:(0,X.jsx)(Sh,{style:ry,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`not_found.kicker`)}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`not_found.title`)})]}),description:(0,X.jsx)(`div`,{className:`welcome-content`,children:(0,X.jsx)(`p`,{className:`welcome-body meta-text`,children:e(`not_found.description`)})})})}),(0,X.jsx)(`div`,{className:`welcome-card__actions`,children:(0,X.jsx)(`button`,{className:`welcome-btn`,onClick:()=>t(`/`),children:(0,X.jsx)(`span`,{children:e(`not_found.go_home`)})})}),(0,X.jsx)(`div`,{className:`welcome-card__panel`,children:(0,X.jsxs)(`div`,{className:`auth-status-panel`,children:[(0,X.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`not_found.path_label`)}),(0,X.jsx)(`p`,{className:`auth-status-detail`,children:n.pathname})]})})]})})}var ay=Zr(`ui.notificationPreferences`,{enabled:!0,soundEnabled:!0}),oy=V([]),sy=V(null,(e,t,n)=>{let r=`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,i={...n,id:r,createdAt:Date.now()};t(oy,e=>[...e.slice(-4),i])}),cy=V(null,(e,t,n)=>{t(oy,e=>e.filter(e=>e.id!==n))});function ly(e){let{workspaceId:t,sessionId:n,setPendingFocus:r,setActiveWorkspaceId:i,persistLastViewedTarget:a,navigate:o}=e;if(typeof window>`u`)return;a?.({workspaceId:t,sessionId:n}),i(t),r(n);let s=`/workspace`;window.location.pathname!==s&&(o?o(s):(window.history.pushState({},``,s),window.dispatchEvent(new PopStateEvent(`popstate`))))}function uy({toast:e}){let t=W(cy),n=W(jp),r=W(to),i=Qt(),a=Xg(),o=e.duration??5e3;(0,H.useEffect)(()=>{if(o<=0)return;let n=setTimeout(()=>t(e.id),o);return()=>clearTimeout(n)},[e.id,o,t]);let s=(0,H.useCallback)(()=>{e.workspaceId&&e.sessionId?ly({workspaceId:e.workspaceId,sessionId:e.sessionId,setPendingFocus:r,setActiveWorkspaceId:n,persistLastViewedTarget:e=>{a(e)},navigate:i}):e.workspaceId&&(n(e.workspaceId),window.location.pathname!==`/workspace`&&i(`/workspace`)),t(e.id)},[e.workspaceId,e.sessionId,i,t,n,r]);return(0,X.jsx)(kg,{description:e.body,onClick:e.workspaceId?s:void 0,onDismiss:()=>t(e.id),title:e.title,tone:e.kind})}function dy(){let e=U(oy),t=Br()===`mobile`;return e.length===0?null:(0,X.jsx)(Og,{"aria-live":`polite`,mobile:t,children:e.map(e=>(0,X.jsx)(uy,{toast:e},e.id))})}var fy=4e3,py=new Set([`running`]),my=new Set([`idle`,`ended`]);function hy(e,t,n,r,i){return n===e?r===`mobile`?i===t:!0:!1}function gy(e,t){return e?`system`:t?`none`:`toast`}function _y(){return!!(typeof document<`u`&&document.hidden)}async function vy(){try{let e=new Audio(`/task-complete.wav`);e.volume=.75,await e.play();return}catch{}try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e,n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type=`sine`,r.frequency.value=880,i.gain.setValueAtTime(.25,n),i.gain.exponentialRampToValueAtTime(.001,n+.3),r.connect(i).connect(t.destination),r.start(n),r.stop(n+.3);let a=t.createOscillator(),o=t.createGain();a.type=`sine`,a.frequency.value=660,o.gain.setValueAtTime(.25,n+.15),o.gain.exponentialRampToValueAtTime(.001,n+.5),a.connect(o).connect(t.destination),a.start(n+.15),a.stop(n+.5),setTimeout(()=>t.close(),2e3)}catch{}}function yy(e){if(`Notification`in window&&Notification.permission===`granted`)try{let t=new Notification(e.title,{body:e.body,tag:e.tag,silent:!0});t.onclick=()=>{window.focus(),ly({workspaceId:e.workspaceId,sessionId:e.sessionId,setActiveWorkspaceId:e.setActiveWorkspaceId,persistLastViewedTarget:e.persistLastViewedTarget,setPendingFocus:e.setPendingFocus}),t.close()}}catch{}}function by(){let e=U(Vp),t=U(xp),n=U(Op),r=U(ay),i=W(ay),a=U(zp),o=U(ro),s=W(jp),c=W(sy),l=W(to),u=Z(),d=Br(),f=Xg(),p=ve(),m=(0,H.useRef)(new Map);(0,H.useEffect)(()=>{if(t!==`connected`)return;let e=!1;return(async()=>{let t=await n(`settings.get`,{});e||!t.ok||!t.data||i({enabled:typeof t.data[`notifications.enabled`]==`boolean`?t.data[`notifications.enabled`]:!0,soundEnabled:typeof t.data[`notifications.soundEnabled`]==`boolean`?t.data[`notifications.soundEnabled`]:!0})})(),()=>{e=!0}},[t,n,i]),(0,H.useEffect)(()=>{let t=m.current;for(let n of Object.values(e)){let e=t.get(n.id),i=e?.state,m=n.state,h=py.has(m)&&(!e||!py.has(e.state)),g={state:m,activeSince:h?Date.now():e?.activeSince??(py.has(m)?Date.now():null),notifiedForTurn:h?!1:e?.notifiedForTurn??!1};if(t.set(n.id,g),!r.enabled||!i||!py.has(i)||!my.has(m)||g.notifiedForTurn)continue;if(m===`idle`&&g.activeSince!==null&&Date.now()-g.activeSince<fy){g.notifiedForTurn=!0;continue}g.notifiedForTurn=!0;let _=_y(),v=gy(_,_?!1:hy(n.workspaceId,n.id,a,d,o));if(v===`none`)continue;let y=u(`notification.session_completed_title`,{session:n.title?.trim()||xy(n.id)}),b=p.get(Mp)[n.workspaceId],x=[],S=Hg(n.providerId).replace(/\s+/g,` `).trim();S&&x.push(S);let C=Ug(b??null).replace(/\s+/g,` `).trim();C&&x.push(C);let w=g.activeSince===null?null:Date.now()-g.activeSince,T=w===null?``:Gg(w);T&&x.push(T);let E=x.join(` · `),D=u(m===`ended`?`notification.session_ended_hint`:`notification.session_turn_completed`),O=[];E&&O.push(E),O.push(D);let k=O.join(`
|
|
103
103
|
`);r.soundEnabled&&vy(),v===`system`?yy({title:y,body:k,tag:`session-${n.id}-${g.activeSince??`unknown`}`,workspaceId:n.workspaceId,sessionId:n.id,setActiveWorkspaceId:s,persistLastViewedTarget:e=>{f(e)},setPendingFocus:l}):c({kind:`success`,title:y,body:k,workspaceId:n.workspaceId,sessionId:n.id,duration:6e3})}let n=new Set(Object.keys(e));for(let e of t.keys())n.has(e)||t.delete(e)},[e,r,a,o,d,c,s,l,f,p,u])}function xy(e){let t=e.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.replace(/[_-]/g,` `).toUpperCase()}var Sy=Ap(e=>V(null));function Cy(e){let t=U(m_(e)),n=U(l_(e)),r=W(u_(e)),i=W(d_(e)),a=W(m_(e)),o=W(Sy(e)),s=(0,H.useRef)(0);return{openLocation:(0,H.useCallback)(async e=>{if(t?.source===`commit`){a(null);let t=n[e.path];i(t?s_(t):c_(e.path))}r(e.path),n[e.path],o({...e,requestId:++s.current})},[t,n,r,a,i,o]),clearPendingNavigation:(0,H.useCallback)(e=>{o(t=>t?.path===e?null:t)},[o])}}function wy(){let e=Z(),[t,n]=Te(eo),r=U(zp),i=U(Op),{openLocation:a}=Cy(r??`__workspace_placeholder__`),o=(0,H.useRef)(null),s=(0,H.useRef)(i),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(0),[f,p]=(0,H.useState)([]),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(null),v=e(`quick_open.failed`);if((0,H.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`&&(e.preventDefault(),n(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,H.useEffect)(()=>{t&&(o.current?.focus(),l(``),d(0),p([]),_(null))},[t]),(0,H.useEffect)(()=>{s.current=i},[i]),(0,H.useEffect)(()=>{if(!t||!r)return;let e=c.trim();if(!e){p([]),h(!1),_(null);return}let n=!1;h(!0),_(null);let i=window.setTimeout(()=>{s.current(`file.search`,{workspaceId:r,query:e,limit:25}).then(e=>{if(!n){if(!e.ok||!e.data){p([]),_(v);return}p(e.data.files),d(0)}}).catch(()=>{n||(p([]),_(v))}).finally(()=>{n||h(!1)})},150);return()=>{n=!0,window.clearTimeout(i)}},[v,t,c,r]),!t)return null;let y=f[u]??null;return(0,X.jsx)(Rg,{ariaLabel:e(`quick_open.title`),initialFocus:()=>o.current,onOpenChange:n,open:!0,children:(0,X.jsxs)(`div`,{className:`quick-open`,onKeyDown:e=>{if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,Math.max(f.length-1,0)));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),n(!1);return}e.key===`Enter`&&y&&r&&(e.preventDefault(),a({workspaceId:r,path:y.path,source:`manual`}),n(!1))},children:[(0,X.jsxs)(`div`,{className:`quick-open__search`,children:[(0,X.jsx)($,{className:`quick-open__icon`,semantic:`nav.search`,size:16}),(0,X.jsx)(`input`,{ref:o,type:`text`,className:`quick-open__input`,"aria-label":e(`quick_open.title`),placeholder:e(`quick_open.placeholder`),value:c,onChange:e=>l(e.target.value)})]}),(0,X.jsx)(`div`,{className:`quick-open__list`,children:r?g?(0,X.jsx)(`p`,{className:`quick-open__state`,children:g}):c.trim()?m?(0,X.jsx)(`p`,{className:`quick-open__state`,children:e(`common.loading`)}):f.length===0?(0,X.jsx)(`p`,{className:`quick-open__state`,children:e(`quick_open.no_results`)}):(0,X.jsx)(`div`,{role:`listbox`,"aria-label":e(`quick_open.title`),children:f.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===u,className:`quick-open__item${t===u?` quick-open__item--active`:``}`,onMouseEnter:()=>d(t),onClick:()=>{r&&(a({workspaceId:r,path:e.path,source:`manual`}),n(!1))},children:[(0,X.jsx)(`span`,{className:`quick-open__primary`,children:e.name}),(0,X.jsx)(`span`,{className:`quick-open__secondary`,children:e.path})]},e.path))}):(0,X.jsx)(`p`,{className:`quick-open__state`,children:e(`quick_open.empty`)}):(0,X.jsx)(Sh,{className:`quick-open__empty`,title:(0,X.jsx)(`p`,{children:e(`workspace.no_workspace`)})})})]})})}var Ty=V(`auto`),Ey=`appearance.terminalFontSize`,Dy=`appearance.desktopTerminalFontSize`,Oy=`appearance.mobileTerminalFontSize`,ky={copyOnSelect:!0,fontSize:11};function Ay(e){let t=e[`appearance.terminalCopyOnSelect`];return typeof t==`boolean`?t:ky.copyOnSelect}function jy(e){return typeof e==`number`&&Number.isInteger(e)&&Number.isFinite(e)&&e>=10&&e<=18?e:null}function My(e){return Object.hasOwn(e,Ey)}function Ny(e,t){return Object.hasOwn(e,t===`mobile`?Oy:Dy)}function Py(e){return jy(e[`appearance.terminalFontSize`])??ky.fontSize}function Fy(e,t){let n=jy(e[t===`mobile`?Oy:Dy]);return n===null?Py(e):n}function Iy(e,t){let n=jy(e.fontSize)??ky.fontSize;return jy(t===`mobile`?e.mobileFontSize:e.desktopFontSize)??n}function Ly(e,t){return Iy(e,t===`mobile`?`mobile`:`desktop`)}function Ry(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e,r=jy(n.fontSize)??t.fontSize,i=jy(n.desktopFontSize)??r,a=jy(n.mobileFontSize)??r;return{copyOnSelect:typeof n.copyOnSelect==`boolean`?n.copyOnSelect:t.copyOnSelect,fontSize:r,desktopFontSize:i,mobileFontSize:a}}var zy=Yr(()=>window.localStorage),By=Zr(`ui.terminalPreferences`,ky,{...zy,getItem:(e,t)=>Ry(zy.getItem(`ui.terminalPreferences`,t),t),setItem:(e,t)=>zy.setItem(e,Ry(t,t))},{getOnInit:!0}),Vy=V(null),Hy=V(null);function Uy(e,t){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e):t===`zh`?`未检查`:`Not checked`}function Wy(e){if(!e)return`neutral`;switch(e.updateStatus){case`installing`:case`restarting`:case`checking`:return`info`;case`succeeded`:return`success`;case`manual_required`:return`warning`;case`failed`:return`error`;default:return`neutral`}}var Gy=[3600,21600,43200,86400];function Ky({autoCheckEnabled:e,checkIntervalSec:t,onAutoCheckEnabledChange:n,onCheckIntervalChange:r,locale:i}){let a=Z(),o=U(Op),s=U(Ep),c=U(Vy),l=W(Vy),u=W(Hy),d=W(sy),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(null),g=(0,H.useId)(),_=(0,H.useId)(),v=(0,H.useId)(),y=(0,H.useMemo)(()=>{if(!c)return a(`settings.about.update_status_unknown`);switch(c.updateStatus){case`idle`:return a(`settings.about.update_status_idle`);case`checking`:return a(`settings.about.update_status_checking`);case`installing`:return a(`settings.about.update_status_installing`);case`restarting`:return a(`settings.about.update_status_restarting`);case`succeeded`:return a(`settings.about.update_status_succeeded`);case`failed`:return a(`settings.about.update_status_failed`);case`manual_required`:return a(`settings.about.update_status_manual_required`)}},[a,c]),b=(0,H.useMemo)(()=>{if(!c)return a(`settings.about.availability_unknown`);switch(c.availability){case`unknown`:return a(`settings.about.availability_unknown`);case`up_to_date`:return a(`settings.about.availability_up_to_date`);case`update_available`:return a(`settings.about.availability_update_available`);case`check_failed`:return a(`settings.about.availability_check_failed`)}},[a,c]),x=(0,H.useMemo)(()=>Gy.map(t=>({disabled:!e,label:a(`settings.about.interval_${t}`),value:String(t)})),[e,a]),S=async()=>{h(`check`);let e=await o(`updates.check`,{});if(h(null),!e.ok||!e.data){d({kind:`error`,title:a(`settings.about.check_failed`),body:e.error?.message});return}l(e.data)},C=async()=>{h(`prepare`);let e=await o(`updates.prepareInstall`,{});if(h(null),!e.ok||!e.data){d({kind:`error`,title:a(`settings.about.update_now`),body:e.error?.message});return}if(u(e.data),e.data.activity.hasActiveWork){p(e.data);return}await w(e.data,!1)},w=async(e,t)=>{h(`install`);let n=await o(`updates.startInstall`,{targetVersion:e.latestVersion??e.targetVersion??void 0,force:t});if(h(null),p(null),!n.ok||!n.data){d({kind:`error`,title:a(`settings.about.update_now`),body:n.error?.message});return}l(n.data)};return(0,X.jsxs)(`div`,{className:`settings-section`,"data-testid":`about-settings`,children:[(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:a(`settings.about.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:a(`settings.about.description`)}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.product_name`)}),(0,X.jsx)(`span`,{className:`settings-info-value`,children:`Coder Studio`})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.current_version`)}),(0,X.jsxs)(`span`,{className:`settings-info-value`,children:[`v`,s?.version??`0.0.0`]})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.server_instance_id`)}),(0,X.jsx)(`span`,{className:`settings-info-value`,children:s?.serverInstanceId??`-`})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.install_support`)}),(0,X.jsx)(`span`,{className:`settings-info-value`,children:c?.supported?a(`settings.about.install_supported`):c?.unsupportedReason??a(`settings.about.install_unsupported`)})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:a(`settings.about.update_group`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:a(`settings.about.update_group_hint`)}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.latest_version`)}),(0,X.jsx)(`span`,{className:`settings-info-value`,children:c?.latestVersion?`v${c.latestVersion}`:`-`})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.last_checked`)}),(0,X.jsx)(`span`,{className:`settings-info-value`,children:Uy(c?.lastCheckedAt??null,i)})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.availability`)}),(0,X.jsx)(`span`,{className:`settings-info-value`,children:b})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:a(`settings.about.update_status`)}),(0,X.jsxs)(`span`,{className:`settings-info-value settings-info-value--with-dot`,children:[(0,X.jsx)(lg,{tone:Wy(c),size:`sm`}),(0,X.jsx)(`span`,{children:y})]})]}),c?.errorSummary?(0,X.jsx)(jh,{tone:c.updateStatus===`manual_required`?`warning`:`error`,title:a(`settings.about.error_summary`),message:c.errorSummary}):null,c?.manualCommand?(0,X.jsx)(jh,{tone:`warning`,title:a(`settings.about.manual_command`),message:c.manualCommand}):null,(0,X.jsxs)(`div`,{className:`settings-actions-row settings-actions-row--end`,children:[(0,X.jsx)(Q,{onClick:()=>{S()},disabled:m!==null||c?.updateStatus===`checking`||c?.updateStatus===`installing`||c?.updateStatus===`restarting`,children:a(m===`check`?`settings.about.checking`:`settings.about.check_now`)}),(0,X.jsx)(Q,{onClick:()=>{C()},disabled:m!==null||!c?.supported||c?.availability!==`update_available`||c.updateStatus===`checking`||c.updateStatus===`installing`||c.updateStatus===`restarting`||!!c.manualCommand,children:a(m===`install`||m===`prepare`?`settings.about.installing`:`settings.about.update_now`)})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:g,children:a(`settings.about.auto_check_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:_,children:a(`settings.about.auto_check_enabled_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":_,"aria-labelledby":g,checked:e,className:`settings-toggle`,onCheckedChange:n})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,id:v,children:a(`settings.about.check_interval`)}),(0,X.jsx)(Uh,{"aria-labelledby":v,onChange:e=>r(Number(e)),options:x,size:`sm`,value:String(t)})]})]}),f?(0,X.jsx)(Bm,{open:!0,onOpenChange:e=>{e||p(null)},title:a(`settings.about.confirm_update_title`),description:(0,X.jsxs)(`div`,{className:`settings-dialog-copy`,children:[(0,X.jsx)(`p`,{children:a(`settings.about.confirm_update_message`)}),(0,X.jsx)(`p`,{children:a(`settings.about.confirm_update_activity`,{terminals:f.activity.runningTerminalCount,sessions:f.activity.runningSessionCount,supervisors:f.activity.runningSupervisorCount})})]}),cancelText:a(`action.cancel`),confirmText:a(`settings.about.update_now`),tone:`danger`,onConfirm:()=>{w(f,!0)}}):null]})}function qy(e){let t=Yy(e.replace(/\\/g,`/`)),n=t.match(/^([A-Za-z]):(\/.*)?$/);if(n){let e=n[1].toLowerCase(),t=n[2]??``;return t===`/`?`${e}:/`:`${e}:${Xy(t)}`}return t===`/`?t:Xy(t)}function Jy(e){let t=Yy(e.replace(/\\/g,`/`)).split(`/`).filter(Boolean),n=[];for(let e of t)if(e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return n.join(`/`)}function Yy(e){return e.replace(/\/+/g,`/`)}function Xy(e){return e.length>1?e.replace(/\/$/,``):e}function Zy(e,t){let n=qy(e),r=Jy(t);return r?n===`/`?`/${r}`:`${n}/${r}`:n}function Qy(e){return qy(e.fsPath||e.path)}function $y(e,t){return n.file(Zy(e,t))}function eb(e,t){if(e.scheme!==`file`)return null;let n=Qy(e),r=qy(t);if(n===r)return``;let i=r===`/`?`/`:`${r}/`;return n.startsWith(i)?n.slice(i.length):null}var tb=`coder-studio-lsp`;function nb(){return{apply(e,t){let n=p.getModel($y(e,t.path));n&&(typeof t.version==`number`&&t.version<n.getVersionId()||p.setModelMarkers(n,tb,t.diagnostics.map(e=>({message:e.message,source:e.source,code:e.code,severity:rb(e.severity),startLineNumber:e.range.startLine,startColumn:e.range.startColumn,endLineNumber:e.range.endLine,endColumn:e.range.endColumn}))))},clearFile(e,t){let n=p.getModel($y(e,t));n&&p.setModelMarkers(n,tb,[])}}}function rb(e){switch(e){case`error`:return h.Error;case`warning`:return h.Warning;case`info`:return h.Info;case`hint`:return h.Hint}}var ib=new Set([`ts`,`tsx`,`js`,`jsx`,`mts`,`cts`,`mjs`,`cjs`]),ab=new Set([`py`]),ob=new Set([`go`]),sb=new Set([`rs`]);function cb(e,t){let n=e.split(`.`).pop()?.toLowerCase()??``;return ib.has(n)||t===`typescript`?`typescript`:ab.has(n)||t===`python`?`python`:ob.has(n)||t===`go`?`go`:sb.has(n)||t===`rust`?`rust`:null}function lb(e){let t=new Set;function n(e){t.has(e)||(t.add(e),a.registerDefinitionProvider(e,{provideDefinition:r}),a.registerDeclarationProvider?.(e,{provideDeclaration:i}),a.registerTypeDefinitionProvider?.(e,{provideTypeDefinition:o}),a.registerHoverProvider(e,{provideHover:l}),a.registerReferenceProvider(e,{provideReferences:u}),a.registerDocumentSymbolProvider(e,{provideDocumentSymbols:d}),gb(e)&&a.registerLinkProvider?.(e,{provideLinks:f,resolveLink:p}))}async function r(t,n){return await s(t,n,[e.requestDefinition,e.requestDeclaration,e.requestTypeDefinition])}async function i(t,n){return await s(t,n,[e.requestDeclaration])}async function o(t,n){return await s(t,n,[e.requestTypeDefinition])}async function s(t,n,r){let i=e.lookupModelMetadata(t);return i?await c(t,i,n.lineNumber,n.column,r):[]}async function c(e,t,n,r,i,a=e.getVersionId()){let o=a;for(let a of i){let i=await a({meta:t,line:n,column:r,version:o});if(e.getVersionId()!==o)return[];if(!(!i||i.length===0))return i.map(e=>({uri:$y(t.workspaceRootPath,e.path),range:_b(e.range)}))}return[]}async function l(t,n){let r=e.lookupModelMetadata(t);if(!r)return null;let i=t.getVersionId(),a=await e.requestHover({meta:r,line:n.lineNumber,column:n.column,version:i});return!a||t.getVersionId()!==i?null:{contents:a.contents.map(e=>({value:e})),range:a.range?_b(a.range):void 0}}async function u(t,n){let r=e.lookupModelMetadata(t);if(!r)return[];let i=t.getVersionId(),a=await e.requestReferences({meta:r,line:n.lineNumber,column:n.column,version:i});return!a||t.getVersionId()!==i?[]:a.map(e=>({uri:$y(r.workspaceRootPath,e.path),range:_b(e.range)}))}async function d(t){let n=e.lookupModelMetadata(t);if(!n)return[];let r=t.getVersionId(),i=await e.requestDocumentSymbols({meta:n,version:r});return!i||t.getVersionId()!==r?[]:i.map(vb)}async function f(t){let n=e.lookupModelMetadata(t);if(!n)return{links:[]};let r=db(t.getValue());return r.length===0?{links:[]}:{links:r.map(e=>({range:e.range,tooltip:e.specifier,__lspImportLink:{model:t,meta:n,line:e.targetLineNumber,column:e.targetColumn,version:t.getVersionId()}}))}}async function p(t){let n=t.__lspImportLink;if(!n||n.model.getVersionId()!==n.version)return t;let r=await c(n.model,n.meta,n.line,n.column,[e.requestDefinition,e.requestDeclaration,e.requestTypeDefinition],n.version);return r.length===0?t:{...t,url:r[0].uri}}return{register:n,provideDefinition:r,provideDeclaration:i,provideTypeDefinition:o,provideHover:l,provideReferences:u,provideDocumentSymbols:d,provideLinks:f,resolveLink:p}}var ub=[/\bimport\s+(?:type\s+)?(?:[^"'`\n]+?\s+from\s+)?(["'])([^"'`\n]+)\1/g,/\bexport\s+(?:type\s+)?(?:[^"'`\n]+?\s+from\s+)(["'])([^"'`\n]+)\1/g,/\bimport\s*\(\s*(["'])([^"'`\n]+)\1\s*\)/g,/\brequire\s*\(\s*(["'])([^"'`\n]+)\1\s*\)/g];function db(e){let t=[],n=pb(e);for(let r of ub)for(let i of e.matchAll(r)){let e=i[2];if(!e)continue;let r=i[0].indexOf(e);if(r<0)continue;let a=(i.index??0)+r,o=a-1,s=a+e.length+1,c=hb(n,a+fb(e));t.push({specifier:e,range:mb(n,o,s),targetLineNumber:c.lineNumber,targetColumn:c.column})}return t}function fb(e){let t=e.lastIndexOf(`/`);return t>=0&&t+1<e.length?t+1:0}function pb(e){let t=[0];for(let n=0;n<e.length;n+=1)e[n]===`
|
|
104
104
|
`&&t.push(n+1);return t}function mb(e,t,n){let r=hb(e,t),i=hb(e,n);return{startLineNumber:r.lineNumber,startColumn:r.column,endLineNumber:i.lineNumber,endColumn:i.column}}function hb(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=e[i],o=e[i+1]??1/0;if(t<a){r=i-1;continue}if(t>=o){n=i+1;continue}return{lineNumber:i+1,column:t-a+1}}let i=e[e.length-1]??0;return{lineNumber:e.length,column:t-i+1}}function gb(e){return e===`typescript`||e===`typescriptreact`||e===`javascript`||e===`javascriptreact`}function _b(e){return{startLineNumber:e.startLine,startColumn:e.startColumn,endLineNumber:e.endLine,endColumn:e.endColumn}}function vb(e){return{name:e.name,detail:``,kind:e.kind,tags:[],containerName:``,range:_b(e.range),selectionRange:_b(e.selectionRange),children:Array.isArray(e.children)?e.children.map(vb):[]}}var yb={sendCommand:async()=>null,subscribe:()=>()=>{}};function bb(e){return e.kind!==`ready`&&e.kind!==`unsupported_language`}function xb(e={}){let t={...yb,...e},n=new Map,r=nb(),i=new Map,a=new Map,o=new Map,s=lb({lookupModelMetadata:e=>{let t=n.get(e.uri.toString());if(t)return{workspaceId:t.workspaceId,workspaceRootPath:t.workspaceRootPath,path:t.path}},requestDefinition:async({meta:e,line:n,column:r})=>await t.sendCommand(`lsp.definition`,{workspaceId:e.workspaceId,path:e.path,line:n,column:r}),requestDeclaration:async({meta:e,line:n,column:r})=>await t.sendCommand(`lsp.declaration`,{workspaceId:e.workspaceId,path:e.path,line:n,column:r}),requestTypeDefinition:async({meta:e,line:n,column:r})=>await t.sendCommand(`lsp.typeDefinition`,{workspaceId:e.workspaceId,path:e.path,line:n,column:r}),requestHover:async({meta:e,line:n,column:r})=>await t.sendCommand(`lsp.hover`,{workspaceId:e.workspaceId,path:e.path,line:n,column:r}),requestReferences:async({meta:e,line:n,column:r})=>await t.sendCommand(`lsp.references`,{workspaceId:e.workspaceId,path:e.path,line:n,column:r}),requestDocumentSymbols:async({meta:e})=>await t.sendCommand(`lsp.documentSymbols`,{workspaceId:e.workspaceId,path:e.path})});function c(e){if(t={...t,...e},e.subscribe)for(let e of i.values())e.unsubscribe(),e.unsubscribe=t.subscribe([e.topic],e.handleEvent)}function l(e,i){let c=cb(e.path,e.monacoLanguage);if(!c)return i?.({kind:`unsupported_language`}),Object.assign(()=>{},{install:async()=>{},retry:async()=>{}});let l=e.model.uri.toString(),f=!1,p;n.set(l,e),s.register(Cb(e.monacoLanguage)),u(e.workspaceId,e.workspaceRootPath);let m=async()=>{let r=await t.sendCommand(`lsp.ensureSession`,{workspaceId:e.workspaceId,path:e.path});if(r.kind!==`ready`){i?.(r),bb(r)&&r.installJob&&(p=r.installJob.jobId,g());return}i?.({kind:`ready`}),!(r.summary.serverKind!==c||f||n.get(l)!==e)&&await t.sendCommand(`lsp.openDocument`,{workspaceId:e.workspaceId,path:e.path,languageId:e.monacoLanguage,text:e.model.getValue()})},h=async()=>{if(!p||f)return;let e=await t.sendCommand(`lsp.install.get`,{jobId:p});if(e.status===`queued`||e.status===`running`){i?.({kind:`installing`,serverKind:c,displayName:`${c} language server`,errorCode:`lsp_install_in_progress`,message:`Install in progress`,autoInstallSupported:!0,missingCommands:[],missingPrerequisites:[],installJob:e}),g();return}if(e.status===`failed`){i?.({kind:`failed`,serverKind:c,displayName:`${c} language server`,errorCode:`lsp_install_failed`,message:e.failure?.message??`Install failed`,autoInstallSupported:!0,missingCommands:e.failure?.missingCommands??[],missingPrerequisites:[],installJob:e});return}p=void 0,await m().catch(()=>null)},g=()=>{clearTimeout(o.get(l)),o.set(l,setTimeout(()=>{h().catch(()=>null)},1500))};m().catch(()=>null);let _=e.model.onDidChangeContent(()=>{clearTimeout(a.get(l)),a.set(l,setTimeout(()=>{t.sendCommand(`lsp.changeDocument`,{workspaceId:e.workspaceId,path:e.path,text:e.model.getValue()}).catch(()=>null)},75))});return Object.assign(()=>{f=!0,clearTimeout(a.get(l)),a.delete(l),clearTimeout(o.get(l)),o.delete(l),n.delete(l),r.clearFile(e.workspaceRootPath,e.path),_.dispose(),d(e.workspaceId),t.sendCommand(`lsp.closeDocument`,{workspaceId:e.workspaceId,path:e.path}).catch(()=>null)},{install:async()=>{let n=await t.sendCommand(`lsp.install.start`,{workspaceId:e.workspaceId,serverKind:c});if(p=n.jobId,i?.({kind:n.status===`failed`?`failed`:`installing`,serverKind:c,displayName:`${c} language server`,errorCode:n.status===`failed`?`lsp_install_failed`:`lsp_install_in_progress`,message:n.failure?.message??`Install in progress`,autoInstallSupported:!0,missingCommands:n.failure?.missingCommands??[],missingPrerequisites:[],installJob:n}),n.status===`queued`||n.status===`running`){g();return}n.status===`succeeded`&&await m().catch(()=>null)},retry:async()=>{await m().catch(()=>null)}})}function u(e,n){let a=i.get(e);if(a){a.workspaceRootPath=n,a.refCount+=1;return}let o={topic:dp.workspaceLspDiagnostics(e),refCount:1,workspaceRootPath:n,unsubscribe:()=>{},handleEvent:(e,t)=>{r.apply(o.workspaceRootPath,t)}};o.unsubscribe=t.subscribe([o.topic],o.handleEvent),i.set(e,o)}function d(e){let t=i.get(e);t&&(--t.refCount,t.refCount<=0&&(t.unsubscribe(),i.delete(e)))}return{configure:c,attachModel:l,provideDefinition:s.provideDefinition,provideHover:s.provideHover,provideReferences:s.provideReferences,provideDocumentSymbols:s.provideDocumentSymbols}}var Sb=xb();function Cb(e){return e===`typescriptreact`?`typescript`:e===`javascriptreact`?`javascript`:e}function wb(e,t){return`${e}::${t}`}function Tb(e,t){p.setModelLanguage(e,t)}function Eb(e,t,n){Tb(e,t),e.getValue()!==n&&e.setValue(n)}function Db(){let e=new Map;return{getOrCreate({workspaceRootPath:t,path:n,language:r,content:i}){let a=wb(t,n),o=e.get(a);if(o){Tb(o.model,r);let t=o.language===r?o:{...o,language:r};return e.set(a,t),t}let s=$y(t,n),c=p.getModel(s),l=c??p.createModel(i,r,s);Tb(l,r),!c&&l.getValue()!==i&&l.setValue(i);let u={key:a,uri:s,model:l,language:r,path:n};return e.set(a,u),u},updateFromDisk({workspaceRootPath:t,path:n,content:r}){let i=wb(t,n),a=e.get(i);a&&Eb(a.model,a.language,r)},disposeFile(t,n){let r=wb(t,n),i=e.get(r);i&&(i.model.dispose(),e.delete(r))},disposeWorkspace(t){for(let[n,r]of e)n.startsWith(`${t}::`)&&(r.model.dispose(),e.delete(n))}}}var Ob=Db();function kb(e){return e?e.status===`running`?`Installing: ${e.title}`:e.status===`failed`?`Install failed at: ${e.title}`:null:null}function Ab({state:e,onInstall:t,onRetry:n,installing:r=!1}){if(e.kind===`disabled`)return(0,X.jsx)(jh,{tone:`info`,title:`Language server disabled`,message:`LSP is turned off in Settings to reduce memory usage.`});let i=e.installJob?.steps.find(t=>t.id===e.installJob?.currentStepId),a=kb(i),o=e.kind===`tool_missing`&&e.autoInstallSupported&&e.missingPrerequisites.length===0&&t,s=e.kind===`failed`&&n,c=o?(0,X.jsx)(Q,{onClick:t,loading:r,size:`sm`,children:`Install`}):s?(0,X.jsx)(Q,{onClick:n,size:`sm`,variant:`ghost`,children:`Retry`}):null;return(0,X.jsx)(jh,{tone:e.kind===`failed`?`warning`:`info`,title:`${e.displayName} unavailable`,message:a??e.message,action:c})}var jb=globalThis,Mb=new Set;function Nb(e){return e.kind!==`ready`&&e.kind!==`unsupported_language`}jb.MonacoEnvironment??={getWorker(e,t){return t===`json`?new l:t===`css`||t===`scss`||t===`less`?new r:t===`html`||t===`handlebars`||t===`razor`?new u:t===`typescript`||t===`javascript`?new c:new o}};var Pb=!1;Vb();var Fb=({workspaceId:e,workspaceRootPath:t,filePath:n,content:r,visible:i=!0,standalone:a=!1,readOnly:o=!1,onContentChange:c,onSave:l})=>{let u=U(Xa),h=U(Ty),g=U(Sy(e??``)),_=W(Sy(e??``)),v=U(Op),y=U(bp),{openLocation:b}=Cy(e??``),x=(0,H.useRef)(null),S=(0,H.useRef)(null),C=(0,H.useRef)(null),w=(0,H.useRef)(null),T=(0,H.useRef)(i),E=(0,H.useRef)(c),D=(0,H.useRef)(l),O=(0,H.useRef)(b),k=(0,H.useRef)(n),A=(0,H.useRef)(e),j=(0,H.useRef)(t),M=!!t&&!a,N=(0,H.useRef)(null),[P,F]=(0,H.useState)({kind:`unsupported_language`}),[ee,I]=(0,H.useState)(!1);(0,H.useEffect)(()=>{E.current=c},[c]),(0,H.useEffect)(()=>{D.current=l},[l]),(0,H.useEffect)(()=>{O.current=b,k.current=n,A.current=e,j.current=t},[n,b,e,t]);let L=Ib(n),R=Lb(n,L),z=Oa(u),te=M?`coder-studio-workspace-${z.id}`:`coder-studio-${z.id}`,ne=M?Sa(z.monaco):z.monaco;(0,H.useEffect)(()=>{Mb.has(te)||(p.defineTheme(te,ne),Mb.add(te))},[te,ne]),(0,H.useEffect)(()=>{if(!x.current||S.current)return;let e=p.create(x.current,{model:null,theme:te,fontSize:13,fontFamily:`JetBrains Mono, monospace`,minimap:{enabled:!1},readOnly:o,scrollBeyondLastLine:!1,padding:{top:12,bottom:12},automaticLayout:!0});S.current=e;let t=e.onDidChangeModelContent(()=>{E.current?.(e.getValue())});return e.addCommand(d.CtrlCmd|s.KeyS,()=>{D.current?.()}),()=>{t.dispose(),e.dispose(),S.current=null,C.current?.dispose(),C.current=null}},[]),(0,H.useEffect)(()=>{let e=S.current;if(!e)return;if(M&&t){let i=Ob.getOrCreate({workspaceRootPath:t,path:n,language:L,content:r});e.getModel()!==i.model&&e.setModel(i.model);return}C.current||=p.createModel(r,L);let i=C.current;p.setModelLanguage(i,L),i.getValue()!==r&&i.setValue(r),e.getModel()!==i&&e.setModel(i)},[r,L,n,M,t]),(0,H.useEffect)(()=>{p.setTheme(te)},[te]),(0,H.useEffect)(()=>{if(h===`off`){F({kind:`disabled`,mode:`off`,message:`LSP is disabled by runtime mode`}),I(!1);return}F({kind:`unsupported_language`})},[n,h]),(0,H.useEffect)(()=>{S.current?.updateOptions({readOnly:o})},[o]),(0,H.useEffect)(()=>{Sb.configure({sendCommand:async(e,t)=>{let n=await v(e,t);return n.ok?n.data:null},subscribe:(e,t)=>y?.subscribe(e,(e,n)=>t(e,n))??(()=>{})})},[v,y]),(0,H.useEffect)(()=>{let t=S.current;if(!t||!M||!e||!g||g.path!==n)return;let r=g.requestId??`${g.path}:${g.line??``}:${g.column??``}:${g.endLine??``}:${g.endColumn??``}:${g.source}`;w.current!==r&&(w.current=r,Rb(t,g),_(e=>e&&zb(e,g)?null:e))},[n,M,g,_,e]),(0,H.useEffect)(()=>{let r=S.current?.getModel();if(!r||!M||!e||!t||h!==`auto`)return;let i=Sb.attachModel({workspaceId:e,workspaceRootPath:t,path:n,monacoLanguage:R,model:r},F);return N.current=i,()=>{N.current=null,i()}},[n,M,R,h,e,t]);let re=M&&e&&Nb(P),ie=P.kind===`tool_missing`&&P.autoInstallSupported&&P.missingPrerequisites.length===0;return(0,H.useEffect)(()=>{let e=S.current;if(!e||!M)return;let t=f.get(m).registerCodeEditorOpenHandler(async(t,n)=>{if(n!==e||!t.resource)return null;let r=A.current,i=j.current;if(!r||!i)return null;let a=eb(t.resource,i);return!a||a===k.current?null:(await O.current({workspaceId:r,path:a,source:`lsp`,...Hb(t.options?.selection)}),Ub(e,t.resource))});return()=>{t.dispose()}},[M]),(0,H.useEffect)(()=>{let e=S.current,t=T.current;T.current=i,!(!e||!i||t)&&e.layout()},[i]),(0,X.jsxs)(X.Fragment,{children:[re?(0,X.jsx)(Ab,{state:P,onInstall:ie?async()=>{if(N.current){I(!0);try{await N.current.install()}finally{I(!1)}}}:void 0,onRetry:async()=>{await N.current?.retry()},installing:ee}):null,(0,X.jsx)(`div`,{ref:x,className:`monaco-host`,"data-monaco-mode":M?`workspace`:`standalone`})]})};function Ib(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,go:`go`,rs:`rust`,java:`java`,cpp:`cpp`,c:`c`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[e.split(`.`).pop()?.toLowerCase()||``]||`plaintext`}function Lb(e,t){let n=e.split(`.`).pop()?.toLowerCase();return n===`tsx`?`typescriptreact`:n===`jsx`?`javascriptreact`:t}function Rb(e,t){let n=Bb(t.line),r=Bb(t.column),i=Bb(t.endLine,n),a=Bb(t.endColumn,r);if(t.endLine!==void 0||t.endColumn!==void 0){let t={startLineNumber:n,startColumn:r,endLineNumber:i,endColumn:a};e.setSelection(t),e.revealRangeInCenter(t);return}if(t.line!==void 0||t.column!==void 0){let t={lineNumber:n,column:r};e.setPosition(t),e.revealPositionInCenter(t)}}function zb(e,t){return e.requestId!==void 0||t.requestId!==void 0?e.requestId===t.requestId:e.workspaceId===t.workspaceId&&e.path===t.path&&e.line===t.line&&e.column===t.column&&e.endLine===t.endLine&&e.endColumn===t.endColumn&&e.source===t.source}function Bb(e,t=1){return Math.max(1,e??t)}function Vb(){let e=a.typescript;if(Pb||!e)return;Pb=!0;let t={allowJs:!0,allowNonTsExtensions:!0,jsx:e.JsxEmit.ReactJSX,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.NodeJs,target:e.ScriptTarget.ESNext};e.typescriptDefaults.setCompilerOptions(t),e.javascriptDefaults.setCompilerOptions(t),e.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0}),e.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0}),e.typescriptDefaults.setEagerModelSync(!0),e.javascriptDefaults.setEagerModelSync(!0)}function Hb(e){return e?`startLineNumber`in e?{line:e.startLineNumber,column:e.startColumn,endLine:e.endLineNumber,endColumn:e.endColumn}:{line:e.lineNumber,column:e.column}:{}}function Ub(e,t,n=3e3){return e.getModel()?.uri.toString()===t.toString()?Promise.resolve(e):new Promise(r=>{let i=!1,a=null,o=e=>{i||(i=!0,a!==null&&globalThis.clearTimeout(a),s.dispose(),r(e))},s=e.onDidChangeModel(()=>{e.getModel()?.uri.toString()===t.toString()&&o(e)});a=globalThis.setTimeout(()=>{o(null)},n)})}var Wb={minHeight:`200px`,padding:0,gap:0},Gb={margin:0,color:`var(--text-tertiary)`,fontSize:`var(--text-base)`,fontWeight:`var(--font-normal)`};function Kb({configType:e,visible:t=!0,fillHeight:n=!1}){let r=Z(),i=U(Op),a=W(sy),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(!0),[m,h]=(0,H.useState)(!0),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(()=>{let t=localStorage.getItem(`config-expanded-${e}`);return t===null?!0:t===`true`}),S=(0,H.useMemo)(()=>g?`saving`:v?`error`:o===c?`saved`:`dirty`,[g,v,o,c]),C=S===`dirty`;(0,H.useEffect)(()=>{let t=!1;return(async()=>{h(!0),y(null);try{let n=await i(`settings.readConfigFile`,{configType:e});if(t)return;n.ok&&n.data?(s(n.data.content),l(n.data.content),d(n.data.configPath),p(n.data.exists)):y(n.error?.message??r(`settings.config_files.load_failed`))}catch{t||y(r(`settings.config_files.load_failed`))}finally{t||h(!1)}})(),()=>{t=!0}},[e,i,r]),(0,H.useEffect)(()=>{localStorage.setItem(`config-expanded-${e}`,String(b))},[b,e]);let w=(0,H.useCallback)(async()=>{if(!(!C||g)){_(!0);try{let t=await i(`settings.writeConfigFile`,{configType:e,content:o});if(t.ok&&t.data?.success)a({kind:`success`,title:r(`settings.config_files.save_success`),body:t.data.backupPath?r(`settings.config_files.save_success_with_backup`,{configPath:u,backupPath:t.data.backupPath}):void 0}),p(!0),l(o),y(null);else{let e=t.error?.message??t.data?.error;y(e??`Save failed`),a({kind:`error`,title:r(`settings.config_files.save_failed`),body:e})}}catch(e){y(e instanceof Error?e.message:`Save failed`),a({kind:`error`,title:r(`settings.config_files.save_failed`)})}finally{_(!1)}}},[e,o,C,g,i,a,r]),T=(0,H.useCallback)(()=>{s(c),y(null)},[c]),E=(0,H.useCallback)(()=>{if(e===`claude`)try{let e=JSON.parse(o);s(JSON.stringify(e,null,2)),a({kind:`success`,title:`JSON formatted`})}catch{a({kind:`error`,title:`Invalid JSON`,body:`Cannot format invalid JSON`})}},[e,o,a]),D=(0,H.useCallback)(e=>{s(e),y(null)},[]),O=(0,H.useCallback)(()=>{x(e=>!e)},[]);return m?(0,X.jsx)(`div`,{className:`config-card`,children:(0,X.jsx)(Sh,{className:`config-card-loading`,style:Wb,title:(0,X.jsx)(`p`,{style:Gb,children:r(`common.loading`)})})}):v&&!u?(0,X.jsx)(`div`,{className:`config-card`,children:(0,X.jsx)(`div`,{className:`config-card-error`,children:(0,X.jsx)(`span`,{className:`config-card-error-message`,children:v})})}):(0,X.jsxs)(`div`,{className:`config-card ${n?`config-card--fill-height`:``}`,children:[(0,X.jsxs)(`div`,{className:`config-card-header`,onClick:O,children:[(0,X.jsxs)(`div`,{className:`config-card-title`,children:[(0,X.jsx)($,{semantic:`state.configFile`,size:16}),(0,X.jsx)(Ig,{content:u,children:(0,X.jsx)(`span`,{className:`config-card-path`,children:u})})]}),(0,X.jsx)(`div`,{className:`config-card-header-right`,children:b?(0,X.jsx)(bi,{size:16}):(0,X.jsx)(_i,{size:16})})]}),b&&(0,X.jsxs)(`div`,{className:`config-card-body ${n?`config-card-body--fill-height`:``}`,children:[!f&&(0,X.jsx)(Sh,{className:`config-empty-state`,description:(0,X.jsx)(`div`,{className:`config-empty-desc`,children:r(`settings.config_files.file_not_found_hint`)}),icon:(0,X.jsx)($,{className:`config-empty-icon`,semantic:`state.emptyConfig`,size:16}),title:(0,X.jsx)(`div`,{className:`config-empty-title`,children:r(`settings.config_files.file_not_found`)})}),(0,X.jsx)(Fb,{filePath:u,content:o,onContentChange:D,standalone:!0,visible:t}),(0,X.jsxs)(`div`,{className:`config-card-actions`,children:[(0,X.jsx)(`div`,{className:`config-actions-left`,children:(0,X.jsx)(()=>{if(!f&&!g&&!v&&!C)return(0,X.jsxs)(`div`,{className:`config-status config-status--warning`,children:[(0,X.jsx)($,{"aria-hidden":`true`,className:`config-status__icon`,semantic:`state.warning`,size:14}),(0,X.jsx)(`span`,{children:r(`settings.config_files.file_not_found_hint`)})]});let e={saved:{color:`success`,text:r(`settings.config_files.status_saved`)},dirty:{color:`warning`,text:r(`settings.config_files.unsaved_changes`)},saving:{color:`info`,text:r(`settings.config_files.saving`)},error:{color:`error`,text:r(`settings.config_files.save_failed`)}}[S];return(0,X.jsxs)(`div`,{className:`config-status config-status--${e.color}`,children:[S===`saving`?(0,X.jsx)(ig,{label:e.text,size:`sm`}):(0,X.jsx)($,{"aria-hidden":`true`,className:`config-status__icon`,semantic:S===`saved`?`state.success`:S===`dirty`?`state.warning`:S===`error`?`state.error`:`state.info`,size:14}),(0,X.jsx)(`span`,{children:e.text})]})},{})}),(0,X.jsxs)(`div`,{className:`config-actions-right`,children:[e===`claude`&&(0,X.jsx)(Ig,{content:r(`settings.config_files.format_hint`),children:(0,X.jsxs)(Q,{size:`sm`,onClick:E,children:[(0,X.jsx)(oa,{size:14}),(0,X.jsx)(`span`,{children:r(`settings.config_files.format`)})]})}),(0,X.jsx)(Q,{size:`sm`,onClick:T,disabled:!C||g,children:r(`action.reset`)}),(0,X.jsx)(Q,{variant:`primary`,size:`sm`,onClick:w,disabled:!C||g,children:r(g?`settings.config_files.saving`:`action.save`)})]})]})]})]})}function qb(){let e=U(Op),t=Qt();return(0,H.useCallback)(async function(n,r,i){let a=await e(n,r,i);return!a.ok&&a.error?.code===`activation_required`?(t(`/session-gate`,{replace:!0}),null):a},[e,t])}function Jb(e){return e.split(`
|
|
105
105
|
`).map(e=>e.trim()).filter(e=>e.length>0)}function Yb(e,t){return Object.fromEntries(e.map(e=>[e.id,t()]))}function Xb({providers:e,additionalArgsById:t,setAdditionalArgsById:n,isMobile:r,activeWorkspaceId:i,onLayoutModeChange:a}){let o=Z(),s=Qt(),c=qb(),l=U(xp),u=o(`settings.provider.command_preview_title`),d=o(`settings.provider.command_preview_hint`),[f,p]=(0,H.useState)(e[0]?.id??`claude`),[m,h]=(0,H.useState)(`base`),[g,_]=(0,H.useState)(`base`),[v,y]=(0,H.useState)(()=>Yb(e,()=>``)),[b,x]=(0,H.useState)(()=>Yb(e,()=>null)),[S,C]=(0,H.useState)(()=>Yb(e,()=>!1)),w=(0,H.useRef)(Yb(e,()=>0));(0,H.useEffect)(()=>{e.some(e=>e.id===f)||p(e[0]?.id??`claude`)},[e,f]),(0,H.useEffect)(()=>{y(t=>{let n=Yb(e,()=>``),r=!1;for(let i of e)i.id in t?n[i.id]=t[i.id]:r=!0;return Object.keys(t).length!==e.length&&(r=!0),r?n:t}),x(t=>{let n=Yb(e,()=>null),r=!1;for(let i of e)i.id in t?n[i.id]=t[i.id]:r=!0;return Object.keys(t).length!==e.length&&(r=!0),r?n:t}),C(t=>{let n=Yb(e,()=>!1),r=!1;for(let i of e)i.id in t?n[i.id]=t[i.id]:r=!0;return Object.keys(t).length!==e.length&&(r=!0),r?n:t});let t=Yb(e,()=>0);for(let n of e)n.id in w.current&&(t[n.id]=w.current[n.id]);w.current=t},[e]);let T=e.find(e=>e.id===f),E=T?b[T.id]:null,D=T?t[T.id]??``:``,O=(0,H.useMemo)(()=>Jb(D),[D]),k=r?g===`base`:m===`base`,A=r?g===`config`:m===`config`,j=T?v[T.id]??``:``,M=A;(0,H.useEffect)(()=>{a?.(M?`fill-height`:`default`)},[a,M]),(0,H.useEffect)(()=>{if(l!==`connected`)return;let t=!1;return(async()=>{let n=await c(`provider.runtimeStatus`,{});if(t||n===null||!n.ok||!n.data)return;let r=n.data.providers??{};x(t=>{let n={...t};for(let t of e)n[t.id]=r[t.id]??null;return n})})(),()=>{t=!0}},[l,c,e]),(0,H.useEffect)(()=>{if(l!==`connected`||!T)return;let e=(w.current[T.id]??0)+1;w.current[T.id]=e;let t=!1;return(async()=>{let n=await c(`settings.previewCommand`,{providerId:T.id,config:{additionalArgs:O}});t||n===null||w.current[T.id]===e&&y(e=>({...e,[T.id]:n.ok&&n.data?n.data.preview:`Error loading preview`}))})(),()=>{t=!0}},[O,D,l,c,T]),(0,H.useEffect)(()=>{!T||!A||C(e=>e[T.id]?e:{...e,[T.id]:!0})},[T,A]);let N=e=>{p(e),r&&_(`base`)},P=async(e,t)=>{await c(`settings.update`,{settings:{providers:{[e]:{additionalArgs:Jb(t)}}}})},F=E&&!E.available?E.manualGuideKeys.map(e=>o(e)).join(` `):``,ee=T&&E?E.available?o(`diagnostics.checks.provider_runtime_ready.title`,{provider:T.displayName}):o(`diagnostics.checks.provider_cli_missing.title`,{provider:T.displayName}):``,I=T&&E?E.available?o(`diagnostics.checks.provider_runtime_ready.description`,{provider:T.displayName}):o(`diagnostics.checks.provider_cli_missing.description`,{provider:T.displayName}):``;return(0,X.jsxs)(`div`,{className:`settings-section ${M?`settings-section--fill-height settings-provider-section--config-active`:``}`,children:[(0,X.jsx)(Uh,{"aria-label":o(`settings.providers`),className:`settings-provider-tabs`,onChange:e=>N(e),optionClassName:`settings-provider-tab`,options:e.map(e=>({label:e.displayName,value:e.id})),value:f}),r?null:(0,X.jsx)(Uh,{className:`settings-provider-subnav`,"aria-label":o(`settings.provider.config`),onChange:e=>h(e),optionClassName:`settings-provider-subnav-button`,options:[{label:o(`settings.provider.base`),value:`base`},{label:o(`settings.provider.config_file`),value:`config`}],value:m}),T&&k?(0,X.jsxs)(`div`,{className:`settings-provider-content ${M?`settings-provider-content--fill-height`:``}`,children:[E?(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:o(`settings.provider.status`)}),(0,X.jsx)(jh,{tone:E.available?`success`:`warning`,title:ee,message:F?`${I} ${F}`:I,action:(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`var(--sp-2)`,flexWrap:`wrap`},children:[E.docUrls.provider?(0,X.jsx)(Q,{as:`a`,href:E.docUrls.provider,rel:`noreferrer`,size:`sm`,target:`_blank`,variant:`ghost`,children:o(`provider.install.open_docs`)}):null,(0,X.jsx)(Q,{onClick:()=>s(X_({context:`manual_check`,workspaceId:i??void 0,providerId:T.id})),size:`sm`,variant:`ghost`,children:o(`diagnostics.actions.open_diagnostics`)})]})})]}):null,(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:o(`settings.provider.config`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:o(`settings.provider.startup_args_hint`)}),(0,X.jsxs)(`div`,{className:`settings-config-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`provider-startup-args`,children:o(`settings.provider.startup_args`)}),(0,X.jsx)(Cg,{id:`provider-startup-args`,className:`settings-provider-args-input`,rows:4,placeholder:o(`settings.provider.startup_args_placeholder`),value:D,onChange:e=>{let t=e.target.value;n(e=>({...e,[T.id]:t})),P(T.id,t)}})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:u}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:d}),(0,X.jsx)(`div`,{className:`settings-config-field`,children:(0,X.jsx)(`code`,{className:`settings-command-preview`,children:j})})]}),r?(0,X.jsxs)(`button`,{type:`button`,className:`settings-provider-mobile-entry`,"aria-label":o(`settings.provider.open_config_file_editor`),onClick:()=>_(`config`),children:[(0,X.jsx)(`span`,{className:`settings-provider-mobile-entry__title`,children:o(`settings.provider.open_config_file_editor`)}),(0,X.jsx)(`span`,{className:`settings-provider-mobile-entry__meta`,children:T.id===`codex`?o(`settings.config_files.codex_config`):o(`settings.config_files.claude_config`)})]}):null]}):null,(0,X.jsx)(`div`,{className:`settings-provider-config-stack ${M?`settings-provider-config-stack--fill-height`:``}`,children:e.filter(e=>S[e.id]||T?.id===e.id&&A).map(e=>{let t=T?.id===e.id&&A;return(0,X.jsx)(`div`,{className:`settings-provider-config-panel ${M?`settings-provider-config-panel--fill-height`:``} ${t?``:`settings-provider-config-panel-hidden`}`,"aria-hidden":!t,children:(0,X.jsx)(`div`,{className:`settings-provider-content ${M?`settings-provider-content--fill-height`:``}`,children:(0,X.jsxs)(`div`,{className:`settings-group ${M?`settings-group--fill-height`:``}`,children:[r?(0,X.jsx)(`div`,{className:`settings-provider-mobile-config-header`,children:(0,X.jsx)(`button`,{type:`button`,className:`settings-link`,onClick:()=>_(`base`),children:o(`settings.provider.back_to_base`)})}):null,(0,X.jsx)(`h3`,{className:`settings-group-title`,children:o(`settings.config_files.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:e.id===`codex`?o(`settings.config_files.codex_config`):o(`settings.config_files.claude_config`)}),(0,X.jsx)(Kb,{configType:e.id,visible:t,fillHeight:M})]})})},e.id)})})]})}function Zb({historyIndex:e,historyLength:t,hasActiveWorkspace:n}){return(typeof e==`number`?e>0:t>1)?`history`:n?`/workspace`:`/`}function Qb(e){let{history:t,hasActiveWorkspace:n}=e,r=t.state;return Zb({historyIndex:r?.idx??null,historyLength:t.length,hasActiveWorkspace:n})}function $b(e){return Qb({history:typeof window<`u`?window.history:{state:null,length:1},hasActiveWorkspace:e})}var ex=[{id:`general`,labelKey:`settings.general`,iconSemantic:`nav.settings.general`},{id:`providers`,labelKey:`settings.providers`,iconSemantic:`nav.settings.providers`},{id:`appearance`,labelKey:`settings.appearance`,iconSemantic:`nav.settings.appearance`},{id:`shortcuts`,labelKey:`settings.shortcuts.title`,iconSemantic:`nav.settings.shortcuts`},{id:`about`,labelKey:`settings.about.title`,iconSemantic:`nav.settings.about`}],tx=ex,nx=[{id:`command-palette.toggle`,name:`命令面板`,description:`打开/关闭命令面板`,defaultBinding:`Mod+K`,category:`global`},{id:`workspace.new`,name:`新建工作区`,description:`打开新的工作区标签`,defaultBinding:`Mod+N`,category:`global`},{id:`workspace.previous`,name:`上一个工作区`,description:`切换到上一个工作区标签`,defaultBinding:`Ctrl+Shift+ArrowLeft`,category:`workspace`},{id:`workspace.next`,name:`下一个工作区`,description:`切换到下一个工作区标签`,defaultBinding:`Ctrl+Shift+ArrowRight`,category:`workspace`},{id:`focus-mode.toggle`,name:`专注模式`,description:`切换专注模式(隐藏非必要面板)`,defaultBinding:`F`,category:`global`},{id:`agent.split-vertical`,name:`垂直分屏`,description:`垂直分割 Agent 面板`,defaultBinding:`Mod+D`,category:`workspace`},{id:`session.navigate.left`,name:`切换到左侧会话`,description:`将焦点切换到左侧会话`,defaultBinding:`Ctrl+ArrowLeft`,category:`workspace`},{id:`session.navigate.right`,name:`切换到右侧会话`,description:`将焦点切换到右侧会话`,defaultBinding:`Ctrl+ArrowRight`,category:`workspace`},{id:`session.navigate.up`,name:`切换到上方会话`,description:`将焦点切换到上方会话`,defaultBinding:`Ctrl+ArrowUp`,category:`workspace`},{id:`session.navigate.down`,name:`切换到下方会话`,description:`将焦点切换到下方会话`,defaultBinding:`Ctrl+ArrowDown`,category:`workspace`},{id:`agent.split-horizontal`,name:`水平分屏`,description:`水平分割 Agent 面板`,defaultBinding:`Mod+Shift+D`,category:`workspace`},{id:`editor.save`,name:`保存`,description:`保存当前编辑的文件`,defaultBinding:`Mod+S`,category:`editor`}],rx=Zr(`ui.customShortcuts`,{});function ix(e){let t=e.split(`+`);return{modifiers:t,key:t.pop()||``}}function ax(e){return e.replace(`Mod`,navigator.platform.includes(`Mac`)?`⌘`:`Ctrl`).replace(`Ctrl`,`Ctrl`).replace(`Shift`,`⇧`).replace(`Alt`,navigator.platform.includes(`Mac`)?`⌥`:`Alt`).replace(`ArrowLeft`,`←`).replace(`ArrowRight`,`→`).replace(`ArrowUp`,`↑`).replace(`ArrowDown`,`↓`)}function ox(e,t){let{modifiers:n,key:r}=ix(t),i=navigator.platform.includes(`Mac`),a=n.includes(`Ctrl`)||!i&&n.includes(`Mod`),o=i&&n.includes(`Mod`),s=n.includes(`Shift`),c=n.includes(`Alt`);return e.ctrlKey!==a||e.metaKey!==o||e.shiftKey!==s||e.altKey!==c?!1:e.key.toLowerCase()===r.toLowerCase()}function sx(e,t){return t[e]||nx.find(t=>t.id===e)?.defaultBinding||``}var cx={global:`全局`,workspace:`工作区`,editor:`编辑器`,terminal:`终端`};function lx(){let e=Z(),t=U(Op),n=e(`settings.shortcuts.reset_hint`),[r,i]=Te(rx),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(`global`),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{a&&l.current&&l.current.focus()},[a]);let u=(0,H.useCallback)((e,n)=>{e.preventDefault(),e.stopPropagation();let r=[],a=navigator.platform.includes(`Mac`),s=e.key.startsWith(`Arrow`),c=a&&e.metaKey;if(c&&r.push(`Mod`),e.ctrlKey&&s?r.push(`Ctrl`):(!a&&e.ctrlKey||a&&e.ctrlKey&&!c)&&r.push(`Mod`),e.shiftKey&&r.push(`Shift`),e.altKey&&r.push(`Alt`),e.key.length===1)r.push(e.key.toUpperCase());else if(e.key===`Escape`){o(null);return}else r.push(e.key);let l=r.join(`+`);i(e=>({...e,[n]:l})),t(`settings.update`,{settings:{shortcuts:{[n]:l}}}),o(null)},[i,t]),d=(0,H.useCallback)(e=>{i(t=>{let n={...t};return delete n[e],n}),t(`settings.update`,{settings:{shortcuts:{[e]:null}}})},[i,t]),f=(0,H.useCallback)(()=>{i({}),t(`settings.update`,{settings:{shortcuts:{}}})},[i,t]),p=nx.filter(e=>e.category===s);return(0,X.jsxs)(`div`,{className:`settings-section`,children:[(0,X.jsx)(Uh,{"aria-label":e(`settings.shortcuts.title`),className:`shortcuts-category-tabs`,onChange:e=>c(e),optionClassName:`shortcuts-category-tab`,options:Object.keys(cx).map(e=>({label:cx[e],value:e})),size:`sm`,value:s}),(0,X.jsx)(`div`,{className:`shortcuts-list`,children:p.map(e=>{let t=sx(e.id,r),i=r[e.id]!==void 0,s=a===e.id,c=`shortcut-name-${e.id}`,f=`shortcut-description-${e.id}`;return(0,X.jsxs)(`div`,{className:`shortcuts-item ${i?`shortcuts-item-custom`:``}`,children:[(0,X.jsxs)(`div`,{className:`shortcuts-info`,children:[(0,X.jsx)(`span`,{id:c,className:`shortcuts-name`,children:e.name}),(0,X.jsx)(`span`,{id:f,className:`shortcuts-desc`,children:e.description})]}),(0,X.jsx)(`div`,{className:`shortcuts-binding`,children:s?(0,X.jsx)(rh,{ref:l,type:`text`,className:`shortcuts-capture`,"aria-labelledby":c,"aria-describedby":f,placeholder:`按下快捷键...`,autoFocus:!0,onKeyDown:t=>u(t,e.id),onBlur:()=>o(null),readOnly:!0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Th,{className:`shortcuts-key`,interactive:!0,onClick:()=>o(e.id),children:ax(t)}),i&&(0,X.jsx)(Ig,{content:n,children:(0,X.jsx)(Em,{"aria-label":n,icon:`↺`,onClick:()=>d(e.id),size:`sm`})})]})})]},e.id)})}),(0,X.jsx)(`div`,{className:`shortcuts-footer`,children:(0,X.jsx)(Q,{onClick:f,variant:`secondary`,children:e(`settings.shortcuts.reset_all`)})})]})}var ux=ex[0].id,dx=500,fx=[`backgroundAssetId`,`backgroundDimness`,`backgroundBlur`,`glassEnabled`,`glassIntensity`,`surfaceOpacity`];function px(){if(typeof window>`u`)return!1;let e=window.navigator;return window.matchMedia?.(`(display-mode: standalone)`).matches===!0||e.standalone===!0}function mx(){if(typeof window>`u`)return!1;let{userAgent:e=``,maxTouchPoints:t=0,platform:n=``}=window.navigator,r=e.toLowerCase();return/android|iphone|ipad|ipod|mobile/.test(r)||n===`MacIntel`&&t>1}function hx(){return typeof window>`u`||!(`Notification`in window)?`unsupported`:mx()?px()?`available`:`limited`:`available`}function gx(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`
|
|
106
|
-
`):``}function _x(e,t){return Object.fromEntries(t.map(t=>[t.id,gx(e[`providers.${t.id}.additionalArgs`])]))}function vx(e){switch(e){case`general`:return`settings.notifications_channel_hint`;case`providers`:return`settings.provider.command_preview_hint`;case`appearance`:return`settings.theme.hint`;case`shortcuts`:return`settings.shortcuts.hint`;case`about`:return`settings.about.description`}}var yx=[{titleKey:`settings.mobile_groups.workspace_runtime`,sections:[`general`,`providers`]},{titleKey:`settings.mobile_groups.interface_interaction`,sections:[`appearance`,`shortcuts`,`about`]}];function bx(e){let t=new Map(e.map(e=>[e.id,e])),n=yx.flatMap(e=>e.sections);if(n.length!==e.length)throw Error(`Mobile settings groups are out of sync with available sections.`);for(let e of n)if(!t.has(e))throw Error(`Missing mobile settings section mapping for "${e}".`);return yx.map(e=>({titleKey:e.titleKey,sections:e.sections.map(e=>t.get(e))}))}function xx(){let e=Z(),t=e(`settings.load_failed_unknown`),n=Yt(),r=Qt(),i=Br()===`mobile`,a=qb(),o=U(xp),s=U(Ep),c=U(zp),l=(()=>{let e=new URLSearchParams(n.search).get(`section`);return ex.some(t=>t.id===e)?e:null})(),u=(0,H.useRef)(l),[d,f]=(0,H.useState)(()=>l?{kind:`detail`,section:l}:i?{kind:`root`,lastSection:ux}:{kind:`detail`,section:ux}),[p]=(0,H.useState)([{id:`claude`,displayName:`Claude`},{id:`codex`,displayName:`Codex`}]),[m,h]=(0,H.useState)(!0),[g,_]=(0,H.useState)(!0),[v,y]=(0,H.useState)(600),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(0),[w,T]=(0,H.useState)(10),[E,D]=(0,H.useState)(!0),[O,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(`auto`),[M,N]=(0,H.useState)(`standard`),[P,F]=(0,H.useState)({}),ee=yo(),[I,L]=(0,H.useState)(ee.autoCheckEnabled),[R,z]=(0,H.useState)(ee.checkIntervalSec),[te,ne]=(0,H.useState)(`default`),[re,ie]=(0,H.useState)(null),[ae,B]=(0,H.useState)(0),[oe,se]=Te(Za),[ce,V]=Te(io),[le,ue]=Te(Xa),de=U(By),fe=W(ay),pe=W(By),me=W(Ty),he=ve(),ge=(0,H.useRef)(t),_e=(0,H.useRef)({theme:0,personalization:0,locale:0,lspRuntimeMode:0,terminalRenderer:0,terminalCopyOnSelect:0,desktopTerminalFontSize:0,mobileTerminalFontSize:0}),ye=(0,H.useRef)({autoCheckEnabled:0,checkIntervalSec:0}),be=d.kind===`detail`?d.section:d.lastSection,xe=i?tx:ex,Se=xe.find(e=>e.id===be)??xe[0],Ce=e=>{pe({...he.get(By),...e})};(0,H.useEffect)(()=>{ge.current=t},[t]),(0,H.useEffect)(()=>{f(e=>i?u.current&&e.kind===`detail`&&e.section===u.current?(u.current=null,e):e.kind===`root`?e:{kind:`root`,lastSection:e.section}:e.kind===`detail`?e:{kind:`detail`,section:e.lastSection})},[i]),(0,H.useEffect)(()=>{if(o!==`connected`)return;let e=!1;return(async()=>{let t={..._e.current},n={...ye.current},r=await a(`settings.get`,{});if(r===null)return;if(!r.ok||!r.data){e||ie(r.error?.message??ge.current);return}let i=r.data;if(e)return;ie(null),typeof i[`notifications.enabled`]==`boolean`&&h(i[`notifications.enabled`]),typeof i[`notifications.soundEnabled`]==`boolean`&&_(i[`notifications.soundEnabled`]),ye.current.autoCheckEnabled===n.autoCheckEnabled&&L(vo(i[`updates.autoCheckEnabled`])),ye.current.checkIntervalSec===n.checkIntervalSec&&z(_o(i[`updates.checkIntervalSec`])),_e.current.lspRuntimeMode===t.lspRuntimeMode&&(i[`lsp.mode`]===`auto`||i[`lsp.mode`]===`off`?(j(i[`lsp.mode`]),me(i[`lsp.mode`])):(j(`auto`),me(`auto`))),y(so(i[`supervisor.evaluationTimeoutSec`])),x(co(i[`supervisor.retryEnabled`])),C(lo(i[`supervisor.retryMaxCount`])),T(uo(i[`supervisor.retryDelaySec`])),D(fo(i[`supervisor.retryOnTimeout`])),k(po(i[`supervisor.retryOnEvaluatorError`])),fe({enabled:typeof i[`notifications.enabled`]==`boolean`?i[`notifications.enabled`]:!0,soundEnabled:typeof i[`notifications.soundEnabled`]==`boolean`?i[`notifications.soundEnabled`]:!0}),(i[`appearance.terminalRenderer`]===`standard`||i[`appearance.terminalRenderer`]===`compatibility`)&&_e.current.terminalRenderer===t.terminalRenderer&&N(i[`appearance.terminalRenderer`]);let o=_e.current.terminalCopyOnSelect===t.terminalCopyOnSelect,s=_e.current.desktopTerminalFontSize===t.desktopTerminalFontSize,c=_e.current.mobileTerminalFontSize===t.mobileTerminalFontSize;if(o||s||c){let e=he.get(By),t=s?Fy(i,`desktop`):Iy(e,`desktop`),n=c?Fy(i,`mobile`):Iy(e,`mobile`),r=My(i),a=Ny(i,`desktop`),l=Ny(i,`mobile`);pe({copyOnSelect:o?Ay(i):e.copyOnSelect,desktopFontSize:t,mobileFontSize:n,fontSize:a||l||r?t:e.fontSize})}if((i[`appearance.locale`]===`zh`||i[`appearance.locale`]===`en`)&&_e.current.locale===t.locale&&se(i[`appearance.locale`]),_e.current.personalization===t.personalization&&V(Va(i)),(Object.prototype.hasOwnProperty.call(i,`appearance.themeId`)||Object.prototype.hasOwnProperty.call(i,`appearance.theme`))&&_e.current.theme===t.theme){let e=ka(i[`appearance.themeId`]??i[`appearance.theme`]);ue(e),document.documentElement.setAttribute(`data-theme`,Oa(e).documentThemeAttr)}F(_x(i,p))})(),()=>{e=!0}},[o,a,se,fe,V,me,pe,ue,ae,he]);let we=e=>{_e.current.locale+=1,se(e)},Ee=e=>{_e.current.theme+=1,ue(e)},De=async e=>{let t=ce;_e.current.personalization+=1,V(e);let n=await a(`settings.update`,{settings:{appearance:{personalization:e}}});return n.ok?!0:(V(t),ie(n.error?.message??ge.current),!1)},Oe=e=>{_e.current.terminalRenderer+=1,N(e)},ke=e=>{_e.current.terminalCopyOnSelect+=1,Ce({copyOnSelect:e})},Ae=e=>{_e.current.desktopTerminalFontSize+=1,Ce({desktopFontSize:e,fontSize:e})},je=e=>{_e.current.mobileTerminalFontSize+=1,Ce({mobileFontSize:e})},Me=async e=>{if(e===A)return;_e.current.lspRuntimeMode+=1;let t=await a(`settings.update`,{settings:{lsp:{mode:e}}});if(t===null||!t.ok)return;let n=await a(`lsp.setMode`,{mode:e});n===null||!n.ok||(j(e),me(e))},Ne=async e=>await a(`settings.update`,{settings:{updates:e}}),Pe=async e=>{ye.current.autoCheckEnabled+=1,L(e);let t=await Ne({autoCheckEnabled:e});t!==null&&(t.ok||L(t=>!e))},Fe=async e=>{if(e===R)return;let t=R;ye.current.checkIntervalSec+=1,z(e);let n=await Ne({checkIntervalSec:e});n!==null&&(n.ok||z(t))};(0,H.useEffect)(()=>{be!==`providers`&&ne(`default`)},[be]);let Ie=()=>{let e=$b(!!c);if(e===`history`){r(-1);return}r(e)},Le=()=>{if(i&&d.kind===`detail`){f({kind:`root`,lastSection:d.section});return}Ie()},Re=()=>{switch(be){case`general`:return(0,X.jsx)(kx,{notificationsEnabled:m,setNotificationsEnabled:h,soundEnabled:g,setSoundEnabled:_,supervisorEvaluationTimeoutSec:v,setSupervisorEvaluationTimeoutSec:y,supervisorRetryEnabled:b,setSupervisorRetryEnabled:x,supervisorRetryMaxCount:S,setSupervisorRetryMaxCount:C,supervisorRetryDelaySec:w,setSupervisorRetryDelaySec:T,supervisorRetryOnTimeout:E,setSupervisorRetryOnTimeout:D,supervisorRetryOnEvaluatorError:O,setSupervisorRetryOnEvaluatorError:k,lspRuntimeMode:A,onLspRuntimeModeSelect:Me,terminalRenderer:M,setTerminalRenderer:Oe,terminalCopyOnSelect:de.copyOnSelect,setTerminalCopyOnSelect:ke,activeWorkspaceId:c});case`appearance`:return(0,X.jsx)(Ax,{desktopTerminalFontSize:Iy(de,`desktop`),mobileTerminalFontSize:Iy(de,`mobile`),locale:oe,personalization:ce,setDesktopTerminalFontSize:Ae,setLocale:we,setMobileTerminalFontSize:je,savePersonalization:De,theme:le,setTheme:Ee});case`providers`:return(0,X.jsx)(Xb,{providers:p,additionalArgsById:P,setAdditionalArgsById:F,isMobile:i,activeWorkspaceId:c,onLayoutModeChange:ne});case`shortcuts`:return(0,X.jsx)(lx,{});case`about`:return(0,X.jsx)(Ky,{autoCheckEnabled:I,checkIntervalSec:R,onAutoCheckEnabledChange:Pe,onCheckIntervalChange:Fe,locale:oe});default:return null}},ze=()=>(0,X.jsx)(`main`,{className:`settings-content settings-content--mobile-root`,children:(0,X.jsx)(`div`,{className:`settings-mobile-root`,"data-testid":`settings-mobile-root`,children:bx(xe).map(t=>(0,X.jsxs)(`section`,{className:`settings-mobile-group`,children:[(0,X.jsx)(`h2`,{className:`settings-mobile-group__title`,children:e(t.titleKey)}),(0,X.jsx)(`div`,{className:`settings-mobile-group__list`,children:t.sections.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`settings-mobile-item`,"aria-label":e(t.labelKey),onClick:()=>f({kind:`detail`,section:t.id}),children:[(0,X.jsx)(`span`,{className:`settings-mobile-item__icon-shell`,"aria-hidden":`true`,children:(0,X.jsx)(`span`,{className:`settings-mobile-item__icon`,children:(0,X.jsx)($,{semantic:t.iconSemantic,size:18})})}),(0,X.jsxs)(`span`,{className:`settings-mobile-item__copy`,children:[(0,X.jsx)(`span`,{className:`settings-mobile-item__label`,children:e(t.labelKey)}),(0,X.jsx)(`span`,{className:`settings-mobile-item__hint`,children:e(vx(t.id))})]}),(0,X.jsx)(yi,{size:16,className:`settings-mobile-item__arrow`})]},t.id))})]},t.titleKey))})}),Be=i&&d.kind===`root`,Ve=i&&d.kind===`detail`,He=e(i?Be?`settings.title`:Se.labelKey:`settings.title`);return(0,X.jsxs)(`div`,{className:`settings-page ${i?`settings-page--mobile`:``}`,children:[(0,X.jsx)(`header`,{className:`settings-header`,children:i?(0,X.jsx)(rm,{title:He,titleAs:`div`,onBack:Le,backLabel:e(`action.back`)}):(0,X.jsx)(nm,{title:e(`settings.title`),titleAs:`h1`,level:`secondary`,onBack:Le,backLabel:e(`action.back`)})}),Be?ze():(0,X.jsxs)(`div`,{className:`settings-body ${i?`settings-body--mobile`:``} ${Ve?`settings-body--mobile-detail`:``} ${te===`fill-height`?`settings-body--fill-height`:``}`,children:[i?null:(0,X.jsx)(`aside`,{className:`settings-sidebar`,children:(0,X.jsx)(`nav`,{className:`settings-nav`,children:xe.map(({id:t,labelKey:n,iconSemantic:r})=>(0,X.jsx)(Sx,{icon:(0,X.jsx)($,{semantic:r,size:16}),label:e(n),active:be===t,onClick:()=>f({kind:`detail`,section:t})},t))})}),(0,X.jsx)(`main`,{className:`settings-content ${i?`settings-content--mobile`:``} ${Ve?`settings-content--mobile-detail`:``} ${te===`fill-height`?`settings-content--fill-height`:``}`,children:(0,X.jsxs)(`div`,{className:`settings-content-surface`,children:[re&&(0,X.jsx)(jh,{role:`alert`,tone:`error`,title:e(`settings.load_failed`),message:re,action:(0,X.jsx)(`button`,{type:`button`,className:`settings-link`,onClick:()=>B(e=>e+1),children:e(`action.refresh`)})}),Re()]})})]}),(0,X.jsx)(`footer`,{className:`settings-footer ${i?`settings-footer--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`settings-footer__meta`,children:[(0,X.jsx)(`span`,{className:`settings-autosave`,children:e(`settings.autosave_hint`)}),(0,X.jsxs)(`span`,{className:`settings-version`,children:[`v`,s?.version??`0.0.0`]})]})})]})}function Sx({icon:e,label:t,active:n,onClick:r}){return(0,X.jsxs)(`button`,{className:`settings-nav-item ${n?`settings-nav-item-active`:``}`,onClick:r,children:[(0,X.jsx)(`span`,{className:`settings-nav-icon`,children:e}),(0,X.jsx)(`span`,{className:`settings-nav-label`,children:t}),n&&(0,X.jsx)(yi,{size:14,className:`settings-nav-arrow`})]})}function Cx(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<1||n>86400?null:n}function wx(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<0||n>20?null:n}function Tx(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<1||n>3600?null:n}function Ex(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<10||n>18?null:n}function Dx(e,t,n){let r=e.trim();if(!/^\d+$/.test(r))return null;let i=Number(r);return!Number.isSafeInteger(i)||i<t||i>n?null:i}function Ox(e){let t={};for(let n of fx)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];r!==void 0&&(t[n]=r)}return t}function kx({notificationsEnabled:e,setNotificationsEnabled:t,soundEnabled:n,setSoundEnabled:r,supervisorEvaluationTimeoutSec:i,setSupervisorEvaluationTimeoutSec:a,supervisorRetryEnabled:o,setSupervisorRetryEnabled:s,supervisorRetryMaxCount:c,setSupervisorRetryMaxCount:l,supervisorRetryDelaySec:u,setSupervisorRetryDelaySec:d,supervisorRetryOnTimeout:f,setSupervisorRetryOnTimeout:p,supervisorRetryOnEvaluatorError:m,setSupervisorRetryOnEvaluatorError:h,lspRuntimeMode:g,onLspRuntimeModeSelect:_,terminalRenderer:v,setTerminalRenderer:y,terminalCopyOnSelect:b,setTerminalCopyOnSelect:x,activeWorkspaceId:S}){let C=Z(),w=Qt(),T=(0,H.useId)(),E=(0,H.useId)(),D=(0,H.useId)(),O=(0,H.useId)(),k=(0,H.useId)(),A=(0,H.useId)(),j=(0,H.useId)(),M=(0,H.useId)(),N=(0,H.useId)(),P=(0,H.useId)(),F=qb(),ee=W(ay),[I,L]=(0,H.useState)(`unavailable`),[R,z]=(0,H.useState)(`unsupported`),[te,ne]=(0,H.useState)(String(i)),[re,ie]=(0,H.useState)(null),[ae,B]=(0,H.useState)(String(c)),[oe,se]=(0,H.useState)(String(u)),[ce,V]=(0,H.useState)(null),[le,ue]=(0,H.useState)(null),de=async e=>await F(`settings.update`,{settings:e}),fe=e=>{ee(e)};(0,H.useEffect)(()=>{if(z(hx()),`Notification`in window){L(Notification.permission);return}L(`unavailable`)},[]),(0,H.useEffect)(()=>{ne(String(i))},[i]),(0,H.useEffect)(()=>{B(String(c))},[c]),(0,H.useEffect)(()=>{se(String(u))},[u]),(0,H.useEffect)(()=>{ie(null)},[i]),(0,H.useEffect)(()=>{V(null)},[c]),(0,H.useEffect)(()=>{ue(null)},[u]);let pe=async()=>{`Notification`in window&&L(await Notification.requestPermission())},me=async()=>{let e=Cx(te);if(e===null){ne(String(i)),ie(C(`settings.supervisor.validation_error`,{max:ao}));return}if(e===i){ne(String(e)),ie(null);return}let t=await de({supervisor:{evaluationTimeoutSec:e}});if(t!==null){if(!t.ok){ne(String(i)),ie(t.error?.message||C(`settings.config_files.save_failed`));return}a(e),ne(String(e)),ie(null)}},he=async()=>{let e=wx(ae);if(e===null){B(String(c)),V(C(`settings.supervisor.retry_max_count_validation_error`,{max:20}));return}if(e===c){B(String(e)),V(null);return}let t=await de({supervisor:{retryMaxCount:e}});if(t!==null){if(!t.ok){B(String(c)),V(t.error?.message||C(`settings.config_files.save_failed`));return}l(e),B(String(e)),V(null)}},ge=async()=>{let e=Tx(oe);if(e===null){se(String(u)),ue(C(`settings.supervisor.retry_delay_validation_error`,{max:oo}));return}if(e===u){se(String(e)),ue(null);return}let t=await de({supervisor:{retryDelaySec:e}});if(t!==null){if(!t.ok){se(String(u)),ue(t.error?.message||C(`settings.config_files.save_failed`));return}d(e),se(String(e)),ue(null)}};return(0,X.jsxs)(`div`,{className:`settings-section`,children:[(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:C(`settings.notifications`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:C(`settings.notifications_channel_hint`)}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:T,children:C(`settings.notifications_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:E,children:C(`settings.notifications_enabled_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":E,"aria-labelledby":T,checked:e,className:`settings-toggle`,onCheckedChange:e=>{t(e),fe({enabled:e,soundEnabled:n}),de({notifications:{enabled:e}})}})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:D,children:C(`settings.notification_sound`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:O,children:C(`settings.notification_sound_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":O,"aria-labelledby":D,checked:n,className:`settings-toggle`,disabled:!e,onCheckedChange:t=>{r(t),fe({enabled:e,soundEnabled:t}),de({notifications:{soundEnabled:t}})}})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:C(`settings.notification_status`)}),(0,X.jsxs)(`span`,{className:`settings-info-value settings-capability-${R}`,children:[R===`available`&&C(`settings.notification_status_available`),R===`limited`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.notification_status_limited`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.notification_status_limited_hint`)})]}),R===`unsupported`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.notification_status_unsupported`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.notification_status_unsupported_hint`)})]})]})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:C(`settings.notification_permission`)}),(0,X.jsxs)(`span`,{className:`settings-info-value settings-permission-${I}`,children:[I===`granted`&&C(`settings.permission_granted`),I===`denied`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.permission_denied`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.permission_denied_hint`)})]}),I===`default`&&R===`available`&&(0,X.jsx)(`button`,{className:`settings-link`,onClick:pe,children:C(`settings.permission_request`)}),I===`default`&&R===`limited`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.permission_unavailable`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.permission_limited_hint`)})]}),I===`unavailable`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.permission_unavailable`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.permission_unavailable_hint`)})]})]})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:j,children:C(`settings.lsp_runtime_mode`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:M,children:C(`settings.lsp_runtime_mode_hint`)}),(0,X.jsxs)(`div`,{"aria-describedby":M,"aria-labelledby":j,className:`settings-pills`,role:`group`,children:[(0,X.jsx)(Nh,{leadingIcon:g===`auto`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{_(`auto`)},active:g===`auto`,children:C(`settings.lsp_runtime_mode_auto`)}),(0,X.jsx)(Nh,{leadingIcon:g===`off`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{_(`off`)},active:g===`off`,children:C(`settings.lsp_runtime_mode_off`)})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:k,children:C(`settings.terminal_renderer`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:A,children:C(`settings.terminal_renderer_hint`)}),(0,X.jsxs)(`div`,{"aria-describedby":A,"aria-labelledby":k,className:`settings-pills`,role:`group`,children:[(0,X.jsx)(Nh,{leadingIcon:v===`standard`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{y(`standard`),de({appearance:{terminalRenderer:`standard`}})},active:v===`standard`,children:C(`settings.terminal_standard`)}),(0,X.jsx)(Nh,{leadingIcon:v===`compatibility`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{y(`compatibility`),de({appearance:{terminalRenderer:`compatibility`}})},active:v===`compatibility`,children:C(`settings.terminal_compatibility`)})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:N,children:C(`settings.copy_on_select`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:P,children:C(`settings.copy_on_select_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":P,"aria-labelledby":N,checked:b,className:`settings-toggle`,onCheckedChange:e=>{x(e),de({appearance:{terminalCopyOnSelect:e}})}})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:C(`settings.supervisor.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:C(`settings.supervisor.hint`)}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-evaluation-timeout`,children:C(`settings.supervisor.evaluation_timeout`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`supervisor-evaluation-timeout`,className:`settings-input-compact`,type:`number`,min:1,max:ao,step:1,inputMode:`numeric`,invalid:!!re,value:te,onChange:e=>{ne(e.target.value),re&&ie(null)},onBlur:()=>{me()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())}})}),re?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:re}):null]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-enabled-label`,children:C(`settings.supervisor.retry_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-enabled-desc`,children:C(`settings.supervisor.retry_enabled_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":`supervisor-retry-enabled-desc`,"aria-labelledby":`supervisor-retry-enabled-label`,checked:o,className:`settings-toggle`,onCheckedChange:e=>{s(e),de({supervisor:{retryEnabled:e}})}})]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-max-count`,children:C(`settings.supervisor.retry_max_count`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`supervisor-retry-max-count`,className:`settings-input-compact`,type:`number`,min:0,max:20,step:1,inputMode:`numeric`,invalid:!!ce,value:ae,onChange:e=>{B(e.target.value),ce&&V(null)},onBlur:()=>{he()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),he())}})}),ce?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ce}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-delay-sec`,children:C(`settings.supervisor.retry_delay_sec`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`supervisor-retry-delay-sec`,className:`settings-input-compact`,type:`number`,min:1,max:oo,step:1,inputMode:`numeric`,invalid:!!le,value:oe,onChange:e=>{se(e.target.value),le&&ue(null)},onBlur:()=>{ge()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ge())}})}),le?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:le}):null]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-timeout-label`,children:C(`settings.supervisor.retry_on_timeout`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-timeout-desc`,children:C(`settings.supervisor.retry_on_timeout_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":`supervisor-retry-on-timeout-desc`,"aria-labelledby":`supervisor-retry-on-timeout-label`,checked:f,className:`settings-toggle`,onCheckedChange:e=>{p(e),de({supervisor:{retryOnTimeout:e}})}})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-evaluator-error-label`,children:C(`settings.supervisor.retry_on_evaluator_error`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-evaluator-error-desc`,children:C(`settings.supervisor.retry_on_evaluator_error_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":`supervisor-retry-on-evaluator-error-desc`,"aria-labelledby":`supervisor-retry-on-evaluator-error-label`,checked:m,className:`settings-toggle`,onCheckedChange:e=>{h(e),de({supervisor:{retryOnEvaluatorError:e}})}})]})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row settings-toggle-row--action`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,children:C(`diagnostics.title`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,children:C(`diagnostics.settings_hint`)})]}),(0,X.jsx)(Q,{className:`settings-diagnostics-button`,leadingIcon:(0,X.jsx)($,{semantic:`state.warning`,size:16}),onClick:()=>w(X_({context:`manual_check`,workspaceId:S??void 0})),size:`sm`,variant:`ghost`,children:C(`action.open`)})]})]})}function Ax({desktopTerminalFontSize:e,locale:t,mobileTerminalFontSize:n,personalization:r,setDesktopTerminalFontSize:i,setLocale:a,setMobileTerminalFontSize:o,savePersonalization:s,theme:c,setTheme:l}){let u=Z(),d=(0,H.useId)(),f=(0,H.useId)(),p=(0,H.useId)(),m=(0,H.useId)(),h=(0,H.useId)(),g=(0,H.useId)(),_=(0,H.useId)(),v=(0,H.useId)(),y=(0,H.useId)(),b=(0,H.useId)(),x=(0,H.useId)(),S=(0,H.useId)(),C=(0,H.useId)(),w=(0,H.useId)(),T=(0,H.useId)(),E=(0,H.useId)(),D=(0,H.useId)(),O=(0,H.useId)(),k=(0,H.useId)(),A=(0,H.useId)(),j=qb(),M=ka(c),N=Ca.map(e=>({value:e.id,label:u(e.labelKey)})),[P,F]=(0,H.useState)(String(e)),[ee,I]=(0,H.useState)(null),[L,R]=(0,H.useState)(String(n)),[z,te]=(0,H.useState)(null),[ne,re]=(0,H.useState)(null),[ie,ae]=(0,H.useState)(String(r.common.backgroundDimness)),[B,oe]=(0,H.useState)(String(r.common.backgroundBlur)),[se,ce]=(0,H.useState)(String(r.common.glassIntensity)),[V,le]=(0,H.useState)(String(r.common.surfaceOpacity)),[ue,de]=(0,H.useState)(null),[fe,pe]=(0,H.useState)(null),[me,he]=(0,H.useState)(null),[ge,_e]=(0,H.useState)(null),[ve,ye]=(0,H.useState)(r.desktop.surfaceOpacity===void 0?String(r.common.surfaceOpacity):String(r.desktop.surfaceOpacity)),[be,xe]=(0,H.useState)(r.mobile.surfaceOpacity===void 0?String(r.common.surfaceOpacity):String(r.mobile.surfaceOpacity)),[Se,Ce]=(0,H.useState)(null),[we,U]=(0,H.useState)(null),W=(0,H.useRef)(null),Te=(0,H.useRef)({desktopTerminalFontSize:0,mobileTerminalFontSize:0}),Ee=async e=>await j(`settings.update`,{settings:e});(0,H.useEffect)(()=>{F(String(e))},[e]),(0,H.useEffect)(()=>{R(String(n))},[n]),(0,H.useEffect)(()=>{I(null)},[e]),(0,H.useEffect)(()=>{te(null)},[n]),(0,H.useEffect)(()=>{ae(String(r.common.backgroundDimness)),oe(String(r.common.backgroundBlur)),ce(String(r.common.glassIntensity)),le(String(r.common.surfaceOpacity)),ye(String(r.desktop.surfaceOpacity??r.common.surfaceOpacity)),xe(String(r.mobile.surfaceOpacity??r.common.surfaceOpacity))},[r]);let De=e=>{let t=Oa(e);t.id!==M&&(l(t.id),document.documentElement.setAttribute(`data-theme`,t.documentThemeAttr),Ee({appearance:{themeId:t.id}}))},Oe=(e,t)=>({...r,common:{...r.common,[e]:t}}),ke=e=>e===`image`?r.common:{...r.common,backgroundAssetId:null},Ae=(e,t,n)=>{let i={...r[e],[t]:n};return n===void 0&&delete i[t],{...r,[e]:Ox(i)}},je=e=>Object.keys(r[e]).length>0,Me=(e,t)=>t?{...r,[e]:Ox({...r[e],surfaceOpacity:r[e].surfaceOpacity??r.common.surfaceOpacity})}:{...r,[e]:{}},Ne=async e=>(re(null),await s(e)),Pe=async(e,t,n,r,i,a,o)=>{let s=Dx(e,n,r);if(s===null){i(String(t)),a(u(`settings.terminal_font_size_validation_error`,{min:n,max:r}));return}if(s===t){i(String(s)),a(null);return}if(!await Ne(Oe(o,s))){i(String(t)),a(u(`settings.config_files.save_failed`));return}i(String(s)),a(null)},Fe=async(e,t,n,r,i,a,o,s)=>{let c=Dx(t,r,i);if(c===null){a(String(n)),o(u(`settings.terminal_font_size_validation_error`,{min:r,max:i}));return}if(!await Ne(Ae(e,s,c))){a(String(n)),o(u(`settings.config_files.save_failed`));return}a(String(c)),o(null)},Ie=async(e,t)=>{let[n]=Array.from(e.target.files??[]);if(e.target.value=``,n)try{let e=await ei(n);t===`common`?await Ne(Oe(`backgroundAssetId`,e.assetId))||re(u(`settings.config_files.save_failed`)):await Ne(Ae(t,`backgroundAssetId`,e.assetId))||re(u(`settings.config_files.save_failed`))}catch{re(u(`settings.appearance_asset_upload_failed`))}},Le=e=>{W.current&&(W.current.dataset.scope=e,W.current.click())},Re=async e=>{let t=e===`common`?r.common.backgroundAssetId:r[e].backgroundAssetId;if(t)try{await ti(t),e===`common`?await Ne(Oe(`backgroundAssetId`,null))||re(u(`settings.config_files.save_failed`)):await Ne(Ae(e,`backgroundAssetId`,null))||re(u(`settings.config_files.save_failed`))}catch{re(u(`settings.appearance_asset_delete_failed`))}},ze=(e,t)=>(0,X.jsxs)(`div`,{className:`settings-appearance-actions`,children:[(0,X.jsx)(Q,{"aria-label":u(t?`settings.appearance_background_replace`:`settings.appearance_background_upload`),size:`sm`,variant:`secondary`,onClick:()=>Le(e),children:u(t?`settings.appearance_background_replace`:`settings.appearance_background_upload`)}),t?(0,X.jsx)(Q,{"aria-label":u(`settings.appearance_background_remove`),size:`sm`,variant:`ghost`,onClick:()=>void Re(e),children:u(`settings.appearance_background_remove`)}):null]}),Be=(e,t,n,r)=>(0,X.jsxs)(`div`,{className:`settings-appearance-asset-summary`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info settings-appearance-asset-meta`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,children:t}),(0,X.jsx)(`span`,{className:`settings-toggle-desc settings-appearance-asset-id`,children:n||u(`settings.appearance_uses_shared_value`)})]}),ze(e,r)]}),Ve=async(e,t,n,r,i,a)=>{let o=Ex(e);if(o===null){i(String(t)),a(u(`settings.terminal_font_size_validation_error`,{min:10,max:18}));return}if(o===t){i(String(o)),a(null);return}let s=Date.now();if(s-Te.current[n]<dx)return;Te.current[n]=s;let c=await j(`settings.update`,{settings:{appearance:{[n]:o}}});if(c!==null){if(!c.ok){i(String(t)),a(c.error?.message||u(`settings.config_files.save_failed`));return}r(o),i(String(o)),a(null)}};return(0,X.jsxs)(`div`,{className:`settings-section`,children:[(0,X.jsx)(`input`,{ref:W,id:b,accept:`image/png,image/jpeg,image/webp`,className:`settings-appearance-file-input`,type:`file`,onChange:e=>{Ie(e,e.currentTarget.dataset.scope??`common`)}}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:u(`settings.appearance_background_material`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:u(`settings.appearance_background_material_hint`)}),(0,X.jsxs)(`div`,{className:`settings-appearance-panels`,children:[(0,X.jsxs)(`div`,{className:`settings-appearance-panel settings-appearance-panel--asset`,children:[(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-mode`,children:u(`settings.appearance_background_mode`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(tg,{desktopMode:`listbox`,id:`appearance-background-mode`,"aria-label":u(`settings.appearance_background_mode`),className:`settings-input-compact`,mobileSheetTitle:u(`settings.appearance_background_mode`),options:[{value:`none`,label:u(`settings.appearance_background_mode_off`)},{value:`image`,label:u(`settings.appearance_background_mode_image`)}],value:r.common.backgroundMode,onValueChange:e=>{let t=e,n={...r,common:ke(t)};n.common.backgroundMode=t,Ne(n)}})})]}),r.common.backgroundMode===`image`?Be(`common`,u(`settings.appearance_background_upload`),r.common.backgroundAssetId,!!r.common.backgroundAssetId):null,(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-fit`,children:u(`settings.appearance_background_fit`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(tg,{desktopMode:`listbox`,id:`appearance-background-fit`,"aria-label":u(`settings.appearance_background_fit`),className:`settings-input-compact`,mobileSheetTitle:u(`settings.appearance_background_fit`),options:[{value:`cover`,label:u(`settings.appearance_background_fit_cover`)},{value:`contain`,label:u(`settings.appearance_background_fit_contain`)}],value:r.common.backgroundFit,onValueChange:e=>{Ne(Oe(`backgroundFit`,e))}})})]})]}),(0,X.jsxs)(`div`,{className:`settings-appearance-panel settings-appearance-panel--material`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:x,children:u(`settings.appearance_glass_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:S,children:u(`settings.appearance_uses_shared_value`)})]}),(0,X.jsx)(fg,{"aria-describedby":S,"aria-labelledby":x,checked:r.common.glassEnabled,className:`settings-toggle`,onCheckedChange:e=>{Ne(Oe(`glassEnabled`,e))}})]}),(0,X.jsxs)(`div`,{className:`settings-appearance-material-grid`,children:[(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-dimness`,children:u(`settings.appearance_background_dimness`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-background-dimness`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!ue,max:100,min:0,step:1,type:`number`,value:ie,onBlur:()=>{Pe(ie,r.common.backgroundDimness,0,100,ae,de,`backgroundDimness`)},onChange:e=>{ae(e.target.value),de(null)}})}),ue?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ue}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-blur`,children:u(`settings.appearance_background_blur`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-background-blur`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!fe,max:40,min:0,step:1,type:`number`,value:B,onBlur:()=>{Pe(B,r.common.backgroundBlur,0,40,oe,pe,`backgroundBlur`)},onChange:e=>{oe(e.target.value),pe(null)}})}),fe?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:fe}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-glass-intensity`,children:u(`settings.appearance_glass_intensity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-glass-intensity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!me,max:100,min:0,step:1,type:`number`,value:se,onBlur:()=>{Pe(se,r.common.glassIntensity,0,100,ce,he,`glassIntensity`)},onChange:e=>{ce(e.target.value),he(null)}})}),me?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:me}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-surface-opacity`,children:u(`settings.appearance_surface_opacity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-surface-opacity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!ge,max:100,min:0,step:1,type:`number`,value:V,onBlur:()=>{Pe(V,r.common.surfaceOpacity,0,100,le,_e,`surfaceOpacity`)},onChange:e=>{le(e.target.value),_e(null)}})}),ge?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ge}):null]})]})]}),(0,X.jsxs)(`div`,{className:`settings-appearance-overrides`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:C,children:u(`settings.appearance_override_desktop`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:w,children:je(`desktop`)?u(`settings.appearance_override_enabled`):u(`settings.appearance_uses_shared_value`)})]}),(0,X.jsx)(fg,{"aria-describedby":w,"aria-labelledby":C,checked:je(`desktop`),className:`settings-toggle`,onCheckedChange:e=>{Ne(Me(`desktop`,e))}})]}),je(`desktop`)?(0,X.jsxs)(`div`,{className:`settings-appearance-override-panel`,children:[r.common.backgroundMode===`image`?Be(`desktop`,u(`settings.appearance_override_desktop`),r.desktop.backgroundAssetId,Object.prototype.hasOwnProperty.call(r.desktop,`backgroundAssetId`)):null,(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:T,children:u(`settings.appearance_glass_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:E,children:u(`settings.appearance_override_desktop`)})]}),(0,X.jsx)(fg,{"aria-describedby":E,"aria-labelledby":T,checked:r.desktop.glassEnabled??r.common.glassEnabled,className:`settings-toggle`,onCheckedChange:e=>{Ne(Ae(`desktop`,`glassEnabled`,e))}})]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-desktop-surface-opacity`,children:u(`settings.appearance_surface_opacity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-desktop-surface-opacity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!Se,max:100,min:0,step:1,type:`number`,value:ve,onBlur:()=>{Fe(`desktop`,ve,r.desktop.surfaceOpacity??r.common.surfaceOpacity,0,100,ye,Ce,`surfaceOpacity`)},onChange:e=>{ye(e.target.value),Ce(null)}})}),Se?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:Se}):null]})]}):null,(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:D,children:u(`settings.appearance_override_mobile`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:O,children:je(`mobile`)?u(`settings.appearance_override_enabled`):u(`settings.appearance_uses_shared_value`)})]}),(0,X.jsx)(fg,{"aria-describedby":O,"aria-labelledby":D,checked:je(`mobile`),className:`settings-toggle`,onCheckedChange:e=>{Ne(Me(`mobile`,e))}})]}),je(`mobile`)?(0,X.jsxs)(`div`,{className:`settings-appearance-override-panel`,children:[r.common.backgroundMode===`image`?Be(`mobile`,u(`settings.appearance_override_mobile`),r.mobile.backgroundAssetId,Object.prototype.hasOwnProperty.call(r.mobile,`backgroundAssetId`)):null,(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:k,children:u(`settings.appearance_glass_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:A,children:u(`settings.appearance_override_mobile`)})]}),(0,X.jsx)(fg,{"aria-describedby":A,"aria-labelledby":k,checked:r.mobile.glassEnabled??r.common.glassEnabled,className:`settings-toggle`,onCheckedChange:e=>{Ne(Ae(`mobile`,`glassEnabled`,e))}})]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-mobile-surface-opacity`,children:u(`settings.appearance_surface_opacity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-mobile-surface-opacity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!we,max:100,min:0,step:1,type:`number`,value:be,onBlur:()=>{Fe(`mobile`,be,r.mobile.surfaceOpacity??r.common.surfaceOpacity,0,100,xe,U,`surfaceOpacity`)},onChange:e=>{xe(e.target.value),U(null)}})}),we?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:we}):null]})]}):null]})]}),ne?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ne}):null]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:u(`settings.terminal_appearance`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:u(`settings.terminal_font_size_hint`)}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`desktop-terminal-font-size`,id:g,children:u(`settings.desktop_terminal_font_size`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`desktop-terminal-font-size`,"aria-describedby":_,"aria-labelledby":g,className:`settings-input-compact`,type:`number`,min:10,max:18,step:1,inputMode:`numeric`,invalid:!!ee,value:P,onChange:e=>{F(e.target.value),ee&&I(null)},onBlur:()=>{Ve(P,e,`desktopTerminalFontSize`,i,F,I)},onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),Ve(P,e,`desktopTerminalFontSize`,i,F,I))}})}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:_,children:u(`settings.desktop_terminal_font_size_hint`)}),ee?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ee}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`mobile-terminal-font-size`,id:v,children:u(`settings.mobile_terminal_font_size`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`mobile-terminal-font-size`,"aria-describedby":y,"aria-labelledby":v,className:`settings-input-compact`,type:`number`,min:10,max:18,step:1,inputMode:`numeric`,invalid:!!z,value:L,onChange:e=>{R(e.target.value),z&&te(null)},onBlur:()=>{Ve(L,n,`mobileTerminalFontSize`,o,R,te)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Ve(L,n,`mobileTerminalFontSize`,o,R,te))}})}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:y,children:u(`settings.mobile_terminal_font_size_hint`)}),z?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:z}):null]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:d,children:u(`settings.theme.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:f,children:u(`settings.theme.hint`)}),(0,X.jsx)(tg,{desktopMode:`listbox`,id:p,"aria-describedby":f,"aria-label":u(`settings.theme.title`),className:`settings-input-compact`,mobileSheetTitle:u(`settings.theme.title`),options:N,value:M,onValueChange:De})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:m,children:u(`settings.language.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:h,children:u(`settings.language.hint`)}),(0,X.jsxs)(`div`,{"aria-describedby":h,"aria-labelledby":m,className:`settings-pills`,role:`group`,children:[(0,X.jsx)(Nh,{leadingIcon:t===`zh`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{a(`zh`),Ee({appearance:{locale:`zh`}})},active:t===`zh`,children:u(`settings.language.zh`)}),(0,X.jsx)(Nh,{leadingIcon:t===`en`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{a(`en`),Ee({appearance:{locale:`en`}})},active:t===`en`,children:u(`settings.language.en`)})]})]})]})}var jx=()=>{let e=Z(),t=Qt(),[n,r]=(0,H.useState)(!1),i=Br()===`mobile`,a=[{iconSemantic:`state.welcome.lightning`,title:e(`welcome.features.agent_first.title`),description:e(`welcome.features.agent_first.description`)},{iconSemantic:`state.welcome.git`,title:e(`welcome.features.git_tools.title`),description:e(`welcome.features.git_tools.description`)},{iconSemantic:`state.welcome.terminal`,title:e(`welcome.features.terminals.title`),description:e(`welcome.features.terminals.description`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`welcome-container ${i?`welcome-container--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`welcome-card ${i?`welcome-card--mobile`:``}`,children:[(0,X.jsxs)(`div`,{className:`welcome-card__hero`,children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`welcome.kicker`)}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`welcome.title`)}),(0,X.jsx)(`p`,{className:`welcome-body meta-text`,children:e(`welcome.description`)})]}),(0,X.jsx)(`div`,{className:`welcome-card__actions`,children:(0,X.jsxs)(`div`,{className:`welcome-actions-group`,children:[(0,X.jsxs)(`button`,{className:`welcome-btn`,onClick:()=>{r(!0)},children:[(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:18}),(0,X.jsx)(`span`,{children:e(`action.open_workspace`)})]}),(0,X.jsxs)(`button`,{className:`welcome-link`,onClick:()=>{t(`/settings`)},children:[(0,X.jsx)($,{semantic:`nav.settings`,size:14}),(0,X.jsx)(`span`,{children:e(`action.settings`)})]})]})}),(0,X.jsx)(`div`,{className:`welcome-card__features`,children:(0,X.jsx)(`div`,{className:`welcome-features`,children:a.map(e=>(0,X.jsxs)(`div`,{className:`welcome-feature`,children:[(0,X.jsx)($,{className:`welcome-feature-icon`,semantic:e.iconSemantic,size:18}),(0,X.jsxs)(`div`,{className:`welcome-feature-text`,children:[(0,X.jsx)(`div`,{className:`welcome-feature-title`,children:e.title}),(0,X.jsx)(`div`,{className:`welcome-feature-desc`,children:e.description})]})]},e.iconSemantic))})})]})}),n?(0,X.jsx)(Qv,{onClose:()=>r(!1)}):null]})};function Mx(e){let t=W(tv(e)),n=ve(),{persistUiState:r}=Bv(e),i=(0,H.useCallback)(i=>{let a=n.get(tv(e)),o=typeof i==`function`?i(a):i;return t(o),r({paneLayout:o}),o},[r,t,n,e]),a=(0,H.useCallback)((e,t)=>{i(n=>mv(n,e,t))},[i]),o=(0,H.useCallback)((e,t)=>{i(n=>pv(n,e,t))},[i]),s=(0,H.useCallback)(e=>{i(t=>bv(t,e))},[i]),c=(0,H.useCallback)(e=>{i(t=>Sv(t,e))},[i]),l=(0,H.useCallback)(e=>{i(t=>wv(t,e))},[i]),u=(0,H.useCallback)((e,t)=>{i(n=>hv(n,e,t))},[i]),d=(0,H.useCallback)(e=>{i({id:`root`,type:`leaf`,sessionId:e})},[i]),f=(0,H.useCallback)((e,t)=>{i(n=>gv(n,e,t))},[i]);return{appendSession:(0,H.useCallback)((e,t,n=`horizontal`)=>{i(r=>Dv(r,e,t,n))},[i]),appendSessionToMobileColumn:(0,H.useCallback)(e=>{i(t=>Ov(t,e))},[i]),assignSession:u,closeDraftPane:c,closeSessionPane:s,removeSessionPane:l,replaceSession:f,replaceWithSession:d,splitDraftPane:o,splitSessionPane:a,swapPaneSessions:(0,H.useCallback)((e,t)=>{i(n=>_v(n,e,t))},[i]),moveSessionToDraft:(0,H.useCallback)((e,t)=>{i(n=>vv(n,e,t))},[i]),insertSessionPaneAtEdge:(0,H.useCallback)((e,t,n)=>{i(r=>yv(r,e,t,n))},[i])}}var Nx=.22,Px=48,Fx=96;function Ix(){return{isDragging:!1,source:null,hoverTargetPaneId:null,hoverPlacement:null,previewPosition:{x:0,y:0},previewX:0,previewY:0}}function Lx(e){return Math.max(Px,Math.min(Fx,e*Nx))}function Rx(e,t,n,r,i){let a=t.element.getBoundingClientRect();if(n<a.left||n>a.right||r<a.top||r>a.bottom||i===e)return null;if(t.type===`draft`)return`center`;let o=Lx(a.width),s=Lx(a.height);return n<=a.left+o?`left`:n>=a.right-o?`right`:r<=a.top+s?`top`:r>=a.bottom-s?`bottom`:`center`}function zx({enabled:e=!0,onDrop:t}){let n=(0,H.useRef)(new Map),[r,i]=(0,H.useState)(()=>Ix()),a=(0,H.useRef)(t),o=(0,H.useRef)(r),s=(0,H.useCallback)(e=>{let t=typeof e==`function`?e(o.current):e;o.current=t,i(t)},[]),c=(0,H.useCallback)((e,t)=>{if(!t){n.current.delete(e);return}n.current.set(e,t)},[]),l=(0,H.useCallback)(t=>{e&&(document.body.classList.add(`is-dragging-pane`),s({isDragging:!0,source:t,hoverTargetPaneId:null,hoverPlacement:null,previewPosition:{x:0,y:0},previewX:0,previewY:0}))},[e,s]),u=(0,H.useCallback)(()=>{document.body.classList.remove(`is-dragging-pane`),s(Ix())},[s]);(0,H.useEffect)(()=>{a.current=t},[t]),(0,H.useEffect)(()=>{!e&&o.current.isDragging&&u()},[u,e]);let d=(0,H.useCallback)(e=>{s(t=>{if(!t.isDragging)return t;let r=null,i=null;for(let[a,o]of n.current.entries()){let n=Rx(a,o,e.clientX,e.clientY,t.source?.paneId);if(n){r=a,i=n;break}}return{...t,hoverTargetPaneId:r,hoverPlacement:i,previewPosition:{x:e.clientX,y:e.clientY},previewX:e.clientX,previewY:e.clientY}})},[s]),f=(0,H.useCallback)(()=>{let e=o.current;if(e.isDragging&&e.source&&e.hoverTargetPaneId&&e.hoverPlacement){let t=n.current.get(e.hoverTargetPaneId);t&&a.current({sourcePaneId:e.source.paneId,targetPaneId:e.hoverTargetPaneId,placement:e.hoverPlacement,targetType:t.type})}u()},[u]),p=(0,H.useCallback)(()=>{u()},[u]);return(0,H.useEffect)(()=>{if(r.isDragging)return window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,p),()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,p)}},[p,d,f,r.isDragging]),(0,H.useEffect)(()=>()=>{document.body.classList.remove(`is-dragging-pane`)},[]),{clearDrag:u,handlePointerCancel:p,handlePointerMove:d,handlePointerUp:f,registerPane:c,startDrag:l,state:r}}var Bx=`(pointer: coarse)`,Vx=e=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>void 0;let t=window.matchMedia(Bx);return typeof t.addEventListener==`function`?(t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}):(t.addListener(e),()=>{t.removeListener(e)})},Hx=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:!window.matchMedia(Bx).matches,Ux=()=>!0;function Wx(){return(0,H.useSyncExternalStore)(Vx,Hx,Ux)}var Gx=new TextEncoder,Kx=100,qx=5e3;function Jx(e){return new Promise(t=>{setTimeout(t,e)})}function Yx(){let e=U(Op),t=U(bp),n=ve(),r=(0,H.useCallback)(async t=>{let n=await e(`session.stop`,{sessionId:t});n.ok||console.error(`Failed to stop session:`,n.error?.message)},[e]);return{closeSession:(0,H.useCallback)(async(t,r=`draft`)=>{let i=n.get(Up(t));if(!i)return!1;if(r===`remove`){let n=await e(`session.close`,{sessionId:t,paneDisposition:r});return n.ok?!0:(console.error(`Failed to close session:`,n.error?.message),!1)}if(i.state===`ended`){let n=await e(`session.remove`,{sessionId:t});return n.ok?!0:(console.error(`Failed to remove ended session:`,n.error?.message),!1)}let a=await e(`session.stop`,{sessionId:t});if(!a.ok&&a.error?.code!==`invalid_state`)return console.error(`Failed to stop session before removal:`,a.error?.message),!1;let o=Date.now()+qx;for(;Date.now()<o;){let r=n.get(Up(t));if(!r)return!0;if(r.state===`ended`){let n=await e(`session.remove`,{sessionId:t});return n.ok?!0:(console.error(`Failed to remove ended session:`,n.error?.message),!1)}await Jx(Kx)}return console.error(`Timed out waiting for session to end before removal:`,t),!1},[e,n]),submitSessionPrompt:(0,H.useCallback)(async(e,n)=>{let r=n.trim();if(!t||!r)return!1;try{return await t.sendTerminalInput(e,Gx.encode(`${r}\r`),`submit`,r),!0}catch(e){return console.error(`Failed to submit session prompt:`,e),!1}},[t]),stopSession:r}}function Xx(e,t){let n=U(Bp),r=e===void 0?n:e,i=r?.id??`__workspace_empty__`,a=t?.disabled??!1,o=U(Op),s=U(xp),c=U(Hp(i)),l=U(tv(i)),u=W(Vp),d=W(tv(i)),f=ve(),{persistUiState:p}=Bv(i);return(0,H.useEffect)(()=>{if(a||!r||s!==`connected`)return;let e=!1,t=new Set(Object.values(f.get(Vp)).filter(e=>e.workspaceId===r.id).map(e=>e.id));return o(`session.list`,{workspaceId:r.id}).then(n=>{if(e||!n.ok||!n.data){console.error(`Failed to fetch sessions:`,n.error?.message);return}let a=n.data,o=Object.values(f.get(Vp)).filter(e=>e.workspaceId===r.id).filter(e=>!t.has(e.id)&&!a.some(t=>t.id===e.id)),s=[...a,...o];u(e=>{let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.workspaceId!==r.id));for(let e of s)t[e.id]=e;return t});let c=f.get(tv(i)),l=Zx(r?.uiState.paneLayout),m=l?null:Zx(rv(r.id)),h=l??m??c??ev,g=new Set(s.filter(e=>e.state!==`draft`).map(e=>e.id)),_=s.filter(e=>e.state!==`draft`),v=Av(h,g),y=new Set(Ev(v)),b=s.filter(e=>e.state!==`draft`&&e.state!==`ended`&&!y.has(e.id)).map(e=>e.id);b.length>0&&(v=Qx(v,b)),Ev(v).length>0||_.length>0&&(v=kv(_.map(e=>e.id))),v!==c&&d(v);let x=!l||m!==null||b.length>0,S=m!==null||Ev(v).length>0;x&&S&&p({paneLayout:v}).then(e=>{e&&m!==null&&iv(r.id)})}).catch(t=>{e||console.error(`Failed to fetch sessions:`,t)}),()=>{e=!0}},[s,a,o,p,d,u,f,r?.id,i]),{workspace:r,workspaceId:i,sessions:c,paneLayout:l,setPaneLayout:d}}function Zx(e){return e?{id:e.id,type:e.type,sessionId:e.sessionId,direction:e.direction,ratio:`ratio`in e?e.ratio:void 0,children:e.children?.map(e=>Zx(e)??ev)}:null}function Qx(e,t){let n=e,r=Ev(n),i=r[r.length-1]??null;for(let e of t)n=Dv(n,e,i,`horizontal`),i=e;return n}function $x(e){return e.autoInstallSupported&&e.installReadiness===`ready`}function eS(e){return{providerId:e,available:!0,missingCommands:[],missingPrerequisites:[],autoInstallSupported:!1,installReadiness:`ready`,manualGuideKeys:[],docUrls:{provider:``,prerequisites:{}}}}function tS(e){return{claude:{runtime:e?.claude??eS(`claude`),loading:!1},codex:{runtime:e?.codex??eS(`codex`),loading:!1}}}function nS(e,t,n,r){let[i,a]=(0,H.useState)(tS()),o=(0,H.useRef)({}),s=Aa();(0,H.useEffect)(()=>{let t=!1;return(async()=>{let n=await e(`provider.runtimeStatus`,{});if(t)return;if(!n.ok||!n.data){a(e=>({claude:{...e.claude,...tS().claude},codex:{...e.codex,...tS().codex}}));return}let r=tS(n.data.providers);a(e=>({claude:{...e.claude,...r.claude},codex:{...e.codex,...r.codex}}))})(),()=>{t=!0;for(let e of Object.values(o.current))typeof e==`number`&&window.clearTimeout(e)}},[e]);let c=async()=>{let t=await e(`provider.runtimeStatus`,{});if(!t.ok||!t.data)return;let n=tS(t.data.providers);a(e=>({claude:{...e.claude,runtime:n.claude.runtime,loading:!1},codex:{...e.codex,runtime:n.codex.runtime,loading:!1}}))},l=(e,t,n)=>{a(r=>({...r,[e]:{...r[e],loading:!1,inlineError:n,installJob:r[e].installJob?{...r[e].installJob,failure:t}:r[e].installJob}}))},u=async(e,t,n)=>{n===`provider_cli_missing`&&await c(),a(n=>({...n,[e]:{...n[e],loading:!1,inlineError:t}}))};return{states:i,launch:async r=>{let d=i[r].runtime;if(!d)return;if(a(e=>({...e,[r]:{...e[r],loading:!0,inlineError:void 0}})),d.available){let i=await e(`session.create`,{workspaceId:t,providerId:r,themeBackground:s});if(i.ok&&i.data){n(i.data,r),a(e=>({...e,[r]:{...e[r],loading:!1}}));return}await u(r,i.error?.message,i.error?.code);return}if(!$x(d)){a(e=>({...e,[r]:{...e[r],loading:!1,inlineError:`manual`}}));return}let f=await e(`provider.install.start`,{providerId:r});if(!f.ok||!f.data){a(e=>({...e,[r]:{...e[r],loading:!1,inlineError:f.error?.message}}));return}if(a(e=>({...e,[r]:{...e[r],installJob:f.data,loading:!1}})),f.data.status===`failed`){l(r,f.data.failure,f.data.failure?.message);return}if(f.data.status===`succeeded`){await c();let i=await e(`session.create`,{workspaceId:t,providerId:r,themeBackground:s});i.ok&&i.data&&n(i.data,r),i.ok||await u(r,i.error?.message,i.error?.code);return}let p=async()=>{let i=await e(`provider.install.get`,{jobId:f.data.jobId});if(!i.ok||!i.data){a(e=>({...e,[r]:{...e[r],loading:!1,inlineError:i.error?.message}}));return}if(a(e=>({...e,[r]:{...e[r],installJob:i.data,loading:!1,inlineError:void 0}})),i.data.status===`queued`||i.data.status===`running`){o.current[r]=window.setTimeout(p,1500);return}if(i.data.status===`failed`){l(r,i.data.failure,i.data.failure?.message);return}await c();let d=await e(`session.create`,{workspaceId:t,providerId:r,themeBackground:s});if(d.ok&&d.data){n(d.data,r);return}await u(r,d.error?.message,d.error?.code)};o.current[r]=window.setTimeout(p,1500)}}}var rS=({dragState:e,workspaceId:t,paneId:n,onAssignSession:r,onClosePane:i,onPaneDrop:a,onReplaceWithSession:o,onSplitPane:s})=>{let c=Z(),l=U(Op),u=W(Vp),{states:d,launch:f}=nS(l,t,(e,t)=>{u(t=>({...t,[e.id]:e})),n?r?.(n,e.id):o?.(e.id)},{paneId:n,launchMode:n?`assign`:`replace`}),p=e=>X_({context:`session_start`,workspaceId:t,providerId:e,paneId:n,launchMode:n?`assign`:`replace`}),m=e=>{let t=d[e].runtime;return!!(t?.autoInstallSupported&&t.installReadiness===`ready`)},h=e=>{let t=d[e];return t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`?c(`provider.install.cta.installing`):t.runtime?.available?c(`provider.install.cta.start`):m(e)?c(`provider.install.cta.install_and_start`):c(`provider.install.cta.manual`)},g=e=>{let t=d[e],n=t.installJob?.failure;return n?{message:n.message,docUrl:n.docUrls.provider}:t.inlineError&&t.inlineError!==`manual`?{message:t.inlineError,docUrl:t.runtime?.docUrls.provider}:t.inlineError===`manual`||!m(e)?{message:t.runtime?.manualGuideKeys.map(e=>c(e)).join(` `),docUrl:t.runtime?.docUrls.provider}:{docUrl:t.runtime?.docUrls.provider}},_=Object.values(d).some(e=>e.loading||e.installJob?.status===`queued`||e.installJob?.status===`running`);return(0,X.jsxs)(`div`,{className:`session-card agent-pane${e?.isDragging?` draft-launcher--dragging`:``}${e?.isActiveDropTarget?` draft-launcher--drop-target`:``}`,"data-pane-id":n,children:[e?.isActiveDropTarget?(0,X.jsx)(`div`,{className:`pane-drop-overlay pane-drop-overlay--draft`,children:(0,X.jsx)(`div`,{className:`pane-drop-overlay__center`,children:`Move here`})}):null,(0,X.jsxs)(`div`,{className:`session-header`,children:[(0,X.jsxs)(`div`,{className:`session-header-left`,children:[(0,X.jsx)(lg,{tone:`neutral`,className:`session-dot session-dot-idle`}),(0,X.jsx)(`div`,{className:`session-header-copy`,children:(0,X.jsxs)(`div`,{className:`session-title-row`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:c(`session.provider_select`)||`New Session`}),(0,X.jsx)(_g,{color:`neutral`,className:`session-state-badge`,children:`DRAFT`})]})})]}),(0,X.jsxs)(`div`,{className:`session-header-actions`,children:[(0,X.jsx)(Ig,{content:`Split horizontal`,children:(0,X.jsx)(Em,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,X.jsx)(ca,{size:13}),onClick:()=>{n&&s?.(n,`horizontal`)},size:`sm`})}),(0,X.jsx)(Ig,{content:`Split vertical`,children:(0,X.jsx)(Em,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,X.jsx)(sa,{size:13}),onClick:()=>{n&&s?.(n,`vertical`)},size:`sm`})}),(0,X.jsx)(Ig,{content:`Close`,children:(0,X.jsx)(Em,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:()=>{n&&i?.(n)},size:`sm`})})]})]}),(0,X.jsx)(`div`,{className:`agent-draft-launcher`,children:(0,X.jsxs)(`div`,{className:`agent-draft-content`,children:[(0,X.jsx)(`span`,{className:`agent-draft-kicker`,children:`SESSION LAUNCHER`}),(0,X.jsx)(`p`,{className:`agent-draft-description`,children:`选择一个 AI 会话,在当前 workspace 里继续查看文件、运行命令和推进代码修改。`}),(0,X.jsx)(`div`,{className:`agent-draft-providers`,children:[{id:`claude`,title:`Claude`,meta:`analysis`,icon:(0,X.jsx)($,{semantic:`agent.provider.claude`,size:18}),description:`更适合长上下文梳理、方案分析和代码审查。`,className:`agent-provider-card-claude`},{id:`codex`,title:`Codex`,meta:`workspace`,icon:(0,X.jsx)($,{semantic:`agent.provider.codex`,size:18}),description:`更适合终端操作、直接改文件和逐步修复问题。`,className:`agent-provider-card-codex`}].map(e=>{let t=d[e.id],n=g(e.id),r=t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`;return(0,X.jsx)(Q,{className:`agent-provider-card ${e.className}`,disabled:_,leadingIcon:(0,X.jsx)(`span`,{className:`agent-provider-card-icon`,children:e.icon}),onClick:()=>{f(e.id)},trailingIcon:(0,X.jsx)(fi,{size:16,className:`agent-provider-card-arrow`}),variant:`secondary`,children:(0,X.jsxs)(`span`,{className:`agent-provider-card-body`,children:[(0,X.jsxs)(`span`,{className:`agent-provider-card-title-row`,children:[(0,X.jsx)(`span`,{className:`agent-provider-card-title`,children:e.title}),(0,X.jsx)(`span`,{className:`agent-provider-card-meta`,children:e.meta})]}),(0,X.jsx)(`span`,{className:`agent-provider-card-desc`,children:e.description}),(0,X.jsx)(`span`,{className:`agent-provider-card-cta`,children:h(e.id)}),r?(0,X.jsx)(`span`,{className:`agent-provider-card-status`,children:c(`provider.install.status.installing`)}):null,n.message?(0,X.jsxs)(`span`,{className:`agent-provider-card-guide`,children:[(0,X.jsx)(`span`,{children:n.message}),n.docUrl?(0,X.jsx)(`a`,{href:n.docUrl,onClick:e=>e.stopPropagation(),rel:`noreferrer`,target:`_blank`,children:c(`provider.install.open_docs`)}):null,(0,X.jsx)(`a`,{href:p(e.id),onClick:e=>e.stopPropagation(),children:c(`diagnostics.actions.open_diagnostics`)})]}):null]})},e.id)})})]})})]})},iS=({splitId:e,direction:t,ratio:n,children:r,onRatioCommit:i})=>{let[a,o]=(0,H.useState)(n),s=(0,H.useRef)(null),c=(0,H.useRef)(!1),l=(0,H.useRef)(n),u=(0,H.useCallback)(()=>{c.current=!0,l.current=a,document.body.classList.add(`is-resizing-panels`)},[a]),d=(0,H.useCallback)(e=>{if(!c.current||!s.current)return;let n=s.current.getBoundingClientRect(),r=t===`horizontal`?n.width:n.height,i=t===`horizontal`?e.clientX-n.left:e.clientY-n.top,a=Math.max(.1,Math.min(.9,i/r));o(a),l.current=a},[t]),f=(0,H.useCallback)(()=>{c.current&&(c.current=!1,document.body.classList.remove(`is-resizing-panels`),i?.(l.current))},[i]);(0,H.useEffect)(()=>(document.addEventListener(`mousemove`,d),document.addEventListener(`mouseup`,f),()=>{document.removeEventListener(`mousemove`,d),document.removeEventListener(`mouseup`,f)}),[d,f]),(0,H.useEffect)(()=>{o(n),l.current=n},[n,e]);let[p,m]=Array.isArray(r)?r:[r],h=t===`horizontal`?{gridTemplateColumns:`${a*100}% 0px ${(1-a)*100}%`}:{gridTemplateRows:`${a*100}% 0px ${(1-a)*100}%`},g=t===`horizontal`?`pane-layout-divider pane-layout-horizontal-divider`:`pane-layout-divider pane-layout-vertical-divider`;return(0,X.jsxs)(`div`,{ref:s,className:`pane-layout pane-layout-${t}`,style:{display:`grid`,...h},children:[(0,X.jsx)(`div`,{className:`pane-layout-child`,children:p}),(0,X.jsx)(`div`,{className:g,onMouseDown:u,role:`separator`,"aria-orientation":t===`horizontal`?`vertical`:`horizontal`}),(0,X.jsx)(`div`,{className:`pane-layout-child`,children:m})]})};function aS({title:e,meta:t,status:n,actions:r,metaPlacement:i=`stacked`,className:a}){let o=t?(0,X.jsx)(`div`,{className:`panel-header__meta${i===`inline`?` panel-header__meta--inline`:``}`,children:t}):null;return(0,X.jsxs)(`div`,{className:`panel-header${i===`inline`?` panel-header--inline-meta`:``}${a?` ${a}`:``}`,children:[(0,X.jsx)(`div`,{className:`panel-header__leading`,children:(0,X.jsxs)(`div`,{className:`panel-header__copy`,children:[(0,X.jsxs)(`div`,{className:`panel-header__title-row`,children:[n?(0,X.jsx)(`div`,{className:`panel-header__status`,children:n}):null,(0,X.jsx)(`div`,{className:`panel-header__title`,children:e}),i===`inline`?o:null]}),i===`stacked`?o:null]})}),r?(0,X.jsx)(`div`,{className:`panel-header__actions`,children:r}):null]})}var oS=V(new Map),sS=Ap(e=>V(!1)),cS=V({open:!1,sessionId:null,mode:`enable`,restoreStep:`form`,returnToDetails:!1,draftObjective:``,initialObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``,recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1}),lS=V({open:!1,sessionId:null});V(e=>t=>e(oS).get(t));function uS(e){let[t,n]=Te(lS);return{details:t,isVisible:t.open&&(!e||t.sessionId===e),openDetails:(0,H.useCallback)(e=>{n({open:!0,sessionId:e})},[n]),closeDetails:(0,H.useCallback)(()=>{n({open:!1,sessionId:null})},[n])}}var dS=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}],fS={open:!1,sessionId:null,mode:`enable`,restoreStep:`form`,returnToDetails:!1,draftObjective:``,initialObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``,recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1};function pS(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e),n=t.getTimezoneOffset();return new Date(t.getTime()-n*6e4).toISOString().slice(0,16)}function mS(e){let t=Number.parseInt(e,10);return!Number.isSafeInteger(t)||t<0?0:t}function hS(e){let t=(e??``).trim();if(!t)return!1;let n=Number(t);return Number.isSafeInteger(n)&&n>=0}function gS(e){if(!e.trim())return;let t=Date.parse(e);if(Number.isFinite(t))return t}function _S({workspaceId:e,sessionId:t}){let[n,r]=Te(cS),i=U(oS),a=U(Op),{openDetails:o}=uS(),s=Z(),c=t??n.sessionId,l=c?i.get(c):void 0,u=n.open&&(!t||n.sessionId===t),d=n.mode,f=n.restoreStep??`form`,p={title:s(f===`restore`?`supervisor.dialog.restore.title`:`supervisor.dialog.${d}.title`),subtitle:s(f===`restore`?`supervisor.dialog.restore.subtitle`:`supervisor.dialog.${d}.subtitle`),confirm:s(f===`restore`?`supervisor.dialog.restore.confirm`:`supervisor.dialog.${d}.confirm`)},m=hS(n.draftMaxSupervisionCount),h=n.selectedRecoverableTargetId??null,g=n.recoverableTargets??[],_=n.isRecoverableTargetsLoading??!1,v=n.draftObjective.trim(),y=v!==(n.initialObjective?.trim()??``),b=(n.draftEvaluatorModel??``).trim(),x=l?.evaluatorModel?.trim()??``,S=mS(n.draftMaxSupervisionCount??`0`),C=gS(n.draftScheduledAt??``)??null,w=l?.scheduledAt??null,T=!!(l&&(n.draftEvaluatorProviderId!==l.evaluatorProviderId||b!==x||S!==l.maxSupervisionCount||C!==w)),E=y||T,D=(0,H.useCallback)(()=>{let e=n.returnToDetails?n.sessionId:null;r(fS),e&&o(e)},[n.returnToDetails,n.sessionId,o,r]);return{dialog:n,supervisor:l,isVisible:u,mode:d,restoreStep:f,copy:p,isMaxSupervisionCountValid:m,recoverableTargets:g,selectedRecoverableTargetId:h,isRecoverableTargetsLoading:_,hasObjectiveChanged:y,hasSettingsChanged:T,hasChanges:E,close:D,updateDraft:(0,H.useCallback)(e=>{r(t=>({...t,...e}))},[r]),openRestoreStep:(0,H.useCallback)(async()=>{r(e=>({...e,restoreStep:`restore`,isRecoverableTargetsLoading:!0,recoverableTargets:[],selectedRecoverableTargetId:null}));let t=await a(`supervisor.listRecoverableTargets`,{workspaceId:e});r(e=>{if(e.sessionId!==c)return e;let n=(t.ok?t.data?.targets??[]:[]).filter(e=>e.targetId!==l?.targetId);return{...e,restoreStep:`restore`,isRecoverableTargetsLoading:!1,recoverableTargets:n,selectedRecoverableTargetId:null}})},[a,c,r,l?.targetId,e]),closeRestoreStep:(0,H.useCallback)(()=>{r(e=>({...e,restoreStep:`form`,isRecoverableTargetsLoading:!1,selectedRecoverableTargetId:null}))},[r]),selectRecoverableTarget:(0,H.useCallback)(e=>{r(t=>({...t,selectedRecoverableTargetId:e}))},[r]),confirm:(0,H.useCallback)(async()=>{if(!n.sessionId||!m)return!1;let t=n.draftEvaluatorModel.trim(),r=mS(n.draftMaxSupervisionCount),i=gS(n.draftScheduledAt);if(f===`restore`)return h&&(await a(`supervisor.restore`,{sessionId:n.sessionId,workspaceId:e,sourceTargetId:h,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:t||void 0,maxSupervisionCount:r,scheduledAt:i})).ok?(D(),!0):!1;let o=v;return o?n.mode===`enable`?(await a(`supervisor.create`,{sessionId:n.sessionId,workspaceId:e,objective:o,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:t||void 0,maxSupervisionCount:r,scheduledAt:i})).ok?(D(),!0):!1:l&&(await a(`supervisor.update`,{id:l.id,objective:o,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:t||null,maxSupervisionCount:r,scheduledAt:i??null})).ok?(D(),!0):!1:!1},[D,n,a,m,f,h,l,e]),formatScheduledAtInput:pS}}var vS=`__supervisor-empty__`;function yS(e){let t=e?.id??vS,n=ve(),r=U(xp),i=U(Op),a=W(cS),o=W(oS),s=W(sS(t));return(0,H.useEffect)(()=>{if(!e?.id)return;let t=sS(e.id);if(r!==`connected`){n.get(t)&&s(!1);return}if(e.capability!==`full`||e.state===`draft`||e.state===`ended`||n.get(t))return;s(!0);let a=!1;return i(`supervisor.get`,{sessionId:e.id}).then(t=>{if(a||!t.ok)return;let n=t.data?.supervisor??null;o(t=>{let r=new Map(t);return n?r.set(e.id,n):r.delete(e.id),r})}),()=>{a=!0}},[r,i,e,s,o,n]),{openDialog:(0,H.useCallback)((e,n)=>{a({open:!0,sessionId:t,mode:e,restoreStep:`form`,returnToDetails:e===`edit`,draftObjective:n?.objective??``,initialObjective:n?.objective??``,draftEvaluatorProviderId:n?.evaluatorProviderId??`claude`,draftEvaluatorModel:n?.evaluatorModel??``,draftMaxSupervisionCount:String(n?.maxSupervisionCount??0),draftScheduledAt:pS(n?.scheduledAt),recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1})},[t,a])}}var bS={inactive:`supervisor-state-inactive`,idle:`supervisor-state-idle`,evaluating:`supervisor-state-evaluating`,injecting:`supervisor-state-injecting`,paused:`supervisor-state-paused`,error:`supervisor-state-error`,stopped:`supervisor-state-stopped`};function xS({sessionId:e}){let t=U(oS),n=U(Op),r=W(cS),{openDetails:i}=uS(),a=Z(),o=t.get(e),[s,c]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(!s)return;let e=window.setTimeout(()=>c(null),6e3);return()=>window.clearTimeout(e)},[s]);let l=(0,H.useCallback)(t=>{r({open:!0,sessionId:e,mode:t,restoreStep:`form`,returnToDetails:t===`edit`,draftObjective:o?.objective??``,initialObjective:o?.objective??``,draftEvaluatorProviderId:o?.evaluatorProviderId??`claude`,draftEvaluatorModel:o?.evaluatorModel??``,draftMaxSupervisionCount:String(o?.maxSupervisionCount??0),draftScheduledAt:pS(o?.scheduledAt),recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1})},[e,r,o]),u=(0,H.useCallback)(async(e,t,r)=>{c(null);let i=await n(e,{id:t});i.ok||c(i.error?.message?`${r}: ${i.error.message}`:r)},[n]),d=(0,H.useCallback)(async()=>{o&&await u(`supervisor.pause`,o.id,a(`supervisor.action.pause_failed`))},[u,o,a]),f=(0,H.useCallback)(async()=>{o&&await u(`supervisor.resume`,o.id,a(`supervisor.action.resume_failed`))},[u,o,a]),p=(0,H.useCallback)(async()=>{o&&await u(`supervisor.trigger`,o.id,a(`supervisor.action.trigger_failed`))},[u,o,a]),m=o?.stopReason?a(`supervisor.stop_reason.${o.stopReason}`):null,h=o?.currentTargetMemory,g=h?.items.find(e=>e.id===h.activeItemId)??h?.items[0]??null,_=h?.decompositionMode?a(`supervisor.target_memory.decomposition_mode.${h.decompositionMode}`):null,v=h?h.decompositionGenerated?a(`supervisor.target_memory.decomposition_ready`):a(`supervisor.target_memory.decomposition_pending`):null,y=o?.recentTargetCycles?.[0]?.reason??null;return{activeItem:g,actionError:s,decompositionModeLabel:_,decompositionStatusLabel:v,handlePause:d,handleResume:f,handleTrigger:p,isBusy:o?.state===`evaluating`||o?.state===`injecting`,openDetails:()=>{o&&i(o.sessionId)},openDialog:l,recentReasoning:y,stopReasonLabel:m,stateClass:o?bS[o.state]:bS.inactive,stateLabel:a(`supervisor.state.${o?o.state:`inactive`}`),supervisor:o,targetMemory:h}}var SS=dS.map(e=>({value:e.id,label:e.label}));function CS({mode:e}){return e===`enable`?(0,X.jsx)($,{semantic:`supervisor.mode.enable`,size:14}):(0,X.jsx)($,{semantic:`supervisor.mode.edit`,size:14})}function wS({mode:e,showIntro:t=!1,restoreStep:n,draftObjective:r,draftEvaluatorProviderId:i,draftEvaluatorModel:a,draftMaxSupervisionCount:o,draftScheduledAt:s,isMaxSupervisionCountValid:c,recoverableTargets:l,selectedRecoverableTargetId:u,isRecoverableTargetsLoading:d,onDraftObjectiveChange:f,onDraftEvaluatorProviderChange:p,onDraftEvaluatorModelChange:m,onDraftMaxSupervisionCountChange:h,onDraftScheduledAtChange:g,onOpenRestoreStep:_,onCloseRestoreStep:v,onSelectRecoverableTarget:y}){let b=Z(),x=U(Za),S=(0,H.useId)(),C=(0,H.useId)(),w=(0,H.useId)(),T=(0,H.useId)(),E=(0,H.useId)(),D=(0,H.useId)(),O=b(`supervisor.dialog.${e}.title`),k=b(`supervisor.dialog.${e}.subtitle`);return n===`restore`?(0,X.jsxs)(`div`,{className:`supervisor-restore-view`,children:[(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro`,children:[(0,X.jsx)(`div`,{className:`supervisor-dialog-intro__icon`,"aria-hidden":`true`,children:(0,X.jsx)(CS,{mode:e})}),(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro__copy`,children:[(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__title`,children:b(`supervisor.dialog.restore.title`)}),(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__description`,children:b(`supervisor.dialog.restore.subtitle`)})]})]}),(0,X.jsx)(`div`,{className:`supervisor-restore-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`supervisor-restore-link`,onClick:v,children:b(`supervisor.dialog.restore.back`)})}),d?(0,X.jsx)(`div`,{className:`supervisor-restore-loading`,children:(0,X.jsx)(ig,{label:b(`common.loading`),size:`md`})}):l.length===0?(0,X.jsx)(Sh,{className:`supervisor-restore-empty`,title:b(`supervisor.dialog.restore.empty`),description:b(`supervisor.dialog.restore.empty_hint`)}):(0,X.jsx)(`div`,{className:`supervisor-restore-list`,role:`radiogroup`,children:l.map(e=>{let t=e.targetId===u;return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:`supervisor-restore-card${t?` supervisor-restore-card--selected`:``}`,onClick:()=>y(e.targetId),children:[(0,X.jsxs)(`span`,{className:`supervisor-restore-card__header`,children:[(0,X.jsx)(`span`,{className:`supervisor-restore-card__title`,children:e.objective}),(0,X.jsx)(`span`,{className:`supervisor-restore-card__meta`,children:b(`supervisor.dialog.restore.cycle_count`,{count:e.cycleCount})})]}),e.progressSummary?(0,X.jsx)(`span`,{className:`supervisor-restore-card__summary`,children:e.progressSummary}):null,(0,X.jsx)(`span`,{className:`supervisor-restore-card__footer`,children:b(`supervisor.dialog.restore.updated_at`,{time:dm(e.updatedAt,x,{year:`numeric`,month:`short`,day:`numeric`})})})]},e.targetId)})})]}):(0,X.jsxs)(X.Fragment,{children:[t?(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro`,children:[(0,X.jsx)(`div`,{className:`supervisor-dialog-intro__icon`,"aria-hidden":`true`,children:(0,X.jsx)(CS,{mode:e})}),(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro__copy`,children:[(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__title`,children:O}),(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__description`,children:k})]})]}):null,(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsxs)(`div`,{className:`supervisor-objective-label-row`,children:[(0,X.jsx)(`label`,{htmlFor:`objective`,children:b(`supervisor.field.objective`)}),(0,X.jsx)(`button`,{type:`button`,className:`supervisor-restore-link`,onClick:_,children:b(`supervisor.dialog.restore.open`)})]}),(0,X.jsx)(Cg,{id:`objective`,rows:5,value:r,onChange:e=>f(e.target.value),"aria-describedby":S,placeholder:b(`supervisor.field.objective_placeholder`),autoFocus:!0}),(0,X.jsx)(`span`,{id:S,className:`dialog-helper`,children:b(`supervisor.field.objective_helper`)}),(0,X.jsx)(`p`,{className:`supervisor-restore-entry__hint`,children:b(`supervisor.dialog.restore.hint`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{id:C,htmlFor:`evaluator-provider`,children:b(`supervisor.field.evaluator`)}),(0,X.jsx)(tg,{id:`evaluator-provider`,size:`sm`,desktopMode:`listbox`,mobileSheetTitle:b(`supervisor.field.evaluator`),mobileSheetPresentation:`inline`,options:SS,value:i,"aria-labelledby":C,"aria-describedby":w,onValueChange:p}),(0,X.jsx)(`span`,{id:w,className:`dialog-helper`,children:b(`supervisor.field.evaluator_helper`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`evaluator-model`,children:b(`supervisor.field.evaluator_model`)}),(0,X.jsx)(rh,{id:`evaluator-model`,size:`sm`,value:a,onChange:e=>m(e.target.value),"aria-describedby":T,placeholder:b(`supervisor.field.evaluator_model_placeholder`)}),(0,X.jsx)(`span`,{id:T,className:`dialog-helper`,children:b(`supervisor.field.evaluator_model_helper`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`max-supervision-count`,children:b(`supervisor.field.max_supervision_count`)}),(0,X.jsx)(rh,{id:`max-supervision-count`,size:`sm`,type:`number`,min:0,step:1,value:o,onChange:e=>h(e.target.value),invalid:!c,"aria-invalid":!c,"aria-describedby":E}),(0,X.jsx)(`span`,{id:E,className:`dialog-helper`,children:b(`supervisor.field.max_supervision_count_helper`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`scheduled-at`,children:b(`supervisor.field.scheduled_at`)}),(0,X.jsx)(gh,{label:b(`supervisor.field.scheduled_at`),size:`sm`,value:s,onValueChange:g,placeholder:b(`supervisor.field.scheduled_at_placeholder`),clearable:!0,minDate:new Date,"aria-describedby":D}),(0,X.jsx)(`span`,{id:D,className:`dialog-helper`,children:b(`supervisor.field.scheduled_at_helper`)})]})]})}function TS({workspaceId:e,sessionId:t}){let n=Br(),r=Z(),{dialog:i,isVisible:a,mode:o,restoreStep:s,copy:c,isMaxSupervisionCountValid:l,recoverableTargets:u,selectedRecoverableTargetId:d,isRecoverableTargetsLoading:f,hasObjectiveChanged:p,hasChanges:m,close:h,updateDraft:g,openRestoreStep:_,closeRestoreStep:v,selectRecoverableTarget:y,confirm:b}=_S({workspaceId:e,sessionId:t}),[x,S]=(0,H.useState)(!1);if(!a||n===`mobile`)return null;let C=s===`restore`,w=o===`edit`?!m||!i.draftObjective.trim()||!l:!i.draftObjective.trim()||!l;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(jm,{className:`supervisor-dialog supervisor-dialog--${o}`,onOpenChange:h,open:!0,children:[(0,X.jsxs)(Nm,{children:[(0,X.jsxs)(`div`,{className:`dialog-header__leading`,children:[(0,X.jsx)(`span`,{className:`dialog-header__icon supervisor-dialog-header-icon`,"aria-hidden":`true`,children:(0,X.jsx)(CS,{mode:o})}),(0,X.jsx)(`div`,{className:`dialog-header__copy`,children:(0,X.jsx)(Pm,{children:c.title})})]}),(0,X.jsx)(Em,{"aria-label":r(`action.close`),className:`modal-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:h,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsx)(wS,{mode:o,restoreStep:s,draftObjective:i.draftObjective,draftEvaluatorProviderId:i.draftEvaluatorProviderId,draftEvaluatorModel:i.draftEvaluatorModel,draftMaxSupervisionCount:i.draftMaxSupervisionCount,draftScheduledAt:i.draftScheduledAt,isMaxSupervisionCountValid:l,recoverableTargets:u,selectedRecoverableTargetId:d,isRecoverableTargetsLoading:f,onDraftObjectiveChange:e=>g({draftObjective:e}),onDraftEvaluatorProviderChange:e=>g({draftEvaluatorProviderId:e}),onDraftEvaluatorModelChange:e=>g({draftEvaluatorModel:e}),onDraftMaxSupervisionCountChange:e=>g({draftMaxSupervisionCount:e}),onDraftScheduledAtChange:e=>g({draftScheduledAt:e}),onOpenRestoreStep:()=>{_()},onCloseRestoreStep:v,onSelectRecoverableTarget:y})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:h,children:r(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{if(o===`edit`&&!C&&p){S(!0);return}b()},disabled:C?!d||f||!l:w,children:c.confirm})]})]}),(0,X.jsx)(Bm,{open:x,onOpenChange:S,title:r(`supervisor.dialog.edit.reset_confirm_title`),description:r(`supervisor.dialog.edit.reset_confirm_description`),cancelText:r(`action.cancel`),confirmText:r(`supervisor.dialog.edit.confirm`),tone:`danger`,onConfirm:()=>{S(!1),b()}})]})}function ES({sessionId:e,workspaceId:t,onEdit:n}){let r=Z(),{recentReasoning:i,supervisor:a,targetMemory:o}=xS({sessionId:e});if(!a)return null;let s=a.completedSupervisionCount,c=a.maxSupervisionCount>0?String(a.maxSupervisionCount):r(`supervisor.meta.no_cap`),l=a.recentTargetCycles?.find(e=>e.result===`error`)?.errorReason??a.errorReason??null,u=a.state===`error`?`error`:a.state===`evaluating`||a.state===`injecting`?`running`:`idle`;return(0,X.jsxs)(`div`,{className:`supervisor-details`,"aria-label":r(`supervisor.target_memory.title`),children:[(0,X.jsxs)(`section`,{className:`supervisor-details-section`,children:[(0,X.jsxs)(`div`,{className:`supervisor-details-section-header`,children:[(0,X.jsx)(`h3`,{className:`supervisor-details-section-title`,children:r(`supervisor.target_memory.basic_info_title`)}),(0,X.jsx)(Q,{className:`supervisor-details-edit-btn`,onClick:n,size:`sm`,variant:`ghost`,children:r(`supervisor.action.edit_objective`)})]}),(0,X.jsx)(`div`,{className:`supervisor-summary-card supervisor-details-surface`,children:(0,X.jsxs)(`div`,{className:`supervisor-meta-grid supervisor-meta-grid--stacked`,children:[(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.field.objective`)}),(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--wrap`,children:a.objective})]}),(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.field.evaluator`)}),(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--strong`,children:Hg(a.evaluatorProviderId)})]}),(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.cycles_title`)}),(0,X.jsxs)(`p`,{className:`supervisor-meta-value supervisor-meta-value--strong`,children:[s,` / `,c]})]}),(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.runtime_title`)}),(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--strong`,children:r(`supervisor.target_memory.runtime_status.${u}`)})]}),u===`error`&&l?(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.error_reason_label`)}),(0,X.jsx)(`div`,{className:`supervisor-error`,role:`alert`,children:l})]}):null]})})]}),i&&u!==`error`?(0,X.jsxs)(`section`,{className:`supervisor-details-section`,children:[(0,X.jsx)(`h3`,{className:`supervisor-details-section-title`,children:r(`supervisor.target_memory.reasoning_title`)}),(0,X.jsx)(`div`,{className:`supervisor-details-surface supervisor-details-surface--reasoning supervisor-meta-item--reasoning`,children:(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--wrap`,children:i})})]}):null,o?.items.length?(0,X.jsxs)(`section`,{className:`supervisor-details-section`,children:[(0,X.jsx)(`h3`,{className:`supervisor-details-section-title`,children:r(`supervisor.target_memory.progress_list_title`)}),(0,X.jsx)(`div`,{className:`supervisor-details-surface supervisor-details-surface--progress`,children:(0,X.jsx)(`div`,{className:`supervisor-progress-list supervisor-progress-list--checklist`,children:o.items.map(e=>{let t=e.id===o.activeItemId,n=e.status===`done`?`green`:e.status===`in_progress`?`blue`:`neutral`;return(0,X.jsxs)(`article`,{className:`supervisor-progress-item${t?` supervisor-progress-item--active`:``}`,children:[(0,X.jsx)(`div`,{className:`supervisor-progress-item__rail`,"aria-hidden":`true`,children:(0,X.jsx)(`span`,{className:`supervisor-progress-item__marker supervisor-progress-item__marker--${e.status}`})}),(0,X.jsxs)(`div`,{className:`supervisor-progress-item__body`,children:[(0,X.jsxs)(`div`,{className:`supervisor-progress-item__header`,children:[(0,X.jsx)(`p`,{className:`supervisor-progress-item__title`,children:e.title}),(0,X.jsx)(_g,{color:n,size:`sm`,caps:!1,children:r(`supervisor.target_memory.step_status.${e.status}`)})]}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-label`,children:r(`supervisor.target_memory.item_objective_title`)}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-value`,children:e.objective}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-label`,children:r(`supervisor.target_memory.item_deliverable_title`)}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-value`,children:e.deliverable})]})]},e.id)})})})]}):null]})}function DS({workspaceId:e,sessionId:t}){let n=Br(),r=Z(),{details:i,isVisible:a,closeDetails:o}=uS(t),{openDialog:s}=xS({sessionId:t??i.sessionId??``});return!a||n===`mobile`||!i.sessionId?null:(0,X.jsxs)(jm,{className:`supervisor-dialog supervisor-dialog--details`,onOpenChange:o,open:!0,children:[(0,X.jsxs)(Nm,{children:[(0,X.jsx)(`div`,{className:`dialog-header__leading`,children:(0,X.jsx)(`div`,{className:`dialog-header__copy`,children:(0,X.jsx)(Pm,{children:r(`supervisor.dialog.details.title`)})})}),(0,X.jsx)(Em,{"aria-label":r(`action.close`),className:`modal-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:o,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsx)(ES,{sessionId:i.sessionId,workspaceId:e,onEdit:()=>{o(),s(`edit`)}})})]})}function OS({sessionId:e,workspaceId:t}){let n=Z(),{handlePause:r,handleResume:i,handleTrigger:a,isBusy:o,openDetails:s,openDialog:c,stateClass:l,stateLabel:u,supervisor:d}=xS({sessionId:e});return d?(0,X.jsxs)(`div`,{className:`supervisor-card ${l}`,"data-workspace-id":t,children:[(0,X.jsxs)(`div`,{className:`supervisor-strip-row`,children:[(0,X.jsxs)(`span`,{className:`supervisor-strip-eyebrow`,children:[(0,X.jsx)(`span`,{className:`supervisor-pulse ${l}`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`supervisor-label`,children:n(`supervisor.title`)})]}),(0,X.jsxs)(`span`,{className:`supervisor-status-cluster`,children:[(0,X.jsx)(`span`,{className:`supervisor-state-tag ${l}`,children:u}),(0,X.jsx)(`span`,{className:`supervisor-cycle-count`,children:n(`supervisor.completed_cycles`,{count:String(d.completedSupervisionCount)})})]}),(0,X.jsxs)(`div`,{className:`supervisor-actions`,children:[(0,X.jsx)(Ig,{content:n(`supervisor.action.details`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.details`),className:`supervisor-icon-btn`,icon:(0,X.jsx)($,{semantic:`supervisor.action.details`,size:12}),onClick:s,size:`sm`})}),d.state===`paused`?(0,X.jsx)(Ig,{content:n(`supervisor.action.resume`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.resume`),className:`supervisor-icon-btn`,icon:(0,X.jsx)($,{semantic:`supervisor.action.resume`,size:12}),onClick:()=>{i()},size:`sm`})}):(0,X.jsx)(Ig,{content:n(`supervisor.action.pause`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.pause`),className:`supervisor-icon-btn`,icon:(0,X.jsx)($,{semantic:`supervisor.action.pause`,size:12}),onClick:()=>{r()},size:`sm`})}),(0,X.jsx)(Ig,{content:n(`supervisor.action.trigger`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.trigger`),className:`supervisor-icon-btn`,disabled:o,icon:(0,X.jsx)($,{semantic:`supervisor.action.trigger`,size:12}),onClick:()=>{a()},size:`sm`})})]})]}),(0,X.jsx)(DS,{workspaceId:t,sessionId:e}),(0,X.jsx)(TS,{workspaceId:t,sessionId:e})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`supervisor-card supervisor-card-inactive`,children:(0,X.jsx)(Ig,{content:n(`supervisor.action.enable`),children:(0,X.jsxs)(`button`,{className:`supervisor-enable-btn`,onClick:()=>c(`enable`),"aria-label":n(`supervisor.action.enable`),children:[(0,X.jsx)($,{semantic:`supervisor.entry`,size:13}),(0,X.jsx)(`span`,{children:n(`supervisor.title`)})]})})}),(0,X.jsx)(TS,{workspaceId:t,sessionId:e})]})}async function kS(e){let t;try{await navigator.clipboard.writeText(e);return}catch(e){t=e}if(typeof document>`u`||typeof document.execCommand!=`function`)throw t??Error(`Clipboard copy unavailable`);let n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,`true`),n.setAttribute(`aria-hidden`,`true`),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`0`,n.style.width=`1px`,n.style.height=`1px`,n.style.padding=`0`,n.style.border=`0`,n.style.opacity=`0`,n.style.pointerEvents=`none`,document.body.appendChild(n);try{if(n.focus(),n.select(),n.setSelectionRange(0,n.value.length),!document.execCommand(`copy`))throw t??Error(`Clipboard copy unavailable`)}finally{n.remove()}}var AS=Ap(e=>V({chunks:[],lastSeq:0})),jS=Ap(e=>V(null)),MS=Ap(e=>V([])),NS=Ap(e=>V(null));Ap(e=>V(t=>t(MS(e))));var PS=2,FS={focused:0,"visible-active":1,"visible-other":2,background:3};function IS(e,t){return FS[e]-FS[t]}function LS(e){let t=Math.max(1,e?.concurrency??PS),n=new Map,r=[],i=new Map,a=()=>{r.forEach((e,t)=>{for(let n of e.positionListeners)n(t)})},o=()=>{for(;n.size<t&&r.length>0;){let e=r.shift();if(!e)break;e.running=!0,n.set(e.terminalId,e),e.handle.isGranted=!0,e.grantedResolved||(e.grantedResolved=!0,e.resolveGranted())}a()},s=e=>{let t=r.findIndex(t=>t.terminalId===e);return t>=0?(r.splice(t,1),a(),!0):!1},c=e=>{let t=s(e.terminalId),r=n.delete(e.terminalId);!t&&!r||(i.delete(e.terminalId),r&&o())},l=(e,t)=>{if(e.tier=t,e.running)return;let n=r.findIndex(t=>t.terminalId===e.terminalId);if(n<0)return;r.splice(n,1);let i=r.findIndex(e=>IS(t,e.tier)<0);i<0&&(i=r.length),r.splice(i,0,e),o()},u=e=>{let t=r.findIndex(t=>IS(e.tier,t.tier)<0);t<0&&(t=r.length),r.splice(t,0,e),o()};return{request(e){let a=i.get(e.terminalId);if(a)return IS(e.tier,a.tier)<0&&l(a,e.tier),a.handle;let o=()=>{},s=new Promise(e=>{o=e}),d={};return d.terminalId=e.terminalId,d.tier=e.tier,d.granted=s,d.resolveGranted=o,d.grantedResolved=!1,d.running=!1,d.positionListeners=new Set,d.handle={granted:s,isGranted:!1,promote:e=>l(d,e),release:()=>c(d),subscribePosition:e=>{d.positionListeners.add(e);let t=r.findIndex(e=>e.terminalId===d.terminalId);return t>=0&&e(t),()=>{d.positionListeners.delete(e)}}},i.set(e.terminalId,d),n.size<t?(d.running=!0,n.set(d.terminalId,d),d.handle.isGranted=!0,d.grantedResolved=!0,d.resolveGranted()):u(d),d.handle},inspect(){return{running:Array.from(n.keys()),queued:r.map((e,t)=>({terminalId:e.terminalId,tier:e.tier,queuePosition:t}))}}}}var RS=LS();function zS(e,t){if(typeof e.getCell==`function`){let n=typeof e.length==`number`&&Number.isFinite(e.length)?Math.min(Math.max(e.length,0),t):t;for(let t=n-1;t>=0;--t){let n=e.getCell(t);if(!(!n||n.getChars()===``))return t+Math.max(n.getWidth(),1)}return 0}return e.translateToString(!0).length}function BS(e,t){let n=Array.from(e.children).filter(e=>e instanceof HTMLElement);for(let e=0;e<n.length;e+=1){let r=n[e].getBoundingClientRect();if(!(t<r.top||t>r.bottom))return e}return null}function VS(e,t,n,r,i){let a=e.getBoundingClientRect(),o=(t??e).getBoundingClientRect();if(r<a.left||r>a.right||i<a.top||i>a.bottom)return null;let s=BS(e,i);if(s===null)return null;let c=n.buffer.active.viewportY+s,l=n.buffer.active.getLine(c);if(!l||!Number.isFinite(n.cols)||n.cols<=0||o.width<=0||r<o.left||r>o.right)return null;let u=zS(l,n.cols);if(u===0)return c;let d=o.width/n.cols;if(d<=0)return null;let f=Math.floor((r-o.left)/d);return f<0||f>=n.cols||f>=u?null:c}function HS(e,t){let n=e.buffer.active,r=t,i=n.getLine(r);if(!i)return null;for(;i.isWrapped===!0;)if(--r,r<0||(i=n.getLine(r),!i))return null;let a=[i],o=r;for(;;){let e=n.getLine(o+1);if(!e||e.isWrapped!==!0)break;a.push(e),o+=1}return a.map((e,t)=>e.translateToString(t===a.length-1)).join(``)}function US(e){let t=VS(e.rowsElement,e.screenElement,e.terminal,e.clientX,e.clientY);return t===null?null:HS(e.terminal,t)}var WS=400,GS=[{id:`escape`,text:`Esc`},{id:`tab`,text:`Tab`},{id:`arrow_up`,text:`↑`},{id:`arrow_left`,text:`←`},{id:`arrow_down`,text:`↓`},{id:`arrow_right`,text:`→`},{id:`enter`,text:`Enter`}];function KS(e){(e.pointerType===`touch`||e.pointerType===`pen`)&&e.preventDefault()}function qS(e){return e.pointerType===`touch`||e.pointerType===`pen`}function JS(e,t){switch(e){case`escape`:return t.escape;case`tab`:return t.tab;case`enter`:return t.enter;case`arrow_up`:return t.up;case`arrow_down`:return t.down;case`arrow_left`:return t.left;case`arrow_right`:return t.right}}function YS({ctrlMode:e,shiftArmed:t,disabled:n=!1,labels:r,onKeyPress:i,onCtrlTap:a,onCtrlLongPress:o,onShiftTap:s,onPaste:c,onUpload:l}){let u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(!1),p=(0,H.useRef)(null),m=(0,H.useRef)(!1),h=(0,H.useRef)(null),g=n,_=()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},v=()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},y=()=>{m.current=!0,v(),d.current=setTimeout(()=>{m.current=!1,d.current=null},0)},b=()=>m.current?(m.current=!1,v(),!0):!1,x=()=>{h.current=null},S=(e,t)=>{qS(e)&&(h.current={pointerId:e.pointerId,target:t})},C=(e,t)=>{if(!qS(e))return`none`;let n=h.current;return!n||n.pointerId!==e.pointerId?`none`:(h.current=null,n.target===t?`matched`:`mismatched`)};(0,H.useEffect)(()=>{g&&(_(),v(),x(),f.current=!1,p.current=null,m.current=!1)},[g]),(0,H.useEffect)(()=>()=>{_(),v(),x()},[]);let w=()=>{g||(_(),f.current=!1,p.current=null,u.current=setTimeout(()=>{f.current=!0,p.current=`pointer`,o()},WS))},T=()=>{_(),f.current=!1,p.current=null,m.current=!1},E=()=>{g||_()},D=e=>{if(!g&&!b()){if(f.current){let t=p.current===`pointer`||p.current===`keyboard`&&e.detail===0;if(f.current=!1,p.current=null,t)return}a()}},O=e=>{let t=C(e,`ctrl`);if(E(),!(g||!qS(e)||t===`none`)&&(y(),t===`matched`)){if(f.current){f.current=!1,p.current=null;return}a()}},k=(e,t,n)=>{if(g||!qS(e))return;let r=C(e,t);r!==`none`&&(y(),r===`matched`&&n())},A=()=>{g||b()||s()},j=e=>{g||b()||i(e)},M=e=>{g||(e.key===`Enter`||e.key===` `)&&e.altKey&&(e.preventDefault(),_(),f.current=!0,p.current=`keyboard`,o())},N=e===`locked`?r.ctrlLocked:e===`armed`?r.ctrlArmed:r.ctrl,P=t?r.shiftArmed:r.shift;return(0,X.jsxs)(`div`,{className:`mobile-terminal-input-bar`,"data-expanded":`true`,"data-disabled":n?`true`:`false`,children:[(0,X.jsxs)(`div`,{className:`mobile-terminal-input-bar__actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.paste,disabled:g,onClick:()=>{g||c()},children:r.paste}),(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.upload,disabled:g,onClick:()=>{g||l()},children:r.upload})]}),(0,X.jsxs)(`div`,{className:`mobile-terminal-input-bar__keys`,role:`group`,"aria-label":r.shortcuts,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key mobile-terminal-input-bar__ctrl`,"data-ctrl-mode":e,"aria-pressed":e!==`off`,"aria-label":N,"aria-keyshortcuts":`Alt+Enter Alt+Space`,disabled:g,onPointerDown:e=>{KS(e),S(e,`ctrl`),w()},onPointerUp:O,onPointerCancel:()=>{x(),T()},onPointerLeave:()=>{x(),T()},onClick:D,onKeyDown:M,children:`Ctrl`}),(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key mobile-terminal-input-bar__shift`,"data-shift-armed":t?`true`:`false`,"aria-pressed":t,"aria-label":P,disabled:g,onPointerDown:e=>{KS(e),S(e,`shift`)},onPointerUp:e=>{k(e,`shift`,s)},onPointerCancel:x,onClick:A,children:`Shift`}),GS.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key`,"aria-label":JS(e.id,r),disabled:g,onPointerDown:t=>{KS(t),S(t,e.id)},onPointerUp:t=>{k(t,e.id,()=>i(e.id))},onPointerCancel:x,onClick:()=>j(e.id),children:e.text},e.id))]})]})}var XS={escape:`\x1B`,tab:` `,enter:`\r`,arrow_up:`\x1B[A`,arrow_down:`\x1B[B`,arrow_left:`\x1B[D`,arrow_right:`\x1B[C`},ZS={tab:`\x1B[Z`,arrow_up:`\x1B[1;2A`,arrow_down:`\x1B[1;2B`,arrow_left:`\x1B[1;2D`,arrow_right:`\x1B[1;2C`},QS=`control`;function $S(e,t){return t?.shift?ZS[e]??XS[e]:XS[e]}function eC(e){return e===`off`?`armed`:`off`}function tC(){return`locked`}function nC(e,t){if(t===`off`)return{data:e,nextCtrlMode:`off`};if(!/^[A-Za-z]$/.test(e))return{data:e,nextCtrlMode:t};let n=e.toUpperCase();return{data:String.fromCharCode(n.charCodeAt(0)-64),nextCtrlMode:t===`armed`?`off`:`locked`,activity:QS}}var rC=null;function iC(e){rC!==e&&(rC?.dispose(),rC=e)}function aC(){return rC}function oC(){iC(null)}var sC=12e4;function cC(e){return e instanceof Error&&e.message.includes(`Command timeout: terminal.replay`)||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`&&String(e.message).includes(`Command timeout: terminal.replay`)?`timeout`:`failed`}var lC=`application/x-coder-studio-workspace-path`;function uC(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.workspaceId==`string`&&t.workspaceId.length>0&&typeof t.path==`string`&&t.path.length>0&&(t.kind===`file`||t.kind===`dir`)}function dC(e){return Array.from(e?.types??[]).includes(lC)}function fC(e,t){e.effectAllowed=`copy`,e.setData(lC,JSON.stringify(t)),e.setData(`text/plain`,t.path)}function pC(e){if(!dC(e))return null;try{let t=e?.getData(`application/x-coder-studio-workspace-path`)??``,n=JSON.parse(t);return uC(n)?n:null}catch{return null}}function mC(e){return`'${e.replace(/'/g,`'\\''`)}'`}var hC=class extends Error{constructor(e,t,n){super(n??e),this.code=e,this.status=t,this.name=`UploadError`}};async function gC(e){let t=new FormData;t.append(`workspaceId`,e.workspaceId);for(let n of e.files)t.append(`files`,n,n.name);let n;try{n=await fetch(`/api/uploads`,{method:`POST`,body:t,credentials:`include`})}catch(e){throw new hC(`network_error`,0,e.message)}let r;try{r=await n.json()}catch{r={}}if(!n.ok||!r.ok)throw new hC(r.error??`http_${n.status}`,n.status);return r.files??[]}async function _C(e){let t=e.types.find(e=>e.startsWith(`image/`));if(!t)return null;let n=await e.getType(t),r=t.split(`/`)[1]??`png`;return new File([n],`clipboard.${r}`,{type:t})}function vC(e){let{containerRef:t,workspaceId:n,sendTextToTerminal:r,enabled:i}=e,[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(0),c=(0,H.useRef)(0),l=(0,H.useRef)(0),u=(0,H.useRef)(new Map),d=(0,H.useRef)(Promise.resolve()),f=W(sy),p=(0,H.useCallback)(async(e,t)=>{u.current.set(e,t),d.current=d.current.then(async()=>{for(;u.current.has(l.current);){let e=l.current,t=u.current.get(e)??null;u.current.delete(e),l.current+=1,t&&await r(t)}}),await d.current},[r]),m=(0,H.useCallback)(async(e,t)=>{let{trackBusy:n=!0,onError:r}=t??{},i=c.current;c.current+=1,n&&(s.current+=1,o(!0));try{await p(i,await e())}catch(e){if(await p(i,null),r){r(e);return}f({kind:`error`,title:`Upload failed`,body:`Could not upload file(s): ${e instanceof hC?e.code:`unknown`}`,duration:5e3})}finally{n&&(s.current=Math.max(0,s.current-1),o(s.current>0))}},[f,p]),h=(0,H.useCallback)(async e=>{e.length!==0&&await m(async()=>{let t=await gC({workspaceId:n,files:e});return t.length===0?null:`${t.map(e=>mC(e.path)).join(` `)} `})},[m,n]),g=(0,H.useCallback)(async e=>{e&&await m(async()=>e,{trackBusy:!1,onError:e=>{throw e}})},[m]),_=(0,H.useCallback)(async e=>{let t=pC(e);if(!t){f({kind:`error`,title:`Drop failed`,body:`Could not read the dragged workspace path.`,duration:3e3});return}if(t.workspaceId!==n){f({kind:`error`,title:`Drop failed`,body:`You can only drop paths from the current workspace.`,duration:3e3});return}await m(async()=>`${mC(t.path)} `,{trackBusy:!1,onError:e=>{console.debug(`Workspace path drop failed:`,e),f({kind:`error`,title:`Drop failed`,body:`Could not insert the dragged path into the terminal.`,duration:3e3})}})},[f,m,n]),v=(0,H.useCallback)(async()=>{if(!i)return;let e=navigator.clipboard;if(!e)throw Error(`Clipboard API not available`);try{let t=e.read;if(typeof t==`function`){let n=await t.call(e),r=[];for(let e of n){let t=await _C(e);t&&r.push(t)}if(r.length>0){await h(r);return}}}catch(e){console.debug(`Clipboard image read failed, trying text:`,e)}try{let t=e.readText?.bind(e);if(!t)throw Error(`Clipboard text read not available`);let n=await t();if(!n){f({kind:`info`,title:`Paste`,body:`Clipboard is empty`,duration:2e3});return}await g(n)}catch(e){throw f({kind:`error`,title:`Paste failed`,body:`Could not read from clipboard. Please check permissions.`,duration:3e3}),e}},[i,h,g,f]);return(0,H.useEffect)(()=>{let e=t.current;if(!e||!i)return;let n=e=>{let t=e.clipboardData?.files;!t||t.length===0||(e.preventDefault(),e.stopPropagation(),h(Array.from(t)))},r=e=>{let t=e.dataTransfer?.files;if(t&&t.length>0){e.preventDefault(),e.stopPropagation(),h(Array.from(t));return}dC(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),_(e.dataTransfer))},a=e=>{if(dC(e.dataTransfer)){e.preventDefault();return}Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&e.preventDefault()};return e.addEventListener(`paste`,n,{capture:!0}),e.addEventListener(`drop`,r,{capture:!0}),e.addEventListener(`dragover`,a,{capture:!0}),()=>{e.removeEventListener(`paste`,n,{capture:!0}),e.removeEventListener(`drop`,r,{capture:!0}),e.removeEventListener(`dragover`,a,{capture:!0})}},[t,i,h,_]),{busy:a,handleClipboardPaste:v,handleFiles:h}}var yC=({state:e,queuePosition:t})=>{let n=Z(),r=e===`granting`?n(`terminal.replay.loading_title`):t===0?n(`terminal.replay.up_next`):n(`terminal.replay.queued_title`,{count:t??0});return(0,X.jsxs)(Dh,{className:`xterm-replay-overlay xterm-replay-overlay--placeholder`,interactive:!1,mode:`status`,open:!0,surfaceClassName:`xterm-replay-overlay__card`,children:[e===`granting`?(0,X.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,X.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:r})]})},bC=16,xC=80,SC=.12,CC=.02,wC=.92,TC=16,EC=500,DC=10,OC=new Set([`\x1B[I`,`\x1B[O`]),kC=3e3,AC=1200;function jC(e){return/^\x1b\[\d+;\d+R$/.test(e)||/^\x1b\[(?:\?|>)(?:\d+;)*\d*c$/.test(e)}function MC(e){return OC.has(e)?`system`:e.includes(`\r`)||e.includes(`
|
|
107
|
-
`)?`submit`:`typing`}function
|
|
108
|
-
`){i=r.length>0?r:i,r=``;continue}n>=` `&&(r+=n)}return{nextDraft:r,submittedText:i}}function FC(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n)&255;return t}function IC(e,t){return e?`item`in e&&typeof e.item==`function`?e.item(t):e[t]??null:null}function LC(e,t){if(t===null||!e)return null;for(let n=0;n<e.length;n+=1){let r=IC(e,n);if(r?.identifier===t)return r}return null}function RC(e,t){if(e.rows>0){let n=e.element?.querySelector(`.xterm-screen`),r=n instanceof HTMLElement?n.getBoundingClientRect().height:t.getBoundingClientRect().height;if(r>0)return r/e.rows}return bC}function zC(e){return e.type!==`keydown`||e.shiftKey||e.altKey?!1:(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`}var BC=new TextEncoder,VC=new TextDecoder(`utf-8`,{fatal:!1}),HC=`coderStudio.terminalTrace`;function UC(){try{return globalThis.localStorage?.getItem(HC)===`1`}catch{return!1}}function WC(){if(typeof document>`u`)return Promise.resolve();let e=document.fonts;return e?.ready?e.ready.then(()=>void 0,()=>void 0):Promise.resolve()}function GC(e,t){return e.split(t).length-1}function KC(e){let t=typeof e==`string`?e:VC.decode(e);return{length:typeof e==`string`?e.length:e.byteLength,syncStart:GC(t,`\x1B[?2026h`),syncEnd:GC(t,`\x1B[?2026l`),clearToEnd:GC(t,`\x1B[J`),clearScreen:GC(t,`\x1B[2J`),eraseLine:GC(t,`\x1B[K`),cursorHome:GC(t,`\x1B[1;1H`),dsr:GC(t,`\x1B[6n`),da:GC(t,`\x1B[c`),reverseIndex:GC(t,`\x1BM`),cursorMoves:t.match(/\x1b\[[0-9;]*[Hf]/g)?.length??0,scrollRegions:t.match(/\x1b\[[0-9;]*r/g)?.slice(0,6)??[]}}function qC(e,t,n={}){UC()&&console.debug(`[terminal-trace]`,{at:Math.round(performance.now()*100)/100,terminalId:e,event:t,...n})}function JC(e,t){let n=Math.min(t,e.chunks.length);return n===0?e:{...e,chunks:e.chunks.slice(n)}}function YC(e){return{...Oa(e).terminalTheme,background:`#00000000`}}function XC(e){return Oa(e).terminalTheme}function ZC(e){let t=e.trim();if(!t.startsWith(`#`))return null;let n=t.slice(1),r;if(n.length===3||n.length===4)r=n.slice(0,3).split(``).map(e=>`${e}${e}`).join(``);else if(n.length===6||n.length===8)r=n.slice(0,6);else return null;return/^[\da-f]{6}$/iu.test(r)?[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16)]:null}function QC(e,t){let n=ZC(t);if(!n)return null;let r=e=>e.toString(16).padStart(2,`0`).repeat(2);return`\x1b]${e};rgb:${r(n[0])}/${r(n[1])}/${r(n[2])}\x1b\\`}function $C(e){let t=e.trim();if(!t)return null;let n=t.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:\d*\.?\d+))?\s*\)$/iu);return n?[Math.min(255,Number.parseInt(n[1]??`0`,10)),Math.min(255,Number.parseInt(n[2]??`0`,10)),Math.min(255,Number.parseInt(n[3]??`0`,10))]:ZC(t)}function ew(e,t){let n=Math.min(Math.max(t,0),1);return n>=.999?`rgb(${e[0]}, ${e[1]}, ${e[2]})`:`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${Math.round(n*1e3)/1e3})`}function tw(e){return!Array.from(e.classList).some(e=>e===`xterm-cursor`||e.startsWith(`xterm-cursor-`))}function nw(e){return e.style.backgroundColor.trim()||(!Array.from(e.classList).some(e=>e.startsWith(`xterm-bg-`))||typeof window>`u`?null:window.getComputedStyle(e).backgroundColor.trim()||null)}function rw(e,t,n){if(!e)return;let r=e.querySelector(`.xterm-rows`);if(!(r instanceof HTMLElement))return;let i=Array.from(r.children);if(i.length===0)return;let a=Math.max(0,n?.start??0),o=Math.min(i.length-1,n?.end??i.length-1);for(let e=a;e<=o;e+=1){let n=i[e];if(!(n instanceof HTMLElement))continue;let r=n.querySelectorAll(`span`);for(let e of r){if(!(e instanceof HTMLSpanElement)||!tw(e))continue;let n=nw(e);if(!n)continue;let r=$C(n);r&&(e.style.backgroundColor=ew(r,t))}}}function iw({closedSessionContinueLabel:e,closedSessionProviderLabel:t,onClosedSessionClose:n,onClosedSessionContinue:r,terminalId:i,workspaceId:a,readOnly:o=!1,isActiveSession:s=!1,terminalKind:c}){let l=Z(),u=Br(),d=U(Xa),f=U(io),p=U(By),m=Ly(p,u),h=U(bp),v=U(Op),y=W(sy),b=W(jS(i)),[x,S]=Te(AS(i)),C=U(jS(i)),w=(0,H.useRef)(C),T=c??C?.kind??`shell`,E=!o&&C?.alive!==!1,D=(0,H.useRef)(null),O=(0,H.useRef)(null),k=(0,H.useRef)(null),A=(0,H.useRef)(null),j=(0,H.useRef)(null),M=(0,H.useRef)(!1),N=(0,H.useRef)([]),P=(0,H.useRef)(null),F=(0,H.useRef)(!0),ee=(0,H.useRef)(null),I=(0,H.useRef)([]),L=(0,H.useRef)(!1),R=(0,H.useRef)(0),z=(0,H.useRef)(null),te=(0,H.useRef)(null),ne=(0,H.useRef)(null),re=(0,H.useRef)(null),ie=(0,H.useRef)(null),ae=(0,H.useRef)(null),B=(0,H.useRef)(null),oe=(0,H.useRef)(null),se=(0,H.useRef)(!1),ce=(0,H.useRef)(`idle`),V=(0,H.useRef)(null),le=(0,H.useRef)(0),ue=(0,H.useRef)(null),de=(0,H.useRef)(0),fe=(0,H.useRef)(0),pe=(0,H.useRef)(d),me=(0,H.useRef)(``),he=(0,H.useRef)(0),ge=(0,H.useRef)(null),_e=(0,H.useRef)(!1),ve=(0,H.useRef)(null),ye=(0,H.useRef)(``),be=(0,H.useRef)(0),xe=(0,H.useRef)(null),Se=(0,H.useRef)(()=>{}),Ce=(0,H.useRef)(()=>{}),we=(0,H.useRef)({activeTouchId:null,lastClientY:0,carryPx:0,pxPerLine:null,velocityPxPerMs:0,lastMomentumFrameAt:0,momentumFrameId:null,gestureDidScroll:!1,samples:[]}),[Ee,De]=(0,H.useState)({kind:`loading`}),[Oe,ke]=(0,H.useState)(!1),Ae=E&&Ee.kind!==`closed`&&Ee.kind!==`unavailable`,je=(0,H.useRef)(`blocking_rebuild`),[Me,Ne]=(0,H.useState)(u===`mobile`?{kind:`granted`}:{kind:`idle`}),[Pe,Fe]=(0,H.useState)(`off`),[Ie,Le]=(0,H.useState)(!1),Re=(0,H.useRef)(`off`),ze=(0,H.useRef)(!1),[Be,Ve]=(0,H.useState)(()=>!h||typeof h.getStatus!=`function`?`disconnected`:h.getStatus()),He=YC(d),Ue=Ha(f,u),We=d===`hc-dark`||d===`hc-light`?1:Math.min(Math.max(Ue.surfaceOpacity,0),100)/100,Ge=(0,H.useRef)(We),Ke=(0,H.useRef)(()=>{}),qe=(0,H.useRef)(()=>{}),Je=(0,H.useRef)(()=>{}),Ye=aC();(0,H.useEffect)(()=>{w.current=C},[C]);let Xe=(0,H.useCallback)(e=>{w.current?.alive!==!1&&(b(t=>t&&{...t,alive:!1,exitCode:e}),O.current&&O.current.writeln(`\r\n[Process exited with code ${e??0}]`))},[b]);(0,H.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]),(0,H.useEffect)(()=>{pe.current=d},[d]),(0,H.useLayoutEffect)(()=>{if(u===`mobile`){Ne({kind:`granted`}),_e.current=!0,ge.current=null;return}_e.current=!1;let e=C?.alive===!1?`background`:s?`visible-active`:`visible-other`,t=RS.request({terminalId:i,tier:e});ge.current=t,Ne(t.isGranted?{kind:`granted`}:{kind:`idle`});let n=!1,r=t.subscribePosition(e=>{n||Ne({kind:`queued`,queuePosition:e})});return t.isGranted||t.granted.then(()=>{n||Ne({kind:`granted`})}),()=>{n=!0,r(),_e.current||=(t.release(),!0),ge.current=null}},[i,u]),(0,H.useEffect)(()=>{if(u===`mobile`)return;let e=C?.alive===!1?`background`:s?`visible-active`:`visible-other`;ge.current?.promote(e)},[s,C?.alive,u]),(0,H.useEffect)(()=>{O.current&&(O.current.options.theme=He)},[He]),(0,H.useEffect)(()=>{Ge.current=We,rw(D.current,We)},[We]),(0,H.useEffect)(()=>{if(Ee.kind!==`loading`){ke(!1);return}ke(!1);let e=setTimeout(()=>{ke(!0)},AC);return()=>{clearTimeout(e)}},[Ee]),(0,H.useEffect)(()=>{let e=D.current;if(!e||typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(pointer: coarse)`).matches)return;let t=we.current,n=null,r=null,i=0,a=0,o=null,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null),r=null,i=0,a=0,o=null,s=!1},l=()=>{t.momentumFrameId!==null&&(cancelAnimationFrame(t.momentumFrameId),t.momentumFrameId=null),t.velocityPxPerMs=0,t.lastMomentumFrameAt=0},d=(e,n)=>{t.samples.push({clientY:e,at:n});let r=n-xC;for(;t.samples.length>0&&t.samples[0].at<r;)t.samples.shift()},f=()=>{if(t.samples.length<2){t.velocityPxPerMs=0;return}let e=t.samples[0],n=t.samples[t.samples.length-1],r=n.at-e.at;if(r<=0){t.velocityPxPerMs=0;return}t.velocityPxPerMs=(e.clientY-n.clientY)/r},m=(n,r)=>{let i=n.buffer.active.baseY;if(i<=0)return t.carryPx=0,`blocked`;t.carryPx+=r;let a=t.pxPerLine??=RC(n,e),o=t.carryPx>0?Math.floor(t.carryPx/a):Math.ceil(t.carryPx/a);if(o===0)return`buffered`;let s=n.buffer.active.viewportY,c=i-s,l=o>0?Math.min(o,c):Math.max(o,-s);return l===0?(t.carryPx=0,`blocked`):(n.scrollLines(l),t.carryPx-=l*a,`scrolled`)},h=e=>{if(t.momentumFrameId===null)return;let n=O.current;if(!n){l();return}let r=t.lastMomentumFrameAt>0?t.lastMomentumFrameAt:e-TC,i=Math.max(1,Math.min(64,e-r));t.lastMomentumFrameAt=e;let a=m(n,t.velocityPxPerMs*i),o=wC**+(i/TC);if(t.velocityPxPerMs*=o,a===`blocked`||Math.abs(t.velocityPxPerMs)<=CC){t.carryPx=0,l(),t.pxPerLine=null;return}t.momentumFrameId=requestAnimationFrame(h)},g=()=>{c(),l(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.gestureDidScroll=!1,t.samples=[]};Ce.current=g;let _=c=>{if(c.touches.length!==1){g();return}let f=IC(c.touches,0);if(!f){g();return}if(l(),t.activeTouchId=f.identifier,t.lastClientY=f.clientY,t.carryPx=0,t.pxPerLine=O.current?RC(O.current,e):bC,t.gestureDidScroll=!1,t.samples=[],d(f.clientY,performance.now()),u===`mobile`&&p.copyOnSelect){r=f.identifier,i=f.clientX,a=f.clientY;let t=O.current,c=e.querySelector(`.xterm-rows`),l=e.querySelector(`.xterm-screen`);s=!1,o=t&&c instanceof HTMLElement?US({clientX:f.clientX,clientY:f.clientY,rowsElement:c,screenElement:l instanceof HTMLElement?l:void 0,terminal:t}):null,n=setTimeout(()=>{n=null,s=!0},EC)}},v=e=>{let n=LC(e.changedTouches,t.activeTouchId),o=O.current;if(!n||!o)return;if(r===n.identifier)if(Math.abs(n.clientX-i)>DC||Math.abs(n.clientY-a)>DC)c();else return;if(o.buffer.active.baseY<=0){t.lastClientY=n.clientY,t.carryPx=0,t.gestureDidScroll=!1,t.samples=[],t.velocityPxPerMs=0;return}t.gestureDidScroll=!0;let s=t.lastClientY-n.clientY;t.lastClientY=n.clientY,d(n.clientY,performance.now()),f();let l=m(o,s);(l===`buffered`||l===`scrolled`)&&e.cancelable&&e.preventDefault()},y=e=>{if(LC(e.changedTouches,r)){if(s){let e=o;c(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0,t.gestureDidScroll=!1,t.samples=[],Se.current(e);return}c()}if(LC(e.changedTouches,t.activeTouchId)){let n=t.gestureDidScroll,r=LC(e.changedTouches,t.activeTouchId);if(r&&n&&(d(r.clientY,performance.now()),f()),t.activeTouchId=null,t.lastClientY=0,t.gestureDidScroll=!1,t.samples=[],n&&Math.abs(t.velocityPxPerMs)>=SC){t.lastMomentumFrameAt=0,t.momentumFrameId=requestAnimationFrame(h);return}t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0}},b=()=>{g()};return e.addEventListener(`touchstart`,_,{passive:!0}),e.addEventListener(`touchmove`,v,{passive:!1}),e.addEventListener(`touchend`,y,{passive:!0}),e.addEventListener(`touchcancel`,b,{passive:!0}),()=>{e.removeEventListener(`touchstart`,_),e.removeEventListener(`touchmove`,v),e.removeEventListener(`touchend`,y),e.removeEventListener(`touchcancel`,b),Ce.current=()=>{},g()}},[p.copyOnSelect,u]);let Ze=(0,H.useCallback)(()=>{j.current!==null&&cancelAnimationFrame(j.current),j.current=requestAnimationFrame(()=>{j.current=null;try{let e=O.current?{cols:O.current.cols,rows:O.current.rows}:null;k.current?.fit(),qC(i,`fit`,{before:e,after:O.current?{cols:O.current.cols,rows:O.current.rows}:null})}catch(e){console.error(`Failed to fit xterm instance:`,e)}finally{let e=N.current;N.current=[];for(let t of e)t()}})},[i]),Qe=(0,H.useCallback)(()=>new Promise(e=>{N.current.push(e)}),[]);(0,H.useEffect)(()=>{!O.current||O.current.options.fontSize===m||(O.current.options.fontSize=m,Ze())},[Ze,m]);let $e=(0,H.useCallback)(e=>{Re.current=e,Fe(e)},[]),et=(0,H.useCallback)(e=>{ze.current=e,Le(e)},[]),tt=(0,H.useCallback)(()=>{let e=Date.now();e-be.current<kC||(be.current=e,y({kind:`error`,title:l(u===`mobile`?`terminal.mobile_copy_current_line_failed_title`:`settings.copy_on_select_failed_title`),body:l(u===`mobile`?`terminal.mobile_copy_current_line_failed_body`:`settings.copy_on_select_failed_body`)}))},[y,l,u]),nt=(0,H.useCallback)(async e=>{if(!(u!==`mobile`||!p.copyOnSelect)&&(Ce.current(),e!==null))try{await kS(e),y({kind:`success`,title:l(`terminal.copied_current_line`)}),typeof navigator<`u`&&typeof navigator.vibrate==`function`&&navigator.vibrate(10)}catch{tt()}},[tt,y,l,p.copyOnSelect,u]);(0,H.useEffect)(()=>{Se.current=e=>{nt(e)}},[nt]),(0,H.useLayoutEffect)(()=>{Ce.current()},[i,a]);let rt=(0,H.useCallback)(async()=>{if(u===`mobile`||!p.copyOnSelect)return;let e=O.current;if(!e?.hasSelection())return;let t=ye.current||e.getSelection();if(t)try{await kS(t)}catch{tt()}},[tt,p.copyOnSelect,u]),it=(0,H.useCallback)(async(e,t,n)=>{if(F.current){if(!h){console.error(`Cannot send terminal input: WebSocket not connected`);return}await h.sendTerminalInput(i,e,t,n)}},[i,h]),at=(0,H.useCallback)(async(e,t)=>{if(de.current>0&&jC(e)){qC(i,`input.suppressed-replay-response`,{summary:KC(e)});return}let n=he.current+1;he.current=n;let r=Re.current,a=me.current,o=nC(e,r),s=o.activity??t??MC(o.data),{nextDraft:c,submittedText:l}=PC(a,o.data,s);try{o.nextCtrlMode!==r&&$e(o.nextCtrlMode),qC(i,`input`,{activity:s,summary:KC(o.data)}),me.current=c,await it(BC.encode(o.data),s,l)}catch(e){he.current===n&&(me.current=a,o.nextCtrlMode!==r&&Re.current===o.nextCtrlMode&&$e(r)),console.error(`Failed to send terminal input:`,e)}},[it,i,$e]),ot=(0,H.useCallback)(async e=>{let t=FC(e);qC(i,`input.binary`,{activity:`control`,summary:KC(t)});try{await it(t,`control`)}catch(e){console.error(`Failed to send terminal input:`,e)}},[it,i]),st=(0,H.useCallback)(async({cols:e,rows:t})=>{if(!F.current)return;let n=ee.current;if(n&&n.cols===e&&n.rows===t)return;ee.current={cols:e,rows:t},qC(i,`resize.dispatch`,{previousSize:n,nextSize:{cols:e,rows:t}});let r=await v(`terminal.resize`,{terminalId:i,cols:e,rows:t});r.ok||console.error(`Failed to sync terminal size:`,r.error),qC(i,`resize.result`,{nextSize:{cols:e,rows:t},ok:r.ok,error:r.ok?void 0:r.error})},[i,v]),ct=(0,H.useCallback)(async e=>{await at(e)},[at]),{busy:lt,handleClipboardPaste:ut,handleFiles:dt}=vC({containerRef:D,workspaceId:a,sendTextToTerminal:ct,enabled:Ae});(0,H.useEffect)(()=>{F.current=Ae,O.current&&(O.current.options.disableStdin=!Ae||lt,O.current.options.cursorBlink=Ae&&!lt)},[Ae,lt]),(0,H.useEffect)(()=>{if(!h){Ve(`disconnected`);return}if(typeof h.getStatus==`function`?Ve(h.getStatus()):Ve(`connected`),typeof h.onStatus==`function`)return h.onStatus(e=>{Ve(e)})},[h]),(0,H.useEffect)(()=>{if(Ye)return Ye.registerTerminal({terminalId:i,workspaceId:a,getRenderedSeq:()=>z.current??le.current,setUiMode:(e,t)=>{if(je.current=e,e===`silent`){z.current=null,De({kind:`ready`});return}if(e===`closed`){z.current=null,De({kind:`closed`});return}if(e===`error`){if(t?.reason===`too_old_no_snapshot`){if(ae.current){ae.current();return}z.current=null,De({kind:`unrecoverable_history`,reason:`too_old_no_snapshot`});return}if(t?.reason===`unknown_terminal`){if(B.current){B.current();return}z.current=null,De({kind:`unavailable`});return}if(ie.current){ie.current(Error(`terminal recovery failed`));return}De({kind:`retryable_failure`,reason:`failed`});return}(e===`non_blocking_recovering`||e===`blocking_rebuild`)&&z.current===null&&(z.current=le.current),De({kind:`loading`})},markClosed:({exitCode:e})=>{Xe(e)},completeRecovery:async(e,t)=>{await re.current?.(e,t)},applyReplay:async e=>{await te.current?.(e)},applySnapshot:async e=>{await ne.current?.(e)}})},[Xe,Ye,i,a]),(0,H.useLayoutEffect)(()=>{$e(`off`),et(!1),me.current=``,he.current+=1},[i,$e,et]),(0,H.useEffect)(()=>{Ke.current=at},[at]),(0,H.useEffect)(()=>{qe.current=ot},[ot]),(0,H.useEffect)(()=>{Je.current=st},[st]),(0,H.useEffect)(()=>{if(u!==`mobile`&&Me.kind!==`granted`||!D.current)return;let e=!1,t=null,n=fe.current+1;fe.current=n,de.current=0,ve.current=null,ue.current=null,L.current=!1,R.current=0,ce.current=`idle`,V.current=null,I.current=[],ee.current=null,De({kind:`loading`});let r=new _({theme:YC(pe.current),allowTransparency:!0,fontFamily:`JetBrains Mono, Fira Code, SF Mono, monospace`,fontSize:m,scrollback:5e3,cursorBlink:Ae&&!lt,cursorStyle:`block`,disableStdin:!Ae||lt,allowProposedApi:!0}),o=(e,t)=>{let n=QC(e,t);return n?(Ke.current(n,`system`),!0):!1},s=r.parser.registerOscHandler(10,e=>e===`?`?o(`10`,XC(pe.current).foreground):!1),c=r.parser.registerOscHandler(11,e=>e===`?`?o(`11`,XC(pe.current).background):!1),l=new g;r.loadAddon(l),r.onResize(e=>{Je.current(e)}),r.onData(e=>{Ke.current(e)}),typeof r.onBinary==`function`&&r.onBinary(e=>{qe.current(e)});let d=typeof r.onRender==`function`?r.onRender(({start:e,end:t})=>{rw(D.current,Ge.current,{start:e,end:t})}):void 0,f=typeof r.onSelectionChange==`function`?r.onSelectionChange(()=>{ye.current=r.hasSelection()?r.getSelection():``}):void 0;r.attachCustomKeyEventHandler(e=>!zC(e)),r.open(D.current),qC(i,`mount.open`),O.current=r,k.current=l,Ze();let p=Qe();u!==`mobile`&&p.then(async()=>{await WC(),!(e||!M.current)&&Ze()}).catch(()=>{});let v=async()=>{h&&(typeof h.getStatus!=`function`||typeof h.onStatus!=`function`||h.getStatus()!==`connected`&&await new Promise(e=>{let n=!1,r=()=>{n||(n=!0,t?.(),t=null,e())};t=h.onStatus(e=>{e===`connected`&&r()}),h.getStatus()===`connected`&&r()}))},y=p.then(async()=>{if(!h||(await v(),e||!M.current))return;let{cols:t,rows:n}=r;await Je.current({cols:t,rows:n})}),b=(e,t)=>{de.current+=1;let i=!1,a=()=>{i||(i=!0,fe.current===n&&(de.current=Math.max(0,de.current-1),t?.()))};try{r.write(e,a)}catch(e){throw a(),e}},x=dp.terminalOutput(a,i),C=dp.terminalExit(a,i),w=e=>{let t=I.current;I.current=[];let n=[],r=e;for(let e of t)e.seq<=r||(n.push(e),r=e.seq);return{entries:n,latestCoveredSeq:r}},T=()=>{u!==`mobile`&&(ge.current?.release(),_e.current=!0)},E=e=>{ce.current=`done`,V.current=null,e&&ue.current===e&&(ue.current=`reconnect`),ve.current?.()},N=async e=>{e.length!==0&&await new Promise((t,a)=>{let o=e.length,s=!1,c=e=>{M.current&&fe.current===n&&(le.current=Math.max(le.current,e)),o=Math.max(0,o-1),o===0&&!s&&(s=!0,t())};for(let t of e){t.resetTerminalBeforeWrite&&typeof O.current?.reset==`function`&&O.current.reset(),t.kind===`historical`?qC(i,`write.historical`,{seq:t.seq,size:t.bytes.byteLength,summary:KC(t.bytes)}):qC(i,`write.pending-replay-chunk`,{seq:t.seq,summary:KC(t.bytes)});try{if(t.kind===`historical`){b(t.bytes,()=>{c(t.seq)});continue}r.write(t.bytes,()=>{c(t.seq)})}catch(e){s||(s=!0,a(e));return}}})},P=async e=>{let t=e?.coveredSeq??R.current,n=[];for(e?.bytes&&typeof e.coveredSeq==`number`&&n.push({kind:`historical`,bytes:e.bytes,seq:e.coveredSeq,resetTerminalBeforeWrite:e.resetTerminalBeforeWrite}),L.current=!1,n.length>0&&await N(n),R.current=t,le.current=Math.max(le.current,t),L.current=!0,S(e=>({...e,chunks:[],lastSeq:Math.max(e.lastSeq,t)}));;){let{entries:e,latestCoveredSeq:n}=w(t);if(e.length===0)break;t=n,await N(e.map(e=>({kind:`pending`,bytes:e.bytes,seq:e.seq})))}E(V.current)};re.current=async(e,t)=>{!M.current||!O.current||(T(),await P({coveredSeq:e}),z.current=null,t&&Xe(t.exitCode))};let F=async e=>{if(console.error(`Failed to recover terminal output:`,e),!M.current||!O.current)return;je.current=`error`;let t=cC(e);De(se.current?{kind:`failed`,reason:t}:{kind:`retryable_failure`,reason:t}),T(),await P()};ie.current=F;let me=async()=>{!M.current||!O.current||(je.current=`error`,z.current=null,De({kind:`unrecoverable_history`,reason:`too_old_no_snapshot`}),T(),await P())};ae.current=me;let he=async()=>{!M.current||!O.current||(je.current=`error`,z.current=null,De({kind:`unavailable`}),T(),await P())};B.current=he,te.current=async(e,t)=>{if(!M.current||!O.current)return;let n=t?.resetTerminalBeforeWrite??z.current===0;ce.current=`in-flight`,V.current=`reconnect`,je.current=`silent`,se.current=!1,De({kind:`ready`}),T(),await P({bytes:e.bytes,coveredSeq:e.seq,resetTerminalBeforeWrite:n}),z.current=null},ne.current=async e=>{!M.current||!O.current||(ce.current=`in-flight`,V.current=`initial`,je.current=`silent`,se.current=!1,De({kind:`ready`}),T(),await P({bytes:e.bytes,coveredSeq:e.seq,resetTerminalBeforeWrite:!0}),z.current=null)};let H=e=>{h&&(z.current===null&&(z.current=le.current),ce.current=`in-flight`,L.current=!1,De({kind:`loading`}),h.sendCommand(`terminal.snapshot`,{terminalId:i},{timeoutMs:sC}).then(e=>({ok:!0,data:e})).catch(e=>({ok:!1,error:e})).then(t=>{if(!(!M.current||!O.current)){if(t.ok&&t.data?.status===`ok`&&t.data.bytes&&typeof t.data.seq==`number`){ne.current?.({...t.data,bytes:t.data.bytes});return}if(e?.onUnavailable){e.onUnavailable(t);return}F(t.ok?Error(`terminal.snapshot returned status ${t.data?.status??`unknown`}`):t.error)}}))},be=(e,t)=>{h&&(z.current=e,ce.current=`in-flight`,L.current=!1,e===0&&De({kind:`loading`}),qC(i,`replay.request`,{lastSeq:e}),h.sendCommand(`terminal.replay`,{terminalId:i,lastSeq:e},{timeoutMs:sC}).then(e=>({ok:!0,data:e})).catch(e=>({ok:!1,error:e})).then(n=>{if(n.ok&&n.data?.status===`too_old`&&t?.onTooOld){t.onTooOld();return}if(n.ok&&n.data?.status===`ok`&&n.data.bytes){te.current?.({...n.data,bytes:n.data.bytes},{resetTerminalBeforeWrite:t?.resetTerminalBeforeWrite??e===0});return}if(n.ok&&n.data?.status===`unknown`){he();return}if(t?.onError){t.onError(n.ok?void 0:n.error);return}F(n.ok?Error(`terminal.replay failed`):n.error)}))},xe=()=>{ue.current||=V.current??`reconnect`,ce.current=`idle`,V.current=null,L.current=!1,ve.current?.()},Se=()=>typeof h?.getStatus==`function`?h.getStatus():`connected`,Ce=(e,t)=>{let n=Se();if(ue.current===`reconnect`||n===`disconnected`||n===`reconnecting`){qC(i,`reconnect.snapshot-fallback.defer-until-reconnect`,{lastSeq:le.current,reason:e,error:t?String(t):void 0,connectionStatus:n}),xe();return}qC(i,`reconnect.snapshot-fallback`,{lastSeq:le.current,reason:e,error:t?String(t):void 0}),H({resetTerminalBeforeWrite:!0,onUnavailable:t=>{let n=Se();if(ue.current===`reconnect`||n===`disconnected`||n===`reconnecting`){qC(i,`reconnect.snapshot.defer-until-reconnect`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error),connectionStatus:n}),xe();return}if(e===`too_old`&&t.ok&&t.data?.status===`unsupported`){me();return}F(t.ok?Error(`terminal.snapshot returned status ${t.data?.status??`unknown`}`):t.error)}})},we=e=>{V.current=`reconnect`,je.current=`non_blocking_recovering`,De({kind:`loading`}),oe.current=()=>{we(e)},be(e,{onTooOld:()=>{Ce(`too_old`)},onError:e=>{Ce(`error`,e)}})},U=e=>{if(h){if(e===`reconnect`){we(le.current);return}V.current=`initial`,je.current=`blocking_rebuild`,oe.current=()=>{U(`initial`)},H({onUnavailable:e=>{let t=Se();if(ue.current===`initial`||t===`disconnected`||t===`reconnecting`){qC(i,`snapshot.defer-until-reconnect`,{reason:e.ok?e.data?.status??`unsupported`:String(e.error),connectionStatus:t}),xe();return}if(qC(i,`snapshot.fallback`,{reason:e.ok?e.data?.status??`unsupported`:String(e.error)}),e.ok&&e.data?.status===`unsupported`){be(0,{resetTerminalBeforeWrite:!0,onTooOld:()=>{me()}});return}be(0)}})}};return ve.current=()=>{if(!ue.current||typeof h?.getStatus==`function`&&h.getStatus()!==`connected`||ce.current===`in-flight`)return;let e=ue.current;ue.current=null,U(e)},h&&(A.current=h.subscribe([x,C],(e,t,n)=>{if(e===x){let e=t;if(qC(i,`live.output`,{seq:n,replayCompleted:L.current,replayedSeq:R.current,size:e.bytes.byteLength,summary:KC(e.bytes)}),!L.current){I.current.push({bytes:e.bytes,seq:n});return}if(n<=R.current){qC(i,`live.drop-covered`,{seq:n,replayedSeq:R.current});return}let r=n-e.bytes.byteLength;if(r>R.current){qC(i,`live.gap`,{seq:n,chunkStartSeq:r,replayedSeq:R.current}),I.current.push({bytes:e.bytes,seq:n}),S(e=>({chunks:[],lastSeq:R.current})),Ye?Ye.notifyReason(`seq_gap`,i).catch(e=>{F(e)}):we(R.current);return}S(t=>n<=t.lastSeq?t:{chunks:[...t.chunks,e.bytes],lastSeq:n}),R.current=n}else e===C&&Xe(t.code)})),(async()=>{if(await y,M.current){if(Ye){await Ye.notifyReason(`initial_mount`,i);return}U(`initial`)}})().catch(e=>{F(e)}),()=>{if(e=!0,te.current=null,ne.current=null,re.current=null,ie.current=null,ae.current=null,B.current=null,oe.current=null,z.current=null,fe.current===n&&(fe.current+=1,de.current=0),t&&=(t(),null),A.current&&=(A.current(),null),j.current!==null&&(cancelAnimationFrame(j.current),j.current=null),O.current){try{O.current.dispose()}catch(e){console.error(`Failed to dispose xterm instance:`,e)}O.current=null,k.current=null}typeof f==`function`?f():f?.dispose?.(),typeof d==`function`?d():d?.dispose?.(),s.dispose(),c.dispose()}},[Me.kind,Xe,Ze,S,i,T,u,a,h]),(0,H.useEffect)(()=>{let e=D.current;if(!e||typeof document>`u`||u===`mobile`||!p.copyOnSelect)return;let t=e=>{e.pointerType===`touch`||e.pointerType===`pen`||(xe.current=e.pointerId)},n=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target;n instanceof Node&&e.contains(n)||xe.current===t.pointerId&&(xe.current=null)},r=e=>{xe.current===e.pointerId&&(xe.current=null)},i=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target,r=n instanceof Node&&e.contains(n),i=xe.current!==null&&xe.current===t.pointerId;xe.current=null,!(!r&&!i)&&rt()};return e.addEventListener(`pointerdown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,r),()=>{xe.current=null,e.removeEventListener(`pointerdown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,r)}},[rt,p.copyOnSelect,u]),(0,H.useEffect)(()=>{if(!(Ye||!h||typeof h.onStatus!=`function`))return h.onStatus(e=>{if(e===`disconnected`||e===`reconnecting`){ce.current!==`idle`&&(ue.current=V.current??`reconnect`);return}e!==`connected`||!ue.current||ve.current?.()})},[Ye,h]),(0,H.useEffect)(()=>{let e=O.current;if(!e)return;let{chunks:t}=x,n=t.length;if(n>0){let r=Array(t.length),a=x.lastSeq;for(let e=t.length-1;e>=0;--e)r[e]=a,a-=t[e]?.byteLength??0;for(let n=0;n<t.length;n++){let a=t[n];if(!a)continue;let o=r[n]??x.lastSeq;qC(i,`write.live-buffer`,{index:n,lastSeq:x.lastSeq,summary:KC(a)}),e.write(a,()=>{le.current=Math.max(le.current,o)})}S(e=>JC(e,n))}},[Me.kind,x,S,i]),(0,H.useEffect)(()=>{let e=D.current,t=k.current;if(!e||!t)return;let n=new ResizeObserver(()=>{qC(i,`resize-observer`,{clientWidth:e.clientWidth,clientHeight:e.clientHeight}),P.current!==null&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,Ze()},150)});return n.observe(e),()=>{n.disconnect(),P.current!==null&&(clearTimeout(P.current),P.current=null)}},[Me.kind,Ze,i]),(0,H.useEffect)(()=>{u!==`mobile`&&Me.kind===`granted`&&Ae&&O.current&&O.current.focus()},[Me.kind,Ae,u]);let ft=u===`mobile`&&Ae,pt=!Ae||lt||Be!==`connected`,mt={paste:l(`terminal.mobile_input.paste`),upload:l(`terminal.mobile_input.upload`),shortcuts:l(`terminal.mobile_input.shortcuts`),ctrl:l(`terminal.mobile_input.ctrl`),ctrlArmed:l(`terminal.mobile_input.ctrl_armed`),ctrlLocked:l(`terminal.mobile_input.ctrl_locked`),shift:l(`terminal.mobile_input.shift`),shiftArmed:l(`terminal.mobile_input.shift_armed`),escape:l(`terminal.mobile_input.escape`),tab:l(`terminal.mobile_input.tab`),enter:l(`terminal.mobile_input.enter`),up:l(`terminal.mobile_input.up`),down:l(`terminal.mobile_input.down`),left:l(`terminal.mobile_input.left`),right:l(`terminal.mobile_input.right`)},ht=(0,H.useCallback)(async e=>{let t=ze.current;t&&et(!1),await at($S(e,{shift:t}))},[at,et]),gt=(0,H.useCallback)(()=>{$e(eC(Re.current))},[$e]),_t=(0,H.useCallback)(()=>{$e(tC())},[$e]),vt=(0,H.useCallback)(()=>{et(!ze.current)},[et]),yt=(0,H.useRef)(null),[bt,xt]=(0,H.useState)(!1),St=(0,H.useRef)(null),Ct=(0,H.useCallback)(async()=>{if(navigator.clipboard)try{await ut();return}catch(e){console.debug(`Clipboard API failed, showing paste dialog:`,e)}xt(!0)},[ut]),wt=(0,H.useCallback)(async()=>{let e=St.current;if(!e)return;let t=e.value;t&&(await ct(t),e.value=``),xt(!1)},[ct]),Tt=(0,H.useCallback)(()=>{let e=St.current;e&&(e.value=``),xt(!1)},[]),Et=(0,H.useCallback)(()=>{yt.current?.click()},[]),Dt=(0,H.useCallback)(()=>{if(se.current=!0,De({kind:`loading`}),Ye){Ye.notifyReason(`foreground_resume`,i).catch(e=>{ie.current?.(e)});return}oe.current?.()},[Ye,i]),Ot=(0,H.useCallback)(async e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,t.length!==0&&await dt(t)},[dt]),kt=Ee.kind===`loading`&&je.current===`blocking_rebuild`,At=u===`mobile`||Me.kind===`granted`,jt=(Ee.kind===`loading`&&kt&&Oe||Ee.kind===`closed`||Ee.kind===`unavailable`)&&At,Mt=Ee.kind===`retryable_failure`||Ee.kind===`failed`||Ee.kind===`unrecoverable_history`||Ee.kind===`truncated`,Nt=``,Pt=``,Ft=`xterm-replay-overlay`,It=(Ee.kind===`closed`||Ee.kind===`unavailable`)&&T===`agent`&&!!r&&!!n,Lt=``,Rt=``,zt=null;return Ee.kind===`loading`?(Nt=l(`terminal.replay.loading_title`),Pt=l(`terminal.replay.loading_body`)):Ee.kind===`closed`?(Ft+=` xterm-replay-overlay--degraded`,Pt=t?l(`terminal.replay.closed_body_with_provider`,{provider:t}):l(`terminal.replay.closed_body`),Nt=l(`terminal.replay.closed_title`)):Ee.kind===`unavailable`?(Ft+=` xterm-replay-overlay--degraded`,Pt=t?l(`terminal.replay.unknown_body_with_provider`,{provider:t}):l(`terminal.replay.unknown_body`),Nt=l(`terminal.replay.unknown_title`)):Ee.kind===`retryable_failure`?(Lt=l(`terminal.replay.retryable_title`),Rt=l(`terminal.replay.retryable_body`),zt=(0,X.jsx)(Q,{onClick:()=>{Dt()},size:`sm`,variant:`ghost`,children:l(`terminal.replay.retry_action`)})):Ee.kind===`failed`?(Lt=l(`terminal.replay.failed_title`),Rt=l(`terminal.replay.failed_body`)):Ee.kind===`unrecoverable_history`?(Lt=l(`terminal.replay.unrecoverable_title`),Rt=l(`terminal.replay.unrecoverable_body`)):Ee.kind===`truncated`&&(Lt=l(`terminal.replay.truncated_title`),Rt=l(`terminal.replay.truncated_body`)),(0,X.jsxs)(`div`,{className:`xterm-host-shell${ft?` xterm-host-shell--mobile-input`:``}`,children:[ft?(0,X.jsx)(YS,{ctrlMode:Pe,shiftArmed:Ie,disabled:pt,labels:mt,onKeyPress:e=>{ht(e)},onCtrlTap:gt,onCtrlLongPress:_t,onShiftTap:vt,onPaste:Ct,onUpload:Et}):null,(0,X.jsx)(`input`,{ref:yt,type:`file`,accept:`image/*,video/*,audio/*,text/plain,.txt,.md,.json,.csv`,multiple:!0,hidden:!0,onChange:e=>{Ot(e)}}),Mt?(0,X.jsx)(jh,{action:zt,message:Rt,title:Lt,tone:`warning`}):null,(0,X.jsx)(`div`,{ref:D,className:`xterm-host`,style:{width:`100%`,minHeight:0,overflow:`hidden`},onFocusCapture:()=>{Ae&&ge.current?.promote(`focused`)},onMouseDown:()=>{Ae&&ge.current?.promote(`focused`)}}),lt?(0,X.jsx)(Dh,{className:`terminal-upload-overlay`,open:!0,interactive:!1,mode:`status`,surfaceClassName:`xterm-replay-overlay__card`,children:(0,X.jsx)(`div`,{children:`Uploading…`})}):null,bt?(0,X.jsxs)(Dh,{ariaLabelledBy:`paste-dialog-title`,interactive:!0,mode:`dialog`,open:!0,onDismiss:Tt,surfaceClassName:`paste-dialog`,children:[(0,X.jsx)(`h3`,{id:`paste-dialog-title`,className:`paste-dialog__title`,children:l(`terminal.paste_dialog_title`)}),(0,X.jsx)(`textarea`,{ref:St,className:`paste-dialog__textarea`,placeholder:l(`terminal.paste_dialog_placeholder`),autoFocus:!0}),(0,X.jsxs)(`div`,{className:`paste-dialog__actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--secondary`,onClick:Tt,children:l(`common.cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--primary`,onClick:()=>{wt()},children:l(`terminal.paste_dialog_submit`)})]})]}):null,u!==`mobile`&&Me.kind===`queued`?(0,X.jsx)(yC,{state:`queued`,queuePosition:Me.queuePosition}):null,jt?(0,X.jsxs)(Dh,{className:Ft,interactive:It,mode:It?`dialog`:`status`,open:!0,surfaceClassName:`xterm-replay-overlay__card`,children:[Ee.kind===`loading`?(0,X.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,X.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:Nt}),Pt?(0,X.jsx)(`div`,{className:`xterm-replay-overlay__body`,children:Pt}):null,It?(0,X.jsxs)(`div`,{className:`xterm-replay-overlay__actions`,children:[(0,X.jsx)(Q,{className:`xterm-replay-overlay__action-btn`,onClick:()=>{r?.()},variant:`primary`,children:e??l(`action.confirm`)}),(0,X.jsx)(Q,{className:`xterm-replay-overlay__action-btn`,onClick:()=>{n?.()},variant:`secondary`,children:l(`action.close`)})]}):null]}):null]})}var aw=({paneId:e,dragState:t,sessionId:n,showHeaderActions:r=!0,showSupervisorInline:i=!0,terminalReadOnlyOverride:a,headerAccessory:o,onClose:s,onPaneDragStart:c,onPaneDrop:l,onSplitHorizontal:u,onSplitVertical:d})=>{let f=U(Up(n)),p=U(Op),m=W(Vp),h=Aa(),g=U(Ip(f?.workspaceId??`__workspace_empty__`)),_=U(to),v=W(to),y=Wx(),b=(0,H.useRef)(null),[x,S]=(0,H.useState)(!1);yS(f);let C=Mx(f?.workspaceId??`__workspace_empty__`),w=Yx(),{persistUiState:T}=Bv(f?.workspaceId??`__workspace_empty__`),E=Xg();if((0,H.useEffect)(()=>{if(_!==n)return;let e=b.current;e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),S(!0),v(null);let t=setTimeout(()=>S(!1),1400);return()=>clearTimeout(t)},[_,n,v]),!f)return null;let D=f.title?.trim()||uw(f.id),O=fw(f.providerId),k=dw(f.state),A=a??!pw(f.state),j=g?.uiState.activeSessionId===f.id,M=f.state===`running`,N=t?.isActiveDropTarget?t.hoverPlacement:null,P=async()=>{let e=await p(`session.create`,{workspaceId:f.workspaceId,providerId:f.providerId,themeBackground:h});if(!e.ok||!e.data)return;let t=e.data;m(e=>({...e,[t.id]:t})),C.replaceSession(f.id,t.id),E({workspaceId:f.workspaceId,sessionId:t.id}),T({activeSessionId:t.id});let n=await p(`session.remove`,{sessionId:f.id});n.ok||console.error(`Failed to remove closed session after relaunch:`,n.error?.message)},F=async()=>{if(s){await s();return}C.closeSessionPane(f.id),await w.closeSession(f.id,`draft`)};return(0,X.jsxs)(`div`,{ref:b,className:`session-card agent-pane${j?` session-card--active`:``}${x?` session-card--focus-pulse`:``}${M?` session-card--running`:``}${t?.isDragging?` session-card--dragging`:``}${t?.isActiveDropTarget?` session-card--drop-target`:``}`,"data-pane-id":e,"data-session-id":n,onClick:e=>{let t=e.target;t instanceof HTMLElement&&(t.closest(`button, a, input, textarea, select, [role="button"]`)||g?.uiState.activeSessionId!==f.id&&(E({workspaceId:f.workspaceId,sessionId:f.id}),T({activeSessionId:f.id})))},children:[N?(0,X.jsx)(`div`,{className:`pane-drop-overlay pane-drop-overlay--${N}`,children:N===`center`?(0,X.jsx)(`div`,{className:`pane-drop-overlay__center`,children:`Swap`}):null}):null,(0,X.jsx)(aS,{className:M?`session-header--running`:void 0,title:D,metaPlacement:`inline`,status:(0,X.jsx)(lg,{tone:sw(f.state),pulse:cw(f.state),className:`session-dot ${ow(f.state)}`}),meta:(0,X.jsxs)(`div`,{className:`session-title-row`,children:[(0,X.jsx)(_g,{color:`blue`,className:`session-provider-badge`,children:O}),(0,X.jsx)(_g,{color:lw(f.state),className:`session-state-badge`,caps:!1,children:k})]}),actions:r||o?(0,X.jsxs)(`div`,{className:`session-header-right`,children:[o?(0,X.jsx)(`div`,{className:`session-header-accessory`,children:o}):null,r?(0,X.jsxs)(`div`,{className:`session-header-actions`,children:[y?(0,X.jsx)(Ig,{content:`Drag pane`,children:(0,X.jsx)(Em,{"aria-label":`Drag pane`,className:`session-action-btn session-action-btn-drag`,icon:(0,X.jsx)(Ri,{size:13}),onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),t.pointerType!==`touch`&&e&&c?.({paneId:e,sessionId:f.id,title:D,providerLabel:O})},size:`sm`})}):null,(0,X.jsx)(Ig,{content:`Split horizontal`,children:(0,X.jsx)(Em,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,X.jsx)(ca,{size:13}),onClick:()=>u?.(),size:`sm`})}),(0,X.jsx)(Ig,{content:`Split vertical`,children:(0,X.jsx)(Em,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,X.jsx)(sa,{size:13}),onClick:()=>d?.(),size:`sm`})}),(0,X.jsx)(Ig,{content:`Close`,children:(0,X.jsx)(Em,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:()=>void s?.(),size:`sm`})})]}):null]}):null}),i&&f.capability===`full`&&f.state!==`draft`&&f.state!==`ended`?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(OS,{sessionId:f.id,workspaceId:f.workspaceId})}):null,(0,X.jsx)(`div`,{className:`session-terminal`,children:(0,X.jsx)(iw,{closedSessionProviderLabel:O,onClosedSessionClose:()=>{F()},onClosedSessionContinue:()=>{P()},terminalId:f.terminalId,workspaceId:f.workspaceId,readOnly:A,isActiveSession:j,terminalKind:`agent`})})]})};function ow(e){switch(e){case`starting`:return`session-dot-starting`;case`running`:return`session-dot-running`;case`ended`:return`session-dot-complete`;default:return`session-dot-idle`}}function sw(e){switch(e){case`starting`:return`warning`;case`running`:return`info`;case`ended`:return`success`;default:return`neutral`}}function cw(e){switch(e){case`starting`:case`running`:return!0;default:return!1}}function lw(e){switch(e){case`starting`:return`amber`;case`running`:return`green`;case`ended`:return`blue`;default:return`neutral`}}function uw(e){let t=e.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.replace(/[_-]/g,` `).toUpperCase()}function dw(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function fw(e){return e.replace(/\b\w/g,e=>e.toUpperCase())}function pw(e){return e===`running`||e===`idle`||e===`starting`}var mw={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},hw=({hydrateSessions:e=!0})=>{let t=Z(),n=Wx(),r=U(Bp),{workspaceId:i,sessions:a,paneLayout:o}=Xx(r,{disabled:!e}),s=Mx(i),c=Yx(),{insertSessionPaneAtEdge:l,moveSessionToDraft:u,swapPaneSessions:d}=s,f=Ev(o).length>0,p=a.length===0&&(f||o.type===`leaf`&&!o.sessionId&&o.id===`root`),m=(0,H.useCallback)(e=>{if(e.placement===`center`){if(e.targetType===`draft`){u(e.sourcePaneId,e.targetPaneId);return}d(e.sourcePaneId,e.targetPaneId);return}l(e.sourcePaneId,e.targetPaneId,e.placement)},[l,u,d]),h=zx({enabled:n,onDrop:m});return r?p?(0,X.jsx)(rS,{workspaceId:i,onReplaceWithSession:s.replaceWithSession}):(0,X.jsx)(`div`,{className:`agent-panes`,children:(0,X.jsx)(vw,{node:o,workspaceId:i,onCloseSession:s.closeSessionPane,onSplitDraftPane:s.splitDraftPane,onSplitSession:s.splitSessionPane,onCloseDraftPane:s.closeDraftPane,onAssignSession:s.assignSession,dragController:h,onPaneDrop:m,onReplaceWithSession:s.replaceWithSession,onCloseSessionCommand:c.closeSession})}):(0,X.jsx)(`div`,{className:`agent-panes-empty`,children:(0,X.jsx)(Sh,{style:{padding:0},title:(0,X.jsx)(`p`,{style:mw,children:t(`workspace.no_workspace`)})})})};function gw(e,t){let n=e.hoverTargetPaneId===t;return{isDragging:e.isDragging,isActiveDropTarget:n,hoverPlacement:n?e.hoverPlacement:null}}var _w=({dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u})=>{let d=(0,H.useRef)(null),f=gw(e.state,t.id);return(0,H.useEffect)(()=>{let n=d.current;if(n)return e.registerPane(t.id,{type:t.sessionId?`session`:`draft`,element:n}),()=>{e.registerPane(t.id,null)}},[e,t.id,t.sessionId]),t.sessionId?(0,X.jsx)(`div`,{ref:d,className:`agent-pane-leaf`,"data-pane-id":t.id,"data-pane-dragging":f.isDragging?`true`:void 0,"data-pane-drop-target":f.isActiveDropTarget?`true`:void 0,"data-pane-hover-placement":f.hoverPlacement??void 0,children:(0,X.jsx)(aw,{dragState:f,paneId:t.id,onPaneDragStart:e.startDrag,onPaneDrop:s,sessionId:t.sessionId,onClose:async()=>{a(t.sessionId),await o(t.sessionId,`draft`)},onSplitHorizontal:()=>u(t.sessionId,`horizontal`),onSplitVertical:()=>u(t.sessionId,`vertical`)})}):(0,X.jsx)(`div`,{ref:d,className:`agent-pane-leaf`,"data-pane-id":t.id,"data-pane-dragging":f.isDragging?`true`:void 0,"data-pane-drop-target":f.isActiveDropTarget?`true`:void 0,"data-pane-hover-placement":f.hoverPlacement??void 0,children:(0,X.jsx)(rS,{dragState:{isDragging:f.isDragging,isActiveDropTarget:f.isActiveDropTarget,hoverPlacement:f.hoverPlacement===`center`?`center`:null},workspaceId:n,paneId:t.id,onAssignSession:r,onClosePane:i,onPaneDrop:s,onReplaceWithSession:c,onSplitPane:l})})},vw=({dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u})=>{if(t.type===`leaf`)return(0,X.jsx)(_w,{dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u});let d=av(n,t.id)??t.ratio??.5;return(0,X.jsx)(iS,{splitId:t.id,direction:t.direction||`horizontal`,ratio:d,onRatioCommit:e=>ov(n,t.id,e),children:t.children?.map(t=>(0,X.jsx)(vw,{dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u},t.id))})},yw=new Map,bw=new Map,xw=0;function Sw(e){let t=yw.get(e);if(t)return t;let n={pendingByPath:{},cancelledByPath:{}};return yw.set(e,n),n}function Cw(e,t){Object.keys(t.pendingByPath).length===0&&Object.keys(t.cancelledByPath).length===0&&yw.delete(e)}function ww(e){let t=bw.get(e);if(t)for(let e of t)e()}function Tw(e,t){let n=Sw(e),r=xw+1;return xw=r,delete n.cancelledByPath[t],n.pendingByPath[t]=r,ww(e),r}function Ew(e,t,n){let r=yw.get(e);return r?r.cancelledByPath[t]===n?(delete r.cancelledByPath[t],Cw(e,r),!0):r.pendingByPath[t]!==n:!0}function Dw(e,t,n){let r=yw.get(e);r&&(r.pendingByPath[t]===n&&delete r.pendingByPath[t],r.cancelledByPath[t]===n&&delete r.cancelledByPath[t],Cw(e,r),ww(e))}function Ow(e,t){let n=yw.get(e);if(!n)return;let r=n.pendingByPath[t];r!==void 0&&(n.cancelledByPath[t]=r,delete n.pendingByPath[t],ww(e))}function kw(e){let t=yw.get(e);if(t){for(let[e,n]of Object.entries(t.pendingByPath))t.cancelledByPath[e]=n;t.pendingByPath={},ww(e)}}function Aw(e,t){return yw.get(e)?.pendingByPath[t]!==void 0}function jw(e){let t=yw.get(e);return t!==void 0&&Object.keys(t.pendingByPath).length>0}function Mw(e,t){let n=bw.get(e)??new Set;return n.add(t),bw.set(e,n),()=>{n.delete(t),n.size===0&&bw.delete(e)}}function Nw(e){return Object.keys(e).sort()}function Pw(e){let{openFiles:t,activeFilePath:n,pendingActiveFilePath:r=null,targetPath:i,closeAll:a=!1}=e,o=Nw(t),s=r&&!o.includes(r)?[...o,r].sort():o;return a?{orderedPaths:s,removedPaths:s,nextActiveFilePath:null,shouldExitEditor:!0}:!i||!s.includes(i)?{orderedPaths:s,removedPaths:[],nextActiveFilePath:n,shouldExitEditor:!1}:n===i?{orderedPaths:s,removedPaths:[i],nextActiveFilePath:null,shouldExitEditor:!0}:{orderedPaths:s,removedPaths:[i],nextActiveFilePath:n,shouldExitEditor:!1}}function Fw(e,t,n,r){return e?e.source===`commit`?n&&!r?.preserveCommitPreviewOnExit:n?!0:t.includes(e.path):!1}function Iw(e,t){let n=U(Ip(e)),r=t?.workspaceRootPath??n?.path,[i,a]=Te(u_(e)),[o,s]=Te(l_(e)),[c,l]=Te(m_(e)),u=W(h_(e)),[,d]=Te(d_(e)),f=(0,H.useCallback)(t=>{let n=Pw({openFiles:o,activeFilePath:i,pendingActiveFilePath:i&&!(i in o)?i:null,targetPath:t});if(n.removedPaths.length!==0){s(e=>{let t={...e};for(let e of n.removedPaths)delete t[e];return t});for(let t of n.removedPaths){if(!(t in o)){Ow(e,t);continue}let n=o[t];r&&n?.kind===`text`&&Ob.disposeFile(r,t)}a(n.nextActiveFilePath),(n.nextActiveFilePath!==i||n.shouldExitEditor)&&d(`edit`),c?.source===`file`&&Fw(c,n.removedPaths,n.shouldExitEditor)&&u(!0),l(e=>Fw(e,n.removedPaths,n.shouldExitEditor)?null:e)}},[i,c,o,a,l,u,d,s,e,r]);return{closeAll:(0,H.useCallback)(()=>{let t=Pw({openFiles:o,activeFilePath:i,pendingActiveFilePath:i&&!(i in o)?i:null,closeAll:!0});if(!(t.removedPaths.length===0&&i===null&&!jw(e))){kw(e),s({});for(let e of t.removedPaths){let t=o[e];r&&t?.kind===`text`&&Ob.disposeFile(r,e)}a(null),d(`edit`),c?.source===`file`&&Fw(c,t.removedPaths,t.shouldExitEditor,{preserveCommitPreviewOnExit:!0})&&u(!0),l(e=>Fw(e,t.removedPaths,t.shouldExitEditor,{preserveCommitPreviewOnExit:!0})?null:e)}},[i,c,o,a,l,u,d,s,e,r]),closePath:f}}async function Lw(e){if(!e.ok)throw Error(`preview_request_failed:${e.status}`);return e.json()}async function Rw(e){return Lw(await fetch(`/api/preview/session`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}))}async function zw(e,t){return Lw(await fetch(`/api/preview/session/${e}`,{method:`PUT`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Bw(e){await Lw(await fetch(`/api/preview/session/${e}`,{method:`DELETE`,credentials:`include`}))}function Vw(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(0),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(0),_=(0,H.useRef)(e.content??``),v=(0,H.useRef)(e.content??``),y=e.enabled&&e.workspaceId&&e.filePath&&e.kind?`${e.workspaceId}:${e.kind}:${e.filePath}`:null;return _.current=e.content??``,(0,H.useEffect)(()=>{if(!y||!e.workspaceId||!e.filePath||!e.kind){n(null),i(null),o(0),c(null),u(!1),f(!1),m(null),v.current=_.current;return}let t=!1,r=null;return n(null),i(null),o(0),c(null),u(!0),f(!1),m(null),Rw({workspaceId:e.workspaceId,entryPath:e.filePath,kind:e.kind,content:_.current}).then(e=>{if(t){Bw(e.id).catch(()=>void 0);return}r=e.id,n(e.id),i(e.previewUrl),o(e.revision),c(y),v.current=_.current,m(null)}).catch(e=>{t||m(e instanceof Error?e.message:`preview_bootstrap_failed`)}).finally(()=>{t||u(!1)}),()=>{t=!0,r&&Bw(r).catch(()=>void 0)}},[e.filePath,e.kind,e.workspaceId,h,y]),(0,H.useEffect)(()=>{if(!y||!t||!r||s!==y||v.current===_.current)return;let n=window.setTimeout(()=>{f(!0),zw(t,{content:_.current}).then(e=>{o(e.revision),v.current=_.current,m(null)}).catch(e=>{m(e instanceof Error?e.message:`preview_sync_failed`)}).finally(()=>{f(!1)})},e.debounceMs??300);return()=>{window.clearTimeout(n)}},[e.content,e.debounceMs,r,t,s,y]),{iframeSrc:r?`${r}?rev=${a}`:null,isBootstrapping:l,isSyncing:d,error:p,retry:()=>g(e=>e+1)}}function Hw(){let e=U(Bp),t=e?.path,n=U(Op),r=W(m_(e?.id??``)),i=W(h_(e?.id??``)),[a,o]=(0,H.useState)(()=>new Set),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=e?.id,[m,h]=Te(u_(p??``)),[g,_]=Te(l_(p??``)),[v,y]=Te(d_(p??``)),b=U(f_(p??``)),x=U(m_(p??``)),S=U(p_(p??``)),C=(0,H.useRef)(null),w=(0,H.useRef)(null),T=(0,H.useRef)(0),E=(0,H.useRef)(new Map),D=(0,H.useRef)(null),{closePath:O}=Iw(p??``,{workspaceRootPath:t}),k=p?g[m??``]:void 0;(0,H.useEffect)(()=>{if(!m){C.current=null;return}if(!p||!k||C.current===m)return;C.current=m;let e=v===`diff`&&x?.source===`file`&&x.path===m?`diff`:s_(k);e!==v&&y(e)},[m,k,x,v,y,p]),(0,H.useEffect)(()=>{c(e=>e?.path===m?e:null),u(e=>e?.path===m?e:null),f(e=>e?.path===m?e:null)},[m]);let A=(0,H.useCallback)(e=>{if(e.length===0)return;let t=new Set(e);for(let e of t)E.current.delete(e);o(e=>{let n=!1,r=new Set(e);for(let e of t)r.delete(e)&&(n=!0);return n?r:e}),c(e=>e&&t.has(e.path)?null:e)},[]);(0,H.useEffect)(()=>{let e=Object.keys(g);if(D.current===null){D.current=e;return}let t=D.current.filter(e=>!(e in g));D.current=e,A(t)},[A,g]),(0,H.useEffect)(()=>{if(!p){w.current=null;return}let e=m&&!g[m]?m:null,t=w.current;t&&t!==e&&Ow(p,t),w.current=e},[m,g,p]);let j=(0,H.useCallback)(async(e,r)=>{if(!p)return;let i=Tw(p,e);u(t=>t?.path===e?null:t);let a=await n(`file.read`,{workspaceId:p,path:e});if(Ew(p,e,i))return;if(!a.ok||!a.data){Dw(p,e,i);let t=a.error?.message??`Failed to open file`;console.error(`Failed to open file:`,t),u({path:e,message:t});return}let o=a.data;if(r?.forceText&&o.kind===`image`&&o.isTextBacked){try{let n=await fetch(o.url,{credentials:`include`});if(Ew(p,e,i))return;if(!n.ok){Dw(p,e,i);let t=`Failed to fetch text-backed image bytes: ${n.status}`;console.error(t),u({path:e,message:t});return}let r=await n.text();if(Ew(p,e,i))return;let a={kind:`text`,path:e,content:r,savedContent:r,baseHash:``,isDirty:!1,viewingTextBackedImageAsText:!0};Dw(p,e,i),_(t=>({...t,[e]:a})),t&&Ob.updateFromDisk({workspaceRootPath:t,path:e,content:r}),u(t=>t?.path===e?null:t)}catch(t){Dw(p,e,i);let n=t instanceof Error?t.message:`Failed to fetch text-backed image bytes`;console.error(`Failed to fetch text-backed image bytes:`,t),u({path:e,message:n})}return}let s=o.kind===`text`?{kind:`text`,path:e,content:o.content,savedContent:o.content,baseHash:o.baseHash,isDirty:!1,externalState:void 0}:{kind:`image`,path:e,mime:o.mime,url:o.url,size:o.size,version:o.version,isTextBacked:o.isTextBacked,externalState:void 0};Dw(p,e,i),_(t=>({...t,[e]:s})),t&&o.kind===`text`&&Ob.updateFromDisk({workspaceRootPath:t,path:e,content:o.content}),f(t=>t?.path===e?null:t),u(t=>t?.path===e?null:t)},[n,_,p,t]),M=(0,H.useCallback)(async e=>{let t=await fetch(e,{credentials:`include`});if(!t.ok)throw Error(`Failed to fetch text-backed image bytes: ${t.status}`);return t.text()},[]),N=(0,H.useCallback)(async()=>{if(!p||!k||k.kind!==`text`)return;let{path:e,content:t,baseHash:r}=k;if(a.has(e))return;let i=++T.current;E.current.set(e,i),o(t=>new Set(t).add(e)),c(t=>t?.path===e?null:t);let s=await n(`file.write`,{workspaceId:p,path:e,content:t,baseHash:r||void 0});E.current.get(e)===i&&(s.ok&&s.data?(_(n=>{let r=n[e];return!r||r.kind!==`text`?n:{...n,[e]:{...r,savedContent:t,baseHash:s.data.newHash,isDirty:!1,externalState:void 0}}}),f(t=>t?.path===e?null:t)):c({path:e,message:s.error?.message??`Failed to save file`}),E.current.delete(e),o(t=>{let n=new Set(t);return n.delete(e),n}))},[k,n,a,_,p]),P=(0,H.useCallback)(e=>{!p||!k||k.kind!==`text`||_(t=>{let n=t[k.path];return!n||n.kind!==`text`?t:{...t,[k.path]:{...n,content:e,isDirty:e!==n.savedContent}}})},[k,_,p]);(0,H.useEffect)(()=>{!p||!m||g[m]||Aw(p,m)||j(m)},[m,j,g,p]),(0,H.useEffect)(()=>{if(!p||b<=0)return;let e=Object.entries(g);if(e.length===0)return;let r=!1;return(async()=>{for(let[i,a]of e){let e=await n(`file.read`,{workspaceId:p,path:i});if(r)return;if(!e.ok||!e.data){let t=e.error?.code===`not_found`;_(e=>{let n=e[i];return n?{...e,[i]:{...n,externalState:t?`deleted`:n.externalState}}:e}),t&&m===i&&f({path:i,status:`deleted`});continue}let o=e.data;if(a.kind===`text`&&o.kind===`text`){if(o.baseHash===a.baseHash)continue;if(a.isDirty){_(e=>{let t=e[i];return!t||t.kind!==`text`?e:{...e,[i]:{...t,externalState:`modified`}}}),m===i&&f({path:i,status:`modified`});continue}_(e=>({...e,[i]:{kind:`text`,path:i,content:o.content,savedContent:o.content,baseHash:o.baseHash,isDirty:!1,externalState:void 0,viewingTextBackedImageAsText:a.viewingTextBackedImageAsText}})),t&&Ob.updateFromDisk({workspaceRootPath:t,path:i,content:o.content}),m===i&&f(e=>e?.path===i?null:e);continue}if(a.kind===`text`&&a.viewingTextBackedImageAsText===!0&&o.kind===`image`&&o.isTextBacked){if(a.isDirty){_(e=>{let t=e[i];return!t||t.kind!==`text`?e:{...e,[i]:{...t,externalState:`modified`}}}),m===i&&f({path:i,status:`modified`});continue}try{let e=await M(o.url);if(r)return;_(t=>{let n=t[i];return!n||n.kind!==`text`?t:{...t,[i]:{...n,content:e,savedContent:e,baseHash:o.version,isDirty:!1,externalState:void 0,viewingTextBackedImageAsText:!0}}}),m===i&&f(e=>e?.path===i?null:e)}catch(e){console.error(`Failed to refresh text-backed image bytes:`,e),_(e=>{let t=e[i];return!t||t.kind!==`text`?e:{...e,[i]:{...t,externalState:`modified`}}}),m===i&&f({path:i,status:`modified`})}continue}if(a.kind===`image`&&o.kind===`image`){if(a.version===o.version&&a.size===o.size)continue;_(e=>({...e,[i]:{kind:`image`,path:i,mime:o.mime,url:o.url,size:o.size,version:o.version,isTextBacked:o.isTextBacked,externalState:void 0}})),m===i&&f(e=>e?.path===i?null:e);continue}_(e=>{let t={...e};return delete t[i],t}),m===i&&f({path:i,status:`modified`})}})(),()=>{r=!0}},[m,n,b,M,g,_,p,t]);let F=(0,H.useCallback)(()=>{if(x?.source===`commit`){if(r(null),k){let e=s_(k);e!==v&&y(e)}return}(k?.path||m)&&O(k?.path??m),c(null)},[m,O,k,x,v,r,y]),ee=(0,H.useCallback)(()=>{if(!p||!k)return;let e=k.path,n=k.kind===`image`;y(n?`edit`:`preview`),_(t=>{let n={...t};return delete n[e],n}),t&&k.kind===`text`&&Ob.disposeFile(t,e),j(e,n?{forceText:!0}:void 0)},[k,j,y,_,p,t]),I=(0,H.useCallback)(async()=>{if(!p||!k)return!1;let e=await n(`git.diff`,{workspaceId:p,path:k.path,staged:!1});if(!e.ok||!e.data)return!1;let t={path:k.path,diff:e.data.diff,staged:!1,source:`file`,...e.data.renderAs?{renderAs:e.data.renderAs}:{},...e.data.status?{status:e.data.status}:{},...e.data.originalContent===void 0?{}:{originalContent:e.data.originalContent},...e.data.modifiedContent===void 0?{}:{modifiedContent:e.data.modifiedContent},...e.data.originalRevision?{originalRevision:e.data.originalRevision}:{},...e.data.modifiedRevision?{modifiedRevision:e.data.modifiedRevision}:{}};return i(!1),r(t),y(`diff`),!0},[k,n,r,i,y,p]),L=k?.kind===`text`,R=k?.kind===`image`,z=R&&k.isTextBacked||L&&k.viewingTextBackedImageAsText===!0,te=!!k,ne=!!k&&(k?.kind===`text`||k?.kind===`image`&&k.isTextBacked),re=!!(m&&S&&[...S.staged,...S.modified,...S.deleted,...S.untracked].some(e=>e.path===m)),ie=!!(m&&re),ae=!!(v===`diff`&&m&&k?.kind===`text`&&k.isDirty),B=x&&(x.source===`file`&&x.path===m||x.source===`commit`)?x:null,oe=!!(L&&a.has(k.path)),se=!!(L&&k.isDirty&&!oe),ce=m&&l?.path===m?l.message:null,V=m&&d?.path===m?d.status:null,le=m&&s?.path===m?s.message:null,ue=k?.kind===`text`?a_(k.path):null;return{activeFilePath:m,activeDiffChange:B,activeExternalStatus:V,activeLoadError:ce,canSave:se,canDiff:ie,canEdit:ne,canPreview:te,currentFile:k,documentPreview:Vw({enabled:v===`preview`&&!!ue,workspaceId:p,filePath:k?.kind===`text`?k.path:null,content:k?.kind===`text`?k.content:void 0,kind:ue}),handleClose:F,handleContentChange:P,handleSave:N,hasUnsavedChangesOutsideDiff:ae,isImageFile:R,isSaving:oe,isSvgTextBacked:z,isTextFile:L,mode:v,openInDiffMode:I,saveError:le,setMode:e=>{y(e)},toggleSvgTextMode:ee,workspace:e,workspaceId:p}}var Uw=({src:e,title:t,isLoading:n,error:r,onRetry:i})=>{let a=Z(),[o,s]=(0,H.useState)(!1),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{s(!1)},[e]),(0,H.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{s(!0)};return e.addEventListener(`error`,t),()=>{e.removeEventListener(`error`,t)}},[e]),n?(0,X.jsx)(`div`,{className:`document-preview document-preview--loading`,children:a(`code_editor.preview_loading`)}):r||o||!e?(0,X.jsx)(`div`,{className:`document-preview`,children:(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:a(`code_editor.preview_unavailable`)}),action:i?(0,X.jsx)(`button`,{type:`button`,className:`code-mode-btn`,onClick:i,children:a(`code_editor.preview_retry`)}):null})}):(0,X.jsx)(`div`,{className:`document-preview`,children:(0,X.jsx)(`iframe`,{ref:c,className:`document-preview-frame`,title:`${t} preview`,src:e,sandbox:``})})};function Ww(e){let t=e.split(`/`)[1]??e;return(t.split(`+`)[0]??t).replace(/^x-/,``).toUpperCase()}function Gw({label:e,url:t,alt:n}){return(0,X.jsxs)(`section`,{className:`image-diff-preview__pane`,children:[(0,X.jsx)(`header`,{className:`image-diff-preview__pane-header`,children:(0,X.jsx)(`span`,{children:e})}),(0,X.jsx)(`div`,{className:`image-diff-preview__canvas`,children:t?(0,X.jsx)(`img`,{className:`image-diff-preview__image`,src:t,alt:n,draggable:!1}):(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:`No image`})})})]})}var Kw=({path:e,mime:t,status:n,beforeUrl:r,afterUrl:i})=>(0,X.jsxs)(`div`,{className:`image-diff-preview`,"data-testid":`image-diff-preview`,children:[(0,X.jsxs)(`div`,{className:`image-diff-preview__meta`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{children:Ww(t)}),(0,X.jsx)(`span`,{children:n})]}),(0,X.jsxs)(`div`,{className:`image-diff-preview__stack`,children:[(0,X.jsx)(Gw,{label:`Base`,url:r,alt:`${e} base`}),(0,X.jsx)(Gw,{label:`Current`,url:i,alt:`${e} current`})]})]});function qw(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function Jw(e){let t=e.split(`/`)[1]??e;return(t.split(`+`)[0]??t).replace(/^x-/,``).toUpperCase()}var Yw=({url:e,version:t,mime:n,sizeBytes:r,alt:i})=>{let[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=`${e}${e.includes(`?`)?`&`:`?`}v=${t}`;return(0,H.useEffect)(()=>{o(null),c(!1)},[e,t]),(0,X.jsxs)(`div`,{className:`image-preview`,children:[(0,X.jsx)(`div`,{className:`image-preview-canvas`,children:s?(0,X.jsx)(Sh,{className:`git-diff-empty`,description:(0,X.jsx)(`p`,{className:`git-diff-empty-body`,children:`The image could not be loaded. The file may have been moved or is larger than the browser allows.`}),title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:`Preview unavailable`})}):(0,X.jsx)(`img`,{className:`image-preview-img`,src:l,alt:i,draggable:!1,onLoad:e=>{let t=e.currentTarget;o({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>c(!0)})}),(0,X.jsxs)(`div`,{className:`image-preview-meta`,children:[(0,X.jsx)(`span`,{className:`image-preview-type`,children:Jw(n)}),a&&(0,X.jsxs)(`span`,{className:`image-preview-dim`,children:[a.w,` × `,a.h]}),(0,X.jsx)(`span`,{className:`image-preview-size`,children:qw(r)})]})]})},Xw=globalThis;Xw.MonacoEnvironment??={getWorker(e,t){return t===`json`?new l:t===`css`||t===`scss`||t===`less`?new r:t===`html`||t===`handlebars`||t===`razor`?new u:t===`typescript`||t===`javascript`?new c:new o}};var Zw=({originalContent:e,modifiedContent:t,filePath:n,readOnly:r=!0})=>{let i=U(Xa),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=Oa(i),u=`coder-studio-workspace-${l.id}`,d=Sa(l.monaco);return(0,H.useEffect)(()=>{p.defineTheme(u,d)},[u,d]),(0,H.useEffect)(()=>{if(!(!a.current||o.current))return o.current=p.createDiffEditor(a.current,{automaticLayout:!0,fontFamily:`JetBrains Mono, monospace`,fontSize:13,minimap:{enabled:!1},originalEditable:!1,readOnly:r,renderSideBySide:!1,scrollBeyondLastLine:!1,theme:u}),()=>{o.current?.dispose(),o.current=null,s.current?.dispose(),c.current?.dispose(),s.current=null,c.current=null}},[u,r]),(0,H.useEffect)(()=>{let r=o.current;if(!r)return;s.current?.dispose(),c.current?.dispose();let i=Qw(n);s.current=p.createModel(e,i),c.current=p.createModel(t,i),r.setModel({original:s.current,modified:c.current})},[n,t,e]),(0,H.useEffect)(()=>{p.setTheme(u)},[u]),(0,X.jsx)(`div`,{ref:a,className:`monaco-host monaco-diff-host`,"data-testid":`monaco-diff-host`})};function Qw(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,go:`go`,rs:`rust`,java:`java`,cpp:`cpp`,c:`c`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[e.split(`.`).pop()?.toLowerCase()||``]||`plaintext`}var $w=({state:e,chrome:t=`full`})=>{let n=Z(),{activeFilePath:r,activeDiffChange:i,activeExternalStatus:a,activeLoadError:o,currentFile:s,documentPreview:c,handleClose:l,handleContentChange:u,handleSave:d,hasUnsavedChangesOutsideDiff:f,mode:p,openInDiffMode:m,saveError:h,workspace:g}=e;if(!g)return(0,X.jsx)(`div`,{className:`workspace-git-view`,children:(0,X.jsx)(`div`,{className:`code-editor workspace-git-editor`,children:(0,X.jsx)(`div`,{className:`code-editor-body`,children:(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`workspace.no_workspace`)})})})})});let _=s?.kind===`text`?s:null,v=s?.kind===`image`?s:null,y=t===`full`,b=i?.source===`commit`,x=!b&&_?.isDirty?(0,X.jsx)(`span`,{className:`dirty-indicator`,children:`*`}):null,S=(p===`diff`||b)&&!!i&&(i?.renderAs===`text`||i?.source===`commit`),C=p===`diff`&&!!i&&i?.renderAs===`image`,w=p===`preview`&&_!==null&&a_(_.path)!==null,T=b?i.title??i.path:s?s.path:i?.title??r??n(`file.title`);return(0,X.jsx)(`div`,{className:`workspace-git-view`,children:(0,X.jsxs)(`div`,{className:`code-editor workspace-git-editor`,children:[y?(0,X.jsxs)(`div`,{className:`code-editor-header editor-surface__header`,children:[(0,X.jsx)(`span`,{className:`code-file-path`,children:s&&!b?(0,X.jsxs)(X.Fragment,{children:[T,x]}):T}),b?(0,X.jsx)(`div`,{className:`editor-surface__toolbar`,role:`toolbar`,"aria-label":`Editor actions`,children:(0,X.jsx)(Ig,{content:n(`action.close`),children:(0,X.jsx)(Em,{"aria-label":n(`action.close`),className:`code-mode-btn editor-surface__action-btn`,icon:(0,X.jsx)(pa,{size:12}),onClick:l,size:`sm`})})}):(0,X.jsx)(eT,{state:e})]}):null,!b&&h?(0,X.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,X.jsx)($,{semantic:`state.error`,size:14}),(0,X.jsx)(`span`,{children:h})]}):null,!b&&a?(0,X.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,X.jsx)($,{semantic:a===`deleted`?`state.fileDeleted`:`state.fileModified`,size:14}),(0,X.jsx)(`span`,{children:n(a===`deleted`?`code_editor.deleted_on_disk`:`code_editor.modified_on_disk`)})]}):null,!b&&f?(0,X.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,X.jsx)($,{semantic:`state.warning`,size:14}),(0,X.jsx)(`span`,{children:n(`code_editor.diff_saved_only`)})]}):null,(0,X.jsx)(`div`,{className:`code-editor-body`,children:S?(0,X.jsx)(Zw,{filePath:i?.path??s?.path??`diff.patch`,originalContent:i?.originalContent??``,modifiedContent:i?.modifiedContent??i?.diff??``}):C&&v?(0,X.jsx)(Kw,{path:v.path,mime:v.mime,status:i?.status??`modified`,beforeUrl:i?.originalRevision?`${v.url}&revision=${i.originalRevision}`:void 0,afterUrl:i?.status===`deleted`?void 0:i?.modifiedRevision===`WORKTREE`?v.url:i?.modifiedRevision?`${v.url}&revision=${i.modifiedRevision}`:v.url}):w&&_?(0,X.jsx)(Uw,{src:c.iframeSrc,title:_.path,isLoading:c.isBootstrapping,error:c.error,onRetry:c.retry}):_?(0,X.jsx)(Fb,{workspaceId:g.id,workspaceRootPath:g.path,filePath:_.path,content:_.content,onContentChange:u,onSave:d,readOnly:p===`preview`}):v?(0,X.jsx)(Yw,{url:v.url,version:v.version,mime:v.mime,sizeBytes:v.size,alt:v.path}):o?(0,X.jsx)(Sh,{className:`git-diff-empty`,description:(0,X.jsx)(`p`,{className:`git-diff-empty-body`,children:o}),role:`alert`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`code_editor.open_failed_title`)})}):r?(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsxs)(`p`,{className:`git-diff-empty-title`,children:[n(`status.connecting`),`…`]})}):(0,X.jsx)(Sh,{className:`git-diff-empty`,description:(0,X.jsx)(`p`,{className:`git-diff-empty-body`,children:n(`code_editor.empty_hint`)}),title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`file.title`)})})})]})})},eT=({state:e})=>{let t=Z(),{canDiff:n,canEdit:r,canPreview:i,canSave:a,handleClose:o,handleSave:s,isImageFile:c,isSvgTextBacked:l,isSaving:u,mode:d,openInDiffMode:f,setMode:p,toggleSvgTextMode:m}=e,h=t(u?`code_editor.saving`:`action.save_file`);return(0,X.jsxs)(`div`,{className:`editor-surface__toolbar`,role:`toolbar`,"aria-label":`Editor actions`,children:[n?(0,X.jsx)(`button`,{type:`button`,className:`code-mode-btn editor-surface__mode-btn${d===`diff`?` active`:``}`,onClick:()=>void f(),"aria-pressed":d===`diff`,"aria-label":t(`code_editor.mode_diff`),children:(0,X.jsx)(`span`,{children:t(`code_editor.mode_diff`)})}):null,i?(0,X.jsxs)(`button`,{type:`button`,className:`code-mode-btn editor-surface__mode-btn${d===`preview`?` active`:``}`,onClick:()=>{if(l&&!c){m();return}p(`preview`)},"aria-pressed":d===`preview`,"aria-label":t(`code_editor.mode_preview`),children:[c?(0,X.jsx)(Bi,{size:12}):(0,X.jsx)(ki,{size:12}),(0,X.jsx)(`span`,{children:t(`code_editor.mode_preview`)})]}):null,r?(0,X.jsxs)(`button`,{type:`button`,className:`code-mode-btn editor-surface__mode-btn${d===`edit`?` active`:``}`,onClick:()=>{if(l&&c){m();return}p(`edit`)},"aria-pressed":d===`edit`,"aria-label":t(`code_editor.mode_edit`),children:[(0,X.jsx)(ki,{size:12}),(0,X.jsx)(`span`,{children:t(`code_editor.mode_edit`)})]}):null,(0,X.jsx)(Ig,{content:h,disabled:!a,children:(0,X.jsxs)(`button`,{type:`button`,className:`code-mode-btn editor-surface__action-btn`,onClick:s,disabled:!a,"aria-label":h,children:[(0,X.jsx)(ra,{size:12}),(0,X.jsx)(`span`,{children:h})]})}),(0,X.jsx)(Ig,{content:t(`action.close`),children:(0,X.jsx)(Em,{"aria-label":t(`action.close`),className:`code-mode-btn editor-surface__action-btn`,icon:(0,X.jsx)(pa,{size:12}),onClick:o,size:`sm`})})]})},tT=({state:e,variant:t=`full`})=>{let n=Z(),{activeFilePath:r,activeDiffChange:i,canDiff:a,canEdit:o,canPreview:s,canSave:c,handleClose:l,handleSave:u,isImageFile:d,isSaving:f,isSvgTextBacked:p,mode:m,openInDiffMode:h,setMode:g,toggleSvgTextMode:_}=e,v=n(f?`code_editor.saving`:`action.save_file`),y=n(d?`code_editor.edit_as_text`:`code_editor.preview_as_image`),b=i?.source===`commit`;return t===`mobile`?b?(0,X.jsx)(`div`,{className:`mobile-sheet__header-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:l,"aria-label":n(`action.close`),children:n(`action.close`)})}):(0,X.jsxs)(`div`,{className:`mobile-sheet__header-actions`,children:[a?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action mobile-sheet__action--mode${m===`diff`?` active`:``}`,onClick:()=>void h(),"aria-pressed":m===`diff`,"aria-label":n(`code_editor.mode_diff`),children:n(`code_editor.mode_diff`)}):null,s?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action mobile-sheet__action--mode${m===`preview`?` active`:``}`,onClick:()=>{if(p&&!d){_();return}g(`preview`)},"aria-pressed":m===`preview`,"aria-label":n(`code_editor.mode_preview`),children:n(`code_editor.mode_preview`)}):null,o?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action mobile-sheet__action--mode${m===`edit`?` active`:``}`,onClick:()=>{if(p&&d){_();return}g(`edit`)},"aria-pressed":m===`edit`,"aria-label":n(`code_editor.mode_edit`),children:n(`code_editor.mode_edit`)}):null,p?(0,X.jsx)(Ig,{content:y,children:(0,X.jsx)(Em,{"aria-label":y,className:`mobile-sheet__action mobile-sheet__action--icon`,icon:d?(0,X.jsx)(ki,{size:16}):(0,X.jsx)(Bi,{size:16}),onClick:_})}):null,(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:u,disabled:!c,"aria-label":v,children:v}),r||i?.source===`commit`?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:l,"aria-label":n(`action.close`),children:n(`action.close`)}):null]}):(0,X.jsx)(eT,{state:e})},nT=({state:e,chrome:t=`full`})=>(0,X.jsx)($w,{state:e,chrome:t}),rT=({chrome:e=`full`,editorState:t})=>(0,X.jsx)(nT,{state:t??Hw(),chrome:e});function iT(e){return async(t,n,r)=>{try{return{ok:!0,data:await e(t,n,r)}}catch(e){return{ok:!1,error:{code:`command_error`,message:e instanceof Error?e.message:String(e)}}}}}function aT(e){return e===`foreground_resume`?`foreground_resume`:e===`network_online`?`network_online`:null}function oT(e){let t=new Map,n=new Map,r=!1,i=!1,a=e=>{let t=n.get(e);if(t)return t;let r={idleResolvers:[],queued:null,running:null};return n.set(e,r),r},o=e=>{switch(e){case`initial_mount`:return 1;case`foreground_resume`:case`network_online`:return 2;case`socket_reconnected`:return 3;case`continuity_lost`:case`seq_gap`:return 4;default:return 0}},s=(e,t)=>{if(!e)return t;let n=o(e.reason),r=o(t.reason);return r>n||r===n?t:e},c=()=>{let t=e.wsClient.getStatus();return t===`connecting`||t===`disconnected`||t===`reconnecting`},l=e=>{if(c())return!0;let t=e instanceof Error?e.message:typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?String(e.message):``;return t.includes(`WebSocket disconnected`)||t.includes(`WebSocket not connected`)||t.includes(`Connection probe timeout`)||t.includes(`Command timeout: connection.probe`)},u=e=>{r=!0,!c()&&f(e,{reason:`socket_reconnected`,skipProbe:!0})},d=e=>{let t=e.idleResolvers;e.idleResolvers=[];for(let e of t)e()},f=(e,t)=>{if(i)return Promise.resolve();let n=a(e);return n.queued=s(n.queued,t),n.running||=(async()=>{try{for(;;){let t=n.queued;if(n.queued=null,!t)return;await v(e,t)}}finally{if(n.running=null,n.queued){f(e,n.queued);return}d(n)}})(),new Promise(e=>{n.idleResolvers.push(e)})},p=async(t,n,r)=>{if(i)return;n.setUiMode(`blocking_rebuild`);let a=await e.sendCommand(`terminal.snapshot`,{terminalId:t},{timeoutMs:sC});if(!i){if(!a.ok||!a.data||a.data.status!==`ok`){if(l(a.ok?void 0:a.error)){u(t);return}n.setUiMode(`error`);return}n.applySnapshot?await n.applySnapshot(a.data):await e.applySnapshot(t,a.data),await m(n,r),n.setUiMode(r?`closed`:`silent`)}},m=async(e,t)=>{t&&await e.markClosed?.(t)},h=async n=>{if(i)return;let r=t.get(n.terminalId);if(r){if(n.action===`noop`){r.completeRecovery&&await r.completeRecovery(n.headSeq),r.setUiMode(`silent`);return}if(n.action===`closed`){r.completeRecovery?await r.completeRecovery(n.headSeq,{exitCode:n.exitCode}):await m(r,{exitCode:n.exitCode}),r.setUiMode(`closed`);return}if(n.action===`unrecoverable`){r.setUiMode(`error`,{reason:n.reason});return}if(n.action===`replay`){r.setUiMode(`non_blocking_recovering`);let t=await e.sendCommand(`terminal.replay`,{terminalId:n.terminalId,lastSeq:n.fromSeq},{timeoutMs:sC});if(!t.ok){if(l(t.error)){u(n.terminalId);return}await p(n.terminalId,r,n.closed);return}if(!t.data){r.setUiMode(`error`);return}if(t.data.status===`too_old`){await p(n.terminalId,r,n.closed);return}if(t.data.status!==`ok`){r.setUiMode(`error`);return}r.applyReplay?await r.applyReplay(t.data):await e.applyReplay(n.terminalId,t.data),await m(r,n.closed),r.setUiMode(n.closed?`closed`:`silent`);return}await p(n.terminalId,r,n.closed)}},g=async(n,a)=>{if(i)return;let o=Array.from(t.values()).filter(e=>a?e.terminalId===a:!0);if(a&&o.length===0)return;let s=await e.sendCommand(`recovery.reconcile`,{reason:n,terminals:o.map(e=>({terminalId:e.terminalId,renderedSeq:e.getRenderedSeq()}))});if(!i){if(!s.ok||!s.data||!Array.isArray(s.data.terminals)){if(l(s.ok?void 0:s.error)){r=!0,a&&u(a);return}for(let e of o)e.setUiMode(`error`);return}for(let e of s.data.terminals)await h(e)}},_=async t=>{if(i)return!1;let n=aT(t);if(!n)return!0;if(e.wsClient.getStatus()!==`connected`)return!1;try{return await e.wsClient.probeConnection(n),!0}catch(e){if(l(e))return r=!0,!1;throw e}},v=async(e,n)=>{if(i)return;let a=t.get(e);if(a)try{if(!n.skipProbe&&!await _(n.reason)){r=!0;return}await g(n.reason,e)}catch(t){if(l(t)){u(e);return}a.setUiMode(`error`)}},y=e=>{if(!i){if(e===`disconnected`||e===`reconnecting`){r=!0;return}if(e===`connected`&&r){r=!1;for(let e of t.keys())f(e,{reason:`socket_reconnected`,skipProbe:!0})}}},b=e.subscribeToStatus===!1?()=>{}:e.wsClient.onStatus(y),x=e.subscribeToContinuityLost===!1?()=>{}:e.wsClient.subscribe([`workspace.*`],(e,t)=>{i||e.match(/^workspace\.([^.]+)\.terminal\.([^.]+)\.continuity_lost$/)&&f(t.terminalId,{reason:`continuity_lost`,skipProbe:!0})});return{registerTerminal(e){return i?()=>{}:(t.set(e.terminalId,e),()=>{t.delete(e.terminalId),n.delete(e.terminalId)})},async notifyReason(e,n){if(!i){if(n){await f(n,{reason:e,skipProbe:!1});return}if(!await _(e)){r=!0;return}if(t.size===0){await g(e);return}await Promise.all(Array.from(t.keys(),t=>f(t,{reason:e,skipProbe:!0})))}},handleConnectionStatus:y,dispose(){if(!i){i=!0,b(),x(),r=!1,t.clear();for(let e of n.values())e.queued=null,d(e);n.clear()}}}}function sT(e){return{id:e.id,workspaceId:e.workspaceId,kind:e.kind,alive:e.alive,exitCode:e.exitCode,title:e.title}}function cT(e){let t=Z(),n=U(Op),r=W(sy),i=ve(),a=Aa();return{async createShellTerminal(o={}){if(!e)return r({kind:`warning`,title:t(`terminal.create_unavailable_title`),body:t(`terminal.create_unavailable_body`)}),null;try{let s=await n(`terminal.create`,{workspaceId:e,cwdPath:o.cwdPath,themeBackground:a});if(!s.ok||!s.data)return r({kind:`error`,title:t(`terminal.create_failed_title`),body:s.error?.message??t(`terminal.create_failed_body`)}),null;let c=s.data;return i.set(jS(c.id),sT(c)),i.set(MS(e),e=>e.includes(c.id)?e:[...e,c.id]),i.set(NS(e),c.id),c}catch(e){return r({kind:`error`,title:t(`terminal.create_failed_title`),body:e instanceof Error?e.message:t(`terminal.create_failed_body`)}),null}}}}var lT=`__terminal_panel_empty__`,uT=`__terminal_panel_empty_workspace__`;function dT(e,t){let n=new Set(t),r=[...t];for(let t of e)n.has(t)||(n.add(t),r.push(t));return r}function fT(e){return{id:e.id,workspaceId:e.workspaceId,kind:e.kind,alive:e.alive,exitCode:e.exitCode,title:e.title}}function pT(){let e=Z(),t=U(zp),n=U(Op),r=U(bp),i=W(sy),a=ve(),o=t??uT,[s,c]=Te(MS(o)),[l,u]=Te(NS(o)),{createShellTerminal:d}=cT(t),f=(0,H.useRef)(null),p=U(jS(l??lT)),m=l?p:null;(0,H.useEffect)(()=>{if(!t){c([]),u(null);return}let r=!1;return c([]),u(null),n(`terminal.list`,{workspaceId:t}).then(t=>{if(r)return;if(!t.ok||!t.data){console.error(`Failed to fetch terminals:`,t.error?.message),i({kind:`error`,title:e(`terminal.load_failed_title`),body:t.error?.message??e(`terminal.load_failed_body`)});return}let n=t.data.filter(e=>e.kind===`shell`),o=n.map(e=>e.id);for(let e of n)a.set(jS(e.id),fT(e));c(e=>dT(e,o)),u(e=>e??o[0]??null)}).catch(t=>{r||(console.error(`Failed to fetch terminals:`,t),i({kind:`error`,title:e(`terminal.load_failed_title`),body:t instanceof Error?t.message:e(`terminal.load_failed_body`)}))}),()=>{r=!0}},[t,n,i,a,e]),(0,H.useEffect)(()=>{if(!r||!t)return;let e=dp.terminalsAll(t);return f.current=r.subscribe([e],(e,t,n)=>{let r=e.split(`.`);if(r.length<5)return;let i=r[3],o=r[4];if(o===`created`){let e=t;if(e.kind!==`shell`)return;c(t=>t.includes(e.id)?t:[...t,e.id]),u(e.id);return}if(o!==`output`)return;let s=a.get(jS(i));if(!s||s.kind!==`shell`)return;let l=t,d=AS(i),f=a.get(d);n<=f.lastSeq||a.set(d,{chunks:[...f.chunks,l.bytes],lastSeq:n})}),()=>{f.current?.(),f.current=null}},[t,a,r]);let h=(0,H.useCallback)(async()=>{await d()},[d]);return{activeTerminalId:l,activeTerminalMeta:m,activeWorkspaceId:t,handleCloseTerminal:(0,H.useCallback)(async e=>{(await n(`terminal.close`,{terminalId:e})).ok&&c(t=>{let n=t.filter(t=>t!==e);return u(t=>t===e?n[0]??null:t),n})},[n,u,c]),handleCreateTerminal:h,handleSwitchTerminal:(0,H.useCallback)(e=>{u(e)},[u]),hasTerminals:s.length>0,terminalIds:s}}function mT(e,t,n){let r=e?.title?.trim(),i=hT(r);return!r||gT(r,n)?`${i??n} — ${t+1}`:i?`${i} — ${t+1}`:r}function hT(e){if(!e)return null;let t=e.split(/[\\/]/).pop()?.trim();if(!t)return null;let n=t.toLowerCase().replace(/\.exe$/,``);return new Set([`bash`,`cmd`,`csh`,`fish`,`ksh`,`powershell`,`pwsh`,`sh`,`tcsh`,`zsh`]).has(n)?n:null}function gT(e,t){let n=e.toLowerCase();return n===t.trim().toLowerCase()||n===`shell terminal`||n===`shell 终端`}function _T({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=Z(),o=mT(U(jS(e)),t,a(`terminal.shell`));return(0,X.jsxs)(`div`,{className:`terminal-selector-item ${n?`terminal-selector-item-active`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`terminal-selector-item-trigger`,onClick:r,children:(0,X.jsx)(`span`,{className:`terminal-selector-item-title`,children:o})}),(0,X.jsx)(Em,{"aria-label":a(`action.close`),className:`terminal-selector-item-close`,icon:(0,X.jsx)(pa,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function vT({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=Z(),o=mT(U(jS(e)),t,a(`terminal.shell`));return(0,X.jsxs)(`div`,{className:`terminal-tab-shell ${n?`active`:``}`,role:`presentation`,children:[(0,X.jsx)(Bh,{className:`terminal-tab ${n?`terminal-tab-active`:``}`,onClick:r,value:e,children:(0,X.jsx)(`span`,{className:`terminal-tab-title`,children:o})}),(0,X.jsx)(Em,{"aria-label":a(`action.close`),className:`terminal-tab-close`,icon:(0,X.jsx)(pa,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function yT({chrome:e=`default`,onMobileHeaderActionsChange:t}){let n=Z(),r=ve(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),{activeTerminalId:c,activeTerminalMeta:l,activeWorkspaceId:u,handleCloseTerminal:d,handleCreateTerminal:f,handleSwitchTerminal:p,hasTerminals:m,terminalIds:h}=pT(),g=c?h.indexOf(c):0,_=mT(l,g>=0?g:0,n(`terminal.shell`)),v=c??h[0]??``,y=e===`mobile-fullscreen`,b=m&&(!y||h.length>1),x=h.length>1&&!y,S=h.map((e,t)=>({value:e,label:mT(r.get(jS(e)),t,n(`terminal.shell`))}));return(0,H.useEffect)(()=>{(!b||h.length<=1)&&(a(!1),s(!1))},[b,h.length]),(0,H.useEffect)(()=>{if(t)return()=>{t(null)}},[t]),(0,H.useEffect)(()=>{t&&t(null)},[t]),(0,X.jsxs)(`div`,{className:`bottom-terminal${y?` bottom-terminal--mobile-fullscreen`:``}`,children:[(0,X.jsx)(`div`,{className:`terminal-toolbar`,children:y?(0,X.jsxs)(`div`,{className:`terminal-toolbar-mobile-row`,children:[m?(0,X.jsxs)(`div`,{className:`terminal-selector`,children:[b?(0,X.jsx)(tg,{mobile:!0,"aria-label":n(`terminal.selector.switch`),"aria-expanded":o,className:`terminal-selector-btn`,includeValueInAriaLabel:!1,options:S,value:v,valueLabel:_,onClick:e=>{o&&(e.preventDefault(),s(!1))},onOpen:()=>s(!0)}):(0,X.jsx)(`div`,{className:`terminal-selector-btn terminal-selector-btn--static`,"aria-label":_,children:(0,X.jsx)(`span`,{children:_})}),b&&o?(0,X.jsx)(Jh,{className:`mobile-select-sheet--command`,title:n(`terminal.selector.title`),sections:[{kind:`options`,id:`terminals`,items:S.map((e,t)=>({id:e.value,label:e.label,meta:e.value===c?n(`terminal.selector.current`):n(`terminal.selector.indexed`,{index:t+1})}))}],selectedId:c,onSelect:p,onClose:()=>s(!1)}):null]}):(0,X.jsx)(`div`,{className:`terminal-toolbar-mobile-placeholder`,"aria-hidden":`true`}),m&&c?(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.close`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.close_terminal`),icon:(0,X.jsx)(pa,{size:14}),onClick:()=>{a(!1),s(!1),d(c)},size:`sm`})})}):null,y?(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.open`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.new_terminal`),icon:(0,X.jsx)($,{semantic:`terminal.action.new`,size:14}),onClick:f,size:`sm`})})}):null]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`terminal-toolbar-left`,children:(0,X.jsxs)(`div`,{className:`terminal-title-stack`,children:[(0,X.jsx)(`span`,{className:`terminal-kicker`,children:n(`terminal.kicker`)}),l?(0,X.jsx)(`span`,{className:`terminal-title`,children:_}):null]})}),(0,X.jsxs)(`div`,{className:`terminal-toolbar-right`,children:[m&&(0,X.jsxs)(X.Fragment,{children:[b?(0,X.jsx)(`div`,{className:`terminal-selector`,children:h.length>1?(0,X.jsx)(Gm,{content:(0,X.jsx)(X.Fragment,{children:h.map((e,t)=>(0,X.jsx)(_T,{id:e,index:t,isActive:e===c,onSelect:()=>{p(e),a(!1)},onClose:()=>{a(!1),d(e)}},e))}),contentClassName:`terminal-selector-dropdown`,forceMode:`desktop`,open:i,placement:`bottom-end`,title:n(`terminal.selector.title`),onOpenChange:a,children:(0,X.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":_,children:[(0,X.jsx)(`span`,{children:_}),(0,X.jsx)(_i,{size:12})]})}):(0,X.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":_,children:[(0,X.jsx)(`span`,{children:_}),(0,X.jsx)(_i,{size:12})]})}):null,(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.close`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.close_terminal`),icon:(0,X.jsx)(pa,{size:14}),onClick:()=>{c&&(a(!1),s(!1),d(c))},size:`sm`})})})]}),(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.open`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.new_terminal`),icon:(0,X.jsx)($,{semantic:`terminal.action.new`,size:14}),onClick:f,size:`sm`})})})]})]})}),(0,X.jsx)(`div`,{className:`bottom-terminal-content`,children:m?(0,X.jsxs)(X.Fragment,{children:[x?(0,X.jsx)(Rh,{"aria-label":n(`terminal.selector.title`),className:`bottom-terminal-tabs-nav`,onValueChange:p,value:v,children:(0,X.jsx)(zh,{className:`bottom-terminal-tabs`,children:h.map((e,t)=>(0,X.jsx)(vT,{id:e,index:t,isActive:e===v,onSelect:()=>p(e),onClose:()=>d(e)},e))})}):null,l&&u&&(0,X.jsx)(`div`,{className:`bottom-terminal-xterm`,children:(0,X.jsx)(iw,{terminalId:l.id,workspaceId:u,terminalKind:l.kind??`shell`})})]}):(0,X.jsx)(Sh,{action:(0,X.jsx)(Q,{variant:`primary`,size:`sm`,onClick:f,leadingIcon:(0,X.jsx)($,{semantic:`terminal.action.new`,size:14}),children:n(`terminal.new_terminal`)}),className:`bottom-terminal-empty`,description:(0,X.jsx)(`p`,{className:`bottom-terminal-empty-hint`,children:n(`terminal.empty_hint`)}),icon:(0,X.jsx)($,{className:`bottom-terminal-empty-icon`,semantic:`state.emptyTerminal`,size:32}),title:(0,X.jsx)(`p`,{className:`bottom-terminal-empty-text`,children:n(`terminal.no_terminal`)})})})]})}function bT({controller:e,className:t,iconSize:n,dataTestId:r}){let i=Z();if(!e)return null;let a=e.isFullscreen?i(`tooltip.exit_fullscreen`):i(`tooltip.enter_fullscreen`);return(0,X.jsx)(Ig,{content:a,children:(0,X.jsx)(Em,{"aria-label":a,className:t,"data-testid":r,icon:(0,X.jsx)(e.isFullscreen?Ki:Wi,{size:n}),onClick:()=>{e.toggleFullscreen()}})})}var xT=()=>{let e=Z(),t=U(xp);if(t===`connected`)return null;let n=`connection-status-${t}`,r=`connection-status-dot connection-status-dot-${t}`,i=e(`status.${t}`);return(0,X.jsx)(Ig,{content:i,children:(0,X.jsxs)(`div`,{className:`connection-status ${n}`,"aria-label":i,children:[(0,X.jsx)(lg,{tone:ST(t),size:`sm`,pulse:CT(t),className:r}),(0,X.jsx)(`span`,{className:`connection-status-text`,children:i})]})})};function ST(e){switch(e){case`connected`:return`success`;case`disconnected`:return`error`;default:return`warning`}}function CT(e){switch(e){case`connecting`:case`reconnecting`:return!0;default:return!1}}function wT(){let e=Qt(),t=U(Op),n=U(Np),r=W(jp),i=W(Mp),a=W(Np);return(0,H.useCallback)(async(o,s)=>{let c=await t(`workspace.close`,{id:o});if(!c.ok)return console.error(`Failed to close workspace:`,c.error?.message),!1;let l=n.filter(e=>e!==o);return i(e=>{let t={...e};return delete t[o],t}),a(l),r(e=>e===o?l[0]??null:e),l.length===0&&s?.navigateHomeWhenEmpty&&e(`/`,{replace:!0}),!0},[t,e,r,a,i,n])}var TT={running:`var(--workspace-session-map-running)`,starting:`var(--workspace-session-map-starting)`,idle:`var(--workspace-session-map-idle)`,empty:`var(--workspace-session-map-empty)`};function ET({cells:e,columns:t=1}){let n=Math.max(t,1),r=DT(e,n);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`workspace-session-mini-map`,"data-testid":`workspace-session-mini-map`,style:{"--workspace-session-map-columns":String(n)},children:(0,X.jsx)(`span`,{className:`workspace-session-mini-map__viewport`,children:r.map(e=>(0,X.jsx)(`span`,{className:`workspace-session-mini-map__column`,style:{"--workspace-session-map-column-fill":e.fill}},e.id))})})}function DT(e,t){let n=Array.from({length:t},()=>[]);for(let r of e){let e=jT(Math.round(r.x*t),t),i=jT(e+Math.max(1,Math.round(r.width*t))-1,t),a={top:MT(r.y),bottom:MT(r.y+r.height),state:r.state};for(let t=e;t<=i;t+=1)n[t]?.push(a)}return n.map((e,t)=>({id:`column-${t}`,fill:OT(e)}))}function OT(e){let t=e.filter(e=>e.bottom>e.top).sort((e,t)=>e.top-t.top||e.bottom-t.bottom);if(t.length===0)return AT(`empty`);let n=[],r=1/t.length;for(let[e,i]of t.entries()){let t=e*r,a=(e+1)*r;kT(n,i.state,t,a)}return`linear-gradient(180deg, ${n.join(`, `)})`}function kT(e,t,n,r){let i=TT[t];e.push(`${i} ${NT(n)}`),e.push(`${i} ${NT(r)}`)}function AT(e){let t=TT[e];return`linear-gradient(180deg, ${t} 0%, ${t} 100%)`}function jT(e,t){return Math.max(0,Math.min(t-1,e))}function MT(e){return Math.max(0,Math.min(1,e))}function NT(e){let t=Math.round(MT(e)*1e3)/10;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}%`}function PT(e,t){return IT(e??{id:`root`,type:`leaf`},t,{x:0,y:0,width:1,height:1})}function FT(e){return RT(e??{id:`root`,type:`leaf`})}function IT(e,t,n){if(e.type!==`split`||!e.children?.length)return[{paneId:e.id,sessionId:e.sessionId??null,state:LT(e.sessionId?t[e.sessionId]:void 0),x:n.x,y:n.y,width:n.width,height:n.height}];let[r,i]=e.children;if(!r||!i)return IT({...e,type:`leaf`,children:void 0},t,n);if(e.direction===`horizontal`){let e=RT(r),a=e+RT(i),o=n.width*(e/a);return[...IT(r,t,{x:n.x,y:n.y,width:o,height:n.height}),...IT(i,t,{x:n.x+o,y:n.y,width:n.width-o,height:n.height})]}return e.direction===`vertical`?[...IT(r,t,{x:n.x,y:n.y,width:n.width,height:n.height*.5}),...IT(i,t,{x:n.x,y:n.y+n.height*.5,width:n.width,height:n.height*.5})]:IT({...e,direction:`horizontal`},t,n)}function LT(e){switch(e?.state){case`running`:return`running`;case`starting`:return`starting`;case`idle`:return`idle`;default:return`empty`}}function RT(e){if(e.type!==`split`||!e.children?.length)return 1;let[t,n]=e.children;return!t||!n?1:e.direction===`vertical`?Math.max(RT(t),RT(n)):RT(t)+RT(n)}var zT=({workspace:e,isActive:t})=>{let n=Z(),r=wT(),i=Zg(),{paneLayout:a,sessions:o}=Xx(e,{disabled:t}),s=Ug(e)||e.id,c=PT(a,Object.fromEntries(o.map(e=>[e.id,e]))),l=FT(a);return(0,X.jsxs)(`div`,{className:`topbar-tab-shell ${t?`active`:``}`,role:`presentation`,children:[(0,X.jsx)(Bh,{className:`topbar-tab`,onClick:n=>{n.preventDefault(),!t&&i(e.id)},value:e.id,children:(0,X.jsxs)(`span`,{className:`topbar-tab-content`,children:[(0,X.jsx)(Ig,{content:e.path||e.id,children:(0,X.jsx)(`span`,{className:`topbar-tab-name`,children:s})}),(0,X.jsx)(ET,{cells:c,columns:l}),(0,X.jsx)(mm,{count:e.unreadCount??0,max:9})]})}),(0,X.jsx)(Em,{className:`topbar-close`,"aria-label":n(`action.close_workspace`),icon:(0,X.jsx)(pa,{size:14}),onClick:async t=>{t.stopPropagation(),await r(e.id)},size:`sm`})]})},BT={width:`auto`,minHeight:`auto`,padding:0,gap:0},VT={color:`var(--text-tertiary)`,fontSize:`var(--text-sm)`,fontWeight:`var(--font-normal)`},HT=({fullscreenController:e})=>{let t=Z(),n=Qt(),r=U(Rp),i=U(zp)??r[0]?.id??``,a=Zg(),[o,s]=Te($a),[c,l]=Te(J_),[u,d]=Te(K_),[f,p]=(0,H.useState)(!1);return(0,X.jsxs)(`header`,{className:`app-topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-tabs`,children:[r.length===0?(0,X.jsx)(Sh,{className:`topbar-empty-state`,style:BT,title:(0,X.jsx)(`span`,{className:`topbar-hint`,style:VT,children:t(`workspace.no_workspace`)})}):(0,X.jsx)(Rh,{"aria-label":t(`workspace.tabs`),className:`topbar-tabs-nav`,onValueChange:e=>{a(e)},value:i,children:(0,X.jsx)(zh,{className:`topbar-tablist`,children:r.map(e=>(0,X.jsx)(zT,{workspace:e,isActive:e.id===i},e.id))})}),(0,X.jsx)(Ig,{content:t(`tooltip.new_workspace`),children:(0,X.jsx)(Em,{"aria-label":t(`tooltip.new_workspace`),className:`topbar-add`,icon:(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:14}),onClick:()=>p(!0)})})]}),(0,X.jsxs)(`div`,{className:`topbar-actions`,children:[(0,X.jsx)(xT,{}),(0,X.jsx)(Ig,{content:t(`tooltip.quick_actions`),children:(0,X.jsxs)(`button`,{className:`topbar-btn topbar-quick-actions`,onClick:()=>s(!o),"aria-label":t(`tooltip.quick_actions`),children:[(0,X.jsx)($,{semantic:`nav.search`,size:14}),(0,X.jsx)(`span`,{className:`topbar-btn-label`,children:t(`tooltip.quick_actions`)})]})}),(0,X.jsx)(Ig,{content:t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),children:(0,X.jsx)(Em,{"aria-label":t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),className:`topbar-btn ${c?`topbar-btn--active`:`topbar-btn--muted`}`,icon:(0,X.jsx)($,{semantic:`nav.panelTerminal`,size:14}),onClick:()=>l(!c)})}),(0,X.jsx)(Ig,{content:t(u?`tooltip.show_files`:`tooltip.hide_files`),children:(0,X.jsx)(Em,{"aria-label":t(u?`tooltip.show_files`:`tooltip.hide_files`),className:`topbar-btn ${u?`topbar-btn--muted`:`topbar-btn--active`}`,icon:(0,X.jsx)($,{semantic:`nav.panelFiles`,size:14}),onClick:()=>d(!u)})}),(0,X.jsx)(Ig,{content:t(`settings.title`),children:(0,X.jsx)(Em,{"aria-label":t(`settings.title`),className:`topbar-btn`,"data-testid":`settings-open`,icon:(0,X.jsx)($,{semantic:`nav.settings`,size:14}),onClick:()=>n(`/settings`)})}),(0,X.jsx)(bT,{controller:e,className:`topbar-btn`,iconSize:14,dataTestId:`workspace-fullscreen-open`})]}),f?(0,X.jsx)(Qv,{onClose:()=>p(!1)}):null]})};function UT(e){let t=e;return e.fullscreenElement??t.webkitCurrentFullScreenElement??null}function WT(e){if(!e)return null;let t=e;return typeof t.requestFullscreen==`function`?t.requestFullscreen.bind(t):typeof t.webkitRequestFullscreen==`function`?t.webkitRequestFullscreen.bind(t):typeof t.webkitRequestFullScreen==`function`?t.webkitRequestFullScreen.bind(t):null}function GT(e){let t=e;return typeof e.exitFullscreen==`function`?e.exitFullscreen.bind(e):typeof t.webkitExitFullscreen==`function`?t.webkitExitFullscreen.bind(e):typeof t.webkitCancelFullScreen==`function`?t.webkitCancelFullScreen.bind(e):null}function KT(e){return!!(WT(e)&>(document))}function qT(e){return e instanceof Error&&e.message.trim().length>0?e.message:null}function JT(e){let t=Z(),n=W(sy),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=(0,H.useCallback)(()=>{n({kind:`info`,title:t(`workspace.fullscreen.unsupported_title`),body:t(`workspace.fullscreen.unsupported_body`)})},[n,t]);(0,H.useEffect)(()=>{let t=()=>{let t=e.current;i(KT(t)),o(!!(t&&UT(document)===t))};return t(),document.addEventListener(`fullscreenchange`,t),document.addEventListener(`webkitfullscreenchange`,t),()=>{document.removeEventListener(`fullscreenchange`,t),document.removeEventListener(`webkitfullscreenchange`,t)}},[e]);let c=(0,H.useCallback)(async()=>{let r=e.current,i=WT(r);if(!i||!GT(document)){s();return}try{await Promise.resolve(i())}catch(e){console.warn(`Failed to enter fullscreen`,e),n({kind:`warning`,title:t(`workspace.fullscreen.enter_failed_title`),body:qT(e)??t(`workspace.fullscreen.enter_failed_body`)})}},[n,s,t,e]),l=(0,H.useCallback)(async()=>{let e=GT(document);if(UT(document)){if(!e){s();return}try{await Promise.resolve(e())}catch(e){console.warn(`Failed to exit fullscreen`,e),n({kind:`warning`,title:t(`workspace.fullscreen.exit_failed_title`),body:qT(e)??t(`workspace.fullscreen.exit_failed_body`)})}}},[n,s,t]);return{supported:r,isFullscreen:a,enterFullscreen:c,exitFullscreen:l,toggleFullscreen:(0,H.useCallback)(async()=>{if(e.current&&UT(document)===e.current){await l();return}await c()},[c,l,e])}}var YT={left:0,top:0,right:1,bottom:1},XT=1e-9;function ZT(e,t,n){let r=QT(e,YT),i=r.find(e=>e.sessionId===t);if(!i)return null;let a=null,o=!1,s=1/0,c=1/0;for(let e of r){if(e.sessionId===t)continue;let r=$T(i,e,n);if(r===null)continue;let l=eE(i,e,n),u=tE(i,e,n);(a===null||l&&!o||l===o&&r<s-XT||l===o&&Math.abs(r-s)<=XT&&u<c-XT)&&(a=e,o=l,s=r,c=u)}return a?.sessionId??null}function QT(e,t){if(e.type===`leaf`)return e.sessionId?[{sessionId:e.sessionId,...t}]:[];let n=e.children??[];if(n.length===0)return[];if(n.length===1)return QT(n[0],t);let r=e.ratio??.5;if(e.direction===`horizontal`){let e=t.left+(t.right-t.left)*r;return[...QT(n[0],{...t,right:e}),...QT(n[1],{...t,left:e})]}let i=t.top+(t.bottom-t.top)*r;return[...QT(n[0],{...t,bottom:i}),...QT(n[1],{...t,top:i})]}function $T(e,t,n){switch(n){case`left`:{let n=e.left-t.right;return n>=-XT?Math.max(n,0):null}case`right`:{let n=t.left-e.right;return n>=-XT?Math.max(n,0):null}case`up`:{let n=e.top-t.bottom;return n>=-XT?Math.max(n,0):null}case`down`:{let n=t.top-e.bottom;return n>=-XT?Math.max(n,0):null}}}function eE(e,t,n){return n===`left`||n===`right`?nE(e.top,e.bottom,t.top,t.bottom):nE(e.left,e.right,t.left,t.right)}function tE(e,t,n){return Math.abs(n===`left`||n===`right`?rE(e.top,e.bottom)-rE(t.top,t.bottom):rE(e.left,e.right)-rE(t.left,t.right))}function nE(e,t,n,r){return Math.min(t,r)-Math.max(e,n)>XT}function rE(e,t){return(e+t)/2}var iE=[{id:`session.navigate.left`,direction:`left`},{id:`session.navigate.right`,direction:`right`},{id:`session.navigate.up`,direction:`up`},{id:`session.navigate.down`,direction:`down`}],aE=[{id:`workspace.previous`,step:-1},{id:`workspace.next`,step:1}];function oE(e){let t=ve(),n=U(Bp),r=U(Lp),i=U(rx),a=Xg(),o=Zg(),{persistUiState:s}=Bv(e);(0,H.useEffect)(()=>{if(!e)return;let c=c=>{let l=iE.find(({id:e})=>ox(c,sx(e,i)));if(l){c.preventDefault();let r=n;if(!r||r.id!==e)return;let i=r.uiState.activeSessionId;if(!i)return;let o=ZT(t.get(tv(e)),i,l.direction);if(!o)return;a({workspaceId:e,sessionId:o}),s({activeSessionId:o});return}let u=aE.find(({id:e})=>ox(c,sx(e,i)));if(!u)return;c.preventDefault();let d=n?.id??e,f=r.indexOf(d);if(f===-1)return;let p=r[f+u.step];p&&o(p)};return window.addEventListener(`keydown`,c),()=>window.removeEventListener(`keydown`,c)},[n,i,r,a,s,o,t,e])}var sE=220,cE=120;function lE(e,t,n){if(e>0)return e;let r=Number.parseFloat(t);return Number.isFinite(r)&&r>0?r:n}function uE(e){let[t,n]=Te(z_(e)),[r,i]=Te(B_(e)),a=(0,H.useRef)(!1),o=(0,H.useRef)(null),s=(0,H.useRef)(0),c=(0,H.useRef)(0),l=(0,H.useRef)(t),u=(0,H.useRef)(null),d=(0,H.useCallback)(e=>{e.preventDefault(),a.current=!0,s.current=e.clientX,c.current=lE(o.current?.offsetWidth??0,o.current?.style.width??``,t),l.current=c.current,document.body.classList.add(`is-resizing-panels`);let r=e=>{if(!a.current)return;let t=e.clientX-s.current,n=Math.max(sE,c.current+t);l.current=n,o.current&&(o.current.style.width=`${n}px`)},i=()=>{a.current=!1,document.body.classList.remove(`is-resizing-panels`),n(l.current),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[n,t]),f=(0,H.useRef)(!1),p=(0,H.useRef)(0),m=(0,H.useRef)(0),h=(0,H.useRef)(r);return{bottomPanelHeight:r,bottomPanelRef:u,handleBottomMouseDown:(0,H.useCallback)(e=>{e.preventDefault(),f.current=!0,p.current=e.clientY,m.current=lE(u.current?.offsetHeight??0,u.current?.style.height??``,r),h.current=m.current,document.body.classList.add(`is-resizing-panels`);let t=e=>{if(!f.current)return;let t=p.current-e.clientY,n=Math.max(cE,m.current+t);h.current=n,u.current&&(u.current.style.height=`${n}px`)},n=()=>{f.current=!1,document.body.classList.remove(`is-resizing-panels`),i(h.current),document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)},[i,r]),handleLeftMouseDown:d,leftPanelRef:o,leftPanelWidth:t}}function dE(){return{kind:`root`}}function fE(){return{createRequest:null,panelRefreshToken:0,mobileSheet:null,mobileFilesRoute:dE(),mobileActiveSessionId:null,mobileSelectionVersion:0}}var pE=Ap(e=>V(fE()));function mE(){let e=U(Bp),t=e?.id??`__workspace_placeholder__`,n=pE(t),r=U(zp),i=W(jp),a=U(Rp),o=U(p_(t)),s=U(u_(t)),c=U(m_(t)),l=U(W_),u=U(J_),d=U(K_),f=U(q_),{sessions:p,paneLayout:m}=Xx(e),h=U(Op),g=W(__),_=U(n),v=W(n),y=ve(),b=uE(t),x=Mx(t),S=Yx(),{createRequest:C,mobileActiveSessionId:w,mobileFilesRoute:T,mobileSheet:E,panelRefreshToken:D}=_;(0,H.useEffect)(()=>{if(!e){i(null);return}i(e.id)},[i,e]),(0,H.useEffect)(()=>{if(!e||o)return;let t=!1;return h(`git.status`,{workspaceId:e.id}).then(n=>{t||!n.ok||!n.data||y.set(p_(e.id),n.data)}).catch(e=>{t||console.error(`Failed to load git status:`,e)}),()=>{t=!0}},[h,o,y,e]);let O=(0,H.useCallback)(()=>{e&&(y.set(q_,`source-control`),g({visible:!0,workspaceId:e.id,inputValue:``}))},[g,y,e]),k=(0,H.useCallback)(()=>{v(e=>({...e,createRequest:{id:(e.createRequest?.id??0)+1,mode:`file`,baseDir:null}}))},[v]),A=(0,H.useCallback)(()=>{v(e=>({...e,createRequest:{id:(e.createRequest?.id??0)+1,mode:`folder`,baseDir:null}}))},[v]),j=(0,H.useCallback)(()=>{v(e=>e.createRequest===null?e:{...e,createRequest:null})},[v]),M=(0,H.useCallback)(()=>{v(e=>({...e,panelRefreshToken:e.panelRefreshToken+1}))},[v]),N=(0,H.useMemo)(()=>{let e=new Map(p.map(e=>[e.id,e]));return Array.from(new Set(Ev(m))).map(t=>e.get(t)).filter(e=>!!e)},[m,p]),P=(0,H.useMemo)(()=>{let e=new Set(N.map(e=>e.id));return[...N,...p.filter(t=>t.state!==`draft`&&!e.has(t.id))]},[N,p]),F=P.find(e=>e.id===w)??null,ee=(0,H.useCallback)(e=>{e&&!N.some(t=>t.id===e)&&p.some(t=>t.id===e&&t.state!==`draft`)&&x.appendSessionToMobileColumn(e),v(t=>({...t,mobileSelectionVersion:t.mobileSelectionVersion+1,mobileActiveSessionId:e}))},[w,N,x,p,v]),I=(0,H.useCallback)(e=>{x.appendSessionToMobileColumn(e),v(t=>({...t,mobileSelectionVersion:t.mobileSelectionVersion+1,mobileActiveSessionId:e}))},[x,v]),L=(0,H.useCallback)(async e=>{let t=w===e,r=y.get(n).mobileSelectionVersion,i=P.filter(t=>t.id!==e)[0]?.id??null;if(t&&v(t=>t.mobileActiveSessionId===e?{...t,mobileActiveSessionId:i}:t),!await S.closeSession(e,`remove`)){if(!t||y.get(n).mobileSelectionVersion!==r)return;v(t=>t.mobileActiveSessionId===i?{...t,mobileActiveSessionId:e}:t);return}v(e=>({...e,mobileSelectionVersion:e.mobileSelectionVersion+1}))},[w,P,n,S,v,y]),R=(0,H.useCallback)(e=>{e&&!N.some(t=>t.id===e)&&p.some(t=>t.id===e&&t.state!==`draft`)&&x.appendSessionToMobileColumn(e),v(t=>({...t,mobileSelectionVersion:t.mobileSelectionVersion+1,mobileActiveSessionId:e}))},[N,x,p,v]),z=(0,H.useCallback)(e=>{v(t=>({...t,mobileSheet:e,mobileFilesRoute:e===`files`?t.mobileFilesRoute:dE()}))},[v]),te=(0,H.useCallback)(()=>{v(e=>({...e,mobileSheet:null,mobileFilesRoute:dE()}))},[v]),ne=(0,H.useCallback)(e=>{v(t=>({...t,mobileFilesRoute:e}))},[v]);return{activeSession:F,activeFilePath:s,activeWorkspaceId:r,createRequest:C,diffPreview:c,focusMode:l,gitState:o,handleConsumeCreateRequest:j,handleOpenBranchSwitcher:O,handleOpenFileCreate:k,handleOpenFolderCreate:A,handleRefreshSidebarPanel:M,handleMobileSessionCreated:I,mainAreaMode:s||c?.source===`commit`?`editor`:`agent`,mobileActiveSessionId:w,mobileAgentSessions:P,mobileFilesRoute:T,mobileSheet:E,openMobileSheet:z,orderedSessions:N,paneLayout:m,panelRefreshToken:D,paneLayout:m,closeMobileSession:L,restoreMobileSession:R,selectMobileSession:ee,sessions:p,desktopSidebarView:f,setDesktopSidebarView:e=>y.set(q_,e),sidebarCollapsed:d,closeMobileSheet:te,terminalPanelVisible:u,updateMobileFilesRoute:ne,workspace:e,workspaces:a,workspaceId:t,...b}}function hE(e,t,n){return e===t?n:e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:e}function gE(e,t,n){let r=Object.entries(e).map(([e,r])=>{let i=hE(e,t,n);return i===e?[e,r]:[i,{...r,path:i}]});return Object.fromEntries(r)}function _E({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i}){let a=Z(),o=U(Qg(e)),s=U($g(e)),c=U(u_(e)),l=U(Op),u=W(Qg(e)),d=W($g(e)),f=W(u_(e)),p=W(d_(e)),m=W(l_(e)),{openLocation:h}=Cy(e),g=U(e_(e)),_=W(e_(e)),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(null),O=(0,H.useRef)(t),k=(0,H.useRef)(0),A=(0,H.useCallback)(async()=>{if(!e||v)return!1;y(!0);let t=await l(`file.readTree`,{workspaceId:e});if(t.ok&&t.data){let e=new Map;return e.set(`.`,t.data.children),u(e),_(new Set),y(!1),!0}return t.ok||console.error(`Failed to load file tree:`,t.error?.message),y(!1),!1},[e,v,l,u,_]),j=(0,H.useCallback)(async t=>{let n=g.has(t)&&o?.has(t);if(!e||b===t||n)return;x(t);let r=await l(`file.readTree`,{workspaceId:e,subPath:t});r.ok&&r.data&&(u(e=>{if(!e)return e;let n=new Map(e);return n.set(t,r.data.children),n}),_(e=>new Set(e).add(t))),x(null)},[e,b,g,o,l,u,_]),M=(0,H.useCallback)(async t=>{if(!e)return[];let n=await l(`file.search`,{workspaceId:e,query:t,limit:10});return!n.ok||!n.data?[]:n.data.files},[l,e]),N=(0,H.useCallback)((e,t)=>{C({mode:e,draftPath:t?`${t.replace(/\/+$/,``)}/`:``,error:null})},[]),P=(0,H.useCallback)(()=>{C(null)},[]),F=(0,H.useCallback)(({path:e,name:t,kind:n})=>{T({fromPath:e,currentName:t,nextName:t,kind:n,error:null})},[]),ee=(0,H.useCallback)(()=>{T(null)},[]),I=(0,H.useCallback)(e=>{T(t=>t&&{...t,nextName:e,error:null})},[]),L=(0,H.useCallback)(e=>{C(t=>t&&{...t,draftPath:e,error:null})},[]),R=(0,H.useCallback)(async()=>{if(!S)return;let t=S.draftPath.trim();if(!t){C(e=>e&&{...e,error:a(`file.path_required`)});return}if(S.mode===`file`&&t.endsWith(`/`)){C(e=>e&&{...e,error:a(`file.invalid_file_path`)});return}let n=await l(S.mode===`file`?`file.create`:`file.mkdir`,{workspaceId:e,path:t});if(!n.ok){C(e=>e&&{...e,error:n.error?.message??a(`file.create_failed`)});return}await A(),P(),S.mode===`file`&&h({workspaceId:e,path:t,source:`manual`})},[S,l,e,A,P,h,a]),z=(0,H.useCallback)(async()=>{if(!w)return;let t=w.nextName.trim();if(!t){T(e=>e&&{...e,error:a(`file.rename_required`)});return}if(t.includes(`/`)||t.includes(`\\`)){T(e=>e&&{...e,error:a(`file.rename_invalid_name`)});return}if(t===w.currentName){T(null);return}let n=w.fromPath.lastIndexOf(`/`),r=n===-1?``:w.fromPath.slice(0,n),i=r?`${r}/${t}`:t,o=await l(`file.rename`,{workspaceId:e,fromPath:w.fromPath,toPath:i});if(!o.ok){T(e=>e&&{...e,error:o.error?.message??a(`file.rename_failed`)});return}f(e=>e&&hE(e,w.fromPath,i)),m(e=>gE(e,w.fromPath,i)),await A(),T(null)},[l,A,w,f,m,a,e]),te=(0,H.useCallback)(()=>{D(null)},[]),ne=(0,H.useCallback)(async()=>{if(!E)return;let t=await l(`file.delete`,{workspaceId:e,path:E.path});if(!t.ok){D(e=>e&&{...e,error:t.error?.message??a(`file.delete_failed`)});return}c===E.path&&f(null),m(e=>{if(!(E.path in e))return e;let t={...e};return delete t[E.path],t}),await A(),D(null)},[E,l,e,c,f,m,A,a]);return(0,H.useEffect)(()=>{!o&&!v&&A()},[o,v,A]),(0,H.useEffect)(()=>{s&&!v&&(d(!1),A())},[s,v,A,d]),(0,H.useEffect)(()=>{t<=O.current||v||(O.current=t,A())},[t,v,A]),(0,H.useEffect)(()=>{!n||n.id<=k.current||(k.current=n.id,N(n.mode,n.baseDir),r?.())},[n,N,r]),{activeFilePath:c,createDialog:S,fileTree:o,isLoading:v,isLoadingDir:b,renameDialog:w,pendingDelete:E,cancelDelete:te,confirmDelete:ne,handleSelectFile:(0,H.useCallback)(t=>{p(c_(t)),h({workspaceId:e,path:t,source:`file-tree`}),i?.(t)},[i,h,p,e]),loadChildren:j,loadSearchResults:M,openCreateDialog:N,openRenameDialog:F,requestDelete:D,updateRenameDraft:I,submitRenameDialog:z,closeRenameDialog:ee,submitCreateDialog:R,updateDraftPath:L,closeCreateDialog:P}}function vE(e,t,n){let r=e(t);return r===t?n:r}function yE(e,t){let n=e.includes(`\\`)?`\\`:`/`,r=e.replace(/[\\/]+$/,``),i=t===`.`?[]:t.split(/[\\/]+/).map(e=>e.trim()).filter(Boolean);return i.length>0?`${r}${n}${i.join(n)}`:r}function bE(e){if(e.kind===`dir`)return e.path===`.`?void 0:e.path;let t=Math.max(e.path.lastIndexOf(`/`),e.path.lastIndexOf(`\\`));if(!(t<=0))return e.path.slice(0,t)}function xE({workspacePath:e,target:t,createShellTerminal:n,openCreateDialog:r,openRenameDialog:i,requestDelete:a}){let o=Z();return(0,H.useMemo)(()=>{if(!t)return[];let{node:s}=t,c=s.path,l=e?yE(e,c):null,u=bE(s),d=[];return s.kind===`dir`&&d.push({id:`create`,title:vE(o,`file.context_section_create`,`Create`),items:[{id:`new-file`,label:vE(o,`file.new_file`,`New File`),onSelect:()=>r(`file`,s.path)},{id:`new-folder`,label:vE(o,`file.new_folder`,`New Folder`),onSelect:()=>r(`folder`,s.path)}]}),d.push({id:`edit`,title:vE(o,`file.context_section_edit`,`Edit`),items:[{id:`rename`,label:vE(o,`file.rename`,`Rename`),onSelect:()=>i({path:s.path,name:s.name,kind:s.kind})},{id:`delete`,label:vE(o,`file.delete`,`Delete`),tone:`danger`,onSelect:()=>a({path:s.path,name:s.name,error:null})}]},{id:`path`,title:vE(o,`file.context_section_path`,`Path`),items:[{id:`copy-relative-path`,label:vE(o,`file.copy_relative_path`,`Copy Relative Path`),onSelect:()=>kS(c)},{id:`copy-absolute-path`,label:vE(o,`file.copy_absolute_path`,`Copy Absolute Path`),disabled:!l,onSelect:()=>l?kS(l):void 0}]},{id:`terminal`,title:vE(o,`file.context_section_terminal`,`Terminal`),items:[{id:`open-in-terminal`,label:vE(o,`file.open_in_terminal`,`Open in Terminal`),onSelect:()=>n(u?{cwdPath:u}:{})}]}),d},[n,r,i,a,o,t,e])}function SE(e,t){return Math.abs(t.x-e.x)>10||Math.abs(t.y-e.y)>10}function CE(){let[e,t]=(0,H.useState)(null),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(!1),s=(0,H.useRef)(null),c=(0,H.useCallback)(()=>{s.current&&=(window.clearTimeout(s.current.timer),null)},[]),l=(0,H.useCallback)(()=>{c(),r(null),a(!1)},[c]),u=(0,H.useCallback)((e,n)=>{e.preventDefault(),c(),t(n),r({x:e.clientX,y:e.clientY}),a(!1)},[c]),d=(0,H.useCallback)((e,n)=>{e.pointerType!==`mouse`&&(c(),s.current={pointerId:e.pointerId,startPoint:{x:e.clientX,y:e.clientY},timer:window.setTimeout(()=>{t(n),r(null),a(!0),o.current=!0,s.current=null},450),target:n})},[c]),f=(0,H.useCallback)(e=>{let t=s.current;!t||t.pointerId!==e.pointerId||SE(t.startPoint,{x:e.clientX,y:e.clientY})&&c()},[c]),p=(0,H.useCallback)(e=>{e!==void 0&&s.current?.pointerId!==e||c()},[c]),m=(0,H.useCallback)(()=>{let e=o.current;return o.current=!1,e},[]);return(0,H.useEffect)(()=>()=>c(),[c]),{contextTarget:e,desktopAnchorPoint:n,mobileOpen:i,isOpen:(0,H.useMemo)(()=>n!==null||i,[n,i]),closeMenu:l,openDesktopMenu:u,beginLongPress:d,updateLongPress:f,cancelLongPress:p,consumeSuppressedClick:m}}var wE=8;function TE(e){return e.flatMap(e=>e.items.filter(e=>!e.disabled))}function EE(e,t,n){if(e.length===0)return null;if(t===null)return n===1?e[0]?.id??null:e[e.length-1]?.id??null;let r=e.findIndex(e=>e.id===t);if(r===-1)return n===1?e[0]?.id??null:e[e.length-1]?.id??null;let i=r+n;return e[i]?e[i].id:n===1?e[0]?.id??null:e[e.length-1]?.id??null}async function DE(e,t){try{await e.onSelect()}catch(e){console.error(`File context menu action failed`,e)}finally{t()}}function OE(e,t){return`file-context-menu-item-${e}-${t}`}function kE({title:e,open:t,mode:n,sections:r,anchorPoint:i=null,restoreFocusTo:a=null,onClose:o}){let s=(0,H.useRef)(null),c=(0,H.useRef)(t),l=(0,H.useRef)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)({left:wE,top:wE}),m=(0,H.useMemo)(()=>TE(r),[r]),h=(0,H.useMemo)(()=>{if(u)for(let e of r){let t=e.items.find(e=>e.id===u);if(t)return OE(e.id,t.id)}},[u,r]);if((0,H.useEffect)(()=>{let e=c.current;t&&!e&&d(null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),!t&&e&&a?.isConnected&&(l.current=window.setTimeout(()=>{a.isConnected&&a.focus(),l.current=null},0)),c.current=t},[t,a]),(0,H.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,H.useLayoutEffect)(()=>{if(!t||n!==`desktop`||!i||!s.current)return;let e=s.current.getBoundingClientRect();p({left:Math.min(Math.max(wE,i.x),Math.max(wE,window.innerWidth-e.width-wE)),top:Math.min(Math.max(wE,i.y),Math.max(wE,window.innerHeight-e.height-wE))})},[i,n,t,r]),(0,H.useLayoutEffect)(()=>{!t||n!==`desktop`||s.current?.focus()},[n,t]),(0,H.useEffect)(()=>{if(!t||n!==`desktop`)return;let e=e=>{e.target instanceof Node&&(s.current?.contains(e.target)||o())};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[n,o,t]),!t)return null;let g=e=>{d(EE(m,u,e))},_=(0,X.jsx)(`div`,{className:`file-context-menu-layer`,children:(0,X.jsx)(`div`,{ref:s,role:`menu`,tabIndex:-1,"aria-label":e,"aria-orientation":`vertical`,"aria-activedescendant":h,className:`file-context-menu`,style:{position:`fixed`,left:f.left,top:f.top},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),o();return}if(e.key===`ArrowDown`){e.preventDefault(),g(1);return}if(e.key===`ArrowUp`){e.preventDefault(),g(-1);return}if(e.key!==`Enter`&&e.key!==` `)return;let t=m.find(e=>e.id===u);t&&(e.preventDefault(),DE(t,o))},children:r.map(e=>(0,X.jsxs)(`div`,{className:`file-context-menu__section`,children:[(0,X.jsx)(`h3`,{className:`file-context-menu__section-title`,children:e.title}),(0,X.jsx)(`div`,{className:`file-context-menu__section-items`,children:e.items.map(t=>(0,X.jsx)(`button`,{id:OE(e.id,t.id),type:`button`,role:`menuitem`,tabIndex:-1,disabled:t.disabled,"data-active":u===t.id?`true`:void 0,className:Y(`file-context-menu__item`,t.tone===`danger`?`file-context-menu__item--danger`:null),onFocus:()=>{t.disabled||d(t.id)},onMouseEnter:()=>{t.disabled||d(t.id)},onClick:()=>{t.disabled||DE(t,o)},children:t.label},t.id))})]},e.id))})});return n===`mobile`?(0,X.jsx)(fm,{title:e,onClose:o,body:(0,X.jsx)(`div`,{className:`file-context-menu__sheet`,children:r.map(e=>(0,X.jsxs)(`section`,{className:`file-context-menu__sheet-section`,children:[(0,X.jsx)(`h3`,{children:e.title}),(0,X.jsx)(`div`,{className:`file-context-menu__sheet-actions`,children:e.items.map(e=>(0,X.jsx)(`button`,{type:`button`,disabled:e.disabled,className:Y(`file-context-menu__sheet-action`,e.tone===`danger`?`file-context-menu__sheet-action--danger`:null),onClick:()=>{e.disabled||DE(e,o)},children:e.label},e.id))})]},e.id))})}):(0,X.jsx)($p,{children:_})}function AE(e,t){if(e.kind===`dir`)return t?`file.folder.open`:`file.folder.closed`;switch(e.name.split(`.`).pop()?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`mjs`:case`cjs`:case`py`:case`go`:case`rs`:case`java`:return`file.type.code`;case`json`:case`yaml`:case`yml`:case`toml`:case`lock`:return`file.type.data`;case`md`:case`txt`:return`file.type.doc`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:case`webp`:return`file.type.media`;default:return`file.type.default`}}var jE=new Set([`app`,`packages`,`src`]),ME=200,NE={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},PE={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`},FE={display:`block`,width:`auto`,minHeight:`auto`,padding:0,gap:0,textAlign:`left`},IE={margin:0,color:`inherit`,fontSize:`inherit`,fontWeight:`inherit`};function LE({title:e}){return(0,X.jsx)(Sh,{className:`file-tree-empty`,style:NE,title:(0,X.jsx)(`p`,{style:PE,children:e})})}function RE({className:e,title:t}){return(0,X.jsx)(Sh,{className:e,style:FE,title:(0,X.jsx)(`p`,{style:IE,children:t})})}function zE(){return{searchValue:``,resolvedQuery:``,searchResults:[],searchLoading:!1,contextTargetPath:null}}function BE(e,t,n){return`${e}::${t}::${n?`search`:`plain`}`}var VE=Ap(e=>V(zE()));function HE(e){return[...new Set([...e].map(YE).filter(Boolean))].sort((e,t)=>e.localeCompare(t)).slice(0,ME)}var UE=({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i,onVisibleCountChange:a,collapseVersion:o=0,variant:s=`desktop`,showSearch:c=!0})=>{let[l,u]=Te(VE(BE(e,s,c))),d=Z(),f=U(Ip(e)),p=U(t_(e)),m=W(t_(e)),{persistUiState:h}=Bv(e),{createShellTerminal:g}=cT(e),{activeFilePath:_,createDialog:v,fileTree:y,isLoading:b,isLoadingDir:x,renameDialog:S,pendingDelete:C,cancelDelete:w,confirmDelete:T,handleSelectFile:E,loadChildren:D,loadSearchResults:O,openCreateDialog:k,openRenameDialog:A,requestDelete:j,updateRenameDraft:M,submitRenameDialog:N,closeRenameDialog:P,submitCreateDialog:F,updateDraftPath:ee,closeCreateDialog:I}=_E({workspaceId:e,refreshToken:t,createRequest:n,onCreateRequestConsumed:r,onSelectFile:i}),{contextTargetPath:L,resolvedQuery:R,searchLoading:z,searchResults:te,searchValue:ne}=l,re=ne.trim(),ie=(0,H.useMemo)(()=>y?QE(ZE(y)):[],[y]),ae=(0,H.useRef)(0),{contextTarget:B,desktopAnchorPoint:oe,isOpen:se,closeMenu:ce,openDesktopMenu:V,beginLongPress:le,updateLongPress:ue,cancelLongPress:de,consumeSuppressedClick:fe}=CE(),pe=re.length>0,me=(0,H.useMemo)(()=>pe?te.length:XE(ie),[pe,te.length,ie]),he=(0,H.useMemo)(()=>ie.filter(e=>e.kind===`dir`&&jE.has(e.name.toLowerCase())).map(e=>e.path),[ie]),ge=xE({workspacePath:f?.path??null,target:B,createShellTerminal:g,openCreateDialog:k,openRenameDialog:A,requestDelete:({path:e,name:t,error:n})=>j({path:e,name:t,error:n})});(0,H.useEffect)(()=>{p!==null||!f||f.uiState.fileTreeExpandedDirs!==void 0&&m(new Set(HE(f.uiState.fileTreeExpandedDirs)))},[p,m,f]);let _e=(0,H.useCallback)(e=>{let t=HE(e);m(new Set(t)),h({fileTreeExpandedDirs:t})},[h,m]);(0,H.useEffect)(()=>{let e=!1;if(!pe)return u(e=>e.searchResults.length>0||e.resolvedQuery||e.searchLoading?{...e,resolvedQuery:``,searchResults:[],searchLoading:!1}:e),ae.current+=1,()=>{e=!0};if(R===re&&!z)return;u(e=>({...e,searchLoading:!0}));let t=++ae.current,n=setTimeout(()=>{(async()=>{let n=await O(re);e||t!==ae.current||u(e=>({...e,resolvedQuery:re,searchResults:n,searchLoading:!1}))})()},150);return()=>{e=!0,clearTimeout(n)}},[pe,O,R,z,re,u]),(0,H.useEffect)(()=>{a?.(me,z||b)},[b,a,z,me]),(0,H.useEffect)(()=>{o<=0||_e([])},[_e,o]),(0,H.useEffect)(()=>{B&&u(e=>e.contextTargetPath===B.node.path?e:{...e,contextTargetPath:B.node.path})},[B,u]);let ve=(0,H.useCallback)(()=>{u(e=>e.contextTargetPath===null?e:{...e,contextTargetPath:null}),ce()},[ce,u]),ye=(0,H.useCallback)((e,t,n)=>{t.kind===`file`&&E(t.path),u(e=>({...e,contextTargetPath:t.path})),V(e,{node:t,surface:n,triggerElement:e.currentTarget})},[E,V,u]),be=(0,H.useCallback)((e,t,n)=>{le(e,{node:t,surface:n,triggerElement:e.currentTarget})},[le]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`file-tree-shell file-tree-shell--${s}`,children:[c?(0,X.jsxs)(`label`,{className:`file-tree-search ${s===`desktop`?`file-tree-search--desktop`:``}`,htmlFor:`file-tree-search-${e}`,children:[(0,X.jsx)($,{semantic:`file.action.search`,size:14,className:`file-tree-search-icon`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{id:`file-tree-search-${e}`,className:`file-tree-search-input`,type:`search`,value:ne,onChange:e=>u(t=>({...t,searchValue:e.target.value})),placeholder:d(`action.search_files`),"aria-label":d(`action.search_files`)})]}):null,(0,X.jsx)(`div`,{className:`file-tree`,children:pe?z?(0,X.jsx)(LE,{title:d(`common.loading`)}):te.length>0?te.map(t=>(0,X.jsx)(WE,{workspaceId:e,node:t,variant:s,selectedPath:_,isContextTarget:L===t.path,onSelectFile:E,onOpenContextMenu:ye,onBeginLongPress:be,onUpdateLongPress:ue,onCancelLongPress:de,consumeSuppressedClick:fe},t.path)):(0,X.jsx)(LE,{title:d(`command.no_results`)}):y&&y.size>0?ie.map(t=>(0,X.jsx)(GE,{workspaceId:e,node:t,depth:0,variant:s,expandedDirs:p,defaultExpandedRootPaths:he,selectedPath:_,contextTargetPath:L,onRequestCreate:k,onSelectFile:E,onLoadChildren:D,onToggleDirs:_e,isLoadingDir:x,onOpenContextMenu:ye,onBeginLongPress:be,onUpdateLongPress:ue,onCancelLongPress:de,consumeSuppressedClick:fe},t.path)):(0,X.jsx)(LE,{title:d(b?`common.loading`:`file.title`)})})]}),(0,X.jsx)(KE,{dialog:v,onCancel:I,onConfirm:F,onDraftPathChange:ee}),(0,X.jsx)(qE,{pendingDelete:C,onCancel:w,onConfirm:T}),(0,X.jsx)(JE,{dialog:S,onCancel:P,onConfirm:N,onDraftChange:M}),(0,X.jsx)(kE,{title:d(`file.context_menu_title`),open:se&&ge.length>0,mode:s===`mobile`?`mobile`:`desktop`,sections:ge,anchorPoint:oe,restoreFocusTo:B?.triggerElement??null,onClose:ve})]})},WE=({workspaceId:e,node:t,variant:n,selectedPath:r,isContextTarget:i,onSelectFile:a,onOpenContextMenu:o,onBeginLongPress:s,onUpdateLongPress:c,onCancelLongPress:l,consumeSuppressedClick:u})=>{let d=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``,f=n===`mobile`?`mobile`:`search`;return(0,X.jsxs)(`div`,{className:`tree-item tree-item--file ${r===t.path?`selected`:``} ${i?`tree-item--context-target`:``}`,draggable:n===`desktop`?!0:void 0,onDragStart:n===`desktop`?r=>{n!==`desktop`||!r.dataTransfer||fC(r.dataTransfer,{workspaceId:e,path:t.path,kind:t.kind})}:void 0,onClick:()=>{u()||a(t.path)},onContextMenu:n===`desktop`?e=>o(e,t,f):void 0,onPointerDown:e=>s(e,t,f),onPointerMove:c,onPointerCancel:e=>l(e.pointerId),onPointerUp:e=>l(e.pointerId),style:{paddingLeft:12},children:[(0,X.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:AE(t,!1),size:14})}),(0,X.jsxs)(`span`,{className:`tree-search-labels`,children:[(0,X.jsx)(`span`,{className:`tree-label`,children:t.name}),d?(0,X.jsx)(`span`,{className:`tree-search-path`,children:d}):null]})]})},GE=({workspaceId:e,node:t,depth:n,variant:r,expandedDirs:i,defaultExpandedRootPaths:a,selectedPath:o,contextTargetPath:s,onRequestCreate:c,onSelectFile:l,onLoadChildren:u,onToggleDirs:d,isLoadingDir:f,onOpenContextMenu:p,onBeginLongPress:m,onUpdateLongPress:h,onCancelLongPress:g,consumeSuppressedClick:_})=>{let v=Z(),y=t.kind===`dir`,b=y&&(i===null?n===0&&a.includes(t.path):i.has(t.path)),x=(0,H.useRef)(!1);(0,H.useEffect)(()=>{t.children&&(x.current=!1)},[t.children]),(0,H.useEffect)(()=>{y&&b&&!t.children&&!x.current&&(x.current=!0,u(t.path))},[y,b,t.children,t.path,u]);let S=()=>{if(r===`mobile`&&_())return;if(!y){l(t.path);return}let e=new Set(i??a);b?e.delete(t.path):(e.add(t.path),t.children||u(t.path)),d(e)},C=n=>{r!==`desktop`||!n.dataTransfer||fC(n.dataTransfer,{workspaceId:e,path:t.path,kind:t.kind})},w=n*14+16;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`tree-item tree-item--${t.kind} ${o===t.path?`selected`:``} ${s===t.path?`tree-item--context-target`:``}`,draggable:r===`desktop`?!0:void 0,onDragStart:r===`desktop`?C:void 0,onClick:S,onContextMenu:r===`desktop`?e=>p(e,t,`tree`):void 0,onPointerDown:r===`mobile`?e=>m(e,t,`mobile`):void 0,onPointerMove:r===`mobile`?h:void 0,onPointerCancel:r===`mobile`?e=>g(e.pointerId):void 0,onPointerUp:r===`mobile`?e=>g(e.pointerId):void 0,style:{paddingLeft:w},children:[(0,X.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`,children:y?b?(0,X.jsx)(_i,{size:14}):(0,X.jsx)(yi,{size:14}):null}),(0,X.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:AE(t,b),size:14})}),(0,X.jsx)(`span`,{className:`tree-label`,children:t.name}),r===`desktop`?(0,X.jsx)(`div`,{className:`tree-item-actions`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ig,{content:v(`file.new_file`),children:(0,X.jsx)(Em,{"aria-label":`${v(`file.new_file`)} ${t.path}`,className:`git-row-action`,icon:(0,X.jsx)($,{semantic:`file.action.new`,size:12}),onClick:e=>{e.stopPropagation(),c(`file`,t.path)},size:`sm`})}),(0,X.jsx)(Ig,{content:v(`file.new_folder`),children:(0,X.jsx)(Em,{"aria-label":`${v(`file.new_folder`)} ${t.path}`,className:`git-row-action`,icon:(0,X.jsx)($,{semantic:`file.action.newFolder`,size:12}),onClick:e=>{e.stopPropagation(),c(`folder`,t.path)},size:`sm`})})]}):null}):null]}),y&&b&&t.children&&(0,X.jsxs)(`div`,{className:`tree-children`,children:[QE(t.children).map(t=>(0,X.jsx)(GE,{workspaceId:e,node:t,depth:n+1,variant:r,expandedDirs:i,selectedPath:o,contextTargetPath:s,onRequestCreate:c,onSelectFile:l,onLoadChildren:u,onToggleDirs:d,defaultExpandedRootPaths:a,isLoadingDir:f,onOpenContextMenu:p,onBeginLongPress:m,onUpdateLongPress:h,onCancelLongPress:g,consumeSuppressedClick:_},t.path)),t.children.length===0&&!f&&(0,X.jsx)(RE,{className:`tree-empty-hint`,title:v(`file.empty_directory`)})]}),y&&b&&!t.children&&f===t.path&&(0,X.jsx)(RE,{className:`tree-loading`,title:v(`common.loading`)})]})},KE=({dialog:e,onCancel:t,onConfirm:n,onDraftPathChange:r})=>{let i=Z(),a=(0,H.useRef)(null);if(!e)return null;let o=`file-path-helper`,s=e.error?`file-path-error`:void 0,c=e.mode===`file`?i(`file.path_helper_file`):i(`file.path_helper_folder`),l=[o,s].filter(Boolean).join(` `);return(0,X.jsxs)(jm,{initialFocus:()=>a.current,onOpenChange:t,open:!0,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsxs)(Pm,{children:[e.mode===`file`?(0,X.jsx)($,{"aria-hidden":`true`,semantic:`file.action.new`,size:16}):(0,X.jsx)($,{"aria-hidden":`true`,semantic:`file.action.newFolder`,size:16}),(0,X.jsx)(`span`,{children:e.mode===`file`?i(`file.new_file`):i(`file.new_folder`)})]}),(0,X.jsx)(Em,{"aria-label":i(`action.close`),icon:(0,X.jsx)(pa,{size:14}),onClick:t,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`file-path`,children:i(`file.path`)}),(0,X.jsx)(rh,{id:`file-path`,ref:a,value:e.draftPath,onChange:e=>r(e.target.value),placeholder:e.mode===`file`?`src/demo/new-file.ts`:`src/demo/new-folder`,"aria-describedby":l,invalid:!!e.error,autoFocus:!0}),(0,X.jsx)(`span`,{id:o,className:`dialog-helper`,children:c}),e.error?(0,X.jsx)(`span`,{id:s,className:`form-error`,role:`alert`,children:e.error}):null]})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:t,children:i(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{n()},children:i(`action.confirm`)})]})]})},qE=({pendingDelete:e,onCancel:t,onConfirm:n})=>{let r=Z();return e?(0,X.jsx)(Bm,{open:!0,onOpenChange:t,title:r(`file.delete`),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`file.delete_confirm`,{name:e.name})}),e.error?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:e.error}):null]}),cancelText:r(`action.cancel`),closeLabel:r(`action.close`),confirmText:r(`action.confirm`),onConfirm:()=>{n()},tone:`danger`}):null},JE=({dialog:e,onCancel:t,onConfirm:n,onDraftChange:r})=>{let i=Z(),a=(0,H.useRef)(null);if(!e)return null;let o=`file-rename-helper`,s=e.error?`file-rename-error`:void 0,c=[o,s].filter(Boolean).join(` `);return(0,X.jsxs)(jm,{initialFocus:()=>a.current,onOpenChange:t,open:!0,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsx)(Pm,{children:(0,X.jsx)(`span`,{children:i(`file.rename`)})}),(0,X.jsx)(Em,{"aria-label":i(`action.close`),icon:(0,X.jsx)(pa,{size:14}),onClick:t,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`file-rename`,children:i(`file.rename_name`)}),(0,X.jsx)(rh,{id:`file-rename`,ref:a,value:e.nextName,onChange:e=>r(e.target.value),"aria-describedby":c,invalid:!!e.error,autoFocus:!0}),(0,X.jsx)(`span`,{id:o,className:`dialog-helper`,children:i(`file.rename_helper`)}),e.error?(0,X.jsx)(`span`,{id:s,className:`form-error`,role:`alert`,children:e.error}):null]})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:t,children:i(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{n()},children:i(`action.confirm`)})]})]})};function YE(e){return e.trim().replace(/^\.\/+/,``).replace(/\/+$/,``)}function XE(e){return e.reduce((e,t)=>t.kind===`file`?e+1:e+XE(t.children??[]),0)}function ZE(e){let t=n=>n.map(n=>n.kind===`dir`&&e.has(n.path)?{...n,children:t(e.get(n.path))}:n);return t(e.get(`.`)??[])}function QE(e){return[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`dir`?-1:1)}function $E({workspaceId:e,onSelectFile:t,title:n}){let r=Z(),i=U(l_(e)),a=U(u_(e)),o=W(d_(e)),{openLocation:s}=Cy(e),{closeAll:c,closePath:l}=Iw(e),[u,d]=(0,H.useState)(!1),[,f]=(0,H.useState)(0);(0,H.useEffect)(()=>{let t=Mw(e,()=>f(e=>e+1));return f(e=>e+1),t},[e]);let p=a&&!(a in i)&&Aw(e,a)?a:null,m=p?[...Nw(i),p].sort():Nw(i),h=n??r(`workspace.sidebar.open_editors`),g=r(`workspace.open_editors.title_with_count`,{count:m.length,title:h}),_=m.length>0,v=_&&!u,y=r(v?`workspace.open_editors.collapse_label`:`workspace.open_editors.expand_label`);return(0,X.jsxs)(`section`,{className:`workspace-sidebar-section`,children:[(0,X.jsxs)(`div`,{className:`workspace-open-editors__header`,children:[(0,X.jsxs)(`div`,{className:`workspace-open-editors__header-main`,children:[(0,X.jsx)(Ig,{content:y,children:(0,X.jsx)(Em,{"aria-label":y,"aria-expanded":_?v:void 0,className:`workspace-open-editors__toggle`,disabled:!_,icon:v?(0,X.jsx)(_i,{size:14}):(0,X.jsx)(yi,{size:14}),size:`sm`,onClick:()=>d(e=>!e)})}),(0,X.jsx)(`h2`,{className:`workspace-sidebar-section__title workspace-open-editors__title`,children:(0,X.jsx)(`span`,{className:`workspace-open-editors__title-text`,children:g})})]}),(0,X.jsx)(`button`,{type:`button`,className:`workspace-open-editors__close-all`,disabled:m.length===0,onClick:()=>c(),children:r(`action.close_all`)})]}),v?(0,X.jsx)(`div`,{className:`workspace-open-editors`,children:m.map(n=>(0,X.jsxs)(`div`,{className:`workspace-open-editors__row`,children:[(0,X.jsx)(`button`,{type:`button`,className:`workspace-open-editors__item ${a===n?`workspace-open-editors__item--active`:``}`,"aria-current":a===n?`true`:void 0,"aria-label":n,title:n,onClick:()=>{o(c_(n)),s({workspaceId:e,path:n,source:`manual`}),t?.(n)},children:(0,X.jsx)(`span`,{className:`workspace-open-editors__item-label`,children:n})}),(0,X.jsx)(Ig,{content:r(`action.close`),children:(0,X.jsx)(Em,{"aria-label":r(`workspace.open_editors.close_path`,{path:n}),className:`workspace-open-editors__item-close`,icon:(0,X.jsx)(pa,{size:14}),size:`sm`,onClick:()=>l(n)})})]},n))}):null]})}function eD({onOpenFileCreate:e,onOpenFolderCreate:t,onCollapseAll:n}){let r=Z();return(0,X.jsxs)(`div`,{className:`workspace-sidebar-section__header`,children:[(0,X.jsx)(`h2`,{className:`workspace-sidebar-section__title`,children:r(`workspace.sidebar.workspace`)}),(0,X.jsxs)(`div`,{className:`workspace-sidebar-panel__actions workspace-sidebar-section__actions`,children:[(0,X.jsx)(Ig,{content:r(`file.new_file`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":r(`file.new_file`),icon:(0,X.jsx)($,{semantic:`file.action.new`,size:14}),onClick:e,size:`sm`})}),(0,X.jsx)(Ig,{content:r(`file.new_folder`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":r(`file.new_folder`),icon:(0,X.jsx)($,{semantic:`file.action.newFolder`,size:14}),onClick:t,size:`sm`})}),(0,X.jsx)(Ig,{content:r(`file.collapse_all`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":r(`file.collapse_all`),icon:(0,X.jsx)(xi,{size:14}),onClick:n,size:`sm`})})]})]})}var tD=({workspaceId:e,createRequest:t,onCreateRequestConsumed:n,onOpenFileCreate:r,onOpenFolderCreate:i})=>{let a=Z(),[o,s]=(0,H.useState)(0);return(0,X.jsxs)(`div`,{className:`workspace-sidebar-view`,children:[(0,X.jsx)(aS,{title:a(`workspace.sidebar.explorer`)}),(0,X.jsxs)(`div`,{className:`workspace-sidebar-panel__body workspace-sidebar-panel__body--stacked`,children:[(0,X.jsx)($E,{workspaceId:e}),(0,X.jsxs)(`section`,{className:`workspace-sidebar-section workspace-sidebar-section--fill`,children:[(0,X.jsx)(eD,{onOpenFileCreate:r,onOpenFolderCreate:i,onCollapseAll:()=>s(e=>e+1)}),(0,X.jsx)(UE,{workspaceId:e,createRequest:t,onCreateRequestConsumed:n,collapseVersion:o,variant:`desktop`,showSearch:!1})]})]})]})};function nD(e){return e?.source===`commit`}var rD=180*1e3,iD={push:`git.operation_push`,pull:`git.operation_pull`,fetch:`git.operation_fetch`};function aD(e,t){return e&&t?`${e}/${t}`:null}function oD(e){let t=Z(),n=U(Op),r=W(sy),i=W(p_(e)),a=W(g_(e)),o=W($g(e)),s=W(b_(e)),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=(0,H.useCallback)(e=>e.canPrompt?e.reason===`invalid_credentials`?t(`git.auth_failed_invalid`,{remote:e.remoteLabel}):e.reason===`authorization_failed`?t(`git.auth_failed_forbidden`,{remote:e.remoteLabel,operation:t(iD[e.operation])}):t(`git.auth_required_message`,{remote:e.remoteLabel}):t(`git.auth_failed_unsupported`,{remote:e.remoteLabel}),[t]),p=(0,H.useCallback)((e,n,r)=>{if(e===`git.fetch`)return n.message||r;let i=aD(n.remote,n.branch);return i?e===`git.push`?n.updated?t(`git.push_success_target`,{target:i}):t(`git.sync_up_to_date`,{target:i}):n.updated?t(`git.pull_success_target`,{target:i}):t(`git.sync_up_to_date`,{target:i}):n.message||r},[t]),m=(0,H.useCallback)(async()=>{if(!e)return!1;let[t,r]=await Promise.all([n(`git.branches`,{workspaceId:e}),n(`git.status`,{workspaceId:e})]);return t.ok&&t.data?a({current:t.data.current,branches:t.data.branches,loading:!1}):a(e=>({...e,loading:!1})),r.ok&&r.data&&i(r.data),t.ok&&r.ok},[n,a,i,e]),h=(0,H.useCallback)(async(i,a)=>{if(!e)return!1;let c=i===`git.fetch`;c?(s(e=>({...e,status:`fetching`,error:void 0})),l(`fetch`)):l(i===`git.push`?`push`:`pull`);try{let l=await n(i,{workspaceId:e,...a.auth?{auth:a.auth}:{}},{timeoutMs:rD});if(!l.ok||!l.data?.success){let e=l.error?.message??l.data?.message;if((l.error?.code===`git_auth_required`||l.error?.code===`git_auth_failed`)&&l.error.details&&typeof l.error.details==`object`){c&&s(t=>({...t,status:`error`,error:e}));let t=l.error.details,n=i===`git.push`?`push`:i===`git.pull`?`pull`:`fetch`;return d({intent:n,details:{...t,usernameHint:u?.intent===n?u.details.usernameHint:t.usernameHint}}),!1}return a.auth&&d(null),c&&s(t=>({...t,status:`error`,error:e})),r({kind:`error`,title:a.errorTitle,body:e}),console.error(`Failed to run ${i}:`,e),!1}if(!await m()&&c){let e=t(`git.fetch_refresh_failed_body`);return s(t=>({...t,status:`error`,error:e})),r({kind:`error`,title:a.errorTitle,body:e}),!1}return a.markFileTreeStale&&o(!0),c&&s({status:`idle`,lastFetchAt:Date.now()}),r({kind:`success`,title:a.successTitle,body:p(i,l.data,a.fallbackSuccessBody)}),!0}finally{l(null)}},[u,n,p,r,m,s,o,t,e]),g=(0,H.useCallback)(async e=>h(`git.push`,{successTitle:t(`git.push_success_title`),fallbackSuccessBody:t(`git.push_success_body`),errorTitle:t(`git.push_failed_title`),auth:e}),[h,t]),_=(0,H.useCallback)(async e=>h(`git.pull`,{successTitle:t(`git.pull_success_title`),fallbackSuccessBody:t(`git.pull_success_body`),errorTitle:t(`git.pull_failed_title`),markFileTreeStale:!0,auth:e}),[h,t]);return{authPrompt:u,clearAuthPrompt:()=>d(null),setAuthPrompt:d,getAuthPromptMessage:f,handleFetch:(0,H.useCallback)(async e=>h(`git.fetch`,{successTitle:t(`git.fetch_success_title`),fallbackSuccessBody:t(`git.fetch_success_body`),errorTitle:t(`git.fetch_failed_title`),auth:e}),[h,t]),handlePull:_,handlePush:g,refreshBranchState:m,syncingIntent:c}}function sD(e,t){let n=[{type:`staged`,changes:e.staged},{type:`modified`,changes:e.modified},{type:`deleted`,changes:e.deleted},{type:`untracked`,changes:e.untracked}];for(let e of n){let n=e.changes.find(e=>e.path===t);if(n)return{change:n,type:e.type}}return null}function cD({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,initialHistoryLimit:r=5}){let i=Z(),a=U(p_(e)),o=U(m_(e)),s=U(h_(e)),c=U(Op),l=W(sy),u=W(p_(e)),d=W(g_(e)),f=W(m_(e)),p=W(h_(e)),m=W(u_(e)),h=W(d_(e)),[g,_]=Te(v_(e)),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)([]),[S,C]=(0,H.useState)(r),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(null),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useCallback)(e=>{d({current:e?.current??``,branches:e?.branches??[],loading:!1})},[d]),j=(0,H.useCallback)(e=>{f(e)},[f]),M=(0,H.useCallback)(async(t,n)=>{let r=await c(`git.diff`,{workspaceId:e,path:t.path,staged:n===`staged`});if(!r.ok||!r.data)return console.error(`Failed to get diff:`,r.error?.message),null;let i={path:t.path,diff:r.data.diff,staged:n===`staged`,source:`file`,...r.data.renderAs?{renderAs:r.data.renderAs}:{},...r.data.status?{status:r.data.status}:{},...r.data.originalContent===void 0?{}:{originalContent:r.data.originalContent},...r.data.modifiedContent===void 0?{}:{modifiedContent:r.data.modifiedContent},...r.data.originalRevision?{originalRevision:r.data.originalRevision}:{},...r.data.modifiedRevision?{modifiedRevision:r.data.modifiedRevision}:{}};return p(!1),j(i),m(t.path),h(`diff`),i},[c,m,p,h,j,e]),N=(0,H.useCallback)(async t=>{let r=await c(`git.show`,{workspaceId:e,sha:t.sha});if(!r.ok||!r.data)return console.error(`Failed to get commit diff:`,r.error?.message),null;let i={path:t.sha,title:`${t.shortSha} · ${t.subject}`,diff:r.data.diff,source:`commit`};return p(!1),j(i),n?.(i),i},[c,n,p,j,e]),P=(0,H.useCallback)(async(e,t)=>{let r=await M(e,t);r&&n?.(r)},[n,M]),F=(0,H.useCallback)(async()=>{if(!e)return;d(e=>({...e,loading:!0,error:void 0}));let t=await c(`git.branches`,{workspaceId:e});if(!t.ok||!t.data){d(e=>({...e,loading:!1,error:t.error?.message??`Failed to load branches`})),console.error(`Failed to load git branches:`,t.error?.message);return}A(t.data)},[c,d,A,e]),ee=(0,H.useCallback)(async(t=S)=>{if(e){T(!0);try{let n=await c(`git.log`,{workspaceId:e,limit:t});if(!n.ok){console.error(`Failed to load git history:`,n.error?.message),x([]);return}x(Array.isArray(n.data?.entries)?n.data.entries:[])}finally{T(!1)}}},[c,S,e]),I=(0,H.useCallback)(async()=>{if(e){if(O.current){k.current=!0;return}O.current=!0,y(!0);try{let t=await c(`git.status`,{workspaceId:e});if(!t.ok||!t.data){console.error(`Failed to load git status:`,t.error?.message);return}if(u(t.data),s){j(null);return}if(nD(o)||!o)return;let n=sD(t.data,o.path);if(!n){j(null);return}!!o.staged!=(n.type===`staged`)&&await M(n.change,n.type)}finally{O.current=!1,y(!1),k.current&&(k.current=!1,queueMicrotask(()=>{I()}))}}},[o,s,c,M,u,j,e]);(0,H.useEffect)(()=>{!a&&!O.current&&I()},[a,I]),(0,H.useEffect)(()=>{F()},[F]),(0,H.useEffect)(()=>{ee(S)},[a?.headSha,S,ee]),(0,H.useEffect)(()=>{if(!a||s||nD(o)||!o)return;let e=sD(a,o.path);if(!e){j(null);return}!!o.staged!=(e.type===`staged`)&&M(e.change,e.type)},[o,s,a,M,j]),(0,H.useEffect)(()=>{t>0&&!O.current&&I()},[t,I]);let L=(0,H.useCallback)(async(e,t,n,r,i)=>{let a=await c(e,t);return a.ok?(i?.(),await I(),!0):(l({kind:`error`,title:r,body:a.error?.message??n}),console.error(n,a.error?.message),!1)},[c,I,l]),R=(0,H.useCallback)(async t=>{t.length!==0&&await L(`git.stage`,{workspaceId:e,paths:t},`Failed to stage all:`,i(`git.stage_failed_title`))},[L,i,e]),z=(0,H.useCallback)(async t=>{t.length!==0&&await L(`git.unstage`,{workspaceId:e,paths:t},`Failed to unstage all:`,i(`git.unstage_failed_title`))},[L,i,e]),te=(0,H.useCallback)(async()=>{await R([...a?.modified.map(e=>e.path)??[],...a?.deleted.map(e=>e.path)??[],...a?.untracked.map(e=>e.path)??[]])},[a,R]),ne=(0,H.useCallback)(async()=>{await z(a?.staged.map(e=>e.path)??[])},[a,z]),re=(0,H.useCallback)(()=>{let e=[...a?.staged.map(e=>e.path)??[],...a?.modified.map(e=>e.path)??[],...a?.deleted.map(e=>e.path)??[],...a?.untracked.map(e=>e.path)??[]];e.length&&D({scope:`all`,paths:e})},[a]),ie=(0,H.useCallback)(e=>{e.length&&D({scope:`all`,paths:e})},[]),ae=(0,H.useCallback)(e=>{D({scope:`single`,paths:[e],filePath:e})},[]),B=(0,H.useCallback)(()=>{D(null)},[]),oe=(0,H.useCallback)(async()=>{if(!E)return;let t=E;D(null),await L(`git.discard`,{workspaceId:e,paths:t.paths},t.scope===`all`?`Failed to discard all:`:`Failed to discard:`,i(`git.discard_failed_title`))},[E,L,i,e]),se=(0,H.useCallback)(async()=>{!g.trim()||!a?.staged.length||await L(`git.commit`,{workspaceId:e,message:g.trim()},`Failed to commit:`,i(`git.commit_failed_title`),()=>_(``))},[g,a?.staged.length,L,i,e]),ce=!!(a&&(a.staged.length>0||a.modified.length>0||a.untracked.length>0||a.deleted.length>0));return{commitMessage:g,diffPreview:o,gitState:a,groups:(0,H.useMemo)(()=>[{title:`staged`,changes:(a?.staged??[]).map(e=>({change:e,type:`staged`}))},{title:`changes`,changes:[...(a?.modified??[]).map(e=>({change:e,type:`modified`})),...(a?.deleted??[]).map(e=>({change:e,type:`deleted`})),...(a?.untracked??[]).map(e=>({change:e,type:`untracked`}))]}].filter(e=>e.changes.length>0),[a]),hasChanges:ce,history:b,historyLimit:S,historyLoading:w,isLoading:v,pendingDiscard:E,canShowMoreHistory:S<10&&b.length>0,setCommitMessage:_,handleCancelDiscard:B,handleCommit:se,handleConfirmDiscard:oe,handleDiscardAll:re,handleRequestDiscardPaths:ie,handleRequestDiscardSingle:ae,handleStageAll:te,handleStagePaths:R,handleUnstageAll:ne,handleUnstagePaths:z,loadGitStatus:I,loadGitHistory:ee,openDiff:P,openHistoryDiff:N,requestDiff:M,runGitMutation:L,showMoreHistory:()=>C(10),t:i}}function lD(e){let t=U(m_(e)),n=W(m_(e)),r=W(h_(e));return{closePreview:()=>{r(!0),n(null)},preview:t}}function uD(){let e=Z(),t=U(__),n=W(__),r=U(Op),i=W(sy),a=t.workspaceId,o=U(g_(a??``)),s=W(g_(a??``)),{refreshBranchState:c}=oD(a??``),[l,u]=(0,H.useState)(t.inputValue),[d,f]=(0,H.useState)(0),[p,m]=(0,H.useState)(null);(0,H.useEffect)(()=>{u(t.inputValue)},[t.inputValue]),(0,H.useEffect)(()=>{if(!t.visible||!a)return;if(o.branches.length>0){s(e=>({...e,loading:!1,error:void 0}));return}let e=!1;return s(e=>({...e,loading:!0,error:void 0})),r(`git.branches`,{workspaceId:a}).then(t=>{if(!e){if(!t.ok||!t.data){s(e=>({...e,loading:!1,error:t.error?.message??`Failed to load branches`})),console.error(`Failed to load git branches:`,t.error?.message);return}s({current:t.data.current,branches:t.data.branches,loading:!1})}}).catch(t=>{e||(s(e=>({...e,loading:!1,error:t instanceof Error?t.message:`Failed to load branches`})),console.error(`Failed to load git branches:`,t))}),()=>{e=!0}},[o.branches.length,r,t.visible,s,a]);let h=l.trim(),g=(0,H.useMemo)(()=>o.branches.filter(e=>(e.isCurrent||!e.linkedWorktreePath)&&e.name.toLowerCase().includes(l.toLowerCase())),[o.branches,l]),_=(0,H.useCallback)(e=>e.isCurrent||!e.linkedWorktreePath,[]),v=g.find(e=>e.name.toLowerCase()===l.toLowerCase()),y=(0,H.useMemo)(()=>{let t=[];return g.forEach(e=>{t.push({type:`branch`,branch:e,label:e.name})}),!v&&h&&!o.loading&&t.push({type:p===h?`confirm-create`:`create`,label:e(p===h?`git.quick_pick.confirm_create`:`git.quick_pick.create`,{name:h})}),t},[o.loading,v,g,p,e,h]),b=(0,H.useMemo)(()=>y.findIndex(e=>e.type===`branch`&&e.branch&&(e.branch.isCurrent||e.branch.name===o.current)),[o.current,y]);(0,H.useEffect)(()=>{if(t.visible){if(m(null),h){f(0);return}f(b>=0?b:0)}},[b,t.visible,h]);let x=(0,H.useCallback)(()=>{m(null),n({visible:!1,inputValue:``})},[n]),S=(0,H.useCallback)(e=>{e&&m(e)},[]),C=(0,H.useCallback)(async t=>{if(!a)return;let n=await r(`git.checkout`,{workspaceId:a,ref:t});if(!n.ok||!n.data?.success){let r=n.error?.message??n.data?.message;console.error(`Failed to checkout branch:`,r),i({kind:`error`,title:e(`git.quick_pick.checkout_failed_title`),body:r||e(`git.quick_pick.checkout_failed_body`,{name:t})});return}await c(),x()},[r,x,i,c,e,a]);return{branchList:o,displayItems:y,filteredBranches:g,handleBranchCreate:(0,H.useCallback)(async t=>{if(!a||!t)return;let n=await r(`git.checkout`,{workspaceId:a,ref:t,createBranch:!0});if(!n.ok||!n.data?.success){let r=n.error?.message??n.data?.message;console.error(`Failed to create branch:`,r),i({kind:`error`,title:e(`git.quick_pick.create_failed_title`),body:r||e(`git.quick_pick.create_failed_body`,{name:t})});return}await c(),x()},[r,x,i,c,e,a]),handleBranchSelect:C,handleClose:x,handleRequestBranchCreate:S,inputValue:l,isBranchSelectable:_,pendingCreateBranchName:p,quickPickState:t,selectedIndex:d,setInputValue:u,setPendingCreateBranchName:m,setSelectedIndex:f,trimmedInput:h}}function dD(e){return e.trim().replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}function fD(e,t){let n=e.trim(),r=n.replace(/[\\/]+$/,``)||n,i=n.includes(`\\`)?`\\`:`/`,a=/^([A-Za-z]:)([\\/]*)(.*)$/.exec(n),o=/^(\\\\|\/\/)([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]+(.*))?$/.exec(n),s=``,c=r;a?(s=`${a[1]}${i}`,c=a[3].replace(/[\\/]+$/,``).replace(/^[\\/]+/,``)):o?(s=`${o[1]}${o[2]}${i}${o[3]}${i}`,c=(o[4]??``).replace(/[\\/]+$/,``).replace(/^[\\/]+/,``)):(r.startsWith(`/`)||r.startsWith(`\\`))&&(s=r[0],c=r.replace(/^[\\/]+/,``));let l=c.split(/[\\/]+/).filter(Boolean),u=l.pop()??`worktree`,d=l.length>0?`${l.join(i)}${i}`:``,f=dD(t||`worktree`);return`${s}${d}${u}-${f}`}function pD(e){let t=e.trim();return t?/^[A-Za-z]:[\\/]+$/.test(t)?`${t.slice(0,2)}${t.includes(`\\`)?`\\`:`/`}`:t.replace(/[\\/]+$/,``)||t:``}function mD(e){return/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(e)}function hD(e){let t=Z(),n=U(Op),r=U(Ip(e)),[i,a]=Te(y_(e)),o=W(jp),s=W(Mp),c=W(Np),l=W(Pp),u=W(Fp),d=W(sy),f=Xg(),p=(0,H.useCallback)(async()=>{if(!e)return!1;a(e=>({...e,loading:!0,error:void 0}));let t=await n(`worktree.list`,{workspaceId:e});return!t.ok||!t.data?(a(e=>({...e,loading:!1,error:t.error?.message??`Failed to load worktrees`})),!1):(a({items:t.data.worktrees,loading:!1,lastLoadedAt:Date.now()}),!0)},[n,a,e]),m=(0,H.useCallback)(async(r,i)=>{let a=pD(i);if(!a||!mD(a)){let e=t(`worktree.create_path_absolute_required`);return d({kind:`error`,title:t(`worktree.create_failed_title`),body:e}),{ok:!1,error:e}}let o=await n(`worktree.create`,{workspaceId:e,branch:r,path:a});if(!o.ok||!o.data?.worktree){let e=o.error?.message??`Failed to create worktree`;return d({kind:`error`,title:t(`worktree.create_failed_title`),body:e}),{ok:!1,error:e}}return await p(),d({kind:`success`,title:t(`worktree.create_success_title`),body:t(`worktree.create_success_body`,{name:o.data.worktree.name})}),{ok:!0,worktree:o.data.worktree}},[n,p,d,t,e]),h=(0,H.useCallback)(async(r,i=!1)=>{let a=await n(`worktree.remove`,{workspaceId:e,worktreePath:r,force:i});if(!a.ok){let e=a.error?.message??`Failed to remove worktree`;return d({kind:`error`,title:t(`worktree.remove_failed_title`),body:e}),{ok:!1,error:e}}return await p(),d({kind:`success`,title:t(`worktree.remove_success_title`),body:t(`worktree.remove_success_body`)}),{ok:!0}},[n,p,d,t,e]),g=(0,H.useMemo)(()=>i.items.find(e=>e.path===r?.path)??null,[i.items,r?.path]),_=(0,H.useMemo)(()=>i.items.filter(e=>e.status===`dirty`).length,[i.items]),v=(0,H.useCallback)(e=>r?.path?fD(r.path,e):``,[r?.path]),y=(0,H.useCallback)(async e=>{let r=await n(`workspace.open`,{path:e});if(!r.ok||!r.data?.id){let e=r.error?.message??`Failed to open worktree`;return d({kind:`error`,title:t(`workspace.launch.open_failed`),body:e}),{ok:!1,error:e}}return o(r.data.id),s(e=>({...e,[r.data.id]:r.data})),c(e=>e.includes(r.data.id)?e:[r.data.id,...e]),l(`ready`),u(null),f({workspaceId:r.data.id}),{ok:!0,workspace:r.data}},[n,f,d,o,c,s,u,l,t]);return{createWorktree:m,currentWorktree:g,dirtyCount:_,hasWorkspace:!!r,list:i,loadWorktrees:p,openWorktree:y,removeWorktreeByPath:h,suggestedPathForBranch:v}}var gD={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},_D={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function vD({title:e}){return(0,X.jsx)(Sh,{className:`worktree-loading`,style:gD,title:(0,X.jsx)(`p`,{style:_D,children:e})})}function yD({workspaceId:e,worktree:t,mobile:n=!1}){let r=Z(),{activeTab:i,diff:a,error:o,handleTabChange:s,loading:c,status:l,tree:u}=qv(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:n?`mobile-worktree-sheet__summary`:void 0,children:(0,X.jsxs)(`div`,{className:`worktree-chips`,children:[(0,X.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,t.branch]}),(0,X.jsxs)(`span`,{className:`worktree-chip worktree-chip-path`,children:[`📁 `,t.path]}),(0,X.jsx)(`span`,{className:`worktree-chip worktree-chip-status ${t.status===`clean`?`worktree-clean`:`worktree-dirty`}`,children:t.status===`clean`?`✓ ${r(`worktree.clean`)}`:`● ${r(`worktree.dirty_status`)}`})]})}),(0,X.jsxs)(Rh,{"aria-label":r(`worktree.title`),onValueChange:e=>s(e),value:i,children:[(0,X.jsx)(zh,{className:`worktree-tabs${n?` mobile-worktree-sheet__tabs`:``}`,children:[`status`,`diff`,`tree`].map(e=>(0,X.jsx)(Bh,{className:`worktree-tab`,value:e,children:r(e===`status`?`worktree.status_tab`:e===`diff`?`worktree.diff_tab`:`worktree.tree_tab`)},e))}),(0,X.jsxs)(`div`,{className:n?`mobile-worktree-sheet__content`:void 0,children:[(0,X.jsxs)(Vh,{className:`worktree-content`,value:`status`,children:[o?(0,X.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,X.jsx)(vD,{title:r(`worktree.loading`)}):(0,X.jsxs)(`div`,{className:`worktree-status-tab`,children:[(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.path`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:t.path})]}),(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.branch`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:t.branch})]}),(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`git.latest_commit`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:l?.headShortSha||t.commit?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`code`,{children:l?.headShortSha??t.commit}),l?.headSubject?` ${l.headSubject}`:``]}):r(`git.no_commits`)})]}),(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`label.status`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:t.status===`clean`?r(`worktree.clean`):r(`worktree.dirty`)})]}),l?(0,X.jsxs)(`div`,{className:`worktree-changes`,children:[(0,X.jsx)(`h4`,{children:r(`worktree.changes`)}),l.staged.length>0?(0,X.jsx)(`div`,{className:`worktree-change-group`,children:(0,X.jsx)(`span`,{children:r(`worktree.staged_count`,{count:l.staged.length})})}):null,l.modified.length>0?(0,X.jsx)(`div`,{className:`worktree-change-group`,children:(0,X.jsx)(`span`,{children:r(`worktree.modified_count`,{count:l.modified.length})})}):null,l.untracked.length>0?(0,X.jsx)(`div`,{className:`worktree-change-group`,children:(0,X.jsx)(`span`,{children:r(`worktree.untracked_count`,{count:l.untracked.length})})}):null]}):null]})]}),(0,X.jsxs)(Vh,{className:`worktree-content`,value:`diff`,children:[o?(0,X.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,X.jsx)(vD,{title:r(`worktree.loading`)}):(0,X.jsx)(`div`,{className:`worktree-diff-tab`,children:a?(0,X.jsx)(`pre`,{className:`worktree-diff-output`,children:a}):(0,X.jsx)(Sh,{className:`worktree-empty`,style:gD,title:(0,X.jsx)(`p`,{style:_D,children:r(`git.no_changes`)})})})]}),(0,X.jsxs)(Vh,{className:`worktree-content`,value:`tree`,children:[o?(0,X.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,X.jsx)(vD,{title:r(`worktree.loading`)}):(0,X.jsx)(`div`,{className:`worktree-tree-tab`,children:u.length>0?(0,X.jsx)(`div`,{className:`worktree-tree`,children:u.map(e=>(0,X.jsxs)(`div`,{className:`worktree-tree-node`,children:[(0,X.jsx)(`span`,{className:`worktree-tree-icon`,children:e.kind===`dir`?`📁`:`📄`}),(0,X.jsx)(`span`,{className:`worktree-tree-name`,children:e.name})]},e.path))}):(0,X.jsx)(Sh,{className:`worktree-empty`,style:gD,title:(0,X.jsx)(`p`,{style:_D,children:r(`worktree.empty_tree`)})})})]})]})]})]})}var bD={minHeight:`auto`,padding:`var(--sp-4) 0`,gap:0},xD={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function SD({title:e}){return(0,X.jsx)(Sh,{className:`worktree-loading`,style:bD,title:(0,X.jsx)(`p`,{style:xD,children:e})})}function CD({workspaceId:e,openView:t,onClose:n,desktopPreviewInline:r=!1}){let i=Br()===`mobile`,a=Z(),{createWorktree:o,currentWorktree:s,list:c,loadWorktrees:l,removeWorktreeByPath:u,suggestedPathForBranch:d}=hD(e),[f,p]=(0,H.useState)(`list`),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(``),[v,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(null),[O,k]=(0,H.useState)(null),A=(0,H.useRef)(!1),j=(0,H.useRef)(null),M=()=>{_(``),y(``),x(!1),T(null)};(0,H.useEffect)(()=>{if(!t){A.current=!1;return}A.current||(A.current=!0,k(null),D(null),C(null),h(null),t===`create`?(M(),p(`create`)):p(`list`),!c.lastLoadedAt&&!c.loading&&l())},[c.lastLoadedAt,c.loading,l,t]),(0,H.useEffect)(()=>{f!==`create`||b||y(g.trim()?d(g):``)},[g,b,d,f]);let N=(0,H.useMemo)(()=>c.items.find(e=>e.path===m)??null,[c.items,m]),P=(0,H.useMemo)(()=>c.items.find(e=>e.path===S)??null,[S,c.items]);if((0,H.useEffect)(()=>{f===`detail`&&m&&!N&&(k(a(`worktree.selection_removed`)),h(null),p(`list`))},[N,m,a,f]),!t)return null;let F=f===`detail`&&N?N.name:a(f===`create`?`worktree.create_title`:`worktree.list_title`),ee=g.trim().length>0&&/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(v.trim()),I=`worktree-path-hint-${e}`,L=t===`create`,R=()=>{D(null),C(null),p(`list`)},z=()=>{M(),C(null),h(null),k(null),p(`create`)},te=()=>{P&&(D(null),u(P.path,P.status===`dirty`).then(e=>{if(e.ok){R();return}D(e.error)}))},ne=f===`detail`&&N?(0,X.jsx)(`div`,{className:i?`mobile-worktree-sheet`:void 0,children:(0,X.jsx)(yD,{workspaceId:e,worktree:N,mobile:i})}):f===`create`?(0,X.jsxs)(`form`,{className:`worktree-manager__form`,onSubmit:e=>{e.preventDefault(),T(null),o(g.trim(),v.trim()).then(e=>{if(e.ok){M(),L?n():p(`list`);return}T(e.error)})},children:[w?(0,X.jsx)(`div`,{className:`worktree-error`,children:w}):null,(0,X.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,X.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-branch-${e}`,children:a(`worktree.branch`)}),(0,X.jsx)(rh,{id:`worktree-branch-${e}`,ref:j,value:g,onChange:e=>_(e.target.value),placeholder:`feature/worktree-manager`,autoFocus:!0})]}),(0,X.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,X.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-path-${e}`,children:a(`worktree.path`)}),(0,X.jsx)(rh,{id:`worktree-path-${e}`,value:v,onChange:e=>{x(!0),y(e.target.value)},placeholder:`/home/spencer/workspace/coder-studio-feature-worktree-manager`,"aria-describedby":I}),(0,X.jsx)(`span`,{id:I,className:`worktree-manager__field-hint`,children:a(`worktree.create_path_hint`)})]}),(0,X.jsxs)(`div`,{className:`worktree-manager__form-actions`,children:[(0,X.jsx)(Q,{variant:`secondary`,onClick:()=>{L?n():p(`list`)},children:a(`action.cancel`)}),(0,X.jsx)(Q,{type:`submit`,variant:`primary`,disabled:!ee,children:a(`worktree.create_submit`)})]})]}):f===`confirm-delete`&&P?(0,X.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[E?(0,X.jsx)(`div`,{className:`worktree-error`,children:E}):null,(0,X.jsx)(`p`,{children:P.status===`dirty`?a(`worktree.remove_force_confirm`):a(`worktree.remove_confirm`)}),(0,X.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:P.path}),(0,X.jsxs)(`div`,{className:`worktree-manager__confirm-actions`,children:[(0,X.jsx)(Q,{variant:`secondary`,onClick:R,children:a(`action.cancel`)}),(0,X.jsx)(Q,{variant:`danger`,onClick:()=>{te()},children:P.status===`dirty`?a(`worktree.force_remove`):a(`common.delete`)})]})]}):(0,X.jsxs)(`div`,{className:`worktree-manager__list`,children:[O?(0,X.jsx)(`div`,{className:`worktree-error`,children:O}):null,c.error?(0,X.jsxs)(`div`,{className:`worktree-error`,children:[(0,X.jsx)(`div`,{children:c.error}),(0,X.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>void l(),children:a(`action.refresh`)})]}):null,c.loading&&c.items.length===0?(0,X.jsx)(SD,{title:a(`worktree.loading`)}):c.error&&c.items.length===0?null:c.items.length===0?(0,X.jsx)(Sh,{className:`worktree-empty`,style:bD,title:(0,X.jsx)(`p`,{style:xD,children:a(`worktree.list_empty`)})}):c.items.map((e,t)=>{let n=s?.path===e.path,r=t===0;return(0,X.jsxs)(`div`,{className:`worktree-manager__row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`worktree-manager__row-main`,onClick:()=>{k(null),h(e.path),p(`detail`)},children:[(0,X.jsx)(`span`,{className:`worktree-manager__row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`worktree-manager__meta`,children:[(0,X.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,e.branch]}),(0,X.jsx)(`span`,{className:`worktree-chip worktree-chip-status ${e.status===`clean`?`worktree-clean`:`worktree-dirty`}`,children:e.status===`clean`?a(`worktree.clean`):a(`worktree.dirty_status`)}),n?(0,X.jsx)(`span`,{className:`worktree-chip`,children:a(`worktree.current`)}):null]}),(0,X.jsx)(`span`,{className:`worktree-manager__row-path`,children:e.path})]}),!n&&!r?(0,X.jsx)(Q,{"aria-label":a(`worktree.remove_row_label`,{name:e.name}),size:`sm`,variant:`ghost`,onClick:()=>{D(null),C(e.path),p(`confirm-delete`)},children:a(`common.delete`)}):null]},e.path)})]});return!i&&f===`confirm-delete`&&P?(0,X.jsx)(Bm,{open:!0,className:`worktree-manager-surface`,title:a(`common.delete`),description:(0,X.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[E?(0,X.jsx)(`div`,{className:`worktree-error`,children:E}):null,(0,X.jsx)(`p`,{children:P.status===`dirty`?a(`worktree.remove_force_confirm`):a(`worktree.remove_confirm`)}),(0,X.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:P.path})]}),cancelText:a(`action.cancel`),closeLabel:a(`action.close`),confirmText:P.status===`dirty`?a(`worktree.force_remove`):a(`common.delete`),onOpenChange:e=>{e||R()},onConfirm:te,tone:`danger`}):i?(0,X.jsx)(fm,{kicker:a(`worktree.title`).toUpperCase(),title:F,body:(0,X.jsx)(`div`,{className:`worktree-manager-surface`,children:ne}),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`mobile-sheet--worktree`,onBack:f===`list`?void 0:()=>{L?n():p(`list`)},headerAction:f===`list`?(0,X.jsx)(Q,{size:`sm`,variant:`primary`,onClick:z,children:a(`worktree.new`)}):void 0,onClose:n}):r?(0,X.jsxs)(`div`,{className:`drawer-panel worktree-manager-surface worktree-manager-surface--inline-preview`,children:[(0,X.jsxs)(`div`,{className:`drawer-header`,children:[(0,X.jsx)(`div`,{className:`worktree-header-info`,children:(0,X.jsx)(`h2`,{className:`drawer-title`,children:F})}),(0,X.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[f===`list`?(0,X.jsx)(Q,{size:`sm`,variant:`primary`,onClick:z,children:a(`worktree.new`)}):L?null:(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>{L?n():p(`list`)},children:a(`action.back`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:n,children:a(`action.close`)})]})]}),(0,X.jsx)(`div`,{className:`drawer-body`,children:ne})]}):(0,X.jsxs)(jm,{className:`worktree-manager-surface`,dismissible:!1,initialFocus:()=>f===`create`?j.current:null,onOpenChange:e=>{e||n()},open:!0,size:`lg`,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsx)(Pm,{children:F}),(0,X.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[f===`list`?(0,X.jsx)(Q,{size:`sm`,variant:`primary`,onClick:z,children:a(`worktree.new`)}):L?null:(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>{L?n():p(`list`)},children:a(`action.back`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:n,children:a(`action.close`)})]})]}),(0,X.jsx)(Fm,{children:ne})]})}var wD={minHeight:`auto`,padding:`12px 0`,gap:`4px`},TD={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`};function ED({title:e,action:t}){return(0,X.jsx)(Sh,{action:t,className:`git-panel-empty`,style:wD,title:(0,X.jsx)(`p`,{style:TD,children:e})})}function DD(e){return e?{staged:!1,changes:!0}:{staged:!1,changes:!1}}function OD(e){return{pendingWorktreeDeletePath:null,worktreeSurfaceView:null,worktreesExpanded:!1,historyExpanded:!1,collapsedGroups:DD(e)}}function kD(e,t){return`${e}::${t}`}var AD=Ap(e=>V(OD(e.endsWith(`::mobile`)))),jD=({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,variant:r=`desktop`})=>{let i=r===`mobile`,[a,o]=Te(AD(kD(e,r))),s=U(Za)===`zh`?`zh`:`en`,c=Z(),{commitMessage:l,diffPreview:u,gitState:d,groups:f,history:p,historyLoading:m,isLoading:h,pendingDiscard:g,setCommitMessage:_,handleCancelDiscard:v,handleCommit:y,handleConfirmDiscard:b,handleRequestDiscardPaths:x,handleRequestDiscardSingle:S,handleStagePaths:C,handleUnstagePaths:w,openHistoryDiff:T,openDiff:E,runGitMutation:D}=cD({workspaceId:e,refreshToken:t,onPreviewOpen:n,initialHistoryLimit:20}),{currentWorktree:O,hasWorkspace:k,list:A,loadWorktrees:j,openWorktree:M,removeWorktreeByPath:N}=hD(e),P=(0,H.useRef)(!1),{collapsedGroups:F,historyExpanded:ee,pendingWorktreeDeletePath:I,worktreeSurfaceView:L,worktreesExpanded:R}=a,z=(0,H.useMemo)(()=>A.items.find(e=>e.path===I)??null,[A.items,I]);(0,H.useEffect)(()=>{P.current=!1},[e]),(0,H.useEffect)(()=>{if(!k){P.current=!1;return}A.lastLoadedAt||A.loading||P.current||(P.current=!0,j())},[k,A.lastLoadedAt,A.loading,j]);let te=d?.staged.length??0,ne=!!l.trim()&&te>0,re=async e=>{O?.path!==e.path&&await M(e.path)},ie=()=>{o(e=>({...e,pendingWorktreeDeletePath:null}))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`git-panel git-panel--${r}`,children:(0,X.jsxs)(`div`,{className:`git-panel-scroll`,children:[(0,X.jsxs)(`section`,{className:`git-commit-block`,children:[(0,X.jsx)(Cg,{className:`git-commit-input`,placeholder:c(`git.commit_summary_placeholder`),value:l,onChange:e=>_(e.target.value),rows:3,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),y())}}),(0,X.jsx)(`div`,{className:`git-commit-actions`,children:(0,X.jsx)(Ig,{content:c(ne?`git.commit`:`git.nothing_staged`),children:(0,X.jsxs)(`button`,{className:`git-commit-primary`,onClick:()=>void y(),disabled:!ne,type:`button`,children:[(0,X.jsx)(`span`,{children:c(`git.commit`)}),(0,X.jsx)($,{semantic:`git.commit`,size:14})]})})})]}),(0,X.jsxs)(`section`,{className:`git-panel-section`,children:[(0,X.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>o(e=>({...e,worktreesExpanded:!e.worktreesExpanded})),"aria-expanded":R,children:[(0,X.jsx)(`span`,{children:c(`worktree.list_title`)}),(0,X.jsx)(`span`,{className:`git-panel-section-count`,children:A.items.length}),(0,X.jsx)(`span`,{className:`git-panel-section-chevron ${R?`expanded`:``}`,children:(0,X.jsx)(_i,{size:14})})]}),(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>o(e=>({...e,worktreeSurfaceView:`create`})),children:[(0,X.jsx)($,{semantic:`worktree.action.new`,size:12}),(0,X.jsx)(`span`,{children:c(`worktree.new`)})]})]}),R?(0,X.jsx)(`div`,{className:`git-panel-section-body`,children:A.loading&&A.items.length===0?(0,X.jsx)(ED,{title:c(`worktree.loading`)}):A.error?(0,X.jsx)(ED,{action:(0,X.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void j(),children:c(`action.refresh`)}),title:A.error}):A.items.length===0?(0,X.jsx)(ED,{title:c(`worktree.list_empty`)}):A.items.map((e,t)=>{let n=O?.path===e.path,r=!n&&t!==0;return(0,X.jsxs)(`div`,{className:`git-worktree-row ${n?`active`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`git-worktree-row__main`,onClick:()=>void re(e),children:[(0,X.jsx)(`span`,{className:`git-worktree-row__dot git-worktree-row__dot-${e.status}`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`git-worktree-row__name`,children:e.name}),(0,X.jsxs)(`span`,{className:`git-worktree-row__tail`,children:[(0,X.jsx)(`span`,{className:`git-worktree-row__status`,children:e.status===`clean`?c(`worktree.clean`):c(`worktree.dirty_status`)}),n?(0,X.jsx)(`span`,{className:`git-worktree-row__chip`,children:c(`worktree.current`)}):null]})]}),r?(0,X.jsx)(Em,{"aria-label":c(`worktree.remove_row_label`,{name:e.name}),className:`git-worktree-row__delete`,icon:(0,X.jsx)(ua,{size:12}),onClick:()=>o(t=>({...t,pendingWorktreeDeletePath:e.path})),size:`sm`,variant:`ghost`}):null]},e.path)})}):null]}),(0,X.jsx)(`div`,{className:`git-panel-groups`,children:d&&f.length>0?f.map(t=>(0,X.jsx)(MD,{title:t.title,changes:t.changes,mobile:i,collapsed:F[t.title]??!1,selectedPath:u?.path??null,onToggleCollapsed:()=>o(e=>({...e,collapsedGroups:{...e.collapsedGroups,[t.title]:!(e.collapsedGroups[t.title]??!1)}})),onStageAll:async()=>{if(t.title===`staged`){await w(t.changes.map(({change:e})=>e.path));return}await C(t.changes.map(({change:e})=>e.path))},onDiscardAll:()=>x(t.changes.map(({change:e})=>e.path)),onViewDiff:E,onRunMutation:D,onRequestDiscard:S,workspaceId:e},t.title)):(0,X.jsx)(ED,{title:c(h?`common.loading`:`git.no_changes`)})}),(0,X.jsxs)(`section`,{className:`git-panel-section git-panel-section-history`,children:[(0,X.jsx)(`div`,{className:`git-panel-section-header`,children:(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>o(e=>({...e,historyExpanded:!e.historyExpanded})),"aria-expanded":ee,children:[(0,X.jsx)(`span`,{children:c(`git.history`)}),(0,X.jsx)(`span`,{className:`git-panel-section-chevron ${ee?`expanded`:``}`,children:(0,X.jsx)(_i,{size:14})})]})}),ee?(0,X.jsx)(`div`,{className:`git-panel-section-body`,children:m&&p.length===0?(0,X.jsx)(ED,{title:c(`common.loading`)}):p.length===0?(0,X.jsx)(ED,{title:c(`git.no_commits`)}):p.map((e,t)=>(0,X.jsx)(PD,{entry:e,isCurrent:t===0,locale:s,onOpen:T},e.sha))}):null]})]})}),(0,X.jsx)(CD,{workspaceId:e,openView:L,onClose:()=>o(e=>({...e,pendingWorktreeDeletePath:null,worktreeSurfaceView:null}))}),z?(0,X.jsx)(Bm,{open:!0,title:c(`common.delete`),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:z.status===`dirty`?c(`worktree.remove_force_confirm`):c(`worktree.remove_confirm`)}),(0,X.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:z.path})]}),cancelText:c(`action.cancel`),closeLabel:c(`action.close`),confirmText:z.status===`dirty`?c(`worktree.force_remove`):c(`common.delete`),onOpenChange:e=>{e||ie()},onConfirm:()=>{N(z.path,z.status===`dirty`).then(e=>{e.ok&&ie()})},tone:`danger`}):null,(0,X.jsx)(FD,{discard:g,onCancel:v,onConfirm:b})]})},MD=({title:e,changes:t,collapsed:n,mobile:r,selectedPath:i,workspaceId:a,onDiscardAll:o,onRequestDiscard:s,onRunMutation:c,onStageAll:l,onToggleCollapsed:u,onViewDiff:d})=>{let f=Z(),p=e===`staged`?`git.staged`:`git.changes`,m=f(e===`staged`?`git.unstage_all`:`git.stage_all`);return(0,X.jsxs)(`section`,{className:`git-panel-section git-panel-section-changes`,children:[(0,X.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:u,"aria-expanded":!n,children:[(0,X.jsx)(`span`,{children:f(p)}),(0,X.jsx)(`span`,{className:`git-panel-section-count`,children:t.length}),(0,X.jsx)(`span`,{className:`git-panel-section-chevron ${n?``:`expanded`}`,children:(0,X.jsx)(_i,{size:14})})]}),(0,X.jsxs)(`div`,{className:`git-panel-section-actions`,children:[(0,X.jsx)(Ig,{content:m,children:(0,X.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void l(),children:m})}),e===`changes`?(0,X.jsx)(Ig,{content:f(`git.discard_all`),children:(0,X.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void o(),children:f(`git.discard_all`)})}):null]})]}),n?null:(0,X.jsx)(`div`,{className:`git-panel-section-body`,children:t.map(({change:e,type:t})=>(0,X.jsx)(ND,{change:e,type:t,mobile:r,workspaceId:a,selected:i===e.path,onViewDiff:d,onRunMutation:c,onRequestDiscard:s},`${t}:${e.path}`))})]})},ND=({change:e,type:t,mobile:n,workspaceId:r,selected:i,onViewDiff:a,onRunMutation:o,onRequestDiscard:s})=>{let c=Z(),l=(0,H.useMemo)(()=>e.path.split(`/`),[e.path]),u=l[l.length-1]??e.path,d=l.length>1?`${l.slice(0,-1).join(`/`)}/`:``,f=c(t===`staged`?`git.unstage`:`git.stage`),p=c(`git.discard`),m=t===`staged`?(0,X.jsx)(qi,{size:12}):(0,X.jsx)(ea,{size:12}),h=LD(e,t),g=async()=>{if(t===`staged`){await o(`git.unstage`,{workspaceId:r,paths:[e.path]},`Failed to unstage:`,c(`git.unstage_failed_title`));return}await o(`git.stage`,{workspaceId:r,paths:[e.path]},`Failed to stage:`,c(`git.stage_failed_title`))};return(0,X.jsxs)(`div`,{className:`git-row ${i?`active`:``} ${n?`mobile`:``}`,onClick:()=>void a(e,t),role:`button`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),a(e,t))},children:[(0,X.jsx)(`span`,{className:`git-row-icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:h,size:13})}),(0,X.jsxs)(`div`,{className:`git-row-content`,children:[(0,X.jsx)(`span`,{className:`git-row-name`,children:u}),(0,X.jsxs)(`span`,{className:`git-row-meta`,children:[d?(0,X.jsx)(`span`,{className:`git-row-dir`,children:d}):null,e.oldPath?(0,X.jsx)(`span`,{className:`git-row-rename`,children:e.oldPath}):null]})]}),(0,X.jsxs)(`div`,{className:`git-row-actions`,children:[(0,X.jsx)(Ig,{content:f,children:(0,X.jsx)(Em,{"aria-label":f,className:`git-row-action`,icon:m,onClick:e=>{e.stopPropagation(),g()},size:`sm`,type:`button`,variant:`ghost`})}),(0,X.jsx)(Ig,{content:p,children:(0,X.jsx)(Em,{"aria-label":p,className:`git-row-action`,icon:(0,X.jsx)(na,{size:12}),onClick:t=>{t.stopPropagation(),s(e.path)},size:`sm`,type:`button`,variant:`ghost`})})]})]})};function PD({entry:e,isCurrent:t,locale:n,onOpen:r}){return(0,X.jsxs)(`button`,{type:`button`,className:`git-history-row ${t?`current`:``}`,onClick:()=>void r(e),children:[(0,X.jsx)(`span`,{className:`git-history-row__dot`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`git-history-row__copy`,children:[(0,X.jsx)(Ig,{content:e.subject,children:(0,X.jsx)(`span`,{className:`git-history-row__title`,children:e.subject})}),(0,X.jsxs)(`span`,{className:`git-history-row__meta`,children:[e.shortSha,` · `,e.authorName]})]}),(0,X.jsx)(`span`,{className:`git-history-row__when`,children:um(e.authoredAt,n)})]})}var FD=({discard:e,onCancel:t,onConfirm:n})=>{let r=Z();return e?(0,X.jsx)(Bm,{open:!0,onOpenChange:t,title:e.scope===`all`?r(`git.discard_all_confirm_title`):r(`git.discard_file_confirm_title`),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:e.scope===`all`?r(`git.discard_all_confirm_message`,{count:e.paths.length}):r(`git.discard_file_confirm_message`,{path:e.filePath??e.paths[0]??``})}),(0,X.jsx)(`p`,{className:`dialog-helper`,children:r(`git.discard_confirm_irreversible`)})]}),cancelText:r(`action.cancel`),closeLabel:r(`action.close`),confirmText:r(`git.discard`),onConfirm:()=>{n()},tone:`danger`}):null};function ID(e,t){return e.status?e.status:t===`deleted`?`deleted`:t===`untracked`?`untracked`:`modified`}function LD(e,t){switch(ID(e,t)){case`deleted`:return`git.status.deleted`;case`untracked`:return`git.status.untracked`;default:return t===`staged`?`git.status.staged`:`git.status.modified`}}var RD=Ap(e=>V({query:``,retryNonce:0,resolvedQuery:``,resolvedRetryNonce:0,results:null,expandedFiles:{},loading:!1,error:!1}));function zD(e){let t=Math.max(0,e.previewColumnStart-1),n=Math.max(t,e.previewColumnEnd-1);return(0,X.jsxs)(X.Fragment,{children:[e.preview.slice(0,t),(0,X.jsx)(`mark`,{children:e.preview.slice(t,n)}),e.preview.slice(n)]})}function BD(e){return Object.fromEntries(e.files.map(e=>[e.path,!0]))}var VD=({workspaceId:e,variant:t=`desktop`,onSelectFile:n})=>{let r=Z(),i=U(Op),{openLocation:a}=Cy(e),o=W(d_(e)),s=(0,H.useRef)(null),c=(0,H.useRef)(i),l=(0,H.useId)(),[u,d]=Te(RD(e)),{error:f,expandedFiles:p,loading:m,query:h,resolvedQuery:g,resolvedRetryNonce:_,results:v,retryNonce:y}=u;(0,H.useEffect)(()=>{s.current?.focus()},[e]),(0,H.useEffect)(()=>{c.current=i},[i]),(0,H.useEffect)(()=>{let t=h.trim();if(!t){d(e=>e.results!==null||e.resolvedQuery||Object.keys(e.expandedFiles).length>0||e.loading||e.error?{...e,resolvedQuery:``,resolvedRetryNonce:e.retryNonce,results:null,expandedFiles:{},loading:!1,error:!1}:e);return}if(v&&!f&&g===t&&_===y)return;let n=!1;d(e=>({...e,loading:!0,error:!1}));let r=window.setTimeout(()=>{c.current(`file.searchContent`,{workspaceId:e,query:t,maxFiles:50,maxMatchesPerFile:20}).then(e=>{if(!n){if(!e.ok||!e.data){d(e=>({...e,results:null,expandedFiles:{},error:!0}));return}d(n=>({...n,resolvedQuery:t,resolvedRetryNonce:y,results:e.data,expandedFiles:BD(e.data)}))}}).catch(()=>{n||d(e=>({...e,results:null,expandedFiles:{},error:!0}))}).finally(()=>{n||d(e=>({...e,loading:!1}))})},250);return()=>{n=!0,window.clearTimeout(r)}},[h,y,d,e]);let b=(t,r,i,s)=>{o(c_(t)),a({workspaceId:e,path:t,line:r,column:i,endColumn:s,source:`search`}),n?.(t)};return(0,X.jsxs)(`div`,{className:`workspace-sidebar-view workspace-search-panel workspace-search-panel--${t}`,children:[t===`desktop`?(0,X.jsx)(aS,{title:r(`workspace.sidebar.search`)}):null,(0,X.jsxs)(`div`,{className:`workspace-search-panel__controls`,children:[(0,X.jsx)(`input`,{ref:s,type:`search`,"aria-label":r(`workspace.sidebar.search`),className:`workspace-search-panel__input`,value:h,onChange:e=>d(t=>({...t,query:e.target.value})),placeholder:r(`workspace.search.placeholder`)}),(0,X.jsx)(`div`,{className:`workspace-search-panel__summary`,children:m?r(`common.loading`):h.trim()?r(`workspace.search.results_count`,{count:v?.totalMatchCount??0,files:v?.files.length??0}):null}),v&&(v.hasMoreFiles||v.truncatedMatchFileCount>0)?(0,X.jsx)(`div`,{className:`workspace-search-panel__truncate-note`,children:r(`workspace.search.truncated`)}):null]}),(0,X.jsx)(`div`,{className:`workspace-search-panel__results`,children:f?(0,X.jsxs)(`div`,{className:`workspace-search-panel__state-block`,children:[(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`workspace.search.failed`)}),(0,X.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>d(e=>({...e,retryNonce:e.retryNonce+1})),children:r(`workspace.search.retry`)})]}):h.trim()?m?(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`common.loading`)}):!v||v.files.length===0?(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`workspace.search.no_results`)}):v.files.map((e,t)=>{let n=`${l}-group-${t}`,i=p[e.path]??!0;return(0,X.jsxs)(`section`,{className:`workspace-search-panel__group`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`workspace-search-panel__group-header`,onClick:()=>d(t=>({...t,expandedFiles:{...t.expandedFiles,[e.path]:!(t.expandedFiles[e.path]??!0)}})),"aria-expanded":i,"aria-controls":n,children:[(0,X.jsx)(`span`,{className:`workspace-search-panel__group-chevron`,"aria-hidden":`true`,children:i?(0,X.jsx)(_i,{size:14}):(0,X.jsx)(yi,{size:14})}),(0,X.jsxs)(`span`,{className:`workspace-search-panel__group-copy`,children:[(0,X.jsx)(`strong`,{className:`workspace-search-panel__group-name`,children:e.name}),(0,X.jsx)(`span`,{className:`workspace-search-panel__group-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`workspace-search-panel__group-count`,children:r(`workspace.search.file_match_count`,{count:e.matchCount,suffix:e.hasMoreMatches?`+`:``})})]}),(0,X.jsx)(`div`,{id:n,hidden:!i,className:`workspace-search-panel__matches`,children:i?e.matches.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`workspace-search-panel__match`,onClick:()=>b(e.path,t.line,t.column,t.endColumn),children:[(0,X.jsx)(`span`,{className:`workspace-search-panel__line`,children:t.line}),(0,X.jsx)(`span`,{className:`workspace-search-panel__preview`,children:zD(t)})]},`${e.path}:${t.line}:${t.column}`)):null})]},e.path)}):(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`workspace.search.empty`)})})]})},HD=({activeView:e,onSelectView:t})=>{let n=Z(),r=[{view:`explorer`,label:n(`workspace.sidebar.explorer`),icon:Ni},{view:`search`,label:n(`workspace.sidebar.search`),icon:ia},{view:`source-control`,label:n(`workspace.sidebar.source_control`),icon:Fi}];return(0,X.jsx)(`nav`,{className:`workspace-activity-bar`,"aria-label":n(`workspace.sidebar.label`),children:r.map(({view:n,label:r,icon:i})=>(0,X.jsxs)(`button`,{type:`button`,className:`workspace-activity-bar__button ${e===n?`workspace-activity-bar__button--active`:``}`,"aria-label":r,"aria-pressed":e===n,onClick:()=>t(n),children:[(0,X.jsx)(i,{size:18,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workspace-activity-bar__label`,children:r})]},n))})};function UD(e){return!e||e.updateStatus!==`succeeded`?null:e.targetVersion??e.latestVersion??e.currentVersion??null}function WD(){let e=Z(),t=Qt(),n=U(Op),r=U(Vy),i=W(Vy),a=W(Hy),o=W(sy),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=UD(r);(0,H.useEffect)(()=>{if(r?.updateStatus!==`succeeded`){f(!1);return}f(!1);let e=window.setTimeout(()=>{f(!0)},3e3);return()=>{window.clearTimeout(e)}},[p,r?.updateStatus]);let m=async(t,r)=>{u(`install`);let a=await n(`updates.startInstall`,{targetVersion:t.latestVersion??t.targetVersion??void 0,force:r});if(u(!1),c(null),!a.ok||!a.data){o({kind:`error`,title:e(`settings.about.update_now`),body:a.error?.message});return}i(a.data)},h=async()=>{u(`prepare`);let t=await n(`updates.prepareInstall`,{});if(u(!1),!t.ok||!t.data){o({kind:`error`,title:e(`settings.about.update_now`),body:t.error?.message});return}if(a(t.data),t.data.activity.hasActiveWork){c(t.data);return}await m(t.data,!1)},g=()=>{t(`/settings?section=about`)};if(!r)return null;let _=r.availability===`update_available`&&r.updateStatus===`idle`,v=r.updateStatus===`installing`||r.updateStatus===`restarting`||r.updateStatus===`failed`||r.updateStatus===`manual_required`||r.updateStatus===`succeeded`&&!d;return!_&&!v?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`footer-update-rail`,"data-testid":`footer-update-rail`,children:[_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_update_available`,{version:r.latestVersion?`v${r.latestVersion}`:``})}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,className:`footer-update-rail__action`,onClick:()=>{h()},disabled:l!==!1,children:e(`settings.about.update_now`)})]}):null,r.updateStatus===`installing`?(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_installing`)}):null,r.updateStatus===`restarting`?(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_restarting`)}):null,r.updateStatus===`failed`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_failed`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,className:`footer-update-rail__action`,onClick:g,children:e(`settings.about.footer_view_details`)})]}):null,r.updateStatus===`manual_required`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_manual_required`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,className:`footer-update-rail__action`,onClick:g,children:e(`settings.about.footer_view_details`)})]}):null,r.updateStatus===`succeeded`&&!d&&p?(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_succeeded`,{version:`v${p}`})}):null]}),s?(0,X.jsx)(Bm,{open:!0,onOpenChange:e=>{e||c(null)},title:e(`settings.about.confirm_update_title`),description:(0,X.jsxs)(`div`,{className:`settings-dialog-copy`,children:[(0,X.jsx)(`p`,{children:e(`settings.about.confirm_update_message`)}),(0,X.jsx)(`p`,{children:e(`settings.about.confirm_update_activity`,{terminals:s.activity.runningTerminalCount,sessions:s.activity.runningSessionCount,supervisors:s.activity.runningSupervisorCount})})]}),cancelText:e(`action.cancel`),confirmText:e(`settings.about.update_now`),tone:`danger`,onConfirm:()=>{m(s,!0)}}):null]})}function GD(e){return[...e].sort((e,t)=>e.split(`/`).length-t.split(`/`).length||e.localeCompare(t))}function KD(e){let t=Z(),n=U(Op),r=W(sy),i=U(t_(e)),a=W(p_(e)),o=W(g_(e)),s=W(y_(e)),c=W(Qg(e)),l=W(e_(e)),u=W(f_(e)),[d,f]=(0,H.useState)(`idle`),p=(0,H.useRef)(!1),m=(0,H.useRef)(!1);return{refreshWorkspace:(0,H.useCallback)(async()=>{if(!e)return!1;if(p.current)return m.current=!0,!1;p.current=!0,f(`refreshing`);try{do{m.current=!1;let d=[],[p,h,g,_]=await Promise.all([n(`git.branches`,{workspaceId:e}),n(`git.status`,{workspaceId:e}),n(`worktree.list`,{workspaceId:e}),n(`file.readTree`,{workspaceId:e})]);if(p.ok&&p.data?o({current:p.data.current,branches:p.data.branches,loading:!1}):d.push(`branches`),h.ok&&h.data?a(h.data):d.push(`git`),g.ok&&g.data?s({items:g.data.worktrees,loading:!1,lastLoadedAt:Date.now()}):d.push(`worktrees`),_.ok&&_.data){let e=new Map;e.set(`.`,_.data.children),c(e),l(new Set)}else d.push(`files`);if(_.ok&&_.data&&i&&i.size>0)for(let t of GD(i)){let r=await n(`file.readTree`,{workspaceId:e,subPath:t});if(!r.ok||!r.data){d.push(`files:${t}`);continue}c(e=>{let n=new Map(e??[]);return n.set(t,r.data.children),n}),l(e=>new Set(e).add(t))}u(e=>e+1),d.length>0?(f(`error`),r({kind:`warning`,title:t(`workspace.refresh_partial_title`),body:t(`workspace.refresh_partial_body`,{sections:d.join(`, `)})})):f(`idle`)}while(m.current);return!0}finally{p.current=!1,m.current||f(e=>e===`error`?`error`:`idle`)}},[n,i,r,o,u,c,a,l,s,t,e]),status:d}}var qD={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},JD={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function YD({title:e}){return(0,X.jsx)(Sh,{className:`branch-quick-pick-empty`,style:qD,title:(0,X.jsx)(`p`,{style:JD,children:e})})}function XD(){let e=Z(),{branchList:t,displayItems:n,handleBranchCreate:r,handleBranchSelect:i,handleClose:a,handleRequestBranchCreate:o,inputValue:s,isBranchSelectable:c,selectedIndex:l,setInputValue:u,setPendingCreateBranchName:d,setSelectedIndex:f,trimmedInput:p}=uD(),m=(0,H.useRef)(null),h=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{m.current?.focus()},0);return()=>{window.clearTimeout(e)}},[]),(0,H.useEffect)(()=>{h.current&&h.current.querySelector(`.branch-quick-pick-item:nth-child(${l+1})`)?.scrollIntoView({block:`nearest`})},[l]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`branch-quick-pick-search`,children:(0,X.jsx)(`input`,{ref:m,type:`text`,className:`branch-quick-pick-input`,placeholder:`Search branches or create new branch...`,value:s,onChange:e=>{u(e.target.value),d(null),f(0)},onKeyDown:e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),f(e=>e<n.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),f(e=>e>0?e-1:e);break;case`Enter`:if(e.preventDefault(),n[l]){let e=n[l];if(e.type===`branch`&&e.branch){if(!c(e.branch))return;i(e.branch.name)}else e.type===`create`?o(p):e.type===`confirm-create`&&r(p)}break;case`Escape`:e.preventDefault(),a();break}}})}),(0,X.jsx)(`div`,{className:`branch-quick-pick-list`,ref:h,children:t.loading?(0,X.jsx)(YD,{title:`Loading branches...`}):n.length>0?n.map((t,n)=>(0,X.jsx)(`div`,{className:`branch-quick-pick-item ${n===l?`branch-quick-pick-item-selected`:``}`,onClick:()=>{if(t.type===`branch`&&t.branch){if(!c(t.branch))return;i(t.branch.name)}else t.type===`create`?o(p):t.type===`confirm-create`&&r(p)},onMouseEnter:()=>f(n),children:t.type===`branch`&&t.branch?(0,X.jsxs)(X.Fragment,{children:[t.branch.isCurrent&&(0,X.jsx)(`span`,{className:`branch-quick-pick-check`,children:(0,X.jsx)(gi,{size:14})}),(0,X.jsx)(`span`,{className:`branch-quick-pick-name`,children:t.branch.name}),t.branch.linkedWorktreePath&&!t.branch.isCurrent&&(0,X.jsx)(_g,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:e(`git.quick_pick.in_use`)}),t.branch.isRemote&&(0,X.jsx)(_g,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:`Remote`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`branch-quick-pick-create-icon`,children:(0,X.jsx)($,{semantic:`git.branch.create`,size:14})}),(0,X.jsx)(`span`,{className:`branch-quick-pick-create-label`,children:t.label})]})},t.type===`branch`?t.branch?.name:`create`)):(0,X.jsx)(YD,{title:s?`No branches found`:`Type to search branches`})}),(0,X.jsxs)(`div`,{className:`branch-quick-pick-hint`,children:[(0,X.jsx)(`span`,{children:`↑↓ Navigate`}),(0,X.jsx)(`span`,{children:`↵ Select`}),(0,X.jsx)(`span`,{children:`Esc Close`})]})]})}function ZD({children:e,workspaceId:t,onOpenBranchSwitcher:n}){let r=Br(),i=Z(),a=U(__),o=W(__);return r===`mobile`||!n?e:(0,X.jsx)(Gm,{content:(0,X.jsx)(XD,{}),contentClassName:`branch-quick-pick`,forceMode:`desktop`,onOpenChange:e=>{if(e){n();return}o({visible:!1,inputValue:``})},open:a.visible&&a.workspaceId===t,title:i(`git.branch`),children:e})}function QD(){let e=Br(),t=Z(),{branchList:n,displayItems:r,handleBranchCreate:i,handleBranchSelect:a,handleClose:o,handleRequestBranchCreate:s,inputValue:c,isBranchSelectable:l,quickPickState:u,selectedIndex:d,setInputValue:f,setPendingCreateBranchName:p,setSelectedIndex:m,trimmedInput:h}=uD(),g=e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),m(e=>e<r.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),m(e=>e>0?e-1:e);break;case`Enter`:if(e.preventDefault(),r[d]){let e=r[d];if(e.type===`branch`&&e.branch){if(!l(e.branch))return;a(e.branch.name)}else e.type===`create`?s(h):e.type===`confirm-create`&&i(h)}break;case`Escape`:e.preventDefault(),o();break}};if(!u.visible||e!==`mobile`)return null;let _=r[d]??null,v=_?.type===`branch`&&_.branch?_.branch.name:null,y=r.some(e=>e.type===`branch`&&e.branch?.name.toLowerCase()===h.toLowerCase()),b=r.filter(e=>e.type===`branch`&&e.branch).map(e=>({id:e.branch.name,label:e.branch.name,icon:e.branch.isCurrent?(0,X.jsx)(gi,{size:14}):void 0,meta:e.branch.isCurrent?t(`git.current_branch`):e.branch.linkedWorktreePath?t(`git.quick_pick.worktree_in_use`):void 0,badge:e.branch.isRemote?t(`git.branch_remote`):void 0,disabled:!l(e.branch)})),x=r.find(e=>e.type===`create`||e.type===`confirm-create`);return(0,X.jsx)(`div`,{onKeyDown:g,children:(0,X.jsx)(Jh,{className:`mobile-select-sheet--command`,title:t(`git.branch`),searchable:!0,searchPlaceholder:t(`git.quick_pick.search_placeholder`),searchValue:c,onSearchValueChange:e=>{f(e),p(null),m(0)},sections:[{kind:`options`,id:`branches`,items:b}],closeOnSelect:!1,selectedId:v,loading:n.loading,loadingText:t(`git.quick_pick.loading`),emptyText:t(c?`git.quick_pick.empty_filtered`:`git.quick_pick.empty_idle`),create:{visible:!!h&&!y,label:()=>x?.type===`confirm-create`?t(`git.quick_pick.confirm_create_label`):t(`git.quick_pick.create_label`),description:()=>h,onCreate:async()=>{if(x?.type===`confirm-create`){await i(h);return}s(h),m(r.length-1)}},onClose:o,onSelect:a})})}var $D=({workspaceId:e,gitState:t,inline:n=!1,onRefresh:r,refreshStatus:i=`idle`})=>{let a=Z(),o=U(Za),s=U(b_(e)),{authPrompt:c,clearAuthPrompt:l,getAuthPromptMessage:u,handleFetch:d,handlePull:f,handlePush:p,syncingIntent:m}=oD(e),h=`git-auth-form-${e}`,[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)({username:``,password:``}),b=(0,H.useRef)(!1);if((0,H.useLayoutEffect)(()=>{if(!c){y({username:``,password:``});return}y(e=>({username:e.username||c.details.usernameHint||``,password:``}))},[c]),(0,H.useEffect)(()=>{i===`refreshing`||!b.current||(b.current=!1,ae())},[i]),!t)return null;let x=t.staged.length+t.modified.length+t.untracked.length+t.deleted.length,S=t.ahead,C=t.behind,w=s.status===`fetching`,T=w||i===`refreshing`,E=s.lastFetchAt?a(`git.fetch_last_at`,{when:dm(s.lastFetchAt,o)}):a(`git.fetch_last_never`),D=a(T?`git.fetch_in_progress`:`git.fetch_label`),O=g?.intent===`push`?a(`git.push_confirm_title`):a(`git.pull_confirm_title`),k=g?.intent===`push`?a(`git.push_confirm_message`,{count:g.count}):a(`git.pull_confirm_message`,{count:g?.count??0}),A=g?.intent===`push`?a(`action.push`):a(`action.pull`),j=g?.intent===`push`?a(`git.push_in_progress`):a(`git.pull_in_progress`),M=!!(g&&m===g.intent),N=c?.intent,P=N??g?.intent??`pull`,F=a(N===`push`?`action.push`:N===`pull`?`action.pull`:`git.fetch_label`),ee=a(N===`push`?`git.push_in_progress`:N===`pull`?`git.pull_in_progress`:`git.fetch_in_progress`),I=!!(N&&m===N),L=M||I,R=!!(g&&!c),z=(e,t)=>{t<=0||_({intent:e,count:t})},te=()=>{L||(_(null),l())},ne=e=>{e||te()},re=async()=>{if(g){if(g.intent===`push`){await p()&&_(null);return}await f()&&_(null)}},ie=async()=>{let e=c;if(!e)return;let t={username:v.username.trim(),password:v.password};!t.username||!t.password||(e.intent===`push`?await p(t):e.intent===`pull`?await f(t):await d(t))&&(l(),_(null),(e.intent===`fetch`||e.intent===`pull`)&&await r?.())},ae=async()=>{if(i===`refreshing`){b.current=!0;return}await d()&&await r?.()},B=c;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`git-status-bar${n?` git-status-bar--inline`:``}`,children:[(0,X.jsx)(Ig,{content:a(`git.statusbar.changes`),children:(0,X.jsxs)(`span`,{className:`git-status-bar__item git-status-bar__item--changes`,children:[(0,X.jsx)($,{semantic:`git.footer.diff`,size:13}),(0,X.jsx)(`span`,{className:`git-status-bar__value`,children:x})]})}),(0,X.jsx)(Ig,{content:a(`git.statusbar.ahead`),children:(0,X.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--ahead`,type:`button`,"aria-label":a(`action.push`),disabled:S<=0,onClick:()=>z(`push`,S),children:[(0,X.jsx)($,{semantic:`git.footer.push`,size:13}),(0,X.jsx)(`span`,{className:`git-status-bar__value`,children:S})]})}),(0,X.jsx)(Ig,{content:a(`git.statusbar.behind`),children:(0,X.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--behind`,type:`button`,"aria-label":a(`action.pull`),disabled:C<=0,onClick:()=>z(`pull`,C),children:[(0,X.jsx)($,{semantic:`git.footer.pull`,size:13}),(0,X.jsx)(`span`,{className:`git-status-bar__value`,children:C})]})}),(0,X.jsx)(Ig,{content:E,children:(0,X.jsx)(Em,{"aria-label":D,className:`git-status-bar__item git-status-bar__item--actionable`,disabled:w,icon:(0,X.jsx)($,{semantic:`git.footer.refresh`,size:13,className:T?`spin`:void 0}),onClick:()=>void ae(),size:`sm`})})]}),R?(0,X.jsx)(Bm,{className:`git-status-bar__confirm`,dismissible:!L,closeDisabled:L,open:!0,onOpenChange:ne,title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{semantic:`git.action.warning`,size:16}),(0,X.jsx)(`span`,{children:O})]}),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:k}),(0,X.jsx)(`p`,{className:`dialog-helper`,children:a(`git.sync_confirm_helper`)})]}),cancelDisabled:L,cancelText:a(`action.cancel`),closeLabel:a(`action.close`),confirmText:M?j:A,confirmDisabled:M,onConfirm:()=>{re()}}):null,B?(0,X.jsxs)(jm,{className:`git-status-bar__confirm`,dismissible:!L,open:!0,onOpenChange:ne,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsxs)(Pm,{children:[(0,X.jsx)($,{semantic:`git.action.warning`,size:16}),(0,X.jsx)(`span`,{children:a(P===`push`?`git.push_confirm_title`:P===`pull`?`git.pull_confirm_title`:`git.fetch_label`)})]}),(0,X.jsx)(Em,{"aria-label":a(`action.close`),disabled:L,icon:(0,X.jsx)(pa,{size:14}),onClick:te,size:`sm`})]}),(0,X.jsx)(Fm,{children:B.details.canPrompt?(0,X.jsxs)(`form`,{id:h,className:`form-group`,onSubmit:e=>{e.preventDefault(),ie()},children:[(0,X.jsx)(`p`,{children:u(B.details)}),(0,X.jsx)(`span`,{className:`dialog-helper`,children:a(`git.auth_helper_http`)}),(0,X.jsx)(`label`,{htmlFor:`git-auth-username-${e}`,children:a(`git.auth_username`)}),(0,X.jsx)(rh,{id:`git-auth-username-${e}`,value:v.username,onChange:e=>y(t=>({...t,username:e.target.value})),placeholder:B.details.usernameHint??a(`git.auth_username_placeholder`),autoFocus:!0,disabled:I}),(0,X.jsx)(`label`,{htmlFor:`git-auth-password-${e}`,children:a(`git.auth_password`)}),(0,X.jsx)(rh,{id:`git-auth-password-${e}`,type:`password`,value:v.password,onChange:e=>y(t=>({...t,password:e.target.value})),placeholder:a(`git.auth_password_placeholder`),disabled:I})]}):(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`p`,{children:u(B.details)}),(0,X.jsx)(`span`,{className:`dialog-helper`,children:a(`git.auth_helper_unsupported`)})]})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:te,disabled:L,children:a(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,form:B.details.canPrompt?h:void 0,type:B.details.canPrompt?`submit`:`button`,disabled:!B.details.canPrompt||I||!v.username.trim()||!v.password,children:I?ee:F})]})]}):null]})};function eO({"aria-controls":e,"aria-expanded":t,"aria-haspopup":n,ariaLabel:r,branchName:i,branchSummary:a,disabled:o,onClick:s,onKeyDown:c}){return(0,X.jsx)(Ig,{content:i,children:(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-status-strip__branch`,onClick:s,onKeyDown:c,"aria-controls":e,"aria-expanded":t,"aria-haspopup":n,"aria-label":r,disabled:o,children:[(0,X.jsx)($,{semantic:`git.footer.branch`,size:11}),(0,X.jsx)(`span`,{className:`git-panel-status-strip__branch-text`,children:i})]})})}function tO({workspaceId:e,gitState:t,onOpenBranchSwitcher:n}){let r=Z(),i=Br(),{refreshWorkspace:a,status:o}=KD(e),s=t?.branch?.trim()||r(`git.no_branch`),c=t&&(t.ahead>0||t.behind>0)?[t.ahead>0?`↑${t.ahead}`:null,t.behind>0?`↓${t.behind}`:null].filter(Boolean).join(` `):null,l=(0,X.jsx)(eO,{ariaLabel:`${r(`git.current_branch`)}: ${s}`,branchName:s,branchSummary:c,disabled:!n,onClick:i===`mobile`?n:void 0});return(0,X.jsx)(`div`,{className:`git-panel-status-strip`,children:(0,X.jsxs)(`div`,{className:`git-panel-status-strip__left`,children:[i===`desktop`&&n?(0,X.jsx)(ZD,{workspaceId:e,onOpenBranchSwitcher:n,children:l}):l,(0,X.jsx)(`div`,{className:`git-panel-status-strip__meta`,children:(0,X.jsx)($D,{workspaceId:e,gitState:t,inline:!0,onRefresh:a,refreshStatus:o})})]})})}function nO({workspaceId:e,gitState:t,onOpenBranchSwitcher:n,flush:r=!1}){return(0,X.jsxs)(`div`,{className:`workspace-status-bar${r?` workspace-status-bar--flush`:``}`,children:[(0,X.jsx)(`div`,{className:`workspace-status-bar__left`,children:(0,X.jsx)(tO,{workspaceId:e,gitState:t,onOpenBranchSwitcher:n})}),(0,X.jsx)(`div`,{className:`workspace-status-bar__right`,children:(0,X.jsx)(WD,{})})]})}function rO(e){return e instanceof HTMLElement?e.isContentEditable||e.closest(`[contenteditable="true"]`)?!0:[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.tagName):!1}var iO=()=>{let e=(0,H.useRef)(null),t=JT(e),n=Z(),{createRequest:r,desktopSidebarView:i,focusMode:a,gitState:o,handleBottomMouseDown:s,handleConsumeCreateRequest:c,handleLeftMouseDown:l,handleOpenBranchSwitcher:u,handleOpenFileCreate:d,handleOpenFolderCreate:f,leftPanelWidth:p,leftPanelRef:m,mainAreaMode:h,setDesktopSidebarView:g,sidebarCollapsed:_,terminalPanelVisible:v,workspace:y,bottomPanelHeight:b,bottomPanelRef:x}=mE(),S=W(K_),C=T_(i);return oE(y.id),(0,H.useEffect)(()=>{let e=e=>{if(!(e.defaultPrevented||rO(e.target))&&(e.metaKey||e.ctrlKey)){if(e.key.toLowerCase()===`b`){e.preventDefault(),S(e=>!e);return}if(e.key===`1`){e.preventDefault(),g(`explorer`);return}if(e.key===`2`){e.preventDefault(),g(`search`);return}e.key===`3`&&(e.preventDefault(),g(`source-control`))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,S]),(0,X.jsxs)(`div`,{ref:e,className:`workspace-page workspace-page--desktop`,children:[(0,X.jsx)(HT,{fullscreenController:t}),(0,X.jsxs)(`div`,{className:`workspace-body`,children:[!a&&!_&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`aside`,{ref:m,className:`left-panel`,style:{width:`${p}px`},children:(0,X.jsxs)(`div`,{className:`nav-panel workspace-sidebar-panel`,children:[(0,X.jsx)(HD,{activeView:C,onSelectView:g}),(0,X.jsxs)(`div`,{className:`workspace-sidebar-panel__content`,children:[C===`explorer`?(0,X.jsx)(tD,{workspaceId:y.id,createRequest:r,onCreateRequestConsumed:c,onOpenFileCreate:d,onOpenFolderCreate:f}):null,C===`search`?(0,X.jsx)(VD,{workspaceId:y.id}):null,C===`source-control`?(0,X.jsxs)(`div`,{className:`workspace-sidebar-view`,children:[(0,X.jsx)(aS,{title:n(`workspace.sidebar.source_control`)}),(0,X.jsx)(`div`,{className:`workspace-sidebar-panel__body`,children:(0,X.jsx)(jD,{workspaceId:y.id,variant:`desktop`})})]}):null]})]})}),(0,X.jsx)(`div`,{className:`split-divider-v`,onMouseDown:l,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize left panel`})]}),(0,X.jsxs)(`div`,{className:`workspace-main-area`,children:[(0,X.jsx)(`div`,{className:`workspace-main-stage`,children:h===`editor`?(0,X.jsx)(rT,{}):(0,X.jsx)(`div`,{className:`agent-panes`,children:(0,X.jsx)(hw,{hydrateSessions:!1})})}),!a&&v&&(0,X.jsx)(`div`,{className:`split-divider-h`,onMouseDown:s,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize bottom panel`}),!a&&v&&(0,X.jsx)(`div`,{ref:x,className:`workspace-bottom-panel`,style:{height:`${b}px`},children:(0,X.jsx)(yT,{})})]})]}),(0,X.jsx)(nO,{align:`start`,workspaceId:y.id,gitState:o,onOpenBranchSwitcher:u})]})},aO=()=>{let e=U(Bp),t=Z();return e?(0,X.jsx)(iO,{},e.id):(0,X.jsx)(`div`,{className:`workspace-page workspace-page-empty`,children:(0,X.jsx)(`div`,{className:`workspace-empty-content`,children:(0,X.jsx)(`div`,{className:`workspace-empty-inner`,children:(0,X.jsx)(Sh,{style:{minHeight:`auto`,padding:0},title:(0,X.jsx)(`p`,{children:t(`workspace.no_workspace`)})})})})})},oO={minHeight:`auto`,padding:0,gap:0,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function sO({title:e,description:t,testId:n}){return(0,X.jsx)(`div`,{className:`workspace-resolving-shell`,"data-testid":n,children:(0,X.jsx)(`div`,{className:`workspace-resolving-card`,children:(0,X.jsx)(Sh,{style:oO,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`workspace-resolving-kicker`,children:Z()(`workspace.title`)}),(0,X.jsx)(`div`,{className:`workspace-resolving-title`,children:e})]}),description:(0,X.jsx)(`div`,{className:`workspace-resolving-desc`,children:t})})})})}function cO({title:e,description:t}){let n=Z();return(0,X.jsx)(sO,{title:e??n(`workspace.load_failed_title`),description:t??n(`workspace.load_failed_description`)})}function lO(){let e=Z();return(0,X.jsx)(sO,{testId:`workspace-resolving-shell`,title:e(`workspace.loading_title`),description:e(`workspace.loading_description`)})}function uO({children:e}){let t=U(Bp),n=U(Pp),r=U(Fp),i=Yt().pathname===`/workspace`;return!t&&n===`error`?(0,X.jsx)(cO,{description:r??`Failed to fetch workspace list`}):!t&&(n===`idle`||n===`loading`||i&&n===`ready`)?(0,X.jsx)(lO,{}):(0,X.jsx)(X.Fragment,{children:e})}function dO(){let e=(0,H.useRef)(0),t=Qt(),n=Yt(),r=U(Wr),i=U(xp),a=U(Op),o=U(Rp),s=U(Qa),c=U(Dp),l=U(Pp),u=W(jp),d=W(no),f=W(Mp),p=W(Np),m=W(Pp),h=W(Fp);(0,H.useEffect)(()=>{if(c===null)return;let g=c===!0;if(g&&!s){if(n.pathname!==`/login`){t(`/login`,{replace:!0});return}return}if(n.pathname===`/login`&&(!g||s)){t(`/`,{replace:!0});return}if(n.pathname!==`/session-gate`){if(r===`gated`){t(`/session-gate`,{replace:!0});return}if(!(n.pathname!==`/`&&n.pathname!==`/workspace`)&&r===`active`){if(l===`idle`){if(i!==`connected`)return;let t=e.current+1;e.current=t,m(`loading`),h(null),Promise.all([a(`workspace.list`,{}),a(`workspace.lastViewedTarget.get`,{})]).then(n=>{if(e.current!==t)return;let[r,i]=n;if(!r.ok){m(`error`),h(r.error?.message??`Failed to fetch workspace list`);return}let a=Array.isArray(r.data)?r.data:[],o={};for(let e of a)o[e.id]=e;f(o),p(a.map(e=>e.id));let s=i.ok&&i.data&&o[i.data.workspaceId]?i.data:null;d(s),s?.workspaceId&&u(s.workspaceId),m(`ready`),h(null)}).catch(n=>{e.current===t&&(m(`error`),h(n instanceof Error?n.message:`Failed to fetch workspace list`))});return}if(l===`ready`){if(n.pathname===`/`&&o.length>0){t(`/workspace`,{replace:!0});return}n.pathname===`/workspace`&&o.length===0&&t(`/`,{replace:!0})}}}},[r,c,s,i,a,n.pathname,t,p,f,u,d,h,m,o.length,l])}var fO=25e3,pO=`连接恢复较慢,可能是网络问题。如果长时间没有恢复,可以刷新页面。`,mO=`连接恢复较慢,长时间未恢复可刷新页面。`;function hO(){let e=U(Wr),t=U(Kr),n=U(xp),r=U(wp),i=Br()===`mobile`,[a,o]=(0,H.useState)(()=>Date.now());if((0,H.useEffect)(()=>{if(r===null||n!==`reconnecting`&&n!==`disconnected`)return;let e=r+fO-Date.now();if(e<=0){o(Date.now());return}let t=setTimeout(()=>{o(Date.now())},e);return()=>{clearTimeout(t)}},[n,r]),n===`connected`||n===`connecting`)return null;if(n===`rejected`||e===`gated`&&t===`displaced`)return(0,X.jsx)(`div`,{className:`connection-banner${i?` connection-banner--mobile`:``} connection-banner--error`,role:`status`,"aria-live":`polite`,children:(0,X.jsx)(`span`,{children:`另一个标签页已激活`})});let s=r!==null&&a-r>=fO&&(n===`reconnecting`||n===`disconnected`),c=s&&i,l=i?mO:pO;return(0,X.jsxs)(`div`,{className:[`connection-banner`,i?`connection-banner--mobile`:null,c?`connection-banner--stacked`:null].filter(Boolean).join(` `),role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`span`,{className:`connection-banner__primary`,children:`连接已断开,正在重新连接...`}),s?(0,X.jsx)(`span`,{className:`connection-banner__hint`,children:l}):null]})}var gO={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function _O(){dO();let e=U(Dp),t=Yt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname.startsWith(`/diagnostics`)||t.pathname===`/session-gate`;return(0,X.jsxs)(`div`,{className:`app`,children:[(0,X.jsx)(hO,{}),(0,X.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,X.jsx)(`div`,{className:`app-loading-shell`,children:(0,X.jsx)(`div`,{className:`app-loading-card`,children:(0,X.jsx)(Sh,{style:gO,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,X.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,X.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,X.jsxs)(Dn,{children:[(0,X.jsx)(Tn,{path:`/`,element:(0,X.jsx)(jx,{})}),(0,X.jsx)(Tn,{path:`/login`,element:(0,X.jsx)(zg,{})}),(0,X.jsx)(Tn,{path:`/session-gate`,element:(0,X.jsx)(Bg,{})}),(0,X.jsx)(Tn,{path:`/diagnostics`,element:(0,X.jsx)(Gv,{})}),(0,X.jsx)(Tn,{path:`/workspace`,element:(0,X.jsx)(uO,{children:(0,X.jsx)(aO,{})})}),(0,X.jsx)(Tn,{path:`/settings`,element:(0,X.jsx)(xx,{})}),(0,X.jsx)(Tn,{path:`*`,element:(0,X.jsx)(iy,{})})]})}),(0,X.jsx)(wy,{}),(0,X.jsx)(ty,{}),(0,X.jsx)(dy,{})]})}function vO({sessionId:e,workspaceId:t,onClose:n}){let r=Z(),i=W(cS),{closeDetails:a}=uS(e),{dialog:o,supervisor:s,mode:c,restoreStep:l,copy:u,isMaxSupervisionCountValid:d,recoverableTargets:f,selectedRecoverableTargetId:p,isRecoverableTargetsLoading:m,hasObjectiveChanged:h,hasChanges:g,close:_,updateDraft:v,openRestoreStep:y,closeRestoreStep:b,selectRecoverableTarget:x,confirm:S}=_S({workspaceId:t,sessionId:e}),[C,w]=(0,H.useState)(()=>s?`details`:null),[T,E]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(s){w(e=>e??`details`);return}w(e=>e===`details`?null:e),i(t=>t.sessionId===e&&t.mode===`enable`&&!t.open?t:{open:!1,sessionId:e,mode:`enable`,restoreStep:`form`,returnToDetails:!1,draftObjective:t.sessionId===e&&t.mode===`enable`?t.draftObjective:``,initialObjective:``,draftEvaluatorProviderId:t.sessionId===e&&t.mode===`enable`?t.draftEvaluatorProviderId:`claude`,draftEvaluatorModel:t.sessionId===e&&t.mode===`enable`?t.draftEvaluatorModel:``,draftMaxSupervisionCount:t.sessionId===e&&t.mode===`enable`?t.draftMaxSupervisionCount:`0`,draftScheduledAt:t.sessionId===e&&t.mode===`enable`?t.draftScheduledAt:``,recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1})},[e,i,s]),(0,H.useEffect)(()=>{!o.open||o.sessionId!==e||o.mode===`edit`&&w(`edit`)},[o.mode,o.open,o.sessionId,e]);let D=()=>{i({open:!0,sessionId:e,mode:`edit`,restoreStep:`form`,returnToDetails:!0,draftObjective:s?.objective??``,initialObjective:s?.objective??``,draftEvaluatorProviderId:s?.evaluatorProviderId??`claude`,draftEvaluatorModel:s?.evaluatorModel??``,draftMaxSupervisionCount:String(s?.maxSupervisionCount??0),draftScheduledAt:pS(s?.scheduledAt),recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1}),w(`edit`)},O=(0,X.jsx)(`div`,{className:`mobile-supervisor-sheet__detail`,children:(0,X.jsx)(wS,{mode:c,restoreStep:l,draftObjective:o.draftObjective,draftEvaluatorProviderId:o.draftEvaluatorProviderId,draftEvaluatorModel:o.draftEvaluatorModel,draftMaxSupervisionCount:o.draftMaxSupervisionCount,draftScheduledAt:o.draftScheduledAt,isMaxSupervisionCountValid:d,recoverableTargets:f,selectedRecoverableTargetId:p,isRecoverableTargetsLoading:m,onDraftObjectiveChange:e=>v({draftObjective:e}),onDraftEvaluatorProviderChange:e=>v({draftEvaluatorProviderId:e}),onDraftEvaluatorModelChange:e=>v({draftEvaluatorModel:e}),onDraftMaxSupervisionCountChange:e=>v({draftMaxSupervisionCount:e}),onDraftScheduledAtChange:e=>v({draftScheduledAt:e}),onOpenRestoreStep:()=>{y()},onCloseRestoreStep:b,onSelectRecoverableTarget:x})}),k=s&&C===`details`?(0,X.jsx)(`div`,{className:`mobile-supervisor-sheet__detail`,children:(0,X.jsx)(ES,{sessionId:e,workspaceId:t,onEdit:()=>{a(),D()}})}):null,A=(0,X.jsxs)(`div`,{className:`mobile-supervisor-sheet__footer`,children:[(0,X.jsx)(Q,{onClick:()=>{_(),s?w(`details`):(w(null),n())},children:r(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{if(c===`edit`&&l!==`restore`&&h){E(!0);return}(async()=>{await S()&&(a(),w(s?`details`:null),n())})()},disabled:l===`restore`?!p||m||!d:c===`edit`?!g||!o.draftObjective.trim()||!d:!o.draftObjective.trim()||!d,children:u.confirm})]});return s&&C===`details`?(0,X.jsx)(fm,{title:r(`supervisor.dialog.details.title`),kicker:r(`supervisor.title`),onClose:()=>{_(),a(),w(`details`),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:k}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fm,{title:u.title,kicker:r(`supervisor.title`),onBack:s&&C===`edit`?()=>{_(),a(),w(`details`)}:void 0,onClose:()=>{_(),a(),w(s?`details`:null),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:O,footer:A}),(0,X.jsx)(Bm,{open:T,onOpenChange:E,title:r(`supervisor.dialog.edit.reset_confirm_title`),description:r(`supervisor.dialog.edit.reset_confirm_description`),cancelText:r(`action.cancel`),confirmText:r(`supervisor.dialog.edit.confirm`),tone:`danger`,onConfirm:()=>{E(!1),(async()=>{await S()&&(a(),w(s?`details`:null),n())})()}})]})}var yO=`(orientation: landscape)`,bO=`(max-height: 540px)`;function xO(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return`default`;let e=window.matchMedia(yO).matches,t=window.matchMedia(bO).matches;return e&&t?`landscape-compact`:`default`}function SO(){let[e,t]=(0,H.useState)(xO);return(0,H.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(yO),n=window.matchMedia(bO),r=()=>{t(xO())};return e.addEventListener(`change`,r),n.addEventListener(`change`,r),r(),()=>{e.removeEventListener(`change`,r),n.removeEventListener(`change`,r)}},[]),e}var CO=`(prefers-reduced-motion: reduce)`;function wO(){return typeof window>`u`||typeof window.matchMedia!=`function`?`default`:window.matchMedia(CO).matches?`reduced`:`default`}function TO(){let[e,t]=(0,H.useState)(wO);return(0,H.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(CO),n=()=>{t(e.matches?`reduced`:`default`)};return e.addEventListener(`change`,n),n(),()=>{e.removeEventListener(`change`,n)}},[]),e}function EO(){let[e,t]=(0,H.useState)(0);return(0,H.useEffect)(()=>{let e=window.visualViewport;if(!e){t(0);return}let n=()=>{let n=Math.max(window.innerHeight-e.height-e.offsetTop,0);t(Math.round(n))};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n)}},[]),e}function DO(e){if(e.title?.trim())return e.title.trim();if(e.providerId)return e.providerId.replace(/\b\w/g,e=>e.toUpperCase());let t=e.id.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.id.replace(/[_-]/g,` `).toUpperCase()}function OO(e,t){switch(e){case`starting`:return t(`status.starting`);case`running`:return t(`status.running`);case`idle`:return t(`status.idle`);case`ended`:return t(`status.ended`);default:return e}}function kO({activeSessionId:e,activeWorkspaceId:t,defaultMode:n=`list`,sessions:r,onClose:i,onCloseSession:a,onSelectSession:o,onSessionCreated:s}){let c=U(Op),l=W(Vp),u=Z(),d=Xg(),[f,p]=(0,H.useState)(n===`create`?`providers`:`sessions`),m=r.find(t=>t.id===e)??r[0]??null,h=!!t,g=[{id:`claude`,title:`Claude`,icon:(0,X.jsx)($,{semantic:`agent.provider.claude`,size:16})},{id:`codex`,title:`Codex`,icon:(0,X.jsx)($,{semantic:`agent.provider.codex`,size:16})}],_=e=>{let t=y[e].runtime;return!!(t?.autoInstallSupported&&t.installReadiness===`ready`)},v=()=>{p(n===`create`?`providers`:`sessions`),i()},{states:y,launch:b}=nS(c,t??`__workspace_placeholder__`,(e,t)=>{l(t=>({...t,[e.id]:e})),s(e.id),v()}),x=[{kind:`actions`,id:`agent-actions`,items:[{id:`create`,label:u(`action.create_session`),icon:(0,X.jsx)($,{semantic:`agent.action.newSession`,size:16}),onAction:()=>p(`providers`),disabled:!h}]},{kind:`options`,id:`sessions`,items:r.length>0?r.map(e=>({id:e.id,label:DO(e),description:u(`mobile.agent.switch_to_agent`,{name:DO(e)}),meta:`${e.providerId.toUpperCase()} · ${OO(e.state,u)}`,trailingAction:{id:`${e.id}-close`,ariaLabel:u(`mobile.agent.close_current_session`),icon:(0,X.jsx)(pa,{size:16}),tone:`danger`,onAction:async()=>{await a(e.id),v()}}})):[]}],S=[{kind:`options`,id:`providers`,items:g.map(e=>{let n=y[e.id],r=n.loading||n.installJob?.status===`queued`||n.installJob?.status===`running`,i=n.inlineError===`manual`||!_(e.id)?(n.runtime?.manualGuideKeys??[]).map(e=>u(e)).join(` `):n.inlineError||n.installJob?.failure?.message;return{id:e.id,label:e.title,description:i||u(`mobile.agent.start_session`,{provider:e.title}),meta:u(r?`mobile.agent.starting`:`mobile.agent.start_new_session`),icon:e.icon,disabled:!h||r,trailingAction:!r&&i&&t?{id:`${e.id}-diagnostics`,ariaLabel:u(`diagnostics.actions.open_diagnostics`),icon:(0,X.jsx)(Ui,{size:16}),onAction:()=>{window.location.assign(X_({context:`session_start`,workspaceId:t,providerId:e.id}))}}:void 0}})}];return(0,X.jsx)(Jh,{className:`mobile-select-sheet--command`,title:u(f===`sessions`?`mobile.agent.title`:`session.provider_select`),sections:f===`sessions`?x:S,selectedId:f===`sessions`?m?.id??null:null,emptyText:f===`sessions`?u(`mobile.agent.empty`):void 0,closeOnSelect:!1,onBack:f===`providers`?()=>p(`sessions`):void 0,onClose:v,onSelect:e=>{if(f===`sessions`){t&&d({workspaceId:t,sessionId:e}),o(e),v();return}return b(e)}})}function AO({activeItem:e,onSelectItem:t}){let n=Z();return(0,X.jsxs)(`nav`,{className:`mobile-dock`,"aria-label":n(`mobile.dock.aria_label`),children:[(0,X.jsxs)(`button`,{type:`button`,className:`mobile-dock__item ${e===`agent`?`mobile-dock__item--active`:``}`,onClick:()=>t(`agent`),"aria-label":n(`mobile.dock.open_agent`),children:[(0,X.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:`mobile.dock.agent`,size:18})}),(0,X.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.agent`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mobile-dock__item ${e===`files`?`mobile-dock__item--active`:``}`,onClick:()=>t(`files`),"aria-label":n(`mobile.dock.open_files`),children:[(0,X.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:`mobile.dock.files`,size:18})}),(0,X.jsx)(`span`,{className:`mobile-dock__label`,children:n(`file.title`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mobile-dock__item ${e===`terminal`?`mobile-dock__item--active`:``}`,onClick:()=>t(`terminal`),"aria-label":n(`mobile.dock.open_terminal`),children:[(0,X.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:`mobile.dock.terminal`,size:18})}),(0,X.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.terminal`)})]})]})}function jO({workspaceId:e,onSelectFile:t}){let n=Z(),r=U(Op),i=W(d_(e)),{openLocation:a}=Cy(e),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),m=(0,H.useRef)(0),h=o.trim().length>0;return(0,H.useEffect)(()=>{let t=o.trim();if(!t){l([]),d(!1),p(!1);return}let n=!1;d(!0),p(!1);let i=++m.current,a=window.setTimeout(()=>{r(`file.search`,{workspaceId:e,query:t,limit:10}).then(e=>{if(!(n||i!==m.current)){if(!e.ok||!e.data){l([]),p(!0);return}l(e.data.files)}}).catch(()=>{n||(l([]),p(!0))}).finally(()=>{n||d(!1)})},150);return()=>{n=!0,window.clearTimeout(a)}},[r,o,e]),(0,X.jsxs)(`section`,{className:`workspace-sidebar-section workspace-quick-jump`,children:[(0,X.jsx)(`h2`,{className:`workspace-sidebar-section__title`,children:n(`workspace.quick_jump.title`)}),(0,X.jsxs)(`label`,{className:`workspace-quick-jump__search`,htmlFor:`quick-jump-${e}`,children:[(0,X.jsx)($,{semantic:`nav.search`,size:14,"aria-hidden":`true`}),(0,X.jsx)(`input`,{id:`quick-jump-${e}`,type:`search`,className:`workspace-quick-jump__input`,"aria-label":n(`workspace.quick_jump.title`),placeholder:n(`workspace.quick_jump.placeholder`),value:o,onChange:e=>s(e.target.value)})]}),h?(0,X.jsx)(`div`,{className:`workspace-quick-jump__results`,children:u?(0,X.jsx)(`p`,{className:`workspace-quick-jump__state`,children:n(`common.loading`)}):f?(0,X.jsx)(`p`,{className:`workspace-quick-jump__state`,children:n(`workspace.quick_jump.failed`)}):c.length===0?(0,X.jsx)(`p`,{className:`workspace-quick-jump__state`,children:n(`workspace.quick_jump.no_results`)}):c.map(n=>(0,X.jsxs)(`button`,{type:`button`,className:`workspace-quick-jump__item`,"aria-label":n.path,onClick:()=>{i(c_(n.path)),a({workspaceId:e,path:n.path,source:`manual`}),t?.(n.path)},children:[(0,X.jsx)(`span`,{className:`workspace-quick-jump__primary`,children:n.name}),(0,X.jsx)(`span`,{className:`workspace-quick-jump__secondary`,children:n.path})]},n.path))}):null]})}function MO({workspaceId:e,createRequest:t=null,onCreateRequestConsumed:n,collapseVersion:r=0,onOpenFileCreate:i,onOpenFolderCreate:a,onCollapseAll:o,routeToDetail:s}){return(0,X.jsxs)(`div`,{className:`mobile-explorer-panel`,children:[(0,X.jsx)(jO,{workspaceId:e,onSelectFile:s}),(0,X.jsx)($E,{workspaceId:e,onSelectFile:s}),(0,X.jsxs)(`section`,{className:`workspace-sidebar-section workspace-sidebar-section--fill`,children:[(0,X.jsx)(eD,{onOpenFileCreate:i,onOpenFolderCreate:a,onCollapseAll:o}),(0,X.jsx)(UE,{workspaceId:e,createRequest:t,onCreateRequestConsumed:n,onSelectFile:s,collapseVersion:r,variant:`mobile`,showSearch:!1})]})]})}function NO({workspaceId:e,route:t,activeView:n,createRequest:r=null,onCreateRequestConsumed:i,collapseVersion:a=0,onCreateFile:o,onCreateFolder:s,onCollapseAll:c,onRouteChange:l,onTabChange:u,editorState:d}){let f=Z();return t.kind===`detail`?(0,X.jsx)(`div`,{className:`mobile-files-sheet`,children:(0,X.jsx)(`div`,{className:`mobile-files-sheet__detail`,children:(0,X.jsx)(rT,{chrome:`content-only`,editorState:d})})}):(0,X.jsxs)(`div`,{className:`mobile-files-sheet mobile-files-sheet--root`,children:[(0,X.jsx)(`div`,{className:`mobile-files-sheet__segmented`,children:(0,X.jsx)(Rh,{"aria-label":f(`mobile.files.tabs`),onValueChange:e=>u?.(e),value:n,children:(0,X.jsxs)(zh,{className:`mobile-files-sheet__tabs`,children:[(0,X.jsx)(Bh,{"aria-label":f(`workspace.sidebar.explorer`),className:`mobile-files-sheet__segment`,value:`explorer`,children:(0,X.jsx)(`span`,{className:`mobile-files-sheet__segment-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Ni,{size:16,"aria-hidden":`true`})})}),(0,X.jsx)(Bh,{"aria-label":f(`workspace.sidebar.search`),className:`mobile-files-sheet__segment`,value:`search`,children:(0,X.jsx)(`span`,{className:`mobile-files-sheet__segment-icon`,"aria-hidden":`true`,children:(0,X.jsx)(ia,{size:16,"aria-hidden":`true`})})}),(0,X.jsx)(Bh,{"aria-label":f(`workspace.sidebar.source_control`),className:`mobile-files-sheet__segment`,value:`source-control`,children:(0,X.jsx)(`span`,{className:`mobile-files-sheet__segment-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Fi,{size:16,"aria-hidden":`true`})})})]})})}),(0,X.jsx)(`div`,{className:`mobile-files-sheet__content`,children:n===`explorer`?(0,X.jsx)(MO,{workspaceId:e,createRequest:r,onCreateRequestConsumed:i,onOpenFileCreate:o,onOpenFolderCreate:s,onCollapseAll:c,routeToDetail:e=>l?.({kind:`detail`,path:e}),collapseVersion:a}):n===`search`?(0,X.jsx)(VD,{workspaceId:e,variant:`mobile`,onSelectFile:e=>l?.({kind:`detail`,path:e})}):(0,X.jsx)(jD,{workspaceId:e,onPreviewOpen:e=>{l?.({kind:`detail`,...e.path?{path:e.path}:{},...e.title?{title:e.title}:{}})},variant:`mobile`})})]})}function PO({activeWorkspace:e,drawerOpen:t,fullscreenController:n,onOpenSettings:r,onToggleDrawer:i}){let a=Z(),o=Ug(e)||a(`mobile.workspace_drawer.select_title`);return(0,X.jsxs)(`header`,{className:`mobile-topbar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mobile-topbar__workspace-button`,onClick:()=>{i()},"aria-label":a(`mobile.topbar.switch_workspace`),"aria-expanded":t,children:[(0,X.jsx)(`span`,{className:`mobile-topbar__workspace-leading`,"aria-hidden":`true`,children:(0,X.jsx)(Gi,{size:18})}),(0,X.jsx)(`span`,{className:`mobile-topbar__workspace-name`,children:o})]}),(0,X.jsxs)(`div`,{className:`mobile-topbar__actions`,children:[(0,X.jsx)(Em,{"aria-label":a(`mobile.topbar.open_settings`),className:`mobile-topbar__icon-button`,icon:(0,X.jsx)($,{semantic:`nav.settings`,size:18}),onClick:r}),(0,X.jsx)(bT,{controller:n,className:`mobile-topbar__icon-button`,iconSize:18,dataTestId:`mobile-fullscreen-toggle`})]})]})}function FO({activeWorkspaceId:e,isOpen:t,workspaces:n,onClose:r,onOpenWorkspaceLauncher:i}){let a=Qt(),o=W(jp),s=Z(),c=wT(),l=Xg();return t?(0,X.jsxs)(`div`,{className:`mobile-drawer-layer`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-drawer-layer__backdrop`,"aria-label":s(`mobile.workspace_drawer.close`),onClick:r}),(0,X.jsxs)(`aside`,{className:`mobile-workspace-drawer`,"aria-label":s(`mobile.workspace_drawer.aria_label`),children:[(0,X.jsxs)(`div`,{className:`mobile-workspace-drawer__header`,children:[(0,X.jsxs)(`div`,{className:`mobile-workspace-drawer__header-copy`,children:[(0,X.jsx)(`div`,{className:`mobile-workspace-drawer__kicker`,children:s(`label.workspace`)}),(0,X.jsx)(`h2`,{className:`mobile-workspace-drawer__title`,children:s(`mobile.workspace_drawer.select_title`)})]}),(0,X.jsx)(Em,{"aria-label":s(`action.close`),className:`mobile-workspace-drawer__dismiss`,icon:(0,X.jsx)(pa,{size:16}),onClick:r,size:`lg`})]}),(0,X.jsx)(`div`,{className:`mobile-workspace-drawer__list`,children:n.map(t=>{let n=Ug(t)||t.id,i=t.id===e;return(0,X.jsxs)(`div`,{className:`mobile-workspace-drawer__item ${i?`mobile-workspace-drawer__item--active`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mobile-workspace-drawer__item-main`,"aria-current":i?`page`:void 0,"aria-label":s(`mobile.workspace_drawer.switch_to_workspace`,{name:n}),onClick:()=>{if(i){a(`/workspace`),r();return}l({workspaceId:t.id}),o(t.id),a(`/workspace`),r()},children:[(0,X.jsxs)(`span`,{className:`mobile-workspace-drawer__item-name-row`,children:[(0,X.jsx)(`span`,{className:`mobile-workspace-drawer__item-name`,children:n}),i?(0,X.jsxs)(`span`,{className:`mobile-workspace-drawer__item-state`,children:[(0,X.jsx)(gi,{size:12}),(0,X.jsx)(`span`,{children:s(`worktree.current`)})]}):null]}),(0,X.jsx)(`span`,{className:`mobile-workspace-drawer__item-path`,children:t.path})]}),(0,X.jsx)(Em,{"aria-label":s(`mobile.workspace_drawer.close_workspace`,{name:n}),className:`mobile-workspace-drawer__item-close`,icon:(0,X.jsx)(pa,{size:16}),onClick:()=>{c(t.id,{navigateHomeWhenEmpty:!0}).then(e=>{e&&r()})},size:`lg`})]},t.id)})}),(0,X.jsx)(`div`,{className:`mobile-workspace-drawer__footer`,children:(0,X.jsxs)(`button`,{type:`button`,className:`mobile-workspace-drawer__footer-button`,onClick:()=>{i(),r()},children:[(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:14}),(0,X.jsx)(`span`,{children:s(`tooltip.new_workspace`)})]})})]})]}):null}function IO(e,t,n,r,i){let a=new Set(n.map(e=>e.id)),o=new Set(e);if(r&&a.has(r))return{sessionId:r,missingFromLayout:!o.has(r)};if(i&&a.has(i))return{sessionId:i,missingFromLayout:!o.has(i)};let s=[...t].sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0]?.id??t[0]?.id??null;return{sessionId:s,missingFromLayout:s?!o.has(s):!1}}function LO(){let e=(0,H.useRef)(null),t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=JT(e),i=Z(),a=Qt(),o=U(to),s=U(no),c=W(ro),l=U(lS),u=U(cS),{activeSession:d,activeWorkspaceId:f,closeMobileSession:p,closeMobileSheet:m,diffPreview:h,handleMobileSessionCreated:g,handleOpenBranchSwitcher:_,gitState:v,mobileActiveSessionId:y,mobileAgentSessions:b,mobileFilesRoute:x,mobileSheet:S,openMobileSheet:C,orderedSessions:w,restoreMobileSession:T,selectMobileSession:E,updateMobileFilesRoute:D,workspace:O,workspaces:k}=mE(),{persistUiState:A}=Bv(f??`__workspace_empty__`),[j,M]=(0,H.useState)(!1),[N,P]=(0,H.useState)(!1),[F,ee]=(0,H.useState)(`explorer`),[I,L]=(0,H.useState)(null),[R,z]=(0,H.useState)(0),[te,ne]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),ae=EO(),B=SO(),oe=TO(),se=Hw(),ce=O?.uiState?.activeSessionId??null,V=s?.workspaceId===O?.id?s.sessionId??null:null;(0,H.useEffect)(()=>{if(!O||t.current===O.id||b.length===0&&w.length===0)return;let e=IO(w.map(e=>e.id),w,b,V,ce);if(!e.sessionId){t.current=O.id;return}if(t.current=O.id,e.missingFromLayout){T(e.sessionId);return}e.sessionId!==y&&T(e.sessionId)},[y,b,w,V,ce,T,O]),(0,H.useEffect)(()=>{if(!O){t.current=null,n.current=null;return}y&&n.current!==y&&(n.current=y,O.uiState.activeSessionId!==y&&A({activeSessionId:y}))},[y,A,O]),(0,H.useEffect)(()=>{o&&o!==y&&w.some(e=>e.id===o)&&E(o)},[y,w,o,E]),(0,H.useEffect)(()=>(c(y),()=>{c(null)}),[y,c]),(0,H.useEffect)(()=>{!d||S===`supervisor`||(l.open&&l.sessionId===d.id||u.open&&u.sessionId===d.id)&&(P(!1),C(`supervisor`))},[d,S,C,l.open,l.sessionId,u.open,u.sessionId]),(0,H.useEffect)(()=>{if(!(S!==`files`||x.kind!==`detail`)&&!(h?.source===`commit`&&x.path===h.path&&x.title===h.title)){if(se.activeFilePath){(x.path!==se.activeFilePath||x.title!==void 0)&&D({kind:`detail`,path:se.activeFilePath});return}if(h?.source===`commit`){(x.path!==h.path||x.title!==h.title)&&D({kind:`detail`,path:h.path,title:h.title});return}m()}},[m,h,se.activeFilePath,x,S,D]);let le=x.kind===`detail`?i(`file.title`):null,ue=e=>{L(t=>({id:(t?.id??0)+1,mode:e,baseDir:null}))},de=x.kind===`detail`?(0,X.jsx)(tT,{state:se,variant:`mobile`}):null,fe=S===`files`?{title:x.kind===`detail`?x.title??x.path?.split(`/`).pop()??i(`mobile.files.editor_fallback`):i(F===`explorer`?`workspace.sidebar.explorer`:F===`search`?`workspace.sidebar.search`:`workspace.sidebar.source_control`),body:f?(0,X.jsx)(NO,{workspaceId:f,route:x,activeView:F,createRequest:I,onCreateRequestConsumed:()=>L(null),collapseVersion:R,onCreateFile:()=>ue(`file`),onCreateFolder:()=>ue(`folder`),onCollapseAll:()=>z(e=>e+1),onRouteChange:D,onTabChange:ee,onCloseSheet:m,editorState:se}):null,footer:f?(0,X.jsx)(nO,{workspaceId:f,gitState:v,onOpenBranchSwitcher:_,flush:!0}):null,kicker:le,onBack:x.kind===`root`?void 0:()=>D({kind:`root`}),backLabel:i(`action.back`),headerAction:de,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--files`}:S===`terminal`?{title:i(`label.terminal`),body:(0,X.jsx)(`div`,{className:`mobile-terminal-sheet mobile-terminal-sheet--fullscreen`,children:(0,X.jsx)(yT,{chrome:`mobile-fullscreen`,onMobileHeaderActionsChange:ie})}),footer:f?(0,X.jsx)(nO,{workspaceId:f,gitState:v,onOpenBranchSwitcher:_,flush:!0}):null,kicker:null,headerAction:re,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--terminal`}:null,pe=e=>{if(e===`agent`){P(e=>!e);return}P(!1),C(e)},me=N?`agent`:S===`files`||S===`terminal`?S:null;return(0,X.jsxs)(`div`,{ref:e,className:`mobile-shell mobile-shell--${B} mobile-shell--motion-${oe}`,"data-testid":`mobile-shell`,"data-layout-mode":B,"data-motion-mode":oe,children:[(0,X.jsx)(PO,{activeWorkspace:O,drawerOpen:j,fullscreenController:r,onOpenSettings:()=>{P(!1),a(`/settings`)},onToggleDrawer:()=>{P(!1),M(e=>!e)}}),(0,X.jsx)(`main`,{className:`mobile-shell__viewport`,children:(0,X.jsx)(`div`,{className:`mobile-shell__content`,children:w.length>0?(0,X.jsx)(X.Fragment,{children:d?(0,X.jsx)(`section`,{className:`mobile-shell__agent-stage`,children:(0,X.jsx)(aw,{sessionId:d.id,showHeaderActions:!1,showSupervisorInline:d.capability===`full`&&d.state!==`draft`&&d.state!==`ended`})}):null}):(0,X.jsx)(`section`,{className:`mobile-shell__agent-empty`,"data-testid":`mobile-agent-empty`,children:(0,X.jsx)(`div`,{className:`mobile-shell__empty-content mobile-shell__empty-content--flat`,children:(0,X.jsxs)(`div`,{className:`mobile-shell__empty-state`,children:[(0,X.jsx)(`div`,{className:`mobile-shell__empty-heading`,children:(0,X.jsx)(`p`,{className:`mobile-shell__empty-title`,children:i(`mobile.empty.start_session`)})}),(0,X.jsx)(`div`,{className:`mobile-shell__placeholder-copy`,children:(0,X.jsx)(`p`,{children:i(`mobile.empty.files_terminal_hint`)})}),(0,X.jsx)(`div`,{className:`mobile-shell__empty-action-row`,children:(0,X.jsx)(`button`,{type:`button`,className:`mobile-shell__empty-cta`,onClick:()=>P(!0),children:i(`action.create_session`)})})]})})})})}),(0,X.jsxs)(`div`,{className:`mobile-shell__bottom-stack`,"data-testid":`mobile-bottom-stack`,style:{"--mobile-keyboard-inset":`${ae}px`},children:[(0,X.jsx)(`div`,{className:`mobile-dock-shell`,children:(0,X.jsx)(AO,{activeItem:me,onSelectItem:pe})}),f?(0,X.jsx)(nO,{workspaceId:f,gitState:v,onOpenBranchSwitcher:_}):null]}),N?(0,X.jsx)(kO,{activeSessionId:y,activeWorkspaceId:f,defaultMode:b.length===0?`create`:`list`,sessions:b,onClose:()=>P(!1),onCloseSession:p,onSelectSession:E,onSessionCreated:g}):null,S===`supervisor`&&d?(0,X.jsx)(vO,{sessionId:d.id,workspaceId:d.workspaceId,onClose:()=>{P(!1),m()}}):null,fe?(0,X.jsx)(fm,{title:fe.title,body:fe.body,onClose:()=>{P(!1),m()},kicker:fe.kicker??void 0,onBack:fe.onBack,backLabel:fe.backLabel,headerAction:`headerAction`in fe?fe.headerAction:void 0,bodyClassName:fe.bodyClassName,contentClassName:fe.contentClassName,footer:`footer`in fe?fe.footer:void 0,fullscreen:fe.fullscreen}):null,(0,X.jsx)(FO,{activeWorkspaceId:f,isOpen:j,workspaces:k,onClose:()=>M(!1),onOpenWorkspaceLauncher:()=>{P(!1),ne(!0)}}),te?(0,X.jsx)(Qv,{onClose:()=>ne(!1)}):null]})}var RO={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function zO(){dO();let e=U(Dp),t=Yt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname.startsWith(`/diagnostics`)||t.pathname===`/session-gate`;return(0,X.jsxs)(`div`,{className:`app`,children:[(0,X.jsx)(hO,{}),(0,X.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,X.jsx)(`div`,{className:`app-loading-shell`,children:(0,X.jsx)(`div`,{className:`app-loading-card`,children:(0,X.jsx)(Sh,{style:RO,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,X.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,X.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,X.jsxs)(Dn,{children:[(0,X.jsx)(Tn,{path:`/`,element:(0,X.jsx)(jx,{})}),(0,X.jsx)(Tn,{path:`/login`,element:(0,X.jsx)(zg,{})}),(0,X.jsx)(Tn,{path:`/session-gate`,element:(0,X.jsx)(Bg,{})}),(0,X.jsx)(Tn,{path:`/diagnostics`,element:(0,X.jsx)(Gv,{})}),(0,X.jsx)(Tn,{path:`/workspace`,element:(0,X.jsx)(uO,{children:(0,X.jsx)(LO,{})})}),(0,X.jsx)(Tn,{path:`/settings`,element:(0,X.jsx)(xx,{})}),(0,X.jsx)(Tn,{path:`*`,element:(0,X.jsx)(iy,{})})]})}),(0,X.jsx)(ty,{}),(0,X.jsx)(QD,{}),(0,X.jsx)(dy,{})]})}export{y_ as $,wn as $t,oS as A,Ep as At,By as B,Wa as Bt,aC as C,Dp as Ct,OS as D,Cp as Dt,jS as E,Op as Et,Vy as F,Qa as Ft,ty as G,wa as Gt,dy as H,Va as Ht,Ny as I,$a as It,J_ as J,Kr as Jt,Qv as K,pa as Kt,My as L,Za as Lt,jx as M,vp as Mt,xx as N,yp as Nt,TS as O,wp as Ot,Ob as P,io as Pt,p_ as Q,mr as Qt,Ay as R,Xa as Rt,aw as S,Pp as St,iC as T,xp as Tt,oy as U,Oa as Ut,by as V,ja as Vt,iy as W,ka as Wt,g_ as X,Ur as Xt,__ as Y,Wr as Yt,m_ as Z,Br as Zt,UE as _,Vp as _t,NO as a,U as an,e_ as at,oT as b,Mp as bt,_O as c,ge as cn,Ig as ct,aO as d,Bm as dt,Tn as en,u_ as et,nO as f,$ as ft,lD as g,tm as gt,CD as h,Z as ht,PO as i,Te as in,$g as it,aS as j,bp as jt,cS as k,Tp as kt,uO as l,fe as ln,jh as lt,jD as m,fm as mt,LO as n,je as nn,t_ as nt,AO as o,W as on,Bg as ot,QD as p,Em as pt,tv as q,Gr as qt,FO as r,ye as rn,Qg as rt,vO as s,ve as sn,zg as st,zO as t,Dn as tn,f_ as tt,cO as u,Sh as ut,HT as v,jp as vt,oC as w,Sp as wt,iT as x,Fp as xt,yT as y,Np as yt,Fy as z,Ga as zt};
|
|
109
|
-
//# sourceMappingURL=components-
|
|
106
|
+
`):``}function _x(e,t){return Object.fromEntries(t.map(t=>[t.id,gx(e[`providers.${t.id}.additionalArgs`])]))}function vx(e){switch(e){case`general`:return`settings.notifications_channel_hint`;case`providers`:return`settings.provider.command_preview_hint`;case`appearance`:return`settings.theme.hint`;case`shortcuts`:return`settings.shortcuts.hint`;case`about`:return`settings.about.description`}}var yx=[{titleKey:`settings.mobile_groups.workspace_runtime`,sections:[`general`,`providers`]},{titleKey:`settings.mobile_groups.interface_interaction`,sections:[`appearance`,`shortcuts`,`about`]}];function bx(e){let t=new Map(e.map(e=>[e.id,e])),n=yx.flatMap(e=>e.sections);if(n.length!==e.length)throw Error(`Mobile settings groups are out of sync with available sections.`);for(let e of n)if(!t.has(e))throw Error(`Missing mobile settings section mapping for "${e}".`);return yx.map(e=>({titleKey:e.titleKey,sections:e.sections.map(e=>t.get(e))}))}function xx(){let e=Z(),t=e(`settings.load_failed_unknown`),n=Yt(),r=Qt(),i=Br()===`mobile`,a=qb(),o=U(xp),s=U(Ep),c=U(zp),l=(()=>{let e=new URLSearchParams(n.search).get(`section`);return ex.some(t=>t.id===e)?e:null})(),u=(0,H.useRef)(l),[d,f]=(0,H.useState)(()=>l?{kind:`detail`,section:l}:i?{kind:`root`,lastSection:ux}:{kind:`detail`,section:ux}),[p]=(0,H.useState)([{id:`claude`,displayName:`Claude`},{id:`codex`,displayName:`Codex`}]),[m,h]=(0,H.useState)(!0),[g,_]=(0,H.useState)(!0),[v,y]=(0,H.useState)(600),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(0),[w,T]=(0,H.useState)(10),[E,D]=(0,H.useState)(!0),[O,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(`auto`),[M,N]=(0,H.useState)(`standard`),[P,F]=(0,H.useState)({}),ee=yo(),[I,L]=(0,H.useState)(ee.autoCheckEnabled),[R,z]=(0,H.useState)(ee.checkIntervalSec),[te,ne]=(0,H.useState)(`default`),[re,ie]=(0,H.useState)(null),[ae,B]=(0,H.useState)(0),[oe,se]=Te(Za),[ce,V]=Te(io),[le,ue]=Te(Xa),de=U(By),fe=W(ay),pe=W(By),me=W(Ty),he=ve(),ge=(0,H.useRef)(t),_e=(0,H.useRef)({theme:0,personalization:0,locale:0,lspRuntimeMode:0,terminalRenderer:0,terminalCopyOnSelect:0,desktopTerminalFontSize:0,mobileTerminalFontSize:0}),ye=(0,H.useRef)({autoCheckEnabled:0,checkIntervalSec:0}),be=d.kind===`detail`?d.section:d.lastSection,xe=i?tx:ex,Se=xe.find(e=>e.id===be)??xe[0],Ce=e=>{pe({...he.get(By),...e})};(0,H.useEffect)(()=>{ge.current=t},[t]),(0,H.useEffect)(()=>{f(e=>i?u.current&&e.kind===`detail`&&e.section===u.current?(u.current=null,e):e.kind===`root`?e:{kind:`root`,lastSection:e.section}:e.kind===`detail`?e:{kind:`detail`,section:e.lastSection})},[i]),(0,H.useEffect)(()=>{if(o!==`connected`)return;let e=!1;return(async()=>{let t={..._e.current},n={...ye.current},r=await a(`settings.get`,{});if(r===null)return;if(!r.ok||!r.data){e||ie(r.error?.message??ge.current);return}let i=r.data;if(e)return;ie(null),typeof i[`notifications.enabled`]==`boolean`&&h(i[`notifications.enabled`]),typeof i[`notifications.soundEnabled`]==`boolean`&&_(i[`notifications.soundEnabled`]),ye.current.autoCheckEnabled===n.autoCheckEnabled&&L(vo(i[`updates.autoCheckEnabled`])),ye.current.checkIntervalSec===n.checkIntervalSec&&z(_o(i[`updates.checkIntervalSec`])),_e.current.lspRuntimeMode===t.lspRuntimeMode&&(i[`lsp.mode`]===`auto`||i[`lsp.mode`]===`off`?(j(i[`lsp.mode`]),me(i[`lsp.mode`])):(j(`auto`),me(`auto`))),y(so(i[`supervisor.evaluationTimeoutSec`])),x(co(i[`supervisor.retryEnabled`])),C(lo(i[`supervisor.retryMaxCount`])),T(uo(i[`supervisor.retryDelaySec`])),D(fo(i[`supervisor.retryOnTimeout`])),k(po(i[`supervisor.retryOnEvaluatorError`])),fe({enabled:typeof i[`notifications.enabled`]==`boolean`?i[`notifications.enabled`]:!0,soundEnabled:typeof i[`notifications.soundEnabled`]==`boolean`?i[`notifications.soundEnabled`]:!0}),(i[`appearance.terminalRenderer`]===`standard`||i[`appearance.terminalRenderer`]===`compatibility`)&&_e.current.terminalRenderer===t.terminalRenderer&&N(i[`appearance.terminalRenderer`]);let o=_e.current.terminalCopyOnSelect===t.terminalCopyOnSelect,s=_e.current.desktopTerminalFontSize===t.desktopTerminalFontSize,c=_e.current.mobileTerminalFontSize===t.mobileTerminalFontSize;if(o||s||c){let e=he.get(By),t=s?Fy(i,`desktop`):Iy(e,`desktop`),n=c?Fy(i,`mobile`):Iy(e,`mobile`),r=My(i),a=Ny(i,`desktop`),l=Ny(i,`mobile`);pe({copyOnSelect:o?Ay(i):e.copyOnSelect,desktopFontSize:t,mobileFontSize:n,fontSize:a||l||r?t:e.fontSize})}if((i[`appearance.locale`]===`zh`||i[`appearance.locale`]===`en`)&&_e.current.locale===t.locale&&se(i[`appearance.locale`]),_e.current.personalization===t.personalization&&V(Va(i)),(Object.prototype.hasOwnProperty.call(i,`appearance.themeId`)||Object.prototype.hasOwnProperty.call(i,`appearance.theme`))&&_e.current.theme===t.theme){let e=ka(i[`appearance.themeId`]??i[`appearance.theme`]);ue(e),document.documentElement.setAttribute(`data-theme`,Oa(e).documentThemeAttr)}F(_x(i,p))})(),()=>{e=!0}},[o,a,se,fe,V,me,pe,ue,ae,he]);let we=e=>{_e.current.locale+=1,se(e)},Ee=e=>{_e.current.theme+=1,ue(e)},De=async e=>{let t=ce;_e.current.personalization+=1,V(e);let n=await a(`settings.update`,{settings:{appearance:{personalization:e}}});return n.ok?!0:(V(t),ie(n.error?.message??ge.current),!1)},Oe=e=>{_e.current.terminalRenderer+=1,N(e)},ke=e=>{_e.current.terminalCopyOnSelect+=1,Ce({copyOnSelect:e})},Ae=e=>{_e.current.desktopTerminalFontSize+=1,Ce({desktopFontSize:e,fontSize:e})},je=e=>{_e.current.mobileTerminalFontSize+=1,Ce({mobileFontSize:e})},Me=async e=>{if(e===A)return;_e.current.lspRuntimeMode+=1;let t=await a(`settings.update`,{settings:{lsp:{mode:e}}});if(t===null||!t.ok)return;let n=await a(`lsp.setMode`,{mode:e});n===null||!n.ok||(j(e),me(e))},Ne=async e=>await a(`settings.update`,{settings:{updates:e}}),Pe=async e=>{ye.current.autoCheckEnabled+=1,L(e);let t=await Ne({autoCheckEnabled:e});t!==null&&(t.ok||L(t=>!e))},Fe=async e=>{if(e===R)return;let t=R;ye.current.checkIntervalSec+=1,z(e);let n=await Ne({checkIntervalSec:e});n!==null&&(n.ok||z(t))};(0,H.useEffect)(()=>{be!==`providers`&&ne(`default`)},[be]);let Ie=()=>{let e=$b(!!c);if(e===`history`){r(-1);return}r(e)},Le=()=>{if(i&&d.kind===`detail`){f({kind:`root`,lastSection:d.section});return}Ie()},Re=()=>{switch(be){case`general`:return(0,X.jsx)(kx,{notificationsEnabled:m,setNotificationsEnabled:h,soundEnabled:g,setSoundEnabled:_,supervisorEvaluationTimeoutSec:v,setSupervisorEvaluationTimeoutSec:y,supervisorRetryEnabled:b,setSupervisorRetryEnabled:x,supervisorRetryMaxCount:S,setSupervisorRetryMaxCount:C,supervisorRetryDelaySec:w,setSupervisorRetryDelaySec:T,supervisorRetryOnTimeout:E,setSupervisorRetryOnTimeout:D,supervisorRetryOnEvaluatorError:O,setSupervisorRetryOnEvaluatorError:k,lspRuntimeMode:A,onLspRuntimeModeSelect:Me,terminalRenderer:M,setTerminalRenderer:Oe,terminalCopyOnSelect:de.copyOnSelect,setTerminalCopyOnSelect:ke,activeWorkspaceId:c});case`appearance`:return(0,X.jsx)(Ax,{desktopTerminalFontSize:Iy(de,`desktop`),mobileTerminalFontSize:Iy(de,`mobile`),locale:oe,personalization:ce,setDesktopTerminalFontSize:Ae,setLocale:we,setMobileTerminalFontSize:je,savePersonalization:De,theme:le,setTheme:Ee});case`providers`:return(0,X.jsx)(Xb,{providers:p,additionalArgsById:P,setAdditionalArgsById:F,isMobile:i,activeWorkspaceId:c,onLayoutModeChange:ne});case`shortcuts`:return(0,X.jsx)(lx,{});case`about`:return(0,X.jsx)(Ky,{autoCheckEnabled:I,checkIntervalSec:R,onAutoCheckEnabledChange:Pe,onCheckIntervalChange:Fe,locale:oe});default:return null}},ze=()=>(0,X.jsx)(`main`,{className:`settings-content settings-content--mobile-root`,children:(0,X.jsx)(`div`,{className:`settings-mobile-root`,"data-testid":`settings-mobile-root`,children:bx(xe).map(t=>(0,X.jsxs)(`section`,{className:`settings-mobile-group`,children:[(0,X.jsx)(`h2`,{className:`settings-mobile-group__title`,children:e(t.titleKey)}),(0,X.jsx)(`div`,{className:`settings-mobile-group__list`,children:t.sections.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`settings-mobile-item`,"aria-label":e(t.labelKey),onClick:()=>f({kind:`detail`,section:t.id}),children:[(0,X.jsx)(`span`,{className:`settings-mobile-item__icon-shell`,"aria-hidden":`true`,children:(0,X.jsx)(`span`,{className:`settings-mobile-item__icon`,children:(0,X.jsx)($,{semantic:t.iconSemantic,size:18})})}),(0,X.jsxs)(`span`,{className:`settings-mobile-item__copy`,children:[(0,X.jsx)(`span`,{className:`settings-mobile-item__label`,children:e(t.labelKey)}),(0,X.jsx)(`span`,{className:`settings-mobile-item__hint`,children:e(vx(t.id))})]}),(0,X.jsx)(yi,{size:16,className:`settings-mobile-item__arrow`})]},t.id))})]},t.titleKey))})}),Be=i&&d.kind===`root`,Ve=i&&d.kind===`detail`,He=e(i?Be?`settings.title`:Se.labelKey:`settings.title`);return(0,X.jsxs)(`div`,{className:`settings-page ${i?`settings-page--mobile`:``}`,children:[(0,X.jsx)(`header`,{className:`settings-header`,children:i?(0,X.jsx)(rm,{title:He,titleAs:`div`,onBack:Le,backLabel:e(`action.back`)}):(0,X.jsx)(nm,{title:e(`settings.title`),titleAs:`h1`,level:`secondary`,onBack:Le,backLabel:e(`action.back`)})}),Be?ze():(0,X.jsxs)(`div`,{className:`settings-body ${i?`settings-body--mobile`:``} ${Ve?`settings-body--mobile-detail`:``} ${te===`fill-height`?`settings-body--fill-height`:``}`,children:[i?null:(0,X.jsx)(`aside`,{className:`settings-sidebar`,children:(0,X.jsx)(`nav`,{className:`settings-nav`,children:xe.map(({id:t,labelKey:n,iconSemantic:r})=>(0,X.jsx)(Sx,{icon:(0,X.jsx)($,{semantic:r,size:16}),label:e(n),active:be===t,onClick:()=>f({kind:`detail`,section:t})},t))})}),(0,X.jsx)(`main`,{className:`settings-content ${i?`settings-content--mobile`:``} ${Ve?`settings-content--mobile-detail`:``} ${te===`fill-height`?`settings-content--fill-height`:``}`,children:(0,X.jsxs)(`div`,{className:`settings-content-surface`,children:[re&&(0,X.jsx)(jh,{role:`alert`,tone:`error`,title:e(`settings.load_failed`),message:re,action:(0,X.jsx)(`button`,{type:`button`,className:`settings-link`,onClick:()=>B(e=>e+1),children:e(`action.refresh`)})}),Re()]})})]}),(0,X.jsx)(`footer`,{className:`settings-footer ${i?`settings-footer--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`settings-footer__meta`,children:[(0,X.jsx)(`span`,{className:`settings-autosave`,children:e(`settings.autosave_hint`)}),(0,X.jsxs)(`span`,{className:`settings-version`,children:[`v`,s?.version??`0.0.0`]})]})})]})}function Sx({icon:e,label:t,active:n,onClick:r}){return(0,X.jsxs)(`button`,{className:`settings-nav-item ${n?`settings-nav-item-active`:``}`,onClick:r,children:[(0,X.jsx)(`span`,{className:`settings-nav-icon`,children:e}),(0,X.jsx)(`span`,{className:`settings-nav-label`,children:t}),n&&(0,X.jsx)(yi,{size:14,className:`settings-nav-arrow`})]})}function Cx(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<1||n>86400?null:n}function wx(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<0||n>20?null:n}function Tx(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<1||n>3600?null:n}function Ex(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isSafeInteger(n)||n<10||n>18?null:n}function Dx(e,t,n){let r=e.trim();if(!/^\d+$/.test(r))return null;let i=Number(r);return!Number.isSafeInteger(i)||i<t||i>n?null:i}function Ox(e){let t={};for(let n of fx)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];r!==void 0&&(t[n]=r)}return t}function kx({notificationsEnabled:e,setNotificationsEnabled:t,soundEnabled:n,setSoundEnabled:r,supervisorEvaluationTimeoutSec:i,setSupervisorEvaluationTimeoutSec:a,supervisorRetryEnabled:o,setSupervisorRetryEnabled:s,supervisorRetryMaxCount:c,setSupervisorRetryMaxCount:l,supervisorRetryDelaySec:u,setSupervisorRetryDelaySec:d,supervisorRetryOnTimeout:f,setSupervisorRetryOnTimeout:p,supervisorRetryOnEvaluatorError:m,setSupervisorRetryOnEvaluatorError:h,lspRuntimeMode:g,onLspRuntimeModeSelect:_,terminalRenderer:v,setTerminalRenderer:y,terminalCopyOnSelect:b,setTerminalCopyOnSelect:x,activeWorkspaceId:S}){let C=Z(),w=Qt(),T=(0,H.useId)(),E=(0,H.useId)(),D=(0,H.useId)(),O=(0,H.useId)(),k=(0,H.useId)(),A=(0,H.useId)(),j=(0,H.useId)(),M=(0,H.useId)(),N=(0,H.useId)(),P=(0,H.useId)(),F=qb(),ee=W(ay),[I,L]=(0,H.useState)(`unavailable`),[R,z]=(0,H.useState)(`unsupported`),[te,ne]=(0,H.useState)(String(i)),[re,ie]=(0,H.useState)(null),[ae,B]=(0,H.useState)(String(c)),[oe,se]=(0,H.useState)(String(u)),[ce,V]=(0,H.useState)(null),[le,ue]=(0,H.useState)(null),de=async e=>await F(`settings.update`,{settings:e}),fe=e=>{ee(e)};(0,H.useEffect)(()=>{if(z(hx()),`Notification`in window){L(Notification.permission);return}L(`unavailable`)},[]),(0,H.useEffect)(()=>{ne(String(i))},[i]),(0,H.useEffect)(()=>{B(String(c))},[c]),(0,H.useEffect)(()=>{se(String(u))},[u]),(0,H.useEffect)(()=>{ie(null)},[i]),(0,H.useEffect)(()=>{V(null)},[c]),(0,H.useEffect)(()=>{ue(null)},[u]);let pe=async()=>{`Notification`in window&&L(await Notification.requestPermission())},me=async()=>{let e=Cx(te);if(e===null){ne(String(i)),ie(C(`settings.supervisor.validation_error`,{max:ao}));return}if(e===i){ne(String(e)),ie(null);return}let t=await de({supervisor:{evaluationTimeoutSec:e}});if(t!==null){if(!t.ok){ne(String(i)),ie(t.error?.message||C(`settings.config_files.save_failed`));return}a(e),ne(String(e)),ie(null)}},he=async()=>{let e=wx(ae);if(e===null){B(String(c)),V(C(`settings.supervisor.retry_max_count_validation_error`,{max:20}));return}if(e===c){B(String(e)),V(null);return}let t=await de({supervisor:{retryMaxCount:e}});if(t!==null){if(!t.ok){B(String(c)),V(t.error?.message||C(`settings.config_files.save_failed`));return}l(e),B(String(e)),V(null)}},ge=async()=>{let e=Tx(oe);if(e===null){se(String(u)),ue(C(`settings.supervisor.retry_delay_validation_error`,{max:oo}));return}if(e===u){se(String(e)),ue(null);return}let t=await de({supervisor:{retryDelaySec:e}});if(t!==null){if(!t.ok){se(String(u)),ue(t.error?.message||C(`settings.config_files.save_failed`));return}d(e),se(String(e)),ue(null)}};return(0,X.jsxs)(`div`,{className:`settings-section`,children:[(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:C(`settings.notifications`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:C(`settings.notifications_channel_hint`)}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:T,children:C(`settings.notifications_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:E,children:C(`settings.notifications_enabled_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":E,"aria-labelledby":T,checked:e,className:`settings-toggle`,onCheckedChange:e=>{t(e),fe({enabled:e,soundEnabled:n}),de({notifications:{enabled:e}})}})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:D,children:C(`settings.notification_sound`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:O,children:C(`settings.notification_sound_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":O,"aria-labelledby":D,checked:n,className:`settings-toggle`,disabled:!e,onCheckedChange:t=>{r(t),fe({enabled:e,soundEnabled:t}),de({notifications:{soundEnabled:t}})}})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:C(`settings.notification_status`)}),(0,X.jsxs)(`span`,{className:`settings-info-value settings-capability-${R}`,children:[R===`available`&&C(`settings.notification_status_available`),R===`limited`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.notification_status_limited`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.notification_status_limited_hint`)})]}),R===`unsupported`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.notification_status_unsupported`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.notification_status_unsupported_hint`)})]})]})]}),(0,X.jsxs)(`div`,{className:`settings-info-row`,children:[(0,X.jsx)(`span`,{className:`settings-info-label`,children:C(`settings.notification_permission`)}),(0,X.jsxs)(`span`,{className:`settings-info-value settings-permission-${I}`,children:[I===`granted`&&C(`settings.permission_granted`),I===`denied`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.permission_denied`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.permission_denied_hint`)})]}),I===`default`&&R===`available`&&(0,X.jsx)(`button`,{className:`settings-link`,onClick:pe,children:C(`settings.permission_request`)}),I===`default`&&R===`limited`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.permission_unavailable`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.permission_limited_hint`)})]}),I===`unavailable`&&(0,X.jsxs)(X.Fragment,{children:[C(`settings.permission_unavailable`),(0,X.jsx)(`span`,{className:`settings-status-hint`,children:C(`settings.permission_unavailable_hint`)})]})]})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:j,children:C(`settings.lsp_runtime_mode`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:M,children:C(`settings.lsp_runtime_mode_hint`)}),(0,X.jsxs)(`div`,{"aria-describedby":M,"aria-labelledby":j,className:`settings-pills`,role:`group`,children:[(0,X.jsx)(Nh,{leadingIcon:g===`auto`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{_(`auto`)},active:g===`auto`,children:C(`settings.lsp_runtime_mode_auto`)}),(0,X.jsx)(Nh,{leadingIcon:g===`off`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{_(`off`)},active:g===`off`,children:C(`settings.lsp_runtime_mode_off`)})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:k,children:C(`settings.terminal_renderer`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:A,children:C(`settings.terminal_renderer_hint`)}),(0,X.jsxs)(`div`,{"aria-describedby":A,"aria-labelledby":k,className:`settings-pills`,role:`group`,children:[(0,X.jsx)(Nh,{leadingIcon:v===`standard`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{y(`standard`),de({appearance:{terminalRenderer:`standard`}})},active:v===`standard`,children:C(`settings.terminal_standard`)}),(0,X.jsx)(Nh,{leadingIcon:v===`compatibility`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{y(`compatibility`),de({appearance:{terminalRenderer:`compatibility`}})},active:v===`compatibility`,children:C(`settings.terminal_compatibility`)})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:N,children:C(`settings.copy_on_select`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:P,children:C(`settings.copy_on_select_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":P,"aria-labelledby":N,checked:b,className:`settings-toggle`,onCheckedChange:e=>{x(e),de({appearance:{terminalCopyOnSelect:e}})}})]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:C(`settings.supervisor.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:C(`settings.supervisor.hint`)}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-evaluation-timeout`,children:C(`settings.supervisor.evaluation_timeout`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`supervisor-evaluation-timeout`,className:`settings-input-compact`,type:`number`,min:1,max:ao,step:1,inputMode:`numeric`,invalid:!!re,value:te,onChange:e=>{ne(e.target.value),re&&ie(null)},onBlur:()=>{me()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())}})}),re?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:re}):null]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-enabled-label`,children:C(`settings.supervisor.retry_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-enabled-desc`,children:C(`settings.supervisor.retry_enabled_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":`supervisor-retry-enabled-desc`,"aria-labelledby":`supervisor-retry-enabled-label`,checked:o,className:`settings-toggle`,onCheckedChange:e=>{s(e),de({supervisor:{retryEnabled:e}})}})]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-max-count`,children:C(`settings.supervisor.retry_max_count`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`supervisor-retry-max-count`,className:`settings-input-compact`,type:`number`,min:0,max:20,step:1,inputMode:`numeric`,invalid:!!ce,value:ae,onChange:e=>{B(e.target.value),ce&&V(null)},onBlur:()=>{he()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),he())}})}),ce?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ce}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-delay-sec`,children:C(`settings.supervisor.retry_delay_sec`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`supervisor-retry-delay-sec`,className:`settings-input-compact`,type:`number`,min:1,max:oo,step:1,inputMode:`numeric`,invalid:!!le,value:oe,onChange:e=>{se(e.target.value),le&&ue(null)},onBlur:()=>{ge()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ge())}})}),le?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:le}):null]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-timeout-label`,children:C(`settings.supervisor.retry_on_timeout`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-timeout-desc`,children:C(`settings.supervisor.retry_on_timeout_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":`supervisor-retry-on-timeout-desc`,"aria-labelledby":`supervisor-retry-on-timeout-label`,checked:f,className:`settings-toggle`,onCheckedChange:e=>{p(e),de({supervisor:{retryOnTimeout:e}})}})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-evaluator-error-label`,children:C(`settings.supervisor.retry_on_evaluator_error`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-evaluator-error-desc`,children:C(`settings.supervisor.retry_on_evaluator_error_hint`)})]}),(0,X.jsx)(fg,{"aria-describedby":`supervisor-retry-on-evaluator-error-desc`,"aria-labelledby":`supervisor-retry-on-evaluator-error-label`,checked:m,className:`settings-toggle`,onCheckedChange:e=>{h(e),de({supervisor:{retryOnEvaluatorError:e}})}})]})]}),(0,X.jsxs)(`div`,{className:`settings-toggle-row settings-toggle-row--action`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,children:C(`diagnostics.title`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,children:C(`diagnostics.settings_hint`)})]}),(0,X.jsx)(Q,{className:`settings-diagnostics-button`,leadingIcon:(0,X.jsx)($,{semantic:`state.warning`,size:16}),onClick:()=>w(X_({context:`manual_check`,workspaceId:S??void 0})),size:`sm`,variant:`ghost`,children:C(`action.open`)})]})]})}function Ax({desktopTerminalFontSize:e,locale:t,mobileTerminalFontSize:n,personalization:r,setDesktopTerminalFontSize:i,setLocale:a,setMobileTerminalFontSize:o,savePersonalization:s,theme:c,setTheme:l}){let u=Z(),d=(0,H.useId)(),f=(0,H.useId)(),p=(0,H.useId)(),m=(0,H.useId)(),h=(0,H.useId)(),g=(0,H.useId)(),_=(0,H.useId)(),v=(0,H.useId)(),y=(0,H.useId)(),b=(0,H.useId)(),x=(0,H.useId)(),S=(0,H.useId)(),C=(0,H.useId)(),w=(0,H.useId)(),T=(0,H.useId)(),E=(0,H.useId)(),D=(0,H.useId)(),O=(0,H.useId)(),k=(0,H.useId)(),A=(0,H.useId)(),j=qb(),M=ka(c),N=Ca.map(e=>({value:e.id,label:u(e.labelKey)})),[P,F]=(0,H.useState)(String(e)),[ee,I]=(0,H.useState)(null),[L,R]=(0,H.useState)(String(n)),[z,te]=(0,H.useState)(null),[ne,re]=(0,H.useState)(null),[ie,ae]=(0,H.useState)(String(r.common.backgroundDimness)),[B,oe]=(0,H.useState)(String(r.common.backgroundBlur)),[se,ce]=(0,H.useState)(String(r.common.glassIntensity)),[V,le]=(0,H.useState)(String(r.common.surfaceOpacity)),[ue,de]=(0,H.useState)(null),[fe,pe]=(0,H.useState)(null),[me,he]=(0,H.useState)(null),[ge,_e]=(0,H.useState)(null),[ve,ye]=(0,H.useState)(r.desktop.surfaceOpacity===void 0?String(r.common.surfaceOpacity):String(r.desktop.surfaceOpacity)),[be,xe]=(0,H.useState)(r.mobile.surfaceOpacity===void 0?String(r.common.surfaceOpacity):String(r.mobile.surfaceOpacity)),[Se,Ce]=(0,H.useState)(null),[we,U]=(0,H.useState)(null),W=(0,H.useRef)(null),Te=(0,H.useRef)({desktopTerminalFontSize:0,mobileTerminalFontSize:0}),Ee=async e=>await j(`settings.update`,{settings:e});(0,H.useEffect)(()=>{F(String(e))},[e]),(0,H.useEffect)(()=>{R(String(n))},[n]),(0,H.useEffect)(()=>{I(null)},[e]),(0,H.useEffect)(()=>{te(null)},[n]),(0,H.useEffect)(()=>{ae(String(r.common.backgroundDimness)),oe(String(r.common.backgroundBlur)),ce(String(r.common.glassIntensity)),le(String(r.common.surfaceOpacity)),ye(String(r.desktop.surfaceOpacity??r.common.surfaceOpacity)),xe(String(r.mobile.surfaceOpacity??r.common.surfaceOpacity))},[r]);let De=e=>{let t=Oa(e);t.id!==M&&(l(t.id),document.documentElement.setAttribute(`data-theme`,t.documentThemeAttr),Ee({appearance:{themeId:t.id}}))},Oe=(e,t)=>({...r,common:{...r.common,[e]:t}}),ke=e=>e===`image`?r.common:{...r.common,backgroundAssetId:null},Ae=(e,t,n)=>{let i={...r[e],[t]:n};return n===void 0&&delete i[t],{...r,[e]:Ox(i)}},je=e=>Object.keys(r[e]).length>0,Me=(e,t)=>t?{...r,[e]:Ox({...r[e],surfaceOpacity:r[e].surfaceOpacity??r.common.surfaceOpacity})}:{...r,[e]:{}},Ne=async e=>(re(null),await s(e)),Pe=async(e,t,n,r,i,a,o)=>{let s=Dx(e,n,r);if(s===null){i(String(t)),a(u(`settings.terminal_font_size_validation_error`,{min:n,max:r}));return}if(s===t){i(String(s)),a(null);return}if(!await Ne(Oe(o,s))){i(String(t)),a(u(`settings.config_files.save_failed`));return}i(String(s)),a(null)},Fe=async(e,t,n,r,i,a,o,s)=>{let c=Dx(t,r,i);if(c===null){a(String(n)),o(u(`settings.terminal_font_size_validation_error`,{min:r,max:i}));return}if(!await Ne(Ae(e,s,c))){a(String(n)),o(u(`settings.config_files.save_failed`));return}a(String(c)),o(null)},Ie=async(e,t)=>{let[n]=Array.from(e.target.files??[]);if(e.target.value=``,n)try{let e=await ei(n);t===`common`?await Ne(Oe(`backgroundAssetId`,e.assetId))||re(u(`settings.config_files.save_failed`)):await Ne(Ae(t,`backgroundAssetId`,e.assetId))||re(u(`settings.config_files.save_failed`))}catch{re(u(`settings.appearance_asset_upload_failed`))}},Le=e=>{W.current&&(W.current.dataset.scope=e,W.current.click())},Re=async e=>{let t=e===`common`?r.common.backgroundAssetId:r[e].backgroundAssetId;if(t)try{await ti(t),e===`common`?await Ne(Oe(`backgroundAssetId`,null))||re(u(`settings.config_files.save_failed`)):await Ne(Ae(e,`backgroundAssetId`,null))||re(u(`settings.config_files.save_failed`))}catch{re(u(`settings.appearance_asset_delete_failed`))}},ze=(e,t)=>(0,X.jsxs)(`div`,{className:`settings-appearance-actions`,children:[(0,X.jsx)(Q,{"aria-label":u(t?`settings.appearance_background_replace`:`settings.appearance_background_upload`),size:`sm`,variant:`secondary`,onClick:()=>Le(e),children:u(t?`settings.appearance_background_replace`:`settings.appearance_background_upload`)}),t?(0,X.jsx)(Q,{"aria-label":u(`settings.appearance_background_remove`),size:`sm`,variant:`ghost`,onClick:()=>void Re(e),children:u(`settings.appearance_background_remove`)}):null]}),Be=(e,t,n,r)=>(0,X.jsxs)(`div`,{className:`settings-appearance-asset-summary`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info settings-appearance-asset-meta`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,children:t}),(0,X.jsx)(`span`,{className:`settings-toggle-desc settings-appearance-asset-id`,children:n||u(`settings.appearance_uses_shared_value`)})]}),ze(e,r)]}),Ve=async(e,t,n,r,i,a)=>{let o=Ex(e);if(o===null){i(String(t)),a(u(`settings.terminal_font_size_validation_error`,{min:10,max:18}));return}if(o===t){i(String(o)),a(null);return}let s=Date.now();if(s-Te.current[n]<dx)return;Te.current[n]=s;let c=await j(`settings.update`,{settings:{appearance:{[n]:o}}});if(c!==null){if(!c.ok){i(String(t)),a(c.error?.message||u(`settings.config_files.save_failed`));return}r(o),i(String(o)),a(null)}};return(0,X.jsxs)(`div`,{className:`settings-section`,children:[(0,X.jsx)(`input`,{ref:W,id:b,accept:`image/png,image/jpeg,image/webp`,className:`settings-appearance-file-input`,type:`file`,onChange:e=>{Ie(e,e.currentTarget.dataset.scope??`common`)}}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:u(`settings.appearance_background_material`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:u(`settings.appearance_background_material_hint`)}),(0,X.jsxs)(`div`,{className:`settings-appearance-panels`,children:[(0,X.jsxs)(`div`,{className:`settings-appearance-panel settings-appearance-panel--asset`,children:[(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-mode`,children:u(`settings.appearance_background_mode`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(tg,{desktopMode:`listbox`,id:`appearance-background-mode`,"aria-label":u(`settings.appearance_background_mode`),className:`settings-input-compact`,mobileSheetTitle:u(`settings.appearance_background_mode`),options:[{value:`none`,label:u(`settings.appearance_background_mode_off`)},{value:`image`,label:u(`settings.appearance_background_mode_image`)}],value:r.common.backgroundMode,onValueChange:e=>{let t=e,n={...r,common:ke(t)};n.common.backgroundMode=t,Ne(n)}})})]}),r.common.backgroundMode===`image`?Be(`common`,u(`settings.appearance_background_upload`),r.common.backgroundAssetId,!!r.common.backgroundAssetId):null,(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-fit`,children:u(`settings.appearance_background_fit`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(tg,{desktopMode:`listbox`,id:`appearance-background-fit`,"aria-label":u(`settings.appearance_background_fit`),className:`settings-input-compact`,mobileSheetTitle:u(`settings.appearance_background_fit`),options:[{value:`cover`,label:u(`settings.appearance_background_fit_cover`)},{value:`contain`,label:u(`settings.appearance_background_fit_contain`)}],value:r.common.backgroundFit,onValueChange:e=>{Ne(Oe(`backgroundFit`,e))}})})]})]}),(0,X.jsxs)(`div`,{className:`settings-appearance-panel settings-appearance-panel--material`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:x,children:u(`settings.appearance_glass_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:S,children:u(`settings.appearance_uses_shared_value`)})]}),(0,X.jsx)(fg,{"aria-describedby":S,"aria-labelledby":x,checked:r.common.glassEnabled,className:`settings-toggle`,onCheckedChange:e=>{Ne(Oe(`glassEnabled`,e))}})]}),(0,X.jsxs)(`div`,{className:`settings-appearance-material-grid`,children:[(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-dimness`,children:u(`settings.appearance_background_dimness`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-background-dimness`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!ue,max:100,min:0,step:1,type:`number`,value:ie,onBlur:()=>{Pe(ie,r.common.backgroundDimness,0,100,ae,de,`backgroundDimness`)},onChange:e=>{ae(e.target.value),de(null)}})}),ue?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ue}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-background-blur`,children:u(`settings.appearance_background_blur`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-background-blur`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!fe,max:40,min:0,step:1,type:`number`,value:B,onBlur:()=>{Pe(B,r.common.backgroundBlur,0,40,oe,pe,`backgroundBlur`)},onChange:e=>{oe(e.target.value),pe(null)}})}),fe?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:fe}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-glass-intensity`,children:u(`settings.appearance_glass_intensity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-glass-intensity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!me,max:100,min:0,step:1,type:`number`,value:se,onBlur:()=>{Pe(se,r.common.glassIntensity,0,100,ce,he,`glassIntensity`)},onChange:e=>{ce(e.target.value),he(null)}})}),me?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:me}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-surface-opacity`,children:u(`settings.appearance_surface_opacity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-surface-opacity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!ge,max:100,min:0,step:1,type:`number`,value:V,onBlur:()=>{Pe(V,r.common.surfaceOpacity,0,100,le,_e,`surfaceOpacity`)},onChange:e=>{le(e.target.value),_e(null)}})}),ge?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ge}):null]})]})]}),(0,X.jsxs)(`div`,{className:`settings-appearance-overrides`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:C,children:u(`settings.appearance_override_desktop`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:w,children:je(`desktop`)?u(`settings.appearance_override_enabled`):u(`settings.appearance_uses_shared_value`)})]}),(0,X.jsx)(fg,{"aria-describedby":w,"aria-labelledby":C,checked:je(`desktop`),className:`settings-toggle`,onCheckedChange:e=>{Ne(Me(`desktop`,e))}})]}),je(`desktop`)?(0,X.jsxs)(`div`,{className:`settings-appearance-override-panel`,children:[r.common.backgroundMode===`image`?Be(`desktop`,u(`settings.appearance_override_desktop`),r.desktop.backgroundAssetId,Object.prototype.hasOwnProperty.call(r.desktop,`backgroundAssetId`)):null,(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:T,children:u(`settings.appearance_glass_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:E,children:u(`settings.appearance_override_desktop`)})]}),(0,X.jsx)(fg,{"aria-describedby":E,"aria-labelledby":T,checked:r.desktop.glassEnabled??r.common.glassEnabled,className:`settings-toggle`,onCheckedChange:e=>{Ne(Ae(`desktop`,`glassEnabled`,e))}})]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-desktop-surface-opacity`,children:u(`settings.appearance_surface_opacity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-desktop-surface-opacity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!Se,max:100,min:0,step:1,type:`number`,value:ve,onBlur:()=>{Fe(`desktop`,ve,r.desktop.surfaceOpacity??r.common.surfaceOpacity,0,100,ye,Ce,`surfaceOpacity`)},onChange:e=>{ye(e.target.value),Ce(null)}})}),Se?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:Se}):null]})]}):null,(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:D,children:u(`settings.appearance_override_mobile`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:O,children:je(`mobile`)?u(`settings.appearance_override_enabled`):u(`settings.appearance_uses_shared_value`)})]}),(0,X.jsx)(fg,{"aria-describedby":O,"aria-labelledby":D,checked:je(`mobile`),className:`settings-toggle`,onCheckedChange:e=>{Ne(Me(`mobile`,e))}})]}),je(`mobile`)?(0,X.jsxs)(`div`,{className:`settings-appearance-override-panel`,children:[r.common.backgroundMode===`image`?Be(`mobile`,u(`settings.appearance_override_mobile`),r.mobile.backgroundAssetId,Object.prototype.hasOwnProperty.call(r.mobile,`backgroundAssetId`)):null,(0,X.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,X.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-label`,id:k,children:u(`settings.appearance_glass_enabled`)}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:A,children:u(`settings.appearance_override_mobile`)})]}),(0,X.jsx)(fg,{"aria-describedby":A,"aria-labelledby":k,checked:r.mobile.glassEnabled??r.common.glassEnabled,className:`settings-toggle`,onCheckedChange:e=>{Ne(Ae(`mobile`,`glassEnabled`,e))}})]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline settings-appearance-metric-field`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`appearance-mobile-surface-opacity`,children:u(`settings.appearance_surface_opacity`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`appearance-mobile-surface-opacity`,className:`settings-input-compact`,inputMode:`numeric`,invalid:!!we,max:100,min:0,step:1,type:`number`,value:be,onBlur:()=>{Fe(`mobile`,be,r.mobile.surfaceOpacity??r.common.surfaceOpacity,0,100,xe,U,`surfaceOpacity`)},onChange:e=>{xe(e.target.value),U(null)}})}),we?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:we}):null]})]}):null]})]}),ne?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ne}):null]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,children:u(`settings.terminal_appearance`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,children:u(`settings.terminal_font_size_hint`)}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`desktop-terminal-font-size`,id:g,children:u(`settings.desktop_terminal_font_size`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`desktop-terminal-font-size`,"aria-describedby":_,"aria-labelledby":g,className:`settings-input-compact`,type:`number`,min:10,max:18,step:1,inputMode:`numeric`,invalid:!!ee,value:P,onChange:e=>{F(e.target.value),ee&&I(null)},onBlur:()=>{Ve(P,e,`desktopTerminalFontSize`,i,F,I)},onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),Ve(P,e,`desktopTerminalFontSize`,i,F,I))}})}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:_,children:u(`settings.desktop_terminal_font_size_hint`)}),ee?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:ee}):null]}),(0,X.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,X.jsx)(`label`,{className:`settings-config-label`,htmlFor:`mobile-terminal-font-size`,id:v,children:u(`settings.mobile_terminal_font_size`)}),(0,X.jsx)(`div`,{className:`settings-config-control`,children:(0,X.jsx)(rh,{id:`mobile-terminal-font-size`,"aria-describedby":y,"aria-labelledby":v,className:`settings-input-compact`,type:`number`,min:10,max:18,step:1,inputMode:`numeric`,invalid:!!z,value:L,onChange:e=>{R(e.target.value),z&&te(null)},onBlur:()=>{Ve(L,n,`mobileTerminalFontSize`,o,R,te)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Ve(L,n,`mobileTerminalFontSize`,o,R,te))}})}),(0,X.jsx)(`span`,{className:`settings-toggle-desc`,id:y,children:u(`settings.mobile_terminal_font_size_hint`)}),z?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:z}):null]})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:d,children:u(`settings.theme.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:f,children:u(`settings.theme.hint`)}),(0,X.jsx)(tg,{desktopMode:`listbox`,id:p,"aria-describedby":f,"aria-label":u(`settings.theme.title`),className:`settings-input-compact`,mobileSheetTitle:u(`settings.theme.title`),options:N,value:M,onValueChange:De})]}),(0,X.jsxs)(`div`,{className:`settings-group`,children:[(0,X.jsx)(`h3`,{className:`settings-group-title`,id:m,children:u(`settings.language.title`)}),(0,X.jsx)(`p`,{className:`settings-group-desc`,id:h,children:u(`settings.language.hint`)}),(0,X.jsxs)(`div`,{"aria-describedby":h,"aria-labelledby":m,className:`settings-pills`,role:`group`,children:[(0,X.jsx)(Nh,{leadingIcon:t===`zh`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{a(`zh`),Ee({appearance:{locale:`zh`}})},active:t===`zh`,children:u(`settings.language.zh`)}),(0,X.jsx)(Nh,{leadingIcon:t===`en`?(0,X.jsx)(gi,{size:12}):void 0,onClick:()=>{a(`en`),Ee({appearance:{locale:`en`}})},active:t===`en`,children:u(`settings.language.en`)})]})]})]})}var jx=()=>{let e=Z(),t=Qt(),[n,r]=(0,H.useState)(!1),i=Br()===`mobile`,a=[{iconSemantic:`state.welcome.git`,title:e(`welcome.features.git_tools.title`),description:e(`welcome.features.git_tools.description`)},{iconSemantic:`state.welcome.terminal`,title:e(`welcome.features.terminals.title`),description:e(`welcome.features.terminals.description`)}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`welcome-container welcome-container--landing ${i?`welcome-container--mobile`:``}`,children:(0,X.jsxs)(`div`,{className:`welcome-card welcome-card--landing ${i?`welcome-card--mobile`:``}`,children:[(0,X.jsxs)(`div`,{className:`welcome-layout`,children:[(0,X.jsxs)(`div`,{className:`welcome-card__hero`,children:[(0,X.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`welcome.kicker`)}),(0,X.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`welcome.title`)}),(0,X.jsx)(`p`,{className:`welcome-body meta-text`,children:e(`welcome.description`)})]}),(0,X.jsxs)(`section`,{className:`welcome-flow`,"aria-labelledby":`welcome-flow-title`,children:[(0,X.jsx)(`div`,{className:`welcome-flow__header`,children:(0,X.jsx)(`div`,{className:`welcome-step-hint meta-text`,id:`welcome-flow-title`,children:e(`welcome.workflow_title`)})}),(0,X.jsxs)(`div`,{className:`welcome-flow__steps`,children:[(0,X.jsxs)(`section`,{className:`welcome-step-card`,children:[(0,X.jsxs)(`div`,{className:`welcome-step-card__header`,children:[(0,X.jsx)(`div`,{className:`welcome-step-card__label`,children:e(`welcome.step_1_label`)}),(0,X.jsx)(`div`,{className:`welcome-step-card__icon`,children:(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:18})})]}),(0,X.jsx)(`div`,{className:`welcome-step-card__title`,children:e(`welcome.step_1_title`)}),(0,X.jsx)(`p`,{className:`welcome-step-detail meta-text`,children:e(`welcome.step_1_detail`)}),(0,X.jsxs)(`button`,{className:`welcome-btn`,onClick:()=>{r(!0)},children:[(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:18}),(0,X.jsx)(`span`,{children:e(`action.open_workspace`)})]})]}),(0,X.jsxs)(`section`,{className:`welcome-step-card`,children:[(0,X.jsxs)(`div`,{className:`welcome-step-card__header`,children:[(0,X.jsx)(`div`,{className:`welcome-step-card__label`,children:e(`welcome.step_2_label`)}),(0,X.jsx)(`div`,{className:`welcome-step-card__icon`,children:(0,X.jsx)($,{semantic:`state.welcome.lightning`,size:18})})]}),(0,X.jsx)(`div`,{className:`welcome-step-card__title`,children:e(`welcome.step_2_title`)}),(0,X.jsx)(`p`,{className:`welcome-step-detail meta-text`,children:e(`welcome.step_2_detail`)})]})]}),(0,X.jsxs)(`div`,{className:`welcome-flow__support`,children:[(0,X.jsx)(`p`,{className:`welcome-settings-hint meta-text`,children:e(`welcome.settings_hint`)}),(0,X.jsxs)(`button`,{className:`welcome-link`,onClick:()=>{t(`/settings`)},children:[(0,X.jsx)($,{semantic:`nav.settings`,size:14}),(0,X.jsx)(`span`,{children:e(`action.settings`)})]})]})]})]}),(0,X.jsx)(`div`,{className:`welcome-card__features`,children:(0,X.jsxs)(`div`,{className:`welcome-support`,children:[(0,X.jsx)(`div`,{className:`welcome-support__title`,children:e(`welcome.support_title`)}),(0,X.jsx)(`div`,{className:`welcome-support-list`,children:a.map(e=>(0,X.jsxs)(`div`,{className:`welcome-feature`,children:[(0,X.jsx)($,{className:`welcome-feature-icon`,semantic:e.iconSemantic,size:18}),(0,X.jsxs)(`div`,{className:`welcome-feature-text`,children:[(0,X.jsx)(`div`,{className:`welcome-feature-title`,children:e.title}),(0,X.jsx)(`div`,{className:`welcome-feature-desc`,children:e.description})]})]},e.iconSemantic))})]})})]})}),n?(0,X.jsx)(Qv,{onClose:()=>r(!1)}):null]})};function Mx(e){let t=W(tv(e)),n=ve(),{persistUiState:r}=Bv(e),i=(0,H.useCallback)(i=>{let a=n.get(tv(e)),o=typeof i==`function`?i(a):i;return t(o),r({paneLayout:o}),o},[r,t,n,e]),a=(0,H.useCallback)((e,t)=>{i(n=>mv(n,e,t))},[i]),o=(0,H.useCallback)((e,t)=>{i(n=>pv(n,e,t))},[i]),s=(0,H.useCallback)(e=>{i(t=>bv(t,e))},[i]),c=(0,H.useCallback)(e=>{i(t=>Sv(t,e))},[i]),l=(0,H.useCallback)(e=>{i(t=>wv(t,e))},[i]),u=(0,H.useCallback)((e,t)=>{i(n=>hv(n,e,t))},[i]),d=(0,H.useCallback)(e=>{i({id:`root`,type:`leaf`,sessionId:e})},[i]),f=(0,H.useCallback)((e,t)=>{i(n=>gv(n,e,t))},[i]);return{appendSession:(0,H.useCallback)((e,t,n=`horizontal`)=>{i(r=>Dv(r,e,t,n))},[i]),appendSessionToMobileColumn:(0,H.useCallback)(e=>{i(t=>Ov(t,e))},[i]),assignSession:u,closeDraftPane:c,closeSessionPane:s,removeSessionPane:l,replaceSession:f,replaceWithSession:d,splitDraftPane:o,splitSessionPane:a,swapPaneSessions:(0,H.useCallback)((e,t)=>{i(n=>_v(n,e,t))},[i]),moveSessionToDraft:(0,H.useCallback)((e,t)=>{i(n=>vv(n,e,t))},[i]),insertSessionPaneAtEdge:(0,H.useCallback)((e,t,n)=>{i(r=>yv(r,e,t,n))},[i])}}var Nx=.22,Px=48,Fx=96;function Ix(){return{isDragging:!1,source:null,hoverTargetPaneId:null,hoverPlacement:null,previewPosition:{x:0,y:0},previewX:0,previewY:0}}function Lx(e){return Math.max(Px,Math.min(Fx,e*Nx))}function Rx(e,t,n,r,i){let a=t.element.getBoundingClientRect();if(n<a.left||n>a.right||r<a.top||r>a.bottom||i===e)return null;if(t.type===`draft`)return`center`;let o=Lx(a.width),s=Lx(a.height);return n<=a.left+o?`left`:n>=a.right-o?`right`:r<=a.top+s?`top`:r>=a.bottom-s?`bottom`:`center`}function zx({enabled:e=!0,onDrop:t}){let n=(0,H.useRef)(new Map),[r,i]=(0,H.useState)(()=>Ix()),a=(0,H.useRef)(t),o=(0,H.useRef)(r),s=(0,H.useCallback)(e=>{let t=typeof e==`function`?e(o.current):e;o.current=t,i(t)},[]),c=(0,H.useCallback)((e,t)=>{if(!t){n.current.delete(e);return}n.current.set(e,t)},[]),l=(0,H.useCallback)(t=>{e&&(document.body.classList.add(`is-dragging-pane`),s({isDragging:!0,source:t,hoverTargetPaneId:null,hoverPlacement:null,previewPosition:{x:0,y:0},previewX:0,previewY:0}))},[e,s]),u=(0,H.useCallback)(()=>{document.body.classList.remove(`is-dragging-pane`),s(Ix())},[s]);(0,H.useEffect)(()=>{a.current=t},[t]),(0,H.useEffect)(()=>{!e&&o.current.isDragging&&u()},[u,e]);let d=(0,H.useCallback)(e=>{s(t=>{if(!t.isDragging)return t;let r=null,i=null;for(let[a,o]of n.current.entries()){let n=Rx(a,o,e.clientX,e.clientY,t.source?.paneId);if(n){r=a,i=n;break}}return{...t,hoverTargetPaneId:r,hoverPlacement:i,previewPosition:{x:e.clientX,y:e.clientY},previewX:e.clientX,previewY:e.clientY}})},[s]),f=(0,H.useCallback)(()=>{let e=o.current;if(e.isDragging&&e.source&&e.hoverTargetPaneId&&e.hoverPlacement){let t=n.current.get(e.hoverTargetPaneId);t&&a.current({sourcePaneId:e.source.paneId,targetPaneId:e.hoverTargetPaneId,placement:e.hoverPlacement,targetType:t.type})}u()},[u]),p=(0,H.useCallback)(()=>{u()},[u]);return(0,H.useEffect)(()=>{if(r.isDragging)return window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,p),()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,p)}},[p,d,f,r.isDragging]),(0,H.useEffect)(()=>()=>{document.body.classList.remove(`is-dragging-pane`)},[]),{clearDrag:u,handlePointerCancel:p,handlePointerMove:d,handlePointerUp:f,registerPane:c,startDrag:l,state:r}}var Bx=`(pointer: coarse)`,Vx=e=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>void 0;let t=window.matchMedia(Bx);return typeof t.addEventListener==`function`?(t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}):(t.addListener(e),()=>{t.removeListener(e)})},Hx=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:!window.matchMedia(Bx).matches,Ux=()=>!0;function Wx(){return(0,H.useSyncExternalStore)(Vx,Hx,Ux)}var Gx=new TextEncoder,Kx=100,qx=5e3;function Jx(e){return new Promise(t=>{setTimeout(t,e)})}function Yx(){let e=U(Op),t=U(bp),n=ve(),r=(0,H.useCallback)(async t=>{let n=await e(`session.stop`,{sessionId:t});n.ok||console.error(`Failed to stop session:`,n.error?.message)},[e]);return{closeSession:(0,H.useCallback)(async(t,r=`draft`)=>{let i=n.get(Up(t));if(!i)return!1;if(r===`remove`){let n=await e(`session.close`,{sessionId:t,paneDisposition:r});return n.ok?!0:(console.error(`Failed to close session:`,n.error?.message),!1)}if(i.state===`ended`){let n=await e(`session.remove`,{sessionId:t});return n.ok?!0:(console.error(`Failed to remove ended session:`,n.error?.message),!1)}let a=await e(`session.stop`,{sessionId:t});if(!a.ok&&a.error?.code!==`invalid_state`)return console.error(`Failed to stop session before removal:`,a.error?.message),!1;let o=Date.now()+qx;for(;Date.now()<o;){let r=n.get(Up(t));if(!r)return!0;if(r.state===`ended`){let n=await e(`session.remove`,{sessionId:t});return n.ok?!0:(console.error(`Failed to remove ended session:`,n.error?.message),!1)}await Jx(Kx)}return console.error(`Timed out waiting for session to end before removal:`,t),!1},[e,n]),submitSessionPrompt:(0,H.useCallback)(async(e,n)=>{let r=n.trim();if(!t||!r)return!1;try{return await t.sendTerminalInput(e,Gx.encode(`${r}\r`),`submit`,r),!0}catch(e){return console.error(`Failed to submit session prompt:`,e),!1}},[t]),stopSession:r}}function Xx(e,t){let n=U(Bp),r=e===void 0?n:e,i=r?.id??`__workspace_empty__`,a=t?.disabled??!1,o=U(Op),s=U(xp),c=U(Hp(i)),l=U(tv(i)),u=W(Vp),d=W(tv(i)),f=ve(),{persistUiState:p}=Bv(i);return(0,H.useEffect)(()=>{if(a||!r||s!==`connected`)return;let e=!1,t=new Set(Object.values(f.get(Vp)).filter(e=>e.workspaceId===r.id).map(e=>e.id));return o(`session.list`,{workspaceId:r.id}).then(n=>{if(e||!n.ok||!n.data){console.error(`Failed to fetch sessions:`,n.error?.message);return}let a=n.data,o=Object.values(f.get(Vp)).filter(e=>e.workspaceId===r.id).filter(e=>!t.has(e.id)&&!a.some(t=>t.id===e.id)),s=[...a,...o];u(e=>{let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.workspaceId!==r.id));for(let e of s)t[e.id]=e;return t});let c=f.get(tv(i)),l=Zx(r?.uiState.paneLayout),m=l?null:Zx(rv(r.id)),h=l??m??c??ev,g=new Set(s.filter(e=>e.state!==`draft`).map(e=>e.id)),_=s.filter(e=>e.state!==`draft`),v=Av(h,g),y=new Set(Ev(v)),b=s.filter(e=>e.state!==`draft`&&e.state!==`ended`&&!y.has(e.id)).map(e=>e.id);b.length>0&&(v=Qx(v,b)),Ev(v).length>0||_.length>0&&(v=kv(_.map(e=>e.id))),v!==c&&d(v);let x=!l||m!==null||b.length>0,S=m!==null||Ev(v).length>0;x&&S&&p({paneLayout:v}).then(e=>{e&&m!==null&&iv(r.id)})}).catch(t=>{e||console.error(`Failed to fetch sessions:`,t)}),()=>{e=!0}},[s,a,o,p,d,u,f,r?.id,i]),{workspace:r,workspaceId:i,sessions:c,paneLayout:l,setPaneLayout:d}}function Zx(e){return e?{id:e.id,type:e.type,sessionId:e.sessionId,direction:e.direction,ratio:`ratio`in e?e.ratio:void 0,children:e.children?.map(e=>Zx(e)??ev)}:null}function Qx(e,t){let n=e,r=Ev(n),i=r[r.length-1]??null;for(let e of t)n=Dv(n,e,i,`horizontal`),i=e;return n}function $x(e){return e.autoInstallSupported&&e.installReadiness===`ready`}function eS(e){return{providerId:e,available:!0,missingCommands:[],missingPrerequisites:[],autoInstallSupported:!1,installReadiness:`ready`,manualGuideKeys:[],docUrls:{provider:``,prerequisites:{}}}}function tS(e){return{claude:{runtime:e?.claude??eS(`claude`),loading:!1},codex:{runtime:e?.codex??eS(`codex`),loading:!1}}}function nS(e,t,n,r){let[i,a]=(0,H.useState)(tS()),o=(0,H.useRef)({}),s=Aa();(0,H.useEffect)(()=>{let t=!1;return(async()=>{let n=await e(`provider.runtimeStatus`,{});if(t)return;if(!n.ok||!n.data){a(e=>({claude:{...e.claude,...tS().claude},codex:{...e.codex,...tS().codex}}));return}let r=tS(n.data.providers);a(e=>({claude:{...e.claude,...r.claude},codex:{...e.codex,...r.codex}}))})(),()=>{t=!0;for(let e of Object.values(o.current))typeof e==`number`&&window.clearTimeout(e)}},[e]);let c=async()=>{let t=await e(`provider.runtimeStatus`,{});if(!t.ok||!t.data)return;let n=tS(t.data.providers);a(e=>({claude:{...e.claude,runtime:n.claude.runtime,loading:!1},codex:{...e.codex,runtime:n.codex.runtime,loading:!1}}))},l=(e,t,n)=>{a(r=>({...r,[e]:{...r[e],loading:!1,inlineError:n,installJob:r[e].installJob?{...r[e].installJob,failure:t}:r[e].installJob}}))},u=async(e,t,n)=>{n===`provider_cli_missing`&&await c(),a(n=>({...n,[e]:{...n[e],loading:!1,inlineError:t}}))};return{states:i,launch:async r=>{let d=i[r].runtime;if(!d)return;if(a(e=>({...e,[r]:{...e[r],loading:!0,inlineError:void 0}})),d.available){let i=await e(`session.create`,{workspaceId:t,providerId:r,themeBackground:s});if(i.ok&&i.data){n(i.data,r),a(e=>({...e,[r]:{...e[r],loading:!1}}));return}await u(r,i.error?.message,i.error?.code);return}if(!$x(d)){a(e=>({...e,[r]:{...e[r],loading:!1,inlineError:`manual`}}));return}let f=await e(`provider.install.start`,{providerId:r});if(!f.ok||!f.data){a(e=>({...e,[r]:{...e[r],loading:!1,inlineError:f.error?.message}}));return}if(a(e=>({...e,[r]:{...e[r],installJob:f.data,loading:!1}})),f.data.status===`failed`){l(r,f.data.failure,f.data.failure?.message);return}if(f.data.status===`succeeded`){await c();let i=await e(`session.create`,{workspaceId:t,providerId:r,themeBackground:s});i.ok&&i.data&&n(i.data,r),i.ok||await u(r,i.error?.message,i.error?.code);return}let p=async()=>{let i=await e(`provider.install.get`,{jobId:f.data.jobId});if(!i.ok||!i.data){a(e=>({...e,[r]:{...e[r],loading:!1,inlineError:i.error?.message}}));return}if(a(e=>({...e,[r]:{...e[r],installJob:i.data,loading:!1,inlineError:void 0}})),i.data.status===`queued`||i.data.status===`running`){o.current[r]=window.setTimeout(p,1500);return}if(i.data.status===`failed`){l(r,i.data.failure,i.data.failure?.message);return}await c();let d=await e(`session.create`,{workspaceId:t,providerId:r,themeBackground:s});if(d.ok&&d.data){n(d.data,r);return}await u(r,d.error?.message,d.error?.code)};o.current[r]=window.setTimeout(p,1500)}}}var rS=({dragState:e,workspaceId:t,paneId:n,onAssignSession:r,onClosePane:i,onPaneDrop:a,onReplaceWithSession:o,onSplitPane:s})=>{let c=Z(),l=U(Op),u=W(Vp),{states:d,launch:f}=nS(l,t,(e,t)=>{u(t=>({...t,[e.id]:e})),n?r?.(n,e.id):o?.(e.id)},{paneId:n,launchMode:n?`assign`:`replace`}),p=e=>X_({context:`session_start`,workspaceId:t,providerId:e,paneId:n,launchMode:n?`assign`:`replace`}),m=e=>{let t=d[e].runtime;return!!(t?.autoInstallSupported&&t.installReadiness===`ready`)},h=e=>{let t=d[e];return t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`?c(`provider.install.cta.installing`):t.runtime?.available?c(`provider.install.cta.start`):m(e)?c(`provider.install.cta.install_and_start`):c(`provider.install.cta.manual`)},g=e=>{let t=d[e],n=t.installJob?.failure;return n?{message:n.message,docUrl:n.docUrls.provider}:t.inlineError&&t.inlineError!==`manual`?{message:t.inlineError,docUrl:t.runtime?.docUrls.provider}:t.inlineError===`manual`||!m(e)?{message:t.runtime?.manualGuideKeys.map(e=>c(e)).join(` `),docUrl:t.runtime?.docUrls.provider}:{docUrl:t.runtime?.docUrls.provider}},_=Object.values(d).some(e=>e.loading||e.installJob?.status===`queued`||e.installJob?.status===`running`);return(0,X.jsxs)(`div`,{className:`session-card agent-pane${e?.isDragging?` draft-launcher--dragging`:``}${e?.isActiveDropTarget?` draft-launcher--drop-target`:``}`,"data-pane-id":n,children:[e?.isActiveDropTarget?(0,X.jsx)(`div`,{className:`pane-drop-overlay pane-drop-overlay--draft`,children:(0,X.jsx)(`div`,{className:`pane-drop-overlay__center`,children:`Move here`})}):null,(0,X.jsxs)(`div`,{className:`session-header`,children:[(0,X.jsxs)(`div`,{className:`session-header-left`,children:[(0,X.jsx)(lg,{tone:`neutral`,className:`session-dot session-dot-idle`}),(0,X.jsx)(`div`,{className:`session-header-copy`,children:(0,X.jsxs)(`div`,{className:`session-title-row`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:c(`session.provider_select`)||`New Session`}),(0,X.jsx)(_g,{color:`neutral`,className:`session-state-badge`,children:`DRAFT`})]})})]}),(0,X.jsxs)(`div`,{className:`session-header-actions`,children:[(0,X.jsx)(Ig,{content:`Split horizontal`,children:(0,X.jsx)(Em,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,X.jsx)(ca,{size:13}),onClick:()=>{n&&s?.(n,`horizontal`)},size:`sm`})}),(0,X.jsx)(Ig,{content:`Split vertical`,children:(0,X.jsx)(Em,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,X.jsx)(sa,{size:13}),onClick:()=>{n&&s?.(n,`vertical`)},size:`sm`})}),(0,X.jsx)(Ig,{content:`Close`,children:(0,X.jsx)(Em,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:()=>{n&&i?.(n)},size:`sm`})})]})]}),(0,X.jsx)(`div`,{className:`agent-draft-launcher`,children:(0,X.jsxs)(`div`,{className:`agent-draft-content`,children:[(0,X.jsx)(`span`,{className:`agent-draft-kicker`,children:`SESSION LAUNCHER`}),(0,X.jsx)(`p`,{className:`agent-draft-description`,children:`选择一个 AI 会话,在当前 workspace 里继续查看文件、运行命令和推进代码修改。`}),(0,X.jsx)(`div`,{className:`agent-draft-providers`,children:[{id:`claude`,title:`Claude`,meta:`analysis`,icon:(0,X.jsx)($,{semantic:`agent.provider.claude`,size:18}),description:`更适合长上下文梳理、方案分析和代码审查。`,className:`agent-provider-card-claude`},{id:`codex`,title:`Codex`,meta:`workspace`,icon:(0,X.jsx)($,{semantic:`agent.provider.codex`,size:18}),description:`更适合终端操作、直接改文件和逐步修复问题。`,className:`agent-provider-card-codex`}].map(e=>{let t=d[e.id],n=g(e.id),r=t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`;return(0,X.jsx)(Q,{className:`agent-provider-card ${e.className}`,disabled:_,leadingIcon:(0,X.jsx)(`span`,{className:`agent-provider-card-icon`,children:e.icon}),onClick:()=>{f(e.id)},trailingIcon:(0,X.jsx)(fi,{size:16,className:`agent-provider-card-arrow`}),variant:`secondary`,children:(0,X.jsxs)(`span`,{className:`agent-provider-card-body`,children:[(0,X.jsxs)(`span`,{className:`agent-provider-card-title-row`,children:[(0,X.jsx)(`span`,{className:`agent-provider-card-title`,children:e.title}),(0,X.jsx)(`span`,{className:`agent-provider-card-meta`,children:e.meta})]}),(0,X.jsx)(`span`,{className:`agent-provider-card-desc`,children:e.description}),(0,X.jsx)(`span`,{className:`agent-provider-card-cta`,children:h(e.id)}),r?(0,X.jsx)(`span`,{className:`agent-provider-card-status`,children:c(`provider.install.status.installing`)}):null,n.message?(0,X.jsxs)(`span`,{className:`agent-provider-card-guide`,children:[(0,X.jsx)(`span`,{children:n.message}),n.docUrl?(0,X.jsx)(`a`,{href:n.docUrl,onClick:e=>e.stopPropagation(),rel:`noreferrer`,target:`_blank`,children:c(`provider.install.open_docs`)}):null,(0,X.jsx)(`a`,{href:p(e.id),onClick:e=>e.stopPropagation(),children:c(`diagnostics.actions.open_diagnostics`)})]}):null]})},e.id)})})]})})]})},iS=({splitId:e,direction:t,ratio:n,children:r,onRatioCommit:i})=>{let[a,o]=(0,H.useState)(n),s=(0,H.useRef)(null),c=(0,H.useRef)(!1),l=(0,H.useRef)(n),u=(0,H.useCallback)(()=>{c.current=!0,l.current=a,document.body.classList.add(`is-resizing-panels`)},[a]),d=(0,H.useCallback)(e=>{if(!c.current||!s.current)return;let n=s.current.getBoundingClientRect(),r=t===`horizontal`?n.width:n.height,i=t===`horizontal`?e.clientX-n.left:e.clientY-n.top,a=Math.max(.1,Math.min(.9,i/r));o(a),l.current=a},[t]),f=(0,H.useCallback)(()=>{c.current&&(c.current=!1,document.body.classList.remove(`is-resizing-panels`),i?.(l.current))},[i]);(0,H.useEffect)(()=>(document.addEventListener(`mousemove`,d),document.addEventListener(`mouseup`,f),()=>{document.removeEventListener(`mousemove`,d),document.removeEventListener(`mouseup`,f)}),[d,f]),(0,H.useEffect)(()=>{o(n),l.current=n},[n,e]);let[p,m]=Array.isArray(r)?r:[r],h=t===`horizontal`?{gridTemplateColumns:`${a*100}% 0px ${(1-a)*100}%`}:{gridTemplateRows:`${a*100}% 0px ${(1-a)*100}%`},g=t===`horizontal`?`pane-layout-divider pane-layout-horizontal-divider`:`pane-layout-divider pane-layout-vertical-divider`;return(0,X.jsxs)(`div`,{ref:s,className:`pane-layout pane-layout-${t}`,style:{display:`grid`,...h},children:[(0,X.jsx)(`div`,{className:`pane-layout-child`,children:p}),(0,X.jsx)(`div`,{className:g,onMouseDown:u,role:`separator`,"aria-orientation":t===`horizontal`?`vertical`:`horizontal`}),(0,X.jsx)(`div`,{className:`pane-layout-child`,children:m})]})};function aS({title:e,meta:t,status:n,actions:r,metaPlacement:i=`stacked`,className:a}){let o=t?(0,X.jsx)(`div`,{className:`panel-header__meta${i===`inline`?` panel-header__meta--inline`:``}`,children:t}):null;return(0,X.jsxs)(`div`,{className:`panel-header${i===`inline`?` panel-header--inline-meta`:``}${a?` ${a}`:``}`,children:[(0,X.jsx)(`div`,{className:`panel-header__leading`,children:(0,X.jsxs)(`div`,{className:`panel-header__copy`,children:[(0,X.jsxs)(`div`,{className:`panel-header__title-row`,children:[n?(0,X.jsx)(`div`,{className:`panel-header__status`,children:n}):null,(0,X.jsx)(`div`,{className:`panel-header__title`,children:e}),i===`inline`?o:null]}),i===`stacked`?o:null]})}),r?(0,X.jsx)(`div`,{className:`panel-header__actions`,children:r}):null]})}var oS=V(new Map),sS=Ap(e=>V(!1)),cS=V({open:!1,sessionId:null,mode:`enable`,restoreStep:`form`,returnToDetails:!1,draftObjective:``,initialObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``,recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1}),lS=V({open:!1,sessionId:null});V(e=>t=>e(oS).get(t));function uS(e){let[t,n]=Te(lS);return{details:t,isVisible:t.open&&(!e||t.sessionId===e),openDetails:(0,H.useCallback)(e=>{n({open:!0,sessionId:e})},[n]),closeDetails:(0,H.useCallback)(()=>{n({open:!1,sessionId:null})},[n])}}var dS=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}],fS={open:!1,sessionId:null,mode:`enable`,restoreStep:`form`,returnToDetails:!1,draftObjective:``,initialObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``,recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1};function pS(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e),n=t.getTimezoneOffset();return new Date(t.getTime()-n*6e4).toISOString().slice(0,16)}function mS(e){let t=Number.parseInt(e,10);return!Number.isSafeInteger(t)||t<0?0:t}function hS(e){let t=(e??``).trim();if(!t)return!1;let n=Number(t);return Number.isSafeInteger(n)&&n>=0}function gS(e){if(!e.trim())return;let t=Date.parse(e);if(Number.isFinite(t))return t}function _S({workspaceId:e,sessionId:t}){let[n,r]=Te(cS),i=U(oS),a=U(Op),{openDetails:o}=uS(),s=Z(),c=t??n.sessionId,l=c?i.get(c):void 0,u=n.open&&(!t||n.sessionId===t),d=n.mode,f=n.restoreStep??`form`,p={title:s(f===`restore`?`supervisor.dialog.restore.title`:`supervisor.dialog.${d}.title`),subtitle:s(f===`restore`?`supervisor.dialog.restore.subtitle`:`supervisor.dialog.${d}.subtitle`),confirm:s(f===`restore`?`supervisor.dialog.restore.confirm`:`supervisor.dialog.${d}.confirm`)},m=hS(n.draftMaxSupervisionCount),h=n.selectedRecoverableTargetId??null,g=n.recoverableTargets??[],_=n.isRecoverableTargetsLoading??!1,v=n.draftObjective.trim(),y=v!==(n.initialObjective?.trim()??``),b=(n.draftEvaluatorModel??``).trim(),x=l?.evaluatorModel?.trim()??``,S=mS(n.draftMaxSupervisionCount??`0`),C=gS(n.draftScheduledAt??``)??null,w=l?.scheduledAt??null,T=!!(l&&(n.draftEvaluatorProviderId!==l.evaluatorProviderId||b!==x||S!==l.maxSupervisionCount||C!==w)),E=y||T,D=(0,H.useCallback)(()=>{let e=n.returnToDetails?n.sessionId:null;r(fS),e&&o(e)},[n.returnToDetails,n.sessionId,o,r]);return{dialog:n,supervisor:l,isVisible:u,mode:d,restoreStep:f,copy:p,isMaxSupervisionCountValid:m,recoverableTargets:g,selectedRecoverableTargetId:h,isRecoverableTargetsLoading:_,hasObjectiveChanged:y,hasSettingsChanged:T,hasChanges:E,close:D,updateDraft:(0,H.useCallback)(e=>{r(t=>({...t,...e}))},[r]),openRestoreStep:(0,H.useCallback)(async()=>{r(e=>({...e,restoreStep:`restore`,isRecoverableTargetsLoading:!0,recoverableTargets:[],selectedRecoverableTargetId:null}));let t=await a(`supervisor.listRecoverableTargets`,{workspaceId:e});r(e=>{if(e.sessionId!==c)return e;let n=(t.ok?t.data?.targets??[]:[]).filter(e=>e.targetId!==l?.targetId);return{...e,restoreStep:`restore`,isRecoverableTargetsLoading:!1,recoverableTargets:n,selectedRecoverableTargetId:null}})},[a,c,r,l?.targetId,e]),closeRestoreStep:(0,H.useCallback)(()=>{r(e=>({...e,restoreStep:`form`,isRecoverableTargetsLoading:!1,selectedRecoverableTargetId:null}))},[r]),selectRecoverableTarget:(0,H.useCallback)(e=>{r(t=>({...t,selectedRecoverableTargetId:e}))},[r]),confirm:(0,H.useCallback)(async()=>{if(!n.sessionId||!m)return!1;let t=n.draftEvaluatorModel.trim(),r=mS(n.draftMaxSupervisionCount),i=gS(n.draftScheduledAt);if(f===`restore`)return h&&(await a(`supervisor.restore`,{sessionId:n.sessionId,workspaceId:e,sourceTargetId:h,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:t||void 0,maxSupervisionCount:r,scheduledAt:i})).ok?(D(),!0):!1;let o=v;return o?n.mode===`enable`?(await a(`supervisor.create`,{sessionId:n.sessionId,workspaceId:e,objective:o,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:t||void 0,maxSupervisionCount:r,scheduledAt:i})).ok?(D(),!0):!1:l&&(await a(`supervisor.update`,{id:l.id,objective:o,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:t||null,maxSupervisionCount:r,scheduledAt:i??null})).ok?(D(),!0):!1:!1},[D,n,a,m,f,h,l,e]),formatScheduledAtInput:pS}}var vS=`__supervisor-empty__`;function yS(e){let t=e?.id??vS,n=ve(),r=U(xp),i=U(Op),a=W(cS),o=W(oS),s=W(sS(t));return(0,H.useEffect)(()=>{if(!e?.id)return;let t=sS(e.id);if(r!==`connected`){n.get(t)&&s(!1);return}if(e.capability!==`full`||e.state===`draft`||e.state===`ended`||n.get(t))return;s(!0);let a=!1;return i(`supervisor.get`,{sessionId:e.id}).then(t=>{if(a||!t.ok)return;let n=t.data?.supervisor??null;o(t=>{let r=new Map(t);return n?r.set(e.id,n):r.delete(e.id),r})}),()=>{a=!0}},[r,i,e,s,o,n]),{openDialog:(0,H.useCallback)((e,n)=>{a({open:!0,sessionId:t,mode:e,restoreStep:`form`,returnToDetails:e===`edit`,draftObjective:n?.objective??``,initialObjective:n?.objective??``,draftEvaluatorProviderId:n?.evaluatorProviderId??`claude`,draftEvaluatorModel:n?.evaluatorModel??``,draftMaxSupervisionCount:String(n?.maxSupervisionCount??0),draftScheduledAt:pS(n?.scheduledAt),recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1})},[t,a])}}var bS={inactive:`supervisor-state-inactive`,idle:`supervisor-state-idle`,evaluating:`supervisor-state-evaluating`,injecting:`supervisor-state-injecting`,paused:`supervisor-state-paused`,error:`supervisor-state-error`,stopped:`supervisor-state-stopped`};function xS({sessionId:e}){let t=U(oS),n=U(Op),r=W(cS),{openDetails:i}=uS(),a=Z(),o=t.get(e),[s,c]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(!s)return;let e=window.setTimeout(()=>c(null),6e3);return()=>window.clearTimeout(e)},[s]);let l=(0,H.useCallback)(t=>{r({open:!0,sessionId:e,mode:t,restoreStep:`form`,returnToDetails:t===`edit`,draftObjective:o?.objective??``,initialObjective:o?.objective??``,draftEvaluatorProviderId:o?.evaluatorProviderId??`claude`,draftEvaluatorModel:o?.evaluatorModel??``,draftMaxSupervisionCount:String(o?.maxSupervisionCount??0),draftScheduledAt:pS(o?.scheduledAt),recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1})},[e,r,o]),u=(0,H.useCallback)(async(e,t,r)=>{c(null);let i=await n(e,{id:t});i.ok||c(i.error?.message?`${r}: ${i.error.message}`:r)},[n]),d=(0,H.useCallback)(async()=>{o&&await u(`supervisor.pause`,o.id,a(`supervisor.action.pause_failed`))},[u,o,a]),f=(0,H.useCallback)(async()=>{o&&await u(`supervisor.resume`,o.id,a(`supervisor.action.resume_failed`))},[u,o,a]),p=(0,H.useCallback)(async()=>{o&&await u(`supervisor.trigger`,o.id,a(`supervisor.action.trigger_failed`))},[u,o,a]),m=o?.stopReason?a(`supervisor.stop_reason.${o.stopReason}`):null,h=o?.currentTargetMemory,g=h?.items.find(e=>e.id===h.activeItemId)??h?.items[0]??null,_=h?.decompositionMode?a(`supervisor.target_memory.decomposition_mode.${h.decompositionMode}`):null,v=h?h.decompositionGenerated?a(`supervisor.target_memory.decomposition_ready`):a(`supervisor.target_memory.decomposition_pending`):null,y=o?.recentTargetCycles?.[0]?.reason??null;return{activeItem:g,actionError:s,decompositionModeLabel:_,decompositionStatusLabel:v,handlePause:d,handleResume:f,handleTrigger:p,isBusy:o?.state===`evaluating`||o?.state===`injecting`,openDetails:()=>{o&&i(o.sessionId)},openDialog:l,recentReasoning:y,stopReasonLabel:m,stateClass:o?bS[o.state]:bS.inactive,stateLabel:a(`supervisor.state.${o?o.state:`inactive`}`),supervisor:o,targetMemory:h}}var SS=dS.map(e=>({value:e.id,label:e.label}));function CS({mode:e}){return e===`enable`?(0,X.jsx)($,{semantic:`supervisor.mode.enable`,size:14}):(0,X.jsx)($,{semantic:`supervisor.mode.edit`,size:14})}function wS({mode:e,showIntro:t=!1,restoreStep:n,draftObjective:r,draftEvaluatorProviderId:i,draftEvaluatorModel:a,draftMaxSupervisionCount:o,draftScheduledAt:s,isMaxSupervisionCountValid:c,recoverableTargets:l,selectedRecoverableTargetId:u,isRecoverableTargetsLoading:d,onDraftObjectiveChange:f,onDraftEvaluatorProviderChange:p,onDraftEvaluatorModelChange:m,onDraftMaxSupervisionCountChange:h,onDraftScheduledAtChange:g,onOpenRestoreStep:_,onCloseRestoreStep:v,onSelectRecoverableTarget:y}){let b=Z(),x=U(Za),S=(0,H.useId)(),C=(0,H.useId)(),w=(0,H.useId)(),T=(0,H.useId)(),E=(0,H.useId)(),D=(0,H.useId)(),O=b(`supervisor.dialog.${e}.title`),k=b(`supervisor.dialog.${e}.subtitle`);return n===`restore`?(0,X.jsxs)(`div`,{className:`supervisor-restore-view`,children:[(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro`,children:[(0,X.jsx)(`div`,{className:`supervisor-dialog-intro__icon`,"aria-hidden":`true`,children:(0,X.jsx)(CS,{mode:e})}),(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro__copy`,children:[(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__title`,children:b(`supervisor.dialog.restore.title`)}),(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__description`,children:b(`supervisor.dialog.restore.subtitle`)})]})]}),(0,X.jsx)(`div`,{className:`supervisor-restore-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`supervisor-restore-link`,onClick:v,children:b(`supervisor.dialog.restore.back`)})}),d?(0,X.jsx)(`div`,{className:`supervisor-restore-loading`,children:(0,X.jsx)(ig,{label:b(`common.loading`),size:`md`})}):l.length===0?(0,X.jsx)(Sh,{className:`supervisor-restore-empty`,title:b(`supervisor.dialog.restore.empty`),description:b(`supervisor.dialog.restore.empty_hint`)}):(0,X.jsx)(`div`,{className:`supervisor-restore-list`,role:`radiogroup`,children:l.map(e=>{let t=e.targetId===u;return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:`supervisor-restore-card${t?` supervisor-restore-card--selected`:``}`,onClick:()=>y(e.targetId),children:[(0,X.jsxs)(`span`,{className:`supervisor-restore-card__header`,children:[(0,X.jsx)(`span`,{className:`supervisor-restore-card__title`,children:e.objective}),(0,X.jsx)(`span`,{className:`supervisor-restore-card__meta`,children:b(`supervisor.dialog.restore.cycle_count`,{count:e.cycleCount})})]}),e.progressSummary?(0,X.jsx)(`span`,{className:`supervisor-restore-card__summary`,children:e.progressSummary}):null,(0,X.jsx)(`span`,{className:`supervisor-restore-card__footer`,children:b(`supervisor.dialog.restore.updated_at`,{time:dm(e.updatedAt,x,{year:`numeric`,month:`short`,day:`numeric`})})})]},e.targetId)})})]}):(0,X.jsxs)(X.Fragment,{children:[t?(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro`,children:[(0,X.jsx)(`div`,{className:`supervisor-dialog-intro__icon`,"aria-hidden":`true`,children:(0,X.jsx)(CS,{mode:e})}),(0,X.jsxs)(`div`,{className:`supervisor-dialog-intro__copy`,children:[(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__title`,children:O}),(0,X.jsx)(`p`,{className:`supervisor-dialog-intro__description`,children:k})]})]}):null,(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsxs)(`div`,{className:`supervisor-objective-label-row`,children:[(0,X.jsx)(`label`,{htmlFor:`objective`,children:b(`supervisor.field.objective`)}),(0,X.jsx)(`button`,{type:`button`,className:`supervisor-restore-link`,onClick:_,children:b(`supervisor.dialog.restore.open`)})]}),(0,X.jsx)(Cg,{id:`objective`,rows:5,value:r,onChange:e=>f(e.target.value),"aria-describedby":S,placeholder:b(`supervisor.field.objective_placeholder`),autoFocus:!0}),(0,X.jsx)(`span`,{id:S,className:`dialog-helper`,children:b(`supervisor.field.objective_helper`)}),(0,X.jsx)(`p`,{className:`supervisor-restore-entry__hint`,children:b(`supervisor.dialog.restore.hint`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{id:C,htmlFor:`evaluator-provider`,children:b(`supervisor.field.evaluator`)}),(0,X.jsx)(tg,{id:`evaluator-provider`,size:`sm`,desktopMode:`listbox`,mobileSheetTitle:b(`supervisor.field.evaluator`),mobileSheetPresentation:`inline`,options:SS,value:i,"aria-labelledby":C,"aria-describedby":w,onValueChange:p}),(0,X.jsx)(`span`,{id:w,className:`dialog-helper`,children:b(`supervisor.field.evaluator_helper`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`evaluator-model`,children:b(`supervisor.field.evaluator_model`)}),(0,X.jsx)(rh,{id:`evaluator-model`,size:`sm`,value:a,onChange:e=>m(e.target.value),"aria-describedby":T,placeholder:b(`supervisor.field.evaluator_model_placeholder`)}),(0,X.jsx)(`span`,{id:T,className:`dialog-helper`,children:b(`supervisor.field.evaluator_model_helper`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`max-supervision-count`,children:b(`supervisor.field.max_supervision_count`)}),(0,X.jsx)(rh,{id:`max-supervision-count`,size:`sm`,type:`number`,min:0,step:1,value:o,onChange:e=>h(e.target.value),invalid:!c,"aria-invalid":!c,"aria-describedby":E}),(0,X.jsx)(`span`,{id:E,className:`dialog-helper`,children:b(`supervisor.field.max_supervision_count_helper`)})]}),(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`scheduled-at`,children:b(`supervisor.field.scheduled_at`)}),(0,X.jsx)(gh,{label:b(`supervisor.field.scheduled_at`),size:`sm`,value:s,onValueChange:g,placeholder:b(`supervisor.field.scheduled_at_placeholder`),clearable:!0,minDate:new Date,"aria-describedby":D}),(0,X.jsx)(`span`,{id:D,className:`dialog-helper`,children:b(`supervisor.field.scheduled_at_helper`)})]})]})}function TS({workspaceId:e,sessionId:t}){let n=Br(),r=Z(),{dialog:i,isVisible:a,mode:o,restoreStep:s,copy:c,isMaxSupervisionCountValid:l,recoverableTargets:u,selectedRecoverableTargetId:d,isRecoverableTargetsLoading:f,hasObjectiveChanged:p,hasChanges:m,close:h,updateDraft:g,openRestoreStep:_,closeRestoreStep:v,selectRecoverableTarget:y,confirm:b}=_S({workspaceId:e,sessionId:t}),[x,S]=(0,H.useState)(!1);if(!a||n===`mobile`)return null;let C=s===`restore`,w=o===`edit`?!m||!i.draftObjective.trim()||!l:!i.draftObjective.trim()||!l;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(jm,{className:`supervisor-dialog supervisor-dialog--${o}`,onOpenChange:h,open:!0,children:[(0,X.jsxs)(Nm,{children:[(0,X.jsxs)(`div`,{className:`dialog-header__leading`,children:[(0,X.jsx)(`span`,{className:`dialog-header__icon supervisor-dialog-header-icon`,"aria-hidden":`true`,children:(0,X.jsx)(CS,{mode:o})}),(0,X.jsx)(`div`,{className:`dialog-header__copy`,children:(0,X.jsx)(Pm,{children:c.title})})]}),(0,X.jsx)(Em,{"aria-label":r(`action.close`),className:`modal-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:h,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsx)(wS,{mode:o,restoreStep:s,draftObjective:i.draftObjective,draftEvaluatorProviderId:i.draftEvaluatorProviderId,draftEvaluatorModel:i.draftEvaluatorModel,draftMaxSupervisionCount:i.draftMaxSupervisionCount,draftScheduledAt:i.draftScheduledAt,isMaxSupervisionCountValid:l,recoverableTargets:u,selectedRecoverableTargetId:d,isRecoverableTargetsLoading:f,onDraftObjectiveChange:e=>g({draftObjective:e}),onDraftEvaluatorProviderChange:e=>g({draftEvaluatorProviderId:e}),onDraftEvaluatorModelChange:e=>g({draftEvaluatorModel:e}),onDraftMaxSupervisionCountChange:e=>g({draftMaxSupervisionCount:e}),onDraftScheduledAtChange:e=>g({draftScheduledAt:e}),onOpenRestoreStep:()=>{_()},onCloseRestoreStep:v,onSelectRecoverableTarget:y})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:h,children:r(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{if(o===`edit`&&!C&&p){S(!0);return}b()},disabled:C?!d||f||!l:w,children:c.confirm})]})]}),(0,X.jsx)(Bm,{open:x,onOpenChange:S,title:r(`supervisor.dialog.edit.reset_confirm_title`),description:r(`supervisor.dialog.edit.reset_confirm_description`),cancelText:r(`action.cancel`),confirmText:r(`supervisor.dialog.edit.confirm`),tone:`danger`,onConfirm:()=>{S(!1),b()}})]})}function ES({sessionId:e,workspaceId:t,onEdit:n}){let r=Z(),{recentReasoning:i,supervisor:a,targetMemory:o}=xS({sessionId:e});if(!a)return null;let s=a.completedSupervisionCount,c=a.maxSupervisionCount>0?String(a.maxSupervisionCount):r(`supervisor.meta.no_cap`),l=a.recentTargetCycles?.find(e=>e.result===`error`)?.errorReason??a.errorReason??null,u=a.state===`error`?`error`:a.state===`evaluating`||a.state===`injecting`?`running`:`idle`;return(0,X.jsxs)(`div`,{className:`supervisor-details`,"aria-label":r(`supervisor.target_memory.title`),children:[(0,X.jsxs)(`section`,{className:`supervisor-details-section`,children:[(0,X.jsxs)(`div`,{className:`supervisor-details-section-header`,children:[(0,X.jsx)(`h3`,{className:`supervisor-details-section-title`,children:r(`supervisor.target_memory.basic_info_title`)}),(0,X.jsx)(Q,{className:`supervisor-details-edit-btn`,onClick:n,size:`sm`,variant:`ghost`,children:r(`supervisor.action.edit_objective`)})]}),(0,X.jsx)(`div`,{className:`supervisor-summary-card supervisor-details-surface`,children:(0,X.jsxs)(`div`,{className:`supervisor-meta-grid supervisor-meta-grid--stacked`,children:[(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.field.objective`)}),(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--wrap`,children:a.objective})]}),(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.field.evaluator`)}),(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--strong`,children:Hg(a.evaluatorProviderId)})]}),(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.cycles_title`)}),(0,X.jsxs)(`p`,{className:`supervisor-meta-value supervisor-meta-value--strong`,children:[s,` / `,c]})]}),(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.runtime_title`)}),(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--strong`,children:r(`supervisor.target_memory.runtime_status.${u}`)})]}),u===`error`&&l?(0,X.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,X.jsx)(`p`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.error_reason_label`)}),(0,X.jsx)(`div`,{className:`supervisor-error`,role:`alert`,children:l})]}):null]})})]}),i&&u!==`error`?(0,X.jsxs)(`section`,{className:`supervisor-details-section`,children:[(0,X.jsx)(`h3`,{className:`supervisor-details-section-title`,children:r(`supervisor.target_memory.reasoning_title`)}),(0,X.jsx)(`div`,{className:`supervisor-details-surface supervisor-details-surface--reasoning supervisor-meta-item--reasoning`,children:(0,X.jsx)(`p`,{className:`supervisor-meta-value supervisor-meta-value--wrap`,children:i})})]}):null,o?.items.length?(0,X.jsxs)(`section`,{className:`supervisor-details-section`,children:[(0,X.jsx)(`h3`,{className:`supervisor-details-section-title`,children:r(`supervisor.target_memory.progress_list_title`)}),(0,X.jsx)(`div`,{className:`supervisor-details-surface supervisor-details-surface--progress`,children:(0,X.jsx)(`div`,{className:`supervisor-progress-list supervisor-progress-list--checklist`,children:o.items.map(e=>{let t=e.id===o.activeItemId,n=e.status===`done`?`green`:e.status===`in_progress`?`blue`:`neutral`;return(0,X.jsxs)(`article`,{className:`supervisor-progress-item${t?` supervisor-progress-item--active`:``}`,children:[(0,X.jsx)(`div`,{className:`supervisor-progress-item__rail`,"aria-hidden":`true`,children:(0,X.jsx)(`span`,{className:`supervisor-progress-item__marker supervisor-progress-item__marker--${e.status}`})}),(0,X.jsxs)(`div`,{className:`supervisor-progress-item__body`,children:[(0,X.jsxs)(`div`,{className:`supervisor-progress-item__header`,children:[(0,X.jsx)(`p`,{className:`supervisor-progress-item__title`,children:e.title}),(0,X.jsx)(_g,{color:n,size:`sm`,caps:!1,children:r(`supervisor.target_memory.step_status.${e.status}`)})]}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-label`,children:r(`supervisor.target_memory.item_objective_title`)}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-value`,children:e.objective}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-label`,children:r(`supervisor.target_memory.item_deliverable_title`)}),(0,X.jsx)(`p`,{className:`supervisor-progress-item__meta-value`,children:e.deliverable})]})]},e.id)})})})]}):null]})}function DS({workspaceId:e,sessionId:t}){let n=Br(),r=Z(),{details:i,isVisible:a,closeDetails:o}=uS(t),{openDialog:s}=xS({sessionId:t??i.sessionId??``});return!a||n===`mobile`||!i.sessionId?null:(0,X.jsxs)(jm,{className:`supervisor-dialog supervisor-dialog--details`,onOpenChange:o,open:!0,children:[(0,X.jsxs)(Nm,{children:[(0,X.jsx)(`div`,{className:`dialog-header__leading`,children:(0,X.jsx)(`div`,{className:`dialog-header__copy`,children:(0,X.jsx)(Pm,{children:r(`supervisor.dialog.details.title`)})})}),(0,X.jsx)(Em,{"aria-label":r(`action.close`),className:`modal-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:o,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsx)(ES,{sessionId:i.sessionId,workspaceId:e,onEdit:()=>{o(),s(`edit`)}})})]})}function OS({sessionId:e,workspaceId:t}){let n=Z(),{handlePause:r,handleResume:i,handleTrigger:a,isBusy:o,openDetails:s,openDialog:c,stateClass:l,stateLabel:u,supervisor:d}=xS({sessionId:e});return d?(0,X.jsxs)(`div`,{className:`supervisor-card ${l}`,"data-workspace-id":t,children:[(0,X.jsxs)(`div`,{className:`supervisor-strip-row`,children:[(0,X.jsxs)(`span`,{className:`supervisor-strip-eyebrow`,children:[(0,X.jsx)(`span`,{className:`supervisor-pulse ${l}`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`supervisor-label`,children:n(`supervisor.title`)})]}),(0,X.jsxs)(`span`,{className:`supervisor-status-cluster`,children:[(0,X.jsx)(`span`,{className:`supervisor-state-tag ${l}`,children:u}),(0,X.jsx)(`span`,{className:`supervisor-cycle-count`,children:n(`supervisor.completed_cycles`,{count:String(d.completedSupervisionCount)})})]}),(0,X.jsxs)(`div`,{className:`supervisor-actions`,children:[(0,X.jsx)(Ig,{content:n(`supervisor.action.details`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.details`),className:`supervisor-icon-btn`,icon:(0,X.jsx)($,{semantic:`supervisor.action.details`,size:12}),onClick:s,size:`sm`})}),d.state===`paused`?(0,X.jsx)(Ig,{content:n(`supervisor.action.resume`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.resume`),className:`supervisor-icon-btn`,icon:(0,X.jsx)($,{semantic:`supervisor.action.resume`,size:12}),onClick:()=>{i()},size:`sm`})}):(0,X.jsx)(Ig,{content:n(`supervisor.action.pause`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.pause`),className:`supervisor-icon-btn`,icon:(0,X.jsx)($,{semantic:`supervisor.action.pause`,size:12}),onClick:()=>{r()},size:`sm`})}),(0,X.jsx)(Ig,{content:n(`supervisor.action.trigger`),children:(0,X.jsx)(Em,{"aria-label":n(`supervisor.action.trigger`),className:`supervisor-icon-btn`,disabled:o,icon:(0,X.jsx)($,{semantic:`supervisor.action.trigger`,size:12}),onClick:()=>{a()},size:`sm`})})]})]}),(0,X.jsx)(DS,{workspaceId:t,sessionId:e}),(0,X.jsx)(TS,{workspaceId:t,sessionId:e})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`supervisor-card supervisor-card-inactive`,children:(0,X.jsx)(Ig,{content:n(`supervisor.action.enable`),children:(0,X.jsxs)(`button`,{className:`supervisor-enable-btn`,onClick:()=>c(`enable`),"aria-label":n(`supervisor.action.enable`),children:[(0,X.jsx)($,{semantic:`supervisor.entry`,size:13}),(0,X.jsx)(`span`,{children:n(`supervisor.title`)})]})})}),(0,X.jsx)(TS,{workspaceId:t,sessionId:e})]})}async function kS(e){let t;try{await navigator.clipboard.writeText(e);return}catch(e){t=e}if(typeof document>`u`||typeof document.execCommand!=`function`)throw t??Error(`Clipboard copy unavailable`);let n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,`true`),n.setAttribute(`aria-hidden`,`true`),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`0`,n.style.width=`1px`,n.style.height=`1px`,n.style.padding=`0`,n.style.border=`0`,n.style.opacity=`0`,n.style.pointerEvents=`none`,document.body.appendChild(n);try{if(n.focus(),n.select(),n.setSelectionRange(0,n.value.length),!document.execCommand(`copy`))throw t??Error(`Clipboard copy unavailable`)}finally{n.remove()}}var AS=Ap(e=>V({chunks:[],lastSeq:0})),jS=Ap(e=>V(null)),MS=Ap(e=>V([])),NS=Ap(e=>V(null));Ap(e=>V(t=>t(MS(e))));var PS=2,FS={focused:0,"visible-active":1,"visible-other":2,background:3};function IS(e,t){return FS[e]-FS[t]}function LS(e){let t=Math.max(1,e?.concurrency??PS),n=new Map,r=[],i=new Map,a=()=>{r.forEach((e,t)=>{for(let n of e.positionListeners)n(t)})},o=()=>{for(;n.size<t&&r.length>0;){let e=r.shift();if(!e)break;e.running=!0,n.set(e.terminalId,e),e.handle.isGranted=!0,e.grantedResolved||(e.grantedResolved=!0,e.resolveGranted())}a()},s=e=>{let t=r.findIndex(t=>t.terminalId===e);return t>=0?(r.splice(t,1),a(),!0):!1},c=e=>{let t=s(e.terminalId),r=n.delete(e.terminalId);!t&&!r||(i.delete(e.terminalId),r&&o())},l=(e,t)=>{if(e.tier=t,e.running)return;let n=r.findIndex(t=>t.terminalId===e.terminalId);if(n<0)return;r.splice(n,1);let i=r.findIndex(e=>IS(t,e.tier)<0);i<0&&(i=r.length),r.splice(i,0,e),o()},u=e=>{let t=r.findIndex(t=>IS(e.tier,t.tier)<0);t<0&&(t=r.length),r.splice(t,0,e),o()};return{request(e){let a=i.get(e.terminalId);if(a)return IS(e.tier,a.tier)<0&&l(a,e.tier),a.handle;let o=()=>{},s=new Promise(e=>{o=e}),d={};return d.terminalId=e.terminalId,d.tier=e.tier,d.granted=s,d.resolveGranted=o,d.grantedResolved=!1,d.running=!1,d.positionListeners=new Set,d.handle={granted:s,isGranted:!1,promote:e=>l(d,e),release:()=>c(d),subscribePosition:e=>{d.positionListeners.add(e);let t=r.findIndex(e=>e.terminalId===d.terminalId);return t>=0&&e(t),()=>{d.positionListeners.delete(e)}}},i.set(e.terminalId,d),n.size<t?(d.running=!0,n.set(d.terminalId,d),d.handle.isGranted=!0,d.grantedResolved=!0,d.resolveGranted()):u(d),d.handle},inspect(){return{running:Array.from(n.keys()),queued:r.map((e,t)=>({terminalId:e.terminalId,tier:e.tier,queuePosition:t}))}}}}var RS=LS();function zS(e,t){if(typeof e.getCell==`function`){let n=typeof e.length==`number`&&Number.isFinite(e.length)?Math.min(Math.max(e.length,0),t):t;for(let t=n-1;t>=0;--t){let n=e.getCell(t);if(!(!n||n.getChars()===``))return t+Math.max(n.getWidth(),1)}return 0}return e.translateToString(!0).length}function BS(e,t){let n=Array.from(e.children).filter(e=>e instanceof HTMLElement);for(let e=0;e<n.length;e+=1){let r=n[e].getBoundingClientRect();if(!(t<r.top||t>r.bottom))return e}return null}function VS(e,t,n,r,i){let a=e.getBoundingClientRect(),o=(t??e).getBoundingClientRect();if(r<a.left||r>a.right||i<a.top||i>a.bottom)return null;let s=BS(e,i);if(s===null)return null;let c=n.buffer.active.viewportY+s,l=n.buffer.active.getLine(c);if(!l||!Number.isFinite(n.cols)||n.cols<=0||o.width<=0||r<o.left||r>o.right)return null;let u=zS(l,n.cols);if(u===0)return c;let d=o.width/n.cols;if(d<=0)return null;let f=Math.floor((r-o.left)/d);return f<0||f>=n.cols||f>=u?null:c}function HS(e,t){let n=e.buffer.active,r=t,i=n.getLine(r);if(!i)return null;for(;i.isWrapped===!0;)if(--r,r<0||(i=n.getLine(r),!i))return null;let a=[i],o=r;for(;;){let e=n.getLine(o+1);if(!e||e.isWrapped!==!0)break;a.push(e),o+=1}return a.map((e,t)=>e.translateToString(t===a.length-1)).join(``)}function US(e){let t=VS(e.rowsElement,e.screenElement,e.terminal,e.clientX,e.clientY);return t===null?null:HS(e.terminal,t)}var WS=400,GS=[{id:`escape`,text:`Esc`},{id:`tab`,text:`Tab`},{id:`arrow_up`,text:`↑`},{id:`arrow_left`,text:`←`},{id:`arrow_down`,text:`↓`},{id:`arrow_right`,text:`→`},{id:`enter`,text:`Enter`}];function KS(e){(e.pointerType===`touch`||e.pointerType===`pen`)&&e.preventDefault()}function qS(e){return e.pointerType===`touch`||e.pointerType===`pen`}function JS(e,t){switch(e){case`escape`:return t.escape;case`tab`:return t.tab;case`enter`:return t.enter;case`arrow_up`:return t.up;case`arrow_down`:return t.down;case`arrow_left`:return t.left;case`arrow_right`:return t.right}}function YS({ctrlMode:e,shiftArmed:t,disabled:n=!1,labels:r,onKeyPress:i,onCtrlTap:a,onCtrlLongPress:o,onShiftTap:s,onPaste:c,onUpload:l}){let u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(!1),p=(0,H.useRef)(null),m=(0,H.useRef)(!1),h=(0,H.useRef)(null),g=n,_=()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},v=()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},y=()=>{m.current=!0,v(),d.current=setTimeout(()=>{m.current=!1,d.current=null},0)},b=()=>m.current?(m.current=!1,v(),!0):!1,x=()=>{h.current=null},S=(e,t)=>{qS(e)&&(h.current={pointerId:e.pointerId,target:t})},C=(e,t)=>{if(!qS(e))return`none`;let n=h.current;return!n||n.pointerId!==e.pointerId?`none`:(h.current=null,n.target===t?`matched`:`mismatched`)};(0,H.useEffect)(()=>{g&&(_(),v(),x(),f.current=!1,p.current=null,m.current=!1)},[g]),(0,H.useEffect)(()=>()=>{_(),v(),x()},[]);let w=()=>{g||(_(),f.current=!1,p.current=null,u.current=setTimeout(()=>{f.current=!0,p.current=`pointer`,o()},WS))},T=()=>{_(),f.current=!1,p.current=null,m.current=!1},E=()=>{g||_()},D=e=>{if(!g&&!b()){if(f.current){let t=p.current===`pointer`||p.current===`keyboard`&&e.detail===0;if(f.current=!1,p.current=null,t)return}a()}},O=e=>{let t=C(e,`ctrl`);if(E(),!(g||!qS(e)||t===`none`)&&(y(),t===`matched`)){if(f.current){f.current=!1,p.current=null;return}a()}},k=(e,t,n)=>{if(g||!qS(e))return;let r=C(e,t);r!==`none`&&(y(),r===`matched`&&n())},A=()=>{g||b()||s()},j=e=>{g||b()||i(e)},M=e=>{g||(e.key===`Enter`||e.key===` `)&&e.altKey&&(e.preventDefault(),_(),f.current=!0,p.current=`keyboard`,o())},N=e===`locked`?r.ctrlLocked:e===`armed`?r.ctrlArmed:r.ctrl,P=t?r.shiftArmed:r.shift;return(0,X.jsxs)(`div`,{className:`mobile-terminal-input-bar`,"data-expanded":`true`,"data-disabled":n?`true`:`false`,children:[(0,X.jsxs)(`div`,{className:`mobile-terminal-input-bar__actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.paste,disabled:g,onClick:()=>{g||c()},children:r.paste}),(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.upload,disabled:g,onClick:()=>{g||l()},children:r.upload})]}),(0,X.jsxs)(`div`,{className:`mobile-terminal-input-bar__keys`,role:`group`,"aria-label":r.shortcuts,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key mobile-terminal-input-bar__ctrl`,"data-ctrl-mode":e,"aria-pressed":e!==`off`,"aria-label":N,"aria-keyshortcuts":`Alt+Enter Alt+Space`,disabled:g,onPointerDown:e=>{KS(e),S(e,`ctrl`),w()},onPointerUp:O,onPointerCancel:()=>{x(),T()},onPointerLeave:()=>{x(),T()},onClick:D,onKeyDown:M,children:`Ctrl`}),(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key mobile-terminal-input-bar__shift`,"data-shift-armed":t?`true`:`false`,"aria-pressed":t,"aria-label":P,disabled:g,onPointerDown:e=>{KS(e),S(e,`shift`)},onPointerUp:e=>{k(e,`shift`,s)},onPointerCancel:x,onClick:A,children:`Shift`}),GS.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key`,"aria-label":JS(e.id,r),disabled:g,onPointerDown:t=>{KS(t),S(t,e.id)},onPointerUp:t=>{k(t,e.id,()=>i(e.id))},onPointerCancel:x,onClick:()=>j(e.id),children:e.text},e.id))]})]})}var XS={escape:`\x1B`,tab:` `,enter:`\r`,arrow_up:`\x1B[A`,arrow_down:`\x1B[B`,arrow_left:`\x1B[D`,arrow_right:`\x1B[C`},ZS={tab:`\x1B[Z`,arrow_up:`\x1B[1;2A`,arrow_down:`\x1B[1;2B`,arrow_left:`\x1B[1;2D`,arrow_right:`\x1B[1;2C`},QS=`control`;function $S(e,t){return t?.shift?ZS[e]??XS[e]:XS[e]}function eC(e){return e===`off`?`armed`:`off`}function tC(){return`locked`}function nC(e,t){if(t===`off`)return{data:e,nextCtrlMode:`off`};if(!/^[A-Za-z]$/.test(e))return{data:e,nextCtrlMode:t};let n=e.toUpperCase();return{data:String.fromCharCode(n.charCodeAt(0)-64),nextCtrlMode:t===`armed`?`off`:`locked`,activity:QS}}var rC=null;function iC(e){rC!==e&&(rC?.dispose(),rC=e)}function aC(){return rC}function oC(){iC(null)}var sC=12e4;function cC(e){return e instanceof Error&&e.message.includes(`Command timeout: terminal.replay`)||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`&&String(e.message).includes(`Command timeout: terminal.replay`)?`timeout`:`failed`}function lC(e){return typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?String(e.code):null}function uC(e){return e instanceof Error?e.message:typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?String(e.message):``}function dC(e){let t=lC(e);if(t===`no_client`||t===`unknown_op`||t===`activation_required`||t===`validation_error`||t===`internal_error`)return!0;let n=uC(e);return n.startsWith(`Unknown operation:`)||n.includes(`active session`)||n.includes(`WebSocket client not initialized`)}var fC=`application/x-coder-studio-workspace-path`;function pC(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.workspaceId==`string`&&t.workspaceId.length>0&&typeof t.path==`string`&&t.path.length>0&&(t.kind===`file`||t.kind===`dir`)}function mC(e){return Array.from(e?.types??[]).includes(fC)}function hC(e,t){e.effectAllowed=`copy`,e.setData(fC,JSON.stringify(t)),e.setData(`text/plain`,t.path)}function gC(e){if(!mC(e))return null;try{let t=e?.getData(`application/x-coder-studio-workspace-path`)??``,n=JSON.parse(t);return pC(n)?n:null}catch{return null}}function _C(e){return`'${e.replace(/'/g,`'\\''`)}'`}var vC=class extends Error{constructor(e,t,n){super(n??e),this.code=e,this.status=t,this.name=`UploadError`}};async function yC(e){let t=new FormData;t.append(`workspaceId`,e.workspaceId);for(let n of e.files)t.append(`files`,n,n.name);let n;try{n=await fetch(`/api/uploads`,{method:`POST`,body:t,credentials:`include`})}catch(e){throw new vC(`network_error`,0,e.message)}let r;try{r=await n.json()}catch{r={}}if(!n.ok||!r.ok)throw new vC(r.error??`http_${n.status}`,n.status);return r.files??[]}async function bC(e){let t=e.types.find(e=>e.startsWith(`image/`));if(!t)return null;let n=await e.getType(t),r=t.split(`/`)[1]??`png`;return new File([n],`clipboard.${r}`,{type:t})}function xC(e){let{containerRef:t,workspaceId:n,sendTextToTerminal:r,enabled:i}=e,[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(0),c=(0,H.useRef)(0),l=(0,H.useRef)(0),u=(0,H.useRef)(new Map),d=(0,H.useRef)(Promise.resolve()),f=W(sy),p=(0,H.useCallback)(async(e,t)=>{u.current.set(e,t),d.current=d.current.then(async()=>{for(;u.current.has(l.current);){let e=l.current,t=u.current.get(e)??null;u.current.delete(e),l.current+=1,t&&await r(t)}}),await d.current},[r]),m=(0,H.useCallback)(async(e,t)=>{let{trackBusy:n=!0,onError:r}=t??{},i=c.current;c.current+=1,n&&(s.current+=1,o(!0));try{await p(i,await e())}catch(e){if(await p(i,null),r){r(e);return}f({kind:`error`,title:`Upload failed`,body:`Could not upload file(s): ${e instanceof vC?e.code:`unknown`}`,duration:5e3})}finally{n&&(s.current=Math.max(0,s.current-1),o(s.current>0))}},[f,p]),h=(0,H.useCallback)(async e=>{e.length!==0&&await m(async()=>{let t=await yC({workspaceId:n,files:e});return t.length===0?null:`${t.map(e=>_C(e.path)).join(` `)} `})},[m,n]),g=(0,H.useCallback)(async e=>{e&&await m(async()=>e,{trackBusy:!1,onError:e=>{throw e}})},[m]),_=(0,H.useCallback)(async e=>{let t=gC(e);if(!t){f({kind:`error`,title:`Drop failed`,body:`Could not read the dragged workspace path.`,duration:3e3});return}if(t.workspaceId!==n){f({kind:`error`,title:`Drop failed`,body:`You can only drop paths from the current workspace.`,duration:3e3});return}await m(async()=>`${_C(t.path)} `,{trackBusy:!1,onError:e=>{console.debug(`Workspace path drop failed:`,e),f({kind:`error`,title:`Drop failed`,body:`Could not insert the dragged path into the terminal.`,duration:3e3})}})},[f,m,n]),v=(0,H.useCallback)(async()=>{if(!i)return;let e=navigator.clipboard;if(!e)throw Error(`Clipboard API not available`);try{let t=e.read;if(typeof t==`function`){let n=await t.call(e),r=[];for(let e of n){let t=await bC(e);t&&r.push(t)}if(r.length>0){await h(r);return}}}catch(e){console.debug(`Clipboard image read failed, trying text:`,e)}try{let t=e.readText?.bind(e);if(!t)throw Error(`Clipboard text read not available`);let n=await t();if(!n){f({kind:`info`,title:`Paste`,body:`Clipboard is empty`,duration:2e3});return}await g(n)}catch(e){throw f({kind:`error`,title:`Paste failed`,body:`Could not read from clipboard. Please check permissions.`,duration:3e3}),e}},[i,h,g,f]);return(0,H.useEffect)(()=>{let e=t.current;if(!e||!i)return;let n=e=>{let t=e.clipboardData?.files;!t||t.length===0||(e.preventDefault(),e.stopPropagation(),h(Array.from(t)))},r=e=>{let t=e.dataTransfer?.files;if(t&&t.length>0){e.preventDefault(),e.stopPropagation(),h(Array.from(t));return}mC(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),_(e.dataTransfer))},a=e=>{if(mC(e.dataTransfer)){e.preventDefault();return}Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&e.preventDefault()};return e.addEventListener(`paste`,n,{capture:!0}),e.addEventListener(`drop`,r,{capture:!0}),e.addEventListener(`dragover`,a,{capture:!0}),()=>{e.removeEventListener(`paste`,n,{capture:!0}),e.removeEventListener(`drop`,r,{capture:!0}),e.removeEventListener(`dragover`,a,{capture:!0})}},[t,i,h,_]),{busy:a,handleClipboardPaste:v,handleFiles:h}}var SC=({state:e,queuePosition:t})=>{let n=Z(),r=e===`granting`?n(`terminal.replay.loading_title`):t===0?n(`terminal.replay.up_next`):n(`terminal.replay.queued_title`,{count:t??0});return(0,X.jsxs)(Dh,{className:`xterm-replay-overlay xterm-replay-overlay--placeholder`,interactive:!1,mode:`status`,open:!0,surfaceClassName:`xterm-replay-overlay__card`,children:[e===`granting`?(0,X.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,X.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:r})]})},CC=16,wC=80,TC=.12,EC=.02,DC=.92,OC=16,kC=500,AC=10,jC=new Set([`\x1B[I`,`\x1B[O`]),MC=3e3,NC=1200;function PC(e){return/^\x1b\[\d+;\d+R$/.test(e)||/^\x1b\[(?:\?|>)(?:\d+;)*\d*c$/.test(e)}function FC(e){return jC.has(e)?`system`:e.includes(`\r`)||e.includes(`
|
|
107
|
+
`)?`submit`:`typing`}function IC(e){let t=e.length;for(;t>0;){let n=e[t-1];if(!n||!/\s/.test(n))break;--t}for(;t>0;){let n=e[t-1];if(!n||/\s/.test(n))break;--t}return e.slice(0,t)}function LC(e,t,n){if(n===`system`)return{nextDraft:e};let r=e,i;for(let e=0;e<t.length;e+=1){let n=t[e];if(n===`\x1B`){let n=t.slice(e).match(/^\x1b(?:\[[0-9;?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|P[\s\S]*?\x1b\\|[@-_])/);if(n){e+=n[0].length-1;continue}}if(n===``||n===`\b`){r=r.slice(0,-1);continue}if(n===``){r=``;continue}if(n===``){r=IC(r);continue}if(n===``){r=``,i=void 0;continue}if(n===`\r`||n===`
|
|
108
|
+
`){i=r.length>0?r:i,r=``;continue}n>=` `&&(r+=n)}return{nextDraft:r,submittedText:i}}function RC(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n)&255;return t}function zC(e,t){return e?`item`in e&&typeof e.item==`function`?e.item(t):e[t]??null:null}function BC(e,t){if(t===null||!e)return null;for(let n=0;n<e.length;n+=1){let r=zC(e,n);if(r?.identifier===t)return r}return null}function VC(e,t){if(e.rows>0){let n=e.element?.querySelector(`.xterm-screen`),r=n instanceof HTMLElement?n.getBoundingClientRect().height:t.getBoundingClientRect().height;if(r>0)return r/e.rows}return CC}function HC(e){return e.type!==`keydown`||e.shiftKey||e.altKey?!1:(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`}var UC=new TextEncoder,WC=new TextDecoder(`utf-8`,{fatal:!1}),GC=`coderStudio.terminalTrace`;function KC(){try{return globalThis.localStorage?.getItem(GC)===`1`}catch{return!1}}function qC(){if(typeof document>`u`)return Promise.resolve();let e=document.fonts;return e?.ready?e.ready.then(()=>void 0,()=>void 0):Promise.resolve()}function JC(e,t){return e.split(t).length-1}function YC(e){let t=typeof e==`string`?e:WC.decode(e);return{length:typeof e==`string`?e.length:e.byteLength,syncStart:JC(t,`\x1B[?2026h`),syncEnd:JC(t,`\x1B[?2026l`),clearToEnd:JC(t,`\x1B[J`),clearScreen:JC(t,`\x1B[2J`),eraseLine:JC(t,`\x1B[K`),cursorHome:JC(t,`\x1B[1;1H`),dsr:JC(t,`\x1B[6n`),da:JC(t,`\x1B[c`),reverseIndex:JC(t,`\x1BM`),cursorMoves:t.match(/\x1b\[[0-9;]*[Hf]/g)?.length??0,scrollRegions:t.match(/\x1b\[[0-9;]*r/g)?.slice(0,6)??[]}}function XC(e,t,n={}){KC()&&console.debug(`[terminal-trace]`,{at:Math.round(performance.now()*100)/100,terminalId:e,event:t,...n})}function ZC(e,t){let n=Math.min(t,e.chunks.length);return n===0?e:{...e,chunks:e.chunks.slice(n)}}function QC(e){return{...Oa(e).terminalTheme,background:`#00000000`}}function $C(e){return Oa(e).terminalTheme}function ew(e){let t=e.trim();if(!t.startsWith(`#`))return null;let n=t.slice(1),r;if(n.length===3||n.length===4)r=n.slice(0,3).split(``).map(e=>`${e}${e}`).join(``);else if(n.length===6||n.length===8)r=n.slice(0,6);else return null;return/^[\da-f]{6}$/iu.test(r)?[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16)]:null}function tw(e,t){let n=ew(t);if(!n)return null;let r=e=>e.toString(16).padStart(2,`0`).repeat(2);return`\x1b]${e};rgb:${r(n[0])}/${r(n[1])}/${r(n[2])}\x1b\\`}function nw(e){let t=e.trim();if(!t)return null;let n=t.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:\d*\.?\d+))?\s*\)$/iu);return n?[Math.min(255,Number.parseInt(n[1]??`0`,10)),Math.min(255,Number.parseInt(n[2]??`0`,10)),Math.min(255,Number.parseInt(n[3]??`0`,10))]:ew(t)}function rw(e,t){let n=Math.min(Math.max(t,0),1);return n>=.999?`rgb(${e[0]}, ${e[1]}, ${e[2]})`:`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${Math.round(n*1e3)/1e3})`}function iw(e){return!Array.from(e.classList).some(e=>e===`xterm-cursor`||e.startsWith(`xterm-cursor-`))}function aw(e){return e.style.backgroundColor.trim()||(!Array.from(e.classList).some(e=>e.startsWith(`xterm-bg-`))||typeof window>`u`?null:window.getComputedStyle(e).backgroundColor.trim()||null)}function ow(e,t,n){if(!e)return;let r=e.querySelector(`.xterm-rows`);if(!(r instanceof HTMLElement))return;let i=Array.from(r.children);if(i.length===0)return;let a=Math.max(0,n?.start??0),o=Math.min(i.length-1,n?.end??i.length-1);for(let e=a;e<=o;e+=1){let n=i[e];if(!(n instanceof HTMLElement))continue;let r=n.querySelectorAll(`span`);for(let e of r){if(!(e instanceof HTMLSpanElement)||!iw(e))continue;let n=aw(e);if(!n)continue;let r=nw(n);r&&(e.style.backgroundColor=rw(r,t))}}}function sw({closedSessionContinueLabel:e,closedSessionProviderLabel:t,onClosedSessionClose:n,onClosedSessionContinue:r,terminalId:i,workspaceId:a,readOnly:o=!1,isActiveSession:s=!1,terminalKind:c}){let l=Z(),u=Br(),d=U(Xa),f=U(io),p=U(By),m=Ly(p,u),h=U(bp),v=U(Op),y=W(sy),b=W(jS(i)),[x,S]=Te(AS(i)),C=U(jS(i)),w=(0,H.useRef)(C),T=c??C?.kind??`shell`,E=!o&&C?.alive!==!1,D=(0,H.useRef)(null),O=(0,H.useRef)(null),k=(0,H.useRef)(null),A=(0,H.useRef)(null),j=(0,H.useRef)(null),M=(0,H.useRef)(!1),N=(0,H.useRef)([]),P=(0,H.useRef)(null),F=(0,H.useRef)(!0),ee=(0,H.useRef)(null),I=(0,H.useRef)([]),L=(0,H.useRef)(!1),R=(0,H.useRef)(0),z=(0,H.useRef)(null),te=(0,H.useRef)(null),ne=(0,H.useRef)(null),re=(0,H.useRef)(null),ie=(0,H.useRef)(null),ae=(0,H.useRef)(null),B=(0,H.useRef)(null),oe=(0,H.useRef)(null),se=(0,H.useRef)(null),ce=(0,H.useRef)(!1),V=(0,H.useRef)(`idle`),le=(0,H.useRef)(null),ue=(0,H.useRef)(0),de=(0,H.useRef)(null),fe=(0,H.useRef)(0),pe=(0,H.useRef)(0),me=(0,H.useRef)(d),he=(0,H.useRef)(``),ge=(0,H.useRef)(0),_e=(0,H.useRef)(null),ve=(0,H.useRef)(!1),ye=(0,H.useRef)(null),be=(0,H.useRef)(``),xe=(0,H.useRef)(0),Se=(0,H.useRef)(null),Ce=(0,H.useRef)(()=>{}),we=(0,H.useRef)(()=>{}),Ee=(0,H.useRef)({activeTouchId:null,lastClientY:0,carryPx:0,pxPerLine:null,velocityPxPerMs:0,lastMomentumFrameAt:0,momentumFrameId:null,gestureDidScroll:!1,samples:[]}),[De,Oe]=(0,H.useState)({kind:`loading`}),[ke,Ae]=(0,H.useState)(!1),je=E&&De.kind!==`closed`&&De.kind!==`unavailable`,Me=(0,H.useRef)(`blocking_rebuild`),[Ne,Pe]=(0,H.useState)(u===`mobile`?{kind:`granted`}:{kind:`idle`}),[Fe,Ie]=(0,H.useState)(`off`),[Le,Re]=(0,H.useState)(!1),ze=(0,H.useRef)(`off`),Be=(0,H.useRef)(!1),[Ve,He]=(0,H.useState)(()=>!h||typeof h.getStatus!=`function`?`disconnected`:h.getStatus()),Ue=QC(d),We=Ha(f,u),Ge=d===`hc-dark`||d===`hc-light`?1:Math.min(Math.max(We.surfaceOpacity,0),100)/100,Ke=(0,H.useRef)(Ge),qe=(0,H.useRef)(()=>{}),Je=(0,H.useRef)(()=>{}),Ye=(0,H.useRef)(()=>{}),Xe=aC();(0,H.useEffect)(()=>{w.current=C},[C]);let Ze=(0,H.useCallback)(e=>{w.current?.alive!==!1&&(b(t=>t&&{...t,alive:!1,exitCode:e}),O.current&&O.current.writeln(`\r\n[Process exited with code ${e??0}]`))},[b]);(0,H.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]),(0,H.useEffect)(()=>{me.current=d},[d]),(0,H.useLayoutEffect)(()=>{if(u===`mobile`){Pe({kind:`granted`}),ve.current=!0,_e.current=null;return}ve.current=!1;let e=C?.alive===!1?`background`:s?`visible-active`:`visible-other`,t=RS.request({terminalId:i,tier:e});_e.current=t,Pe(t.isGranted?{kind:`granted`}:{kind:`idle`});let n=!1,r=t.subscribePosition(e=>{n||Pe({kind:`queued`,queuePosition:e})});return t.isGranted||t.granted.then(()=>{n||Pe({kind:`granted`})}),()=>{n=!0,r(),ve.current||=(t.release(),!0),_e.current=null}},[i,u]),(0,H.useEffect)(()=>{if(u===`mobile`)return;let e=C?.alive===!1?`background`:s?`visible-active`:`visible-other`;_e.current?.promote(e)},[s,C?.alive,u]),(0,H.useEffect)(()=>{O.current&&(O.current.options.theme=Ue)},[Ue]),(0,H.useEffect)(()=>{Ke.current=Ge,ow(D.current,Ge)},[Ge]),(0,H.useEffect)(()=>{if(De.kind!==`loading`){Ae(!1);return}Ae(!1);let e=setTimeout(()=>{Ae(!0)},NC);return()=>{clearTimeout(e)}},[De]),(0,H.useEffect)(()=>{let e=D.current;if(!e||typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(pointer: coarse)`).matches)return;let t=Ee.current,n=null,r=null,i=0,a=0,o=null,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null),r=null,i=0,a=0,o=null,s=!1},l=()=>{t.momentumFrameId!==null&&(cancelAnimationFrame(t.momentumFrameId),t.momentumFrameId=null),t.velocityPxPerMs=0,t.lastMomentumFrameAt=0},d=(e,n)=>{t.samples.push({clientY:e,at:n});let r=n-wC;for(;t.samples.length>0&&t.samples[0].at<r;)t.samples.shift()},f=()=>{if(t.samples.length<2){t.velocityPxPerMs=0;return}let e=t.samples[0],n=t.samples[t.samples.length-1],r=n.at-e.at;if(r<=0){t.velocityPxPerMs=0;return}t.velocityPxPerMs=(e.clientY-n.clientY)/r},m=(n,r)=>{let i=n.buffer.active.baseY;if(i<=0)return t.carryPx=0,`blocked`;t.carryPx+=r;let a=t.pxPerLine??=VC(n,e),o=t.carryPx>0?Math.floor(t.carryPx/a):Math.ceil(t.carryPx/a);if(o===0)return`buffered`;let s=n.buffer.active.viewportY,c=i-s,l=o>0?Math.min(o,c):Math.max(o,-s);return l===0?(t.carryPx=0,`blocked`):(n.scrollLines(l),t.carryPx-=l*a,`scrolled`)},h=e=>{if(t.momentumFrameId===null)return;let n=O.current;if(!n){l();return}let r=t.lastMomentumFrameAt>0?t.lastMomentumFrameAt:e-OC,i=Math.max(1,Math.min(64,e-r));t.lastMomentumFrameAt=e;let a=m(n,t.velocityPxPerMs*i),o=DC**+(i/OC);if(t.velocityPxPerMs*=o,a===`blocked`||Math.abs(t.velocityPxPerMs)<=EC){t.carryPx=0,l(),t.pxPerLine=null;return}t.momentumFrameId=requestAnimationFrame(h)},g=()=>{c(),l(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.gestureDidScroll=!1,t.samples=[]};we.current=g;let _=c=>{if(c.touches.length!==1){g();return}let f=zC(c.touches,0);if(!f){g();return}if(l(),t.activeTouchId=f.identifier,t.lastClientY=f.clientY,t.carryPx=0,t.pxPerLine=O.current?VC(O.current,e):CC,t.gestureDidScroll=!1,t.samples=[],d(f.clientY,performance.now()),u===`mobile`&&p.copyOnSelect){r=f.identifier,i=f.clientX,a=f.clientY;let t=O.current,c=e.querySelector(`.xterm-rows`),l=e.querySelector(`.xterm-screen`);s=!1,o=t&&c instanceof HTMLElement?US({clientX:f.clientX,clientY:f.clientY,rowsElement:c,screenElement:l instanceof HTMLElement?l:void 0,terminal:t}):null,n=setTimeout(()=>{n=null,s=!0},kC)}},v=e=>{let n=BC(e.changedTouches,t.activeTouchId),o=O.current;if(!n||!o)return;if(r===n.identifier)if(Math.abs(n.clientX-i)>AC||Math.abs(n.clientY-a)>AC)c();else return;if(o.buffer.active.baseY<=0){t.lastClientY=n.clientY,t.carryPx=0,t.gestureDidScroll=!1,t.samples=[],t.velocityPxPerMs=0;return}t.gestureDidScroll=!0;let s=t.lastClientY-n.clientY;t.lastClientY=n.clientY,d(n.clientY,performance.now()),f();let l=m(o,s);(l===`buffered`||l===`scrolled`)&&e.cancelable&&e.preventDefault()},y=e=>{if(BC(e.changedTouches,r)){if(s){let e=o;c(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0,t.gestureDidScroll=!1,t.samples=[],Ce.current(e);return}c()}if(BC(e.changedTouches,t.activeTouchId)){let n=t.gestureDidScroll,r=BC(e.changedTouches,t.activeTouchId);if(r&&n&&(d(r.clientY,performance.now()),f()),t.activeTouchId=null,t.lastClientY=0,t.gestureDidScroll=!1,t.samples=[],n&&Math.abs(t.velocityPxPerMs)>=TC){t.lastMomentumFrameAt=0,t.momentumFrameId=requestAnimationFrame(h);return}t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0}},b=()=>{g()};return e.addEventListener(`touchstart`,_,{passive:!0}),e.addEventListener(`touchmove`,v,{passive:!1}),e.addEventListener(`touchend`,y,{passive:!0}),e.addEventListener(`touchcancel`,b,{passive:!0}),()=>{e.removeEventListener(`touchstart`,_),e.removeEventListener(`touchmove`,v),e.removeEventListener(`touchend`,y),e.removeEventListener(`touchcancel`,b),we.current=()=>{},g()}},[p.copyOnSelect,u]);let Qe=(0,H.useCallback)(()=>{j.current!==null&&cancelAnimationFrame(j.current),j.current=requestAnimationFrame(()=>{j.current=null;try{let e=O.current?{cols:O.current.cols,rows:O.current.rows}:null;k.current?.fit(),XC(i,`fit`,{before:e,after:O.current?{cols:O.current.cols,rows:O.current.rows}:null})}catch(e){console.error(`Failed to fit xterm instance:`,e)}finally{let e=N.current;N.current=[];for(let t of e)t()}})},[i]),$e=(0,H.useCallback)(()=>new Promise(e=>{N.current.push(e)}),[]);(0,H.useEffect)(()=>{!O.current||O.current.options.fontSize===m||(O.current.options.fontSize=m,Qe())},[Qe,m]);let et=(0,H.useCallback)(e=>{ze.current=e,Ie(e)},[]),tt=(0,H.useCallback)(e=>{Be.current=e,Re(e)},[]),nt=(0,H.useCallback)(()=>{let e=Date.now();e-xe.current<MC||(xe.current=e,y({kind:`error`,title:l(u===`mobile`?`terminal.mobile_copy_current_line_failed_title`:`settings.copy_on_select_failed_title`),body:l(u===`mobile`?`terminal.mobile_copy_current_line_failed_body`:`settings.copy_on_select_failed_body`)}))},[y,l,u]),rt=(0,H.useCallback)(async e=>{if(!(u!==`mobile`||!p.copyOnSelect)&&(we.current(),e!==null))try{await kS(e),y({kind:`success`,title:l(`terminal.copied_current_line`)}),typeof navigator<`u`&&typeof navigator.vibrate==`function`&&navigator.vibrate(10)}catch{nt()}},[nt,y,l,p.copyOnSelect,u]);(0,H.useEffect)(()=>{Ce.current=e=>{rt(e)}},[rt]),(0,H.useLayoutEffect)(()=>{we.current()},[i,a]);let it=(0,H.useCallback)(async()=>{if(u===`mobile`||!p.copyOnSelect)return;let e=O.current;if(!e?.hasSelection())return;let t=be.current||e.getSelection();if(t)try{await kS(t)}catch{nt()}},[nt,p.copyOnSelect,u]),at=(0,H.useCallback)(async(e,t,n)=>{if(F.current){if(!h){console.error(`Cannot send terminal input: WebSocket not connected`);return}await h.sendTerminalInput(i,e,t,n)}},[i,h]),ot=(0,H.useCallback)(async(e,t)=>{if(fe.current>0&&PC(e)){XC(i,`input.suppressed-replay-response`,{summary:YC(e)});return}let n=ge.current+1;ge.current=n;let r=ze.current,a=he.current,o=nC(e,r),s=o.activity??t??FC(o.data),{nextDraft:c,submittedText:l}=LC(a,o.data,s);try{o.nextCtrlMode!==r&&et(o.nextCtrlMode),XC(i,`input`,{activity:s,summary:YC(o.data)}),he.current=c,await at(UC.encode(o.data),s,l)}catch(e){ge.current===n&&(he.current=a,o.nextCtrlMode!==r&&ze.current===o.nextCtrlMode&&et(r)),console.error(`Failed to send terminal input:`,e)}},[at,i,et]),st=(0,H.useCallback)(async e=>{let t=RC(e);XC(i,`input.binary`,{activity:`control`,summary:YC(t)});try{await at(t,`control`)}catch(e){console.error(`Failed to send terminal input:`,e)}},[at,i]),ct=(0,H.useCallback)(async({cols:e,rows:t})=>{if(!F.current)return;let n=ee.current;if(n&&n.cols===e&&n.rows===t)return;ee.current={cols:e,rows:t},XC(i,`resize.dispatch`,{previousSize:n,nextSize:{cols:e,rows:t}});let r=await v(`terminal.resize`,{terminalId:i,cols:e,rows:t});r.ok||console.error(`Failed to sync terminal size:`,r.error),XC(i,`resize.result`,{nextSize:{cols:e,rows:t},ok:r.ok,error:r.ok?void 0:r.error})},[i,v]),lt=(0,H.useCallback)(async e=>{await ot(e)},[ot]),{busy:ut,handleClipboardPaste:dt,handleFiles:ft}=xC({containerRef:D,workspaceId:a,sendTextToTerminal:lt,enabled:je});(0,H.useEffect)(()=>{F.current=je,O.current&&(O.current.options.disableStdin=!je||ut,O.current.options.cursorBlink=je&&!ut)},[je,ut]),(0,H.useEffect)(()=>{if(!h){He(`disconnected`);return}if(typeof h.getStatus==`function`?He(h.getStatus()):He(`connected`),typeof h.onStatus==`function`)return h.onStatus(e=>{He(e)})},[h]),(0,H.useEffect)(()=>{if(Xe)return Xe.registerTerminal({terminalId:i,workspaceId:a,getRenderedSeq:()=>z.current??ue.current,setUiMode:(e,t)=>{if(Me.current=e,e===`silent`){z.current=null,Oe({kind:`ready`});return}if(e===`closed`){z.current=null,Oe({kind:`closed`});return}if(e===`error`){if(t?.reason===`too_old_no_snapshot`){if(B.current){B.current();return}z.current=null,Oe({kind:`unrecoverable_history`,reason:`too_old_no_snapshot`});return}if(t?.reason===`unknown_terminal`){if(oe.current){oe.current();return}z.current=null,Oe({kind:`unavailable`});return}if(t?.reason===`reconcile_failed`){if(ae.current){ae.current(t);return}z.current=null,Oe({kind:`recovery_check_failed`});return}if(ie.current){ie.current(Error(`terminal recovery failed`));return}Oe({kind:`retryable_failure`,reason:`failed`});return}(e===`non_blocking_recovering`||e===`blocking_rebuild`)&&z.current===null&&(z.current=ue.current),Oe({kind:`loading`})},markClosed:({exitCode:e})=>{Ze(e)},completeRecovery:async(e,t)=>{await re.current?.(e,t)},applyReplay:async e=>{await te.current?.(e)},applySnapshot:async e=>{await ne.current?.(e)}})},[Ze,Xe,i,a]),(0,H.useLayoutEffect)(()=>{et(`off`),tt(!1),he.current=``,ge.current+=1},[i,et,tt]),(0,H.useEffect)(()=>{qe.current=ot},[ot]),(0,H.useEffect)(()=>{Je.current=st},[st]),(0,H.useEffect)(()=>{Ye.current=ct},[ct]),(0,H.useEffect)(()=>{if(u!==`mobile`&&Ne.kind!==`granted`||!D.current)return;let e=!1,t=null,n=pe.current+1;pe.current=n,fe.current=0,ye.current=null,de.current=null,L.current=!1,R.current=0,V.current=`idle`,le.current=null,I.current=[],ee.current=null,Oe({kind:`loading`});let r=new _({theme:QC(me.current),allowTransparency:!0,fontFamily:`JetBrains Mono, Fira Code, SF Mono, monospace`,fontSize:m,scrollback:5e3,cursorBlink:je&&!ut,cursorStyle:`block`,disableStdin:!je||ut,allowProposedApi:!0}),o=(e,t)=>{let n=tw(e,t);return n?(qe.current(n,`system`),!0):!1},s=r.parser.registerOscHandler(10,e=>e===`?`?o(`10`,$C(me.current).foreground):!1),c=r.parser.registerOscHandler(11,e=>e===`?`?o(`11`,$C(me.current).background):!1),l=new g;r.loadAddon(l),r.onResize(e=>{Ye.current(e)}),r.onData(e=>{qe.current(e)}),typeof r.onBinary==`function`&&r.onBinary(e=>{Je.current(e)});let d=typeof r.onRender==`function`?r.onRender(({start:e,end:t})=>{ow(D.current,Ke.current,{start:e,end:t})}):void 0,f=typeof r.onSelectionChange==`function`?r.onSelectionChange(()=>{be.current=r.hasSelection()?r.getSelection():``}):void 0;r.attachCustomKeyEventHandler(e=>!HC(e)),r.open(D.current),XC(i,`mount.open`),O.current=r,k.current=l,Qe();let p=$e();u!==`mobile`&&p.then(async()=>{await qC(),!(e||!M.current)&&Qe()}).catch(()=>{});let v=async()=>{h&&(typeof h.getStatus!=`function`||typeof h.onStatus!=`function`||h.getStatus()!==`connected`&&await new Promise(e=>{let n=!1,r=()=>{n||(n=!0,t?.(),t=null,e())};t=h.onStatus(e=>{e===`connected`&&r()}),h.getStatus()===`connected`&&r()}))},y=p.then(async()=>{if(!h||(await v(),e||!M.current))return;let{cols:t,rows:n}=r;await Ye.current({cols:t,rows:n})}),b=(e,t)=>{fe.current+=1;let i=!1,a=()=>{i||(i=!0,pe.current===n&&(fe.current=Math.max(0,fe.current-1),t?.()))};try{r.write(e,a)}catch(e){throw a(),e}},x=dp.terminalOutput(a,i),C=dp.terminalExit(a,i),w=e=>{let t=I.current;I.current=[];let n=[],r=e;for(let e of t)e.seq<=r||(n.push(e),r=e.seq);return{entries:n,latestCoveredSeq:r}},T=()=>{u!==`mobile`&&(_e.current?.release(),ve.current=!0)},E=e=>{V.current=`done`,le.current=null,e&&de.current===e&&(de.current=`reconnect`),ye.current?.()},N=async e=>{e.length!==0&&await new Promise((t,a)=>{let o=e.length,s=!1,c=e=>{M.current&&pe.current===n&&(ue.current=Math.max(ue.current,e)),o=Math.max(0,o-1),o===0&&!s&&(s=!0,t())};for(let t of e){t.resetTerminalBeforeWrite&&typeof O.current?.reset==`function`&&O.current.reset(),t.kind===`historical`?XC(i,`write.historical`,{seq:t.seq,size:t.bytes.byteLength,summary:YC(t.bytes)}):XC(i,`write.pending-replay-chunk`,{seq:t.seq,summary:YC(t.bytes)});try{if(t.kind===`historical`){b(t.bytes,()=>{c(t.seq)});continue}r.write(t.bytes,()=>{c(t.seq)})}catch(e){s||(s=!0,a(e));return}}})},P=async e=>{let t=e?.coveredSeq??R.current,n=[];for(e?.bytes&&typeof e.coveredSeq==`number`&&n.push({kind:`historical`,bytes:e.bytes,seq:e.coveredSeq,resetTerminalBeforeWrite:e.resetTerminalBeforeWrite}),L.current=!1,n.length>0&&await N(n),R.current=t,ue.current=Math.max(ue.current,t),L.current=!0,S(e=>({...e,chunks:[],lastSeq:Math.max(e.lastSeq,t)}));;){let{entries:e,latestCoveredSeq:n}=w(t);if(e.length===0)break;t=n,await N(e.map(e=>({kind:`pending`,bytes:e.bytes,seq:e.seq})))}E(le.current)};re.current=async(e,t)=>{!M.current||!O.current||(T(),await P({coveredSeq:e}),z.current=null,t&&Ze(t.exitCode))};let F=async e=>{if(!M.current||!O.current)return;let t=Ce();if(t!==`connected`){XC(i,`recovery.fail.deferred-ws-unhealthy`,{status:t,error:e instanceof Error?e.message:String(e)}),Me.current=`non_blocking_recovering`,Oe({kind:`loading`}),Se(),T();return}console.error(`Failed to recover terminal output:`,e),Me.current=`error`;let n=cC(e);Oe(ce.current?{kind:`failed`,reason:n}:{kind:`retryable_failure`,reason:n}),T(),await P()};ie.current=F;let he=async()=>{!M.current||!O.current||(Me.current=`error`,z.current=null,Oe({kind:`unrecoverable_history`,reason:`too_old_no_snapshot`}),T(),await P())};B.current=he,ae.current=async e=>{!M.current||!O.current||(Me.current=`error`,z.current=null,Oe({kind:`recovery_check_failed`}),T(),await P())};let ge=async()=>{!M.current||!O.current||(Me.current=`error`,z.current=null,Oe({kind:`unavailable`}),T(),await P())};oe.current=ge,te.current=async(e,t)=>{if(!M.current||!O.current)return;let n=t?.resetTerminalBeforeWrite??z.current===0;V.current=`in-flight`,le.current=`reconnect`,Me.current=`silent`,ce.current=!1,Oe({kind:`ready`}),T(),await P({bytes:e.bytes,coveredSeq:e.seq,resetTerminalBeforeWrite:n}),z.current=null},ne.current=async e=>{!M.current||!O.current||(V.current=`in-flight`,le.current=`initial`,Me.current=`silent`,ce.current=!1,Oe({kind:`ready`}),T(),await P({bytes:e.bytes,coveredSeq:e.seq,resetTerminalBeforeWrite:!0}),z.current=null)};let H=e=>{h&&(z.current===null&&(z.current=ue.current),V.current=`in-flight`,L.current=!1,Oe({kind:`loading`}),h.sendCommand(`terminal.snapshot`,{terminalId:i},{timeoutMs:sC}).then(e=>({ok:!0,data:e})).catch(e=>({ok:!1,error:e})).then(t=>{if(!(!M.current||!O.current)){if(t.ok&&t.data?.status===`ok`&&t.data.bytes&&typeof t.data.seq==`number`){ne.current?.({...t.data,bytes:t.data.bytes});return}if(e?.onUnavailable){e.onUnavailable(t);return}if(!t.ok&&dC(t.error)){ae.current?.({reason:`reconcile_failed`,operation:`terminal.snapshot`});return}if(t.ok){ae.current?.({reason:`reconcile_failed`,operation:`terminal.snapshot`});return}F(t.error)}}))},xe=(e,t)=>{h&&(z.current=e,V.current=`in-flight`,L.current=!1,e===0&&Oe({kind:`loading`}),XC(i,`replay.request`,{lastSeq:e}),h.sendCommand(`terminal.replay`,{terminalId:i,lastSeq:e},{timeoutMs:sC}).then(e=>({ok:!0,data:e})).catch(e=>({ok:!1,error:e})).then(n=>{if(n.ok&&n.data?.status===`too_old`&&t?.onTooOld){t.onTooOld();return}if(n.ok&&n.data?.status===`ok`&&n.data.bytes){te.current?.({...n.data,bytes:n.data.bytes},{resetTerminalBeforeWrite:t?.resetTerminalBeforeWrite??e===0});return}if(n.ok&&n.data?.status===`unknown`){ge();return}if(t?.onError){t.onError(n.ok?void 0:n.error);return}if(!n.ok&&dC(n.error)){ae.current?.({reason:`reconcile_failed`,operation:`terminal.replay`});return}if(n.ok){ae.current?.({reason:`reconcile_failed`,operation:`terminal.replay`});return}F(n.error)}))},Se=()=>{de.current||=le.current??`reconnect`,V.current=`idle`,le.current=null,L.current=!1,ye.current?.()},Ce=()=>typeof h?.getStatus==`function`?h.getStatus():`connected`,we=(e,t)=>{let n=Ce();if(de.current===`reconnect`||n===`disconnected`||n===`reconnecting`){XC(i,`reconnect.snapshot-fallback.defer-until-reconnect`,{lastSeq:ue.current,reason:e,error:t?String(t):void 0,connectionStatus:n}),Se();return}XC(i,`reconnect.snapshot-fallback`,{lastSeq:ue.current,reason:e,error:t?String(t):void 0}),H({resetTerminalBeforeWrite:!0,onUnavailable:n=>{let r=Ce();if(de.current===`reconnect`||r===`disconnected`||r===`reconnecting`){XC(i,`reconnect.snapshot.defer-until-reconnect`,{reason:n.ok?n.data?.status??`unsupported`:String(n.error),connectionStatus:r}),Se();return}if(e===`too_old`&&n.ok&&n.data?.status===`unsupported`){he();return}if(e===`error`&&(dC(t)||!n.ok&&dC(n.error))){ae.current?.({reason:`reconcile_failed`,operation:`terminal.snapshot`});return}F(n.ok?Error(`terminal.snapshot returned status ${n.data?.status??`unknown`}`):n.error)}})},U=e=>{le.current=`reconnect`,Me.current=`non_blocking_recovering`,Oe({kind:`loading`}),se.current=()=>{U(e)},xe(e,{onTooOld:()=>{we(`too_old`)},onError:e=>{we(`error`,e)}})},W=e=>{if(h){if(e===`reconnect`){U(ue.current);return}le.current=`initial`,Me.current=`blocking_rebuild`,se.current=()=>{W(`initial`)},H({onUnavailable:e=>{let t=Ce();if(de.current===`initial`||t===`disconnected`||t===`reconnecting`){XC(i,`snapshot.defer-until-reconnect`,{reason:e.ok?e.data?.status??`unsupported`:String(e.error),connectionStatus:t}),Se();return}if(XC(i,`snapshot.fallback`,{reason:e.ok?e.data?.status??`unsupported`:String(e.error)}),e.ok&&e.data?.status===`unsupported`){xe(0,{resetTerminalBeforeWrite:!0,onTooOld:()=>{he()}});return}xe(0)}})}};return ye.current=()=>{if(!de.current||typeof h?.getStatus==`function`&&h.getStatus()!==`connected`||V.current===`in-flight`)return;let e=de.current;de.current=null,W(e)},h&&(A.current=h.subscribe([x,C],(e,t,n)=>{if(e===x){let e=t;if(XC(i,`live.output`,{seq:n,replayCompleted:L.current,replayedSeq:R.current,size:e.bytes.byteLength,summary:YC(e.bytes)}),!L.current){I.current.push({bytes:e.bytes,seq:n});return}if(n<=R.current){XC(i,`live.drop-covered`,{seq:n,replayedSeq:R.current});return}let r=n-e.bytes.byteLength;if(r>R.current){XC(i,`live.gap`,{seq:n,chunkStartSeq:r,replayedSeq:R.current}),I.current.push({bytes:e.bytes,seq:n}),S(e=>({chunks:[],lastSeq:R.current})),Xe?Xe.notifyReason(`seq_gap`,i).catch(e=>{F(e)}):U(R.current);return}S(t=>n<=t.lastSeq?t:{chunks:[...t.chunks,e.bytes],lastSeq:n}),R.current=n}else e===C&&Ze(t.code)})),(async()=>{if(await y,M.current){if(Xe){await Xe.notifyReason(`initial_mount`,i);return}W(`initial`)}})().catch(e=>{F(e)}),()=>{if(e=!0,te.current=null,ne.current=null,re.current=null,ie.current=null,ae.current=null,B.current=null,oe.current=null,se.current=null,z.current=null,pe.current===n&&(pe.current+=1,fe.current=0),t&&=(t(),null),A.current&&=(A.current(),null),j.current!==null&&(cancelAnimationFrame(j.current),j.current=null),O.current){try{O.current.dispose()}catch(e){console.error(`Failed to dispose xterm instance:`,e)}O.current=null,k.current=null}typeof f==`function`?f():f?.dispose?.(),typeof d==`function`?d():d?.dispose?.(),s.dispose(),c.dispose()}},[Ne.kind,Ze,Qe,S,i,T,u,a,h]),(0,H.useEffect)(()=>{let e=D.current;if(!e||typeof document>`u`||u===`mobile`||!p.copyOnSelect)return;let t=e=>{e.pointerType===`touch`||e.pointerType===`pen`||(Se.current=e.pointerId)},n=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target;n instanceof Node&&e.contains(n)||Se.current===t.pointerId&&(Se.current=null)},r=e=>{Se.current===e.pointerId&&(Se.current=null)},i=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target,r=n instanceof Node&&e.contains(n),i=Se.current!==null&&Se.current===t.pointerId;Se.current=null,!(!r&&!i)&&it()};return e.addEventListener(`pointerdown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,r),()=>{Se.current=null,e.removeEventListener(`pointerdown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,r)}},[it,p.copyOnSelect,u]),(0,H.useEffect)(()=>{if(!(Xe||!h||typeof h.onStatus!=`function`))return h.onStatus(e=>{if(e===`disconnected`||e===`reconnecting`){V.current!==`idle`&&(de.current=le.current??`reconnect`);return}e!==`connected`||!de.current||ye.current?.()})},[Xe,h]),(0,H.useEffect)(()=>{let e=O.current;if(!e)return;let{chunks:t}=x,n=t.length;if(n>0){let r=Array(t.length),a=x.lastSeq;for(let e=t.length-1;e>=0;--e)r[e]=a,a-=t[e]?.byteLength??0;for(let n=0;n<t.length;n++){let a=t[n];if(!a)continue;let o=r[n]??x.lastSeq;XC(i,`write.live-buffer`,{index:n,lastSeq:x.lastSeq,summary:YC(a)}),e.write(a,()=>{ue.current=Math.max(ue.current,o)})}S(e=>ZC(e,n))}},[Ne.kind,x,S,i]),(0,H.useEffect)(()=>{let e=D.current,t=k.current;if(!e||!t)return;let n=new ResizeObserver(()=>{XC(i,`resize-observer`,{clientWidth:e.clientWidth,clientHeight:e.clientHeight}),P.current!==null&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,Qe()},150)});return n.observe(e),()=>{n.disconnect(),P.current!==null&&(clearTimeout(P.current),P.current=null)}},[Ne.kind,Qe,i]),(0,H.useEffect)(()=>{u!==`mobile`&&Ne.kind===`granted`&&je&&O.current&&O.current.focus()},[Ne.kind,je,u]);let pt=u===`mobile`&&je,mt=!je||ut||Ve!==`connected`,ht={paste:l(`terminal.mobile_input.paste`),upload:l(`terminal.mobile_input.upload`),shortcuts:l(`terminal.mobile_input.shortcuts`),ctrl:l(`terminal.mobile_input.ctrl`),ctrlArmed:l(`terminal.mobile_input.ctrl_armed`),ctrlLocked:l(`terminal.mobile_input.ctrl_locked`),shift:l(`terminal.mobile_input.shift`),shiftArmed:l(`terminal.mobile_input.shift_armed`),escape:l(`terminal.mobile_input.escape`),tab:l(`terminal.mobile_input.tab`),enter:l(`terminal.mobile_input.enter`),up:l(`terminal.mobile_input.up`),down:l(`terminal.mobile_input.down`),left:l(`terminal.mobile_input.left`),right:l(`terminal.mobile_input.right`)},gt=(0,H.useCallback)(async e=>{let t=Be.current;t&&tt(!1),await ot($S(e,{shift:t}))},[ot,tt]),_t=(0,H.useCallback)(()=>{et(eC(ze.current))},[et]),vt=(0,H.useCallback)(()=>{et(tC())},[et]),yt=(0,H.useCallback)(()=>{tt(!Be.current)},[tt]),bt=(0,H.useRef)(null),[xt,St]=(0,H.useState)(!1),Ct=(0,H.useRef)(null),wt=(0,H.useCallback)(async()=>{if(navigator.clipboard)try{await dt();return}catch(e){console.debug(`Clipboard API failed, showing paste dialog:`,e)}St(!0)},[dt]),Tt=(0,H.useCallback)(async()=>{let e=Ct.current;if(!e)return;let t=e.value;t&&(await lt(t),e.value=``),St(!1)},[lt]),Et=(0,H.useCallback)(()=>{let e=Ct.current;e&&(e.value=``),St(!1)},[]),Dt=(0,H.useCallback)(()=>{bt.current?.click()},[]),Ot=(0,H.useCallback)(()=>{if(ce.current=!0,Oe({kind:`loading`}),Xe){Xe.notifyReason(`foreground_resume`,i).catch(e=>{ie.current?.(e)});return}se.current?.()},[Xe,i]),kt=(0,H.useCallback)(async e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,t.length!==0&&await ft(t)},[ft]),At=De.kind===`loading`&&Me.current===`blocking_rebuild`,jt=u===`mobile`||Ne.kind===`granted`,Mt=Ve===`connected`,Nt=jt&&(Mt&&De.kind===`loading`&&At&&ke||De.kind===`closed`||De.kind===`unavailable`),Pt=Mt&&(De.kind===`recovery_check_failed`||De.kind===`retryable_failure`||De.kind===`failed`||De.kind===`unrecoverable_history`),Ft=``,It=``,Lt=`xterm-replay-overlay`,Rt=(De.kind===`closed`||De.kind===`unavailable`)&&T===`agent`&&!!r&&!!n,zt=``,Bt=``,Vt=null;return De.kind===`loading`?(Ft=l(`terminal.replay.loading_title`),It=l(`terminal.replay.loading_body`)):De.kind===`closed`?(Lt+=` xterm-replay-overlay--degraded`,It=t?l(`terminal.replay.closed_body_with_provider`,{provider:t}):l(`terminal.replay.closed_body`),Ft=l(`terminal.replay.closed_title`)):De.kind===`unavailable`?(Lt+=` xterm-replay-overlay--degraded`,It=t?l(`terminal.replay.unknown_body_with_provider`,{provider:t}):l(`terminal.replay.unknown_body`),Ft=l(`terminal.replay.unknown_title`)):De.kind===`recovery_check_failed`?(zt=l(`terminal.replay.reconcile_failed_title`),Bt=l(`terminal.replay.reconcile_failed_body`),Vt=(0,X.jsx)(Q,{onClick:()=>{Ot()},size:`sm`,variant:`ghost`,children:l(`terminal.replay.recheck_action`)})):De.kind===`retryable_failure`?(zt=l(`terminal.replay.retryable_title`),Bt=l(`terminal.replay.retryable_body`),Vt=(0,X.jsx)(Q,{onClick:()=>{Ot()},size:`sm`,variant:`ghost`,children:l(`terminal.replay.retry_action`)})):De.kind===`failed`?(zt=l(`terminal.replay.failed_title`),Bt=l(`terminal.replay.failed_body`)):De.kind===`unrecoverable_history`&&(zt=l(`terminal.replay.unrecoverable_title`),Bt=l(`terminal.replay.unrecoverable_body`)),(0,X.jsxs)(`div`,{className:`xterm-host-shell${pt?` xterm-host-shell--mobile-input`:``}`,children:[pt?(0,X.jsx)(YS,{ctrlMode:Fe,shiftArmed:Le,disabled:mt,labels:ht,onKeyPress:e=>{gt(e)},onCtrlTap:_t,onCtrlLongPress:vt,onShiftTap:yt,onPaste:wt,onUpload:Dt}):null,(0,X.jsx)(`input`,{ref:bt,type:`file`,accept:`image/*,video/*,audio/*,text/plain,.txt,.md,.json,.csv`,multiple:!0,hidden:!0,onChange:e=>{kt(e)}}),Pt?(0,X.jsx)(jh,{action:Vt,message:Bt,title:zt,tone:`warning`}):null,(0,X.jsx)(`div`,{ref:D,className:`xterm-host`,style:{width:`100%`,minHeight:0,overflow:`hidden`},onFocusCapture:()=>{je&&_e.current?.promote(`focused`)},onMouseDown:()=>{je&&_e.current?.promote(`focused`)}}),ut?(0,X.jsx)(Dh,{className:`terminal-upload-overlay`,open:!0,interactive:!1,mode:`status`,surfaceClassName:`xterm-replay-overlay__card`,children:(0,X.jsx)(`div`,{children:`Uploading…`})}):null,xt?(0,X.jsxs)(Dh,{ariaLabelledBy:`paste-dialog-title`,interactive:!0,mode:`dialog`,open:!0,onDismiss:Et,surfaceClassName:`paste-dialog`,children:[(0,X.jsx)(`h3`,{id:`paste-dialog-title`,className:`paste-dialog__title`,children:l(`terminal.paste_dialog_title`)}),(0,X.jsx)(`textarea`,{ref:Ct,className:`paste-dialog__textarea`,placeholder:l(`terminal.paste_dialog_placeholder`),autoFocus:!0}),(0,X.jsxs)(`div`,{className:`paste-dialog__actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--secondary`,onClick:Et,children:l(`common.cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--primary`,onClick:()=>{Tt()},children:l(`terminal.paste_dialog_submit`)})]})]}):null,u!==`mobile`&&Ne.kind===`queued`?(0,X.jsx)(SC,{state:`queued`,queuePosition:Ne.queuePosition}):null,Nt?(0,X.jsxs)(Dh,{className:Lt,interactive:Rt,mode:Rt?`dialog`:`status`,open:!0,surfaceClassName:`xterm-replay-overlay__card`,children:[De.kind===`loading`?(0,X.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,X.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:Ft}),It?(0,X.jsx)(`div`,{className:`xterm-replay-overlay__body`,children:It}):null,Rt?(0,X.jsxs)(`div`,{className:`xterm-replay-overlay__actions`,children:[(0,X.jsx)(Q,{className:`xterm-replay-overlay__action-btn`,onClick:()=>{r?.()},variant:`primary`,children:e??l(`action.confirm`)}),(0,X.jsx)(Q,{className:`xterm-replay-overlay__action-btn`,onClick:()=>{n?.()},variant:`secondary`,children:l(`action.close`)})]}):null]}):null]})}var cw=({paneId:e,dragState:t,sessionId:n,showHeaderActions:r=!0,showSupervisorInline:i=!0,terminalReadOnlyOverride:a,headerAccessory:o,onClose:s,onPaneDragStart:c,onPaneDrop:l,onSplitHorizontal:u,onSplitVertical:d})=>{let f=U(Up(n)),p=U(Op),m=W(Vp),h=Aa(),g=U(Ip(f?.workspaceId??`__workspace_empty__`)),_=U(to),v=W(to),y=Wx(),b=(0,H.useRef)(null),[x,S]=(0,H.useState)(!1);yS(f);let C=Mx(f?.workspaceId??`__workspace_empty__`),w=Yx(),{persistUiState:T}=Bv(f?.workspaceId??`__workspace_empty__`),E=Xg();if((0,H.useEffect)(()=>{if(_!==n)return;let e=b.current;e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),S(!0),v(null);let t=setTimeout(()=>S(!1),1400);return()=>clearTimeout(t)},[_,n,v]),!f)return null;let D=f.title?.trim()||pw(f.id),O=hw(f.providerId),k=mw(f.state),A=a??!gw(f.state),j=g?.uiState.activeSessionId===f.id,M=f.state===`running`,N=t?.isActiveDropTarget?t.hoverPlacement:null,P=async()=>{let e=await p(`session.create`,{workspaceId:f.workspaceId,providerId:f.providerId,themeBackground:h});if(!e.ok||!e.data)return;let t=e.data;m(e=>({...e,[t.id]:t})),C.replaceSession(f.id,t.id),E({workspaceId:f.workspaceId,sessionId:t.id}),T({activeSessionId:t.id});let n=await p(`session.remove`,{sessionId:f.id});n.ok||console.error(`Failed to remove closed session after relaunch:`,n.error?.message)},F=async()=>{if(s){await s();return}C.closeSessionPane(f.id),await w.closeSession(f.id,`draft`)};return(0,X.jsxs)(`div`,{ref:b,className:`session-card agent-pane${j?` session-card--active`:``}${x?` session-card--focus-pulse`:``}${M?` session-card--running`:``}${t?.isDragging?` session-card--dragging`:``}${t?.isActiveDropTarget?` session-card--drop-target`:``}`,"data-pane-id":e,"data-session-id":n,onClick:e=>{let t=e.target;t instanceof HTMLElement&&(t.closest(`button, a, input, textarea, select, [role="button"]`)||g?.uiState.activeSessionId!==f.id&&(E({workspaceId:f.workspaceId,sessionId:f.id}),T({activeSessionId:f.id})))},children:[N?(0,X.jsx)(`div`,{className:`pane-drop-overlay pane-drop-overlay--${N}`,children:N===`center`?(0,X.jsx)(`div`,{className:`pane-drop-overlay__center`,children:`Swap`}):null}):null,(0,X.jsx)(aS,{className:M?`session-header--running`:void 0,title:D,metaPlacement:`inline`,status:(0,X.jsx)(lg,{tone:uw(f.state),pulse:dw(f.state),className:`session-dot ${lw(f.state)}`}),meta:(0,X.jsxs)(`div`,{className:`session-title-row`,children:[(0,X.jsx)(_g,{color:`blue`,className:`session-provider-badge`,children:O}),(0,X.jsx)(_g,{color:fw(f.state),className:`session-state-badge`,caps:!1,children:k})]}),actions:r||o?(0,X.jsxs)(`div`,{className:`session-header-right`,children:[o?(0,X.jsx)(`div`,{className:`session-header-accessory`,children:o}):null,r?(0,X.jsxs)(`div`,{className:`session-header-actions`,children:[y?(0,X.jsx)(Ig,{content:`Drag pane`,children:(0,X.jsx)(Em,{"aria-label":`Drag pane`,className:`session-action-btn session-action-btn-drag`,icon:(0,X.jsx)(Ri,{size:13}),onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),t.pointerType!==`touch`&&e&&c?.({paneId:e,sessionId:f.id,title:D,providerLabel:O})},size:`sm`})}):null,(0,X.jsx)(Ig,{content:`Split horizontal`,children:(0,X.jsx)(Em,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,X.jsx)(ca,{size:13}),onClick:()=>u?.(),size:`sm`})}),(0,X.jsx)(Ig,{content:`Split vertical`,children:(0,X.jsx)(Em,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,X.jsx)(sa,{size:13}),onClick:()=>d?.(),size:`sm`})}),(0,X.jsx)(Ig,{content:`Close`,children:(0,X.jsx)(Em,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,X.jsx)(pa,{size:14}),onClick:()=>void s?.(),size:`sm`})})]}):null]}):null}),i&&f.capability===`full`&&f.state!==`draft`&&f.state!==`ended`?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(OS,{sessionId:f.id,workspaceId:f.workspaceId})}):null,(0,X.jsx)(`div`,{className:`session-terminal`,children:(0,X.jsx)(sw,{closedSessionProviderLabel:O,onClosedSessionClose:()=>{F()},onClosedSessionContinue:()=>{P()},terminalId:f.terminalId,workspaceId:f.workspaceId,readOnly:A,isActiveSession:j,terminalKind:`agent`})})]})};function lw(e){switch(e){case`starting`:return`session-dot-starting`;case`running`:return`session-dot-running`;case`ended`:return`session-dot-complete`;default:return`session-dot-idle`}}function uw(e){switch(e){case`starting`:return`warning`;case`running`:return`info`;case`ended`:return`success`;default:return`neutral`}}function dw(e){switch(e){case`starting`:case`running`:return!0;default:return!1}}function fw(e){switch(e){case`starting`:return`amber`;case`running`:return`green`;case`ended`:return`blue`;default:return`neutral`}}function pw(e){let t=e.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.replace(/[_-]/g,` `).toUpperCase()}function mw(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function hw(e){return e.replace(/\b\w/g,e=>e.toUpperCase())}function gw(e){return e===`running`||e===`idle`||e===`starting`}var _w={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},vw=({hydrateSessions:e=!0})=>{let t=Z(),n=Wx(),r=U(Bp),{workspaceId:i,sessions:a,paneLayout:o}=Xx(r,{disabled:!e}),s=Mx(i),c=Yx(),{insertSessionPaneAtEdge:l,moveSessionToDraft:u,swapPaneSessions:d}=s,f=Ev(o).length>0,p=a.length===0&&(f||o.type===`leaf`&&!o.sessionId&&o.id===`root`),m=(0,H.useCallback)(e=>{if(e.placement===`center`){if(e.targetType===`draft`){u(e.sourcePaneId,e.targetPaneId);return}d(e.sourcePaneId,e.targetPaneId);return}l(e.sourcePaneId,e.targetPaneId,e.placement)},[l,u,d]),h=zx({enabled:n,onDrop:m});return r?p?(0,X.jsx)(rS,{workspaceId:i,onReplaceWithSession:s.replaceWithSession}):(0,X.jsx)(`div`,{className:`agent-panes`,children:(0,X.jsx)(xw,{node:o,workspaceId:i,onCloseSession:s.closeSessionPane,onSplitDraftPane:s.splitDraftPane,onSplitSession:s.splitSessionPane,onCloseDraftPane:s.closeDraftPane,onAssignSession:s.assignSession,dragController:h,onPaneDrop:m,onReplaceWithSession:s.replaceWithSession,onCloseSessionCommand:c.closeSession})}):(0,X.jsx)(`div`,{className:`agent-panes-empty`,children:(0,X.jsx)(Sh,{style:{padding:0},title:(0,X.jsx)(`p`,{style:_w,children:t(`workspace.no_workspace`)})})})};function yw(e,t){let n=e.hoverTargetPaneId===t;return{isDragging:e.isDragging,isActiveDropTarget:n,hoverPlacement:n?e.hoverPlacement:null}}var bw=({dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u})=>{let d=(0,H.useRef)(null),f=yw(e.state,t.id);return(0,H.useEffect)(()=>{let n=d.current;if(n)return e.registerPane(t.id,{type:t.sessionId?`session`:`draft`,element:n}),()=>{e.registerPane(t.id,null)}},[e,t.id,t.sessionId]),t.sessionId?(0,X.jsx)(`div`,{ref:d,className:`agent-pane-leaf`,"data-pane-id":t.id,"data-pane-dragging":f.isDragging?`true`:void 0,"data-pane-drop-target":f.isActiveDropTarget?`true`:void 0,"data-pane-hover-placement":f.hoverPlacement??void 0,children:(0,X.jsx)(cw,{dragState:f,paneId:t.id,onPaneDragStart:e.startDrag,onPaneDrop:s,sessionId:t.sessionId,onClose:async()=>{a(t.sessionId),await o(t.sessionId,`draft`)},onSplitHorizontal:()=>u(t.sessionId,`horizontal`),onSplitVertical:()=>u(t.sessionId,`vertical`)})}):(0,X.jsx)(`div`,{ref:d,className:`agent-pane-leaf`,"data-pane-id":t.id,"data-pane-dragging":f.isDragging?`true`:void 0,"data-pane-drop-target":f.isActiveDropTarget?`true`:void 0,"data-pane-hover-placement":f.hoverPlacement??void 0,children:(0,X.jsx)(rS,{dragState:{isDragging:f.isDragging,isActiveDropTarget:f.isActiveDropTarget,hoverPlacement:f.hoverPlacement===`center`?`center`:null},workspaceId:n,paneId:t.id,onAssignSession:r,onClosePane:i,onPaneDrop:s,onReplaceWithSession:c,onSplitPane:l})})},xw=({dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u})=>{if(t.type===`leaf`)return(0,X.jsx)(bw,{dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u});let d=av(n,t.id)??t.ratio??.5;return(0,X.jsx)(iS,{splitId:t.id,direction:t.direction||`horizontal`,ratio:d,onRatioCommit:e=>ov(n,t.id,e),children:t.children?.map(t=>(0,X.jsx)(xw,{dragController:e,node:t,workspaceId:n,onAssignSession:r,onCloseDraftPane:i,onCloseSession:a,onCloseSessionCommand:o,onPaneDrop:s,onReplaceWithSession:c,onSplitDraftPane:l,onSplitSession:u},t.id))})},Sw=new Map,Cw=new Map,ww=0;function Tw(e){let t=Sw.get(e);if(t)return t;let n={pendingByPath:{},cancelledByPath:{}};return Sw.set(e,n),n}function Ew(e,t){Object.keys(t.pendingByPath).length===0&&Object.keys(t.cancelledByPath).length===0&&Sw.delete(e)}function Dw(e){let t=Cw.get(e);if(t)for(let e of t)e()}function Ow(e,t){let n=Tw(e),r=ww+1;return ww=r,delete n.cancelledByPath[t],n.pendingByPath[t]=r,Dw(e),r}function kw(e,t,n){let r=Sw.get(e);return r?r.cancelledByPath[t]===n?(delete r.cancelledByPath[t],Ew(e,r),!0):r.pendingByPath[t]!==n:!0}function Aw(e,t,n){let r=Sw.get(e);r&&(r.pendingByPath[t]===n&&delete r.pendingByPath[t],r.cancelledByPath[t]===n&&delete r.cancelledByPath[t],Ew(e,r),Dw(e))}function jw(e,t){let n=Sw.get(e);if(!n)return;let r=n.pendingByPath[t];r!==void 0&&(n.cancelledByPath[t]=r,delete n.pendingByPath[t],Dw(e))}function Mw(e){let t=Sw.get(e);if(t){for(let[e,n]of Object.entries(t.pendingByPath))t.cancelledByPath[e]=n;t.pendingByPath={},Dw(e)}}function Nw(e,t){return Sw.get(e)?.pendingByPath[t]!==void 0}function Pw(e){let t=Sw.get(e);return t!==void 0&&Object.keys(t.pendingByPath).length>0}function Fw(e,t){let n=Cw.get(e)??new Set;return n.add(t),Cw.set(e,n),()=>{n.delete(t),n.size===0&&Cw.delete(e)}}function Iw(e){return Object.keys(e).sort()}function Lw(e){let{openFiles:t,activeFilePath:n,pendingActiveFilePath:r=null,targetPath:i,closeAll:a=!1}=e,o=Iw(t),s=r&&!o.includes(r)?[...o,r].sort():o;return a?{orderedPaths:s,removedPaths:s,nextActiveFilePath:null,shouldExitEditor:!0}:!i||!s.includes(i)?{orderedPaths:s,removedPaths:[],nextActiveFilePath:n,shouldExitEditor:!1}:n===i?{orderedPaths:s,removedPaths:[i],nextActiveFilePath:null,shouldExitEditor:!0}:{orderedPaths:s,removedPaths:[i],nextActiveFilePath:n,shouldExitEditor:!1}}function Rw(e,t,n,r){return e?e.source===`commit`?n&&!r?.preserveCommitPreviewOnExit:n?!0:t.includes(e.path):!1}function zw(e,t){let n=U(Ip(e)),r=t?.workspaceRootPath??n?.path,[i,a]=Te(u_(e)),[o,s]=Te(l_(e)),[c,l]=Te(m_(e)),u=W(h_(e)),[,d]=Te(d_(e)),f=(0,H.useCallback)(t=>{let n=Lw({openFiles:o,activeFilePath:i,pendingActiveFilePath:i&&!(i in o)?i:null,targetPath:t});if(n.removedPaths.length!==0){s(e=>{let t={...e};for(let e of n.removedPaths)delete t[e];return t});for(let t of n.removedPaths){if(!(t in o)){jw(e,t);continue}let n=o[t];r&&n?.kind===`text`&&Ob.disposeFile(r,t)}a(n.nextActiveFilePath),(n.nextActiveFilePath!==i||n.shouldExitEditor)&&d(`edit`),c?.source===`file`&&Rw(c,n.removedPaths,n.shouldExitEditor)&&u(!0),l(e=>Rw(e,n.removedPaths,n.shouldExitEditor)?null:e)}},[i,c,o,a,l,u,d,s,e,r]);return{closeAll:(0,H.useCallback)(()=>{let t=Lw({openFiles:o,activeFilePath:i,pendingActiveFilePath:i&&!(i in o)?i:null,closeAll:!0});if(!(t.removedPaths.length===0&&i===null&&!Pw(e))){Mw(e),s({});for(let e of t.removedPaths){let t=o[e];r&&t?.kind===`text`&&Ob.disposeFile(r,e)}a(null),d(`edit`),c?.source===`file`&&Rw(c,t.removedPaths,t.shouldExitEditor,{preserveCommitPreviewOnExit:!0})&&u(!0),l(e=>Rw(e,t.removedPaths,t.shouldExitEditor,{preserveCommitPreviewOnExit:!0})?null:e)}},[i,c,o,a,l,u,d,s,e,r]),closePath:f}}async function Bw(e){if(!e.ok)throw Error(`preview_request_failed:${e.status}`);return e.json()}async function Vw(e){return Bw(await fetch(`/api/preview/session`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}))}async function Hw(e,t){return Bw(await fetch(`/api/preview/session/${e}`,{method:`PUT`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Uw(e){await Bw(await fetch(`/api/preview/session/${e}`,{method:`DELETE`,credentials:`include`}))}function Ww(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(0),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(0),_=(0,H.useRef)(e.content??``),v=(0,H.useRef)(e.content??``),y=e.enabled&&e.workspaceId&&e.filePath&&e.kind?`${e.workspaceId}:${e.kind}:${e.filePath}`:null;return _.current=e.content??``,(0,H.useEffect)(()=>{if(!y||!e.workspaceId||!e.filePath||!e.kind){n(null),i(null),o(0),c(null),u(!1),f(!1),m(null),v.current=_.current;return}let t=!1,r=null;return n(null),i(null),o(0),c(null),u(!0),f(!1),m(null),Vw({workspaceId:e.workspaceId,entryPath:e.filePath,kind:e.kind,content:_.current}).then(e=>{if(t){Uw(e.id).catch(()=>void 0);return}r=e.id,n(e.id),i(e.previewUrl),o(e.revision),c(y),v.current=_.current,m(null)}).catch(e=>{t||m(e instanceof Error?e.message:`preview_bootstrap_failed`)}).finally(()=>{t||u(!1)}),()=>{t=!0,r&&Uw(r).catch(()=>void 0)}},[e.filePath,e.kind,e.workspaceId,h,y]),(0,H.useEffect)(()=>{if(!y||!t||!r||s!==y||v.current===_.current)return;let n=window.setTimeout(()=>{f(!0),Hw(t,{content:_.current}).then(e=>{o(e.revision),v.current=_.current,m(null)}).catch(e=>{m(e instanceof Error?e.message:`preview_sync_failed`)}).finally(()=>{f(!1)})},e.debounceMs??300);return()=>{window.clearTimeout(n)}},[e.content,e.debounceMs,r,t,s,y]),{iframeSrc:r?`${r}?rev=${a}`:null,isBootstrapping:l,isSyncing:d,error:p,retry:()=>g(e=>e+1)}}function Gw(){let e=U(Bp),t=e?.path,n=U(Op),r=W(m_(e?.id??``)),i=W(h_(e?.id??``)),[a,o]=(0,H.useState)(()=>new Set),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=e?.id,[m,h]=Te(u_(p??``)),[g,_]=Te(l_(p??``)),[v,y]=Te(d_(p??``)),b=U(f_(p??``)),x=U(m_(p??``)),S=U(p_(p??``)),C=(0,H.useRef)(null),w=(0,H.useRef)(null),T=(0,H.useRef)(0),E=(0,H.useRef)(new Map),D=(0,H.useRef)(null),{closePath:O}=zw(p??``,{workspaceRootPath:t}),k=p?g[m??``]:void 0;(0,H.useEffect)(()=>{if(!m){C.current=null;return}if(!p||!k||C.current===m)return;C.current=m;let e=v===`diff`&&x?.source===`file`&&x.path===m?`diff`:s_(k);e!==v&&y(e)},[m,k,x,v,y,p]),(0,H.useEffect)(()=>{c(e=>e?.path===m?e:null),u(e=>e?.path===m?e:null),f(e=>e?.path===m?e:null)},[m]);let A=(0,H.useCallback)(e=>{if(e.length===0)return;let t=new Set(e);for(let e of t)E.current.delete(e);o(e=>{let n=!1,r=new Set(e);for(let e of t)r.delete(e)&&(n=!0);return n?r:e}),c(e=>e&&t.has(e.path)?null:e)},[]);(0,H.useEffect)(()=>{let e=Object.keys(g);if(D.current===null){D.current=e;return}let t=D.current.filter(e=>!(e in g));D.current=e,A(t)},[A,g]),(0,H.useEffect)(()=>{if(!p){w.current=null;return}let e=m&&!g[m]?m:null,t=w.current;t&&t!==e&&jw(p,t),w.current=e},[m,g,p]);let j=(0,H.useCallback)(async(e,r)=>{if(!p)return;let i=Ow(p,e);u(t=>t?.path===e?null:t);let a=await n(`file.read`,{workspaceId:p,path:e});if(kw(p,e,i))return;if(!a.ok||!a.data){Aw(p,e,i);let t=a.error?.message??`Failed to open file`;console.error(`Failed to open file:`,t),u({path:e,message:t});return}let o=a.data;if(r?.forceText&&o.kind===`image`&&o.isTextBacked){try{let n=await fetch(o.url,{credentials:`include`});if(kw(p,e,i))return;if(!n.ok){Aw(p,e,i);let t=`Failed to fetch text-backed image bytes: ${n.status}`;console.error(t),u({path:e,message:t});return}let r=await n.text();if(kw(p,e,i))return;let a={kind:`text`,path:e,content:r,savedContent:r,baseHash:``,isDirty:!1,viewingTextBackedImageAsText:!0};Aw(p,e,i),_(t=>({...t,[e]:a})),t&&Ob.updateFromDisk({workspaceRootPath:t,path:e,content:r}),u(t=>t?.path===e?null:t)}catch(t){Aw(p,e,i);let n=t instanceof Error?t.message:`Failed to fetch text-backed image bytes`;console.error(`Failed to fetch text-backed image bytes:`,t),u({path:e,message:n})}return}let s=o.kind===`text`?{kind:`text`,path:e,content:o.content,savedContent:o.content,baseHash:o.baseHash,isDirty:!1,externalState:void 0}:{kind:`image`,path:e,mime:o.mime,url:o.url,size:o.size,version:o.version,isTextBacked:o.isTextBacked,externalState:void 0};Aw(p,e,i),_(t=>({...t,[e]:s})),t&&o.kind===`text`&&Ob.updateFromDisk({workspaceRootPath:t,path:e,content:o.content}),f(t=>t?.path===e?null:t),u(t=>t?.path===e?null:t)},[n,_,p,t]),M=(0,H.useCallback)(async e=>{let t=await fetch(e,{credentials:`include`});if(!t.ok)throw Error(`Failed to fetch text-backed image bytes: ${t.status}`);return t.text()},[]),N=(0,H.useCallback)(async()=>{if(!p||!k||k.kind!==`text`)return;let{path:e,content:t,baseHash:r}=k;if(a.has(e))return;let i=++T.current;E.current.set(e,i),o(t=>new Set(t).add(e)),c(t=>t?.path===e?null:t);let s=await n(`file.write`,{workspaceId:p,path:e,content:t,baseHash:r||void 0});E.current.get(e)===i&&(s.ok&&s.data?(_(n=>{let r=n[e];return!r||r.kind!==`text`?n:{...n,[e]:{...r,savedContent:t,baseHash:s.data.newHash,isDirty:!1,externalState:void 0}}}),f(t=>t?.path===e?null:t)):c({path:e,message:s.error?.message??`Failed to save file`}),E.current.delete(e),o(t=>{let n=new Set(t);return n.delete(e),n}))},[k,n,a,_,p]),P=(0,H.useCallback)(e=>{!p||!k||k.kind!==`text`||_(t=>{let n=t[k.path];return!n||n.kind!==`text`?t:{...t,[k.path]:{...n,content:e,isDirty:e!==n.savedContent}}})},[k,_,p]);(0,H.useEffect)(()=>{!p||!m||g[m]||Nw(p,m)||j(m)},[m,j,g,p]),(0,H.useEffect)(()=>{if(!p||b<=0)return;let e=Object.entries(g);if(e.length===0)return;let r=!1;return(async()=>{for(let[i,a]of e){let e=await n(`file.read`,{workspaceId:p,path:i});if(r)return;if(!e.ok||!e.data){let t=e.error?.code===`not_found`;_(e=>{let n=e[i];return n?{...e,[i]:{...n,externalState:t?`deleted`:n.externalState}}:e}),t&&m===i&&f({path:i,status:`deleted`});continue}let o=e.data;if(a.kind===`text`&&o.kind===`text`){if(o.baseHash===a.baseHash)continue;if(a.isDirty){_(e=>{let t=e[i];return!t||t.kind!==`text`?e:{...e,[i]:{...t,externalState:`modified`}}}),m===i&&f({path:i,status:`modified`});continue}_(e=>({...e,[i]:{kind:`text`,path:i,content:o.content,savedContent:o.content,baseHash:o.baseHash,isDirty:!1,externalState:void 0,viewingTextBackedImageAsText:a.viewingTextBackedImageAsText}})),t&&Ob.updateFromDisk({workspaceRootPath:t,path:i,content:o.content}),m===i&&f(e=>e?.path===i?null:e);continue}if(a.kind===`text`&&a.viewingTextBackedImageAsText===!0&&o.kind===`image`&&o.isTextBacked){if(a.isDirty){_(e=>{let t=e[i];return!t||t.kind!==`text`?e:{...e,[i]:{...t,externalState:`modified`}}}),m===i&&f({path:i,status:`modified`});continue}try{let e=await M(o.url);if(r)return;_(t=>{let n=t[i];return!n||n.kind!==`text`?t:{...t,[i]:{...n,content:e,savedContent:e,baseHash:o.version,isDirty:!1,externalState:void 0,viewingTextBackedImageAsText:!0}}}),m===i&&f(e=>e?.path===i?null:e)}catch(e){console.error(`Failed to refresh text-backed image bytes:`,e),_(e=>{let t=e[i];return!t||t.kind!==`text`?e:{...e,[i]:{...t,externalState:`modified`}}}),m===i&&f({path:i,status:`modified`})}continue}if(a.kind===`image`&&o.kind===`image`){if(a.version===o.version&&a.size===o.size)continue;_(e=>({...e,[i]:{kind:`image`,path:i,mime:o.mime,url:o.url,size:o.size,version:o.version,isTextBacked:o.isTextBacked,externalState:void 0}})),m===i&&f(e=>e?.path===i?null:e);continue}_(e=>{let t={...e};return delete t[i],t}),m===i&&f({path:i,status:`modified`})}})(),()=>{r=!0}},[m,n,b,M,g,_,p,t]);let F=(0,H.useCallback)(()=>{if(x?.source===`commit`){if(r(null),k){let e=s_(k);e!==v&&y(e)}return}(k?.path||m)&&O(k?.path??m),c(null)},[m,O,k,x,v,r,y]),ee=(0,H.useCallback)(()=>{if(!p||!k)return;let e=k.path,n=k.kind===`image`;y(n?`edit`:`preview`),_(t=>{let n={...t};return delete n[e],n}),t&&k.kind===`text`&&Ob.disposeFile(t,e),j(e,n?{forceText:!0}:void 0)},[k,j,y,_,p,t]),I=(0,H.useCallback)(async()=>{if(!p||!k)return!1;let e=await n(`git.diff`,{workspaceId:p,path:k.path,staged:!1});if(!e.ok||!e.data)return!1;let t={path:k.path,diff:e.data.diff,staged:!1,source:`file`,...e.data.renderAs?{renderAs:e.data.renderAs}:{},...e.data.status?{status:e.data.status}:{},...e.data.originalContent===void 0?{}:{originalContent:e.data.originalContent},...e.data.modifiedContent===void 0?{}:{modifiedContent:e.data.modifiedContent},...e.data.originalRevision?{originalRevision:e.data.originalRevision}:{},...e.data.modifiedRevision?{modifiedRevision:e.data.modifiedRevision}:{}};return i(!1),r(t),y(`diff`),!0},[k,n,r,i,y,p]),L=k?.kind===`text`,R=k?.kind===`image`,z=R&&k.isTextBacked||L&&k.viewingTextBackedImageAsText===!0,te=!!k,ne=!!k&&(k?.kind===`text`||k?.kind===`image`&&k.isTextBacked),re=!!(m&&S&&[...S.staged,...S.modified,...S.deleted,...S.untracked].some(e=>e.path===m)),ie=!!(m&&re),ae=!!(v===`diff`&&m&&k?.kind===`text`&&k.isDirty),B=x&&(x.source===`file`&&x.path===m||x.source===`commit`)?x:null,oe=!!(L&&a.has(k.path)),se=!!(L&&k.isDirty&&!oe),ce=m&&l?.path===m?l.message:null,V=m&&d?.path===m?d.status:null,le=m&&s?.path===m?s.message:null,ue=k?.kind===`text`?a_(k.path):null;return{activeFilePath:m,activeDiffChange:B,activeExternalStatus:V,activeLoadError:ce,canSave:se,canDiff:ie,canEdit:ne,canPreview:te,currentFile:k,documentPreview:Ww({enabled:v===`preview`&&!!ue,workspaceId:p,filePath:k?.kind===`text`?k.path:null,content:k?.kind===`text`?k.content:void 0,kind:ue}),handleClose:F,handleContentChange:P,handleSave:N,hasUnsavedChangesOutsideDiff:ae,isImageFile:R,isSaving:oe,isSvgTextBacked:z,isTextFile:L,mode:v,openInDiffMode:I,saveError:le,setMode:e=>{y(e)},toggleSvgTextMode:ee,workspace:e,workspaceId:p}}var Kw=({src:e,title:t,isLoading:n,error:r,onRetry:i})=>{let a=Z(),[o,s]=(0,H.useState)(!1),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{s(!1)},[e]),(0,H.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{s(!0)};return e.addEventListener(`error`,t),()=>{e.removeEventListener(`error`,t)}},[e]),n?(0,X.jsx)(`div`,{className:`document-preview document-preview--loading`,children:a(`code_editor.preview_loading`)}):r||o||!e?(0,X.jsx)(`div`,{className:`document-preview`,children:(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:a(`code_editor.preview_unavailable`)}),action:i?(0,X.jsx)(`button`,{type:`button`,className:`code-mode-btn`,onClick:i,children:a(`code_editor.preview_retry`)}):null})}):(0,X.jsx)(`div`,{className:`document-preview`,children:(0,X.jsx)(`iframe`,{ref:c,className:`document-preview-frame`,title:`${t} preview`,src:e,sandbox:``})})};function qw(e){let t=e.split(`/`)[1]??e;return(t.split(`+`)[0]??t).replace(/^x-/,``).toUpperCase()}function Jw({label:e,url:t,alt:n}){return(0,X.jsxs)(`section`,{className:`image-diff-preview__pane`,children:[(0,X.jsx)(`header`,{className:`image-diff-preview__pane-header`,children:(0,X.jsx)(`span`,{children:e})}),(0,X.jsx)(`div`,{className:`image-diff-preview__canvas`,children:t?(0,X.jsx)(`img`,{className:`image-diff-preview__image`,src:t,alt:n,draggable:!1}):(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:`No image`})})})]})}var Yw=({path:e,mime:t,status:n,beforeUrl:r,afterUrl:i})=>(0,X.jsxs)(`div`,{className:`image-diff-preview`,"data-testid":`image-diff-preview`,children:[(0,X.jsxs)(`div`,{className:`image-diff-preview__meta`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{children:qw(t)}),(0,X.jsx)(`span`,{children:n})]}),(0,X.jsxs)(`div`,{className:`image-diff-preview__stack`,children:[(0,X.jsx)(Jw,{label:`Base`,url:r,alt:`${e} base`}),(0,X.jsx)(Jw,{label:`Current`,url:i,alt:`${e} current`})]})]});function Xw(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function Zw(e){let t=e.split(`/`)[1]??e;return(t.split(`+`)[0]??t).replace(/^x-/,``).toUpperCase()}var Qw=({url:e,version:t,mime:n,sizeBytes:r,alt:i})=>{let[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=`${e}${e.includes(`?`)?`&`:`?`}v=${t}`;return(0,H.useEffect)(()=>{o(null),c(!1)},[e,t]),(0,X.jsxs)(`div`,{className:`image-preview`,children:[(0,X.jsx)(`div`,{className:`image-preview-canvas`,children:s?(0,X.jsx)(Sh,{className:`git-diff-empty`,description:(0,X.jsx)(`p`,{className:`git-diff-empty-body`,children:`The image could not be loaded. The file may have been moved or is larger than the browser allows.`}),title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:`Preview unavailable`})}):(0,X.jsx)(`img`,{className:`image-preview-img`,src:l,alt:i,draggable:!1,onLoad:e=>{let t=e.currentTarget;o({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>c(!0)})}),(0,X.jsxs)(`div`,{className:`image-preview-meta`,children:[(0,X.jsx)(`span`,{className:`image-preview-type`,children:Zw(n)}),a&&(0,X.jsxs)(`span`,{className:`image-preview-dim`,children:[a.w,` × `,a.h]}),(0,X.jsx)(`span`,{className:`image-preview-size`,children:Xw(r)})]})]})},$w=globalThis;$w.MonacoEnvironment??={getWorker(e,t){return t===`json`?new l:t===`css`||t===`scss`||t===`less`?new r:t===`html`||t===`handlebars`||t===`razor`?new u:t===`typescript`||t===`javascript`?new c:new o}};var eT=({originalContent:e,modifiedContent:t,filePath:n,readOnly:r=!0})=>{let i=U(Xa),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=Oa(i),u=`coder-studio-workspace-${l.id}`,d=Sa(l.monaco);return(0,H.useEffect)(()=>{p.defineTheme(u,d)},[u,d]),(0,H.useEffect)(()=>{if(!(!a.current||o.current))return o.current=p.createDiffEditor(a.current,{automaticLayout:!0,fontFamily:`JetBrains Mono, monospace`,fontSize:13,minimap:{enabled:!1},originalEditable:!1,readOnly:r,renderSideBySide:!1,scrollBeyondLastLine:!1,theme:u}),()=>{o.current?.dispose(),o.current=null,s.current?.dispose(),c.current?.dispose(),s.current=null,c.current=null}},[u,r]),(0,H.useEffect)(()=>{let r=o.current;if(!r)return;s.current?.dispose(),c.current?.dispose();let i=tT(n);s.current=p.createModel(e,i),c.current=p.createModel(t,i),r.setModel({original:s.current,modified:c.current})},[n,t,e]),(0,H.useEffect)(()=>{p.setTheme(u)},[u]),(0,X.jsx)(`div`,{ref:a,className:`monaco-host monaco-diff-host`,"data-testid":`monaco-diff-host`})};function tT(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,go:`go`,rs:`rust`,java:`java`,cpp:`cpp`,c:`c`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[e.split(`.`).pop()?.toLowerCase()||``]||`plaintext`}var nT=({state:e,chrome:t=`full`})=>{let n=Z(),{activeFilePath:r,activeDiffChange:i,activeExternalStatus:a,activeLoadError:o,currentFile:s,documentPreview:c,handleClose:l,handleContentChange:u,handleSave:d,hasUnsavedChangesOutsideDiff:f,mode:p,openInDiffMode:m,saveError:h,workspace:g}=e;if(!g)return(0,X.jsx)(`div`,{className:`workspace-git-view`,children:(0,X.jsx)(`div`,{className:`code-editor workspace-git-editor`,children:(0,X.jsx)(`div`,{className:`code-editor-body`,children:(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`workspace.no_workspace`)})})})})});let _=s?.kind===`text`?s:null,v=s?.kind===`image`?s:null,y=t===`full`,b=i?.source===`commit`,x=!b&&_?.isDirty?(0,X.jsx)(`span`,{className:`dirty-indicator`,children:`*`}):null,S=(p===`diff`||b)&&!!i&&(i?.renderAs===`text`||i?.source===`commit`),C=p===`diff`&&!!i&&i?.renderAs===`image`,w=p===`preview`&&_!==null&&a_(_.path)!==null,T=b?i.title??i.path:s?s.path:i?.title??r??n(`file.title`);return(0,X.jsx)(`div`,{className:`workspace-git-view`,children:(0,X.jsxs)(`div`,{className:`code-editor workspace-git-editor`,children:[y?(0,X.jsxs)(`div`,{className:`code-editor-header editor-surface__header`,children:[(0,X.jsx)(`span`,{className:`code-file-path`,children:s&&!b?(0,X.jsxs)(X.Fragment,{children:[T,x]}):T}),b?(0,X.jsx)(`div`,{className:`editor-surface__toolbar`,role:`toolbar`,"aria-label":`Editor actions`,children:(0,X.jsx)(Ig,{content:n(`action.close`),children:(0,X.jsx)(Em,{"aria-label":n(`action.close`),className:`code-mode-btn editor-surface__action-btn`,icon:(0,X.jsx)(pa,{size:12}),onClick:l,size:`sm`})})}):(0,X.jsx)(rT,{state:e})]}):null,!b&&h?(0,X.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,X.jsx)($,{semantic:`state.error`,size:14}),(0,X.jsx)(`span`,{children:h})]}):null,!b&&a?(0,X.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,X.jsx)($,{semantic:a===`deleted`?`state.fileDeleted`:`state.fileModified`,size:14}),(0,X.jsx)(`span`,{children:n(a===`deleted`?`code_editor.deleted_on_disk`:`code_editor.modified_on_disk`)})]}):null,!b&&f?(0,X.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,X.jsx)($,{semantic:`state.warning`,size:14}),(0,X.jsx)(`span`,{children:n(`code_editor.diff_saved_only`)})]}):null,(0,X.jsx)(`div`,{className:`code-editor-body`,children:S?(0,X.jsx)(eT,{filePath:i?.path??s?.path??`diff.patch`,originalContent:i?.originalContent??``,modifiedContent:i?.modifiedContent??i?.diff??``}):C&&v?(0,X.jsx)(Yw,{path:v.path,mime:v.mime,status:i?.status??`modified`,beforeUrl:i?.originalRevision?`${v.url}&revision=${i.originalRevision}`:void 0,afterUrl:i?.status===`deleted`?void 0:i?.modifiedRevision===`WORKTREE`?v.url:i?.modifiedRevision?`${v.url}&revision=${i.modifiedRevision}`:v.url}):w&&_?(0,X.jsx)(Kw,{src:c.iframeSrc,title:_.path,isLoading:c.isBootstrapping,error:c.error,onRetry:c.retry}):_?(0,X.jsx)(Fb,{workspaceId:g.id,workspaceRootPath:g.path,filePath:_.path,content:_.content,onContentChange:u,onSave:d,readOnly:p===`preview`}):v?(0,X.jsx)(Qw,{url:v.url,version:v.version,mime:v.mime,sizeBytes:v.size,alt:v.path}):o?(0,X.jsx)(Sh,{className:`git-diff-empty`,description:(0,X.jsx)(`p`,{className:`git-diff-empty-body`,children:o}),role:`alert`,title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`code_editor.open_failed_title`)})}):r?(0,X.jsx)(Sh,{className:`git-diff-empty`,title:(0,X.jsxs)(`p`,{className:`git-diff-empty-title`,children:[n(`status.connecting`),`…`]})}):(0,X.jsx)(Sh,{className:`git-diff-empty`,description:(0,X.jsx)(`p`,{className:`git-diff-empty-body`,children:n(`code_editor.empty_hint`)}),title:(0,X.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`file.title`)})})})]})})},rT=({state:e})=>{let t=Z(),{canDiff:n,canEdit:r,canPreview:i,canSave:a,handleClose:o,handleSave:s,isImageFile:c,isSvgTextBacked:l,isSaving:u,mode:d,openInDiffMode:f,setMode:p,toggleSvgTextMode:m}=e,h=t(u?`code_editor.saving`:`action.save_file`);return(0,X.jsxs)(`div`,{className:`editor-surface__toolbar`,role:`toolbar`,"aria-label":`Editor actions`,children:[n?(0,X.jsx)(`button`,{type:`button`,className:`code-mode-btn editor-surface__mode-btn${d===`diff`?` active`:``}`,onClick:()=>void f(),"aria-pressed":d===`diff`,"aria-label":t(`code_editor.mode_diff`),children:(0,X.jsx)(`span`,{children:t(`code_editor.mode_diff`)})}):null,i?(0,X.jsxs)(`button`,{type:`button`,className:`code-mode-btn editor-surface__mode-btn${d===`preview`?` active`:``}`,onClick:()=>{if(l&&!c){m();return}p(`preview`)},"aria-pressed":d===`preview`,"aria-label":t(`code_editor.mode_preview`),children:[c?(0,X.jsx)(Bi,{size:12}):(0,X.jsx)(ki,{size:12}),(0,X.jsx)(`span`,{children:t(`code_editor.mode_preview`)})]}):null,r?(0,X.jsxs)(`button`,{type:`button`,className:`code-mode-btn editor-surface__mode-btn${d===`edit`?` active`:``}`,onClick:()=>{if(l&&c){m();return}p(`edit`)},"aria-pressed":d===`edit`,"aria-label":t(`code_editor.mode_edit`),children:[(0,X.jsx)(ki,{size:12}),(0,X.jsx)(`span`,{children:t(`code_editor.mode_edit`)})]}):null,(0,X.jsx)(Ig,{content:h,disabled:!a,children:(0,X.jsxs)(`button`,{type:`button`,className:`code-mode-btn editor-surface__action-btn`,onClick:s,disabled:!a,"aria-label":h,children:[(0,X.jsx)(ra,{size:12}),(0,X.jsx)(`span`,{children:h})]})}),(0,X.jsx)(Ig,{content:t(`action.close`),children:(0,X.jsx)(Em,{"aria-label":t(`action.close`),className:`code-mode-btn editor-surface__action-btn`,icon:(0,X.jsx)(pa,{size:12}),onClick:o,size:`sm`})})]})},iT=({state:e,variant:t=`full`})=>{let n=Z(),{activeFilePath:r,activeDiffChange:i,canDiff:a,canEdit:o,canPreview:s,canSave:c,handleClose:l,handleSave:u,isImageFile:d,isSaving:f,isSvgTextBacked:p,mode:m,openInDiffMode:h,setMode:g,toggleSvgTextMode:_}=e,v=n(f?`code_editor.saving`:`action.save_file`),y=n(d?`code_editor.edit_as_text`:`code_editor.preview_as_image`),b=i?.source===`commit`;return t===`mobile`?b?(0,X.jsx)(`div`,{className:`mobile-sheet__header-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:l,"aria-label":n(`action.close`),children:n(`action.close`)})}):(0,X.jsxs)(`div`,{className:`mobile-sheet__header-actions`,children:[a?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action mobile-sheet__action--mode${m===`diff`?` active`:``}`,onClick:()=>void h(),"aria-pressed":m===`diff`,"aria-label":n(`code_editor.mode_diff`),children:n(`code_editor.mode_diff`)}):null,s?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action mobile-sheet__action--mode${m===`preview`?` active`:``}`,onClick:()=>{if(p&&!d){_();return}g(`preview`)},"aria-pressed":m===`preview`,"aria-label":n(`code_editor.mode_preview`),children:n(`code_editor.mode_preview`)}):null,o?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action mobile-sheet__action--mode${m===`edit`?` active`:``}`,onClick:()=>{if(p&&d){_();return}g(`edit`)},"aria-pressed":m===`edit`,"aria-label":n(`code_editor.mode_edit`),children:n(`code_editor.mode_edit`)}):null,p?(0,X.jsx)(Ig,{content:y,children:(0,X.jsx)(Em,{"aria-label":y,className:`mobile-sheet__action mobile-sheet__action--icon`,icon:d?(0,X.jsx)(ki,{size:16}):(0,X.jsx)(Bi,{size:16}),onClick:_})}):null,(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:u,disabled:!c,"aria-label":v,children:v}),r||i?.source===`commit`?(0,X.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:l,"aria-label":n(`action.close`),children:n(`action.close`)}):null]}):(0,X.jsx)(rT,{state:e})},aT=({state:e,chrome:t=`full`})=>(0,X.jsx)(nT,{state:e,chrome:t}),oT=({chrome:e=`full`,editorState:t})=>(0,X.jsx)(aT,{state:t??Gw(),chrome:e});function sT(e){return async(t,n,r)=>{try{return{ok:!0,data:await e(t,n,r)}}catch(e){return{ok:!1,error:{code:`command_error`,message:e instanceof Error?e.message:String(e)}}}}}function cT(e){return e===`foreground_resume`?`foreground_resume`:e===`network_online`?`network_online`:null}function lT(e){let t=new Map,n=new Map,r=!1,i=!1,a=e=>{let t=n.get(e);if(t)return t;let r={idleResolvers:[],queued:null,running:null};return n.set(e,r),r},o=e=>{switch(e){case`initial_mount`:return 1;case`foreground_resume`:case`network_online`:return 2;case`socket_reconnected`:return 3;case`continuity_lost`:case`seq_gap`:return 4;default:return 0}},s=(e,t)=>{if(!e)return t;let n=o(e.reason),r=o(t.reason);return r>n||r===n?t:e},c=()=>{let t=e.wsClient.getStatus();return t===`connecting`||t===`disconnected`||t===`reconnecting`},l=e=>{if(c())return!0;let t=e instanceof Error?e.message:typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?String(e.message):``;return t.includes(`WebSocket disconnected`)||t.includes(`WebSocket not connected`)||t.includes(`Connection probe timeout`)||t.includes(`Command timeout: connection.probe`)},u=e=>{r=!0,!c()&&p(e,{reason:`socket_reconnected`,skipProbe:!0})},d=(e,t,n)=>{e.setUiMode(`error`,{reason:`reconcile_failed`,operation:t,errorCode:n})},f=e=>{let t=e.idleResolvers;e.idleResolvers=[];for(let e of t)e()},p=(e,t)=>{if(i)return Promise.resolve();let n=a(e);return n.queued=s(n.queued,t),n.running||=(async()=>{try{for(;;){let t=n.queued;if(n.queued=null,!t)return;await y(e,t)}}finally{if(n.running=null,n.queued){p(e,n.queued);return}f(n)}})(),new Promise(e=>{n.idleResolvers.push(e)})},m=async(t,n,r,a)=>{if(i)return;n.setUiMode(`blocking_rebuild`);let o=await e.sendCommand(`terminal.snapshot`,{terminalId:t},{timeoutMs:sC});if(!i){if(!o.ok||!o.data||o.data.status!==`ok`){if(!o.ok&&l(o.error)){u(t);return}if(!o.ok&&dC(o.error)){if(a?.controlPlaneFailureMeansRecoveryFailure){n.setUiMode(`error`);return}d(n,`terminal.snapshot`,o.error?.code);return}if(!o.data){if(a?.controlPlaneFailureMeansRecoveryFailure){n.setUiMode(`error`);return}d(n,`terminal.snapshot`);return}n.setUiMode(`error`);return}n.applySnapshot?await n.applySnapshot(o.data):await e.applySnapshot(t,o.data),await h(n,r),n.setUiMode(r?`closed`:`silent`)}},h=async(e,t)=>{t&&await e.markClosed?.(t)},g=async n=>{if(i)return;let r=t.get(n.terminalId);if(r){if(n.action===`noop`){r.completeRecovery&&await r.completeRecovery(n.headSeq),r.setUiMode(`silent`);return}if(n.action===`closed`){r.completeRecovery?await r.completeRecovery(n.headSeq,{exitCode:n.exitCode}):await h(r,{exitCode:n.exitCode}),r.setUiMode(`closed`);return}if(n.action===`unrecoverable`){r.setUiMode(`error`,{reason:n.reason});return}if(n.action===`replay`){r.setUiMode(`non_blocking_recovering`);let t=await e.sendCommand(`terminal.replay`,{terminalId:n.terminalId,lastSeq:n.fromSeq},{timeoutMs:sC});if(!t.ok){if(l(t.error)){u(n.terminalId);return}if(dC(t.error)){d(r,`terminal.replay`,t.error?.code);return}await m(n.terminalId,r,n.closed,{controlPlaneFailureMeansRecoveryFailure:!0});return}if(!t.data){d(r,`terminal.replay`);return}if(t.data.status===`too_old`){await m(n.terminalId,r,n.closed);return}if(t.data.status===`unknown`){r.setUiMode(`error`,{reason:`unknown_terminal`});return}if(t.data.status!==`ok`){d(r,`terminal.replay`);return}r.applyReplay?await r.applyReplay(t.data):await e.applyReplay(n.terminalId,t.data),await h(r,n.closed),r.setUiMode(n.closed?`closed`:`silent`);return}await m(n.terminalId,r,n.closed)}},_=async(n,a)=>{if(i)return;let o=Array.from(t.values()).filter(e=>a?e.terminalId===a:!0);if(a&&o.length===0)return;let s=await e.sendCommand(`recovery.reconcile`,{reason:n,terminals:o.map(e=>({terminalId:e.terminalId,renderedSeq:e.getRenderedSeq()}))});if(!i){if(!s.ok||!s.data||!Array.isArray(s.data.terminals)){if(l(s.ok?void 0:s.error)){r=!0,a&&u(a);return}for(let e of o)d(e,`recovery.reconcile`,s.ok?void 0:s.error?.code);return}for(let e of s.data.terminals)await g(e)}},v=async t=>{if(i)return!1;let n=cT(t);if(!n)return!0;if(e.wsClient.getStatus()!==`connected`)return!1;try{return await e.wsClient.probeConnection(n),!0}catch(e){if(l(e))return r=!0,!1;throw e}},y=async(e,n)=>{if(i)return;let a=t.get(e);if(a)try{if(!n.skipProbe&&!await v(n.reason)){r=!0;return}await _(n.reason,e)}catch(t){if(l(t)){u(e);return}d(a,`recovery.reconcile`)}},b=e=>{if(!i){if(e===`disconnected`||e===`reconnecting`){r=!0;return}if(e===`connected`&&r){r=!1;for(let e of t.keys())p(e,{reason:`socket_reconnected`,skipProbe:!0})}}},x=e.subscribeToStatus===!1?()=>{}:e.wsClient.onStatus(b),S=e.subscribeToContinuityLost===!1?()=>{}:e.wsClient.subscribe([`workspace.*`],(e,t)=>{i||e.match(/^workspace\.([^.]+)\.terminal\.([^.]+)\.continuity_lost$/)&&p(t.terminalId,{reason:`continuity_lost`,skipProbe:!0})});return{registerTerminal(e){return i?()=>{}:(t.set(e.terminalId,e),()=>{t.delete(e.terminalId),n.delete(e.terminalId)})},async notifyReason(e,n){if(!i){if(n){await p(n,{reason:e,skipProbe:!1});return}if(!await v(e)){r=!0;return}if(t.size===0){await _(e);return}await Promise.all(Array.from(t.keys(),t=>p(t,{reason:e,skipProbe:!0})))}},handleConnectionStatus:b,dispose(){if(!i){i=!0,x(),S(),r=!1,t.clear();for(let e of n.values())e.queued=null,f(e);n.clear()}}}}function uT(e){return{id:e.id,workspaceId:e.workspaceId,kind:e.kind,alive:e.alive,exitCode:e.exitCode,title:e.title}}function dT(e){let t=Z(),n=U(Op),r=W(sy),i=ve(),a=Aa();return{async createShellTerminal(o={}){if(!e)return r({kind:`warning`,title:t(`terminal.create_unavailable_title`),body:t(`terminal.create_unavailable_body`)}),null;try{let s=await n(`terminal.create`,{workspaceId:e,cwdPath:o.cwdPath,themeBackground:a});if(!s.ok||!s.data)return r({kind:`error`,title:t(`terminal.create_failed_title`),body:s.error?.message??t(`terminal.create_failed_body`)}),null;let c=s.data;return i.set(jS(c.id),uT(c)),i.set(MS(e),e=>e.includes(c.id)?e:[...e,c.id]),i.set(NS(e),c.id),c}catch(e){return r({kind:`error`,title:t(`terminal.create_failed_title`),body:e instanceof Error?e.message:t(`terminal.create_failed_body`)}),null}}}}var fT=`__terminal_panel_empty__`,pT=`__terminal_panel_empty_workspace__`;function mT(e,t){let n=new Set(t),r=[...t];for(let t of e)n.has(t)||(n.add(t),r.push(t));return r}function hT(e){return{id:e.id,workspaceId:e.workspaceId,kind:e.kind,alive:e.alive,exitCode:e.exitCode,title:e.title}}function gT(){let e=Z(),t=U(zp),n=U(Op),r=U(bp),i=W(sy),a=ve(),o=t??pT,[s,c]=Te(MS(o)),[l,u]=Te(NS(o)),{createShellTerminal:d}=dT(t),f=(0,H.useRef)(null),p=U(jS(l??fT)),m=l?p:null;(0,H.useEffect)(()=>{if(!t){c([]),u(null);return}let r=!1;return c([]),u(null),n(`terminal.list`,{workspaceId:t}).then(t=>{if(r)return;if(!t.ok||!t.data){console.error(`Failed to fetch terminals:`,t.error?.message),i({kind:`error`,title:e(`terminal.load_failed_title`),body:t.error?.message??e(`terminal.load_failed_body`)});return}let n=t.data.filter(e=>e.kind===`shell`),o=n.map(e=>e.id);for(let e of n)a.set(jS(e.id),hT(e));c(e=>mT(e,o)),u(e=>e??o[0]??null)}).catch(t=>{r||(console.error(`Failed to fetch terminals:`,t),i({kind:`error`,title:e(`terminal.load_failed_title`),body:t instanceof Error?t.message:e(`terminal.load_failed_body`)}))}),()=>{r=!0}},[t,n,i,a,e]),(0,H.useEffect)(()=>{if(!r||!t)return;let e=dp.terminalsAll(t);return f.current=r.subscribe([e],(e,t,n)=>{let r=e.split(`.`);if(r.length<5)return;let i=r[3],o=r[4];if(o===`created`){let e=t;if(e.kind!==`shell`)return;c(t=>t.includes(e.id)?t:[...t,e.id]),u(e.id);return}if(o!==`output`)return;let s=a.get(jS(i));if(!s||s.kind!==`shell`)return;let l=t,d=AS(i),f=a.get(d);n<=f.lastSeq||a.set(d,{chunks:[...f.chunks,l.bytes],lastSeq:n})}),()=>{f.current?.(),f.current=null}},[t,a,r]);let h=(0,H.useCallback)(async()=>{await d()},[d]);return{activeTerminalId:l,activeTerminalMeta:m,activeWorkspaceId:t,handleCloseTerminal:(0,H.useCallback)(async e=>{(await n(`terminal.close`,{terminalId:e})).ok&&c(t=>{let n=t.filter(t=>t!==e);return u(t=>t===e?n[0]??null:t),n})},[n,u,c]),handleCreateTerminal:h,handleSwitchTerminal:(0,H.useCallback)(e=>{u(e)},[u]),hasTerminals:s.length>0,terminalIds:s}}function _T(e,t,n){let r=e?.title?.trim(),i=vT(r);return!r||yT(r,n)?`${i??n} — ${t+1}`:i?`${i} — ${t+1}`:r}function vT(e){if(!e)return null;let t=e.split(/[\\/]/).pop()?.trim();if(!t)return null;let n=t.toLowerCase().replace(/\.exe$/,``);return new Set([`bash`,`cmd`,`csh`,`fish`,`ksh`,`powershell`,`pwsh`,`sh`,`tcsh`,`zsh`]).has(n)?n:null}function yT(e,t){let n=e.toLowerCase();return n===t.trim().toLowerCase()||n===`shell terminal`||n===`shell 终端`}function bT({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=Z(),o=_T(U(jS(e)),t,a(`terminal.shell`));return(0,X.jsxs)(`div`,{className:`terminal-selector-item ${n?`terminal-selector-item-active`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`terminal-selector-item-trigger`,onClick:r,children:(0,X.jsx)(`span`,{className:`terminal-selector-item-title`,children:o})}),(0,X.jsx)(Em,{"aria-label":a(`action.close`),className:`terminal-selector-item-close`,icon:(0,X.jsx)(pa,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function xT({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=Z(),o=_T(U(jS(e)),t,a(`terminal.shell`));return(0,X.jsxs)(`div`,{className:`terminal-tab-shell ${n?`active`:``}`,role:`presentation`,children:[(0,X.jsx)(Bh,{className:`terminal-tab ${n?`terminal-tab-active`:``}`,onClick:r,value:e,children:(0,X.jsx)(`span`,{className:`terminal-tab-title`,children:o})}),(0,X.jsx)(Em,{"aria-label":a(`action.close`),className:`terminal-tab-close`,icon:(0,X.jsx)(pa,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function ST({chrome:e=`default`,onMobileHeaderActionsChange:t}){let n=Z(),r=ve(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),{activeTerminalId:c,activeTerminalMeta:l,activeWorkspaceId:u,handleCloseTerminal:d,handleCreateTerminal:f,handleSwitchTerminal:p,hasTerminals:m,terminalIds:h}=gT(),g=c?h.indexOf(c):0,_=_T(l,g>=0?g:0,n(`terminal.shell`)),v=c??h[0]??``,y=e===`mobile-fullscreen`,b=m&&(!y||h.length>1),x=h.length>1&&!y,S=h.map((e,t)=>({value:e,label:_T(r.get(jS(e)),t,n(`terminal.shell`))}));return(0,H.useEffect)(()=>{(!b||h.length<=1)&&(a(!1),s(!1))},[b,h.length]),(0,H.useEffect)(()=>{if(t)return()=>{t(null)}},[t]),(0,H.useEffect)(()=>{t&&t(null)},[t]),(0,X.jsxs)(`div`,{className:`bottom-terminal${y?` bottom-terminal--mobile-fullscreen`:``}`,children:[(0,X.jsx)(`div`,{className:`terminal-toolbar`,children:y?(0,X.jsxs)(`div`,{className:`terminal-toolbar-mobile-row`,children:[m?(0,X.jsxs)(`div`,{className:`terminal-selector`,children:[b?(0,X.jsx)(tg,{mobile:!0,"aria-label":n(`terminal.selector.switch`),"aria-expanded":o,className:`terminal-selector-btn`,includeValueInAriaLabel:!1,options:S,value:v,valueLabel:_,onClick:e=>{o&&(e.preventDefault(),s(!1))},onOpen:()=>s(!0)}):(0,X.jsx)(`div`,{className:`terminal-selector-btn terminal-selector-btn--static`,"aria-label":_,children:(0,X.jsx)(`span`,{children:_})}),b&&o?(0,X.jsx)(Jh,{className:`mobile-select-sheet--command`,title:n(`terminal.selector.title`),sections:[{kind:`options`,id:`terminals`,items:S.map((e,t)=>({id:e.value,label:e.label,meta:e.value===c?n(`terminal.selector.current`):n(`terminal.selector.indexed`,{index:t+1})}))}],selectedId:c,onSelect:p,onClose:()=>s(!1)}):null]}):(0,X.jsx)(`div`,{className:`terminal-toolbar-mobile-placeholder`,"aria-hidden":`true`}),m&&c?(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.close`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.close_terminal`),icon:(0,X.jsx)(pa,{size:14}),onClick:()=>{a(!1),s(!1),d(c)},size:`sm`})})}):null,y?(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.open`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.new_terminal`),icon:(0,X.jsx)($,{semantic:`terminal.action.new`,size:14}),onClick:f,size:`sm`})})}):null]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`terminal-toolbar-left`,children:(0,X.jsxs)(`div`,{className:`terminal-title-stack`,children:[(0,X.jsx)(`span`,{className:`terminal-kicker`,children:n(`terminal.kicker`)}),l?(0,X.jsx)(`span`,{className:`terminal-title`,children:_}):null]})}),(0,X.jsxs)(`div`,{className:`terminal-toolbar-right`,children:[m&&(0,X.jsxs)(X.Fragment,{children:[b?(0,X.jsx)(`div`,{className:`terminal-selector`,children:h.length>1?(0,X.jsx)(Gm,{content:(0,X.jsx)(X.Fragment,{children:h.map((e,t)=>(0,X.jsx)(bT,{id:e,index:t,isActive:e===c,onSelect:()=>{p(e),a(!1)},onClose:()=>{a(!1),d(e)}},e))}),contentClassName:`terminal-selector-dropdown`,forceMode:`desktop`,open:i,placement:`bottom-end`,title:n(`terminal.selector.title`),onOpenChange:a,children:(0,X.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":_,children:[(0,X.jsx)(`span`,{children:_}),(0,X.jsx)(_i,{size:12})]})}):(0,X.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":_,children:[(0,X.jsx)(`span`,{children:_}),(0,X.jsx)(_i,{size:12})]})}):null,(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.close`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.close_terminal`),icon:(0,X.jsx)(pa,{size:14}),onClick:()=>{c&&(a(!1),s(!1),d(c))},size:`sm`})})})]}),(0,X.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,X.jsx)(Ig,{content:n(`action.open`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.new_terminal`),icon:(0,X.jsx)($,{semantic:`terminal.action.new`,size:14}),onClick:f,size:`sm`})})})]})]})}),(0,X.jsx)(`div`,{className:`bottom-terminal-content`,children:m?(0,X.jsxs)(X.Fragment,{children:[x?(0,X.jsx)(Rh,{"aria-label":n(`terminal.selector.title`),className:`bottom-terminal-tabs-nav`,onValueChange:p,value:v,children:(0,X.jsx)(zh,{className:`bottom-terminal-tabs`,children:h.map((e,t)=>(0,X.jsx)(xT,{id:e,index:t,isActive:e===v,onSelect:()=>p(e),onClose:()=>d(e)},e))})}):null,l&&u&&(0,X.jsx)(`div`,{className:`bottom-terminal-xterm`,children:(0,X.jsx)(sw,{terminalId:l.id,workspaceId:u,terminalKind:l.kind??`shell`})})]}):(0,X.jsx)(Sh,{action:(0,X.jsx)(Q,{variant:`primary`,size:`sm`,onClick:f,leadingIcon:(0,X.jsx)($,{semantic:`terminal.action.new`,size:14}),children:n(`terminal.new_terminal`)}),className:`bottom-terminal-empty`,description:(0,X.jsx)(`p`,{className:`bottom-terminal-empty-hint`,children:n(`terminal.empty_hint`)}),icon:(0,X.jsx)($,{className:`bottom-terminal-empty-icon`,semantic:`state.emptyTerminal`,size:32}),title:(0,X.jsx)(`p`,{className:`bottom-terminal-empty-text`,children:n(`terminal.no_terminal`)})})})]})}function CT({controller:e,className:t,iconSize:n,dataTestId:r}){let i=Z();if(!e)return null;let a=e.isFullscreen?i(`tooltip.exit_fullscreen`):i(`tooltip.enter_fullscreen`);return(0,X.jsx)(Ig,{content:a,children:(0,X.jsx)(Em,{"aria-label":a,className:t,"data-testid":r,icon:(0,X.jsx)(e.isFullscreen?Ki:Wi,{size:n}),onClick:()=>{e.toggleFullscreen()}})})}var wT=()=>{let e=Z(),t=U(xp);if(t===`connected`)return null;let n=`connection-status-${t}`,r=`connection-status-dot connection-status-dot-${t}`,i=e(`status.${t}`);return(0,X.jsx)(Ig,{content:i,children:(0,X.jsxs)(`div`,{className:`connection-status ${n}`,"aria-label":i,children:[(0,X.jsx)(lg,{tone:TT(t),size:`sm`,pulse:ET(t),className:r}),(0,X.jsx)(`span`,{className:`connection-status-text`,children:i})]})})};function TT(e){switch(e){case`connected`:return`success`;case`disconnected`:return`error`;default:return`warning`}}function ET(e){switch(e){case`connecting`:case`reconnecting`:return!0;default:return!1}}function DT(){let e=Qt(),t=U(Op),n=U(Np),r=W(jp),i=W(Mp),a=W(Np);return(0,H.useCallback)(async(o,s)=>{let c=await t(`workspace.close`,{id:o});if(!c.ok)return console.error(`Failed to close workspace:`,c.error?.message),!1;let l=n.filter(e=>e!==o);return i(e=>{let t={...e};return delete t[o],t}),a(l),r(e=>e===o?l[0]??null:e),l.length===0&&s?.navigateHomeWhenEmpty&&e(`/`,{replace:!0}),!0},[t,e,r,a,i,n])}var OT={running:`var(--workspace-session-map-running)`,starting:`var(--workspace-session-map-starting)`,idle:`var(--workspace-session-map-idle)`,empty:`var(--workspace-session-map-empty)`};function kT({cells:e,columns:t=1}){let n=Math.max(t,1),r=AT(e,n);return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`workspace-session-mini-map`,"data-testid":`workspace-session-mini-map`,style:{"--workspace-session-map-columns":String(n)},children:(0,X.jsx)(`span`,{className:`workspace-session-mini-map__viewport`,children:r.map(e=>(0,X.jsx)(`span`,{className:`workspace-session-mini-map__column`,style:{"--workspace-session-map-column-fill":e.fill}},e.id))})})}function AT(e,t){let n=Array.from({length:t},()=>[]);for(let r of e){let e=PT(Math.round(r.x*t),t),i=PT(e+Math.max(1,Math.round(r.width*t))-1,t),a={top:FT(r.y),bottom:FT(r.y+r.height),state:r.state};for(let t=e;t<=i;t+=1)n[t]?.push(a)}return n.map((e,t)=>({id:`column-${t}`,fill:jT(e)}))}function jT(e){let t=e.filter(e=>e.bottom>e.top).sort((e,t)=>e.top-t.top||e.bottom-t.bottom);if(t.length===0)return NT(`empty`);let n=[],r=1/t.length;for(let[e,i]of t.entries()){let t=e*r,a=(e+1)*r;MT(n,i.state,t,a)}return`linear-gradient(180deg, ${n.join(`, `)})`}function MT(e,t,n,r){let i=OT[t];e.push(`${i} ${IT(n)}`),e.push(`${i} ${IT(r)}`)}function NT(e){let t=OT[e];return`linear-gradient(180deg, ${t} 0%, ${t} 100%)`}function PT(e,t){return Math.max(0,Math.min(t-1,e))}function FT(e){return Math.max(0,Math.min(1,e))}function IT(e){let t=Math.round(FT(e)*1e3)/10;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}%`}function LT(e,t){return zT(e??{id:`root`,type:`leaf`},t,{x:0,y:0,width:1,height:1})}function RT(e){return VT(e??{id:`root`,type:`leaf`})}function zT(e,t,n){if(e.type!==`split`||!e.children?.length)return[{paneId:e.id,sessionId:e.sessionId??null,state:BT(e.sessionId?t[e.sessionId]:void 0),x:n.x,y:n.y,width:n.width,height:n.height}];let[r,i]=e.children;if(!r||!i)return zT({...e,type:`leaf`,children:void 0},t,n);if(e.direction===`horizontal`){let e=VT(r),a=e+VT(i),o=n.width*(e/a);return[...zT(r,t,{x:n.x,y:n.y,width:o,height:n.height}),...zT(i,t,{x:n.x+o,y:n.y,width:n.width-o,height:n.height})]}return e.direction===`vertical`?[...zT(r,t,{x:n.x,y:n.y,width:n.width,height:n.height*.5}),...zT(i,t,{x:n.x,y:n.y+n.height*.5,width:n.width,height:n.height*.5})]:zT({...e,direction:`horizontal`},t,n)}function BT(e){switch(e?.state){case`running`:return`running`;case`starting`:return`starting`;case`idle`:return`idle`;default:return`empty`}}function VT(e){if(e.type!==`split`||!e.children?.length)return 1;let[t,n]=e.children;return!t||!n?1:e.direction===`vertical`?Math.max(VT(t),VT(n)):VT(t)+VT(n)}var HT=({workspace:e,isActive:t})=>{let n=Z(),r=DT(),i=Zg(),{paneLayout:a,sessions:o}=Xx(e,{disabled:t}),s=Ug(e)||e.id,c=LT(a,Object.fromEntries(o.map(e=>[e.id,e]))),l=RT(a);return(0,X.jsxs)(`div`,{className:`topbar-tab-shell ${t?`active`:``}`,role:`presentation`,children:[(0,X.jsx)(Bh,{className:`topbar-tab`,onClick:n=>{n.preventDefault(),!t&&i(e.id)},value:e.id,children:(0,X.jsxs)(`span`,{className:`topbar-tab-content`,children:[(0,X.jsx)(Ig,{content:e.path||e.id,children:(0,X.jsx)(`span`,{className:`topbar-tab-name`,children:s})}),(0,X.jsx)(kT,{cells:c,columns:l}),(0,X.jsx)(mm,{count:e.unreadCount??0,max:9})]})}),(0,X.jsx)(Em,{className:`topbar-close`,"aria-label":n(`action.close_workspace`),icon:(0,X.jsx)(pa,{size:14}),onClick:async t=>{t.stopPropagation(),await r(e.id)},size:`sm`})]})},UT={width:`auto`,minHeight:`auto`,padding:0,gap:0},WT={color:`var(--text-tertiary)`,fontSize:`var(--text-sm)`,fontWeight:`var(--font-normal)`},GT=({fullscreenController:e})=>{let t=Z(),n=Qt(),r=U(Rp),i=U(zp)??r[0]?.id??``,a=Zg(),[o,s]=Te($a),[c,l]=Te(J_),[u,d]=Te(K_),[f,p]=(0,H.useState)(!1);return(0,X.jsxs)(`header`,{className:`app-topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-tabs`,children:[r.length===0?(0,X.jsx)(Sh,{className:`topbar-empty-state`,style:UT,title:(0,X.jsx)(`span`,{className:`topbar-hint`,style:WT,children:t(`workspace.no_workspace`)})}):(0,X.jsx)(Rh,{"aria-label":t(`workspace.tabs`),className:`topbar-tabs-nav`,onValueChange:e=>{a(e)},value:i,children:(0,X.jsx)(zh,{className:`topbar-tablist`,children:r.map(e=>(0,X.jsx)(HT,{workspace:e,isActive:e.id===i},e.id))})}),(0,X.jsx)(Ig,{content:t(`tooltip.new_workspace`),children:(0,X.jsx)(Em,{"aria-label":t(`tooltip.new_workspace`),className:`topbar-add`,icon:(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:14}),onClick:()=>p(!0)})})]}),(0,X.jsxs)(`div`,{className:`topbar-actions`,children:[(0,X.jsx)(wT,{}),(0,X.jsx)(Ig,{content:t(`tooltip.quick_actions`),children:(0,X.jsxs)(`button`,{className:`topbar-btn topbar-quick-actions`,onClick:()=>s(!o),"aria-label":t(`tooltip.quick_actions`),children:[(0,X.jsx)($,{semantic:`nav.search`,size:14}),(0,X.jsx)(`span`,{className:`topbar-btn-label`,children:t(`tooltip.quick_actions`)})]})}),(0,X.jsx)(Ig,{content:t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),children:(0,X.jsx)(Em,{"aria-label":t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),className:`topbar-btn ${c?`topbar-btn--active`:`topbar-btn--muted`}`,icon:(0,X.jsx)($,{semantic:`nav.panelTerminal`,size:14}),onClick:()=>l(!c)})}),(0,X.jsx)(Ig,{content:t(u?`tooltip.show_files`:`tooltip.hide_files`),children:(0,X.jsx)(Em,{"aria-label":t(u?`tooltip.show_files`:`tooltip.hide_files`),className:`topbar-btn ${u?`topbar-btn--muted`:`topbar-btn--active`}`,icon:(0,X.jsx)($,{semantic:`nav.panelFiles`,size:14}),onClick:()=>d(!u)})}),(0,X.jsx)(Ig,{content:t(`settings.title`),children:(0,X.jsx)(Em,{"aria-label":t(`settings.title`),className:`topbar-btn`,"data-testid":`settings-open`,icon:(0,X.jsx)($,{semantic:`nav.settings`,size:14}),onClick:()=>n(`/settings`)})}),(0,X.jsx)(CT,{controller:e,className:`topbar-btn`,iconSize:14,dataTestId:`workspace-fullscreen-open`})]}),f?(0,X.jsx)(Qv,{onClose:()=>p(!1)}):null]})};function KT(e){let t=e;return e.fullscreenElement??t.webkitCurrentFullScreenElement??null}function qT(e){if(!e)return null;let t=e;return typeof t.requestFullscreen==`function`?t.requestFullscreen.bind(t):typeof t.webkitRequestFullscreen==`function`?t.webkitRequestFullscreen.bind(t):typeof t.webkitRequestFullScreen==`function`?t.webkitRequestFullScreen.bind(t):null}function JT(e){let t=e;return typeof e.exitFullscreen==`function`?e.exitFullscreen.bind(e):typeof t.webkitExitFullscreen==`function`?t.webkitExitFullscreen.bind(e):typeof t.webkitCancelFullScreen==`function`?t.webkitCancelFullScreen.bind(e):null}function YT(e){return!!(qT(e)&&JT(document))}function XT(e){return e instanceof Error&&e.message.trim().length>0?e.message:null}function ZT(e){let t=Z(),n=W(sy),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=(0,H.useCallback)(()=>{n({kind:`info`,title:t(`workspace.fullscreen.unsupported_title`),body:t(`workspace.fullscreen.unsupported_body`)})},[n,t]);(0,H.useEffect)(()=>{let t=()=>{let t=e.current;i(YT(t)),o(!!(t&&KT(document)===t))};return t(),document.addEventListener(`fullscreenchange`,t),document.addEventListener(`webkitfullscreenchange`,t),()=>{document.removeEventListener(`fullscreenchange`,t),document.removeEventListener(`webkitfullscreenchange`,t)}},[e]);let c=(0,H.useCallback)(async()=>{let r=e.current,i=qT(r);if(!i||!JT(document)){s();return}try{await Promise.resolve(i())}catch(e){console.warn(`Failed to enter fullscreen`,e),n({kind:`warning`,title:t(`workspace.fullscreen.enter_failed_title`),body:XT(e)??t(`workspace.fullscreen.enter_failed_body`)})}},[n,s,t,e]),l=(0,H.useCallback)(async()=>{let e=JT(document);if(KT(document)){if(!e){s();return}try{await Promise.resolve(e())}catch(e){console.warn(`Failed to exit fullscreen`,e),n({kind:`warning`,title:t(`workspace.fullscreen.exit_failed_title`),body:XT(e)??t(`workspace.fullscreen.exit_failed_body`)})}}},[n,s,t]);return{supported:r,isFullscreen:a,enterFullscreen:c,exitFullscreen:l,toggleFullscreen:(0,H.useCallback)(async()=>{if(e.current&&KT(document)===e.current){await l();return}await c()},[c,l,e])}}var QT={left:0,top:0,right:1,bottom:1},$T=1e-9;function eE(e,t,n){let r=tE(e,QT),i=r.find(e=>e.sessionId===t);if(!i)return null;let a=null,o=!1,s=1/0,c=1/0;for(let e of r){if(e.sessionId===t)continue;let r=nE(i,e,n);if(r===null)continue;let l=rE(i,e,n),u=iE(i,e,n);(a===null||l&&!o||l===o&&r<s-$T||l===o&&Math.abs(r-s)<=$T&&u<c-$T)&&(a=e,o=l,s=r,c=u)}return a?.sessionId??null}function tE(e,t){if(e.type===`leaf`)return e.sessionId?[{sessionId:e.sessionId,...t}]:[];let n=e.children??[];if(n.length===0)return[];if(n.length===1)return tE(n[0],t);let r=e.ratio??.5;if(e.direction===`horizontal`){let e=t.left+(t.right-t.left)*r;return[...tE(n[0],{...t,right:e}),...tE(n[1],{...t,left:e})]}let i=t.top+(t.bottom-t.top)*r;return[...tE(n[0],{...t,bottom:i}),...tE(n[1],{...t,top:i})]}function nE(e,t,n){switch(n){case`left`:{let n=e.left-t.right;return n>=-$T?Math.max(n,0):null}case`right`:{let n=t.left-e.right;return n>=-$T?Math.max(n,0):null}case`up`:{let n=e.top-t.bottom;return n>=-$T?Math.max(n,0):null}case`down`:{let n=t.top-e.bottom;return n>=-$T?Math.max(n,0):null}}}function rE(e,t,n){return n===`left`||n===`right`?aE(e.top,e.bottom,t.top,t.bottom):aE(e.left,e.right,t.left,t.right)}function iE(e,t,n){return Math.abs(n===`left`||n===`right`?oE(e.top,e.bottom)-oE(t.top,t.bottom):oE(e.left,e.right)-oE(t.left,t.right))}function aE(e,t,n,r){return Math.min(t,r)-Math.max(e,n)>$T}function oE(e,t){return(e+t)/2}var sE=[{id:`session.navigate.left`,direction:`left`},{id:`session.navigate.right`,direction:`right`},{id:`session.navigate.up`,direction:`up`},{id:`session.navigate.down`,direction:`down`}],cE=[{id:`workspace.previous`,step:-1},{id:`workspace.next`,step:1}];function lE(e){let t=ve(),n=U(Bp),r=U(Lp),i=U(rx),a=Xg(),o=Zg(),{persistUiState:s}=Bv(e);(0,H.useEffect)(()=>{if(!e)return;let c=c=>{let l=sE.find(({id:e})=>ox(c,sx(e,i)));if(l){c.preventDefault();let r=n;if(!r||r.id!==e)return;let i=r.uiState.activeSessionId;if(!i)return;let o=eE(t.get(tv(e)),i,l.direction);if(!o)return;a({workspaceId:e,sessionId:o}),s({activeSessionId:o});return}let u=cE.find(({id:e})=>ox(c,sx(e,i)));if(!u)return;c.preventDefault();let d=n?.id??e,f=r.indexOf(d);if(f===-1)return;let p=r[f+u.step];p&&o(p)};return window.addEventListener(`keydown`,c),()=>window.removeEventListener(`keydown`,c)},[n,i,r,a,s,o,t,e])}var uE=220,dE=120;function fE(e,t,n){if(e>0)return e;let r=Number.parseFloat(t);return Number.isFinite(r)&&r>0?r:n}function pE(e){let[t,n]=Te(z_(e)),[r,i]=Te(B_(e)),a=(0,H.useRef)(!1),o=(0,H.useRef)(null),s=(0,H.useRef)(0),c=(0,H.useRef)(0),l=(0,H.useRef)(t),u=(0,H.useRef)(null),d=(0,H.useCallback)(e=>{e.preventDefault(),a.current=!0,s.current=e.clientX,c.current=fE(o.current?.offsetWidth??0,o.current?.style.width??``,t),l.current=c.current,document.body.classList.add(`is-resizing-panels`);let r=e=>{if(!a.current)return;let t=e.clientX-s.current,n=Math.max(uE,c.current+t);l.current=n,o.current&&(o.current.style.width=`${n}px`)},i=()=>{a.current=!1,document.body.classList.remove(`is-resizing-panels`),n(l.current),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[n,t]),f=(0,H.useRef)(!1),p=(0,H.useRef)(0),m=(0,H.useRef)(0),h=(0,H.useRef)(r);return{bottomPanelHeight:r,bottomPanelRef:u,handleBottomMouseDown:(0,H.useCallback)(e=>{e.preventDefault(),f.current=!0,p.current=e.clientY,m.current=fE(u.current?.offsetHeight??0,u.current?.style.height??``,r),h.current=m.current,document.body.classList.add(`is-resizing-panels`);let t=e=>{if(!f.current)return;let t=p.current-e.clientY,n=Math.max(dE,m.current+t);h.current=n,u.current&&(u.current.style.height=`${n}px`)},n=()=>{f.current=!1,document.body.classList.remove(`is-resizing-panels`),i(h.current),document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)},[i,r]),handleLeftMouseDown:d,leftPanelRef:o,leftPanelWidth:t}}function mE(){return{kind:`root`}}function hE(){return{createRequest:null,panelRefreshToken:0,mobileSheet:null,mobileFilesRoute:mE(),mobileActiveSessionId:null,mobileSelectionVersion:0}}var gE=Ap(e=>V(hE()));function _E(){let e=U(Bp),t=e?.id??`__workspace_placeholder__`,n=gE(t),r=U(zp),i=W(jp),a=U(Rp),o=U(p_(t)),s=U(u_(t)),c=U(m_(t)),l=U(W_),u=U(J_),d=U(K_),f=U(q_),{sessions:p,paneLayout:m}=Xx(e),h=U(Op),g=W(__),_=U(n),v=W(n),y=ve(),b=pE(t),x=Mx(t),S=Yx(),{createRequest:C,mobileActiveSessionId:w,mobileFilesRoute:T,mobileSheet:E,panelRefreshToken:D}=_;(0,H.useEffect)(()=>{if(!e){i(null);return}i(e.id)},[i,e]),(0,H.useEffect)(()=>{if(!e||o)return;let t=!1;return h(`git.status`,{workspaceId:e.id}).then(n=>{t||!n.ok||!n.data||y.set(p_(e.id),n.data)}).catch(e=>{t||console.error(`Failed to load git status:`,e)}),()=>{t=!0}},[h,o,y,e]);let O=(0,H.useCallback)(()=>{e&&(y.set(q_,`source-control`),g({visible:!0,workspaceId:e.id,inputValue:``}))},[g,y,e]),k=(0,H.useCallback)(()=>{v(e=>({...e,createRequest:{id:(e.createRequest?.id??0)+1,mode:`file`,baseDir:null}}))},[v]),A=(0,H.useCallback)(()=>{v(e=>({...e,createRequest:{id:(e.createRequest?.id??0)+1,mode:`folder`,baseDir:null}}))},[v]),j=(0,H.useCallback)(()=>{v(e=>e.createRequest===null?e:{...e,createRequest:null})},[v]),M=(0,H.useCallback)(()=>{v(e=>({...e,panelRefreshToken:e.panelRefreshToken+1}))},[v]),N=(0,H.useMemo)(()=>{let e=new Map(p.map(e=>[e.id,e]));return Array.from(new Set(Ev(m))).map(t=>e.get(t)).filter(e=>!!e)},[m,p]),P=(0,H.useMemo)(()=>{let e=new Set(N.map(e=>e.id));return[...N,...p.filter(t=>t.state!==`draft`&&!e.has(t.id))]},[N,p]),F=P.find(e=>e.id===w)??null,ee=(0,H.useCallback)(e=>{e&&!N.some(t=>t.id===e)&&p.some(t=>t.id===e&&t.state!==`draft`)&&x.appendSessionToMobileColumn(e),v(t=>({...t,mobileSelectionVersion:t.mobileSelectionVersion+1,mobileActiveSessionId:e}))},[w,N,x,p,v]),I=(0,H.useCallback)(e=>{x.appendSessionToMobileColumn(e),v(t=>({...t,mobileSelectionVersion:t.mobileSelectionVersion+1,mobileActiveSessionId:e}))},[x,v]),L=(0,H.useCallback)(async e=>{let t=w===e,r=y.get(n).mobileSelectionVersion,i=P.filter(t=>t.id!==e)[0]?.id??null;if(t&&v(t=>t.mobileActiveSessionId===e?{...t,mobileActiveSessionId:i}:t),!await S.closeSession(e,`remove`)){if(!t||y.get(n).mobileSelectionVersion!==r)return;v(t=>t.mobileActiveSessionId===i?{...t,mobileActiveSessionId:e}:t);return}v(e=>({...e,mobileSelectionVersion:e.mobileSelectionVersion+1}))},[w,P,n,S,v,y]),R=(0,H.useCallback)(e=>{e&&!N.some(t=>t.id===e)&&p.some(t=>t.id===e&&t.state!==`draft`)&&x.appendSessionToMobileColumn(e),v(t=>({...t,mobileSelectionVersion:t.mobileSelectionVersion+1,mobileActiveSessionId:e}))},[N,x,p,v]),z=(0,H.useCallback)(e=>{v(t=>({...t,mobileSheet:e,mobileFilesRoute:e===`files`?t.mobileFilesRoute:mE()}))},[v]),te=(0,H.useCallback)(()=>{v(e=>({...e,mobileSheet:null,mobileFilesRoute:mE()}))},[v]),ne=(0,H.useCallback)(e=>{v(t=>({...t,mobileFilesRoute:e}))},[v]);return{activeSession:F,activeFilePath:s,activeWorkspaceId:r,createRequest:C,diffPreview:c,focusMode:l,gitState:o,handleConsumeCreateRequest:j,handleOpenBranchSwitcher:O,handleOpenFileCreate:k,handleOpenFolderCreate:A,handleRefreshSidebarPanel:M,handleMobileSessionCreated:I,mainAreaMode:s||c?.source===`commit`?`editor`:`agent`,mobileActiveSessionId:w,mobileAgentSessions:P,mobileFilesRoute:T,mobileSheet:E,openMobileSheet:z,orderedSessions:N,paneLayout:m,panelRefreshToken:D,paneLayout:m,closeMobileSession:L,restoreMobileSession:R,selectMobileSession:ee,sessions:p,desktopSidebarView:f,setDesktopSidebarView:e=>y.set(q_,e),sidebarCollapsed:d,closeMobileSheet:te,terminalPanelVisible:u,updateMobileFilesRoute:ne,workspace:e,workspaces:a,workspaceId:t,...b}}function vE(e,t,n){return e===t?n:e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:e}function yE(e,t,n){let r=Object.entries(e).map(([e,r])=>{let i=vE(e,t,n);return i===e?[e,r]:[i,{...r,path:i}]});return Object.fromEntries(r)}function bE({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i}){let a=Z(),o=U(Qg(e)),s=U($g(e)),c=U(u_(e)),l=U(Op),u=W(Qg(e)),d=W($g(e)),f=W(u_(e)),p=W(d_(e)),m=W(l_(e)),{openLocation:h}=Cy(e),g=U(e_(e)),_=W(e_(e)),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(null),O=(0,H.useRef)(t),k=(0,H.useRef)(0),A=(0,H.useCallback)(async()=>{if(!e||v)return!1;y(!0);let t=await l(`file.readTree`,{workspaceId:e});if(t.ok&&t.data){let e=new Map;return e.set(`.`,t.data.children),u(e),_(new Set),y(!1),!0}return t.ok||console.error(`Failed to load file tree:`,t.error?.message),y(!1),!1},[e,v,l,u,_]),j=(0,H.useCallback)(async t=>{let n=g.has(t)&&o?.has(t);if(!e||b===t||n)return;x(t);let r=await l(`file.readTree`,{workspaceId:e,subPath:t});r.ok&&r.data&&(u(e=>{if(!e)return e;let n=new Map(e);return n.set(t,r.data.children),n}),_(e=>new Set(e).add(t))),x(null)},[e,b,g,o,l,u,_]),M=(0,H.useCallback)(async t=>{if(!e)return[];let n=await l(`file.search`,{workspaceId:e,query:t,limit:10});return!n.ok||!n.data?[]:n.data.files},[l,e]),N=(0,H.useCallback)((e,t)=>{C({mode:e,draftPath:t?`${t.replace(/\/+$/,``)}/`:``,error:null})},[]),P=(0,H.useCallback)(()=>{C(null)},[]),F=(0,H.useCallback)(({path:e,name:t,kind:n})=>{T({fromPath:e,currentName:t,nextName:t,kind:n,error:null})},[]),ee=(0,H.useCallback)(()=>{T(null)},[]),I=(0,H.useCallback)(e=>{T(t=>t&&{...t,nextName:e,error:null})},[]),L=(0,H.useCallback)(e=>{C(t=>t&&{...t,draftPath:e,error:null})},[]),R=(0,H.useCallback)(async()=>{if(!S)return;let t=S.draftPath.trim();if(!t){C(e=>e&&{...e,error:a(`file.path_required`)});return}if(S.mode===`file`&&t.endsWith(`/`)){C(e=>e&&{...e,error:a(`file.invalid_file_path`)});return}let n=await l(S.mode===`file`?`file.create`:`file.mkdir`,{workspaceId:e,path:t});if(!n.ok){C(e=>e&&{...e,error:n.error?.message??a(`file.create_failed`)});return}await A(),P(),S.mode===`file`&&h({workspaceId:e,path:t,source:`manual`})},[S,l,e,A,P,h,a]),z=(0,H.useCallback)(async()=>{if(!w)return;let t=w.nextName.trim();if(!t){T(e=>e&&{...e,error:a(`file.rename_required`)});return}if(t.includes(`/`)||t.includes(`\\`)){T(e=>e&&{...e,error:a(`file.rename_invalid_name`)});return}if(t===w.currentName){T(null);return}let n=w.fromPath.lastIndexOf(`/`),r=n===-1?``:w.fromPath.slice(0,n),i=r?`${r}/${t}`:t,o=await l(`file.rename`,{workspaceId:e,fromPath:w.fromPath,toPath:i});if(!o.ok){T(e=>e&&{...e,error:o.error?.message??a(`file.rename_failed`)});return}f(e=>e&&vE(e,w.fromPath,i)),m(e=>yE(e,w.fromPath,i)),await A(),T(null)},[l,A,w,f,m,a,e]),te=(0,H.useCallback)(()=>{D(null)},[]),ne=(0,H.useCallback)(async()=>{if(!E)return;let t=await l(`file.delete`,{workspaceId:e,path:E.path});if(!t.ok){D(e=>e&&{...e,error:t.error?.message??a(`file.delete_failed`)});return}c===E.path&&f(null),m(e=>{if(!(E.path in e))return e;let t={...e};return delete t[E.path],t}),await A(),D(null)},[E,l,e,c,f,m,A,a]);return(0,H.useEffect)(()=>{!o&&!v&&A()},[o,v,A]),(0,H.useEffect)(()=>{s&&!v&&(d(!1),A())},[s,v,A,d]),(0,H.useEffect)(()=>{t<=O.current||v||(O.current=t,A())},[t,v,A]),(0,H.useEffect)(()=>{!n||n.id<=k.current||(k.current=n.id,N(n.mode,n.baseDir),r?.())},[n,N,r]),{activeFilePath:c,createDialog:S,fileTree:o,isLoading:v,isLoadingDir:b,renameDialog:w,pendingDelete:E,cancelDelete:te,confirmDelete:ne,handleSelectFile:(0,H.useCallback)(t=>{p(c_(t)),h({workspaceId:e,path:t,source:`file-tree`}),i?.(t)},[i,h,p,e]),loadChildren:j,loadSearchResults:M,openCreateDialog:N,openRenameDialog:F,requestDelete:D,updateRenameDraft:I,submitRenameDialog:z,closeRenameDialog:ee,submitCreateDialog:R,updateDraftPath:L,closeCreateDialog:P}}function xE(e,t,n){let r=e(t);return r===t?n:r}function SE(e,t){let n=e.includes(`\\`)?`\\`:`/`,r=e.replace(/[\\/]+$/,``),i=t===`.`?[]:t.split(/[\\/]+/).map(e=>e.trim()).filter(Boolean);return i.length>0?`${r}${n}${i.join(n)}`:r}function CE(e){if(e.kind===`dir`)return e.path===`.`?void 0:e.path;let t=Math.max(e.path.lastIndexOf(`/`),e.path.lastIndexOf(`\\`));if(!(t<=0))return e.path.slice(0,t)}function wE({workspacePath:e,target:t,createShellTerminal:n,openCreateDialog:r,openRenameDialog:i,requestDelete:a}){let o=Z();return(0,H.useMemo)(()=>{if(!t)return[];let{node:s}=t,c=s.path,l=e?SE(e,c):null,u=CE(s),d=[];return s.kind===`dir`&&d.push({id:`create`,title:xE(o,`file.context_section_create`,`Create`),items:[{id:`new-file`,label:xE(o,`file.new_file`,`New File`),onSelect:()=>r(`file`,s.path)},{id:`new-folder`,label:xE(o,`file.new_folder`,`New Folder`),onSelect:()=>r(`folder`,s.path)}]}),d.push({id:`edit`,title:xE(o,`file.context_section_edit`,`Edit`),items:[{id:`rename`,label:xE(o,`file.rename`,`Rename`),onSelect:()=>i({path:s.path,name:s.name,kind:s.kind})},{id:`delete`,label:xE(o,`file.delete`,`Delete`),tone:`danger`,onSelect:()=>a({path:s.path,name:s.name,error:null})}]},{id:`path`,title:xE(o,`file.context_section_path`,`Path`),items:[{id:`copy-relative-path`,label:xE(o,`file.copy_relative_path`,`Copy Relative Path`),onSelect:()=>kS(c)},{id:`copy-absolute-path`,label:xE(o,`file.copy_absolute_path`,`Copy Absolute Path`),disabled:!l,onSelect:()=>l?kS(l):void 0}]},{id:`terminal`,title:xE(o,`file.context_section_terminal`,`Terminal`),items:[{id:`open-in-terminal`,label:xE(o,`file.open_in_terminal`,`Open in Terminal`),onSelect:()=>n(u?{cwdPath:u}:{})}]}),d},[n,r,i,a,o,t,e])}function TE(e,t){return Math.abs(t.x-e.x)>10||Math.abs(t.y-e.y)>10}function EE(){let[e,t]=(0,H.useState)(null),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(!1),s=(0,H.useRef)(null),c=(0,H.useCallback)(()=>{s.current&&=(window.clearTimeout(s.current.timer),null)},[]),l=(0,H.useCallback)(()=>{c(),r(null),a(!1)},[c]),u=(0,H.useCallback)((e,n)=>{e.preventDefault(),c(),t(n),r({x:e.clientX,y:e.clientY}),a(!1)},[c]),d=(0,H.useCallback)((e,n)=>{e.pointerType!==`mouse`&&(c(),s.current={pointerId:e.pointerId,startPoint:{x:e.clientX,y:e.clientY},timer:window.setTimeout(()=>{t(n),r(null),a(!0),o.current=!0,s.current=null},450),target:n})},[c]),f=(0,H.useCallback)(e=>{let t=s.current;!t||t.pointerId!==e.pointerId||TE(t.startPoint,{x:e.clientX,y:e.clientY})&&c()},[c]),p=(0,H.useCallback)(e=>{e!==void 0&&s.current?.pointerId!==e||c()},[c]),m=(0,H.useCallback)(()=>{let e=o.current;return o.current=!1,e},[]);return(0,H.useEffect)(()=>()=>c(),[c]),{contextTarget:e,desktopAnchorPoint:n,mobileOpen:i,isOpen:(0,H.useMemo)(()=>n!==null||i,[n,i]),closeMenu:l,openDesktopMenu:u,beginLongPress:d,updateLongPress:f,cancelLongPress:p,consumeSuppressedClick:m}}var DE=8;function OE(e){return e.flatMap(e=>e.items.filter(e=>!e.disabled))}function kE(e,t,n){if(e.length===0)return null;if(t===null)return n===1?e[0]?.id??null:e[e.length-1]?.id??null;let r=e.findIndex(e=>e.id===t);if(r===-1)return n===1?e[0]?.id??null:e[e.length-1]?.id??null;let i=r+n;return e[i]?e[i].id:n===1?e[0]?.id??null:e[e.length-1]?.id??null}async function AE(e,t){try{await e.onSelect()}catch(e){console.error(`File context menu action failed`,e)}finally{t()}}function jE(e,t){return`file-context-menu-item-${e}-${t}`}function ME({title:e,open:t,mode:n,sections:r,anchorPoint:i=null,restoreFocusTo:a=null,onClose:o}){let s=(0,H.useRef)(null),c=(0,H.useRef)(t),l=(0,H.useRef)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)({left:DE,top:DE}),m=(0,H.useMemo)(()=>OE(r),[r]),h=(0,H.useMemo)(()=>{if(u)for(let e of r){let t=e.items.find(e=>e.id===u);if(t)return jE(e.id,t.id)}},[u,r]);if((0,H.useEffect)(()=>{let e=c.current;t&&!e&&d(null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),!t&&e&&a?.isConnected&&(l.current=window.setTimeout(()=>{a.isConnected&&a.focus(),l.current=null},0)),c.current=t},[t,a]),(0,H.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,H.useLayoutEffect)(()=>{if(!t||n!==`desktop`||!i||!s.current)return;let e=s.current.getBoundingClientRect();p({left:Math.min(Math.max(DE,i.x),Math.max(DE,window.innerWidth-e.width-DE)),top:Math.min(Math.max(DE,i.y),Math.max(DE,window.innerHeight-e.height-DE))})},[i,n,t,r]),(0,H.useLayoutEffect)(()=>{!t||n!==`desktop`||s.current?.focus()},[n,t]),(0,H.useEffect)(()=>{if(!t||n!==`desktop`)return;let e=e=>{e.target instanceof Node&&(s.current?.contains(e.target)||o())};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[n,o,t]),!t)return null;let g=e=>{d(kE(m,u,e))},_=(0,X.jsx)(`div`,{className:`file-context-menu-layer`,children:(0,X.jsx)(`div`,{ref:s,role:`menu`,tabIndex:-1,"aria-label":e,"aria-orientation":`vertical`,"aria-activedescendant":h,className:`file-context-menu`,style:{position:`fixed`,left:f.left,top:f.top},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),o();return}if(e.key===`ArrowDown`){e.preventDefault(),g(1);return}if(e.key===`ArrowUp`){e.preventDefault(),g(-1);return}if(e.key!==`Enter`&&e.key!==` `)return;let t=m.find(e=>e.id===u);t&&(e.preventDefault(),AE(t,o))},children:r.map(e=>(0,X.jsxs)(`div`,{className:`file-context-menu__section`,children:[(0,X.jsx)(`h3`,{className:`file-context-menu__section-title`,children:e.title}),(0,X.jsx)(`div`,{className:`file-context-menu__section-items`,children:e.items.map(t=>(0,X.jsx)(`button`,{id:jE(e.id,t.id),type:`button`,role:`menuitem`,tabIndex:-1,disabled:t.disabled,"data-active":u===t.id?`true`:void 0,className:Y(`file-context-menu__item`,t.tone===`danger`?`file-context-menu__item--danger`:null),onFocus:()=>{t.disabled||d(t.id)},onMouseEnter:()=>{t.disabled||d(t.id)},onClick:()=>{t.disabled||AE(t,o)},children:t.label},t.id))})]},e.id))})});return n===`mobile`?(0,X.jsx)(fm,{title:e,onClose:o,body:(0,X.jsx)(`div`,{className:`file-context-menu__sheet`,children:r.map(e=>(0,X.jsxs)(`section`,{className:`file-context-menu__sheet-section`,children:[(0,X.jsx)(`h3`,{children:e.title}),(0,X.jsx)(`div`,{className:`file-context-menu__sheet-actions`,children:e.items.map(e=>(0,X.jsx)(`button`,{type:`button`,disabled:e.disabled,className:Y(`file-context-menu__sheet-action`,e.tone===`danger`?`file-context-menu__sheet-action--danger`:null),onClick:()=>{e.disabled||AE(e,o)},children:e.label},e.id))})]},e.id))})}):(0,X.jsx)($p,{children:_})}function NE(e,t){if(e.kind===`dir`)return t?`file.folder.open`:`file.folder.closed`;switch(e.name.split(`.`).pop()?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:case`mjs`:case`cjs`:case`py`:case`go`:case`rs`:case`java`:return`file.type.code`;case`json`:case`yaml`:case`yml`:case`toml`:case`lock`:return`file.type.data`;case`md`:case`txt`:return`file.type.doc`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:case`webp`:return`file.type.media`;default:return`file.type.default`}}var PE=new Set([`app`,`packages`,`src`]),FE=200,IE={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},LE={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`},RE={display:`block`,width:`auto`,minHeight:`auto`,padding:0,gap:0,textAlign:`left`},zE={margin:0,color:`inherit`,fontSize:`inherit`,fontWeight:`inherit`};function BE({title:e}){return(0,X.jsx)(Sh,{className:`file-tree-empty`,style:IE,title:(0,X.jsx)(`p`,{style:LE,children:e})})}function VE({className:e,title:t}){return(0,X.jsx)(Sh,{className:e,style:RE,title:(0,X.jsx)(`p`,{style:zE,children:t})})}function HE(){return{searchValue:``,resolvedQuery:``,searchResults:[],searchLoading:!1,contextTargetPath:null}}function UE(e,t,n){return`${e}::${t}::${n?`search`:`plain`}`}var WE=Ap(e=>V(HE()));function GE(e){return[...new Set([...e].map(QE).filter(Boolean))].sort((e,t)=>e.localeCompare(t)).slice(0,FE)}var KE=({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i,onVisibleCountChange:a,collapseVersion:o=0,variant:s=`desktop`,showSearch:c=!0})=>{let[l,u]=Te(WE(UE(e,s,c))),d=Z(),f=U(Ip(e)),p=U(t_(e)),m=W(t_(e)),{persistUiState:h}=Bv(e),{createShellTerminal:g}=dT(e),{activeFilePath:_,createDialog:v,fileTree:y,isLoading:b,isLoadingDir:x,renameDialog:S,pendingDelete:C,cancelDelete:w,confirmDelete:T,handleSelectFile:E,loadChildren:D,loadSearchResults:O,openCreateDialog:k,openRenameDialog:A,requestDelete:j,updateRenameDraft:M,submitRenameDialog:N,closeRenameDialog:P,submitCreateDialog:F,updateDraftPath:ee,closeCreateDialog:I}=bE({workspaceId:e,refreshToken:t,createRequest:n,onCreateRequestConsumed:r,onSelectFile:i}),{contextTargetPath:L,resolvedQuery:R,searchLoading:z,searchResults:te,searchValue:ne}=l,re=ne.trim(),ie=(0,H.useMemo)(()=>y?tD(eD(y)):[],[y]),ae=(0,H.useRef)(0),{contextTarget:B,desktopAnchorPoint:oe,isOpen:se,closeMenu:ce,openDesktopMenu:V,beginLongPress:le,updateLongPress:ue,cancelLongPress:de,consumeSuppressedClick:fe}=EE(),pe=re.length>0,me=(0,H.useMemo)(()=>pe?te.length:$E(ie),[pe,te.length,ie]),he=(0,H.useMemo)(()=>ie.filter(e=>e.kind===`dir`&&PE.has(e.name.toLowerCase())).map(e=>e.path),[ie]),ge=wE({workspacePath:f?.path??null,target:B,createShellTerminal:g,openCreateDialog:k,openRenameDialog:A,requestDelete:({path:e,name:t,error:n})=>j({path:e,name:t,error:n})});(0,H.useEffect)(()=>{p!==null||!f||f.uiState.fileTreeExpandedDirs!==void 0&&m(new Set(GE(f.uiState.fileTreeExpandedDirs)))},[p,m,f]);let _e=(0,H.useCallback)(e=>{let t=GE(e);m(new Set(t)),h({fileTreeExpandedDirs:t})},[h,m]);(0,H.useEffect)(()=>{let e=!1;if(!pe)return u(e=>e.searchResults.length>0||e.resolvedQuery||e.searchLoading?{...e,resolvedQuery:``,searchResults:[],searchLoading:!1}:e),ae.current+=1,()=>{e=!0};if(R===re&&!z)return;u(e=>({...e,searchLoading:!0}));let t=++ae.current,n=setTimeout(()=>{(async()=>{let n=await O(re);e||t!==ae.current||u(e=>({...e,resolvedQuery:re,searchResults:n,searchLoading:!1}))})()},150);return()=>{e=!0,clearTimeout(n)}},[pe,O,R,z,re,u]),(0,H.useEffect)(()=>{a?.(me,z||b)},[b,a,z,me]),(0,H.useEffect)(()=>{o<=0||_e([])},[_e,o]),(0,H.useEffect)(()=>{B&&u(e=>e.contextTargetPath===B.node.path?e:{...e,contextTargetPath:B.node.path})},[B,u]);let ve=(0,H.useCallback)(()=>{u(e=>e.contextTargetPath===null?e:{...e,contextTargetPath:null}),ce()},[ce,u]),ye=(0,H.useCallback)((e,t,n)=>{t.kind===`file`&&E(t.path),u(e=>({...e,contextTargetPath:t.path})),V(e,{node:t,surface:n,triggerElement:e.currentTarget})},[E,V,u]),be=(0,H.useCallback)((e,t,n)=>{le(e,{node:t,surface:n,triggerElement:e.currentTarget})},[le]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`file-tree-shell file-tree-shell--${s}`,children:[c?(0,X.jsxs)(`label`,{className:`file-tree-search ${s===`desktop`?`file-tree-search--desktop`:``}`,htmlFor:`file-tree-search-${e}`,children:[(0,X.jsx)($,{semantic:`file.action.search`,size:14,className:`file-tree-search-icon`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{id:`file-tree-search-${e}`,className:`file-tree-search-input`,type:`search`,value:ne,onChange:e=>u(t=>({...t,searchValue:e.target.value})),placeholder:d(`action.search_files`),"aria-label":d(`action.search_files`)})]}):null,(0,X.jsx)(`div`,{className:`file-tree`,children:pe?z?(0,X.jsx)(BE,{title:d(`common.loading`)}):te.length>0?te.map(t=>(0,X.jsx)(qE,{workspaceId:e,node:t,variant:s,selectedPath:_,isContextTarget:L===t.path,onSelectFile:E,onOpenContextMenu:ye,onBeginLongPress:be,onUpdateLongPress:ue,onCancelLongPress:de,consumeSuppressedClick:fe},t.path)):(0,X.jsx)(BE,{title:d(`command.no_results`)}):y&&y.size>0?ie.map(t=>(0,X.jsx)(JE,{workspaceId:e,node:t,depth:0,variant:s,expandedDirs:p,defaultExpandedRootPaths:he,selectedPath:_,contextTargetPath:L,onRequestCreate:k,onSelectFile:E,onLoadChildren:D,onToggleDirs:_e,isLoadingDir:x,onOpenContextMenu:ye,onBeginLongPress:be,onUpdateLongPress:ue,onCancelLongPress:de,consumeSuppressedClick:fe},t.path)):(0,X.jsx)(BE,{title:d(b?`common.loading`:`file.title`)})})]}),(0,X.jsx)(YE,{dialog:v,onCancel:I,onConfirm:F,onDraftPathChange:ee}),(0,X.jsx)(XE,{pendingDelete:C,onCancel:w,onConfirm:T}),(0,X.jsx)(ZE,{dialog:S,onCancel:P,onConfirm:N,onDraftChange:M}),(0,X.jsx)(ME,{title:d(`file.context_menu_title`),open:se&&ge.length>0,mode:s===`mobile`?`mobile`:`desktop`,sections:ge,anchorPoint:oe,restoreFocusTo:B?.triggerElement??null,onClose:ve})]})},qE=({workspaceId:e,node:t,variant:n,selectedPath:r,isContextTarget:i,onSelectFile:a,onOpenContextMenu:o,onBeginLongPress:s,onUpdateLongPress:c,onCancelLongPress:l,consumeSuppressedClick:u})=>{let d=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``,f=n===`mobile`?`mobile`:`search`;return(0,X.jsxs)(`div`,{className:`tree-item tree-item--file ${r===t.path?`selected`:``} ${i?`tree-item--context-target`:``}`,draggable:n===`desktop`?!0:void 0,onDragStart:n===`desktop`?r=>{n!==`desktop`||!r.dataTransfer||hC(r.dataTransfer,{workspaceId:e,path:t.path,kind:t.kind})}:void 0,onClick:()=>{u()||a(t.path)},onContextMenu:n===`desktop`?e=>o(e,t,f):void 0,onPointerDown:e=>s(e,t,f),onPointerMove:c,onPointerCancel:e=>l(e.pointerId),onPointerUp:e=>l(e.pointerId),style:{paddingLeft:12},children:[(0,X.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:NE(t,!1),size:14})}),(0,X.jsxs)(`span`,{className:`tree-search-labels`,children:[(0,X.jsx)(`span`,{className:`tree-label`,children:t.name}),d?(0,X.jsx)(`span`,{className:`tree-search-path`,children:d}):null]})]})},JE=({workspaceId:e,node:t,depth:n,variant:r,expandedDirs:i,defaultExpandedRootPaths:a,selectedPath:o,contextTargetPath:s,onRequestCreate:c,onSelectFile:l,onLoadChildren:u,onToggleDirs:d,isLoadingDir:f,onOpenContextMenu:p,onBeginLongPress:m,onUpdateLongPress:h,onCancelLongPress:g,consumeSuppressedClick:_})=>{let v=Z(),y=t.kind===`dir`,b=y&&(i===null?n===0&&a.includes(t.path):i.has(t.path)),x=(0,H.useRef)(!1);(0,H.useEffect)(()=>{t.children&&(x.current=!1)},[t.children]),(0,H.useEffect)(()=>{y&&b&&!t.children&&!x.current&&(x.current=!0,u(t.path))},[y,b,t.children,t.path,u]);let S=()=>{if(r===`mobile`&&_())return;if(!y){l(t.path);return}let e=new Set(i??a);b?e.delete(t.path):(e.add(t.path),t.children||u(t.path)),d(e)},C=n=>{r!==`desktop`||!n.dataTransfer||hC(n.dataTransfer,{workspaceId:e,path:t.path,kind:t.kind})},w=n*14+16;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`tree-item tree-item--${t.kind} ${o===t.path?`selected`:``} ${s===t.path?`tree-item--context-target`:``}`,draggable:r===`desktop`?!0:void 0,onDragStart:r===`desktop`?C:void 0,onClick:S,onContextMenu:r===`desktop`?e=>p(e,t,`tree`):void 0,onPointerDown:r===`mobile`?e=>m(e,t,`mobile`):void 0,onPointerMove:r===`mobile`?h:void 0,onPointerCancel:r===`mobile`?e=>g(e.pointerId):void 0,onPointerUp:r===`mobile`?e=>g(e.pointerId):void 0,style:{paddingLeft:w},children:[(0,X.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`,children:y?b?(0,X.jsx)(_i,{size:14}):(0,X.jsx)(yi,{size:14}):null}),(0,X.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:NE(t,b),size:14})}),(0,X.jsx)(`span`,{className:`tree-label`,children:t.name}),r===`desktop`?(0,X.jsx)(`div`,{className:`tree-item-actions`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ig,{content:v(`file.new_file`),children:(0,X.jsx)(Em,{"aria-label":`${v(`file.new_file`)} ${t.path}`,className:`git-row-action`,icon:(0,X.jsx)($,{semantic:`file.action.new`,size:12}),onClick:e=>{e.stopPropagation(),c(`file`,t.path)},size:`sm`})}),(0,X.jsx)(Ig,{content:v(`file.new_folder`),children:(0,X.jsx)(Em,{"aria-label":`${v(`file.new_folder`)} ${t.path}`,className:`git-row-action`,icon:(0,X.jsx)($,{semantic:`file.action.newFolder`,size:12}),onClick:e=>{e.stopPropagation(),c(`folder`,t.path)},size:`sm`})})]}):null}):null]}),y&&b&&t.children&&(0,X.jsxs)(`div`,{className:`tree-children`,children:[tD(t.children).map(t=>(0,X.jsx)(JE,{workspaceId:e,node:t,depth:n+1,variant:r,expandedDirs:i,selectedPath:o,contextTargetPath:s,onRequestCreate:c,onSelectFile:l,onLoadChildren:u,onToggleDirs:d,defaultExpandedRootPaths:a,isLoadingDir:f,onOpenContextMenu:p,onBeginLongPress:m,onUpdateLongPress:h,onCancelLongPress:g,consumeSuppressedClick:_},t.path)),t.children.length===0&&!f&&(0,X.jsx)(VE,{className:`tree-empty-hint`,title:v(`file.empty_directory`)})]}),y&&b&&!t.children&&f===t.path&&(0,X.jsx)(VE,{className:`tree-loading`,title:v(`common.loading`)})]})},YE=({dialog:e,onCancel:t,onConfirm:n,onDraftPathChange:r})=>{let i=Z(),a=(0,H.useRef)(null);if(!e)return null;let o=`file-path-helper`,s=e.error?`file-path-error`:void 0,c=e.mode===`file`?i(`file.path_helper_file`):i(`file.path_helper_folder`),l=[o,s].filter(Boolean).join(` `);return(0,X.jsxs)(jm,{initialFocus:()=>a.current,onOpenChange:t,open:!0,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsxs)(Pm,{children:[e.mode===`file`?(0,X.jsx)($,{"aria-hidden":`true`,semantic:`file.action.new`,size:16}):(0,X.jsx)($,{"aria-hidden":`true`,semantic:`file.action.newFolder`,size:16}),(0,X.jsx)(`span`,{children:e.mode===`file`?i(`file.new_file`):i(`file.new_folder`)})]}),(0,X.jsx)(Em,{"aria-label":i(`action.close`),icon:(0,X.jsx)(pa,{size:14}),onClick:t,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`file-path`,children:i(`file.path`)}),(0,X.jsx)(rh,{id:`file-path`,ref:a,value:e.draftPath,onChange:e=>r(e.target.value),placeholder:e.mode===`file`?`src/demo/new-file.ts`:`src/demo/new-folder`,"aria-describedby":l,invalid:!!e.error,autoFocus:!0}),(0,X.jsx)(`span`,{id:o,className:`dialog-helper`,children:c}),e.error?(0,X.jsx)(`span`,{id:s,className:`form-error`,role:`alert`,children:e.error}):null]})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:t,children:i(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{n()},children:i(`action.confirm`)})]})]})},XE=({pendingDelete:e,onCancel:t,onConfirm:n})=>{let r=Z();return e?(0,X.jsx)(Bm,{open:!0,onOpenChange:t,title:r(`file.delete`),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`file.delete_confirm`,{name:e.name})}),e.error?(0,X.jsx)(`span`,{className:`form-error`,role:`alert`,children:e.error}):null]}),cancelText:r(`action.cancel`),closeLabel:r(`action.close`),confirmText:r(`action.confirm`),onConfirm:()=>{n()},tone:`danger`}):null},ZE=({dialog:e,onCancel:t,onConfirm:n,onDraftChange:r})=>{let i=Z(),a=(0,H.useRef)(null);if(!e)return null;let o=`file-rename-helper`,s=e.error?`file-rename-error`:void 0,c=[o,s].filter(Boolean).join(` `);return(0,X.jsxs)(jm,{initialFocus:()=>a.current,onOpenChange:t,open:!0,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsx)(Pm,{children:(0,X.jsx)(`span`,{children:i(`file.rename`)})}),(0,X.jsx)(Em,{"aria-label":i(`action.close`),icon:(0,X.jsx)(pa,{size:14}),onClick:t,size:`sm`})]}),(0,X.jsx)(Fm,{children:(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`file-rename`,children:i(`file.rename_name`)}),(0,X.jsx)(rh,{id:`file-rename`,ref:a,value:e.nextName,onChange:e=>r(e.target.value),"aria-describedby":c,invalid:!!e.error,autoFocus:!0}),(0,X.jsx)(`span`,{id:o,className:`dialog-helper`,children:i(`file.rename_helper`)}),e.error?(0,X.jsx)(`span`,{id:s,className:`form-error`,role:`alert`,children:e.error}):null]})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:t,children:i(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{n()},children:i(`action.confirm`)})]})]})};function QE(e){return e.trim().replace(/^\.\/+/,``).replace(/\/+$/,``)}function $E(e){return e.reduce((e,t)=>t.kind===`file`?e+1:e+$E(t.children??[]),0)}function eD(e){let t=n=>n.map(n=>n.kind===`dir`&&e.has(n.path)?{...n,children:t(e.get(n.path))}:n);return t(e.get(`.`)??[])}function tD(e){return[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`dir`?-1:1)}function nD({workspaceId:e,onSelectFile:t,title:n}){let r=Z(),i=U(l_(e)),a=U(u_(e)),o=W(d_(e)),{openLocation:s}=Cy(e),{closeAll:c,closePath:l}=zw(e),[u,d]=(0,H.useState)(!1),[,f]=(0,H.useState)(0);(0,H.useEffect)(()=>{let t=Fw(e,()=>f(e=>e+1));return f(e=>e+1),t},[e]);let p=a&&!(a in i)&&Nw(e,a)?a:null,m=p?[...Iw(i),p].sort():Iw(i),h=n??r(`workspace.sidebar.open_editors`),g=r(`workspace.open_editors.title_with_count`,{count:m.length,title:h}),_=m.length>0,v=_&&!u,y=r(v?`workspace.open_editors.collapse_label`:`workspace.open_editors.expand_label`);return(0,X.jsxs)(`section`,{className:`workspace-sidebar-section`,children:[(0,X.jsxs)(`div`,{className:`workspace-open-editors__header`,children:[(0,X.jsxs)(`div`,{className:`workspace-open-editors__header-main`,children:[(0,X.jsx)(Ig,{content:y,children:(0,X.jsx)(Em,{"aria-label":y,"aria-expanded":_?v:void 0,className:`workspace-open-editors__toggle`,disabled:!_,icon:v?(0,X.jsx)(_i,{size:14}):(0,X.jsx)(yi,{size:14}),size:`sm`,onClick:()=>d(e=>!e)})}),(0,X.jsx)(`h2`,{className:`workspace-sidebar-section__title workspace-open-editors__title`,children:(0,X.jsx)(`span`,{className:`workspace-open-editors__title-text`,children:g})})]}),(0,X.jsx)(`button`,{type:`button`,className:`workspace-open-editors__close-all`,disabled:m.length===0,onClick:()=>c(),children:r(`action.close_all`)})]}),v?(0,X.jsx)(`div`,{className:`workspace-open-editors`,children:m.map(n=>(0,X.jsxs)(`div`,{className:`workspace-open-editors__row`,children:[(0,X.jsx)(`button`,{type:`button`,className:`workspace-open-editors__item ${a===n?`workspace-open-editors__item--active`:``}`,"aria-current":a===n?`true`:void 0,"aria-label":n,title:n,onClick:()=>{o(c_(n)),s({workspaceId:e,path:n,source:`manual`}),t?.(n)},children:(0,X.jsx)(`span`,{className:`workspace-open-editors__item-label`,children:n})}),(0,X.jsx)(Ig,{content:r(`action.close`),children:(0,X.jsx)(Em,{"aria-label":r(`workspace.open_editors.close_path`,{path:n}),className:`workspace-open-editors__item-close`,icon:(0,X.jsx)(pa,{size:14}),size:`sm`,onClick:()=>l(n)})})]},n))}):null]})}function rD({onOpenFileCreate:e,onOpenFolderCreate:t,onCollapseAll:n}){let r=Z();return(0,X.jsxs)(`div`,{className:`workspace-sidebar-section__header`,children:[(0,X.jsx)(`h2`,{className:`workspace-sidebar-section__title`,children:r(`workspace.sidebar.workspace`)}),(0,X.jsxs)(`div`,{className:`workspace-sidebar-panel__actions workspace-sidebar-section__actions`,children:[(0,X.jsx)(Ig,{content:r(`file.new_file`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":r(`file.new_file`),icon:(0,X.jsx)($,{semantic:`file.action.new`,size:14}),onClick:e,size:`sm`})}),(0,X.jsx)(Ig,{content:r(`file.new_folder`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":r(`file.new_folder`),icon:(0,X.jsx)($,{semantic:`file.action.newFolder`,size:14}),onClick:t,size:`sm`})}),(0,X.jsx)(Ig,{content:r(`file.collapse_all`),children:(0,X.jsx)(Em,{className:`panel-toolbar-btn`,"aria-label":r(`file.collapse_all`),icon:(0,X.jsx)(xi,{size:14}),onClick:n,size:`sm`})})]})]})}var iD=({workspaceId:e,createRequest:t,onCreateRequestConsumed:n,onOpenFileCreate:r,onOpenFolderCreate:i})=>{let a=Z(),[o,s]=(0,H.useState)(0);return(0,X.jsxs)(`div`,{className:`workspace-sidebar-view`,children:[(0,X.jsx)(aS,{title:a(`workspace.sidebar.explorer`)}),(0,X.jsxs)(`div`,{className:`workspace-sidebar-panel__body workspace-sidebar-panel__body--stacked`,children:[(0,X.jsx)(nD,{workspaceId:e}),(0,X.jsxs)(`section`,{className:`workspace-sidebar-section workspace-sidebar-section--fill`,children:[(0,X.jsx)(rD,{onOpenFileCreate:r,onOpenFolderCreate:i,onCollapseAll:()=>s(e=>e+1)}),(0,X.jsx)(KE,{workspaceId:e,createRequest:t,onCreateRequestConsumed:n,collapseVersion:o,variant:`desktop`,showSearch:!1})]})]})]})};function aD(e){return e?.source===`commit`}var oD=180*1e3,sD={push:`git.operation_push`,pull:`git.operation_pull`,fetch:`git.operation_fetch`};function cD(e,t){return e&&t?`${e}/${t}`:null}function lD(e){let t=Z(),n=U(Op),r=W(sy),i=W(p_(e)),a=W(g_(e)),o=W($g(e)),s=W(b_(e)),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=(0,H.useCallback)(e=>e.canPrompt?e.reason===`invalid_credentials`?t(`git.auth_failed_invalid`,{remote:e.remoteLabel}):e.reason===`authorization_failed`?t(`git.auth_failed_forbidden`,{remote:e.remoteLabel,operation:t(sD[e.operation])}):t(`git.auth_required_message`,{remote:e.remoteLabel}):t(`git.auth_failed_unsupported`,{remote:e.remoteLabel}),[t]),p=(0,H.useCallback)((e,n,r)=>{if(e===`git.fetch`)return n.message||r;let i=cD(n.remote,n.branch);return i?e===`git.push`?n.updated?t(`git.push_success_target`,{target:i}):t(`git.sync_up_to_date`,{target:i}):n.updated?t(`git.pull_success_target`,{target:i}):t(`git.sync_up_to_date`,{target:i}):n.message||r},[t]),m=(0,H.useCallback)(async()=>{if(!e)return!1;let[t,r]=await Promise.all([n(`git.branches`,{workspaceId:e}),n(`git.status`,{workspaceId:e})]);return t.ok&&t.data?a({current:t.data.current,branches:t.data.branches,loading:!1}):a(e=>({...e,loading:!1})),r.ok&&r.data&&i(r.data),t.ok&&r.ok},[n,a,i,e]),h=(0,H.useCallback)(async(i,a)=>{if(!e)return!1;let c=i===`git.fetch`;c?(s(e=>({...e,status:`fetching`,error:void 0})),l(`fetch`)):l(i===`git.push`?`push`:`pull`);try{let l=await n(i,{workspaceId:e,...a.auth?{auth:a.auth}:{}},{timeoutMs:oD});if(!l.ok||!l.data?.success){let e=l.error?.message??l.data?.message;if((l.error?.code===`git_auth_required`||l.error?.code===`git_auth_failed`)&&l.error.details&&typeof l.error.details==`object`){c&&s(t=>({...t,status:`error`,error:e}));let t=l.error.details,n=i===`git.push`?`push`:i===`git.pull`?`pull`:`fetch`;return d({intent:n,details:{...t,usernameHint:u?.intent===n?u.details.usernameHint:t.usernameHint}}),!1}return a.auth&&d(null),c&&s(t=>({...t,status:`error`,error:e})),r({kind:`error`,title:a.errorTitle,body:e}),console.error(`Failed to run ${i}:`,e),!1}if(!await m()&&c){let e=t(`git.fetch_refresh_failed_body`);return s(t=>({...t,status:`error`,error:e})),r({kind:`error`,title:a.errorTitle,body:e}),!1}return a.markFileTreeStale&&o(!0),c&&s({status:`idle`,lastFetchAt:Date.now()}),r({kind:`success`,title:a.successTitle,body:p(i,l.data,a.fallbackSuccessBody)}),!0}finally{l(null)}},[u,n,p,r,m,s,o,t,e]),g=(0,H.useCallback)(async e=>h(`git.push`,{successTitle:t(`git.push_success_title`),fallbackSuccessBody:t(`git.push_success_body`),errorTitle:t(`git.push_failed_title`),auth:e}),[h,t]),_=(0,H.useCallback)(async e=>h(`git.pull`,{successTitle:t(`git.pull_success_title`),fallbackSuccessBody:t(`git.pull_success_body`),errorTitle:t(`git.pull_failed_title`),markFileTreeStale:!0,auth:e}),[h,t]);return{authPrompt:u,clearAuthPrompt:()=>d(null),setAuthPrompt:d,getAuthPromptMessage:f,handleFetch:(0,H.useCallback)(async e=>h(`git.fetch`,{successTitle:t(`git.fetch_success_title`),fallbackSuccessBody:t(`git.fetch_success_body`),errorTitle:t(`git.fetch_failed_title`),auth:e}),[h,t]),handlePull:_,handlePush:g,refreshBranchState:m,syncingIntent:c}}function uD(e,t){let n=[{type:`staged`,changes:e.staged},{type:`modified`,changes:e.modified},{type:`deleted`,changes:e.deleted},{type:`untracked`,changes:e.untracked}];for(let e of n){let n=e.changes.find(e=>e.path===t);if(n)return{change:n,type:e.type}}return null}function dD({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,initialHistoryLimit:r=5}){let i=Z(),a=U(p_(e)),o=U(m_(e)),s=U(h_(e)),c=U(Op),l=W(sy),u=W(p_(e)),d=W(g_(e)),f=W(m_(e)),p=W(h_(e)),m=W(u_(e)),h=W(d_(e)),[g,_]=Te(v_(e)),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)([]),[S,C]=(0,H.useState)(r),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(null),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useCallback)(e=>{d({current:e?.current??``,branches:e?.branches??[],loading:!1})},[d]),j=(0,H.useCallback)(e=>{f(e)},[f]),M=(0,H.useCallback)(async(t,n)=>{let r=await c(`git.diff`,{workspaceId:e,path:t.path,staged:n===`staged`});if(!r.ok||!r.data)return console.error(`Failed to get diff:`,r.error?.message),null;let i={path:t.path,diff:r.data.diff,staged:n===`staged`,source:`file`,...r.data.renderAs?{renderAs:r.data.renderAs}:{},...r.data.status?{status:r.data.status}:{},...r.data.originalContent===void 0?{}:{originalContent:r.data.originalContent},...r.data.modifiedContent===void 0?{}:{modifiedContent:r.data.modifiedContent},...r.data.originalRevision?{originalRevision:r.data.originalRevision}:{},...r.data.modifiedRevision?{modifiedRevision:r.data.modifiedRevision}:{}};return p(!1),j(i),m(t.path),h(`diff`),i},[c,m,p,h,j,e]),N=(0,H.useCallback)(async t=>{let r=await c(`git.show`,{workspaceId:e,sha:t.sha});if(!r.ok||!r.data)return console.error(`Failed to get commit diff:`,r.error?.message),null;let i={path:t.sha,title:`${t.shortSha} · ${t.subject}`,diff:r.data.diff,source:`commit`};return p(!1),j(i),n?.(i),i},[c,n,p,j,e]),P=(0,H.useCallback)(async(e,t)=>{let r=await M(e,t);r&&n?.(r)},[n,M]),F=(0,H.useCallback)(async()=>{if(!e)return;d(e=>({...e,loading:!0,error:void 0}));let t=await c(`git.branches`,{workspaceId:e});if(!t.ok||!t.data){d(e=>({...e,loading:!1,error:t.error?.message??`Failed to load branches`})),console.error(`Failed to load git branches:`,t.error?.message);return}A(t.data)},[c,d,A,e]),ee=(0,H.useCallback)(async(t=S)=>{if(e){T(!0);try{let n=await c(`git.log`,{workspaceId:e,limit:t});if(!n.ok){console.error(`Failed to load git history:`,n.error?.message),x([]);return}x(Array.isArray(n.data?.entries)?n.data.entries:[])}finally{T(!1)}}},[c,S,e]),I=(0,H.useCallback)(async()=>{if(e){if(O.current){k.current=!0;return}O.current=!0,y(!0);try{let t=await c(`git.status`,{workspaceId:e});if(!t.ok||!t.data){console.error(`Failed to load git status:`,t.error?.message);return}if(u(t.data),s){j(null);return}if(aD(o)||!o)return;let n=uD(t.data,o.path);if(!n){j(null);return}!!o.staged!=(n.type===`staged`)&&await M(n.change,n.type)}finally{O.current=!1,y(!1),k.current&&(k.current=!1,queueMicrotask(()=>{I()}))}}},[o,s,c,M,u,j,e]);(0,H.useEffect)(()=>{!a&&!O.current&&I()},[a,I]),(0,H.useEffect)(()=>{F()},[F]),(0,H.useEffect)(()=>{ee(S)},[a?.headSha,S,ee]),(0,H.useEffect)(()=>{if(!a||s||aD(o)||!o)return;let e=uD(a,o.path);if(!e){j(null);return}!!o.staged!=(e.type===`staged`)&&M(e.change,e.type)},[o,s,a,M,j]),(0,H.useEffect)(()=>{t>0&&!O.current&&I()},[t,I]);let L=(0,H.useCallback)(async(e,t,n,r,i)=>{let a=await c(e,t);return a.ok?(i?.(),await I(),!0):(l({kind:`error`,title:r,body:a.error?.message??n}),console.error(n,a.error?.message),!1)},[c,I,l]),R=(0,H.useCallback)(async t=>{t.length!==0&&await L(`git.stage`,{workspaceId:e,paths:t},`Failed to stage all:`,i(`git.stage_failed_title`))},[L,i,e]),z=(0,H.useCallback)(async t=>{t.length!==0&&await L(`git.unstage`,{workspaceId:e,paths:t},`Failed to unstage all:`,i(`git.unstage_failed_title`))},[L,i,e]),te=(0,H.useCallback)(async()=>{await R([...a?.modified.map(e=>e.path)??[],...a?.deleted.map(e=>e.path)??[],...a?.untracked.map(e=>e.path)??[]])},[a,R]),ne=(0,H.useCallback)(async()=>{await z(a?.staged.map(e=>e.path)??[])},[a,z]),re=(0,H.useCallback)(()=>{let e=[...a?.staged.map(e=>e.path)??[],...a?.modified.map(e=>e.path)??[],...a?.deleted.map(e=>e.path)??[],...a?.untracked.map(e=>e.path)??[]];e.length&&D({scope:`all`,paths:e})},[a]),ie=(0,H.useCallback)(e=>{e.length&&D({scope:`all`,paths:e})},[]),ae=(0,H.useCallback)(e=>{D({scope:`single`,paths:[e],filePath:e})},[]),B=(0,H.useCallback)(()=>{D(null)},[]),oe=(0,H.useCallback)(async()=>{if(!E)return;let t=E;D(null),await L(`git.discard`,{workspaceId:e,paths:t.paths},t.scope===`all`?`Failed to discard all:`:`Failed to discard:`,i(`git.discard_failed_title`))},[E,L,i,e]),se=(0,H.useCallback)(async()=>{!g.trim()||!a?.staged.length||await L(`git.commit`,{workspaceId:e,message:g.trim()},`Failed to commit:`,i(`git.commit_failed_title`),()=>_(``))},[g,a?.staged.length,L,i,e]),ce=!!(a&&(a.staged.length>0||a.modified.length>0||a.untracked.length>0||a.deleted.length>0));return{commitMessage:g,diffPreview:o,gitState:a,groups:(0,H.useMemo)(()=>[{title:`staged`,changes:(a?.staged??[]).map(e=>({change:e,type:`staged`}))},{title:`changes`,changes:[...(a?.modified??[]).map(e=>({change:e,type:`modified`})),...(a?.deleted??[]).map(e=>({change:e,type:`deleted`})),...(a?.untracked??[]).map(e=>({change:e,type:`untracked`}))]}].filter(e=>e.changes.length>0),[a]),hasChanges:ce,history:b,historyLimit:S,historyLoading:w,isLoading:v,pendingDiscard:E,canShowMoreHistory:S<10&&b.length>0,setCommitMessage:_,handleCancelDiscard:B,handleCommit:se,handleConfirmDiscard:oe,handleDiscardAll:re,handleRequestDiscardPaths:ie,handleRequestDiscardSingle:ae,handleStageAll:te,handleStagePaths:R,handleUnstageAll:ne,handleUnstagePaths:z,loadGitStatus:I,loadGitHistory:ee,openDiff:P,openHistoryDiff:N,requestDiff:M,runGitMutation:L,showMoreHistory:()=>C(10),t:i}}function fD(e){let t=U(m_(e)),n=W(m_(e)),r=W(h_(e));return{closePreview:()=>{r(!0),n(null)},preview:t}}function pD(){let e=Z(),t=U(__),n=W(__),r=U(Op),i=W(sy),a=t.workspaceId,o=U(g_(a??``)),s=W(g_(a??``)),{refreshBranchState:c}=lD(a??``),[l,u]=(0,H.useState)(t.inputValue),[d,f]=(0,H.useState)(0),[p,m]=(0,H.useState)(null);(0,H.useEffect)(()=>{u(t.inputValue)},[t.inputValue]),(0,H.useEffect)(()=>{if(!t.visible||!a)return;if(o.branches.length>0){s(e=>({...e,loading:!1,error:void 0}));return}let e=!1;return s(e=>({...e,loading:!0,error:void 0})),r(`git.branches`,{workspaceId:a}).then(t=>{if(!e){if(!t.ok||!t.data){s(e=>({...e,loading:!1,error:t.error?.message??`Failed to load branches`})),console.error(`Failed to load git branches:`,t.error?.message);return}s({current:t.data.current,branches:t.data.branches,loading:!1})}}).catch(t=>{e||(s(e=>({...e,loading:!1,error:t instanceof Error?t.message:`Failed to load branches`})),console.error(`Failed to load git branches:`,t))}),()=>{e=!0}},[o.branches.length,r,t.visible,s,a]);let h=l.trim(),g=(0,H.useMemo)(()=>o.branches.filter(e=>(e.isCurrent||!e.linkedWorktreePath)&&e.name.toLowerCase().includes(l.toLowerCase())),[o.branches,l]),_=(0,H.useCallback)(e=>e.isCurrent||!e.linkedWorktreePath,[]),v=g.find(e=>e.name.toLowerCase()===l.toLowerCase()),y=(0,H.useMemo)(()=>{let t=[];return g.forEach(e=>{t.push({type:`branch`,branch:e,label:e.name})}),!v&&h&&!o.loading&&t.push({type:p===h?`confirm-create`:`create`,label:e(p===h?`git.quick_pick.confirm_create`:`git.quick_pick.create`,{name:h})}),t},[o.loading,v,g,p,e,h]),b=(0,H.useMemo)(()=>y.findIndex(e=>e.type===`branch`&&e.branch&&(e.branch.isCurrent||e.branch.name===o.current)),[o.current,y]);(0,H.useEffect)(()=>{if(t.visible){if(m(null),h){f(0);return}f(b>=0?b:0)}},[b,t.visible,h]);let x=(0,H.useCallback)(()=>{m(null),n({visible:!1,inputValue:``})},[n]),S=(0,H.useCallback)(e=>{e&&m(e)},[]),C=(0,H.useCallback)(async t=>{if(!a)return;let n=await r(`git.checkout`,{workspaceId:a,ref:t});if(!n.ok||!n.data?.success){let r=n.error?.message??n.data?.message;console.error(`Failed to checkout branch:`,r),i({kind:`error`,title:e(`git.quick_pick.checkout_failed_title`),body:r||e(`git.quick_pick.checkout_failed_body`,{name:t})});return}await c(),x()},[r,x,i,c,e,a]);return{branchList:o,displayItems:y,filteredBranches:g,handleBranchCreate:(0,H.useCallback)(async t=>{if(!a||!t)return;let n=await r(`git.checkout`,{workspaceId:a,ref:t,createBranch:!0});if(!n.ok||!n.data?.success){let r=n.error?.message??n.data?.message;console.error(`Failed to create branch:`,r),i({kind:`error`,title:e(`git.quick_pick.create_failed_title`),body:r||e(`git.quick_pick.create_failed_body`,{name:t})});return}await c(),x()},[r,x,i,c,e,a]),handleBranchSelect:C,handleClose:x,handleRequestBranchCreate:S,inputValue:l,isBranchSelectable:_,pendingCreateBranchName:p,quickPickState:t,selectedIndex:d,setInputValue:u,setPendingCreateBranchName:m,setSelectedIndex:f,trimmedInput:h}}function mD(e){return e.trim().replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}function hD(e,t){let n=e.trim(),r=n.replace(/[\\/]+$/,``)||n,i=n.includes(`\\`)?`\\`:`/`,a=/^([A-Za-z]:)([\\/]*)(.*)$/.exec(n),o=/^(\\\\|\/\/)([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]+(.*))?$/.exec(n),s=``,c=r;a?(s=`${a[1]}${i}`,c=a[3].replace(/[\\/]+$/,``).replace(/^[\\/]+/,``)):o?(s=`${o[1]}${o[2]}${i}${o[3]}${i}`,c=(o[4]??``).replace(/[\\/]+$/,``).replace(/^[\\/]+/,``)):(r.startsWith(`/`)||r.startsWith(`\\`))&&(s=r[0],c=r.replace(/^[\\/]+/,``));let l=c.split(/[\\/]+/).filter(Boolean),u=l.pop()??`worktree`,d=l.length>0?`${l.join(i)}${i}`:``,f=mD(t||`worktree`);return`${s}${d}${u}-${f}`}function gD(e){let t=e.trim();return t?/^[A-Za-z]:[\\/]+$/.test(t)?`${t.slice(0,2)}${t.includes(`\\`)?`\\`:`/`}`:t.replace(/[\\/]+$/,``)||t:``}function _D(e){return/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(e)}function vD(e){let t=Z(),n=U(Op),r=U(Ip(e)),[i,a]=Te(y_(e)),o=W(jp),s=W(Mp),c=W(Np),l=W(Pp),u=W(Fp),d=W(sy),f=Xg(),p=(0,H.useCallback)(async()=>{if(!e)return!1;a(e=>({...e,loading:!0,error:void 0}));let t=await n(`worktree.list`,{workspaceId:e});return!t.ok||!t.data?(a(e=>({...e,loading:!1,error:t.error?.message??`Failed to load worktrees`})),!1):(a({items:t.data.worktrees,loading:!1,lastLoadedAt:Date.now()}),!0)},[n,a,e]),m=(0,H.useCallback)(async(r,i)=>{let a=gD(i);if(!a||!_D(a)){let e=t(`worktree.create_path_absolute_required`);return d({kind:`error`,title:t(`worktree.create_failed_title`),body:e}),{ok:!1,error:e}}let o=await n(`worktree.create`,{workspaceId:e,branch:r,path:a});if(!o.ok||!o.data?.worktree){let e=o.error?.message??`Failed to create worktree`;return d({kind:`error`,title:t(`worktree.create_failed_title`),body:e}),{ok:!1,error:e}}return await p(),d({kind:`success`,title:t(`worktree.create_success_title`),body:t(`worktree.create_success_body`,{name:o.data.worktree.name})}),{ok:!0,worktree:o.data.worktree}},[n,p,d,t,e]),h=(0,H.useCallback)(async(r,i=!1)=>{let a=await n(`worktree.remove`,{workspaceId:e,worktreePath:r,force:i});if(!a.ok){let e=a.error?.message??`Failed to remove worktree`;return d({kind:`error`,title:t(`worktree.remove_failed_title`),body:e}),{ok:!1,error:e}}return await p(),d({kind:`success`,title:t(`worktree.remove_success_title`),body:t(`worktree.remove_success_body`)}),{ok:!0}},[n,p,d,t,e]),g=(0,H.useMemo)(()=>i.items.find(e=>e.path===r?.path)??null,[i.items,r?.path]),_=(0,H.useMemo)(()=>i.items.filter(e=>e.status===`dirty`).length,[i.items]),v=(0,H.useCallback)(e=>r?.path?hD(r.path,e):``,[r?.path]),y=(0,H.useCallback)(async e=>{let r=await n(`workspace.open`,{path:e});if(!r.ok||!r.data?.id){let e=r.error?.message??`Failed to open worktree`;return d({kind:`error`,title:t(`workspace.launch.open_failed`),body:e}),{ok:!1,error:e}}return o(r.data.id),s(e=>({...e,[r.data.id]:r.data})),c(e=>e.includes(r.data.id)?e:[r.data.id,...e]),l(`ready`),u(null),f({workspaceId:r.data.id}),{ok:!0,workspace:r.data}},[n,f,d,o,c,s,u,l,t]);return{createWorktree:m,currentWorktree:g,dirtyCount:_,hasWorkspace:!!r,list:i,loadWorktrees:p,openWorktree:y,removeWorktreeByPath:h,suggestedPathForBranch:v}}var yD={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},bD={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function xD({title:e}){return(0,X.jsx)(Sh,{className:`worktree-loading`,style:yD,title:(0,X.jsx)(`p`,{style:bD,children:e})})}function SD({workspaceId:e,worktree:t,mobile:n=!1}){let r=Z(),{activeTab:i,diff:a,error:o,handleTabChange:s,loading:c,status:l,tree:u}=qv(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:n?`mobile-worktree-sheet__summary`:void 0,children:(0,X.jsxs)(`div`,{className:`worktree-chips`,children:[(0,X.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,t.branch]}),(0,X.jsxs)(`span`,{className:`worktree-chip worktree-chip-path`,children:[`📁 `,t.path]}),(0,X.jsx)(`span`,{className:`worktree-chip worktree-chip-status ${t.status===`clean`?`worktree-clean`:`worktree-dirty`}`,children:t.status===`clean`?`✓ ${r(`worktree.clean`)}`:`● ${r(`worktree.dirty_status`)}`})]})}),(0,X.jsxs)(Rh,{"aria-label":r(`worktree.title`),onValueChange:e=>s(e),value:i,children:[(0,X.jsx)(zh,{className:`worktree-tabs${n?` mobile-worktree-sheet__tabs`:``}`,children:[`status`,`diff`,`tree`].map(e=>(0,X.jsx)(Bh,{className:`worktree-tab`,value:e,children:r(e===`status`?`worktree.status_tab`:e===`diff`?`worktree.diff_tab`:`worktree.tree_tab`)},e))}),(0,X.jsxs)(`div`,{className:n?`mobile-worktree-sheet__content`:void 0,children:[(0,X.jsxs)(Vh,{className:`worktree-content`,value:`status`,children:[o?(0,X.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,X.jsx)(xD,{title:r(`worktree.loading`)}):(0,X.jsxs)(`div`,{className:`worktree-status-tab`,children:[(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.path`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:t.path})]}),(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.branch`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:t.branch})]}),(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`git.latest_commit`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:l?.headShortSha||t.commit?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`code`,{children:l?.headShortSha??t.commit}),l?.headSubject?` ${l.headSubject}`:``]}):r(`git.no_commits`)})]}),(0,X.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,X.jsx)(`span`,{className:`worktree-info-label`,children:r(`label.status`)}),(0,X.jsx)(`span`,{className:`worktree-info-value`,children:t.status===`clean`?r(`worktree.clean`):r(`worktree.dirty`)})]}),l?(0,X.jsxs)(`div`,{className:`worktree-changes`,children:[(0,X.jsx)(`h4`,{children:r(`worktree.changes`)}),l.staged.length>0?(0,X.jsx)(`div`,{className:`worktree-change-group`,children:(0,X.jsx)(`span`,{children:r(`worktree.staged_count`,{count:l.staged.length})})}):null,l.modified.length>0?(0,X.jsx)(`div`,{className:`worktree-change-group`,children:(0,X.jsx)(`span`,{children:r(`worktree.modified_count`,{count:l.modified.length})})}):null,l.untracked.length>0?(0,X.jsx)(`div`,{className:`worktree-change-group`,children:(0,X.jsx)(`span`,{children:r(`worktree.untracked_count`,{count:l.untracked.length})})}):null]}):null]})]}),(0,X.jsxs)(Vh,{className:`worktree-content`,value:`diff`,children:[o?(0,X.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,X.jsx)(xD,{title:r(`worktree.loading`)}):(0,X.jsx)(`div`,{className:`worktree-diff-tab`,children:a?(0,X.jsx)(`pre`,{className:`worktree-diff-output`,children:a}):(0,X.jsx)(Sh,{className:`worktree-empty`,style:yD,title:(0,X.jsx)(`p`,{style:bD,children:r(`git.no_changes`)})})})]}),(0,X.jsxs)(Vh,{className:`worktree-content`,value:`tree`,children:[o?(0,X.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,X.jsx)(xD,{title:r(`worktree.loading`)}):(0,X.jsx)(`div`,{className:`worktree-tree-tab`,children:u.length>0?(0,X.jsx)(`div`,{className:`worktree-tree`,children:u.map(e=>(0,X.jsxs)(`div`,{className:`worktree-tree-node`,children:[(0,X.jsx)(`span`,{className:`worktree-tree-icon`,children:e.kind===`dir`?`📁`:`📄`}),(0,X.jsx)(`span`,{className:`worktree-tree-name`,children:e.name})]},e.path))}):(0,X.jsx)(Sh,{className:`worktree-empty`,style:yD,title:(0,X.jsx)(`p`,{style:bD,children:r(`worktree.empty_tree`)})})})]})]})]})]})}var CD={minHeight:`auto`,padding:`var(--sp-4) 0`,gap:0},wD={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function TD({title:e}){return(0,X.jsx)(Sh,{className:`worktree-loading`,style:CD,title:(0,X.jsx)(`p`,{style:wD,children:e})})}function ED({workspaceId:e,openView:t,onClose:n,desktopPreviewInline:r=!1}){let i=Br()===`mobile`,a=Z(),{createWorktree:o,currentWorktree:s,list:c,loadWorktrees:l,removeWorktreeByPath:u,suggestedPathForBranch:d}=vD(e),[f,p]=(0,H.useState)(`list`),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(``),[v,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(null),[O,k]=(0,H.useState)(null),A=(0,H.useRef)(!1),j=(0,H.useRef)(null),M=()=>{_(``),y(``),x(!1),T(null)};(0,H.useEffect)(()=>{if(!t){A.current=!1;return}A.current||(A.current=!0,k(null),D(null),C(null),h(null),t===`create`?(M(),p(`create`)):p(`list`),!c.lastLoadedAt&&!c.loading&&l())},[c.lastLoadedAt,c.loading,l,t]),(0,H.useEffect)(()=>{f!==`create`||b||y(g.trim()?d(g):``)},[g,b,d,f]);let N=(0,H.useMemo)(()=>c.items.find(e=>e.path===m)??null,[c.items,m]),P=(0,H.useMemo)(()=>c.items.find(e=>e.path===S)??null,[S,c.items]);if((0,H.useEffect)(()=>{f===`detail`&&m&&!N&&(k(a(`worktree.selection_removed`)),h(null),p(`list`))},[N,m,a,f]),!t)return null;let F=f===`detail`&&N?N.name:a(f===`create`?`worktree.create_title`:`worktree.list_title`),ee=g.trim().length>0&&/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(v.trim()),I=`worktree-path-hint-${e}`,L=t===`create`,R=()=>{D(null),C(null),p(`list`)},z=()=>{M(),C(null),h(null),k(null),p(`create`)},te=()=>{P&&(D(null),u(P.path,P.status===`dirty`).then(e=>{if(e.ok){R();return}D(e.error)}))},ne=f===`detail`&&N?(0,X.jsx)(`div`,{className:i?`mobile-worktree-sheet`:void 0,children:(0,X.jsx)(SD,{workspaceId:e,worktree:N,mobile:i})}):f===`create`?(0,X.jsxs)(`form`,{className:`worktree-manager__form`,onSubmit:e=>{e.preventDefault(),T(null),o(g.trim(),v.trim()).then(e=>{if(e.ok){M(),L?n():p(`list`);return}T(e.error)})},children:[w?(0,X.jsx)(`div`,{className:`worktree-error`,children:w}):null,(0,X.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,X.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-branch-${e}`,children:a(`worktree.branch`)}),(0,X.jsx)(rh,{id:`worktree-branch-${e}`,ref:j,value:g,onChange:e=>_(e.target.value),placeholder:`feature/worktree-manager`,autoFocus:!0})]}),(0,X.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,X.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-path-${e}`,children:a(`worktree.path`)}),(0,X.jsx)(rh,{id:`worktree-path-${e}`,value:v,onChange:e=>{x(!0),y(e.target.value)},placeholder:`/home/spencer/workspace/coder-studio-feature-worktree-manager`,"aria-describedby":I}),(0,X.jsx)(`span`,{id:I,className:`worktree-manager__field-hint`,children:a(`worktree.create_path_hint`)})]}),(0,X.jsxs)(`div`,{className:`worktree-manager__form-actions`,children:[(0,X.jsx)(Q,{variant:`secondary`,onClick:()=>{L?n():p(`list`)},children:a(`action.cancel`)}),(0,X.jsx)(Q,{type:`submit`,variant:`primary`,disabled:!ee,children:a(`worktree.create_submit`)})]})]}):f===`confirm-delete`&&P?(0,X.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[E?(0,X.jsx)(`div`,{className:`worktree-error`,children:E}):null,(0,X.jsx)(`p`,{children:P.status===`dirty`?a(`worktree.remove_force_confirm`):a(`worktree.remove_confirm`)}),(0,X.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:P.path}),(0,X.jsxs)(`div`,{className:`worktree-manager__confirm-actions`,children:[(0,X.jsx)(Q,{variant:`secondary`,onClick:R,children:a(`action.cancel`)}),(0,X.jsx)(Q,{variant:`danger`,onClick:()=>{te()},children:P.status===`dirty`?a(`worktree.force_remove`):a(`common.delete`)})]})]}):(0,X.jsxs)(`div`,{className:`worktree-manager__list`,children:[O?(0,X.jsx)(`div`,{className:`worktree-error`,children:O}):null,c.error?(0,X.jsxs)(`div`,{className:`worktree-error`,children:[(0,X.jsx)(`div`,{children:c.error}),(0,X.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>void l(),children:a(`action.refresh`)})]}):null,c.loading&&c.items.length===0?(0,X.jsx)(TD,{title:a(`worktree.loading`)}):c.error&&c.items.length===0?null:c.items.length===0?(0,X.jsx)(Sh,{className:`worktree-empty`,style:CD,title:(0,X.jsx)(`p`,{style:wD,children:a(`worktree.list_empty`)})}):c.items.map((e,t)=>{let n=s?.path===e.path,r=t===0;return(0,X.jsxs)(`div`,{className:`worktree-manager__row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`worktree-manager__row-main`,onClick:()=>{k(null),h(e.path),p(`detail`)},children:[(0,X.jsx)(`span`,{className:`worktree-manager__row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`worktree-manager__meta`,children:[(0,X.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,e.branch]}),(0,X.jsx)(`span`,{className:`worktree-chip worktree-chip-status ${e.status===`clean`?`worktree-clean`:`worktree-dirty`}`,children:e.status===`clean`?a(`worktree.clean`):a(`worktree.dirty_status`)}),n?(0,X.jsx)(`span`,{className:`worktree-chip`,children:a(`worktree.current`)}):null]}),(0,X.jsx)(`span`,{className:`worktree-manager__row-path`,children:e.path})]}),!n&&!r?(0,X.jsx)(Q,{"aria-label":a(`worktree.remove_row_label`,{name:e.name}),size:`sm`,variant:`ghost`,onClick:()=>{D(null),C(e.path),p(`confirm-delete`)},children:a(`common.delete`)}):null]},e.path)})]});return!i&&f===`confirm-delete`&&P?(0,X.jsx)(Bm,{open:!0,className:`worktree-manager-surface`,title:a(`common.delete`),description:(0,X.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[E?(0,X.jsx)(`div`,{className:`worktree-error`,children:E}):null,(0,X.jsx)(`p`,{children:P.status===`dirty`?a(`worktree.remove_force_confirm`):a(`worktree.remove_confirm`)}),(0,X.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:P.path})]}),cancelText:a(`action.cancel`),closeLabel:a(`action.close`),confirmText:P.status===`dirty`?a(`worktree.force_remove`):a(`common.delete`),onOpenChange:e=>{e||R()},onConfirm:te,tone:`danger`}):i?(0,X.jsx)(fm,{kicker:a(`worktree.title`).toUpperCase(),title:F,body:(0,X.jsx)(`div`,{className:`worktree-manager-surface`,children:ne}),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`mobile-sheet--worktree`,onBack:f===`list`?void 0:()=>{L?n():p(`list`)},headerAction:f===`list`?(0,X.jsx)(Q,{size:`sm`,variant:`primary`,onClick:z,children:a(`worktree.new`)}):void 0,onClose:n}):r?(0,X.jsxs)(`div`,{className:`drawer-panel worktree-manager-surface worktree-manager-surface--inline-preview`,children:[(0,X.jsxs)(`div`,{className:`drawer-header`,children:[(0,X.jsx)(`div`,{className:`worktree-header-info`,children:(0,X.jsx)(`h2`,{className:`drawer-title`,children:F})}),(0,X.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[f===`list`?(0,X.jsx)(Q,{size:`sm`,variant:`primary`,onClick:z,children:a(`worktree.new`)}):L?null:(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>{L?n():p(`list`)},children:a(`action.back`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:n,children:a(`action.close`)})]})]}),(0,X.jsx)(`div`,{className:`drawer-body`,children:ne})]}):(0,X.jsxs)(jm,{className:`worktree-manager-surface`,dismissible:!1,initialFocus:()=>f===`create`?j.current:null,onOpenChange:e=>{e||n()},open:!0,size:`lg`,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsx)(Pm,{children:F}),(0,X.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[f===`list`?(0,X.jsx)(Q,{size:`sm`,variant:`primary`,onClick:z,children:a(`worktree.new`)}):L?null:(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>{L?n():p(`list`)},children:a(`action.back`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:n,children:a(`action.close`)})]})]}),(0,X.jsx)(Fm,{children:ne})]})}var DD={minHeight:`auto`,padding:`12px 0`,gap:`4px`},OD={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`};function kD({title:e,action:t}){return(0,X.jsx)(Sh,{action:t,className:`git-panel-empty`,style:DD,title:(0,X.jsx)(`p`,{style:OD,children:e})})}function AD(e){return e?{staged:!1,changes:!0}:{staged:!1,changes:!1}}function jD(e){return{pendingWorktreeDeletePath:null,worktreeSurfaceView:null,worktreesExpanded:!1,historyExpanded:!1,collapsedGroups:AD(e)}}function MD(e,t){return`${e}::${t}`}var ND=Ap(e=>V(jD(e.endsWith(`::mobile`)))),PD=({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,variant:r=`desktop`})=>{let i=r===`mobile`,[a,o]=Te(ND(MD(e,r))),s=U(Za)===`zh`?`zh`:`en`,c=Z(),{commitMessage:l,diffPreview:u,gitState:d,groups:f,history:p,historyLoading:m,isLoading:h,pendingDiscard:g,setCommitMessage:_,handleCancelDiscard:v,handleCommit:y,handleConfirmDiscard:b,handleRequestDiscardPaths:x,handleRequestDiscardSingle:S,handleStagePaths:C,handleUnstagePaths:w,openHistoryDiff:T,openDiff:E,runGitMutation:D}=dD({workspaceId:e,refreshToken:t,onPreviewOpen:n,initialHistoryLimit:20}),{currentWorktree:O,hasWorkspace:k,list:A,loadWorktrees:j,openWorktree:M,removeWorktreeByPath:N}=vD(e),P=(0,H.useRef)(!1),{collapsedGroups:F,historyExpanded:ee,pendingWorktreeDeletePath:I,worktreeSurfaceView:L,worktreesExpanded:R}=a,z=(0,H.useMemo)(()=>A.items.find(e=>e.path===I)??null,[A.items,I]);(0,H.useEffect)(()=>{P.current=!1},[e]),(0,H.useEffect)(()=>{if(!k){P.current=!1;return}A.lastLoadedAt||A.loading||P.current||(P.current=!0,j())},[k,A.lastLoadedAt,A.loading,j]);let te=d?.staged.length??0,ne=!!l.trim()&&te>0,re=async e=>{O?.path!==e.path&&await M(e.path)},ie=()=>{o(e=>({...e,pendingWorktreeDeletePath:null}))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`git-panel git-panel--${r}`,children:(0,X.jsxs)(`div`,{className:`git-panel-scroll`,children:[(0,X.jsxs)(`section`,{className:`git-commit-block`,children:[(0,X.jsx)(Cg,{className:`git-commit-input`,placeholder:c(`git.commit_summary_placeholder`),value:l,onChange:e=>_(e.target.value),rows:3,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),y())}}),(0,X.jsx)(`div`,{className:`git-commit-actions`,children:(0,X.jsx)(Ig,{content:c(ne?`git.commit`:`git.nothing_staged`),children:(0,X.jsxs)(`button`,{className:`git-commit-primary`,onClick:()=>void y(),disabled:!ne,type:`button`,children:[(0,X.jsx)(`span`,{children:c(`git.commit`)}),(0,X.jsx)($,{semantic:`git.commit`,size:14})]})})})]}),(0,X.jsxs)(`section`,{className:`git-panel-section`,children:[(0,X.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>o(e=>({...e,worktreesExpanded:!e.worktreesExpanded})),"aria-expanded":R,children:[(0,X.jsx)(`span`,{children:c(`worktree.list_title`)}),(0,X.jsx)(`span`,{className:`git-panel-section-count`,children:A.items.length}),(0,X.jsx)(`span`,{className:`git-panel-section-chevron ${R?`expanded`:``}`,children:(0,X.jsx)(_i,{size:14})})]}),(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>o(e=>({...e,worktreeSurfaceView:`create`})),children:[(0,X.jsx)($,{semantic:`worktree.action.new`,size:12}),(0,X.jsx)(`span`,{children:c(`worktree.new`)})]})]}),R?(0,X.jsx)(`div`,{className:`git-panel-section-body`,children:A.loading&&A.items.length===0?(0,X.jsx)(kD,{title:c(`worktree.loading`)}):A.error?(0,X.jsx)(kD,{action:(0,X.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void j(),children:c(`action.refresh`)}),title:A.error}):A.items.length===0?(0,X.jsx)(kD,{title:c(`worktree.list_empty`)}):A.items.map((e,t)=>{let n=O?.path===e.path,r=!n&&t!==0;return(0,X.jsxs)(`div`,{className:`git-worktree-row ${n?`active`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`git-worktree-row__main`,onClick:()=>void re(e),children:[(0,X.jsx)(`span`,{className:`git-worktree-row__dot git-worktree-row__dot-${e.status}`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`git-worktree-row__name`,children:e.name}),(0,X.jsxs)(`span`,{className:`git-worktree-row__tail`,children:[(0,X.jsx)(`span`,{className:`git-worktree-row__status`,children:e.status===`clean`?c(`worktree.clean`):c(`worktree.dirty_status`)}),n?(0,X.jsx)(`span`,{className:`git-worktree-row__chip`,children:c(`worktree.current`)}):null]})]}),r?(0,X.jsx)(Em,{"aria-label":c(`worktree.remove_row_label`,{name:e.name}),className:`git-worktree-row__delete`,icon:(0,X.jsx)(ua,{size:12}),onClick:()=>o(t=>({...t,pendingWorktreeDeletePath:e.path})),size:`sm`,variant:`ghost`}):null]},e.path)})}):null]}),(0,X.jsx)(`div`,{className:`git-panel-groups`,children:d&&f.length>0?f.map(t=>(0,X.jsx)(FD,{title:t.title,changes:t.changes,mobile:i,collapsed:F[t.title]??!1,selectedPath:u?.path??null,onToggleCollapsed:()=>o(e=>({...e,collapsedGroups:{...e.collapsedGroups,[t.title]:!(e.collapsedGroups[t.title]??!1)}})),onStageAll:async()=>{if(t.title===`staged`){await w(t.changes.map(({change:e})=>e.path));return}await C(t.changes.map(({change:e})=>e.path))},onDiscardAll:()=>x(t.changes.map(({change:e})=>e.path)),onViewDiff:E,onRunMutation:D,onRequestDiscard:S,workspaceId:e},t.title)):(0,X.jsx)(kD,{title:c(h?`common.loading`:`git.no_changes`)})}),(0,X.jsxs)(`section`,{className:`git-panel-section git-panel-section-history`,children:[(0,X.jsx)(`div`,{className:`git-panel-section-header`,children:(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>o(e=>({...e,historyExpanded:!e.historyExpanded})),"aria-expanded":ee,children:[(0,X.jsx)(`span`,{children:c(`git.history`)}),(0,X.jsx)(`span`,{className:`git-panel-section-chevron ${ee?`expanded`:``}`,children:(0,X.jsx)(_i,{size:14})})]})}),ee?(0,X.jsx)(`div`,{className:`git-panel-section-body`,children:m&&p.length===0?(0,X.jsx)(kD,{title:c(`common.loading`)}):p.length===0?(0,X.jsx)(kD,{title:c(`git.no_commits`)}):p.map((e,t)=>(0,X.jsx)(LD,{entry:e,isCurrent:t===0,locale:s,onOpen:T},e.sha))}):null]})]})}),(0,X.jsx)(ED,{workspaceId:e,openView:L,onClose:()=>o(e=>({...e,pendingWorktreeDeletePath:null,worktreeSurfaceView:null}))}),z?(0,X.jsx)(Bm,{open:!0,title:c(`common.delete`),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:z.status===`dirty`?c(`worktree.remove_force_confirm`):c(`worktree.remove_confirm`)}),(0,X.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:z.path})]}),cancelText:c(`action.cancel`),closeLabel:c(`action.close`),confirmText:z.status===`dirty`?c(`worktree.force_remove`):c(`common.delete`),onOpenChange:e=>{e||ie()},onConfirm:()=>{N(z.path,z.status===`dirty`).then(e=>{e.ok&&ie()})},tone:`danger`}):null,(0,X.jsx)(RD,{discard:g,onCancel:v,onConfirm:b})]})},FD=({title:e,changes:t,collapsed:n,mobile:r,selectedPath:i,workspaceId:a,onDiscardAll:o,onRequestDiscard:s,onRunMutation:c,onStageAll:l,onToggleCollapsed:u,onViewDiff:d})=>{let f=Z(),p=e===`staged`?`git.staged`:`git.changes`,m=f(e===`staged`?`git.unstage_all`:`git.stage_all`);return(0,X.jsxs)(`section`,{className:`git-panel-section git-panel-section-changes`,children:[(0,X.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:u,"aria-expanded":!n,children:[(0,X.jsx)(`span`,{children:f(p)}),(0,X.jsx)(`span`,{className:`git-panel-section-count`,children:t.length}),(0,X.jsx)(`span`,{className:`git-panel-section-chevron ${n?``:`expanded`}`,children:(0,X.jsx)(_i,{size:14})})]}),(0,X.jsxs)(`div`,{className:`git-panel-section-actions`,children:[(0,X.jsx)(Ig,{content:m,children:(0,X.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void l(),children:m})}),e===`changes`?(0,X.jsx)(Ig,{content:f(`git.discard_all`),children:(0,X.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void o(),children:f(`git.discard_all`)})}):null]})]}),n?null:(0,X.jsx)(`div`,{className:`git-panel-section-body`,children:t.map(({change:e,type:t})=>(0,X.jsx)(ID,{change:e,type:t,mobile:r,workspaceId:a,selected:i===e.path,onViewDiff:d,onRunMutation:c,onRequestDiscard:s},`${t}:${e.path}`))})]})},ID=({change:e,type:t,mobile:n,workspaceId:r,selected:i,onViewDiff:a,onRunMutation:o,onRequestDiscard:s})=>{let c=Z(),l=(0,H.useMemo)(()=>e.path.split(`/`),[e.path]),u=l[l.length-1]??e.path,d=l.length>1?`${l.slice(0,-1).join(`/`)}/`:``,f=c(t===`staged`?`git.unstage`:`git.stage`),p=c(`git.discard`),m=t===`staged`?(0,X.jsx)(qi,{size:12}):(0,X.jsx)(ea,{size:12}),h=BD(e,t),g=async()=>{if(t===`staged`){await o(`git.unstage`,{workspaceId:r,paths:[e.path]},`Failed to unstage:`,c(`git.unstage_failed_title`));return}await o(`git.stage`,{workspaceId:r,paths:[e.path]},`Failed to stage:`,c(`git.stage_failed_title`))};return(0,X.jsxs)(`div`,{className:`git-row ${i?`active`:``} ${n?`mobile`:``}`,onClick:()=>void a(e,t),role:`button`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),a(e,t))},children:[(0,X.jsx)(`span`,{className:`git-row-icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:h,size:13})}),(0,X.jsxs)(`div`,{className:`git-row-content`,children:[(0,X.jsx)(`span`,{className:`git-row-name`,children:u}),(0,X.jsxs)(`span`,{className:`git-row-meta`,children:[d?(0,X.jsx)(`span`,{className:`git-row-dir`,children:d}):null,e.oldPath?(0,X.jsx)(`span`,{className:`git-row-rename`,children:e.oldPath}):null]})]}),(0,X.jsxs)(`div`,{className:`git-row-actions`,children:[(0,X.jsx)(Ig,{content:f,children:(0,X.jsx)(Em,{"aria-label":f,className:`git-row-action`,icon:m,onClick:e=>{e.stopPropagation(),g()},size:`sm`,type:`button`,variant:`ghost`})}),(0,X.jsx)(Ig,{content:p,children:(0,X.jsx)(Em,{"aria-label":p,className:`git-row-action`,icon:(0,X.jsx)(na,{size:12}),onClick:t=>{t.stopPropagation(),s(e.path)},size:`sm`,type:`button`,variant:`ghost`})})]})]})};function LD({entry:e,isCurrent:t,locale:n,onOpen:r}){return(0,X.jsxs)(`button`,{type:`button`,className:`git-history-row ${t?`current`:``}`,onClick:()=>void r(e),children:[(0,X.jsx)(`span`,{className:`git-history-row__dot`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`git-history-row__copy`,children:[(0,X.jsx)(Ig,{content:e.subject,children:(0,X.jsx)(`span`,{className:`git-history-row__title`,children:e.subject})}),(0,X.jsxs)(`span`,{className:`git-history-row__meta`,children:[e.shortSha,` · `,e.authorName]})]}),(0,X.jsx)(`span`,{className:`git-history-row__when`,children:um(e.authoredAt,n)})]})}var RD=({discard:e,onCancel:t,onConfirm:n})=>{let r=Z();return e?(0,X.jsx)(Bm,{open:!0,onOpenChange:t,title:e.scope===`all`?r(`git.discard_all_confirm_title`):r(`git.discard_file_confirm_title`),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:e.scope===`all`?r(`git.discard_all_confirm_message`,{count:e.paths.length}):r(`git.discard_file_confirm_message`,{path:e.filePath??e.paths[0]??``})}),(0,X.jsx)(`p`,{className:`dialog-helper`,children:r(`git.discard_confirm_irreversible`)})]}),cancelText:r(`action.cancel`),closeLabel:r(`action.close`),confirmText:r(`git.discard`),onConfirm:()=>{n()},tone:`danger`}):null};function zD(e,t){return e.status?e.status:t===`deleted`?`deleted`:t===`untracked`?`untracked`:`modified`}function BD(e,t){switch(zD(e,t)){case`deleted`:return`git.status.deleted`;case`untracked`:return`git.status.untracked`;default:return t===`staged`?`git.status.staged`:`git.status.modified`}}var VD=Ap(e=>V({query:``,retryNonce:0,resolvedQuery:``,resolvedRetryNonce:0,results:null,expandedFiles:{},loading:!1,error:!1}));function HD(e){let t=Math.max(0,e.previewColumnStart-1),n=Math.max(t,e.previewColumnEnd-1);return(0,X.jsxs)(X.Fragment,{children:[e.preview.slice(0,t),(0,X.jsx)(`mark`,{children:e.preview.slice(t,n)}),e.preview.slice(n)]})}function UD(e){return Object.fromEntries(e.files.map(e=>[e.path,!0]))}var WD=({workspaceId:e,variant:t=`desktop`,onSelectFile:n})=>{let r=Z(),i=U(Op),{openLocation:a}=Cy(e),o=W(d_(e)),s=(0,H.useRef)(null),c=(0,H.useRef)(i),l=(0,H.useId)(),[u,d]=Te(VD(e)),{error:f,expandedFiles:p,loading:m,query:h,resolvedQuery:g,resolvedRetryNonce:_,results:v,retryNonce:y}=u;(0,H.useEffect)(()=>{s.current?.focus()},[e]),(0,H.useEffect)(()=>{c.current=i},[i]),(0,H.useEffect)(()=>{let t=h.trim();if(!t){d(e=>e.results!==null||e.resolvedQuery||Object.keys(e.expandedFiles).length>0||e.loading||e.error?{...e,resolvedQuery:``,resolvedRetryNonce:e.retryNonce,results:null,expandedFiles:{},loading:!1,error:!1}:e);return}if(v&&!f&&g===t&&_===y)return;let n=!1;d(e=>({...e,loading:!0,error:!1}));let r=window.setTimeout(()=>{c.current(`file.searchContent`,{workspaceId:e,query:t,maxFiles:50,maxMatchesPerFile:20}).then(e=>{if(!n){if(!e.ok||!e.data){d(e=>({...e,results:null,expandedFiles:{},error:!0}));return}d(n=>({...n,resolvedQuery:t,resolvedRetryNonce:y,results:e.data,expandedFiles:UD(e.data)}))}}).catch(()=>{n||d(e=>({...e,results:null,expandedFiles:{},error:!0}))}).finally(()=>{n||d(e=>({...e,loading:!1}))})},250);return()=>{n=!0,window.clearTimeout(r)}},[h,y,d,e]);let b=(t,r,i,s)=>{o(c_(t)),a({workspaceId:e,path:t,line:r,column:i,endColumn:s,source:`search`}),n?.(t)};return(0,X.jsxs)(`div`,{className:`workspace-sidebar-view workspace-search-panel workspace-search-panel--${t}`,children:[t===`desktop`?(0,X.jsx)(aS,{title:r(`workspace.sidebar.search`)}):null,(0,X.jsxs)(`div`,{className:`workspace-search-panel__controls`,children:[(0,X.jsx)(`input`,{ref:s,type:`search`,"aria-label":r(`workspace.sidebar.search`),className:`workspace-search-panel__input`,value:h,onChange:e=>d(t=>({...t,query:e.target.value})),placeholder:r(`workspace.search.placeholder`)}),(0,X.jsx)(`div`,{className:`workspace-search-panel__summary`,children:m?r(`common.loading`):h.trim()?r(`workspace.search.results_count`,{count:v?.totalMatchCount??0,files:v?.files.length??0}):null}),v&&(v.hasMoreFiles||v.truncatedMatchFileCount>0)?(0,X.jsx)(`div`,{className:`workspace-search-panel__truncate-note`,children:r(`workspace.search.truncated`)}):null]}),(0,X.jsx)(`div`,{className:`workspace-search-panel__results`,children:f?(0,X.jsxs)(`div`,{className:`workspace-search-panel__state-block`,children:[(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`workspace.search.failed`)}),(0,X.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>d(e=>({...e,retryNonce:e.retryNonce+1})),children:r(`workspace.search.retry`)})]}):h.trim()?m?(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`common.loading`)}):!v||v.files.length===0?(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`workspace.search.no_results`)}):v.files.map((e,t)=>{let n=`${l}-group-${t}`,i=p[e.path]??!0;return(0,X.jsxs)(`section`,{className:`workspace-search-panel__group`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`workspace-search-panel__group-header`,onClick:()=>d(t=>({...t,expandedFiles:{...t.expandedFiles,[e.path]:!(t.expandedFiles[e.path]??!0)}})),"aria-expanded":i,"aria-controls":n,children:[(0,X.jsx)(`span`,{className:`workspace-search-panel__group-chevron`,"aria-hidden":`true`,children:i?(0,X.jsx)(_i,{size:14}):(0,X.jsx)(yi,{size:14})}),(0,X.jsxs)(`span`,{className:`workspace-search-panel__group-copy`,children:[(0,X.jsx)(`strong`,{className:`workspace-search-panel__group-name`,children:e.name}),(0,X.jsx)(`span`,{className:`workspace-search-panel__group-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`workspace-search-panel__group-count`,children:r(`workspace.search.file_match_count`,{count:e.matchCount,suffix:e.hasMoreMatches?`+`:``})})]}),(0,X.jsx)(`div`,{id:n,hidden:!i,className:`workspace-search-panel__matches`,children:i?e.matches.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`workspace-search-panel__match`,onClick:()=>b(e.path,t.line,t.column,t.endColumn),children:[(0,X.jsx)(`span`,{className:`workspace-search-panel__line`,children:t.line}),(0,X.jsx)(`span`,{className:`workspace-search-panel__preview`,children:HD(t)})]},`${e.path}:${t.line}:${t.column}`)):null})]},e.path)}):(0,X.jsx)(`p`,{className:`workspace-search-panel__state`,children:r(`workspace.search.empty`)})})]})},GD=({activeView:e,onSelectView:t})=>{let n=Z(),r=[{view:`explorer`,label:n(`workspace.sidebar.explorer`),icon:Ni},{view:`search`,label:n(`workspace.sidebar.search`),icon:ia},{view:`source-control`,label:n(`workspace.sidebar.source_control`),icon:Fi}];return(0,X.jsx)(`nav`,{className:`workspace-activity-bar`,"aria-label":n(`workspace.sidebar.label`),children:r.map(({view:n,label:r,icon:i})=>(0,X.jsxs)(`button`,{type:`button`,className:`workspace-activity-bar__button ${e===n?`workspace-activity-bar__button--active`:``}`,"aria-label":r,"aria-pressed":e===n,onClick:()=>t(n),children:[(0,X.jsx)(i,{size:18,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workspace-activity-bar__label`,children:r})]},n))})};function KD(e){return!e||e.updateStatus!==`succeeded`?null:e.targetVersion??e.latestVersion??e.currentVersion??null}function qD(){let e=Z(),t=Qt(),n=U(Op),r=U(Vy),i=W(Vy),a=W(Hy),o=W(sy),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=KD(r);(0,H.useEffect)(()=>{if(r?.updateStatus!==`succeeded`){f(!1);return}f(!1);let e=window.setTimeout(()=>{f(!0)},3e3);return()=>{window.clearTimeout(e)}},[p,r?.updateStatus]);let m=async(t,r)=>{u(`install`);let a=await n(`updates.startInstall`,{targetVersion:t.latestVersion??t.targetVersion??void 0,force:r});if(u(!1),c(null),!a.ok||!a.data){o({kind:`error`,title:e(`settings.about.update_now`),body:a.error?.message});return}i(a.data)},h=async()=>{u(`prepare`);let t=await n(`updates.prepareInstall`,{});if(u(!1),!t.ok||!t.data){o({kind:`error`,title:e(`settings.about.update_now`),body:t.error?.message});return}if(a(t.data),t.data.activity.hasActiveWork){c(t.data);return}await m(t.data,!1)},g=()=>{t(`/settings?section=about`)};if(!r)return null;let _=r.availability===`update_available`&&r.updateStatus===`idle`,v=r.updateStatus===`installing`||r.updateStatus===`restarting`||r.updateStatus===`failed`||r.updateStatus===`manual_required`||r.updateStatus===`succeeded`&&!d;return!_&&!v?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`footer-update-rail`,"data-testid":`footer-update-rail`,children:[_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_update_available`,{version:r.latestVersion?`v${r.latestVersion}`:``})}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,className:`footer-update-rail__action`,onClick:()=>{h()},disabled:l!==!1,children:e(`settings.about.update_now`)})]}):null,r.updateStatus===`installing`?(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_installing`)}):null,r.updateStatus===`restarting`?(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_restarting`)}):null,r.updateStatus===`failed`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_failed`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,className:`footer-update-rail__action`,onClick:g,children:e(`settings.about.footer_view_details`)})]}):null,r.updateStatus===`manual_required`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_manual_required`)}),(0,X.jsx)(Q,{size:`sm`,variant:`ghost`,className:`footer-update-rail__action`,onClick:g,children:e(`settings.about.footer_view_details`)})]}):null,r.updateStatus===`succeeded`&&!d&&p?(0,X.jsx)(`span`,{className:`footer-update-rail__text`,children:e(`settings.about.footer_succeeded`,{version:`v${p}`})}):null]}),s?(0,X.jsx)(Bm,{open:!0,onOpenChange:e=>{e||c(null)},title:e(`settings.about.confirm_update_title`),description:(0,X.jsxs)(`div`,{className:`settings-dialog-copy`,children:[(0,X.jsx)(`p`,{children:e(`settings.about.confirm_update_message`)}),(0,X.jsx)(`p`,{children:e(`settings.about.confirm_update_activity`,{terminals:s.activity.runningTerminalCount,sessions:s.activity.runningSessionCount,supervisors:s.activity.runningSupervisorCount})})]}),cancelText:e(`action.cancel`),confirmText:e(`settings.about.update_now`),tone:`danger`,onConfirm:()=>{m(s,!0)}}):null]})}function JD(e){return[...e].sort((e,t)=>e.split(`/`).length-t.split(`/`).length||e.localeCompare(t))}function YD(e){let t=Z(),n=U(Op),r=W(sy),i=U(t_(e)),a=W(p_(e)),o=W(g_(e)),s=W(y_(e)),c=W(Qg(e)),l=W(e_(e)),u=W(f_(e)),[d,f]=(0,H.useState)(`idle`),p=(0,H.useRef)(!1),m=(0,H.useRef)(!1);return{refreshWorkspace:(0,H.useCallback)(async()=>{if(!e)return!1;if(p.current)return m.current=!0,!1;p.current=!0,f(`refreshing`);try{do{m.current=!1;let d=[],[p,h,g,_]=await Promise.all([n(`git.branches`,{workspaceId:e}),n(`git.status`,{workspaceId:e}),n(`worktree.list`,{workspaceId:e}),n(`file.readTree`,{workspaceId:e})]);if(p.ok&&p.data?o({current:p.data.current,branches:p.data.branches,loading:!1}):d.push(`branches`),h.ok&&h.data?a(h.data):d.push(`git`),g.ok&&g.data?s({items:g.data.worktrees,loading:!1,lastLoadedAt:Date.now()}):d.push(`worktrees`),_.ok&&_.data){let e=new Map;e.set(`.`,_.data.children),c(e),l(new Set)}else d.push(`files`);if(_.ok&&_.data&&i&&i.size>0)for(let t of JD(i)){let r=await n(`file.readTree`,{workspaceId:e,subPath:t});if(!r.ok||!r.data){d.push(`files:${t}`);continue}c(e=>{let n=new Map(e??[]);return n.set(t,r.data.children),n}),l(e=>new Set(e).add(t))}u(e=>e+1),d.length>0?(f(`error`),r({kind:`warning`,title:t(`workspace.refresh_partial_title`),body:t(`workspace.refresh_partial_body`,{sections:d.join(`, `)})})):f(`idle`)}while(m.current);return!0}finally{p.current=!1,m.current||f(e=>e===`error`?`error`:`idle`)}},[n,i,r,o,u,c,a,l,s,t,e]),status:d}}var XD={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},ZD={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function QD({title:e}){return(0,X.jsx)(Sh,{className:`branch-quick-pick-empty`,style:XD,title:(0,X.jsx)(`p`,{style:ZD,children:e})})}function $D(){let e=Z(),{branchList:t,displayItems:n,handleBranchCreate:r,handleBranchSelect:i,handleClose:a,handleRequestBranchCreate:o,inputValue:s,isBranchSelectable:c,selectedIndex:l,setInputValue:u,setPendingCreateBranchName:d,setSelectedIndex:f,trimmedInput:p}=pD(),m=(0,H.useRef)(null),h=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{m.current?.focus()},0);return()=>{window.clearTimeout(e)}},[]),(0,H.useEffect)(()=>{h.current&&h.current.querySelector(`.branch-quick-pick-item:nth-child(${l+1})`)?.scrollIntoView({block:`nearest`})},[l]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`branch-quick-pick-search`,children:(0,X.jsx)(`input`,{ref:m,type:`text`,className:`branch-quick-pick-input`,placeholder:`Search branches or create new branch...`,value:s,onChange:e=>{u(e.target.value),d(null),f(0)},onKeyDown:e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),f(e=>e<n.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),f(e=>e>0?e-1:e);break;case`Enter`:if(e.preventDefault(),n[l]){let e=n[l];if(e.type===`branch`&&e.branch){if(!c(e.branch))return;i(e.branch.name)}else e.type===`create`?o(p):e.type===`confirm-create`&&r(p)}break;case`Escape`:e.preventDefault(),a();break}}})}),(0,X.jsx)(`div`,{className:`branch-quick-pick-list`,ref:h,children:t.loading?(0,X.jsx)(QD,{title:`Loading branches...`}):n.length>0?n.map((t,n)=>(0,X.jsx)(`div`,{className:`branch-quick-pick-item ${n===l?`branch-quick-pick-item-selected`:``}`,onClick:()=>{if(t.type===`branch`&&t.branch){if(!c(t.branch))return;i(t.branch.name)}else t.type===`create`?o(p):t.type===`confirm-create`&&r(p)},onMouseEnter:()=>f(n),children:t.type===`branch`&&t.branch?(0,X.jsxs)(X.Fragment,{children:[t.branch.isCurrent&&(0,X.jsx)(`span`,{className:`branch-quick-pick-check`,children:(0,X.jsx)(gi,{size:14})}),(0,X.jsx)(`span`,{className:`branch-quick-pick-name`,children:t.branch.name}),t.branch.linkedWorktreePath&&!t.branch.isCurrent&&(0,X.jsx)(_g,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:e(`git.quick_pick.in_use`)}),t.branch.isRemote&&(0,X.jsx)(_g,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:`Remote`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`branch-quick-pick-create-icon`,children:(0,X.jsx)($,{semantic:`git.branch.create`,size:14})}),(0,X.jsx)(`span`,{className:`branch-quick-pick-create-label`,children:t.label})]})},t.type===`branch`?t.branch?.name:`create`)):(0,X.jsx)(QD,{title:s?`No branches found`:`Type to search branches`})}),(0,X.jsxs)(`div`,{className:`branch-quick-pick-hint`,children:[(0,X.jsx)(`span`,{children:`↑↓ Navigate`}),(0,X.jsx)(`span`,{children:`↵ Select`}),(0,X.jsx)(`span`,{children:`Esc Close`})]})]})}function eO({children:e,workspaceId:t,onOpenBranchSwitcher:n}){let r=Br(),i=Z(),a=U(__),o=W(__);return r===`mobile`||!n?e:(0,X.jsx)(Gm,{content:(0,X.jsx)($D,{}),contentClassName:`branch-quick-pick`,forceMode:`desktop`,onOpenChange:e=>{if(e){n();return}o({visible:!1,inputValue:``})},open:a.visible&&a.workspaceId===t,title:i(`git.branch`),children:e})}function tO(){let e=Br(),t=Z(),{branchList:n,displayItems:r,handleBranchCreate:i,handleBranchSelect:a,handleClose:o,handleRequestBranchCreate:s,inputValue:c,isBranchSelectable:l,quickPickState:u,selectedIndex:d,setInputValue:f,setPendingCreateBranchName:p,setSelectedIndex:m,trimmedInput:h}=pD(),g=e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),m(e=>e<r.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),m(e=>e>0?e-1:e);break;case`Enter`:if(e.preventDefault(),r[d]){let e=r[d];if(e.type===`branch`&&e.branch){if(!l(e.branch))return;a(e.branch.name)}else e.type===`create`?s(h):e.type===`confirm-create`&&i(h)}break;case`Escape`:e.preventDefault(),o();break}};if(!u.visible||e!==`mobile`)return null;let _=r[d]??null,v=_?.type===`branch`&&_.branch?_.branch.name:null,y=r.some(e=>e.type===`branch`&&e.branch?.name.toLowerCase()===h.toLowerCase()),b=r.filter(e=>e.type===`branch`&&e.branch).map(e=>({id:e.branch.name,label:e.branch.name,icon:e.branch.isCurrent?(0,X.jsx)(gi,{size:14}):void 0,meta:e.branch.isCurrent?t(`git.current_branch`):e.branch.linkedWorktreePath?t(`git.quick_pick.worktree_in_use`):void 0,badge:e.branch.isRemote?t(`git.branch_remote`):void 0,disabled:!l(e.branch)})),x=r.find(e=>e.type===`create`||e.type===`confirm-create`);return(0,X.jsx)(`div`,{onKeyDown:g,children:(0,X.jsx)(Jh,{className:`mobile-select-sheet--command`,title:t(`git.branch`),searchable:!0,searchPlaceholder:t(`git.quick_pick.search_placeholder`),searchValue:c,onSearchValueChange:e=>{f(e),p(null),m(0)},sections:[{kind:`options`,id:`branches`,items:b}],closeOnSelect:!1,selectedId:v,loading:n.loading,loadingText:t(`git.quick_pick.loading`),emptyText:t(c?`git.quick_pick.empty_filtered`:`git.quick_pick.empty_idle`),create:{visible:!!h&&!y,label:()=>x?.type===`confirm-create`?t(`git.quick_pick.confirm_create_label`):t(`git.quick_pick.create_label`),description:()=>h,onCreate:async()=>{if(x?.type===`confirm-create`){await i(h);return}s(h),m(r.length-1)}},onClose:o,onSelect:a})})}var nO=({workspaceId:e,gitState:t,inline:n=!1,onRefresh:r,refreshStatus:i=`idle`})=>{let a=Z(),o=U(Za),s=U(b_(e)),{authPrompt:c,clearAuthPrompt:l,getAuthPromptMessage:u,handleFetch:d,handlePull:f,handlePush:p,syncingIntent:m}=lD(e),h=`git-auth-form-${e}`,[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)({username:``,password:``}),b=(0,H.useRef)(!1);if((0,H.useLayoutEffect)(()=>{if(!c){y({username:``,password:``});return}y(e=>({username:e.username||c.details.usernameHint||``,password:``}))},[c]),(0,H.useEffect)(()=>{i===`refreshing`||!b.current||(b.current=!1,ae())},[i]),!t)return null;let x=t.staged.length+t.modified.length+t.untracked.length+t.deleted.length,S=t.ahead,C=t.behind,w=s.status===`fetching`,T=w||i===`refreshing`,E=s.lastFetchAt?a(`git.fetch_last_at`,{when:dm(s.lastFetchAt,o)}):a(`git.fetch_last_never`),D=a(T?`git.fetch_in_progress`:`git.fetch_label`),O=g?.intent===`push`?a(`git.push_confirm_title`):a(`git.pull_confirm_title`),k=g?.intent===`push`?a(`git.push_confirm_message`,{count:g.count}):a(`git.pull_confirm_message`,{count:g?.count??0}),A=g?.intent===`push`?a(`action.push`):a(`action.pull`),j=g?.intent===`push`?a(`git.push_in_progress`):a(`git.pull_in_progress`),M=!!(g&&m===g.intent),N=c?.intent,P=N??g?.intent??`pull`,F=a(N===`push`?`action.push`:N===`pull`?`action.pull`:`git.fetch_label`),ee=a(N===`push`?`git.push_in_progress`:N===`pull`?`git.pull_in_progress`:`git.fetch_in_progress`),I=!!(N&&m===N),L=M||I,R=!!(g&&!c),z=(e,t)=>{t<=0||_({intent:e,count:t})},te=()=>{L||(_(null),l())},ne=e=>{e||te()},re=async()=>{if(g){if(g.intent===`push`){await p()&&_(null);return}await f()&&_(null)}},ie=async()=>{let e=c;if(!e)return;let t={username:v.username.trim(),password:v.password};!t.username||!t.password||(e.intent===`push`?await p(t):e.intent===`pull`?await f(t):await d(t))&&(l(),_(null),(e.intent===`fetch`||e.intent===`pull`)&&await r?.())},ae=async()=>{if(i===`refreshing`){b.current=!0;return}await d()&&await r?.()},B=c;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`git-status-bar${n?` git-status-bar--inline`:``}`,children:[(0,X.jsx)(Ig,{content:a(`git.statusbar.changes`),children:(0,X.jsxs)(`span`,{className:`git-status-bar__item git-status-bar__item--changes`,children:[(0,X.jsx)($,{semantic:`git.footer.diff`,size:13}),(0,X.jsx)(`span`,{className:`git-status-bar__value`,children:x})]})}),(0,X.jsx)(Ig,{content:a(`git.statusbar.ahead`),children:(0,X.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--ahead`,type:`button`,"aria-label":a(`action.push`),disabled:S<=0,onClick:()=>z(`push`,S),children:[(0,X.jsx)($,{semantic:`git.footer.push`,size:13}),(0,X.jsx)(`span`,{className:`git-status-bar__value`,children:S})]})}),(0,X.jsx)(Ig,{content:a(`git.statusbar.behind`),children:(0,X.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--behind`,type:`button`,"aria-label":a(`action.pull`),disabled:C<=0,onClick:()=>z(`pull`,C),children:[(0,X.jsx)($,{semantic:`git.footer.pull`,size:13}),(0,X.jsx)(`span`,{className:`git-status-bar__value`,children:C})]})}),(0,X.jsx)(Ig,{content:E,children:(0,X.jsx)(Em,{"aria-label":D,className:`git-status-bar__item git-status-bar__item--actionable`,disabled:w,icon:(0,X.jsx)($,{semantic:`git.footer.refresh`,size:13,className:T?`spin`:void 0}),onClick:()=>void ae(),size:`sm`})})]}),R?(0,X.jsx)(Bm,{className:`git-status-bar__confirm`,dismissible:!L,closeDisabled:L,open:!0,onOpenChange:ne,title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{semantic:`git.action.warning`,size:16}),(0,X.jsx)(`span`,{children:O})]}),description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:k}),(0,X.jsx)(`p`,{className:`dialog-helper`,children:a(`git.sync_confirm_helper`)})]}),cancelDisabled:L,cancelText:a(`action.cancel`),closeLabel:a(`action.close`),confirmText:M?j:A,confirmDisabled:M,onConfirm:()=>{re()}}):null,B?(0,X.jsxs)(jm,{className:`git-status-bar__confirm`,dismissible:!L,open:!0,onOpenChange:ne,children:[(0,X.jsxs)(Mm,{children:[(0,X.jsxs)(Pm,{children:[(0,X.jsx)($,{semantic:`git.action.warning`,size:16}),(0,X.jsx)(`span`,{children:a(P===`push`?`git.push_confirm_title`:P===`pull`?`git.pull_confirm_title`:`git.fetch_label`)})]}),(0,X.jsx)(Em,{"aria-label":a(`action.close`),disabled:L,icon:(0,X.jsx)(pa,{size:14}),onClick:te,size:`sm`})]}),(0,X.jsx)(Fm,{children:B.details.canPrompt?(0,X.jsxs)(`form`,{id:h,className:`form-group`,onSubmit:e=>{e.preventDefault(),ie()},children:[(0,X.jsx)(`p`,{children:u(B.details)}),(0,X.jsx)(`span`,{className:`dialog-helper`,children:a(`git.auth_helper_http`)}),(0,X.jsx)(`label`,{htmlFor:`git-auth-username-${e}`,children:a(`git.auth_username`)}),(0,X.jsx)(rh,{id:`git-auth-username-${e}`,value:v.username,onChange:e=>y(t=>({...t,username:e.target.value})),placeholder:B.details.usernameHint??a(`git.auth_username_placeholder`),autoFocus:!0,disabled:I}),(0,X.jsx)(`label`,{htmlFor:`git-auth-password-${e}`,children:a(`git.auth_password`)}),(0,X.jsx)(rh,{id:`git-auth-password-${e}`,type:`password`,value:v.password,onChange:e=>y(t=>({...t,password:e.target.value})),placeholder:a(`git.auth_password_placeholder`),disabled:I})]}):(0,X.jsxs)(`div`,{className:`form-group`,children:[(0,X.jsx)(`p`,{children:u(B.details)}),(0,X.jsx)(`span`,{className:`dialog-helper`,children:a(`git.auth_helper_unsupported`)})]})}),(0,X.jsxs)(Im,{children:[(0,X.jsx)(Q,{onClick:te,disabled:L,children:a(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,form:B.details.canPrompt?h:void 0,type:B.details.canPrompt?`submit`:`button`,disabled:!B.details.canPrompt||I||!v.username.trim()||!v.password,children:I?ee:F})]})]}):null]})};function rO({"aria-controls":e,"aria-expanded":t,"aria-haspopup":n,ariaLabel:r,branchName:i,branchSummary:a,disabled:o,onClick:s,onKeyDown:c}){return(0,X.jsx)(Ig,{content:i,children:(0,X.jsxs)(`button`,{type:`button`,className:`git-panel-status-strip__branch`,onClick:s,onKeyDown:c,"aria-controls":e,"aria-expanded":t,"aria-haspopup":n,"aria-label":r,disabled:o,children:[(0,X.jsx)($,{semantic:`git.footer.branch`,size:11}),(0,X.jsx)(`span`,{className:`git-panel-status-strip__branch-text`,children:i})]})})}function iO({workspaceId:e,gitState:t,onOpenBranchSwitcher:n}){let r=Z(),i=Br(),{refreshWorkspace:a,status:o}=YD(e),s=t?.branch?.trim()||r(`git.no_branch`),c=t&&(t.ahead>0||t.behind>0)?[t.ahead>0?`↑${t.ahead}`:null,t.behind>0?`↓${t.behind}`:null].filter(Boolean).join(` `):null,l=(0,X.jsx)(rO,{ariaLabel:`${r(`git.current_branch`)}: ${s}`,branchName:s,branchSummary:c,disabled:!n,onClick:i===`mobile`?n:void 0});return(0,X.jsx)(`div`,{className:`git-panel-status-strip`,children:(0,X.jsxs)(`div`,{className:`git-panel-status-strip__left`,children:[i===`desktop`&&n?(0,X.jsx)(eO,{workspaceId:e,onOpenBranchSwitcher:n,children:l}):l,(0,X.jsx)(`div`,{className:`git-panel-status-strip__meta`,children:(0,X.jsx)(nO,{workspaceId:e,gitState:t,inline:!0,onRefresh:a,refreshStatus:o})})]})})}function aO({workspaceId:e,gitState:t,onOpenBranchSwitcher:n,flush:r=!1}){return(0,X.jsxs)(`div`,{className:`workspace-status-bar${r?` workspace-status-bar--flush`:``}`,children:[(0,X.jsx)(`div`,{className:`workspace-status-bar__left`,children:(0,X.jsx)(iO,{workspaceId:e,gitState:t,onOpenBranchSwitcher:n})}),(0,X.jsx)(`div`,{className:`workspace-status-bar__right`,children:(0,X.jsx)(qD,{})})]})}function oO(e){return e instanceof HTMLElement?e.isContentEditable||e.closest(`[contenteditable="true"]`)?!0:[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.tagName):!1}var sO=()=>{let e=(0,H.useRef)(null),t=ZT(e),n=Z(),{createRequest:r,desktopSidebarView:i,focusMode:a,gitState:o,handleBottomMouseDown:s,handleConsumeCreateRequest:c,handleLeftMouseDown:l,handleOpenBranchSwitcher:u,handleOpenFileCreate:d,handleOpenFolderCreate:f,leftPanelWidth:p,leftPanelRef:m,mainAreaMode:h,setDesktopSidebarView:g,sidebarCollapsed:_,terminalPanelVisible:v,workspace:y,bottomPanelHeight:b,bottomPanelRef:x}=_E(),S=W(K_),C=T_(i);return lE(y.id),(0,H.useEffect)(()=>{let e=e=>{if(!(e.defaultPrevented||oO(e.target))&&(e.metaKey||e.ctrlKey)){if(e.key.toLowerCase()===`b`){e.preventDefault(),S(e=>!e);return}if(e.key===`1`){e.preventDefault(),g(`explorer`);return}if(e.key===`2`){e.preventDefault(),g(`search`);return}e.key===`3`&&(e.preventDefault(),g(`source-control`))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,S]),(0,X.jsxs)(`div`,{ref:e,className:`workspace-page workspace-page--desktop`,children:[(0,X.jsx)(GT,{fullscreenController:t}),(0,X.jsxs)(`div`,{className:`workspace-body`,children:[!a&&!_&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`aside`,{ref:m,className:`left-panel`,style:{width:`${p}px`},children:(0,X.jsxs)(`div`,{className:`nav-panel workspace-sidebar-panel`,children:[(0,X.jsx)(GD,{activeView:C,onSelectView:g}),(0,X.jsxs)(`div`,{className:`workspace-sidebar-panel__content`,children:[C===`explorer`?(0,X.jsx)(iD,{workspaceId:y.id,createRequest:r,onCreateRequestConsumed:c,onOpenFileCreate:d,onOpenFolderCreate:f}):null,C===`search`?(0,X.jsx)(WD,{workspaceId:y.id}):null,C===`source-control`?(0,X.jsxs)(`div`,{className:`workspace-sidebar-view`,children:[(0,X.jsx)(aS,{title:n(`workspace.sidebar.source_control`)}),(0,X.jsx)(`div`,{className:`workspace-sidebar-panel__body`,children:(0,X.jsx)(PD,{workspaceId:y.id,variant:`desktop`})})]}):null]})]})}),(0,X.jsx)(`div`,{className:`split-divider-v`,onMouseDown:l,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize left panel`})]}),(0,X.jsxs)(`div`,{className:`workspace-main-area`,children:[(0,X.jsx)(`div`,{className:`workspace-main-stage`,children:h===`editor`?(0,X.jsx)(oT,{}):(0,X.jsx)(`div`,{className:`agent-panes`,children:(0,X.jsx)(vw,{hydrateSessions:!1})})}),!a&&v&&(0,X.jsx)(`div`,{className:`split-divider-h`,onMouseDown:s,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize bottom panel`}),!a&&v&&(0,X.jsx)(`div`,{ref:x,className:`workspace-bottom-panel`,style:{height:`${b}px`},children:(0,X.jsx)(ST,{})})]})]}),(0,X.jsx)(aO,{align:`start`,workspaceId:y.id,gitState:o,onOpenBranchSwitcher:u})]})},cO=()=>{let e=U(Bp),t=Z();return e?(0,X.jsx)(sO,{},e.id):(0,X.jsx)(`div`,{className:`workspace-page workspace-page-empty`,children:(0,X.jsx)(`div`,{className:`workspace-empty-content`,children:(0,X.jsx)(`div`,{className:`workspace-empty-inner`,children:(0,X.jsx)(Sh,{style:{minHeight:`auto`,padding:0},title:(0,X.jsx)(`p`,{children:t(`workspace.no_workspace`)})})})})})},lO={minHeight:`auto`,padding:0,gap:0,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function uO({title:e,description:t,testId:n}){return(0,X.jsx)(`div`,{className:`workspace-resolving-shell`,"data-testid":n,children:(0,X.jsx)(`div`,{className:`workspace-resolving-card`,children:(0,X.jsx)(Sh,{style:lO,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`workspace-resolving-kicker`,children:Z()(`workspace.title`)}),(0,X.jsx)(`div`,{className:`workspace-resolving-title`,children:e})]}),description:(0,X.jsx)(`div`,{className:`workspace-resolving-desc`,children:t})})})})}function dO({title:e,description:t}){let n=Z();return(0,X.jsx)(uO,{title:e??n(`workspace.load_failed_title`),description:t??n(`workspace.load_failed_description`)})}function fO(){let e=Z();return(0,X.jsx)(uO,{testId:`workspace-resolving-shell`,title:e(`workspace.loading_title`),description:e(`workspace.loading_description`)})}function pO({children:e}){let t=U(Bp),n=U(Pp),r=U(Fp),i=Yt().pathname===`/workspace`;return!t&&n===`error`?(0,X.jsx)(dO,{description:r??`Failed to fetch workspace list`}):!t&&(n===`idle`||n===`loading`||i&&n===`ready`)?(0,X.jsx)(fO,{}):(0,X.jsx)(X.Fragment,{children:e})}function mO(){let e=(0,H.useRef)(0),t=Qt(),n=Yt(),r=U(Wr),i=U(xp),a=U(Op),o=U(Rp),s=U(Qa),c=U(Dp),l=U(Pp),u=W(jp),d=W(no),f=W(Mp),p=W(Np),m=W(Pp),h=W(Fp);(0,H.useEffect)(()=>{if(c===null)return;let g=c===!0;if(g&&!s){if(n.pathname!==`/login`){t(`/login`,{replace:!0});return}return}if(n.pathname===`/login`&&(!g||s)){t(`/`,{replace:!0});return}if(n.pathname!==`/session-gate`){if(r===`gated`){t(`/session-gate`,{replace:!0});return}if(!(n.pathname!==`/`&&n.pathname!==`/workspace`)&&r===`active`){if(l===`idle`){if(i!==`connected`)return;let t=e.current+1;e.current=t,m(`loading`),h(null),Promise.all([a(`workspace.list`,{}),a(`workspace.lastViewedTarget.get`,{})]).then(n=>{if(e.current!==t)return;let[r,i]=n;if(!r.ok){m(`error`),h(r.error?.message??`Failed to fetch workspace list`);return}let a=Array.isArray(r.data)?r.data:[],o={};for(let e of a)o[e.id]=e;f(o),p(a.map(e=>e.id));let s=i.ok&&i.data&&o[i.data.workspaceId]?i.data:null;d(s),s?.workspaceId&&u(s.workspaceId),m(`ready`),h(null)}).catch(n=>{e.current===t&&(m(`error`),h(n instanceof Error?n.message:`Failed to fetch workspace list`))});return}if(l===`ready`){if(n.pathname===`/`&&o.length>0){t(`/workspace`,{replace:!0});return}n.pathname===`/workspace`&&o.length===0&&t(`/`,{replace:!0})}}}},[r,c,s,i,a,n.pathname,t,p,f,u,d,h,m,o.length,l])}var hO=25e3,gO=`连接恢复较慢,可能是网络问题。如果长时间没有恢复,可以刷新页面。`,_O=`连接恢复较慢,长时间未恢复可刷新页面。`;function vO(){let e=U(Wr),t=U(Kr),n=U(xp),r=U(wp),i=Br()===`mobile`,[a,o]=(0,H.useState)(()=>Date.now());if((0,H.useEffect)(()=>{if(r===null||n!==`reconnecting`&&n!==`disconnected`)return;let e=r+hO-Date.now();if(e<=0){o(Date.now());return}let t=setTimeout(()=>{o(Date.now())},e);return()=>{clearTimeout(t)}},[n,r]),n===`connected`||n===`connecting`)return null;if(n===`rejected`||e===`gated`&&t===`displaced`)return(0,X.jsx)(`div`,{className:`connection-banner${i?` connection-banner--mobile`:``} connection-banner--error`,role:`status`,"aria-live":`polite`,children:(0,X.jsx)(`span`,{children:`另一个标签页已激活`})});let s=r!==null&&a-r>=hO&&(n===`reconnecting`||n===`disconnected`),c=s&&i,l=i?_O:gO;return(0,X.jsxs)(`div`,{className:[`connection-banner`,i?`connection-banner--mobile`:null,c?`connection-banner--stacked`:null].filter(Boolean).join(` `),role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`span`,{className:`connection-banner__primary`,children:`连接已断开,正在重新连接...`}),s?(0,X.jsx)(`span`,{className:`connection-banner__hint`,children:l}):null]})}var yO={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function bO(){mO();let e=U(Dp),t=Yt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname.startsWith(`/diagnostics`)||t.pathname===`/session-gate`;return(0,X.jsxs)(`div`,{className:`app`,children:[(0,X.jsx)(vO,{}),(0,X.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,X.jsx)(`div`,{className:`app-loading-shell`,children:(0,X.jsx)(`div`,{className:`app-loading-card`,children:(0,X.jsx)(Sh,{style:yO,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,X.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,X.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,X.jsxs)(Dn,{children:[(0,X.jsx)(Tn,{path:`/`,element:(0,X.jsx)(jx,{})}),(0,X.jsx)(Tn,{path:`/login`,element:(0,X.jsx)(zg,{})}),(0,X.jsx)(Tn,{path:`/session-gate`,element:(0,X.jsx)(Bg,{})}),(0,X.jsx)(Tn,{path:`/diagnostics`,element:(0,X.jsx)(Gv,{})}),(0,X.jsx)(Tn,{path:`/workspace`,element:(0,X.jsx)(pO,{children:(0,X.jsx)(cO,{})})}),(0,X.jsx)(Tn,{path:`/settings`,element:(0,X.jsx)(xx,{})}),(0,X.jsx)(Tn,{path:`*`,element:(0,X.jsx)(iy,{})})]})}),(0,X.jsx)(wy,{}),(0,X.jsx)(ty,{}),(0,X.jsx)(dy,{})]})}function xO({sessionId:e,workspaceId:t,onClose:n}){let r=Z(),i=W(cS),{closeDetails:a}=uS(e),{dialog:o,supervisor:s,mode:c,restoreStep:l,copy:u,isMaxSupervisionCountValid:d,recoverableTargets:f,selectedRecoverableTargetId:p,isRecoverableTargetsLoading:m,hasObjectiveChanged:h,hasChanges:g,close:_,updateDraft:v,openRestoreStep:y,closeRestoreStep:b,selectRecoverableTarget:x,confirm:S}=_S({workspaceId:t,sessionId:e}),[C,w]=(0,H.useState)(()=>s?`details`:null),[T,E]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(s){w(e=>e??`details`);return}w(e=>e===`details`?null:e),i(t=>t.sessionId===e&&t.mode===`enable`&&!t.open?t:{open:!1,sessionId:e,mode:`enable`,restoreStep:`form`,returnToDetails:!1,draftObjective:t.sessionId===e&&t.mode===`enable`?t.draftObjective:``,initialObjective:``,draftEvaluatorProviderId:t.sessionId===e&&t.mode===`enable`?t.draftEvaluatorProviderId:`claude`,draftEvaluatorModel:t.sessionId===e&&t.mode===`enable`?t.draftEvaluatorModel:``,draftMaxSupervisionCount:t.sessionId===e&&t.mode===`enable`?t.draftMaxSupervisionCount:`0`,draftScheduledAt:t.sessionId===e&&t.mode===`enable`?t.draftScheduledAt:``,recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1})},[e,i,s]),(0,H.useEffect)(()=>{!o.open||o.sessionId!==e||o.mode===`edit`&&w(`edit`)},[o.mode,o.open,o.sessionId,e]);let D=()=>{i({open:!0,sessionId:e,mode:`edit`,restoreStep:`form`,returnToDetails:!0,draftObjective:s?.objective??``,initialObjective:s?.objective??``,draftEvaluatorProviderId:s?.evaluatorProviderId??`claude`,draftEvaluatorModel:s?.evaluatorModel??``,draftMaxSupervisionCount:String(s?.maxSupervisionCount??0),draftScheduledAt:pS(s?.scheduledAt),recoverableTargets:[],selectedRecoverableTargetId:null,isRecoverableTargetsLoading:!1}),w(`edit`)},O=(0,X.jsx)(`div`,{className:`mobile-supervisor-sheet__detail`,children:(0,X.jsx)(wS,{mode:c,restoreStep:l,draftObjective:o.draftObjective,draftEvaluatorProviderId:o.draftEvaluatorProviderId,draftEvaluatorModel:o.draftEvaluatorModel,draftMaxSupervisionCount:o.draftMaxSupervisionCount,draftScheduledAt:o.draftScheduledAt,isMaxSupervisionCountValid:d,recoverableTargets:f,selectedRecoverableTargetId:p,isRecoverableTargetsLoading:m,onDraftObjectiveChange:e=>v({draftObjective:e}),onDraftEvaluatorProviderChange:e=>v({draftEvaluatorProviderId:e}),onDraftEvaluatorModelChange:e=>v({draftEvaluatorModel:e}),onDraftMaxSupervisionCountChange:e=>v({draftMaxSupervisionCount:e}),onDraftScheduledAtChange:e=>v({draftScheduledAt:e}),onOpenRestoreStep:()=>{y()},onCloseRestoreStep:b,onSelectRecoverableTarget:x})}),k=s&&C===`details`?(0,X.jsx)(`div`,{className:`mobile-supervisor-sheet__detail`,children:(0,X.jsx)(ES,{sessionId:e,workspaceId:t,onEdit:()=>{a(),D()}})}):null,A=(0,X.jsxs)(`div`,{className:`mobile-supervisor-sheet__footer`,children:[(0,X.jsx)(Q,{onClick:()=>{_(),s?w(`details`):(w(null),n())},children:r(`action.cancel`)}),(0,X.jsx)(Q,{variant:`primary`,onClick:()=>{if(c===`edit`&&l!==`restore`&&h){E(!0);return}(async()=>{await S()&&(a(),w(s?`details`:null),n())})()},disabled:l===`restore`?!p||m||!d:c===`edit`?!g||!o.draftObjective.trim()||!d:!o.draftObjective.trim()||!d,children:u.confirm})]});return s&&C===`details`?(0,X.jsx)(fm,{title:r(`supervisor.dialog.details.title`),kicker:r(`supervisor.title`),onClose:()=>{_(),a(),w(`details`),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:k}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fm,{title:u.title,kicker:r(`supervisor.title`),onBack:s&&C===`edit`?()=>{_(),a(),w(`details`)}:void 0,onClose:()=>{_(),a(),w(s?`details`:null),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:O,footer:A}),(0,X.jsx)(Bm,{open:T,onOpenChange:E,title:r(`supervisor.dialog.edit.reset_confirm_title`),description:r(`supervisor.dialog.edit.reset_confirm_description`),cancelText:r(`action.cancel`),confirmText:r(`supervisor.dialog.edit.confirm`),tone:`danger`,onConfirm:()=>{E(!1),(async()=>{await S()&&(a(),w(s?`details`:null),n())})()}})]})}var SO=`(orientation: landscape)`,CO=`(max-height: 540px)`;function wO(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return`default`;let e=window.matchMedia(SO).matches,t=window.matchMedia(CO).matches;return e&&t?`landscape-compact`:`default`}function TO(){let[e,t]=(0,H.useState)(wO);return(0,H.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(SO),n=window.matchMedia(CO),r=()=>{t(wO())};return e.addEventListener(`change`,r),n.addEventListener(`change`,r),r(),()=>{e.removeEventListener(`change`,r),n.removeEventListener(`change`,r)}},[]),e}var EO=`(prefers-reduced-motion: reduce)`;function DO(){return typeof window>`u`||typeof window.matchMedia!=`function`?`default`:window.matchMedia(EO).matches?`reduced`:`default`}function OO(){let[e,t]=(0,H.useState)(DO);return(0,H.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(EO),n=()=>{t(e.matches?`reduced`:`default`)};return e.addEventListener(`change`,n),n(),()=>{e.removeEventListener(`change`,n)}},[]),e}function kO(){let[e,t]=(0,H.useState)(0);return(0,H.useEffect)(()=>{let e=window.visualViewport;if(!e){t(0);return}let n=()=>{let n=Math.max(window.innerHeight-e.height-e.offsetTop,0);t(Math.round(n))};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n)}},[]),e}function AO(e){if(e.title?.trim())return e.title.trim();if(e.providerId)return e.providerId.replace(/\b\w/g,e=>e.toUpperCase());let t=e.id.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.id.replace(/[_-]/g,` `).toUpperCase()}function jO(e,t){switch(e){case`starting`:return t(`status.starting`);case`running`:return t(`status.running`);case`idle`:return t(`status.idle`);case`ended`:return t(`status.ended`);default:return e}}function MO({activeSessionId:e,activeWorkspaceId:t,defaultMode:n=`list`,sessions:r,onClose:i,onCloseSession:a,onSelectSession:o,onSessionCreated:s}){let c=U(Op),l=W(Vp),u=Z(),d=Xg(),[f,p]=(0,H.useState)(n===`create`?`providers`:`sessions`),m=r.find(t=>t.id===e)??r[0]??null,h=!!t,g=[{id:`claude`,title:`Claude`,icon:(0,X.jsx)($,{semantic:`agent.provider.claude`,size:16})},{id:`codex`,title:`Codex`,icon:(0,X.jsx)($,{semantic:`agent.provider.codex`,size:16})}],_=e=>{let t=y[e].runtime;return!!(t?.autoInstallSupported&&t.installReadiness===`ready`)},v=()=>{p(n===`create`?`providers`:`sessions`),i()},{states:y,launch:b}=nS(c,t??`__workspace_placeholder__`,(e,t)=>{l(t=>({...t,[e.id]:e})),s(e.id),v()}),x=[{kind:`actions`,id:`agent-actions`,items:[{id:`create`,label:u(`action.create_session`),icon:(0,X.jsx)($,{semantic:`agent.action.newSession`,size:16}),onAction:()=>p(`providers`),disabled:!h}]},{kind:`options`,id:`sessions`,items:r.length>0?r.map(e=>({id:e.id,label:AO(e),description:u(`mobile.agent.switch_to_agent`,{name:AO(e)}),meta:`${e.providerId.toUpperCase()} · ${jO(e.state,u)}`,trailingAction:{id:`${e.id}-close`,ariaLabel:u(`mobile.agent.close_current_session`),icon:(0,X.jsx)(pa,{size:16}),tone:`danger`,onAction:async()=>{await a(e.id),v()}}})):[]}],S=[{kind:`options`,id:`providers`,items:g.map(e=>{let n=y[e.id],r=n.loading||n.installJob?.status===`queued`||n.installJob?.status===`running`,i=n.inlineError===`manual`||!_(e.id)?(n.runtime?.manualGuideKeys??[]).map(e=>u(e)).join(` `):n.inlineError||n.installJob?.failure?.message;return{id:e.id,label:e.title,description:i||u(`mobile.agent.start_session`,{provider:e.title}),meta:u(r?`mobile.agent.starting`:`mobile.agent.start_new_session`),icon:e.icon,disabled:!h||r,trailingAction:!r&&i&&t?{id:`${e.id}-diagnostics`,ariaLabel:u(`diagnostics.actions.open_diagnostics`),icon:(0,X.jsx)(Ui,{size:16}),onAction:()=>{window.location.assign(X_({context:`session_start`,workspaceId:t,providerId:e.id}))}}:void 0}})}];return(0,X.jsx)(Jh,{className:`mobile-select-sheet--command`,title:u(f===`sessions`?`mobile.agent.title`:`session.provider_select`),sections:f===`sessions`?x:S,selectedId:f===`sessions`?m?.id??null:null,emptyText:f===`sessions`?u(`mobile.agent.empty`):void 0,closeOnSelect:!1,onBack:f===`providers`?()=>p(`sessions`):void 0,onClose:v,onSelect:e=>{if(f===`sessions`){t&&d({workspaceId:t,sessionId:e}),o(e),v();return}return b(e)}})}function NO({activeItem:e,onSelectItem:t}){let n=Z();return(0,X.jsxs)(`nav`,{className:`mobile-dock`,"aria-label":n(`mobile.dock.aria_label`),children:[(0,X.jsxs)(`button`,{type:`button`,className:`mobile-dock__item ${e===`agent`?`mobile-dock__item--active`:``}`,onClick:()=>t(`agent`),"aria-label":n(`mobile.dock.open_agent`),children:[(0,X.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:`mobile.dock.agent`,size:18})}),(0,X.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.agent`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mobile-dock__item ${e===`files`?`mobile-dock__item--active`:``}`,onClick:()=>t(`files`),"aria-label":n(`mobile.dock.open_files`),children:[(0,X.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:`mobile.dock.files`,size:18})}),(0,X.jsx)(`span`,{className:`mobile-dock__label`,children:n(`file.title`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mobile-dock__item ${e===`terminal`?`mobile-dock__item--active`:``}`,onClick:()=>t(`terminal`),"aria-label":n(`mobile.dock.open_terminal`),children:[(0,X.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,X.jsx)($,{semantic:`mobile.dock.terminal`,size:18})}),(0,X.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.terminal`)})]})]})}function PO({workspaceId:e,onSelectFile:t}){let n=Z(),r=U(Op),i=W(d_(e)),{openLocation:a}=Cy(e),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),m=(0,H.useRef)(0),h=o.trim().length>0;return(0,H.useEffect)(()=>{let t=o.trim();if(!t){l([]),d(!1),p(!1);return}let n=!1;d(!0),p(!1);let i=++m.current,a=window.setTimeout(()=>{r(`file.search`,{workspaceId:e,query:t,limit:10}).then(e=>{if(!(n||i!==m.current)){if(!e.ok||!e.data){l([]),p(!0);return}l(e.data.files)}}).catch(()=>{n||(l([]),p(!0))}).finally(()=>{n||d(!1)})},150);return()=>{n=!0,window.clearTimeout(a)}},[r,o,e]),(0,X.jsxs)(`section`,{className:`workspace-sidebar-section workspace-quick-jump`,children:[(0,X.jsx)(`h2`,{className:`workspace-sidebar-section__title`,children:n(`workspace.quick_jump.title`)}),(0,X.jsxs)(`label`,{className:`workspace-quick-jump__search`,htmlFor:`quick-jump-${e}`,children:[(0,X.jsx)($,{semantic:`nav.search`,size:14,"aria-hidden":`true`}),(0,X.jsx)(`input`,{id:`quick-jump-${e}`,type:`search`,className:`workspace-quick-jump__input`,"aria-label":n(`workspace.quick_jump.title`),placeholder:n(`workspace.quick_jump.placeholder`),value:o,onChange:e=>s(e.target.value)})]}),h?(0,X.jsx)(`div`,{className:`workspace-quick-jump__results`,children:u?(0,X.jsx)(`p`,{className:`workspace-quick-jump__state`,children:n(`common.loading`)}):f?(0,X.jsx)(`p`,{className:`workspace-quick-jump__state`,children:n(`workspace.quick_jump.failed`)}):c.length===0?(0,X.jsx)(`p`,{className:`workspace-quick-jump__state`,children:n(`workspace.quick_jump.no_results`)}):c.map(n=>(0,X.jsxs)(`button`,{type:`button`,className:`workspace-quick-jump__item`,"aria-label":n.path,onClick:()=>{i(c_(n.path)),a({workspaceId:e,path:n.path,source:`manual`}),t?.(n.path)},children:[(0,X.jsx)(`span`,{className:`workspace-quick-jump__primary`,children:n.name}),(0,X.jsx)(`span`,{className:`workspace-quick-jump__secondary`,children:n.path})]},n.path))}):null]})}function FO({workspaceId:e,createRequest:t=null,onCreateRequestConsumed:n,collapseVersion:r=0,onOpenFileCreate:i,onOpenFolderCreate:a,onCollapseAll:o,routeToDetail:s}){return(0,X.jsxs)(`div`,{className:`mobile-explorer-panel`,children:[(0,X.jsx)(PO,{workspaceId:e,onSelectFile:s}),(0,X.jsx)(nD,{workspaceId:e,onSelectFile:s}),(0,X.jsxs)(`section`,{className:`workspace-sidebar-section workspace-sidebar-section--fill`,children:[(0,X.jsx)(rD,{onOpenFileCreate:i,onOpenFolderCreate:a,onCollapseAll:o}),(0,X.jsx)(KE,{workspaceId:e,createRequest:t,onCreateRequestConsumed:n,onSelectFile:s,collapseVersion:r,variant:`mobile`,showSearch:!1})]})]})}function IO({workspaceId:e,route:t,activeView:n,createRequest:r=null,onCreateRequestConsumed:i,collapseVersion:a=0,onCreateFile:o,onCreateFolder:s,onCollapseAll:c,onRouteChange:l,onTabChange:u,editorState:d}){let f=Z();return t.kind===`detail`?(0,X.jsx)(`div`,{className:`mobile-files-sheet`,children:(0,X.jsx)(`div`,{className:`mobile-files-sheet__detail`,children:(0,X.jsx)(oT,{chrome:`content-only`,editorState:d})})}):(0,X.jsxs)(`div`,{className:`mobile-files-sheet mobile-files-sheet--root`,children:[(0,X.jsx)(`div`,{className:`mobile-files-sheet__segmented`,children:(0,X.jsx)(Rh,{"aria-label":f(`mobile.files.tabs`),onValueChange:e=>u?.(e),value:n,children:(0,X.jsxs)(zh,{className:`mobile-files-sheet__tabs`,children:[(0,X.jsx)(Bh,{"aria-label":f(`workspace.sidebar.explorer`),className:`mobile-files-sheet__segment`,value:`explorer`,children:(0,X.jsx)(`span`,{className:`mobile-files-sheet__segment-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Ni,{size:16,"aria-hidden":`true`})})}),(0,X.jsx)(Bh,{"aria-label":f(`workspace.sidebar.search`),className:`mobile-files-sheet__segment`,value:`search`,children:(0,X.jsx)(`span`,{className:`mobile-files-sheet__segment-icon`,"aria-hidden":`true`,children:(0,X.jsx)(ia,{size:16,"aria-hidden":`true`})})}),(0,X.jsx)(Bh,{"aria-label":f(`workspace.sidebar.source_control`),className:`mobile-files-sheet__segment`,value:`source-control`,children:(0,X.jsx)(`span`,{className:`mobile-files-sheet__segment-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Fi,{size:16,"aria-hidden":`true`})})})]})})}),(0,X.jsx)(`div`,{className:`mobile-files-sheet__content`,children:n===`explorer`?(0,X.jsx)(FO,{workspaceId:e,createRequest:r,onCreateRequestConsumed:i,onOpenFileCreate:o,onOpenFolderCreate:s,onCollapseAll:c,routeToDetail:e=>l?.({kind:`detail`,path:e}),collapseVersion:a}):n===`search`?(0,X.jsx)(WD,{workspaceId:e,variant:`mobile`,onSelectFile:e=>l?.({kind:`detail`,path:e})}):(0,X.jsx)(PD,{workspaceId:e,onPreviewOpen:e=>{l?.({kind:`detail`,...e.path?{path:e.path}:{},...e.title?{title:e.title}:{}})},variant:`mobile`})})]})}function LO({activeWorkspace:e,drawerOpen:t,fullscreenController:n,onOpenSettings:r,onToggleDrawer:i}){let a=Z(),o=Ug(e)||a(`mobile.workspace_drawer.select_title`);return(0,X.jsxs)(`header`,{className:`mobile-topbar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mobile-topbar__workspace-button`,onClick:()=>{i()},"aria-label":a(`mobile.topbar.switch_workspace`),"aria-expanded":t,children:[(0,X.jsx)(`span`,{className:`mobile-topbar__workspace-leading`,"aria-hidden":`true`,children:(0,X.jsx)(Gi,{size:18})}),(0,X.jsx)(`span`,{className:`mobile-topbar__workspace-name`,children:o})]}),(0,X.jsxs)(`div`,{className:`mobile-topbar__actions`,children:[(0,X.jsx)(Em,{"aria-label":a(`mobile.topbar.open_settings`),className:`mobile-topbar__icon-button`,icon:(0,X.jsx)($,{semantic:`nav.settings`,size:18}),onClick:r}),(0,X.jsx)(CT,{controller:n,className:`mobile-topbar__icon-button`,iconSize:18,dataTestId:`mobile-fullscreen-toggle`})]})]})}function RO({activeWorkspaceId:e,isOpen:t,workspaces:n,onClose:r,onOpenWorkspaceLauncher:i}){let a=Qt(),o=W(jp),s=Z(),c=DT(),l=Xg();return t?(0,X.jsxs)(`div`,{className:`mobile-drawer-layer`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mobile-drawer-layer__backdrop`,"aria-label":s(`mobile.workspace_drawer.close`),onClick:r}),(0,X.jsxs)(`aside`,{className:`mobile-workspace-drawer`,"aria-label":s(`mobile.workspace_drawer.aria_label`),children:[(0,X.jsxs)(`div`,{className:`mobile-workspace-drawer__header`,children:[(0,X.jsxs)(`div`,{className:`mobile-workspace-drawer__header-copy`,children:[(0,X.jsx)(`div`,{className:`mobile-workspace-drawer__kicker`,children:s(`label.workspace`)}),(0,X.jsx)(`h2`,{className:`mobile-workspace-drawer__title`,children:s(`mobile.workspace_drawer.select_title`)})]}),(0,X.jsx)(Em,{"aria-label":s(`action.close`),className:`mobile-workspace-drawer__dismiss`,icon:(0,X.jsx)(pa,{size:16}),onClick:r,size:`lg`})]}),(0,X.jsx)(`div`,{className:`mobile-workspace-drawer__list`,children:n.map(t=>{let n=Ug(t)||t.id,i=t.id===e;return(0,X.jsxs)(`div`,{className:`mobile-workspace-drawer__item ${i?`mobile-workspace-drawer__item--active`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mobile-workspace-drawer__item-main`,"aria-current":i?`page`:void 0,"aria-label":s(`mobile.workspace_drawer.switch_to_workspace`,{name:n}),onClick:()=>{if(i){a(`/workspace`),r();return}l({workspaceId:t.id}),o(t.id),a(`/workspace`),r()},children:[(0,X.jsxs)(`span`,{className:`mobile-workspace-drawer__item-name-row`,children:[(0,X.jsx)(`span`,{className:`mobile-workspace-drawer__item-name`,children:n}),i?(0,X.jsxs)(`span`,{className:`mobile-workspace-drawer__item-state`,children:[(0,X.jsx)(gi,{size:12}),(0,X.jsx)(`span`,{children:s(`worktree.current`)})]}):null]}),(0,X.jsx)(`span`,{className:`mobile-workspace-drawer__item-path`,children:t.path})]}),(0,X.jsx)(Em,{"aria-label":s(`mobile.workspace_drawer.close_workspace`,{name:n}),className:`mobile-workspace-drawer__item-close`,icon:(0,X.jsx)(pa,{size:16}),onClick:()=>{c(t.id,{navigateHomeWhenEmpty:!0}).then(e=>{e&&r()})},size:`lg`})]},t.id)})}),(0,X.jsx)(`div`,{className:`mobile-workspace-drawer__footer`,children:(0,X.jsxs)(`button`,{type:`button`,className:`mobile-workspace-drawer__footer-button`,onClick:()=>{i(),r()},children:[(0,X.jsx)($,{semantic:`nav.newWorkspace`,size:14}),(0,X.jsx)(`span`,{children:s(`tooltip.new_workspace`)})]})})]})]}):null}function zO(e,t,n,r,i){let a=new Set(n.map(e=>e.id)),o=new Set(e);if(r&&a.has(r))return{sessionId:r,missingFromLayout:!o.has(r)};if(i&&a.has(i))return{sessionId:i,missingFromLayout:!o.has(i)};let s=[...t].sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0]?.id??t[0]?.id??null;return{sessionId:s,missingFromLayout:s?!o.has(s):!1}}function BO(){let e=(0,H.useRef)(null),t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=ZT(e),i=Z(),a=Qt(),o=U(to),s=U(no),c=W(ro),l=U(lS),u=U(cS),{activeSession:d,activeWorkspaceId:f,closeMobileSession:p,closeMobileSheet:m,diffPreview:h,handleMobileSessionCreated:g,handleOpenBranchSwitcher:_,gitState:v,mobileActiveSessionId:y,mobileAgentSessions:b,mobileFilesRoute:x,mobileSheet:S,openMobileSheet:C,orderedSessions:w,restoreMobileSession:T,selectMobileSession:E,updateMobileFilesRoute:D,workspace:O,workspaces:k}=_E(),{persistUiState:A}=Bv(f??`__workspace_empty__`),[j,M]=(0,H.useState)(!1),[N,P]=(0,H.useState)(!1),[F,ee]=(0,H.useState)(`explorer`),[I,L]=(0,H.useState)(null),[R,z]=(0,H.useState)(0),[te,ne]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),ae=kO(),B=TO(),oe=OO(),se=Gw(),ce=O?.uiState?.activeSessionId??null,V=s?.workspaceId===O?.id?s.sessionId??null:null;(0,H.useEffect)(()=>{if(!O||t.current===O.id||b.length===0&&w.length===0)return;let e=zO(w.map(e=>e.id),w,b,V,ce);if(!e.sessionId){t.current=O.id;return}if(t.current=O.id,e.missingFromLayout){T(e.sessionId);return}e.sessionId!==y&&T(e.sessionId)},[y,b,w,V,ce,T,O]),(0,H.useEffect)(()=>{if(!O){t.current=null,n.current=null;return}y&&n.current!==y&&(n.current=y,O.uiState.activeSessionId!==y&&A({activeSessionId:y}))},[y,A,O]),(0,H.useEffect)(()=>{o&&o!==y&&w.some(e=>e.id===o)&&E(o)},[y,w,o,E]),(0,H.useEffect)(()=>(c(y),()=>{c(null)}),[y,c]),(0,H.useEffect)(()=>{!d||S===`supervisor`||(l.open&&l.sessionId===d.id||u.open&&u.sessionId===d.id)&&(P(!1),C(`supervisor`))},[d,S,C,l.open,l.sessionId,u.open,u.sessionId]),(0,H.useEffect)(()=>{if(!(S!==`files`||x.kind!==`detail`)&&!(h?.source===`commit`&&x.path===h.path&&x.title===h.title)){if(se.activeFilePath){(x.path!==se.activeFilePath||x.title!==void 0)&&D({kind:`detail`,path:se.activeFilePath});return}if(h?.source===`commit`){(x.path!==h.path||x.title!==h.title)&&D({kind:`detail`,path:h.path,title:h.title});return}m()}},[m,h,se.activeFilePath,x,S,D]);let le=x.kind===`detail`?i(`file.title`):null,ue=e=>{L(t=>({id:(t?.id??0)+1,mode:e,baseDir:null}))},de=x.kind===`detail`?(0,X.jsx)(iT,{state:se,variant:`mobile`}):null,fe=S===`files`?{title:x.kind===`detail`?x.title??x.path?.split(`/`).pop()??i(`mobile.files.editor_fallback`):i(F===`explorer`?`workspace.sidebar.explorer`:F===`search`?`workspace.sidebar.search`:`workspace.sidebar.source_control`),body:f?(0,X.jsx)(IO,{workspaceId:f,route:x,activeView:F,createRequest:I,onCreateRequestConsumed:()=>L(null),collapseVersion:R,onCreateFile:()=>ue(`file`),onCreateFolder:()=>ue(`folder`),onCollapseAll:()=>z(e=>e+1),onRouteChange:D,onTabChange:ee,onCloseSheet:m,editorState:se}):null,footer:f?(0,X.jsx)(aO,{workspaceId:f,gitState:v,onOpenBranchSwitcher:_,flush:!0}):null,kicker:le,onBack:x.kind===`root`?void 0:()=>D({kind:`root`}),backLabel:i(`action.back`),headerAction:de,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--files`}:S===`terminal`?{title:i(`label.terminal`),body:(0,X.jsx)(`div`,{className:`mobile-terminal-sheet mobile-terminal-sheet--fullscreen`,children:(0,X.jsx)(ST,{chrome:`mobile-fullscreen`,onMobileHeaderActionsChange:ie})}),footer:f?(0,X.jsx)(aO,{workspaceId:f,gitState:v,onOpenBranchSwitcher:_,flush:!0}):null,kicker:null,headerAction:re,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--terminal`}:null,pe=e=>{if(e===`agent`){P(e=>!e);return}P(!1),C(e)},me=N?`agent`:S===`files`||S===`terminal`?S:null;return(0,X.jsxs)(`div`,{ref:e,className:`mobile-shell mobile-shell--${B} mobile-shell--motion-${oe}`,"data-testid":`mobile-shell`,"data-layout-mode":B,"data-motion-mode":oe,children:[(0,X.jsx)(LO,{activeWorkspace:O,drawerOpen:j,fullscreenController:r,onOpenSettings:()=>{P(!1),a(`/settings`)},onToggleDrawer:()=>{P(!1),M(e=>!e)}}),(0,X.jsx)(`main`,{className:`mobile-shell__viewport`,children:(0,X.jsx)(`div`,{className:`mobile-shell__content`,children:w.length>0?(0,X.jsx)(X.Fragment,{children:d?(0,X.jsx)(`section`,{className:`mobile-shell__agent-stage`,children:(0,X.jsx)(cw,{sessionId:d.id,showHeaderActions:!1,showSupervisorInline:d.capability===`full`&&d.state!==`draft`&&d.state!==`ended`})}):null}):(0,X.jsx)(`section`,{className:`mobile-shell__agent-empty`,"data-testid":`mobile-agent-empty`,children:(0,X.jsx)(`div`,{className:`mobile-shell__empty-content mobile-shell__empty-content--flat`,children:(0,X.jsxs)(`div`,{className:`mobile-shell__empty-state`,children:[(0,X.jsx)(`div`,{className:`mobile-shell__empty-heading`,children:(0,X.jsx)(`p`,{className:`mobile-shell__empty-title`,children:i(`mobile.empty.start_session`)})}),(0,X.jsx)(`div`,{className:`mobile-shell__placeholder-copy`,children:(0,X.jsx)(`p`,{children:i(`mobile.empty.files_terminal_hint`)})}),(0,X.jsx)(`div`,{className:`mobile-shell__empty-action-row`,children:(0,X.jsx)(`button`,{type:`button`,className:`mobile-shell__empty-cta`,onClick:()=>P(!0),children:i(`action.create_session`)})})]})})})})}),(0,X.jsxs)(`div`,{className:`mobile-shell__bottom-stack`,"data-testid":`mobile-bottom-stack`,style:{"--mobile-keyboard-inset":`${ae}px`},children:[(0,X.jsx)(`div`,{className:`mobile-dock-shell`,children:(0,X.jsx)(NO,{activeItem:me,onSelectItem:pe})}),f?(0,X.jsx)(aO,{workspaceId:f,gitState:v,onOpenBranchSwitcher:_}):null]}),N?(0,X.jsx)(MO,{activeSessionId:y,activeWorkspaceId:f,defaultMode:b.length===0?`create`:`list`,sessions:b,onClose:()=>P(!1),onCloseSession:p,onSelectSession:E,onSessionCreated:g}):null,S===`supervisor`&&d?(0,X.jsx)(xO,{sessionId:d.id,workspaceId:d.workspaceId,onClose:()=>{P(!1),m()}}):null,fe?(0,X.jsx)(fm,{title:fe.title,body:fe.body,onClose:()=>{P(!1),m()},kicker:fe.kicker??void 0,onBack:fe.onBack,backLabel:fe.backLabel,headerAction:`headerAction`in fe?fe.headerAction:void 0,bodyClassName:fe.bodyClassName,contentClassName:fe.contentClassName,footer:`footer`in fe?fe.footer:void 0,fullscreen:fe.fullscreen}):null,(0,X.jsx)(RO,{activeWorkspaceId:f,isOpen:j,workspaces:k,onClose:()=>M(!1),onOpenWorkspaceLauncher:()=>{P(!1),ne(!0)}}),te?(0,X.jsx)(Qv,{onClose:()=>ne(!1)}):null]})}var VO={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function HO(){mO();let e=U(Dp),t=Yt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname.startsWith(`/diagnostics`)||t.pathname===`/session-gate`;return(0,X.jsxs)(`div`,{className:`app`,children:[(0,X.jsx)(vO,{}),(0,X.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,X.jsx)(`div`,{className:`app-loading-shell`,children:(0,X.jsx)(`div`,{className:`app-loading-card`,children:(0,X.jsx)(Sh,{style:VO,title:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,X.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,X.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,X.jsxs)(Dn,{children:[(0,X.jsx)(Tn,{path:`/`,element:(0,X.jsx)(jx,{})}),(0,X.jsx)(Tn,{path:`/login`,element:(0,X.jsx)(zg,{})}),(0,X.jsx)(Tn,{path:`/session-gate`,element:(0,X.jsx)(Bg,{})}),(0,X.jsx)(Tn,{path:`/diagnostics`,element:(0,X.jsx)(Gv,{})}),(0,X.jsx)(Tn,{path:`/workspace`,element:(0,X.jsx)(pO,{children:(0,X.jsx)(BO,{})})}),(0,X.jsx)(Tn,{path:`/settings`,element:(0,X.jsx)(xx,{})}),(0,X.jsx)(Tn,{path:`*`,element:(0,X.jsx)(iy,{})})]})}),(0,X.jsx)(ty,{}),(0,X.jsx)(tO,{}),(0,X.jsx)(dy,{})]})}export{y_ as $,wn as $t,oS as A,Ep as At,By as B,Wa as Bt,aC as C,Dp as Ct,OS as D,Cp as Dt,jS as E,Op as Et,Vy as F,Qa as Ft,ty as G,wa as Gt,dy as H,Va as Ht,Ny as I,$a as It,J_ as J,Kr as Jt,Qv as K,pa as Kt,My as L,Za as Lt,jx as M,vp as Mt,xx as N,yp as Nt,TS as O,wp as Ot,Ob as P,io as Pt,p_ as Q,mr as Qt,Ay as R,Xa as Rt,cw as S,Pp as St,iC as T,xp as Tt,oy as U,Oa as Ut,by as V,ja as Vt,iy as W,ka as Wt,g_ as X,Ur as Xt,__ as Y,Wr as Yt,m_ as Z,Br as Zt,KE as _,Vp as _t,IO as a,U as an,e_ as at,lT as b,Mp as bt,bO as c,ge as cn,Ig as ct,cO as d,Bm as dt,Tn as en,u_ as et,aO as f,$ as ft,fD as g,tm as gt,ED as h,Z as ht,LO as i,Te as in,$g as it,aS as j,bp as jt,cS as k,Tp as kt,pO as l,fe as ln,jh as lt,PD as m,fm as mt,BO as n,je as nn,t_ as nt,NO as o,W as on,Bg as ot,tO as p,Em as pt,tv as q,Gr as qt,RO as r,ye as rn,Qg as rt,xO as s,ve as sn,zg as st,HO as t,Dn as tn,f_ as tt,dO as u,Sh as ut,GT as v,jp as vt,oC as w,Sp as wt,sT as x,Fp as xt,ST as y,Np as yt,Fy as z,Ga as zt};
|
|
109
|
+
//# sourceMappingURL=components-DmD8Ga_M.js.map
|