@spencer-kit/coder-studio 0.3.8 → 0.3.9

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.
@@ -92,20 +92,20 @@ 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=$a,s=!Ra.jitless,c=s&&eo.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?Sc([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Tc(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=>!go(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=>bo(e,r,za())))}),t)}var Ec=K(`$ZodUnion`,(e,t)=>{Rs.init(e,t),qa(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),qa(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),qa(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),qa(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=>Wa(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=>Tc(t,r,e,i)):Tc(o,r,e,i)}}),Dc=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ec.init(e,t);let n=e._zod.parse;qa(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=Ha(()=>{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(!$a(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)}}),Oc=K(`$ZodIntersection`,(e,t)=>{Rs.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])=>Ac(e,t,n)):Ac(e,i,a)}});function kc(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(to(e)&&to(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=kc(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=kc(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 Ac(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}),go(e))return e;let o=kc(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var jc=K(`$ZodRecord`,(e,t)=>{Rs.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!to(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=>bo(e,r,za())),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(...vo(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...vo(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`&&hs.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=>bo(e,r,za())),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(...vo(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...vo(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Mc=K(`$ZodEnum`,(e,t)=>{Rs.init(e,t);let n=Ba(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ro.has(typeof e)).map(e=>typeof e==`string`?io(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}}),Nc=K(`$ZodLiteral`,(e,t)=>{if(Rs.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`?io(e):e?io(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}}),Pc=K(`$ZodTransform`,(e,t)=>{Rs.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new La(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 Ia;return n.value=i,n.fallback=!0,n}});function Fc(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ic=K(`$ZodOptional`,(e,t)=>{Rs.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,qa(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),qa(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Wa(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=>Fc(e,r)):Fc(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Lc=K(`$ZodExactOptional`,(e,t)=>{Ic.init(e,t),qa(e._zod,`values`,()=>t.innerType._zod.values),qa(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Rc=K(`$ZodNullable`,(e,t)=>{Rs.init(e,t),qa(e._zod,`optin`,()=>t.innerType._zod.optin),qa(e._zod,`optout`,()=>t.innerType._zod.optout),qa(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Wa(e.source)}|null)$`):void 0}),qa(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)}),zc=K(`$ZodDefault`,(e,t)=>{Rs.init(e,t),e._zod.optin=`optional`,qa(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=>Bc(e,t)):Bc(r,t)}});function Bc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Vc=K(`$ZodPrefault`,(e,t)=>{Rs.init(e,t),e._zod.optin=`optional`,qa(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))}),Hc=K(`$ZodNonOptional`,(e,t)=>{Rs.init(e,t),qa(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=>Uc(t,e)):Uc(i,e)}});function Uc(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 Wc=K(`$ZodCatch`,(e,t)=>{Rs.init(e,t),e._zod.optin=`optional`,qa(e._zod,`optout`,()=>t.innerType._zod.optout),qa(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=>bo(e,n,za()))},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=>bo(e,n,za()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Gc=K(`$ZodPipe`,(e,t)=>{Rs.init(e,t),qa(e._zod,`values`,()=>t.in._zod.values),qa(e._zod,`optin`,()=>t.in._zod.optin),qa(e._zod,`optout`,()=>t.out._zod.optout),qa(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=>Kc(e,t.in,n)):Kc(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kc(e,t.out,n)):Kc(r,t.out,n)}});function Kc(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 qc=K(`$ZodReadonly`,(e,t)=>{Rs.init(e,t),qa(e._zod,`propValues`,()=>t.innerType._zod.propValues),qa(e._zod,`values`,()=>t.innerType._zod.values),qa(e._zod,`optin`,()=>t.innerType?._zod?.optin),qa(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(Jc):Jc(r)}});function Jc(e){return e.value=Object.freeze(e.value),e}var Yc=K(`$ZodCustom`,(e,t)=>{ys.init(e,t),Rs.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=>Xc(t,n,r,e));Xc(i,n,r,e)}});function Xc(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(So(e))}}var Zc,Qc=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 $c(){return new Qc}(Zc=globalThis).__zod_globalRegistry??(Zc.__zod_globalRegistry=$c());var el=globalThis.__zod_globalRegistry;function tl(e,t){return new e({type:`string`,...q(t)})}function nl(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...q(t)})}function rl(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...q(t)})}function il(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...q(t)})}function al(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...q(t)})}function ol(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...q(t)})}function sl(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...q(t)})}function cl(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...q(t)})}function ll(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...q(t)})}function ul(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...q(t)})}function dl(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...q(t)})}function fl(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...q(t)})}function pl(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...q(t)})}function ml(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...q(t)})}function hl(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...q(t)})}function gl(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...q(t)})}function _l(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...q(t)})}function vl(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...q(t)})}function yl(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...q(t)})}function bl(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...q(t)})}function xl(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...q(t)})}function Sl(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...q(t)})}function Cl(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...q(t)})}function wl(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...q(t)})}function Tl(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...q(t)})}function El(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...q(t)})}function Dl(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...q(t)})}function Ol(e,t){return new e({type:`number`,checks:[],...q(t)})}function kl(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...q(t)})}function Al(e,t){return new e({type:`boolean`,...q(t)})}function jl(e){return new e({type:`unknown`})}function Ml(e,t){return new e({type:`never`,...q(t)})}function Nl(e,t){return new xs({check:`less_than`,...q(t),value:e,inclusive:!1})}function Pl(e,t){return new xs({check:`less_than`,...q(t),value:e,inclusive:!0})}function Fl(e,t){return new Ss({check:`greater_than`,...q(t),value:e,inclusive:!1})}function Il(e,t){return new Ss({check:`greater_than`,...q(t),value:e,inclusive:!0})}function Ll(e,t){return new Cs({check:`multiple_of`,...q(t),value:e})}function Rl(e,t){return new Ts({check:`max_length`,...q(t),maximum:e})}function zl(e,t){return new Es({check:`min_length`,...q(t),minimum:e})}function Bl(e,t){return new Ds({check:`length_equals`,...q(t),length:e})}function Vl(e,t){return new ks({check:`string_format`,format:`regex`,...q(t),pattern:e})}function Hl(e){return new As({check:`string_format`,format:`lowercase`,...q(e)})}function Ul(e){return new js({check:`string_format`,format:`uppercase`,...q(e)})}function Wl(e,t){return new Ms({check:`string_format`,format:`includes`,...q(t),includes:e})}function Gl(e,t){return new Ns({check:`string_format`,format:`starts_with`,...q(t),prefix:e})}function Kl(e,t){return new Ps({check:`string_format`,format:`ends_with`,...q(t),suffix:e})}function ql(e){return new Fs({check:`overwrite`,tx:e})}function Jl(e){return ql(t=>t.normalize(e))}function Yl(){return ql(e=>e.trim())}function Xl(){return ql(e=>e.toLowerCase())}function Zl(){return ql(e=>e.toUpperCase())}function Ql(){return ql(e=>Za(e))}function $l(e,t,n){return new e({type:`array`,element:t,...q(n)})}function eu(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...q(n)})}function tu(e,t){let n=nu(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(So(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(So(r))}},e(t.value,t)),t);return n}function nu(e,t){let n=new ys({check:`custom`,...q(t)});return n._zod.check=e,n}function ru(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??el,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 iu(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,iu(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`&&su(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 au(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 ou(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:lu(t,`input`,e.processors),output:lu(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function su(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 su(r.element,n);if(r.type===`set`)return su(r.valueType,n);if(r.type===`lazy`)return su(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 su(r.innerType,n);if(r.type===`intersection`)return su(r.left,n)||su(r.right,n);if(r.type===`record`||r.type===`map`)return su(r.keyType,n)||su(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:su(r.in,n)||su(r.out,n);if(r.type===`object`){for(let e in r.shape)if(su(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(su(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(su(e,n))return!0;return!!(r.rest&&su(r.rest,n))}return!1}var cu=(e,t={})=>n=>{let r=ru({...n,processors:t});return iu(e,r),au(r,e),ou(r,e)},lu=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ru({...i??{},target:a,io:t,processors:n});return iu(e,o),au(o,e),ou(o,e)},uu={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},du=(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=uu[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}))])}},fu=(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)},pu=(e,t,n,r)=>{n.type=`boolean`},mu=(e,t,n,r)=>{n.not={}},hu=(e,t,n,r)=>{let i=e._zod.def,a=Ba(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},gu=(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},_u=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},vu=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},yu=(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=iu(a.element,t,{...r,path:[...r.path,`items`]})},bu=(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]=iu(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=iu(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},xu=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>iu(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Su=(e,t,n,r)=>{let i=e._zod.def,a=iu(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=iu(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]]},Cu=(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=iu(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=iu(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=iu(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)}},wu=(e,t,n,r)=>{let i=e._zod.def,a=iu(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`}]},Tu=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Eu=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Du=(e,t,n,r)=>{let i=e._zod.def;iu(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)))},Ou=(e,t,n,r)=>{let i=e._zod.def;iu(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},ku=(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;iu(o,t,r);let s=t.seen.get(e);s.ref=o},Au=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ju=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mu=K(`ZodISODateTime`,(e,t)=>{Qs.init(e,t),ad.init(e,t)});function Nu(e){return wl(Mu,e)}var Pu=K(`ZodISODate`,(e,t)=>{$s.init(e,t),ad.init(e,t)});function Fu(e){return Tl(Pu,e)}var Iu=K(`ZodISOTime`,(e,t)=>{ec.init(e,t),ad.init(e,t)});function Lu(e){return El(Iu,e)}var Ru=K(`ZodISODuration`,(e,t)=>{tc.init(e,t),ad.init(e,t)});function zu(e){return Dl(Ru,e)}var Bu=K(`ZodError`,(e,t)=>{wo.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Do(e,t)},flatten:{value:t=>Eo(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Va,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Va,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Vu=Oo(Bu),Hu=ko(Bu),Uu=Ao(Bu),Wu=Mo(Bu),Gu=Po(Bu),Ku=Fo(Bu),qu=Io(Bu),Ju=Lo(Bu),Yu=Ro(Bu),Xu=zo(Bu),Zu=Bo(Bu),Qu=Vo(Bu),$u=new WeakMap;function ed(e,t,n){let r=Object.getPrototypeOf(e),i=$u.get(r);if(i||(i=new Set,$u.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 td=K(`ZodType`,(e,t)=>(Rs.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:lu(e,`input`),output:lu(e,`output`)}}),e.toJSONSchema=cu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Vu(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Uu(e,t,n),e.parseAsync=async(t,n)=>Hu(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Wu(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Gu(e,t,n),e.decode=(t,n)=>Ku(e,t,n),e.encodeAsync=async(t,n)=>qu(e,t,n),e.decodeAsync=async(t,n)=>Ju(e,t,n),e.safeEncode=(t,n)=>Yu(e,t,n),e.safeDecode=(t,n)=>Xu(e,t,n),e.safeEncodeAsync=async(t,n)=>Zu(e,t,n),e.safeDecodeAsync=async(t,n)=>Qu(e,t,n),ed(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Ya(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 ao(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(yf(e,t))},superRefine(e,t){return this.check(bf(e,t))},overwrite(e){return this.check(ql(e))},optional(){return ef(this)},exactOptional(){return nf(this)},nullable(){return af(this)},nullish(){return ef(af(this))},nonoptional(e){return df(this,e)},array(){return Id(this)},or(e){return Bd([this,e])},and(e){return Wd(this,e)},transform(e){return hf(this,Qd(e))},default(e){return sf(this,e)},prefault(e){return lf(this,e)},catch(e){return pf(this,e)},pipe(e){return hf(this,e)},readonly(){return _f(this)},describe(e){let t=this.clone();return el.add(t,{description:e}),t},meta(...e){if(e.length===0)return el.get(this);let t=this.clone();return el.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 el.get(e)?.description},configurable:!0}),e)),nd=K(`_ZodString`,(e,t)=>{zs.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>du(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ed(e,`_ZodString`,{regex(...e){return this.check(Vl(...e))},includes(...e){return this.check(Wl(...e))},startsWith(...e){return this.check(Gl(...e))},endsWith(...e){return this.check(Kl(...e))},min(...e){return this.check(zl(...e))},max(...e){return this.check(Rl(...e))},length(...e){return this.check(Bl(...e))},nonempty(...e){return this.check(zl(1,...e))},lowercase(e){return this.check(Hl(e))},uppercase(e){return this.check(Ul(e))},trim(){return this.check(Yl())},normalize(...e){return this.check(Jl(...e))},toLowerCase(){return this.check(Xl())},toUpperCase(){return this.check(Zl())},slugify(){return this.check(Ql())}})}),rd=K(`ZodString`,(e,t)=>{zs.init(e,t),nd.init(e,t),e.email=t=>e.check(nl(od,t)),e.url=t=>e.check(cl(ld,t)),e.jwt=t=>e.check(Cl(wd,t)),e.emoji=t=>e.check(ll(ud,t)),e.guid=t=>e.check(rl(sd,t)),e.uuid=t=>e.check(il(cd,t)),e.uuidv4=t=>e.check(al(cd,t)),e.uuidv6=t=>e.check(ol(cd,t)),e.uuidv7=t=>e.check(sl(cd,t)),e.nanoid=t=>e.check(ul(dd,t)),e.guid=t=>e.check(rl(sd,t)),e.cuid=t=>e.check(dl(fd,t)),e.cuid2=t=>e.check(fl(pd,t)),e.ulid=t=>e.check(pl(md,t)),e.base64=t=>e.check(bl(xd,t)),e.base64url=t=>e.check(xl(Sd,t)),e.xid=t=>e.check(ml(hd,t)),e.ksuid=t=>e.check(hl(gd,t)),e.ipv4=t=>e.check(gl(_d,t)),e.ipv6=t=>e.check(_l(vd,t)),e.cidrv4=t=>e.check(vl(yd,t)),e.cidrv6=t=>e.check(yl(bd,t)),e.e164=t=>e.check(Sl(Cd,t)),e.datetime=t=>e.check(Nu(t)),e.date=t=>e.check(Fu(t)),e.time=t=>e.check(Lu(t)),e.duration=t=>e.check(zu(t))});function id(e){return tl(rd,e)}var ad=K(`ZodStringFormat`,(e,t)=>{Bs.init(e,t),nd.init(e,t)}),od=K(`ZodEmail`,(e,t)=>{Us.init(e,t),ad.init(e,t)}),sd=K(`ZodGUID`,(e,t)=>{Vs.init(e,t),ad.init(e,t)}),cd=K(`ZodUUID`,(e,t)=>{Hs.init(e,t),ad.init(e,t)}),ld=K(`ZodURL`,(e,t)=>{Ws.init(e,t),ad.init(e,t)}),ud=K(`ZodEmoji`,(e,t)=>{Gs.init(e,t),ad.init(e,t)}),dd=K(`ZodNanoID`,(e,t)=>{Ks.init(e,t),ad.init(e,t)}),fd=K(`ZodCUID`,(e,t)=>{qs.init(e,t),ad.init(e,t)}),pd=K(`ZodCUID2`,(e,t)=>{Js.init(e,t),ad.init(e,t)}),md=K(`ZodULID`,(e,t)=>{Ys.init(e,t),ad.init(e,t)}),hd=K(`ZodXID`,(e,t)=>{Xs.init(e,t),ad.init(e,t)}),gd=K(`ZodKSUID`,(e,t)=>{Zs.init(e,t),ad.init(e,t)}),_d=K(`ZodIPv4`,(e,t)=>{nc.init(e,t),ad.init(e,t)}),vd=K(`ZodIPv6`,(e,t)=>{rc.init(e,t),ad.init(e,t)}),yd=K(`ZodCIDRv4`,(e,t)=>{ic.init(e,t),ad.init(e,t)}),bd=K(`ZodCIDRv6`,(e,t)=>{ac.init(e,t),ad.init(e,t)}),xd=K(`ZodBase64`,(e,t)=>{sc.init(e,t),ad.init(e,t)}),Sd=K(`ZodBase64URL`,(e,t)=>{lc.init(e,t),ad.init(e,t)}),Cd=K(`ZodE164`,(e,t)=>{uc.init(e,t),ad.init(e,t)}),wd=K(`ZodJWT`,(e,t)=>{fc.init(e,t),ad.init(e,t)}),Td=K(`ZodNumber`,(e,t)=>{pc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fu(e,t,n,r),ed(e,`ZodNumber`,{gt(e,t){return this.check(Fl(e,t))},gte(e,t){return this.check(Il(e,t))},min(e,t){return this.check(Il(e,t))},lt(e,t){return this.check(Nl(e,t))},lte(e,t){return this.check(Pl(e,t))},max(e,t){return this.check(Pl(e,t))},int(e){return this.check(Od(e))},safe(e){return this.check(Od(e))},positive(e){return this.check(Fl(0,e))},nonnegative(e){return this.check(Il(0,e))},negative(e){return this.check(Nl(0,e))},nonpositive(e){return this.check(Pl(0,e))},multipleOf(e,t){return this.check(Ll(e,t))},step(e,t){return this.check(Ll(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 Ed(e){return Ol(Td,e)}var Dd=K(`ZodNumberFormat`,(e,t)=>{mc.init(e,t),Td.init(e,t)});function Od(e){return kl(Dd,e)}var kd=K(`ZodBoolean`,(e,t)=>{hc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pu(e,t,n,r)});function Ad(e){return Al(kd,e)}var jd=K(`ZodUnknown`,(e,t)=>{gc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Md(){return jl(jd)}var Nd=K(`ZodNever`,(e,t)=>{_c.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mu(e,t,n,r)});function Pd(e){return Ml(Nd,e)}var Fd=K(`ZodArray`,(e,t)=>{yc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yu(e,t,n,r),e.element=t.element,ed(e,`ZodArray`,{min(e,t){return this.check(zl(e,t))},nonempty(e){return this.check(zl(1,e))},max(e,t){return this.check(Rl(e,t))},length(e,t){return this.check(Bl(e,t))},unwrap(){return this.element}})});function Id(e,t){return $l(Fd,e,t)}var Ld=K(`ZodObject`,(e,t)=>{wc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bu(e,t,n,r),qa(e,`shape`,()=>t.shape),ed(e,`ZodObject`,{keyof(){return Jd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Md()})},loose(){return this.clone({...this._zod.def,catchall:Md()})},strict(){return this.clone({...this._zod.def,catchall:Pd()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return uo(this,e)},safeExtend(e){return fo(this,e)},merge(e){return po(this,e)},pick(e){return co(this,e)},omit(e){return lo(this,e)},partial(...e){return mo($d,this,e[0])},required(...e){return ho(uf,this,e[0])}})});function Rd(e,t){return new Ld({type:`object`,shape:e??{},...q(t)})}var zd=K(`ZodUnion`,(e,t)=>{Ec.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xu(e,t,n,r),e.options=t.options});function Bd(e,t){return new zd({type:`union`,options:e,...q(t)})}var Vd=K(`ZodDiscriminatedUnion`,(e,t)=>{zd.init(e,t),Dc.init(e,t)});function Hd(e,t,n){return new Vd({type:`union`,options:t,discriminator:e,...q(n)})}var Ud=K(`ZodIntersection`,(e,t)=>{Oc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Su(e,t,n,r)});function Wd(e,t){return new Ud({type:`intersection`,left:e,right:t})}var Gd=K(`ZodRecord`,(e,t)=>{jc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cu(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Kd(e,t,n){return!t||!t._zod?new Gd({type:`record`,keyType:id(),valueType:e,...q(t)}):new Gd({type:`record`,keyType:e,valueType:t,...q(n)})}var qd=K(`ZodEnum`,(e,t)=>{Mc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hu(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 qd({...t,checks:[],...q(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 qd({...t,checks:[],...q(r),entries:i})}});function Jd(e,t){return new qd({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...q(t)})}var Yd=K(`ZodLiteral`,(e,t)=>{Nc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gu(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 Xd(e,t){return new Yd({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}var Zd=K(`ZodTransform`,(e,t)=>{Pc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vu(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new La(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(So(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(So(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 Qd(e){return new Zd({type:`transform`,transform:e})}var $d=K(`ZodOptional`,(e,t)=>{Ic.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ju(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ef(e){return new $d({type:`optional`,innerType:e})}var tf=K(`ZodExactOptional`,(e,t)=>{Lc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ju(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nf(e){return new tf({type:`optional`,innerType:e})}var rf=K(`ZodNullable`,(e,t)=>{Rc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function af(e){return new rf({type:`nullable`,innerType:e})}var of=K(`ZodDefault`,(e,t)=>{zc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sf(e,t){return new of({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():no(t)}})}var cf=K(`ZodPrefault`,(e,t)=>{Vc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Du(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lf(e,t){return new cf({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():no(t)}})}var uf=K(`ZodNonOptional`,(e,t)=>{Hc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function df(e,t){return new uf({type:`nonoptional`,innerType:e,...q(t)})}var ff=K(`ZodCatch`,(e,t)=>{Wc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ou(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pf(e,t){return new ff({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var mf=K(`ZodPipe`,(e,t)=>{Gc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ku(e,t,n,r),e.in=t.in,e.out=t.out});function hf(e,t){return new mf({type:`pipe`,in:e,out:t})}var gf=K(`ZodReadonly`,(e,t)=>{qc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Au(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _f(e){return new gf({type:`readonly`,innerType:e})}var vf=K(`ZodCustom`,(e,t)=>{Yc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_u(e,t,n,r)});function yf(e,t={}){return eu(vf,e,t)}function bf(e,t){return tu(e,t)}var xf={Output:1,Replay:2,Input:3,Snapshot:4},Sf=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}},Cf=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}},wf=Rd({kind:Xd(`command`),id:id().uuid(),op:id(),args:Md()}),Tf=Rd({kind:Xd(`result`),id:id().uuid(),ok:Ad(),data:Md().optional(),error:Rd({code:id(),message:id(),details:Md().optional()}).optional()}),Ef=Rd({kind:Xd(`event`),topic:id(),seq:Ed().int().nonnegative(),timestamp:Ed().int().positive(),data:Md()});Hd(`kind`,[wf,Rd({kind:Xd(`subscribe`),topics:Id(id())}),Rd({kind:Xd(`unsubscribe`),topics:Id(id())}),Rd({kind:Xd(`resync`),lastSeen:Kd(id(),Ed())})]),Hd(`kind`,[Tf,Ef]);var Df={connectionStatus:`connection.status`,connectionReady:`connection.ready`,workspaceMeta:e=>`workspace.${e}.meta`,workspaceFsDirty:e=>`workspace.${e}.fs.dirty`,workspaceGitState:e=>`workspace.${e}.git.state`,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`,terminalExit:(e,t)=>`workspace.${e}.terminal.${t}.exit`,terminalsAll:e=>`workspace.${e}.terminal.*`,notificationToast:`notification.toast`,supervisorState:(e,t)=>`workspace.${e}.session.${t}.supervisor.state`,supervisorCycle:(e,t)=>`workspace.${e}.session.${t}.supervisor.cycle`};function Of(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 kf=class extends Error{constructor(e){super(e.message),this.name=`CommandResultError`,this.code=e.code,this.details=e.details}},Af={maxAttempts:1/0,baseDelayMs:1e3,maxDelayMs:3e4},jf=3e4,Mf=2500,Nf=()=>{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(`-`)},Pf=class{constructor(e,t={}){this.ws=null,this.connectDeferred=null,this.pendingCommands=new Map,this.eventListeners=new Map,this.statusListeners=new Set,this.recoveryListeners=new Set,this.lastSeenSeq=new Map,this.pendingBinaryStreamIds=new Map,this.orphanBinaryPayloads=new Map,this.nextTerminalInputStreamId=1,this.reconnectAttempts=0,this.reconnectTimer=null,this.recoveryProbeTimer=null,this.recoveryProbeCommandId=null,this.activeRecoveryTrigger=null,this.isManualClose=!1,this.status=`disconnected`,this.url=e,this.reconnectConfig={...Af,...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,this.clearRecoveryProbeState();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.activeRecoveryTrigger&&=(this.notifyRecoveryListeners(`reconnected`),null),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.clearRecoveryProbeState(),this.activeRecoveryTrigger=null,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.probeConnectedSocket(e);return}t!==`connecting`&&(this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.reconnectAttempts=0,this.activeRecoveryTrigger=e,console.log(`[WsClient] Recovering connection after ${e}`),this.connect().catch(e=>{console.error(`Recovery connect failed:`,e)}))}}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=Nf(),o=n.timeoutMs??jf,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=Nf(),s=this.allocateTerminalInputStreamId(),c=setTimeout(()=>{this.cleanupTimedOutBinaryCommand(o),this.pendingCommands.delete(o),a(Error(`Command timeout: terminal.input`))},jf);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)}onRecovery(e){return this.recoveryListeners.add(e),()=>this.recoveryListeners.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 kf({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=Cf(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}=Sf(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)},jf)});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(Of(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?xf.Snapshot:xf.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.clearRecoveryProbeState(),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)}}probeConnectedSocket(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.activeRecoveryTrigger=e,this.forceReconnect(`probe_socket_unavailable`);return}if(this.recoveryProbeCommandId)return;let t=Nf(),n=setTimeout(()=>{this.recoveryProbeCommandId===t&&this.forceReconnect(`probe_timeout`)},Mf);this.recoveryProbeCommandId=t,this.recoveryProbeTimer=n,this.activeRecoveryTrigger=e;let r=this.pendingCommands.get(t);r&&(clearTimeout(r.timeoutId),this.pendingCommands.delete(t)),this.pendingCommands.set(t,{resolve:()=>{this.clearRecoveryProbeState(),this.notifyRecoveryListeners(e),this.activeRecoveryTrigger=null},reject:()=>{this.recoveryProbeCommandId===t&&this.forceReconnect(`probe_rejected`)},timeoutId:n});let i={kind:`command`,id:t,op:`connection.probe`,args:{}};this.ws.send(JSON.stringify(i))}forceReconnect(e){if(this.clearRecoveryProbeState(),this.ws){let t=this.ws;this.ws=null;try{t.close(4e3,e)}catch{}}this.handleClose(1006,e)}clearRecoveryProbeState(){if(this.recoveryProbeTimer&&=(clearTimeout(this.recoveryProbeTimer),null),this.recoveryProbeCommandId){let e=this.pendingCommands.get(this.recoveryProbeCommandId);e&&(clearTimeout(e.timeoutId),this.pendingCommands.delete(this.recoveryProbeCommandId)),this.recoveryProbeCommandId=null}}notifyRecoveryListeners(e){for(let t of this.recoveryListeners)try{t(e)}catch(e){console.error(`Error in recovery listener:`,e)}}};function Ff(){return typeof window>`u`?`ws://127.0.0.1:4173/ws`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/ws`}var If=B(null),Lf=B(`connecting`),Rf=B(null),zf=B(!1),Bf=B(null),Vf=B(0),Hf=B(null),Uf=B(null),Wf=B(e=>{let t=e(If);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 kf?{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`}}}}});B(`tab_${Date.now()}_${Math.random().toString(36).substring(2,9)}`);var Gf=B(new Map);B(e=>t=>e(Gf).get(t)?.isController??!1),B(e=>t=>e(Gf).get(t)?.reason),B(e=>{let t=e(Gf);for(let e of t.values())if(!e.isController)return!0;return!1});function Kf(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 qf=B(null),Jf=B({}),Yf=B([]),Xf=B(`idle`),Zf=B(null),Qf=Kf(e=>B(t=>t(Jf)[e])),$f=B(e=>{let t=e(Yf),n=e(Jf),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]}),ep=B(e=>e($f).map(t=>e(Qf(t))).filter(e=>!!e)),tp=B(e=>{if(e(Xf)!==`ready`)return null;let t=e(qf),n=e(Jf);return t&&n[t]?t:e($f)[0]??null}),np=B(e=>{let t=e(tp);return t?e(Qf(t)):null}),rp=B({}),ip=Kf(e=>B(t=>{let n=t(rp);return Object.values(n).filter(t=>t.workspaceId===e)})),ap=Kf(e=>B(t=>t(rp)[e]));B(e=>{let t=e(tp);return t?e(ip(t)).find(e=>e.state===`running`||e.state===`idle`)??null:null}),Kf(e=>B(t=>{let n=t(ip(e)),r={draft:0,starting:0,running:0,idle:0,ended:0};for(let e of n)r[e.state]++;return r}));function op(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=op(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function J(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=op(e))&&(r&&(r+=` `),r+=t);return r}function sp(e){return e.target===e.currentTarget}function cp(e){return e.key===`Escape`}var lp=[`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 up(e){return e instanceof HTMLElement}function dp(e){return Array.from(e.querySelectorAll(lp)).filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`)}function fp(e,t){let n=typeof t==`function`?t():t;return n&&e.contains(n)&&!n.hasAttribute(`disabled`)?n:dp(e)[0]??e}function pp(e,t){if(t.key!==`Tab`)return;let n=dp(e);if(n.length===0){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],a=up(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 mp(e){e instanceof HTMLElement&&e.isConnected&&e.focus()}var hp=e(Te(),1);function gp({children:e}){let t=typeof document>`u`?null:document.body;return t?(0,hp.createPortal)(e,t):null}var _p=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})),Y=t(((e,t)=>{t.exports=_p()}))();function vp({title:e,onBack:t,backLabel:n=`Back`,backAriaLabel:r,kicker:i,rightSlot:a,titleAs:o=`h2`,className:s}){let c=o;return(0,Y.jsxs)(`div`,{className:J(`page-header`,s),children:[(0,Y.jsxs)(`div`,{className:`page-header__leading`,children:[t?(0,Y.jsxs)(`button`,{type:`button`,className:`page-header__back`,onClick:t,"aria-label":r??n,children:[(0,Y.jsx)(ti,{size:16}),(0,Y.jsx)(`span`,{children:n})]}):null,(0,Y.jsxs)(`div`,{className:`page-header__copy`,children:[i?(0,Y.jsx)(`div`,{className:`page-header__kicker`,children:i}):null,(0,Y.jsx)(c,{className:`page-header__title`,children:e})]})]}),a?(0,Y.jsx)(`div`,{className:`page-header__actions`,children:a}):null]})}function yp({className:e,kicker:t,showKicker:n=!1,...r}){return(0,Y.jsx)(vp,{...r,kicker:n?t:void 0,className:J(`mobile-page-header`,e)})}var bp={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`,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`},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`,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`,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`}},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 could not be restored`,failed_body:`New output will keep streaming. Refresh manually only if you need the missing history.`,closed_title:`This session has been closed`,closed_body:`Start a new 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`,delete:`Delete`,delete_confirm:`Are you sure you want to delete "{name}"?`,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`,mode_text:`Text`,mode_image:`Image`,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:{title:`Settings`,general:`General`,appearance:`Appearance`,providers:`Agents`,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`,copy_on_select:`Copy on select`,copy_on_select_hint:`Automatically copy selected text to the system clipboard`,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
96
- --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`,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`,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`,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.`,needs_user_input:`Supervisor needs more user input before automatic supervision can continue.`},target_memory:{title:`Target memory`,target:`Target`,plan:`Plan`,stalled:`Stalled`,plan_ready:`Plan ready`,plan_pending:`Plan pending`,progress_title:`Target progress`,progress_badge:`PROGRESS`,plan_title:`Target plan`,reasoning_title:`Target cycle reasoning`,cycle_result:{continue:`CONTINUE`,stop:`STOP`,error:`ERROR`},step_status:{pending:`PENDING`,in_progress:`IN PROGRESS`,done:`DONE`}},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 ou(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:lu(t,`input`,e.processors),output:lu(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function su(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 su(r.element,n);if(r.type===`set`)return su(r.valueType,n);if(r.type===`lazy`)return su(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 su(r.innerType,n);if(r.type===`intersection`)return su(r.left,n)||su(r.right,n);if(r.type===`record`||r.type===`map`)return su(r.keyType,n)||su(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:su(r.in,n)||su(r.out,n);if(r.type===`object`){for(let e in r.shape)if(su(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(su(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(su(e,n))return!0;return!!(r.rest&&su(r.rest,n))}return!1}var cu=(e,t={})=>n=>{let r=ru({...n,processors:t});return iu(e,r),au(r,e),ou(r,e)},lu=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ru({...i??{},target:a,io:t,processors:n});return iu(e,o),au(o,e),ou(o,e)},uu={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},du=(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=uu[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}))])}},fu=(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)},pu=(e,t,n,r)=>{n.type=`boolean`},mu=(e,t,n,r)=>{n.not={}},hu=(e,t,n,r)=>{let i=e._zod.def,a=Ba(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},gu=(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},_u=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},vu=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},yu=(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=iu(a.element,t,{...r,path:[...r.path,`items`]})},bu=(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]=iu(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=iu(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},xu=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>iu(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Su=(e,t,n,r)=>{let i=e._zod.def,a=iu(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=iu(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]]},Cu=(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=iu(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=iu(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=iu(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)}},wu=(e,t,n,r)=>{let i=e._zod.def,a=iu(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`}]},Tu=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Eu=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Du=(e,t,n,r)=>{let i=e._zod.def;iu(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)))},Ou=(e,t,n,r)=>{let i=e._zod.def;iu(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},ku=(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;iu(o,t,r);let s=t.seen.get(e);s.ref=o},Au=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ju=(e,t,n,r)=>{let i=e._zod.def;iu(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mu=K(`ZodISODateTime`,(e,t)=>{Qs.init(e,t),ad.init(e,t)});function Nu(e){return wl(Mu,e)}var Pu=K(`ZodISODate`,(e,t)=>{$s.init(e,t),ad.init(e,t)});function Fu(e){return Tl(Pu,e)}var Iu=K(`ZodISOTime`,(e,t)=>{ec.init(e,t),ad.init(e,t)});function Lu(e){return El(Iu,e)}var Ru=K(`ZodISODuration`,(e,t)=>{tc.init(e,t),ad.init(e,t)});function zu(e){return Dl(Ru,e)}var Bu=K(`ZodError`,(e,t)=>{wo.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Do(e,t)},flatten:{value:t=>Eo(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Va,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Va,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Vu=Oo(Bu),Hu=ko(Bu),Uu=Ao(Bu),Wu=Mo(Bu),Gu=Po(Bu),Ku=Fo(Bu),qu=Io(Bu),Ju=Lo(Bu),Yu=Ro(Bu),Xu=zo(Bu),Zu=Bo(Bu),Qu=Vo(Bu),$u=new WeakMap;function ed(e,t,n){let r=Object.getPrototypeOf(e),i=$u.get(r);if(i||(i=new Set,$u.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 td=K(`ZodType`,(e,t)=>(Rs.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:lu(e,`input`),output:lu(e,`output`)}}),e.toJSONSchema=cu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Vu(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Uu(e,t,n),e.parseAsync=async(t,n)=>Hu(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Wu(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Gu(e,t,n),e.decode=(t,n)=>Ku(e,t,n),e.encodeAsync=async(t,n)=>qu(e,t,n),e.decodeAsync=async(t,n)=>Ju(e,t,n),e.safeEncode=(t,n)=>Yu(e,t,n),e.safeDecode=(t,n)=>Xu(e,t,n),e.safeEncodeAsync=async(t,n)=>Zu(e,t,n),e.safeDecodeAsync=async(t,n)=>Qu(e,t,n),ed(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Ya(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 ao(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(yf(e,t))},superRefine(e,t){return this.check(bf(e,t))},overwrite(e){return this.check(ql(e))},optional(){return ef(this)},exactOptional(){return nf(this)},nullable(){return af(this)},nullish(){return ef(af(this))},nonoptional(e){return df(this,e)},array(){return Id(this)},or(e){return Bd([this,e])},and(e){return Wd(this,e)},transform(e){return hf(this,Qd(e))},default(e){return sf(this,e)},prefault(e){return lf(this,e)},catch(e){return pf(this,e)},pipe(e){return hf(this,e)},readonly(){return _f(this)},describe(e){let t=this.clone();return el.add(t,{description:e}),t},meta(...e){if(e.length===0)return el.get(this);let t=this.clone();return el.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 el.get(e)?.description},configurable:!0}),e)),nd=K(`_ZodString`,(e,t)=>{zs.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>du(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ed(e,`_ZodString`,{regex(...e){return this.check(Vl(...e))},includes(...e){return this.check(Wl(...e))},startsWith(...e){return this.check(Gl(...e))},endsWith(...e){return this.check(Kl(...e))},min(...e){return this.check(zl(...e))},max(...e){return this.check(Rl(...e))},length(...e){return this.check(Bl(...e))},nonempty(...e){return this.check(zl(1,...e))},lowercase(e){return this.check(Hl(e))},uppercase(e){return this.check(Ul(e))},trim(){return this.check(Yl())},normalize(...e){return this.check(Jl(...e))},toLowerCase(){return this.check(Xl())},toUpperCase(){return this.check(Zl())},slugify(){return this.check(Ql())}})}),rd=K(`ZodString`,(e,t)=>{zs.init(e,t),nd.init(e,t),e.email=t=>e.check(nl(od,t)),e.url=t=>e.check(cl(ld,t)),e.jwt=t=>e.check(Cl(wd,t)),e.emoji=t=>e.check(ll(ud,t)),e.guid=t=>e.check(rl(sd,t)),e.uuid=t=>e.check(il(cd,t)),e.uuidv4=t=>e.check(al(cd,t)),e.uuidv6=t=>e.check(ol(cd,t)),e.uuidv7=t=>e.check(sl(cd,t)),e.nanoid=t=>e.check(ul(dd,t)),e.guid=t=>e.check(rl(sd,t)),e.cuid=t=>e.check(dl(fd,t)),e.cuid2=t=>e.check(fl(pd,t)),e.ulid=t=>e.check(pl(md,t)),e.base64=t=>e.check(bl(xd,t)),e.base64url=t=>e.check(xl(Sd,t)),e.xid=t=>e.check(ml(hd,t)),e.ksuid=t=>e.check(hl(gd,t)),e.ipv4=t=>e.check(gl(_d,t)),e.ipv6=t=>e.check(_l(vd,t)),e.cidrv4=t=>e.check(vl(yd,t)),e.cidrv6=t=>e.check(yl(bd,t)),e.e164=t=>e.check(Sl(Cd,t)),e.datetime=t=>e.check(Nu(t)),e.date=t=>e.check(Fu(t)),e.time=t=>e.check(Lu(t)),e.duration=t=>e.check(zu(t))});function id(e){return tl(rd,e)}var ad=K(`ZodStringFormat`,(e,t)=>{Bs.init(e,t),nd.init(e,t)}),od=K(`ZodEmail`,(e,t)=>{Us.init(e,t),ad.init(e,t)}),sd=K(`ZodGUID`,(e,t)=>{Vs.init(e,t),ad.init(e,t)}),cd=K(`ZodUUID`,(e,t)=>{Hs.init(e,t),ad.init(e,t)}),ld=K(`ZodURL`,(e,t)=>{Ws.init(e,t),ad.init(e,t)}),ud=K(`ZodEmoji`,(e,t)=>{Gs.init(e,t),ad.init(e,t)}),dd=K(`ZodNanoID`,(e,t)=>{Ks.init(e,t),ad.init(e,t)}),fd=K(`ZodCUID`,(e,t)=>{qs.init(e,t),ad.init(e,t)}),pd=K(`ZodCUID2`,(e,t)=>{Js.init(e,t),ad.init(e,t)}),md=K(`ZodULID`,(e,t)=>{Ys.init(e,t),ad.init(e,t)}),hd=K(`ZodXID`,(e,t)=>{Xs.init(e,t),ad.init(e,t)}),gd=K(`ZodKSUID`,(e,t)=>{Zs.init(e,t),ad.init(e,t)}),_d=K(`ZodIPv4`,(e,t)=>{nc.init(e,t),ad.init(e,t)}),vd=K(`ZodIPv6`,(e,t)=>{rc.init(e,t),ad.init(e,t)}),yd=K(`ZodCIDRv4`,(e,t)=>{ic.init(e,t),ad.init(e,t)}),bd=K(`ZodCIDRv6`,(e,t)=>{ac.init(e,t),ad.init(e,t)}),xd=K(`ZodBase64`,(e,t)=>{sc.init(e,t),ad.init(e,t)}),Sd=K(`ZodBase64URL`,(e,t)=>{lc.init(e,t),ad.init(e,t)}),Cd=K(`ZodE164`,(e,t)=>{uc.init(e,t),ad.init(e,t)}),wd=K(`ZodJWT`,(e,t)=>{fc.init(e,t),ad.init(e,t)}),Td=K(`ZodNumber`,(e,t)=>{pc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fu(e,t,n,r),ed(e,`ZodNumber`,{gt(e,t){return this.check(Fl(e,t))},gte(e,t){return this.check(Il(e,t))},min(e,t){return this.check(Il(e,t))},lt(e,t){return this.check(Nl(e,t))},lte(e,t){return this.check(Pl(e,t))},max(e,t){return this.check(Pl(e,t))},int(e){return this.check(Od(e))},safe(e){return this.check(Od(e))},positive(e){return this.check(Fl(0,e))},nonnegative(e){return this.check(Il(0,e))},negative(e){return this.check(Nl(0,e))},nonpositive(e){return this.check(Pl(0,e))},multipleOf(e,t){return this.check(Ll(e,t))},step(e,t){return this.check(Ll(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 Ed(e){return Ol(Td,e)}var Dd=K(`ZodNumberFormat`,(e,t)=>{mc.init(e,t),Td.init(e,t)});function Od(e){return kl(Dd,e)}var kd=K(`ZodBoolean`,(e,t)=>{hc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pu(e,t,n,r)});function Ad(e){return Al(kd,e)}var jd=K(`ZodUnknown`,(e,t)=>{gc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Md(){return jl(jd)}var Nd=K(`ZodNever`,(e,t)=>{_c.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mu(e,t,n,r)});function Pd(e){return Ml(Nd,e)}var Fd=K(`ZodArray`,(e,t)=>{yc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yu(e,t,n,r),e.element=t.element,ed(e,`ZodArray`,{min(e,t){return this.check(zl(e,t))},nonempty(e){return this.check(zl(1,e))},max(e,t){return this.check(Rl(e,t))},length(e,t){return this.check(Bl(e,t))},unwrap(){return this.element}})});function Id(e,t){return $l(Fd,e,t)}var Ld=K(`ZodObject`,(e,t)=>{wc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bu(e,t,n,r),qa(e,`shape`,()=>t.shape),ed(e,`ZodObject`,{keyof(){return Jd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Md()})},loose(){return this.clone({...this._zod.def,catchall:Md()})},strict(){return this.clone({...this._zod.def,catchall:Pd()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return uo(this,e)},safeExtend(e){return fo(this,e)},merge(e){return po(this,e)},pick(e){return co(this,e)},omit(e){return lo(this,e)},partial(...e){return mo($d,this,e[0])},required(...e){return ho(uf,this,e[0])}})});function Rd(e,t){return new Ld({type:`object`,shape:e??{},...q(t)})}var zd=K(`ZodUnion`,(e,t)=>{Ec.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xu(e,t,n,r),e.options=t.options});function Bd(e,t){return new zd({type:`union`,options:e,...q(t)})}var Vd=K(`ZodDiscriminatedUnion`,(e,t)=>{zd.init(e,t),Dc.init(e,t)});function Hd(e,t,n){return new Vd({type:`union`,options:t,discriminator:e,...q(n)})}var Ud=K(`ZodIntersection`,(e,t)=>{Oc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Su(e,t,n,r)});function Wd(e,t){return new Ud({type:`intersection`,left:e,right:t})}var Gd=K(`ZodRecord`,(e,t)=>{jc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cu(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Kd(e,t,n){return!t||!t._zod?new Gd({type:`record`,keyType:id(),valueType:e,...q(t)}):new Gd({type:`record`,keyType:e,valueType:t,...q(n)})}var qd=K(`ZodEnum`,(e,t)=>{Mc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hu(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 qd({...t,checks:[],...q(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 qd({...t,checks:[],...q(r),entries:i})}});function Jd(e,t){return new qd({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...q(t)})}var Yd=K(`ZodLiteral`,(e,t)=>{Nc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gu(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 Xd(e,t){return new Yd({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}var Zd=K(`ZodTransform`,(e,t)=>{Pc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vu(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new La(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(So(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(So(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 Qd(e){return new Zd({type:`transform`,transform:e})}var $d=K(`ZodOptional`,(e,t)=>{Ic.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ju(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ef(e){return new $d({type:`optional`,innerType:e})}var tf=K(`ZodExactOptional`,(e,t)=>{Lc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ju(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nf(e){return new tf({type:`optional`,innerType:e})}var rf=K(`ZodNullable`,(e,t)=>{Rc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function af(e){return new rf({type:`nullable`,innerType:e})}var of=K(`ZodDefault`,(e,t)=>{zc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sf(e,t){return new of({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():no(t)}})}var cf=K(`ZodPrefault`,(e,t)=>{Vc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Du(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lf(e,t){return new cf({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():no(t)}})}var uf=K(`ZodNonOptional`,(e,t)=>{Hc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function df(e,t){return new uf({type:`nonoptional`,innerType:e,...q(t)})}var ff=K(`ZodCatch`,(e,t)=>{Wc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ou(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pf(e,t){return new ff({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var mf=K(`ZodPipe`,(e,t)=>{Gc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ku(e,t,n,r),e.in=t.in,e.out=t.out});function hf(e,t){return new mf({type:`pipe`,in:e,out:t})}var gf=K(`ZodReadonly`,(e,t)=>{qc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Au(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _f(e){return new gf({type:`readonly`,innerType:e})}var vf=K(`ZodCustom`,(e,t)=>{Yc.init(e,t),td.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_u(e,t,n,r)});function yf(e,t={}){return eu(vf,e,t)}function bf(e,t){return tu(e,t)}var xf={Output:1,Replay:2,Input:3,Snapshot:4},Sf=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}},Cf=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}},wf=Rd({kind:Xd(`command`),id:id().uuid(),op:id(),args:Md()}),Tf=Rd({kind:Xd(`result`),id:id().uuid(),ok:Ad(),data:Md().optional(),error:Rd({code:id(),message:id(),details:Md().optional()}).optional()}),Ef=Rd({kind:Xd(`event`),topic:id(),seq:Ed().int().nonnegative(),timestamp:Ed().int().positive(),data:Md()});Hd(`kind`,[wf,Rd({kind:Xd(`subscribe`),topics:Id(id())}),Rd({kind:Xd(`unsubscribe`),topics:Id(id())}),Rd({kind:Xd(`resync`),lastSeen:Kd(id(),Ed())})]),Hd(`kind`,[Tf,Ef]);var Df={connectionStatus:`connection.status`,connectionReady:`connection.ready`,workspaceMeta:e=>`workspace.${e}.meta`,workspaceFsDirty:e=>`workspace.${e}.fs.dirty`,workspaceGitState:e=>`workspace.${e}.git.state`,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`,terminalExit:(e,t)=>`workspace.${e}.terminal.${t}.exit`,terminalsAll:e=>`workspace.${e}.terminal.*`,notificationToast:`notification.toast`,supervisorState:(e,t)=>`workspace.${e}.session.${t}.supervisor.state`,supervisorCycle:(e,t)=>`workspace.${e}.session.${t}.supervisor.cycle`};function Of(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 kf=class extends Error{constructor(e){super(e.message),this.name=`CommandResultError`,this.code=e.code,this.details=e.details}},Af={maxAttempts:1/0,baseDelayMs:1e3,maxDelayMs:3e4},jf=3e4,Mf=2500,Nf=()=>{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(`-`)},Pf=class{constructor(e,t={}){this.ws=null,this.connectDeferred=null,this.pendingCommands=new Map,this.eventListeners=new Map,this.statusListeners=new Set,this.recoveryListeners=new Set,this.lastSeenSeq=new Map,this.pendingBinaryStreamIds=new Map,this.orphanBinaryPayloads=new Map,this.nextTerminalInputStreamId=1,this.reconnectAttempts=0,this.reconnectTimer=null,this.recoveryProbeTimer=null,this.recoveryProbeCommandId=null,this.activeRecoveryTrigger=null,this.isManualClose=!1,this.status=`disconnected`,this.url=e,this.reconnectConfig={...Af,...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,this.clearRecoveryProbeState();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.activeRecoveryTrigger&&=(this.notifyRecoveryListeners(`reconnected`),null),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.clearRecoveryProbeState(),this.activeRecoveryTrigger=null,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.probeConnectedSocket(e);return}t!==`connecting`&&(this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.reconnectAttempts=0,this.activeRecoveryTrigger=e,console.log(`[WsClient] Recovering connection after ${e}`),this.connect().catch(e=>{console.error(`Recovery connect failed:`,e)}))}}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=Nf(),o=n.timeoutMs??jf,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=Nf(),s=this.allocateTerminalInputStreamId(),c=setTimeout(()=>{this.cleanupTimedOutBinaryCommand(o),this.pendingCommands.delete(o),a(Error(`Command timeout: terminal.input`))},jf);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)}onRecovery(e){return this.recoveryListeners.add(e),()=>this.recoveryListeners.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 kf({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=Cf(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}=Sf(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)},jf)});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(Of(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?xf.Snapshot:xf.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.clearRecoveryProbeState(),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)}}probeConnectedSocket(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.activeRecoveryTrigger=e,this.forceReconnect(`probe_socket_unavailable`);return}if(this.recoveryProbeCommandId)return;let t=Nf(),n=setTimeout(()=>{this.recoveryProbeCommandId===t&&this.forceReconnect(`probe_timeout`)},Mf);this.recoveryProbeCommandId=t,this.recoveryProbeTimer=n,this.activeRecoveryTrigger=e;let r=this.pendingCommands.get(t);r&&(clearTimeout(r.timeoutId),this.pendingCommands.delete(t)),this.pendingCommands.set(t,{resolve:()=>{this.clearRecoveryProbeState(),this.notifyRecoveryListeners(e),this.activeRecoveryTrigger=null},reject:()=>{this.recoveryProbeCommandId===t&&this.forceReconnect(`probe_rejected`)},timeoutId:n});let i={kind:`command`,id:t,op:`connection.probe`,args:{}};this.ws.send(JSON.stringify(i))}forceReconnect(e){if(this.clearRecoveryProbeState(),this.ws){let t=this.ws;this.ws=null;try{t.close(4e3,e)}catch{}}this.handleClose(1006,e)}clearRecoveryProbeState(){if(this.recoveryProbeTimer&&=(clearTimeout(this.recoveryProbeTimer),null),this.recoveryProbeCommandId){let e=this.pendingCommands.get(this.recoveryProbeCommandId);e&&(clearTimeout(e.timeoutId),this.pendingCommands.delete(this.recoveryProbeCommandId)),this.recoveryProbeCommandId=null}}notifyRecoveryListeners(e){for(let t of this.recoveryListeners)try{t(e)}catch(e){console.error(`Error in recovery listener:`,e)}}};function Ff(){return typeof window>`u`?`ws://127.0.0.1:4173/ws`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/ws`}var If=B(null),Lf=B(`connecting`),Rf=B(null),zf=B(!1),Bf=B(null),Vf=B(0),Hf=B(null),Uf=B(null),Wf=B(e=>{let t=e(If);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 kf?{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`}}}}});B(`tab_${Date.now()}_${Math.random().toString(36).substring(2,9)}`);var Gf=B(new Map);B(e=>t=>e(Gf).get(t)?.isController??!1),B(e=>t=>e(Gf).get(t)?.reason),B(e=>{let t=e(Gf);for(let e of t.values())if(!e.isController)return!0;return!1});function Kf(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 qf=B(null),Jf=B({}),Yf=B([]),Xf=B(`idle`),Zf=B(null),Qf=Kf(e=>B(t=>t(Jf)[e])),$f=B(e=>{let t=e(Yf),n=e(Jf),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]}),ep=B(e=>e($f).map(t=>e(Qf(t))).filter(e=>!!e)),tp=B(e=>{if(e(Xf)!==`ready`)return null;let t=e(qf),n=e(Jf);return t&&n[t]?t:e($f)[0]??null}),np=B(e=>{let t=e(tp);return t?e(Qf(t)):null}),rp=B({}),ip=Kf(e=>B(t=>{let n=t(rp);return Object.values(n).filter(t=>t.workspaceId===e)})),ap=Kf(e=>B(t=>t(rp)[e]));B(e=>{let t=e(tp);return t?e(ip(t)).find(e=>e.state===`running`||e.state===`idle`)??null:null}),Kf(e=>B(t=>{let n=t(ip(e)),r={draft:0,starting:0,running:0,idle:0,ended:0};for(let e of n)r[e.state]++;return r}));function op(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=op(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function J(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=op(e))&&(r&&(r+=` `),r+=t);return r}function sp(e){return e.target===e.currentTarget}function cp(e){return e.key===`Escape`}var lp=[`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 up(e){return e instanceof HTMLElement}function dp(e){return Array.from(e.querySelectorAll(lp)).filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`)}function fp(e,t){let n=typeof t==`function`?t():t;return n&&e.contains(n)&&!n.hasAttribute(`disabled`)?n:dp(e)[0]??e}function pp(e,t){if(t.key!==`Tab`)return;let n=dp(e);if(n.length===0){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],a=up(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 mp(e){e instanceof HTMLElement&&e.isConnected&&e.focus()}var hp=e(Te(),1);function gp({children:e}){let t=typeof document>`u`?null:document.body;return t?(0,hp.createPortal)(e,t):null}var _p=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})),Y=t(((e,t)=>{t.exports=_p()}))();function vp({title:e,onBack:t,backLabel:n=`Back`,backAriaLabel:r,kicker:i,rightSlot:a,titleAs:o=`h2`,className:s}){let c=o;return(0,Y.jsxs)(`div`,{className:J(`page-header`,s),children:[(0,Y.jsxs)(`div`,{className:`page-header__leading`,children:[t?(0,Y.jsxs)(`button`,{type:`button`,className:`page-header__back`,onClick:t,"aria-label":r??n,children:[(0,Y.jsx)(ti,{size:16}),(0,Y.jsx)(`span`,{children:n})]}):null,(0,Y.jsxs)(`div`,{className:`page-header__copy`,children:[i?(0,Y.jsx)(`div`,{className:`page-header__kicker`,children:i}):null,(0,Y.jsx)(c,{className:`page-header__title`,children:e})]})]}),a?(0,Y.jsx)(`div`,{className:`page-header__actions`,children:a}):null]})}function yp({className:e,kicker:t,showKicker:n=!1,...r}){return(0,Y.jsx)(vp,{...r,kicker:n?t:void 0,className:J(`mobile-page-header`,e)})}var bp={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`,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`},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`,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`,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`}},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 could not be restored`,failed_body:`New output will keep streaming. Refresh manually only if you need the missing history.`,closed_title:`This session has been closed`,closed_body:`Start a new 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`,delete:`Delete`,delete_confirm:`Are you sure you want to delete "{name}"?`,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`,mode_text:`Text`,mode_image:`Image`,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:{title:`Settings`,general:`General`,appearance:`Appearance`,providers:`Agents`,mobile_groups:{workspace_runtime:`Workspace & Runtime`,interface_interaction:`Interface & Interaction`},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`,copy_on_select:`Copy on select`,copy_on_select_hint:`Automatically copy selected text to the system clipboard`,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
96
+ --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`,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`,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`,plan:`Plan`,stalled:`Stalled`,plan_ready:`Plan ready`,plan_pending:`Plan pending`,progress_title:`Target progress`,progress_badge:`PROGRESS`,plan_title:`Target plan`,reasoning_title:`Target cycle reasoning`,cycle_result:{continue:`CONTINUE`,stop:`STOP`,error:`ERROR`},step_status:{pending:`PENDING`,in_progress:`IN PROGRESS`,done:`DONE`}},meta:{title:`Execution policy`,no_cap:`No cap`},field:{objective:`Objective`,current_objective:`Current objective`,objective_placeholder:`Describe what Supervisor should watch, for example:
97
97
  - Finish implementing user authentication
98
98
  - Fix all failing unit tests
99
- - 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`,edit_objective:`Edit Supervisor`,disable:`Disable`,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 or switch evaluators without clearing evaluation history.`,confirm:`Save`},disable:{title:`Disable Supervisor`,subtitle:`Stop automatic evaluation. The current session's supervision cycles will be removed.`,confirm:`Disable`,warning_title:`Disabling stops evaluation cycles`,warning_body:`Supervisor will be removed from the current session and its cycle history will be cleared. You can enable it again later, but previous records cannot be restored.`}}},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.`}}},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`}},xp={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:`信息`,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:`收起`},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:`未打开工作区`,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:`获取工作区列表失败`,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`}},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:`新输出仍会继续显示;如果需要完整历史,再手动刷新页面。`,closed_title:`该会话已被关闭`,closed_body:`请重新开启新会话。`,truncated_title:`历史内容不完整`,truncated_body:`较早的终端输出已被回放缓冲区淘汰,后续输出仍会继续显示。`}},file:{title:`文件`,modified:`已修改`,unsaved:`未保存`,dirty:`有未保存更改`,visible_count:`{count} 个文件`,empty_directory:`空文件夹`,new_file:`新建文件`,new_folder:`新建文件夹`,collapse_all:`折叠全部`,rename:`重命名`,delete:`删除`,delete_confirm:`确定要删除 "{name}" 吗?`,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:`以图像预览`,mode_text:`文本`,mode_image:`图像`,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`,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:`选择终端渲染模式`,copy_on_select:`选中自动复制`,copy_on_select_hint:`选中文本后自动复制到系统剪贴板`,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
100
- --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:`快捷键`,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 未启用`,latest_evaluation:`最近一次评估`,state:{inactive:`未启用`,idle:`空闲`,evaluating:`评估中`,injecting:`注入中`,paused:`已暂停`,error:`错误`,stopped:`已停止`},trigger:{manual:`手动`,auto:`自动`,scheduled:`定时`},cycle:{no_guidance:`本轮无需注入 guidance`,evaluating:`评估中…`,waiting:`等待评估结果`,cancelled:`已取消`},stop_reason:{objective_complete:`目标已达成,Supervisor 已自动停止。`,max_supervision_count_reached:`已达到配置的最大监督次数。`,supervisor_uncertain:`Supervisor 暂时无法判断下一步,已停止自动监督。`,needs_user_input:`Supervisor 需要更多用户输入后才能继续自动监督。`},target_memory:{title:`目标记忆`,target:`目标`,plan:`计划`,stalled:`停滞`,plan_ready:`计划已就绪`,plan_pending:`计划待生成`,progress_title:`目标进展`,progress_badge:`进展`,plan_title:`目标计划`,reasoning_title:`目标轮次判断`,cycle_result:{continue:`继续`,stop:`停止`,error:`错误`},step_status:{pending:`待处理`,in_progress:`进行中`,done:`已完成`}},meta:{title:`执行策略`,no_cap:`不设上限`},field:{objective:`目标描述`,current_objective:`当前目标`,objective_placeholder:`描述希望 Supervisor 盯住的目标,例如:
99
+ - 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`,edit_objective:`Edit Supervisor`,disable:`Disable`,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 or switch evaluators without clearing evaluation history.`,confirm:`Save`},disable:{title:`Disable Supervisor`,subtitle:`Stop automatic evaluation. The current session's supervision cycles will be removed.`,confirm:`Disable`,warning_title:`Disabling stops evaluation cycles`,warning_body:`Supervisor will be removed from the current session and its cycle history will be cleared. You can enable it again later, but previous records cannot be restored.`}}},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.`}}},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`}},xp={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:`信息`,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:`收起`},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:`未打开工作区`,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:`获取工作区列表失败`,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`}},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:`新输出仍会继续显示;如果需要完整历史,再手动刷新页面。`,closed_title:`该会话已被关闭`,closed_body:`请重新开启新会话。`,truncated_title:`历史内容不完整`,truncated_body:`较早的终端输出已被回放缓冲区淘汰,后续输出仍会继续显示。`}},file:{title:`文件`,modified:`已修改`,unsaved:`未保存`,dirty:`有未保存更改`,visible_count:`{count} 个文件`,empty_directory:`空文件夹`,new_file:`新建文件`,new_folder:`新建文件夹`,collapse_all:`折叠全部`,rename:`重命名`,delete:`删除`,delete_confirm:`确定要删除 "{name}" 吗?`,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:`以图像预览`,mode_text:`文本`,mode_image:`图像`,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:`界面与交互`},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:`选择终端渲染模式`,copy_on_select:`选中自动复制`,copy_on_select_hint:`选中文本后自动复制到系统剪贴板`,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
100
+ --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 未启用`,latest_evaluation:`最近一次评估`,state:{inactive:`未启用`,idle:`空闲`,evaluating:`评估中`,injecting:`注入中`,paused:`已暂停`,error:`错误`,stopped:`已停止`},trigger:{manual:`手动`,auto:`自动`,scheduled:`定时`},cycle:{no_guidance:`本轮无需注入 guidance`,evaluating:`评估中…`,waiting:`等待评估结果`,cancelled:`已取消`},stop_reason:{objective_complete:`目标已达成,Supervisor 已自动停止。`,max_supervision_count_reached:`已达到配置的最大监督次数。`,supervisor_uncertain:`Supervisor 暂时无法判断下一步,已停止自动监督。`},target_memory:{title:`目标记忆`,target:`目标`,plan:`计划`,stalled:`停滞`,plan_ready:`计划已就绪`,plan_pending:`计划待生成`,progress_title:`目标进展`,progress_badge:`进展`,plan_title:`目标计划`,reasoning_title:`目标轮次判断`,cycle_result:{continue:`继续`,stop:`停止`,error:`错误`},step_status:{pending:`待处理`,in_progress:`进行中`,done:`已完成`}},meta:{title:`执行策略`,no_cap:`不设上限`},field:{objective:`目标描述`,current_objective:`当前目标`,objective_placeholder:`描述希望 Supervisor 盯住的目标,例如:
101
101
  - 完成用户认证功能的实现
102
102
  - 修复所有失败的单元测试
103
- - 把 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:`启用目标`,edit_objective:`编辑 Supervisor`,disable:`禁用`,pause:`暂停`,resume:`恢复`,trigger:`触发评估`,pause_failed:`暂停失败`,resume_failed:`恢复失败`,trigger_failed:`触发评估失败`},dialog:{enable:{title:`启用 Supervisor`,subtitle:`描述一个目标,Supervisor 会在每轮结束后自动评估并提示下一步`,confirm:`启用`},edit:{title:`编辑 Supervisor`,subtitle:`调整目标描述或切换评估方,历史评估不会被清除`,confirm:`保存`},disable:{title:`禁用 Supervisor`,subtitle:`停止自动评估。当前会话的监督周期将被移除`,confirm:`禁用`,warning_title:`禁用后会停止评估周期`,warning_body:`当前会话的 Supervisor 将被移除,历史 cycles 会一并清理。可重新启用,但无法恢复记录。`}}},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 会话旁边直接运行命令和脚本。`}}},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:`接管失败 — 控制器仍然活跃`}},Sp={zh:{name:`中文`,data:xp},en:{name:`English`,data:bp}};function Cp(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 wp(e){let t=Sp[e]?.data??xp;function n(e,n){let r=Cp(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 Tp=B(e=>wp(e(xa)));function Ep(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 Dp(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 X(){return H(Tp)}function Op({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=X(),f=i??n,p=u??d(`action.back`);return(0,Y.jsxs)(`div`,{className:`mobile-sheet-layer`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mobile-sheet-layer__backdrop`,"aria-label":d(`mobile.sheet.dismiss`),onClick:n}),(0,Y.jsxs)(`section`,{className:J(`mobile-sheet`,l?`mobile-sheet--fullscreen`:null,c),"aria-label":d(`mobile.sheet.region`,{title:e}),role:`region`,children:[l?null:(0,Y.jsx)(`div`,{className:`mobile-sheet__handle`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`mobile-sheet__header`,children:(0,Y.jsx)(yp,{title:e,kicker:r,onBack:f,backLabel:p,rightSlot:o,titleAs:`h2`})}),(0,Y.jsx)(`div`,{className:J(`mobile-sheet__body`,s),children:t}),a?(0,Y.jsx)(`div`,{className:`mobile-sheet__footer`,children:a}):null]})]})}var kp={badge:`_badge_glfln_1`};function Ap({className:e,count:t,max:n=99,...r}){if(t<=0)return null;let i=t>n?`${n}+`:String(t);return(0,Y.jsx)(`span`,{...r,className:J(kp.badge,`topbar-unread`,e),children:i})}var jp={btn:`_btn_59wz6_1`,primary:`_primary_59wz6_36`,secondary:`_secondary_59wz6_47`,ghost:`_ghost_59wz6_62`,danger:`_danger_59wz6_75`,sm:`_sm_59wz6_81`,lg:`_lg_59wz6_89`,label:`_label_59wz6_97`,icon:`_icon_59wz6_102`,loading:`_loading_59wz6_107`,spinner:`_spinner_59wz6_111`},Mp={primary:jp.primary??``,secondary:jp.secondary??``,ghost:jp.ghost??``,danger:jp.danger??``},Np={sm:jp.sm,md:void 0,lg:jp.lg},Pp={primary:`btn-primary`,secondary:`btn-secondary`,ghost:`btn-ghost`,danger:`btn-danger`},Fp={sm:`btn-sm`,md:void 0,lg:`btn-lg`},Ip=({children:e,leadingIcon:t,loading:n,trailingIcon:r})=>(0,Y.jsxs)(Y.Fragment,{children:[n?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:J(jp.spinner,`animate-spin`)}):null,t?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:jp.icon,children:t}):null,(0,Y.jsx)(`span`,{className:jp.label,children:e}),r?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:jp.icon,children:r}):null]}),Lp=e=>{let{as:t=`button`,children:n,className:r,variant:i=`secondary`,size:a=`md`,loading:o=!1,leadingIcon:s,trailingIcon:c}=e,l=J(jp.btn,Mp[i],Np[a],`btn`,Pp[i],Fp[a],o?jp.loading:void 0,r),u=(0,Y.jsx)(Ip,{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,Y.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,Y.jsx)(`button`,{...x,"aria-busy":o?`true`:void 0,className:l,disabled:m||o,type:y??`button`,children:u})},Rp={root:`_root_1ojt1_1`,ghost:`_ghost_1ojt1_30`,filled:`_filled_1ojt1_40`,sm:`_sm_1ojt1_51`,lg:`_lg_1ojt1_57`,icon:`_icon_1ojt1_63`},zp={ghost:Rp.ghost,filled:Rp.filled},Bp={sm:Rp.sm,md:void 0,lg:Rp.lg},Vp={ghost:`btn-ghost`,filled:`btn-secondary`},Hp={sm:`btn-sm`,md:void 0,lg:`btn-lg`},Z=({"aria-label":e,className:t,icon:n,size:r=`md`,type:i,variant:a=`ghost`,...o})=>(0,Y.jsx)(`button`,{...o,"aria-label":e,className:J(Rp.root,zp[a],Bp[r],`btn`,Vp[a],Hp[r],t),type:i??`button`,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:Rp.icon,children:n})}),Up={overlay:`_overlay_1duw8_1`,card:`_card_1duw8_13`,sm:`_sm_1duw8_28`,md:`_md_1duw8_32`,lg:`_lg_1duw8_36`,full:`_full_1duw8_41`,header:`_header_1duw8_46`,title:`_title_1duw8_56`,body:`_body_1duw8_67`,footer:`_footer_1duw8_76`},Wp=(0,V.createContext)(null),Gp={sm:Up.sm,md:Up.md,lg:Up.lg,full:Up.full},Kp={sm:void 0,md:void 0,lg:`modal-card-lg`,full:void 0};function qp({children:e,className:t,dismissible:n=!0,initialFocus:r,onOpenChange:i,open:a,size:o=`md`}){let s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useId)(),u=(0,V.useMemo)(()=>({titleId:l}),[l]);return(0,V.useLayoutEffect)(()=>{if(!a)return;c.current=document.activeElement;let e=s.current;if(e)return fp(e,r).focus(),()=>{mp(c.current),c.current=null}},[r,a]),a?(0,Y.jsx)(gp,{children:(0,Y.jsx)(`div`,{className:J(Up.overlay,`modal-overlay`),onClick:e=>{n&&sp(e)&&i(!1)},children:(0,Y.jsx)(Wp.Provider,{value:u,children:(0,Y.jsx)(`div`,{"aria-labelledby":l,"aria-modal":`true`,className:J(Up.card,Gp[o],`modal-card`,Kp[o],t),onKeyDown:e=>{if(cp(e)){n&&(e.preventDefault(),e.stopPropagation(),i(!1));return}pp(e.currentTarget,e)},ref:s,role:`dialog`,tabIndex:-1,children:e})})})}):null}function Jp({className:e,...t}){return(0,Y.jsx)(`div`,{...t,className:J(Up.header,`modal-header`,e)})}function Yp({className:e,...t}){let n=(0,V.useContext)(Wp),r=(0,V.useId)(),i=n?.titleId??r;return(0,Y.jsx)(`h2`,{...t,className:J(Up.title,`modal-title`,e),id:i})}function Xp({className:e,...t}){return(0,Y.jsx)(`div`,{...t,className:J(Up.body,`modal-body`,e)})}function Zp({className:e,...t}){return(0,Y.jsx)(`div`,{...t,className:J(Up.footer,`modal-footer`,e)})}var Qp={root:`_root_1fg74_1`};function Q({className:e,decorative:t=!0,role:n,semantic:r,size:i=14,...a}){let o=aa(H(ba),r),s=o.Icon;return(0,Y.jsx)(`span`,{...a,"aria-hidden":t?!0:void 0,className:J(Qp.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,Y.jsx)(s,{size:i,strokeWidth:o.strokeWidth})})}var $p={body:`_body_p96py_1`,titleDanger:`_titleDanger_p96py_9`,iconDanger:`_iconDanger_p96py_13`},em={default:`primary`,danger:`danger`};function tm({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,Y.jsxs)(qp,{className:n,dismissible:l,initialFocus:u,onOpenChange:f,open:p,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(Yp,{className:J(h===`danger`?$p.titleDanger:void 0),children:[h===`danger`?(0,Y.jsx)(Q,{"aria-hidden":`true`,className:$p.iconDanger,semantic:`state.warning`,size:16}):null,(0,Y.jsx)(`span`,{children:m})]}),l||r?(0,Y.jsx)(Z,{"aria-label":i,className:`modal-close`,disabled:r,icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>f(!1),size:`sm`}):null]}),c?(0,Y.jsx)(Xp,{className:$p.body,children:c}):null,(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{disabled:e,onClick:()=>f(!1),children:t}),(0,Y.jsx)(Lp,{...v,className:g,disabled:o||_,onClick:d,variant:em[h],children:s})]})]})}var nm={triggerWrapper:`_triggerWrapper_77m7f_1`,content:`_content_77m7f_6`},rm=8,im=8;function am(e){return(0,V.isValidElement)(e)}function om({children:e,content:t,title:n,open:r,onOpenChange:i,forceMode:a=`auto`,placement:o=`bottom-start`,contentClassName:s,sheetBodyClassName:c}){let l=Pr(),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useId)(),m=a===`desktop`?`desktop`:a===`mobile`?`mobile`:l,h=r&&m===`desktop`,g=r&&m===`mobile`,[_,v]=(0,V.useState)({left:rm,top:rm,visibility:`hidden`}),y=V.Children.only(e);if((0,V.useLayoutEffect)(()=>{if(r)return f.current=document.activeElement,()=>{mp(f.current),f.current=null}},[r]),(0,V.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(rm,window.innerWidth-t.width-rm),i=Math.min(r,Math.max(rm,n)),a=e.bottom+im;v({left:i,top:a+t.height<=window.innerHeight-rm?a:Math.max(rm,e.top-t.height-im),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,V.useLayoutEffect)(()=>{!h||!d.current||d.current.focus()},[h]),(0,V.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=>{cp(e)&&(e.preventDefault(),i(!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[h,i]),!am(y))throw Error(`Popover requires a single trigger React element.`);let b=(0,V.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}cp(e)&&r&&(e.preventDefault(),i(!1))}}});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:nm.triggerWrapper,ref:u,children:b}),h?(0,Y.jsx)(gp,{children:(0,Y.jsx)(`div`,{"aria-label":n,"aria-modal":`false`,className:J(nm.content,s),id:p,onKeyDown:e=>{cp(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,Y.jsx)(Op,{body:(0,Y.jsx)(`div`,{children:t}),bodyClassName:c,onClose:()=>i(!1),title:n}):null]})}var sm={trigger:`_trigger_7ajv2_1`,value:`_value_7ajv2_11`,icon:`_icon_7ajv2_19`,content:`_content_7ajv2_24`,header:`_header_7ajv2_31`,title:`_title_7ajv2_37`,body:`_body_7ajv2_43`,calendar:`_calendar_7ajv2_49`,time:`_time_7ajv2_60`,actions:`_actions_7ajv2_70`,action:`_action_7ajv2_70`,popoverContent:`_popoverContent_7ajv2_106`,sheetBody:`_sheetBody_7ajv2_110`,calendarGrid:`_calendarGrid_7ajv2_118`,calendarHeader:`_calendarHeader_7ajv2_124`,calendarTitle:`_calendarTitle_7ajv2_131`,calendarNav:`_calendarNav_7ajv2_137`,calendarWeekdays:`_calendarWeekdays_7ajv2_158`,calendarWeekday:`_calendarWeekday_7ajv2_158`,calendarDays:`_calendarDays_7ajv2_173`,calendarDay:`_calendarDay_7ajv2_173`,calendarDayToday:`_calendarDayToday_7ajv2_199`,calendarDaySelected:`_calendarDaySelected_7ajv2_204`,calendarDayDisabled:`_calendarDayDisabled_7ajv2_213`,calendarDayEmpty:`_calendarDayEmpty_7ajv2_219`,timeSelector:`_timeSelector_7ajv2_224`,timeField:`_timeField_7ajv2_230`,timeLabel:`_timeLabel_7ajv2_237`,timeSeparator:`_timeSeparator_7ajv2_242`,timeSection:`_timeSection_7ajv2_249`,timeInput:`_timeInput_7ajv2_259`},cm=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`],lm=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`];function um(e,t){return new Date(e,t+1,0).getDate()}function dm(e,t){return new Date(e,t,1).getDay()}function fm(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function pm(e,t,n){return!!(t&&e<t||n&&e>n)}function mm({year:e,month:t,selectedDate:n,minDate:r,maxDate:i,onDateSelect:a,onMonthChange:o}){let s=X(),c=um(e,t),l=dm(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);pm(o,r,i)||a(o)},p=[];for(let e=0;e<l;e++)p.push((0,Y.jsx)(`div`,{className:sm.calendarDayEmpty},`empty-${e}`));for(let a=1;a<=c;a++){let o=new Date(e,t,a),s=n&&fm(o,n),c=pm(o,r,i),l=fm(o,new Date);p.push((0,Y.jsx)(`button`,{type:`button`,disabled:c,className:J(sm.calendarDay,s&&sm.calendarDaySelected,l&&!s&&sm.calendarDayToday,c&&sm.calendarDayDisabled),onClick:()=>f(a),children:a},a))}return(0,Y.jsxs)(`div`,{className:sm.calendarGrid,children:[(0,Y.jsxs)(`div`,{className:sm.calendarHeader,children:[(0,Y.jsx)(`button`,{type:`button`,className:sm.calendarNav,onClick:u,"aria-label":s(`datetime.prev_month`),children:(0,Y.jsx)(ci,{size:16})}),(0,Y.jsxs)(`span`,{className:sm.calendarTitle,children:[s(`datetime.${lm[t]}`),` `,e]}),(0,Y.jsx)(`button`,{type:`button`,className:sm.calendarNav,onClick:d,"aria-label":s(`datetime.next_month`),children:(0,Y.jsx)(li,{size:16})})]}),(0,Y.jsx)(`div`,{className:sm.calendarWeekdays,children:cm.map(e=>(0,Y.jsx)(`div`,{className:sm.calendarWeekday,children:s(`datetime.${e}`)},e))}),(0,Y.jsx)(`div`,{className:sm.calendarDays,children:p})]})}var hm={input:`_input_y1v5b_1`,sm:`_sm_y1v5b_27`,lg:`_lg_y1v5b_33`,invalid:`_invalid_y1v5b_39`},gm={sm:hm.sm,md:void 0,lg:hm.lg},_m={sm:`input-sm`,md:void 0,lg:`input-lg`},vm=(0,V.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,Y.jsx)(`input`,{...i,ref:a,size:t,"aria-invalid":o,className:J(hm.input,gm[r],`input`,_m[r],n?hm.invalid:void 0,e)})});function ym({hour:e,minute:t,onHourChange:n,onMinuteChange:r,disabled:i=!1}){let a=X(),o=(0,V.useId)(),s=(0,V.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,Y.jsxs)(`div`,{className:sm.timeSelector,children:[(0,Y.jsxs)(`div`,{className:sm.timeField,children:[(0,Y.jsx)(`label`,{htmlFor:o,className:sm.timeLabel,children:a(`datetime.hour`)}),(0,Y.jsx)(vm,{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:sm.timeInput})]}),(0,Y.jsx)(`span`,{className:sm.timeSeparator,children:`:`}),(0,Y.jsxs)(`div`,{className:sm.timeField,children:[(0,Y.jsx)(`label`,{htmlFor:s,className:sm.timeLabel,children:a(`datetime.minute`)}),(0,Y.jsx)(vm,{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:sm.timeInput})]})]})}function bm(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 xm(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 Sm(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Cm(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes())}function wm(e,t){return new Date(e,t+1,0).getDate()}function Tm(e,t,n){return Math.min(n,wm(e,t))}function Em(e){return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes()}}function Dm(e){return new Date(e.year,e.month,e.day,e.hour,e.minute)}function Om(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 km(e,t,n){let r=e.getTime();return t!==void 0&&r<t||n!==void 0&&r>n}var Am={sm:`input-sm`,md:void 0,lg:`input-lg`};function jm({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=X(),p=H(xa),m=Pr(),h=(0,V.useId)(),[g,_]=(0,V.useState)(!1),v=o?Cm(o).getTime():void 0,y=s?Cm(s).getTime():void 0,b=e=>Em(bm(e)||Om(Cm(new Date),v,y)),[x,S]=(0,V.useState)(()=>b(e));(0,V.useEffect)(()=>{S(b(e))},[e]);let C=(0,V.useCallback)(e=>{S(t=>({...t,year:e.getFullYear(),month:e.getMonth(),day:e.getDate()}))},[]),w=(0,V.useCallback)((e,t)=>{S(n=>({...n,year:e,month:t,day:Tm(e,t,n.day)}))},[]),T=(0,V.useCallback)(e=>{S(t=>({...t,hour:e}))},[]),E=(0,V.useCallback)(e=>{S(t=>({...t,minute:e}))},[]),D=km(Dm(x),v,y),O=(0,V.useCallback)(()=>{let e=Dm(x);km(e,v,y)||(t(xm(e)),_(!1))},[x,y,v,t]),k=(0,V.useCallback)(()=>{t(``),_(!1)},[t]),A=bm(e),j=A?Dp(A.getTime(),p):r??f(`datetime.select_date`),M=m===`mobile`,N=J(`input`,Am[l],sm.trigger,u?`input-invalid`:void 0,c),P=(0,Y.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,Y.jsx)(`span`,{className:sm.value,children:j}),(0,Y.jsx)(ai,{size:16,className:sm.icon,"aria-hidden":`true`})]}),F=new Date(x.year,x.month,x.day),ee=o?Sm(o):void 0,I=s?Sm(s):void 0,te=(0,Y.jsxs)(`div`,{className:sm.content,children:[(0,Y.jsxs)(`div`,{className:sm.body,children:[(0,Y.jsx)(mm,{year:x.year,month:x.month,selectedDate:F,minDate:ee,maxDate:I,onDateSelect:C,onMonthChange:w}),(0,Y.jsxs)(`div`,{className:sm.timeSection,children:[(0,Y.jsx)(`span`,{className:sm.timeLabel,children:f(`datetime.select_time`)}),(0,Y.jsx)(ym,{hour:x.hour,minute:x.minute,onHourChange:T,onMinuteChange:E})]})]}),(0,Y.jsxs)(`div`,{className:sm.actions,children:[a?(0,Y.jsx)(`button`,{type:`button`,className:sm.action,onClick:k,children:f(`datetime.clear`)}):null,(0,Y.jsx)(`button`,{type:`button`,className:sm.action,onClick:O,disabled:D,children:f(`datetime.confirm`)})]})]});return M?(0,Y.jsxs)(Y.Fragment,{children:[P,g?(0,Y.jsx)(Op,{title:n,body:te,bodyClassName:sm.sheetBody,onClose:()=>_(!1),fullscreen:!0}):null]}):(0,Y.jsx)(om,{open:g,onOpenChange:_,title:n,content:te,contentClassName:sm.popoverContent,sheetBodyClassName:sm.sheetBody,children:P})}var Mm={root:`_root_ua36l_1`,icon:`_icon_ua36l_13`,title:`_title_ua36l_20`,description:`_description_ua36l_26`,action:`_action_ua36l_33`};function Nm(e,t){if(e==null||typeof e==`boolean`)return null;if((0,V.isValidElement)(e)){let n=e;return(0,V.cloneElement)(n,{className:J(n.props.className,t)})}return(0,Y.jsx)(`div`,{className:t,children:e})}function Pm({action:e,className:t,description:n,icon:r,title:i,...a}){return(0,Y.jsxs)(`div`,{...a,className:J(Mm.root,t),children:[Nm(r,Mm.icon),Nm(i,Mm.title),Nm(n,Mm.description),e?(0,Y.jsx)(`div`,{className:Mm.action,children:e}):null]})}var Fm={kbd:`_kbd_1df0g_1`,interactive:`_interactive_1df0g_17`,sm:`_sm_1df0g_30`},Im={sm:Fm.sm,md:void 0},Lm=({children:e,className:t,interactive:n=!1,onKeyDown:r,size:i=`md`,tabIndex:a,...o})=>(0,Y.jsx)(`kbd`,{...o,className:J(Fm.kbd,Im[i],n?Fm.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}),Rm={notice:`_notice_18n4r_1`,info:`_info_18n4r_13`,success:`_success_18n4r_18`,warning:`_warning_18n4r_23`,error:`_error_18n4r_28`,copy:`_copy_18n4r_33`,title:`_title_18n4r_41`,message:`_message_18n4r_49`,action:`_action_18n4r_56`},zm={info:Rm.info,success:Rm.success,warning:Rm.warning,error:Rm.error},Bm={info:void 0,success:void 0,warning:void 0,error:`settings-page__notice--error`};function Vm({action:e,className:t,message:n,title:r,tone:i=`info`,...a}){return(0,Y.jsxs)(`div`,{...a,className:J(Rm.notice,zm[i],`settings-page__notice`,Bm[i],t),children:[r||n?(0,Y.jsxs)(`div`,{className:J(Rm.copy,`settings-page__notice-copy`),children:[r?(0,Y.jsx)(`span`,{className:J(Rm.title,`settings-page__notice-title`),children:r}):null,n?(0,Y.jsx)(`span`,{className:J(Rm.message,`settings-page__notice-message`),children:n}):null]}):null,e?(0,Y.jsx)(`div`,{className:Rm.action,children:e}):null]})}var Hm={pill:`_pill_1oryu_1`,active:`_active_1oryu_34`,icon:`_icon_1oryu_40`};function Um({active:e=!1,children:t,className:n,disabled:r=!1,leadingIcon:i,selected:a=!1,...o}){let s=e||a;return(0,Y.jsxs)(`button`,{...o,"aria-pressed":s,className:J(Hm.pill,s?Hm.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:Hm.icon,children:i}):null,(0,Y.jsx)(`span`,{children:t})]})}var Wm={root:`_root_1348s_1`,fill:`_fill_1348s_7`,success:`_success_1348s_14`,warning:`_warning_1348s_18`,error:`_error_1348s_22`,info:`_info_1348s_26`,neutral:`_neutral_1348s_30`,indeterminate:`_indeterminate_1348s_34`,progressBarIndeterminate:`_progressBarIndeterminate_1348s_1`},Gm={success:Wm.success,warning:Wm.warning,error:Wm.error,info:Wm.info,neutral:Wm.neutral};function Km(e,t,n){return Math.min(Math.max(e,t),n)}function qm({className:e,fillClassName:t,indeterminate:n=!1,max:r,style:i,tone:a,value:o,...s}){let c=s[`aria-hidden`]===!0||s[`aria-hidden`]===`true`,l=r>0?r:0,u=Km(o,0,l),d=l>0?Km(u/l*100,0,100):0;return(0,Y.jsx)(`div`,{...s,"aria-valuemax":c?void 0:l,"aria-valuemin":c?void 0:0,"aria-valuenow":c||n?void 0:u,className:J(Wm.root,n?Wm.indeterminate:void 0,e),role:c?void 0:`progressbar`,style:i,children:(0,Y.jsx)(`div`,{className:J(Wm.fill,Gm[a],t),style:n?void 0:{"--progress-bar-width":`${d}%`}})})}var Jm={tabs:`_tabs_29j1i_1`,tabList:`_tabList_29j1i_5`,tab:`_tab_29j1i_1`,tabActive:`_tabActive_29j1i_71`,panel:`_panel_29j1i_6`},Ym=(0,V.createContext)(null);function Xm(e){let t=(0,V.useContext)(Ym);if(!t)throw Error(`${e} must be used within Tabs`);return t}function Zm({children:e,className:t,orientation:n=`horizontal`,value:r,onValueChange:i,"aria-label":a,...o}){let s=(0,V.useId)(),c=(0,V.useRef)(new Map),[l,u]=(0,V.useState)({}),d=(0,V.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,V.useCallback)(e=>{u(t=>t[e]?t:{...t,[e]:!0})},[]),p=(0,V.useCallback)(e=>{u(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),m=(0,V.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,Y.jsx)(Ym.Provider,{value:m,children:(0,Y.jsx)(`div`,{...o,className:J(Jm.tabs,t),"data-orientation":n,children:e})})}function Qm({children:e,className:t,orientation:n,...r}){let i=Xm(`TabList`),a=n??i.orientation;return(0,Y.jsx)(`div`,{...r,"aria-label":r[`aria-label`]??i.listLabel,"aria-orientation":a===`vertical`?`vertical`:void 0,className:J(Jm.tabList,t),"data-orientation":a,role:`tablist`,children:e})}function $m({children:e,className:t,value:n,onClick:r,onKeyDown:i,...a}){let o=Xm(`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,Y.jsx)(`button`,{...a,"aria-controls":o.hasPanel(n)?c.panelId:void 0,"aria-selected":s,className:J(Jm.tab,s?Jm.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 eh({children:e,className:t,value:n,...r}){let i=Xm(`TabPanel`),a=i.value===n,o=i.ensureTabIds(n),{registerPanel:s,unregisterPanel:c}=i;return(0,V.useLayoutEffect)(()=>(s(n),()=>{c(n)}),[s,c,n]),(0,Y.jsx)(`div`,{...r,"aria-labelledby":o.tabId,className:J(Jm.panel,t),hidden:!a,id:o.panelId,role:`tabpanel`,children:e})}var th={segmentedControl:`_segmentedControl_1u28a_1`,segmentedControlOption:`_segmentedControlOption_1u28a_18`};function nh({options:e,value:t,onChange:n,size:r=`md`,className:i,optionClassName:a,...o}){return(0,Y.jsx)(Zm,{onValueChange:n,value:e.some(e=>e.value===t)?t:e.find(e=>!e.disabled)?.value??t,children:(0,Y.jsx)(Qm,{...o,className:J(th.segmentedControl,i),"data-size":r,children:e.map(e=>(0,Y.jsx)($m,{className:J(th.segmentedControlOption,a),"data-size":r,disabled:e.disabled,value:e.value,children:e.label},e.value))})})}var rh={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},ih={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},ah={color:`var(--text-secondary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`},oh={color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`};function sh({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=X(),[y,b]=(0,V.useState)(``),x=(0,V.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,V.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))},te=(0,Y.jsxs)(Y.Fragment,{children:[a?(0,Y.jsxs)(`div`,{className:`mobile-select-sheet__search`,children:[(0,Y.jsx)(`label`,{className:`mobile-select-sheet__search-label`,htmlFor:x,children:v(`action.search`)}),(0,Y.jsx)(`input`,{id:x,type:`text`,className:`mobile-select-sheet__search-input`,placeholder:D,value:S,onChange:e=>O(e.target.value)})]}):null,(0,Y.jsx)(`div`,{className:`mobile-select-sheet__content`,children:d?(0,Y.jsx)(Pm,{className:`mobile-select-sheet__loading`,role:`status`,style:ih,title:(0,Y.jsx)(`div`,{style:ah,children:T})}):(0,Y.jsxs)(Y.Fragment,{children:[k.map(e=>e.items.length===0&&e.kind===`options`?null:(0,Y.jsxs)(`div`,{className:`mobile-select-sheet__section`,children:[e.title?(0,Y.jsx)(`div`,{className:`mobile-select-sheet__section-title`,children:e.title}):null,(0,Y.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,Y.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,Y.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,Y.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,Y.jsx)(`span`,{id:i,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,Y.jsx)(`span`,{id:`${e.id}-${t.id}-description`,className:`mobile-select-sheet__item-description`,children:t.description}):null,t.meta?(0,Y.jsx)(`span`,{id:`${e.id}-${t.id}-meta`,className:`mobile-select-sheet__item-meta`,children:t.meta}):null]}),t.badge?(0,Y.jsx)(kh,{color:`neutral`,caps:!1,className:`mobile-select-sheet__item-badge`,children:t.badge}):null]});return t.trailingAction?(0,Y.jsxs)(`div`,{className:`mobile-select-sheet__item-row`,"data-selected":n?`true`:`false`,children:[o,(0,Y.jsx)(Z,{"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,Y.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,Y.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,Y.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,Y.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,Y.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,Y.jsx)(`span`,{id:n,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,Y.jsx)(`span`,{id:r,className:`mobile-select-sheet__item-description`,children:t.description}):null]})]},t.id)})})]},e.id)),j?(0,Y.jsx)(`div`,{className:`mobile-select-sheet__section`,children:(0,Y.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,Y.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,Y.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,Y.jsx)(`span`,{id:e,className:`mobile-select-sheet__item-label`,children:l?.label(C)}),n?(0,Y.jsx)(`span`,{id:t,className:`mobile-select-sheet__item-description`,children:n}):null]})})})()})}):null,!A&&!j?(0,Y.jsx)(Pm,{className:`mobile-select-sheet__empty`,style:rh,title:(0,Y.jsx)(`div`,{style:oh,children:E})}):null]})})]});return i===`inline`?(0,Y.jsxs)(`div`,{className:`mobile-inline-sheet`,role:`dialog`,"aria-label":e,children:[(0,Y.jsx)(`div`,{className:`mobile-inline-sheet__handle`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`mobile-inline-sheet__header`,children:(0,Y.jsx)(yp,{title:e,titleAs:`h3`,onBack:h,backLabel:v(`action.back`)})}),(0,Y.jsx)(`div`,{className:`mobile-inline-sheet__body`,children:(0,Y.jsx)(`div`,{className:J(`mobile-select-sheet`,`mobile-select-sheet--inline`,n),children:te})})]}):(0,Y.jsx)(Op,{title:e,body:(0,Y.jsx)(`div`,{className:J(`mobile-select-sheet`,n),children:te}),onClose:_,kicker:m,onBack:h,bodyClassName:`mobile-sheet__body--flush`,fullscreen:!0})}var ch={root:`_root_skc9v_1`,native:`_native_skc9v_6`,mobileTrigger:`_mobileTrigger_skc9v_11`,mobileValue:`_mobileValue_skc9v_20`,mobileIcon:`_mobileIcon_skc9v_25`,listbox:`_listbox_skc9v_30`,option:`_option_skc9v_46`,optionSelected:`_optionSelected_skc9v_60`,optionDisabled:`_optionDisabled_skc9v_64`},lh={sm:hm.sm,md:void 0,lg:hm.lg},uh={sm:`input-sm`,md:void 0,lg:`input-lg`};function dh(e,t,n){return n||(t===void 0?``:e.find(e=>e.value===t)?.label??t)}function fh({className:e,invalid:t,size:n}){return J(hm.input,lh[n],`input`,uh[n],`mobile-select-trigger`,ch.mobileTrigger,t?hm.invalid:void 0,e)}function ph({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 mh(e){let t=Pr(),n=(0,V.useId)(),[r,i]=(0,V.useState)(!1),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.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,V.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,V.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,V.useEffect)(()=>{i(!1)},[d,f]),e.mobile){let{"aria-label":t,"aria-labelledby":r,className:i,disabled:a,id:o,invalid:s,onClick:c,onOpen:d,options:f,size:p,value:m,valueLabel:h,includeValueInAriaLabel:g=!0,..._}=e,v=dh(f,m,h),y=`${o??n}-value`,{resolvedAriaLabel:b,resolvedAriaLabelledBy:x}=ph({ariaLabel:t,ariaLabelledBy:r,includeValueInAriaLabel:g,selectedLabel:v,valueId:y});return(0,Y.jsxs)(`button`,{..._,id:o,type:`button`,disabled:a,"aria-invalid":u,"aria-label":b,"aria-haspopup":_[`aria-haspopup`]??`dialog`,"aria-labelledby":x||void 0,className:fh({className:i,invalid:s,size:l}),onClick:e=>{c?.(e),!e.defaultPrevented&&!a&&!e.currentTarget.disabled&&d()},children:[(0,Y.jsx)(`span`,{id:y,className:J(`mobile-select-trigger__value`,ch.mobileValue),children:v}),(0,Y.jsx)(si,{size:16,className:J(`mobile-select-trigger__icon`,ch.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=dh(w,E),k=`${_??n}-listbox`,A=`${_??n}-value`,{resolvedAriaLabel:j,resolvedAriaLabelledBy:M}=ph({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))}},te=y===`inline`?()=>i(!1):void 0;return(0,Y.jsxs)(`div`,{ref:a,className:ch.root,children:[(0,Y.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:fh({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,Y.jsx)(`span`,{id:A,className:J(`mobile-select-trigger__value`,ch.mobileValue),children:O}),(0,Y.jsx)(si,{size:16,className:J(`mobile-select-trigger__icon`,ch.mobileIcon),"aria-hidden":`true`})]}),p&&r?(0,Y.jsx)(`div`,{id:k,ref:s,role:`listbox`,"aria-label":t,"aria-labelledby":d,className:ch.listbox,onKeyDown:ee,children:w.map(e=>{let t=e.value===E;return(0,Y.jsx)(`div`,{role:`option`,id:`${k}-${e.value}`,"aria-disabled":e.disabled?`true`:void 0,"aria-selected":t,className:J(ch.option,t?ch.optionSelected:void 0,e.disabled?ch.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,Y.jsx)(sh,{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:te,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,Y.jsx)(`select`,{...x,size:h,"aria-invalid":u,className:J(hm.input,lh[l],`input`,uh[l],ch.native,g?hm.invalid:void 0,m),onChange:e=>{_?.(e),v?.(e.target.value)},children:y.map(e=>(0,Y.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))})}var hh={spinner:`_spinner_16qlq_1`},gh={sm:`12px`,md:`16px`,lg:`20px`};function _h({className:e,label:t,size:n=`md`,style:r,...i}){return(0,Y.jsx)(`span`,{...i,"aria-label":t,className:J(hh.spinner,`animate-spin`,e),role:`status`,style:{"--spinner-size":gh[n],...r}})}var vh={dot:`_dot_vc87z_1`,pulse:`_pulse_vc87z_12`,statusDotPulse:`_statusDotPulse_vc87z_1`},yh={success:`var(--color-success)`,warning:`var(--color-warning)`,error:`var(--color-error)`,info:`var(--color-info)`,neutral:`var(--text-tertiary)`},bh={sm:`6px`,md:`8px`,lg:`10px`};function xh({className:e,pulse:t=!1,size:n=`md`,style:r,tone:i=`neutral`,"aria-hidden":a=!0,...o}){return(0,Y.jsx)(`span`,{...o,"aria-hidden":a,className:J(vh.dot,t?vh.pulse:void 0,e),style:{"--status-dot-current-color":yh[i],"--status-dot-current-size":bh[n],...r}})}var Sh={switch:`_switch_14430_1`,track:`_track_14430_26`,checked:`_checked_14430_52`,thumb:`_thumb_14430_57`},Ch={sm:{trackWidth:`32px`,trackHeight:`18px`,thumbSize:`14px`,offset:`2px`},md:{trackWidth:`36px`,trackHeight:`20px`,thumbSize:`16px`,offset:`2px`}};function wh({checked:e,className:t,disabled:n=!1,onCheckedChange:r,onClick:i,size:a=`md`,style:o,...s}){let c=Ch[a];return(0,Y.jsx)(`button`,{...s,"aria-checked":e,className:J(Sh.switch,e?Sh.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:Sh.track,children:(0,Y.jsx)(`span`,{className:Sh.thumb})})})}var Th={tag:`_tag_27mfm_1`,sm:`_sm_27mfm_16`,noCaps:`_noCaps_27mfm_22`,blue:`_blue_27mfm_26`,green:`_green_27mfm_32`,amber:`_amber_27mfm_38`,pink:`_pink_27mfm_44`,purple:`_purple_27mfm_50`,neutral:`_neutral_27mfm_56`},Eh={blue:Th.blue,green:Th.green,amber:Th.amber,pink:Th.pink,purple:Th.purple,neutral:Th.neutral},Dh={blue:`badge-blue`,green:`badge-green`,amber:`badge-amber`,pink:`badge-pink`,purple:`badge-purple`,neutral:`badge-gray`},Oh={sm:Th.sm,md:void 0};function kh({caps:e=!0,className:t,color:n=`neutral`,size:r=`md`,...i}){return(0,Y.jsx)(`span`,{...i,className:J(Th.tag,Eh[n],Oh[r],e?void 0:Th.noCaps,`badge`,Dh[n],t)})}var Ah={input:`_input_1syx3_1`,textarea:`_textarea_1syx3_27`,lg:`_lg_1syx3_34`,invalid:`_invalid_1syx3_40`},jh={md:void 0,lg:Ah.lg},Mh={md:void 0,lg:`textarea-lg`};function Nh(e,t){if(typeof e==`function`){e(t);return}e&&(e.current=t)}function Ph(e){e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}var Fh=(0,V.forwardRef)(function({autoResize:e=!1,className:t,invalid:n,onChange:r,size:i=`md`,...a},o){let s=(0,V.useRef)(null),c=n===void 0?a[`aria-invalid`]:n?`true`:`false`;return(0,V.useEffect)(()=>{!e||!s.current||Ph(s.current)},[e,a.defaultValue,a.value]),(0,Y.jsx)(`textarea`,{...a,"aria-invalid":c,className:J(Ah.input,Ah.textarea,jh[i],`input`,`textarea`,Mh[i],n?Ah.invalid:void 0,t),onChange:t=>{e&&Ph(t.currentTarget),r?.(t)},ref:e=>{s.current=e,Nh(o,e)}})}),Ih={viewport:`_viewport_wwtxg_1`,mobile:`_mobile_wwtxg_14`,toast:`_toast_wwtxg_24`,slideIn:`_slideIn_wwtxg_1`,clickable:`_clickable_wwtxg_41`,success:`_success_wwtxg_50`,error:`_error_wwtxg_54`,warning:`_warning_wwtxg_58`,info:`_info_wwtxg_62`,icon:`_icon_wwtxg_66`,content:`_content_wwtxg_98`,title:`_title_wwtxg_106`,body:`_body_wwtxg_113`,action:`_action_wwtxg_121`,close:`_close_wwtxg_137`},Lh={success:Ih.success,error:Ih.error,warning:Ih.warning,info:Ih.info},Rh={success:`toast--success`,error:`toast--error`,warning:`toast--warning`,info:`toast--info`},zh={success:`state.success`,error:`state.error`,warning:`state.warning`,info:`state.info`};function Bh({children:e,className:t,mobile:n=!1,...r}){return(0,Y.jsx)(`div`,{...r,className:J(Ih.viewport,n?Ih.mobile:void 0,`toast-container`,n?`toast-container--mobile`:void 0,t),children:e})}function Vh({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,Y.jsx)(Q,{className:`toast__icon-symbol`,semantic:zh[l],size:16});return(0,Y.jsxs)(`div`,{...p,"aria-live":f,className:J(Ih.toast,Lh[l],d?Ih.clickable:void 0,`toast`,Rh[l],t),onClick:o,role:`alert`,children:[m?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:J(Ih.icon,`toast__icon`),children:m}):null,(0,Y.jsxs)(`div`,{className:J(Ih.content,`toast__content`),children:[(0,Y.jsx)(`span`,{className:J(Ih.title,`toast__title`),children:c}),r?(0,Y.jsx)(`span`,{className:J(Ih.body,`toast__body`),children:r}):null]}),e&&a?(0,Y.jsx)(`button`,{className:Ih.action,onClick:e=>{e.stopPropagation(),a()},type:`button`,children:e}):null,(0,Y.jsx)(Z,{"aria-label":n,className:J(Ih.close,`toast__close`),icon:(0,Y.jsx)(ea,{size:14}),onClick:e=>{e.stopPropagation(),s()},size:`sm`})]})}var Hh={disabledTriggerWrapper:`_disabledTriggerWrapper_15c9s_1`,tooltip:`_tooltip_15c9s_5`};function Uh(e){return(0,V.isValidElement)(e)}function $({children:e,content:t,disabled:n=!1}){let r=V.Children.only(e),i=Pr(),a=(0,V.useId)(),o=(0,V.useRef)(null),s=(0,V.useRef)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)({left:0,top:0});if(!Uh(r))return r;let m=!n&&i===`desktop`,h=m&&(c||u),g=r.props.disabled===!0,_=r.props[`aria-describedby`],v=(0,V.useMemo)(()=>h?[_,a].filter(Boolean).join(` `):_,[_,h,a]);(0,V.useLayoutEffect)(()=>{if(!h||!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);p({left:i,top:Math.max(8,a>=8?a:Math.min(l,c))})},[h]);let y=g?(0,V.cloneElement)(r,{"aria-describedby":v}):(0,V.cloneElement)(r,{"aria-describedby":v,onBlur:e=>{r.props.onBlur?.(e),d(!1)},onFocus:e=>{r.props.onFocus?.(e),!e.defaultPrevented&&m&&(o.current=e.currentTarget,d(!0))},onMouseEnter:e=>{r.props.onMouseEnter?.(e),!e.defaultPrevented&&m&&(o.current=e.currentTarget,l(!0))},onMouseLeave:e=>{r.props.onMouseLeave?.(e),l(!1)}});return(0,Y.jsxs)(Y.Fragment,{children:[g?(0,Y.jsx)(`span`,{className:Hh.disabledTriggerWrapper,onMouseEnter:e=>{!e.defaultPrevented&&m&&(o.current=e.currentTarget,l(!0))},onMouseLeave:()=>{l(!1)},children:y}):y,h?(0,Y.jsx)(gp,{children:(0,Y.jsx)(`div`,{className:J(Hh.tooltip),id:a,ref:s,role:`tooltip`,style:{left:`${f.left}px`,top:`${f.top}px`},children:t})}):null]})}var Wh={minHeight:`auto`,padding:0,gap:`var(--sp-5)`,alignItems:`stretch`,textAlign:`left`};function Gh({onAuthenticated:e}){let t=X(),[,n]=xe(Sa),r=H(xa),i=H(Uf),a=Pr()===`mobile`,[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(i===null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1);(0,V.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:Dp(e,r,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})});return(0,Y.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,a?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,Y.jsxs)(`div`,{className:[`welcome-card`,`auth-card-shell`,a?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:[(0,Y.jsx)(Pm,{style:Wh,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker`,children:`CODER STUDIO`}),(0,Y.jsx)(`h1`,{className:`welcome-title`,children:t(`app.name`)})]}),description:(0,Y.jsx)(`p`,{className:`welcome-body auth-card-desc`,children:v})}),(0,Y.jsxs)(`div`,{className:b,children:[(0,Y.jsx)(`div`,{className:`auth-status-eyebrow`,children:t(`auth.status_title`)}),(0,Y.jsx)(`p`,{className:`auth-status-detail`,children:c??y})]}),(0,Y.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,Y.jsx)(vm,{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,Y.jsx)(Lp,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`submit`,disabled:f||u||!o.trim(),children:x})]})]})})}var Kh={minHeight:`auto`,padding:0,gap:`var(--sp-5)`,alignItems:`stretch`,textAlign:`left`};function qh(){let e=X(),t=Pr()===`mobile`;return(0,Y.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,t?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,Y.jsxs)(`div`,{className:[`welcome-card`,`auth-card-shell`,t?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:[(0,Y.jsx)(Pm,{style:Kh,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker`,children:e(`auth.session_gate_title`)}),(0,Y.jsx)(`h1`,{className:`welcome-title`,children:e(`app.name`)})]}),description:(0,Y.jsx)(`p`,{className:`welcome-body auth-card-desc`,children:e(`auth.session_gate_description`)})}),(0,Y.jsxs)(`div`,{className:`auth-status-panel auth-status-panel-error`,children:[(0,Y.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`auth.status_title`)}),(0,Y.jsx)(`p`,{className:`auth-status-detail`,children:e(`auth.session_gate_detail`)})]}),(0,Y.jsx)(Lp,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`button`,onClick:()=>window.location.replace(`/`),children:e(`auth.session_gate_reenter`)})]})})}var Jh={claude:`Claude`,codex:`Codex`};function Yh(e){return Jh[e]?Jh[e]:e?e.charAt(0).toUpperCase()+e.slice(1):`Agent`}function Xh(e){if(!e)return``;let t=e.name?.trim();if(t)return Zh(t);let n=e.path?.trim();return n?Zh(n):``}function Zh(e){let t=e.replace(/[/\\]+$/,``),n=t.split(/[/\\]/);return n[n.length-1]||t}function Qh(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 $h=new WeakMap,eg=new WeakMap;function tg(e){let t=eg.get(e);if(t)return t;let n=new WeakSet;return eg.set(e,n),n}function ng(e){let t=e.get(Ta),n=tg(e);return t&&!n.has(t)?($h.set(e,t),t):$h.get(e)??null}function rg(){let e=H(Wf),t=U(Ta),n=me();return(0,V.useCallback)(async({workspaceId:r,sessionId:i})=>{let a=n.get(Ta),o=tg(n);if(ng(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(Ta);if(c.ok&&c.data)return $h.set(n,c.data),l===s?(o.delete(s),t(c.data),c.data):(o.delete(s),l);if(l===s){let e=ng(n);return o.delete(s),t(e),e}return o.delete(s),l},[e,t,n])}function ig(){let e=U(qf),t=rg();return(0,V.useCallback)(async n=>n?(e(n),t({workspaceId:n})):null,[t,e])}var ag=Kf(e=>B(null)),og=Kf(e=>B(!1)),sg=Kf(e=>B(new Set)),cg=Kf(e=>B({})),lg=Kf(e=>B(null)),ug=Kf(e=>B(0));Kf(e=>B(t=>{let n=t(lg(e));return n?t(cg(e))[n]??null:null})),Kf(e=>B(t=>{let n=t(cg(e));return Object.values(n).filter(e=>e.isDirty).length}));var dg=Kf(e=>B(null)),fg=Kf(e=>B(null)),pg=Kf(e=>B(!1));Kf(e=>B(t=>{let n=t(dg(e));return n?n.staged.length>0||n.modified.length>0||n.untracked.length>0||n.deleted.length>0:!1})),Kf(e=>B(t=>{let n=t(dg(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 mg=Kf(e=>B({current:``,branches:[],loading:!1})),hg=B({visible:!1,inputValue:``}),gg=Kf(e=>Gr(`coder-studio:git-commit-draft:${e}`,``)),_g=Kf(e=>B({items:[],loading:!1})),vg=Kf(e=>B({status:`idle`})),yg=Gr(`ui.focusMode`,!1),bg=Gr(`ui.leftPanelWidth`,280),xg=Gr(`ui.bottomPanelHeight`,200),Sg=Gr(`ui.sidebarCollapsed`,!1),Cg=Gr(`ui.terminalPanelVisible`,!0);function wg(e){let t=X(),n=Wt(),r=qt(),i=H(Wf),a=U(qf),o=U(Jf),s=U(Yf),c=U(Xf),l=U(Zf),u=rg(),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(!0),[C,w]=(0,V.useState)(null),T=t(`workspace.launch.title`),E=t(`workspace.launch.hint`),D=[`/`,`~`,`/home/spencer`];(0,V.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let O=(0,V.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)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},[i]);(0,V.useEffect)(()=>{O()},[O]);let k=(0,V.useCallback)(e=>{v(null),O(e)},[O]),A=(0,V.useCallback)(e=>{v(e)},[]),j=(0,V.useCallback)(async()=>{if(!_){w(t(`workspace.launch.select_required`));return}b(!0),w(null);try{let d=await i(`workspace.open`,{path:_});d.ok&&d.data?.id?(u({workspaceId:d.data.id}),a(d.data.id),o(e=>({...e,[d.data.id]:d.data})),s(e=>e.includes(d.data.id)?e:[d.data.id,...e]),c(`ready`),l(null),n.pathname!==`/workspace`&&r(`/workspace`),e()):w(d.error?.message||t(`workspace.launch.open_failed`))}catch(e){w(e instanceof Error?e.message:String(e))}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,V.useCallback)(e=>{if(e===`~`)return`~`;if(e===`/`)return`/`;let t=e.match(/^\/home\/[^/]+/);return t?e.replace(t[0],`~`):e},[]),handleNavigate:k,handleOpen:j,handleSelect:A,launchHint:E,launchTitle:T,loading:y,parentPath:h,rootPaths:D,selectedPath:_}}function Tg(e,t){let n=H(If),[r,i]=(0,V.useState)(`status`),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null);return(0,V.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,V.useCallback)(e=>{i(e)},[]),loading:d,status:a,tree:l}}var Eg={minHeight:`auto`,padding:`var(--sp-6)`,gap:0},Dg={padding:`var(--sp-8)`,gap:`var(--sp-2)`},Og={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},kg={position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0};function Ag({onClose:e}){let t=Pr()===`mobile`,n=X(),{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}=wg(e),_=(0,Y.jsxs)(`div`,{className:`launch-body`,children:[(0,Y.jsxs)(`div`,{className:`folder-picker`,children:[(0,Y.jsxs)(`div`,{className:`fp-toolbar`,children:[(0,Y.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(`~`),children:[(0,Y.jsx)(Q,{semantic:`workspace.launch.home`,size:12}),n(`workspace.launch.home_directory`)]}),m&&(0,Y.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(m),children:[(0,Y.jsx)(ri,{size:12}),n(`workspace.launch.go_up`)]})]}),(0,Y.jsxs)(`div`,{className:`fp-root-chips`,children:[h.map(e=>(0,Y.jsx)(`span`,{className:`fp-chip ${i===e?`active`:``}`,onClick:()=>c(e),children:e},e)),i&&!h.includes(i)&&(0,Y.jsx)(`span`,{className:`fp-chip active`,children:s(i)})]}),(0,Y.jsx)(`div`,{className:`fp-dir-list`,children:r?(0,Y.jsx)(Pm,{className:`directory-loading`,icon:(0,Y.jsx)(_h,{label:n(`common.loading`)}),style:Dg,title:(0,Y.jsx)(`span`,{style:kg,children:n(`common.loading`)})}):a.length===0?(0,Y.jsx)(Pm,{className:`directory-empty`,style:Eg,title:(0,Y.jsx)(`p`,{style:Og,children:n(`workspace.launch.no_directories`)})}):a.map(e=>(0,Y.jsxs)(`div`,{className:`fp-dir ${g===e.path?`selected`:``}`,onClick:()=>u(e.path),onDoubleClick:()=>c(e.path),children:[(0,Y.jsx)(`span`,{className:`fp-dir-icon`,children:(0,Y.jsx)(Q,{semantic:`file.folder.closed`,size:14})}),(0,Y.jsx)(`span`,{className:`fp-dir-name ${g===e.path?`selected`:``}`,children:e.name}),e.itemCount!==void 0&&(0,Y.jsx)(`span`,{className:`fp-dir-hint`,children:n(`workspace.launch.items_count`,{count:e.itemCount})}),g===e.path&&(0,Y.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,Y.jsx)(`div`,{className:`form-error`,style:{marginTop:`var(--sp-3)`},children:o})]}),v=(0,Y.jsx)(`div`,{className:`mobile-launch-sheet__footer`,children:(0,Y.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,Y.jsx)(Op,{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,Y.jsx)(`div`,{className:`launch-overlay`,onClick:e,children:(0,Y.jsxs)(`div`,{className:`launch-modal`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`launch-header`,children:[(0,Y.jsxs)(`div`,{className:`launch-header-left`,children:[(0,Y.jsx)(`div`,{className:`launch-kicker`,children:n(`workspace.launch.kicker`)}),(0,Y.jsx)(`div`,{className:`launch-title`,children:f}),(0,Y.jsx)(`div`,{className:`launch-hint`,children:d})]}),(0,Y.jsx)(`div`,{className:`launch-header-right`,children:(0,Y.jsx)(Z,{"aria-label":n(`action.close`),className:`launch-close-btn`,icon:(0,Y.jsx)(ea,{size:16}),onClick:e,size:`sm`})})]}),_,(0,Y.jsx)(`div`,{className:`launch-footer`,children:(0,Y.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 jg={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},Mg={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function Ng(){let e=X(),t=Wt(),n=qt(),r=Pr()===`mobile`,[i,a]=xe(Ca),[o,s]=xe(yg),[c,l]=xe(Sg),[u,d]=xe(Cg),[f,p]=xe(xg),m=H(tp),h=U(qf),g=ig(),_=H(ep),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)(!1),w=(0,V.useRef)(null),T=Pg({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:g,workspaces:_,locationPathname:t.pathname,navigate:n,t:e,setShowWorkspaceLaunch:e=>{e&&a(!1),C(e)}}).filter(e=>{let t=v.toLowerCase();return e.label.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.shortcut&&e.shortcut.toLowerCase().includes(t)});(0,V.useEffect)(()=>{i&&(w.current?.focus(),y(``),x(0))},[i]);let E=(0,V.useCallback)(e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>e<T.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),x(e=>e>0?e-1:e);break;case`Enter`:e.preventDefault(),T[b]&&(T[b].action(),a(!1));break;case`Escape`:e.preventDefault(),a(!1);break}},[T,b,a]);(0,V.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 D=e=>{e.action(),a(!1)},O=(0,Y.jsxs)(`div`,{className:`command-palette-search`,children:[(0,Y.jsx)(Q,{className:`command-palette-search-icon`,semantic:`nav.search`,size:16}),(0,Y.jsx)(`input`,{ref:w,type:`text`,className:`command-palette-input`,placeholder:e(`placeholder.command`),value:v,onChange:e=>{y(e.target.value),x(0)}})]}),k=(0,Y.jsx)(`div`,{className:`command-palette-list`,children:T.length>0?T.map((e,t)=>(0,Y.jsxs)(`div`,{className:`command-palette-item ${t===b?`command-palette-item-selected`:``}`,onClick:()=>D(e),onMouseEnter:()=>x(t),children:[(0,Y.jsxs)(`div`,{className:`command-palette-item-content`,children:[(0,Y.jsx)(`span`,{className:`command-palette-item-label`,children:e.label}),(0,Y.jsx)(`span`,{className:`command-palette-item-desc`,children:e.description})]}),e.shortcut?(0,Y.jsx)(`span`,{className:`command-palette-item-shortcut`,children:e.shortcut}):null]},e.id)):(0,Y.jsx)(Pm,{className:`command-palette-empty`,style:jg,title:(0,Y.jsx)(`p`,{style:Mg,children:e(`command.no_results`)})})});return S?(0,Y.jsx)(Ag,{onClose:()=>C(!1)}):i?r?(0,Y.jsx)(Op,{title:`Quick Actions`,kicker:e(`command.palette`).toUpperCase(),onClose:()=>a(!1),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`command-palette-sheet-layer`,body:(0,Y.jsx)(`div`,{className:`command-palette-sheet-shell`,onKeyDown:E,children:(0,Y.jsxs)(`div`,{className:`command-palette-sheet`,children:[(0,Y.jsxs)(`div`,{className:`command-palette-sheet__search`,children:[O,(0,Y.jsxs)(`div`,{className:`command-palette-sheet__meta`,children:[(0,Y.jsx)(`span`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),(0,Y.jsxs)(`span`,{className:`command-palette-meta`,children:[T.length,` actions`]})]})]}),k]})})}):(0,Y.jsx)(`div`,{className:`command-palette-overlay`,onClick:()=>a(!1),children:(0,Y.jsxs)(`div`,{className:`command-palette`,onClick:e=>e.stopPropagation(),onKeyDown:E,children:[(0,Y.jsxs)(`div`,{className:`command-palette-header`,children:[(0,Y.jsx)(`span`,{className:`command-palette-kicker`,children:e(`command.palette`).toUpperCase()}),(0,Y.jsxs)(`span`,{className:`command-palette-meta`,children:[T.length,` actions`]})]}),O,(0,Y.jsx)(`div`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),k]})}):null}function Pg(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,setShowWorkspaceLaunch:_}=e,v=[{id:`new-workspace`,label:g(`workspace.open`),description:g(`workspace.open_hint`),shortcut:`Ctrl+N`,action:()=>{_(!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`&&v.push({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=Xh(e)||e.id;v.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&&v.push({id:`go-home`,label:g(`action.back`),description:g(`workspace.no_workspace`),action:()=>{d(null),h(`/`)}}),v}var Fg={minHeight:`auto`,padding:0,gap:`var(--sp-5)`};function Ig(){let e=X(),t=qt(),n=Wt(),r=Pr()===`mobile`;return(0,Y.jsx)(`div`,{className:`welcome-container ${r?`welcome-container--mobile`:``}`,children:(0,Y.jsxs)(`div`,{className:`welcome-card ${r?`welcome-card--mobile`:``}`,children:[(0,Y.jsx)(Pm,{style:Fg,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker`,children:e(`not_found.kicker`)}),(0,Y.jsx)(`h1`,{className:`welcome-title`,children:e(`not_found.title`)})]}),description:(0,Y.jsx)(`div`,{className:`welcome-content`,children:(0,Y.jsx)(`p`,{className:`welcome-body`,children:e(`not_found.description`)})}),action:(0,Y.jsx)(`button`,{className:`welcome-btn`,onClick:()=>t(`/`),children:(0,Y.jsx)(`span`,{children:e(`not_found.go_home`)})})}),(0,Y.jsxs)(`div`,{className:`auth-status-panel`,children:[(0,Y.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`not_found.path_label`)}),(0,Y.jsx)(`p`,{className:`auth-status-detail`,children:n.pathname})]})]})})}var Lg=Gr(`ui.notificationPreferences`,{enabled:!0,soundEnabled:!0}),Rg=B([]),zg=B(null,(e,t,n)=>{let r=`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,i={...n,id:r,createdAt:Date.now()};t(Rg,e=>[...e.slice(-4),i])}),Bg=B(null,(e,t,n)=>{t(Rg,e=>e.filter(e=>e.id!==n))});function Vg(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 Hg({toast:e}){let t=U(Bg),n=U(qf),r=U(wa),i=qt(),a=rg(),o=e.duration??5e3;(0,V.useEffect)(()=>{if(o<=0)return;let n=setTimeout(()=>t(e.id),o);return()=>clearTimeout(n)},[e.id,o,t]);let s=(0,V.useCallback)(()=>{e.workspaceId&&e.sessionId?Vg({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,Y.jsx)(Vh,{description:e.body,onClick:e.workspaceId?s:void 0,onDismiss:()=>t(e.id),title:e.title,tone:e.kind})}function Ug(){let e=H(Rg),t=Pr()===`mobile`;return e.length===0?null:(0,Y.jsx)(Bh,{"aria-live":`polite`,mobile:t,children:e.map(e=>(0,Y.jsx)(Hg,{toast:e},e.id))})}var Wg=4e3,Gg=new Set([`running`]),Kg=new Set([`idle`,`ended`]);function qg(e,t,n,r,i){return n===e?r===`mobile`?i===t:!0:!1}function Jg(e,t){return e?`system`:t?`none`:`toast`}function Yg(){return!!(typeof document<`u`&&document.hidden)}async function Xg(){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 Zg(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(),Vg({workspaceId:e.workspaceId,sessionId:e.sessionId,setActiveWorkspaceId:e.setActiveWorkspaceId,persistLastViewedTarget:e.persistLastViewedTarget,setPendingFocus:e.setPendingFocus}),t.close()}}catch{}}function Qg(){let e=H(rp),t=H(Lf),n=H(Wf),r=H(Lg),i=U(Lg),a=H(tp),o=H(Ea),s=U(qf),c=U(zg),l=U(wa),u=X(),d=Pr(),f=rg(),p=me(),m=(0,V.useRef)(new Map);(0,V.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,V.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=Gg.has(m)&&(!e||!Gg.has(e.state)),g={state:m,activeSince:h?Date.now():e?.activeSince??(Gg.has(m)?Date.now():null),notifiedForTurn:h?!1:e?.notifiedForTurn??!1};if(t.set(n.id,g),!r.enabled||!i||!Gg.has(i)||!Kg.has(m)||g.notifiedForTurn)continue;if(m===`idle`&&g.activeSince!==null&&Date.now()-g.activeSince<Wg){g.notifiedForTurn=!0;continue}g.notifiedForTurn=!0;let _=Yg(),v=Jg(_,_?!1:qg(n.workspaceId,n.id,a,d,o));if(v===`none`)continue;let y=u(`notification.session_completed_title`,{session:n.title?.trim()||$g(n.id)}),b=p.get(Jf)[n.workspaceId],x=[],S=Yh(n.providerId).replace(/\s+/g,` `).trim();S&&x.push(S);let C=Xh(b??null).replace(/\s+/g,` `).trim();C&&x.push(C);let w=g.activeSince===null?null:Date.now()-g.activeSince,T=w===null?``:Qh(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
+ - 把 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:`启用目标`,edit_objective:`编辑 Supervisor`,disable:`禁用`,pause:`暂停`,resume:`恢复`,trigger:`触发评估`,pause_failed:`暂停失败`,resume_failed:`恢复失败`,trigger_failed:`触发评估失败`},dialog:{enable:{title:`启用 Supervisor`,subtitle:`描述一个目标,Supervisor 会在每轮结束后自动评估并提示下一步`,confirm:`启用`},edit:{title:`编辑 Supervisor`,subtitle:`调整目标描述或切换评估方,历史评估不会被清除`,confirm:`保存`},disable:{title:`禁用 Supervisor`,subtitle:`停止自动评估。当前会话的监督周期将被移除`,confirm:`禁用`,warning_title:`禁用后会停止评估周期`,warning_body:`当前会话的 Supervisor 将被移除,历史 cycles 会一并清理。可重新启用,但无法恢复记录。`}}},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 会话旁边直接运行命令和脚本。`}}},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:`接管失败 — 控制器仍然活跃`}},Sp={zh:{name:`中文`,data:xp},en:{name:`English`,data:bp}};function Cp(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 wp(e){let t=Sp[e]?.data??xp;function n(e,n){let r=Cp(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 Tp=B(e=>wp(e(xa)));function Ep(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 Dp(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 X(){return H(Tp)}function Op({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=X(),f=i??n,p=u??d(`action.back`);return(0,Y.jsxs)(`div`,{className:`mobile-sheet-layer`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mobile-sheet-layer__backdrop`,"aria-label":d(`mobile.sheet.dismiss`),onClick:n}),(0,Y.jsxs)(`section`,{className:J(`mobile-sheet`,l?`mobile-sheet--fullscreen`:null,c),"aria-label":d(`mobile.sheet.region`,{title:e}),role:`region`,children:[l?null:(0,Y.jsx)(`div`,{className:`mobile-sheet__handle`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`mobile-sheet__header`,children:(0,Y.jsx)(yp,{title:e,kicker:r,onBack:f,backLabel:p,rightSlot:o,titleAs:`h2`})}),(0,Y.jsx)(`div`,{className:J(`mobile-sheet__body`,s),children:t}),a?(0,Y.jsx)(`div`,{className:`mobile-sheet__footer`,children:a}):null]})]})}var kp={badge:`_badge_glfln_1`};function Ap({className:e,count:t,max:n=99,...r}){if(t<=0)return null;let i=t>n?`${n}+`:String(t);return(0,Y.jsx)(`span`,{...r,className:J(kp.badge,`topbar-unread`,e),children:i})}var jp={btn:`_btn_59wz6_1`,primary:`_primary_59wz6_36`,secondary:`_secondary_59wz6_47`,ghost:`_ghost_59wz6_62`,danger:`_danger_59wz6_75`,sm:`_sm_59wz6_81`,lg:`_lg_59wz6_89`,label:`_label_59wz6_97`,icon:`_icon_59wz6_102`,loading:`_loading_59wz6_107`,spinner:`_spinner_59wz6_111`},Mp={primary:jp.primary??``,secondary:jp.secondary??``,ghost:jp.ghost??``,danger:jp.danger??``},Np={sm:jp.sm,md:void 0,lg:jp.lg},Pp={primary:`btn-primary`,secondary:`btn-secondary`,ghost:`btn-ghost`,danger:`btn-danger`},Fp={sm:`btn-sm`,md:void 0,lg:`btn-lg`},Ip=({children:e,leadingIcon:t,loading:n,trailingIcon:r})=>(0,Y.jsxs)(Y.Fragment,{children:[n?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:J(jp.spinner,`animate-spin`)}):null,t?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:jp.icon,children:t}):null,(0,Y.jsx)(`span`,{className:jp.label,children:e}),r?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:jp.icon,children:r}):null]}),Lp=e=>{let{as:t=`button`,children:n,className:r,variant:i=`secondary`,size:a=`md`,loading:o=!1,leadingIcon:s,trailingIcon:c}=e,l=J(jp.btn,Mp[i],Np[a],`btn`,Pp[i],Fp[a],o?jp.loading:void 0,r),u=(0,Y.jsx)(Ip,{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,Y.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,Y.jsx)(`button`,{...x,"aria-busy":o?`true`:void 0,className:l,disabled:m||o,type:y??`button`,children:u})},Rp={root:`_root_1ojt1_1`,ghost:`_ghost_1ojt1_30`,filled:`_filled_1ojt1_40`,sm:`_sm_1ojt1_51`,lg:`_lg_1ojt1_57`,icon:`_icon_1ojt1_63`},zp={ghost:Rp.ghost,filled:Rp.filled},Bp={sm:Rp.sm,md:void 0,lg:Rp.lg},Vp={ghost:`btn-ghost`,filled:`btn-secondary`},Hp={sm:`btn-sm`,md:void 0,lg:`btn-lg`},Z=({"aria-label":e,className:t,icon:n,size:r=`md`,type:i,variant:a=`ghost`,...o})=>(0,Y.jsx)(`button`,{...o,"aria-label":e,className:J(Rp.root,zp[a],Bp[r],`btn`,Vp[a],Hp[r],t),type:i??`button`,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:Rp.icon,children:n})}),Up={overlay:`_overlay_1duw8_1`,card:`_card_1duw8_13`,sm:`_sm_1duw8_28`,md:`_md_1duw8_32`,lg:`_lg_1duw8_36`,full:`_full_1duw8_41`,header:`_header_1duw8_46`,title:`_title_1duw8_56`,body:`_body_1duw8_67`,footer:`_footer_1duw8_76`},Wp=(0,V.createContext)(null),Gp={sm:Up.sm,md:Up.md,lg:Up.lg,full:Up.full},Kp={sm:void 0,md:void 0,lg:`modal-card-lg`,full:void 0};function qp({children:e,className:t,dismissible:n=!0,initialFocus:r,onOpenChange:i,open:a,size:o=`md`}){let s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useId)(),u=(0,V.useMemo)(()=>({titleId:l}),[l]);return(0,V.useLayoutEffect)(()=>{if(!a)return;c.current=document.activeElement;let e=s.current;if(e)return fp(e,r).focus(),()=>{mp(c.current),c.current=null}},[r,a]),a?(0,Y.jsx)(gp,{children:(0,Y.jsx)(`div`,{className:J(Up.overlay,`modal-overlay`),onClick:e=>{n&&sp(e)&&i(!1)},children:(0,Y.jsx)(Wp.Provider,{value:u,children:(0,Y.jsx)(`div`,{"aria-labelledby":l,"aria-modal":`true`,className:J(Up.card,Gp[o],`modal-card`,Kp[o],t),onKeyDown:e=>{if(cp(e)){n&&(e.preventDefault(),e.stopPropagation(),i(!1));return}pp(e.currentTarget,e)},ref:s,role:`dialog`,tabIndex:-1,children:e})})})}):null}function Jp({className:e,...t}){return(0,Y.jsx)(`div`,{...t,className:J(Up.header,`modal-header`,e)})}function Yp({className:e,...t}){let n=(0,V.useContext)(Wp),r=(0,V.useId)(),i=n?.titleId??r;return(0,Y.jsx)(`h2`,{...t,className:J(Up.title,`modal-title`,e),id:i})}function Xp({className:e,...t}){return(0,Y.jsx)(`div`,{...t,className:J(Up.body,`modal-body`,e)})}function Zp({className:e,...t}){return(0,Y.jsx)(`div`,{...t,className:J(Up.footer,`modal-footer`,e)})}var Qp={root:`_root_1fg74_1`};function Q({className:e,decorative:t=!0,role:n,semantic:r,size:i=14,...a}){let o=aa(H(ba),r),s=o.Icon;return(0,Y.jsx)(`span`,{...a,"aria-hidden":t?!0:void 0,className:J(Qp.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,Y.jsx)(s,{size:i,strokeWidth:o.strokeWidth})})}var $p={body:`_body_p96py_1`,titleDanger:`_titleDanger_p96py_9`,iconDanger:`_iconDanger_p96py_13`},em={default:`primary`,danger:`danger`};function tm({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,Y.jsxs)(qp,{className:n,dismissible:l,initialFocus:u,onOpenChange:f,open:p,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(Yp,{className:J(h===`danger`?$p.titleDanger:void 0),children:[h===`danger`?(0,Y.jsx)(Q,{"aria-hidden":`true`,className:$p.iconDanger,semantic:`state.warning`,size:16}):null,(0,Y.jsx)(`span`,{children:m})]}),l||r?(0,Y.jsx)(Z,{"aria-label":i,className:`modal-close`,disabled:r,icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>f(!1),size:`sm`}):null]}),c?(0,Y.jsx)(Xp,{className:$p.body,children:c}):null,(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{disabled:e,onClick:()=>f(!1),children:t}),(0,Y.jsx)(Lp,{...v,className:g,disabled:o||_,onClick:d,variant:em[h],children:s})]})]})}var nm={triggerWrapper:`_triggerWrapper_77m7f_1`,content:`_content_77m7f_6`},rm=8,im=8;function am(e){return(0,V.isValidElement)(e)}function om({children:e,content:t,title:n,open:r,onOpenChange:i,forceMode:a=`auto`,placement:o=`bottom-start`,contentClassName:s,sheetBodyClassName:c}){let l=Pr(),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useId)(),m=a===`desktop`?`desktop`:a===`mobile`?`mobile`:l,h=r&&m===`desktop`,g=r&&m===`mobile`,[_,v]=(0,V.useState)({left:rm,top:rm,visibility:`hidden`}),y=V.Children.only(e);if((0,V.useLayoutEffect)(()=>{if(r)return f.current=document.activeElement,()=>{mp(f.current),f.current=null}},[r]),(0,V.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(rm,window.innerWidth-t.width-rm),i=Math.min(r,Math.max(rm,n)),a=e.bottom+im;v({left:i,top:a+t.height<=window.innerHeight-rm?a:Math.max(rm,e.top-t.height-im),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,V.useLayoutEffect)(()=>{!h||!d.current||d.current.focus()},[h]),(0,V.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=>{cp(e)&&(e.preventDefault(),i(!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[h,i]),!am(y))throw Error(`Popover requires a single trigger React element.`);let b=(0,V.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}cp(e)&&r&&(e.preventDefault(),i(!1))}}});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:nm.triggerWrapper,ref:u,children:b}),h?(0,Y.jsx)(gp,{children:(0,Y.jsx)(`div`,{"aria-label":n,"aria-modal":`false`,className:J(nm.content,s),id:p,onKeyDown:e=>{cp(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,Y.jsx)(Op,{body:(0,Y.jsx)(`div`,{children:t}),bodyClassName:c,onClose:()=>i(!1),title:n}):null]})}var sm={trigger:`_trigger_7ajv2_1`,value:`_value_7ajv2_11`,icon:`_icon_7ajv2_19`,content:`_content_7ajv2_24`,header:`_header_7ajv2_31`,title:`_title_7ajv2_37`,body:`_body_7ajv2_43`,calendar:`_calendar_7ajv2_49`,time:`_time_7ajv2_60`,actions:`_actions_7ajv2_70`,action:`_action_7ajv2_70`,popoverContent:`_popoverContent_7ajv2_106`,sheetBody:`_sheetBody_7ajv2_110`,calendarGrid:`_calendarGrid_7ajv2_118`,calendarHeader:`_calendarHeader_7ajv2_124`,calendarTitle:`_calendarTitle_7ajv2_131`,calendarNav:`_calendarNav_7ajv2_137`,calendarWeekdays:`_calendarWeekdays_7ajv2_158`,calendarWeekday:`_calendarWeekday_7ajv2_158`,calendarDays:`_calendarDays_7ajv2_173`,calendarDay:`_calendarDay_7ajv2_173`,calendarDayToday:`_calendarDayToday_7ajv2_199`,calendarDaySelected:`_calendarDaySelected_7ajv2_204`,calendarDayDisabled:`_calendarDayDisabled_7ajv2_213`,calendarDayEmpty:`_calendarDayEmpty_7ajv2_219`,timeSelector:`_timeSelector_7ajv2_224`,timeField:`_timeField_7ajv2_230`,timeLabel:`_timeLabel_7ajv2_237`,timeSeparator:`_timeSeparator_7ajv2_242`,timeSection:`_timeSection_7ajv2_249`,timeInput:`_timeInput_7ajv2_259`},cm=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`],lm=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`];function um(e,t){return new Date(e,t+1,0).getDate()}function dm(e,t){return new Date(e,t,1).getDay()}function fm(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function pm(e,t,n){return!!(t&&e<t||n&&e>n)}function mm({year:e,month:t,selectedDate:n,minDate:r,maxDate:i,onDateSelect:a,onMonthChange:o}){let s=X(),c=um(e,t),l=dm(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);pm(o,r,i)||a(o)},p=[];for(let e=0;e<l;e++)p.push((0,Y.jsx)(`div`,{className:sm.calendarDayEmpty},`empty-${e}`));for(let a=1;a<=c;a++){let o=new Date(e,t,a),s=n&&fm(o,n),c=pm(o,r,i),l=fm(o,new Date);p.push((0,Y.jsx)(`button`,{type:`button`,disabled:c,className:J(sm.calendarDay,s&&sm.calendarDaySelected,l&&!s&&sm.calendarDayToday,c&&sm.calendarDayDisabled),onClick:()=>f(a),children:a},a))}return(0,Y.jsxs)(`div`,{className:sm.calendarGrid,children:[(0,Y.jsxs)(`div`,{className:sm.calendarHeader,children:[(0,Y.jsx)(`button`,{type:`button`,className:sm.calendarNav,onClick:u,"aria-label":s(`datetime.prev_month`),children:(0,Y.jsx)(ci,{size:16})}),(0,Y.jsxs)(`span`,{className:sm.calendarTitle,children:[s(`datetime.${lm[t]}`),` `,e]}),(0,Y.jsx)(`button`,{type:`button`,className:sm.calendarNav,onClick:d,"aria-label":s(`datetime.next_month`),children:(0,Y.jsx)(li,{size:16})})]}),(0,Y.jsx)(`div`,{className:sm.calendarWeekdays,children:cm.map(e=>(0,Y.jsx)(`div`,{className:sm.calendarWeekday,children:s(`datetime.${e}`)},e))}),(0,Y.jsx)(`div`,{className:sm.calendarDays,children:p})]})}var hm={input:`_input_y1v5b_1`,sm:`_sm_y1v5b_27`,lg:`_lg_y1v5b_33`,invalid:`_invalid_y1v5b_39`},gm={sm:hm.sm,md:void 0,lg:hm.lg},_m={sm:`input-sm`,md:void 0,lg:`input-lg`},vm=(0,V.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,Y.jsx)(`input`,{...i,ref:a,size:t,"aria-invalid":o,className:J(hm.input,gm[r],`input`,_m[r],n?hm.invalid:void 0,e)})});function ym({hour:e,minute:t,onHourChange:n,onMinuteChange:r,disabled:i=!1}){let a=X(),o=(0,V.useId)(),s=(0,V.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,Y.jsxs)(`div`,{className:sm.timeSelector,children:[(0,Y.jsxs)(`div`,{className:sm.timeField,children:[(0,Y.jsx)(`label`,{htmlFor:o,className:sm.timeLabel,children:a(`datetime.hour`)}),(0,Y.jsx)(vm,{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:sm.timeInput})]}),(0,Y.jsx)(`span`,{className:sm.timeSeparator,children:`:`}),(0,Y.jsxs)(`div`,{className:sm.timeField,children:[(0,Y.jsx)(`label`,{htmlFor:s,className:sm.timeLabel,children:a(`datetime.minute`)}),(0,Y.jsx)(vm,{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:sm.timeInput})]})]})}function bm(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 xm(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 Sm(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Cm(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes())}function wm(e,t){return new Date(e,t+1,0).getDate()}function Tm(e,t,n){return Math.min(n,wm(e,t))}function Em(e){return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes()}}function Dm(e){return new Date(e.year,e.month,e.day,e.hour,e.minute)}function Om(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 km(e,t,n){let r=e.getTime();return t!==void 0&&r<t||n!==void 0&&r>n}var Am={sm:`input-sm`,md:void 0,lg:`input-lg`};function jm({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=X(),p=H(xa),m=Pr(),h=(0,V.useId)(),[g,_]=(0,V.useState)(!1),v=o?Cm(o).getTime():void 0,y=s?Cm(s).getTime():void 0,b=e=>Em(bm(e)||Om(Cm(new Date),v,y)),[x,S]=(0,V.useState)(()=>b(e));(0,V.useEffect)(()=>{S(b(e))},[e]);let C=(0,V.useCallback)(e=>{S(t=>({...t,year:e.getFullYear(),month:e.getMonth(),day:e.getDate()}))},[]),w=(0,V.useCallback)((e,t)=>{S(n=>({...n,year:e,month:t,day:Tm(e,t,n.day)}))},[]),T=(0,V.useCallback)(e=>{S(t=>({...t,hour:e}))},[]),E=(0,V.useCallback)(e=>{S(t=>({...t,minute:e}))},[]),D=km(Dm(x),v,y),O=(0,V.useCallback)(()=>{let e=Dm(x);km(e,v,y)||(t(xm(e)),_(!1))},[x,y,v,t]),k=(0,V.useCallback)(()=>{t(``),_(!1)},[t]),A=bm(e),j=A?Dp(A.getTime(),p):r??f(`datetime.select_date`),M=m===`mobile`,N=J(`input`,Am[l],sm.trigger,u?`input-invalid`:void 0,c),P=(0,Y.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,Y.jsx)(`span`,{className:sm.value,children:j}),(0,Y.jsx)(ai,{size:16,className:sm.icon,"aria-hidden":`true`})]}),F=new Date(x.year,x.month,x.day),ee=o?Sm(o):void 0,I=s?Sm(s):void 0,te=(0,Y.jsxs)(`div`,{className:sm.content,children:[(0,Y.jsxs)(`div`,{className:sm.body,children:[(0,Y.jsx)(mm,{year:x.year,month:x.month,selectedDate:F,minDate:ee,maxDate:I,onDateSelect:C,onMonthChange:w}),(0,Y.jsxs)(`div`,{className:sm.timeSection,children:[(0,Y.jsx)(`span`,{className:sm.timeLabel,children:f(`datetime.select_time`)}),(0,Y.jsx)(ym,{hour:x.hour,minute:x.minute,onHourChange:T,onMinuteChange:E})]})]}),(0,Y.jsxs)(`div`,{className:sm.actions,children:[a?(0,Y.jsx)(`button`,{type:`button`,className:sm.action,onClick:k,children:f(`datetime.clear`)}):null,(0,Y.jsx)(`button`,{type:`button`,className:sm.action,onClick:O,disabled:D,children:f(`datetime.confirm`)})]})]});return M?(0,Y.jsxs)(Y.Fragment,{children:[P,g?(0,Y.jsx)(Op,{title:n,body:te,bodyClassName:sm.sheetBody,onClose:()=>_(!1),fullscreen:!0}):null]}):(0,Y.jsx)(om,{open:g,onOpenChange:_,title:n,content:te,contentClassName:sm.popoverContent,sheetBodyClassName:sm.sheetBody,children:P})}var Mm={root:`_root_ua36l_1`,icon:`_icon_ua36l_13`,title:`_title_ua36l_20`,description:`_description_ua36l_26`,action:`_action_ua36l_33`};function Nm(e,t){if(e==null||typeof e==`boolean`)return null;if((0,V.isValidElement)(e)){let n=e;return(0,V.cloneElement)(n,{className:J(n.props.className,t)})}return(0,Y.jsx)(`div`,{className:t,children:e})}function Pm({action:e,className:t,description:n,icon:r,title:i,...a}){return(0,Y.jsxs)(`div`,{...a,className:J(Mm.root,t),children:[Nm(r,Mm.icon),Nm(i,Mm.title),Nm(n,Mm.description),e?(0,Y.jsx)(`div`,{className:Mm.action,children:e}):null]})}var Fm={kbd:`_kbd_1df0g_1`,interactive:`_interactive_1df0g_17`,sm:`_sm_1df0g_30`},Im={sm:Fm.sm,md:void 0},Lm=({children:e,className:t,interactive:n=!1,onKeyDown:r,size:i=`md`,tabIndex:a,...o})=>(0,Y.jsx)(`kbd`,{...o,className:J(Fm.kbd,Im[i],n?Fm.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}),Rm={notice:`_notice_18n4r_1`,info:`_info_18n4r_13`,success:`_success_18n4r_18`,warning:`_warning_18n4r_23`,error:`_error_18n4r_28`,copy:`_copy_18n4r_33`,title:`_title_18n4r_41`,message:`_message_18n4r_49`,action:`_action_18n4r_56`},zm={info:Rm.info,success:Rm.success,warning:Rm.warning,error:Rm.error},Bm={info:void 0,success:void 0,warning:void 0,error:`settings-page__notice--error`};function Vm({action:e,className:t,message:n,title:r,tone:i=`info`,...a}){return(0,Y.jsxs)(`div`,{...a,className:J(Rm.notice,zm[i],`settings-page__notice`,Bm[i],t),children:[r||n?(0,Y.jsxs)(`div`,{className:J(Rm.copy,`settings-page__notice-copy`),children:[r?(0,Y.jsx)(`span`,{className:J(Rm.title,`settings-page__notice-title`),children:r}):null,n?(0,Y.jsx)(`span`,{className:J(Rm.message,`settings-page__notice-message`),children:n}):null]}):null,e?(0,Y.jsx)(`div`,{className:Rm.action,children:e}):null]})}var Hm={pill:`_pill_1oryu_1`,active:`_active_1oryu_34`,icon:`_icon_1oryu_40`};function Um({active:e=!1,children:t,className:n,disabled:r=!1,leadingIcon:i,selected:a=!1,...o}){let s=e||a;return(0,Y.jsxs)(`button`,{...o,"aria-pressed":s,className:J(Hm.pill,s?Hm.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:Hm.icon,children:i}):null,(0,Y.jsx)(`span`,{children:t})]})}var Wm={root:`_root_1348s_1`,fill:`_fill_1348s_7`,success:`_success_1348s_14`,warning:`_warning_1348s_18`,error:`_error_1348s_22`,info:`_info_1348s_26`,neutral:`_neutral_1348s_30`,indeterminate:`_indeterminate_1348s_34`,progressBarIndeterminate:`_progressBarIndeterminate_1348s_1`},Gm={success:Wm.success,warning:Wm.warning,error:Wm.error,info:Wm.info,neutral:Wm.neutral};function Km(e,t,n){return Math.min(Math.max(e,t),n)}function qm({className:e,fillClassName:t,indeterminate:n=!1,max:r,style:i,tone:a,value:o,...s}){let c=s[`aria-hidden`]===!0||s[`aria-hidden`]===`true`,l=r>0?r:0,u=Km(o,0,l),d=l>0?Km(u/l*100,0,100):0;return(0,Y.jsx)(`div`,{...s,"aria-valuemax":c?void 0:l,"aria-valuemin":c?void 0:0,"aria-valuenow":c||n?void 0:u,className:J(Wm.root,n?Wm.indeterminate:void 0,e),role:c?void 0:`progressbar`,style:i,children:(0,Y.jsx)(`div`,{className:J(Wm.fill,Gm[a],t),style:n?void 0:{"--progress-bar-width":`${d}%`}})})}var Jm={tabs:`_tabs_29j1i_1`,tabList:`_tabList_29j1i_5`,tab:`_tab_29j1i_1`,tabActive:`_tabActive_29j1i_71`,panel:`_panel_29j1i_6`},Ym=(0,V.createContext)(null);function Xm(e){let t=(0,V.useContext)(Ym);if(!t)throw Error(`${e} must be used within Tabs`);return t}function Zm({children:e,className:t,orientation:n=`horizontal`,value:r,onValueChange:i,"aria-label":a,...o}){let s=(0,V.useId)(),c=(0,V.useRef)(new Map),[l,u]=(0,V.useState)({}),d=(0,V.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,V.useCallback)(e=>{u(t=>t[e]?t:{...t,[e]:!0})},[]),p=(0,V.useCallback)(e=>{u(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),m=(0,V.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,Y.jsx)(Ym.Provider,{value:m,children:(0,Y.jsx)(`div`,{...o,className:J(Jm.tabs,t),"data-orientation":n,children:e})})}function Qm({children:e,className:t,orientation:n,...r}){let i=Xm(`TabList`),a=n??i.orientation;return(0,Y.jsx)(`div`,{...r,"aria-label":r[`aria-label`]??i.listLabel,"aria-orientation":a===`vertical`?`vertical`:void 0,className:J(Jm.tabList,t),"data-orientation":a,role:`tablist`,children:e})}function $m({children:e,className:t,value:n,onClick:r,onKeyDown:i,...a}){let o=Xm(`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,Y.jsx)(`button`,{...a,"aria-controls":o.hasPanel(n)?c.panelId:void 0,"aria-selected":s,className:J(Jm.tab,s?Jm.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 eh({children:e,className:t,value:n,...r}){let i=Xm(`TabPanel`),a=i.value===n,o=i.ensureTabIds(n),{registerPanel:s,unregisterPanel:c}=i;return(0,V.useLayoutEffect)(()=>(s(n),()=>{c(n)}),[s,c,n]),(0,Y.jsx)(`div`,{...r,"aria-labelledby":o.tabId,className:J(Jm.panel,t),hidden:!a,id:o.panelId,role:`tabpanel`,children:e})}var th={segmentedControl:`_segmentedControl_1u28a_1`,segmentedControlOption:`_segmentedControlOption_1u28a_18`};function nh({options:e,value:t,onChange:n,size:r=`md`,className:i,optionClassName:a,...o}){return(0,Y.jsx)(Zm,{onValueChange:n,value:e.some(e=>e.value===t)?t:e.find(e=>!e.disabled)?.value??t,children:(0,Y.jsx)(Qm,{...o,className:J(th.segmentedControl,i),"data-size":r,children:e.map(e=>(0,Y.jsx)($m,{className:J(th.segmentedControlOption,a),"data-size":r,disabled:e.disabled,value:e.value,children:e.label},e.value))})})}var rh={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},ih={minHeight:`auto`,padding:`var(--sp-6) var(--sp-4)`,gap:0},ah={color:`var(--text-secondary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`},oh={color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`,lineHeight:`inherit`};function sh({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=X(),[y,b]=(0,V.useState)(``),x=(0,V.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,V.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))},te=(0,Y.jsxs)(Y.Fragment,{children:[a?(0,Y.jsxs)(`div`,{className:`mobile-select-sheet__search`,children:[(0,Y.jsx)(`label`,{className:`mobile-select-sheet__search-label`,htmlFor:x,children:v(`action.search`)}),(0,Y.jsx)(`input`,{id:x,type:`text`,className:`mobile-select-sheet__search-input`,placeholder:D,value:S,onChange:e=>O(e.target.value)})]}):null,(0,Y.jsx)(`div`,{className:`mobile-select-sheet__content`,children:d?(0,Y.jsx)(Pm,{className:`mobile-select-sheet__loading`,role:`status`,style:ih,title:(0,Y.jsx)(`div`,{style:ah,children:T})}):(0,Y.jsxs)(Y.Fragment,{children:[k.map(e=>e.items.length===0&&e.kind===`options`?null:(0,Y.jsxs)(`div`,{className:`mobile-select-sheet__section`,children:[e.title?(0,Y.jsx)(`div`,{className:`mobile-select-sheet__section-title`,children:e.title}):null,(0,Y.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,Y.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,Y.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,Y.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,Y.jsx)(`span`,{id:i,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,Y.jsx)(`span`,{id:`${e.id}-${t.id}-description`,className:`mobile-select-sheet__item-description`,children:t.description}):null,t.meta?(0,Y.jsx)(`span`,{id:`${e.id}-${t.id}-meta`,className:`mobile-select-sheet__item-meta`,children:t.meta}):null]}),t.badge?(0,Y.jsx)(kh,{color:`neutral`,caps:!1,className:`mobile-select-sheet__item-badge`,children:t.badge}):null]});return t.trailingAction?(0,Y.jsxs)(`div`,{className:`mobile-select-sheet__item-row`,"data-selected":n?`true`:`false`,children:[o,(0,Y.jsx)(Z,{"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,Y.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,Y.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,Y.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,Y.jsx)(`span`,{className:`mobile-select-sheet__item-icon`,"aria-hidden":`true`,children:t.icon}):null,(0,Y.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,Y.jsx)(`span`,{id:n,className:`mobile-select-sheet__item-label`,children:t.label}),t.description?(0,Y.jsx)(`span`,{id:r,className:`mobile-select-sheet__item-description`,children:t.description}):null]})]},t.id)})})]},e.id)),j?(0,Y.jsx)(`div`,{className:`mobile-select-sheet__section`,children:(0,Y.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,Y.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,Y.jsxs)(`span`,{className:`mobile-select-sheet__item-copy`,children:[(0,Y.jsx)(`span`,{id:e,className:`mobile-select-sheet__item-label`,children:l?.label(C)}),n?(0,Y.jsx)(`span`,{id:t,className:`mobile-select-sheet__item-description`,children:n}):null]})})})()})}):null,!A&&!j?(0,Y.jsx)(Pm,{className:`mobile-select-sheet__empty`,style:rh,title:(0,Y.jsx)(`div`,{style:oh,children:E})}):null]})})]});return i===`inline`?(0,Y.jsxs)(`div`,{className:`mobile-inline-sheet`,role:`dialog`,"aria-label":e,children:[(0,Y.jsx)(`div`,{className:`mobile-inline-sheet__handle`,"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`mobile-inline-sheet__header`,children:(0,Y.jsx)(yp,{title:e,titleAs:`h3`,onBack:h,backLabel:v(`action.back`)})}),(0,Y.jsx)(`div`,{className:`mobile-inline-sheet__body`,children:(0,Y.jsx)(`div`,{className:J(`mobile-select-sheet`,`mobile-select-sheet--inline`,n),children:te})})]}):(0,Y.jsx)(Op,{title:e,body:(0,Y.jsx)(`div`,{className:J(`mobile-select-sheet`,n),children:te}),onClose:_,kicker:m,onBack:h,bodyClassName:`mobile-sheet__body--flush`,fullscreen:!0})}var ch={root:`_root_skc9v_1`,native:`_native_skc9v_6`,mobileTrigger:`_mobileTrigger_skc9v_11`,mobileValue:`_mobileValue_skc9v_20`,mobileIcon:`_mobileIcon_skc9v_25`,listbox:`_listbox_skc9v_30`,option:`_option_skc9v_46`,optionSelected:`_optionSelected_skc9v_60`,optionDisabled:`_optionDisabled_skc9v_64`},lh={sm:hm.sm,md:void 0,lg:hm.lg},uh={sm:`input-sm`,md:void 0,lg:`input-lg`};function dh(e,t,n){return n||(t===void 0?``:e.find(e=>e.value===t)?.label??t)}function fh({className:e,invalid:t,size:n}){return J(hm.input,lh[n],`input`,uh[n],`mobile-select-trigger`,ch.mobileTrigger,t?hm.invalid:void 0,e)}function ph({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 mh(e){let t=Pr(),n=(0,V.useId)(),[r,i]=(0,V.useState)(!1),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.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,V.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,V.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,V.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=dh(p,h,g),b=`${o??n}-value`,{resolvedAriaLabel:x,resolvedAriaLabelledBy:S}=ph({ariaLabel:t,ariaLabelledBy:r,includeValueInAriaLabel:_,selectedLabel:y,valueId:b});return(0,Y.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:fh({className:i,invalid:s,size:l}),onClick:e=>{d?.(e),!e.defaultPrevented&&!a&&!e.currentTarget.disabled&&f()},children:[(0,Y.jsx)(`span`,{id:b,className:J(`mobile-select-trigger__value`,ch.mobileValue),children:y}),(0,Y.jsx)(si,{size:16,className:J(`mobile-select-trigger__icon`,ch.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=dh(w,E),k=`${_??n}-listbox`,A=`${_??n}-value`,{resolvedAriaLabel:j,resolvedAriaLabelledBy:M}=ph({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))}},te=y===`inline`?()=>i(!1):void 0;return(0,Y.jsxs)(`div`,{ref:a,className:ch.root,children:[(0,Y.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:fh({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,Y.jsx)(`span`,{id:A,className:J(`mobile-select-trigger__value`,ch.mobileValue),children:O}),(0,Y.jsx)(si,{size:16,className:J(`mobile-select-trigger__icon`,ch.mobileIcon),"aria-hidden":`true`})]}),p&&r?(0,Y.jsx)(`div`,{id:k,ref:s,role:`listbox`,"aria-label":t,"aria-labelledby":d,className:ch.listbox,onKeyDown:ee,children:w.map(e=>{let t=e.value===E;return(0,Y.jsx)(`div`,{role:`option`,id:`${k}-${e.value}`,"aria-disabled":e.disabled?`true`:void 0,"aria-selected":t,className:J(ch.option,t?ch.optionSelected:void 0,e.disabled?ch.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,Y.jsx)(sh,{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:te,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,Y.jsx)(`select`,{...x,size:h,"aria-invalid":u,className:J(hm.input,lh[l],`input`,uh[l],ch.native,g?hm.invalid:void 0,m),onChange:e=>{_?.(e),v?.(e.target.value)},children:y.map(e=>(0,Y.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))})}var hh={spinner:`_spinner_16qlq_1`},gh={sm:`12px`,md:`16px`,lg:`20px`};function _h({className:e,label:t,size:n=`md`,style:r,...i}){return(0,Y.jsx)(`span`,{...i,"aria-label":t,className:J(hh.spinner,`animate-spin`,e),role:`status`,style:{"--spinner-size":gh[n],...r}})}var vh={dot:`_dot_vc87z_1`,pulse:`_pulse_vc87z_12`,statusDotPulse:`_statusDotPulse_vc87z_1`},yh={success:`var(--color-success)`,warning:`var(--color-warning)`,error:`var(--color-error)`,info:`var(--color-info)`,neutral:`var(--text-tertiary)`},bh={sm:`6px`,md:`8px`,lg:`10px`};function xh({className:e,pulse:t=!1,size:n=`md`,style:r,tone:i=`neutral`,"aria-hidden":a=!0,...o}){return(0,Y.jsx)(`span`,{...o,"aria-hidden":a,className:J(vh.dot,t?vh.pulse:void 0,e),style:{"--status-dot-current-color":yh[i],"--status-dot-current-size":bh[n],...r}})}var Sh={switch:`_switch_14430_1`,track:`_track_14430_26`,checked:`_checked_14430_52`,thumb:`_thumb_14430_57`},Ch={sm:{trackWidth:`32px`,trackHeight:`18px`,thumbSize:`14px`,offset:`2px`},md:{trackWidth:`36px`,trackHeight:`20px`,thumbSize:`16px`,offset:`2px`}};function wh({checked:e,className:t,disabled:n=!1,onCheckedChange:r,onClick:i,size:a=`md`,style:o,...s}){let c=Ch[a];return(0,Y.jsx)(`button`,{...s,"aria-checked":e,className:J(Sh.switch,e?Sh.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:Sh.track,children:(0,Y.jsx)(`span`,{className:Sh.thumb})})})}var Th={tag:`_tag_27mfm_1`,sm:`_sm_27mfm_16`,noCaps:`_noCaps_27mfm_22`,blue:`_blue_27mfm_26`,green:`_green_27mfm_32`,amber:`_amber_27mfm_38`,pink:`_pink_27mfm_44`,purple:`_purple_27mfm_50`,neutral:`_neutral_27mfm_56`},Eh={blue:Th.blue,green:Th.green,amber:Th.amber,pink:Th.pink,purple:Th.purple,neutral:Th.neutral},Dh={blue:`badge-blue`,green:`badge-green`,amber:`badge-amber`,pink:`badge-pink`,purple:`badge-purple`,neutral:`badge-gray`},Oh={sm:Th.sm,md:void 0};function kh({caps:e=!0,className:t,color:n=`neutral`,size:r=`md`,...i}){return(0,Y.jsx)(`span`,{...i,className:J(Th.tag,Eh[n],Oh[r],e?void 0:Th.noCaps,`badge`,Dh[n],t)})}var Ah={input:`_input_1syx3_1`,textarea:`_textarea_1syx3_27`,lg:`_lg_1syx3_34`,invalid:`_invalid_1syx3_40`},jh={md:void 0,lg:Ah.lg},Mh={md:void 0,lg:`textarea-lg`};function Nh(e,t){if(typeof e==`function`){e(t);return}e&&(e.current=t)}function Ph(e){e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}var Fh=(0,V.forwardRef)(function({autoResize:e=!1,className:t,invalid:n,onChange:r,size:i=`md`,...a},o){let s=(0,V.useRef)(null),c=n===void 0?a[`aria-invalid`]:n?`true`:`false`;return(0,V.useEffect)(()=>{!e||!s.current||Ph(s.current)},[e,a.defaultValue,a.value]),(0,Y.jsx)(`textarea`,{...a,"aria-invalid":c,className:J(Ah.input,Ah.textarea,jh[i],`input`,`textarea`,Mh[i],n?Ah.invalid:void 0,t),onChange:t=>{e&&Ph(t.currentTarget),r?.(t)},ref:e=>{s.current=e,Nh(o,e)}})}),Ih={viewport:`_viewport_wwtxg_1`,mobile:`_mobile_wwtxg_14`,toast:`_toast_wwtxg_24`,slideIn:`_slideIn_wwtxg_1`,clickable:`_clickable_wwtxg_41`,success:`_success_wwtxg_50`,error:`_error_wwtxg_54`,warning:`_warning_wwtxg_58`,info:`_info_wwtxg_62`,icon:`_icon_wwtxg_66`,content:`_content_wwtxg_98`,title:`_title_wwtxg_106`,body:`_body_wwtxg_113`,action:`_action_wwtxg_121`,close:`_close_wwtxg_137`},Lh={success:Ih.success,error:Ih.error,warning:Ih.warning,info:Ih.info},Rh={success:`toast--success`,error:`toast--error`,warning:`toast--warning`,info:`toast--info`},zh={success:`state.success`,error:`state.error`,warning:`state.warning`,info:`state.info`};function Bh({children:e,className:t,mobile:n=!1,...r}){return(0,Y.jsx)(`div`,{...r,className:J(Ih.viewport,n?Ih.mobile:void 0,`toast-container`,n?`toast-container--mobile`:void 0,t),children:e})}function Vh({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,Y.jsx)(Q,{className:`toast__icon-symbol`,semantic:zh[l],size:16});return(0,Y.jsxs)(`div`,{...p,"aria-live":f,className:J(Ih.toast,Lh[l],d?Ih.clickable:void 0,`toast`,Rh[l],t),onClick:o,role:`alert`,children:[m?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:J(Ih.icon,`toast__icon`),children:m}):null,(0,Y.jsxs)(`div`,{className:J(Ih.content,`toast__content`),children:[(0,Y.jsx)(`span`,{className:J(Ih.title,`toast__title`),children:c}),r?(0,Y.jsx)(`span`,{className:J(Ih.body,`toast__body`),children:r}):null]}),e&&a?(0,Y.jsx)(`button`,{className:Ih.action,onClick:e=>{e.stopPropagation(),a()},type:`button`,children:e}):null,(0,Y.jsx)(Z,{"aria-label":n,className:J(Ih.close,`toast__close`),icon:(0,Y.jsx)(ea,{size:14}),onClick:e=>{e.stopPropagation(),s()},size:`sm`})]})}var Hh={disabledTriggerWrapper:`_disabledTriggerWrapper_15c9s_1`,tooltip:`_tooltip_15c9s_5`};function Uh(e){return(0,V.isValidElement)(e)}function $({children:e,content:t,disabled:n=!1}){let r=V.Children.only(e),i=Pr(),a=(0,V.useId)(),o=(0,V.useRef)(null),s=(0,V.useRef)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)({left:0,top:0});if(!Uh(r))return r;let m=!n&&i===`desktop`,h=m&&(c||u),g=r.props.disabled===!0,_=r.props[`aria-describedby`],v=(0,V.useMemo)(()=>h?[_,a].filter(Boolean).join(` `):_,[_,h,a]);(0,V.useLayoutEffect)(()=>{if(!h||!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);p({left:i,top:Math.max(8,a>=8?a:Math.min(l,c))})},[h]);let y=g?(0,V.cloneElement)(r,{"aria-describedby":v}):(0,V.cloneElement)(r,{"aria-describedby":v,onBlur:e=>{r.props.onBlur?.(e),d(!1)},onFocus:e=>{r.props.onFocus?.(e),!e.defaultPrevented&&m&&(o.current=e.currentTarget,d(!0))},onMouseEnter:e=>{r.props.onMouseEnter?.(e),!e.defaultPrevented&&m&&(o.current=e.currentTarget,l(!0))},onMouseLeave:e=>{r.props.onMouseLeave?.(e),l(!1)}});return(0,Y.jsxs)(Y.Fragment,{children:[g?(0,Y.jsx)(`span`,{className:Hh.disabledTriggerWrapper,onMouseEnter:e=>{!e.defaultPrevented&&m&&(o.current=e.currentTarget,l(!0))},onMouseLeave:()=>{l(!1)},children:y}):y,h?(0,Y.jsx)(gp,{children:(0,Y.jsx)(`div`,{className:J(Hh.tooltip),id:a,ref:s,role:`tooltip`,style:{left:`${f.left}px`,top:`${f.top}px`},children:t})}):null]})}var Wh={minHeight:`auto`,padding:0,gap:`var(--sp-5)`,alignItems:`stretch`,textAlign:`left`};function Gh({onAuthenticated:e}){let t=X(),[,n]=xe(Sa),r=H(xa),i=H(Uf),a=Pr()===`mobile`,[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(i===null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1);(0,V.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:Dp(e,r,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1})});return(0,Y.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,a?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,Y.jsx)(`div`,{className:[`welcome-card`,`auth-card-shell`,a?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:(0,Y.jsxs)(`div`,{className:`auth-card-shell__content`,children:[(0,Y.jsx)(Pm,{style:Wh,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:`CODER STUDIO`}),(0,Y.jsx)(`h1`,{className:`welcome-title page-title`,children:t(`app.name`)})]}),description:(0,Y.jsx)(`p`,{className:`welcome-body auth-card-desc meta-text`,children:v})}),(0,Y.jsxs)(`div`,{className:b,children:[(0,Y.jsx)(`div`,{className:`auth-status-eyebrow`,children:t(`auth.status_title`)}),(0,Y.jsx)(`p`,{className:`auth-status-detail`,children:c??y})]}),(0,Y.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,Y.jsx)(vm,{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,Y.jsx)(Lp,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`submit`,disabled:f||u||!o.trim(),children:x})]})]})})})}var Kh={minHeight:`auto`,padding:0,gap:`var(--sp-5)`,alignItems:`stretch`,textAlign:`left`};function qh(){let e=X(),t=Pr()===`mobile`;return(0,Y.jsx)(`div`,{className:[`welcome-container`,`auth-screen`,t?`welcome-container--mobile auth-screen--mobile`:``].filter(Boolean).join(` `),children:(0,Y.jsxs)(`div`,{className:[`welcome-card`,`auth-card-shell`,t?`welcome-card--mobile auth-card-shell--mobile`:``].filter(Boolean).join(` `),children:[(0,Y.jsx)(Pm,{style:Kh,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker`,children:e(`auth.session_gate_title`)}),(0,Y.jsx)(`h1`,{className:`welcome-title`,children:e(`app.name`)})]}),description:(0,Y.jsx)(`p`,{className:`welcome-body auth-card-desc`,children:e(`auth.session_gate_description`)})}),(0,Y.jsxs)(`div`,{className:`auth-status-panel auth-status-panel-error`,children:[(0,Y.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`auth.status_title`)}),(0,Y.jsx)(`p`,{className:`auth-status-detail`,children:e(`auth.session_gate_detail`)})]}),(0,Y.jsx)(Lp,{className:`auth-submit`,variant:`primary`,size:`lg`,type:`button`,onClick:()=>window.location.replace(`/`),children:e(`auth.session_gate_reenter`)})]})})}var Jh={claude:`Claude`,codex:`Codex`};function Yh(e){return Jh[e]?Jh[e]:e?e.charAt(0).toUpperCase()+e.slice(1):`Agent`}function Xh(e){if(!e)return``;let t=e.name?.trim();if(t)return Zh(t);let n=e.path?.trim();return n?Zh(n):``}function Zh(e){let t=e.replace(/[/\\]+$/,``),n=t.split(/[/\\]/);return n[n.length-1]||t}function Qh(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 $h=new WeakMap,eg=new WeakMap;function tg(e){let t=eg.get(e);if(t)return t;let n=new WeakSet;return eg.set(e,n),n}function ng(e){let t=e.get(Ta),n=tg(e);return t&&!n.has(t)?($h.set(e,t),t):$h.get(e)??null}function rg(){let e=H(Wf),t=U(Ta),n=me();return(0,V.useCallback)(async({workspaceId:r,sessionId:i})=>{let a=n.get(Ta),o=tg(n);if(ng(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(Ta);if(c.ok&&c.data)return $h.set(n,c.data),l===s?(o.delete(s),t(c.data),c.data):(o.delete(s),l);if(l===s){let e=ng(n);return o.delete(s),t(e),e}return o.delete(s),l},[e,t,n])}function ig(){let e=U(qf),t=rg();return(0,V.useCallback)(async n=>n?(e(n),t({workspaceId:n})):null,[t,e])}var ag=Kf(e=>B(null)),og=Kf(e=>B(!1)),sg=Kf(e=>B(new Set)),cg=Kf(e=>B({})),lg=Kf(e=>B(null)),ug=Kf(e=>B(0));Kf(e=>B(t=>{let n=t(lg(e));return n?t(cg(e))[n]??null:null})),Kf(e=>B(t=>{let n=t(cg(e));return Object.values(n).filter(e=>e.isDirty).length}));var dg=Kf(e=>B(null)),fg=Kf(e=>B(null)),pg=Kf(e=>B(!1));Kf(e=>B(t=>{let n=t(dg(e));return n?n.staged.length>0||n.modified.length>0||n.untracked.length>0||n.deleted.length>0:!1})),Kf(e=>B(t=>{let n=t(dg(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 mg=Kf(e=>B({current:``,branches:[],loading:!1})),hg=B({visible:!1,inputValue:``}),gg=Kf(e=>Gr(`coder-studio:git-commit-draft:${e}`,``)),_g=Kf(e=>B({items:[],loading:!1})),vg=Kf(e=>B({status:`idle`})),yg=Gr(`ui.focusMode`,!1),bg=Gr(`ui.leftPanelWidth`,280),xg=Gr(`ui.bottomPanelHeight`,200),Sg=Gr(`ui.sidebarCollapsed`,!1),Cg=Gr(`ui.terminalPanelVisible`,!0);function wg(e){let t=X(),n=Wt(),r=qt(),i=H(Wf),a=U(qf),o=U(Jf),s=U(Yf),c=U(Xf),l=U(Zf),u=rg(),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(!0),[C,w]=(0,V.useState)(null),T=t(`workspace.launch.title`),E=t(`workspace.launch.hint`),D=[`/`,`~`,`/home/spencer`];(0,V.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let O=(0,V.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)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},[i]);(0,V.useEffect)(()=>{O()},[O]);let k=(0,V.useCallback)(e=>{v(null),O(e)},[O]),A=(0,V.useCallback)(e=>{v(e)},[]),j=(0,V.useCallback)(async()=>{if(!_){w(t(`workspace.launch.select_required`));return}b(!0),w(null);try{let d=await i(`workspace.open`,{path:_});d.ok&&d.data?.id?(u({workspaceId:d.data.id}),a(d.data.id),o(e=>({...e,[d.data.id]:d.data})),s(e=>e.includes(d.data.id)?e:[d.data.id,...e]),c(`ready`),l(null),n.pathname!==`/workspace`&&r(`/workspace`),e()):w(d.error?.message||t(`workspace.launch.open_failed`))}catch(e){w(e instanceof Error?e.message:String(e))}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,V.useCallback)(e=>{if(e===`~`)return`~`;if(e===`/`)return`/`;let t=e.match(/^\/home\/[^/]+/);return t?e.replace(t[0],`~`):e},[]),handleNavigate:k,handleOpen:j,handleSelect:A,launchHint:E,launchTitle:T,loading:y,parentPath:h,rootPaths:D,selectedPath:_}}function Tg(e,t){let n=H(If),[r,i]=(0,V.useState)(`status`),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null);return(0,V.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,V.useCallback)(e=>{i(e)},[]),loading:d,status:a,tree:l}}var Eg={minHeight:`auto`,padding:`var(--sp-6)`,gap:0},Dg={padding:`var(--sp-8)`,gap:`var(--sp-2)`},Og={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},kg={position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0};function Ag({onClose:e}){let t=Pr()===`mobile`,n=X(),{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}=wg(e),_=(0,Y.jsxs)(`div`,{className:`launch-body`,children:[(0,Y.jsxs)(`div`,{className:`folder-picker`,children:[(0,Y.jsxs)(`div`,{className:`fp-toolbar`,children:[(0,Y.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(`~`),children:[(0,Y.jsx)(Q,{semantic:`workspace.launch.home`,size:12}),n(`workspace.launch.home_directory`)]}),m&&(0,Y.jsxs)(`button`,{className:`fp-btn`,onClick:()=>c(m),children:[(0,Y.jsx)(ri,{size:12}),n(`workspace.launch.go_up`)]})]}),(0,Y.jsxs)(`div`,{className:`fp-root-chips`,children:[h.map(e=>(0,Y.jsx)(`span`,{className:`fp-chip ${i===e?`active`:``}`,onClick:()=>c(e),children:e},e)),i&&!h.includes(i)&&(0,Y.jsx)(`span`,{className:`fp-chip active`,children:s(i)})]}),(0,Y.jsx)(`div`,{className:`fp-dir-list`,children:r?(0,Y.jsx)(Pm,{className:`directory-loading`,icon:(0,Y.jsx)(_h,{label:n(`common.loading`)}),style:Dg,title:(0,Y.jsx)(`span`,{style:kg,children:n(`common.loading`)})}):a.length===0?(0,Y.jsx)(Pm,{className:`directory-empty`,style:Eg,title:(0,Y.jsx)(`p`,{style:Og,children:n(`workspace.launch.no_directories`)})}):a.map(e=>(0,Y.jsxs)(`div`,{className:`fp-dir ${g===e.path?`selected`:``}`,onClick:()=>u(e.path),onDoubleClick:()=>c(e.path),children:[(0,Y.jsx)(`span`,{className:`fp-dir-icon`,children:(0,Y.jsx)(Q,{semantic:`file.folder.closed`,size:14})}),(0,Y.jsx)(`span`,{className:`fp-dir-name ${g===e.path?`selected`:``}`,children:e.name}),e.itemCount!==void 0&&(0,Y.jsx)(`span`,{className:`fp-dir-hint`,children:n(`workspace.launch.items_count`,{count:e.itemCount})}),g===e.path&&(0,Y.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,Y.jsx)(`div`,{className:`form-error`,style:{marginTop:`var(--sp-3)`},children:o})]}),v=(0,Y.jsx)(`div`,{className:`mobile-launch-sheet__footer`,children:(0,Y.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,Y.jsx)(Op,{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,Y.jsx)(`div`,{className:`launch-overlay`,onClick:e,children:(0,Y.jsxs)(`div`,{className:`launch-modal`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`launch-header`,children:[(0,Y.jsxs)(`div`,{className:`launch-header-left`,children:[(0,Y.jsx)(`div`,{className:`launch-kicker`,children:n(`workspace.launch.kicker`)}),(0,Y.jsx)(`div`,{className:`launch-title`,children:f}),(0,Y.jsx)(`div`,{className:`launch-hint`,children:d})]}),(0,Y.jsx)(`div`,{className:`launch-header-right`,children:(0,Y.jsx)(Z,{"aria-label":n(`action.close`),className:`launch-close-btn`,icon:(0,Y.jsx)(ea,{size:16}),onClick:e,size:`sm`})})]}),_,(0,Y.jsx)(`div`,{className:`launch-footer`,children:(0,Y.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 jg={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},Mg={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function Ng(){let e=X(),t=Wt(),n=qt(),r=Pr()===`mobile`,[i,a]=xe(Ca),[o,s]=xe(yg),[c,l]=xe(Sg),[u,d]=xe(Cg),[f,p]=xe(xg),m=H(tp),h=U(qf),g=ig(),_=H(ep),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)(!1),w=(0,V.useRef)(null),T=Pg({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:g,workspaces:_,locationPathname:t.pathname,navigate:n,t:e,setShowWorkspaceLaunch:e=>{e&&a(!1),C(e)}}).filter(e=>{let t=v.toLowerCase();return e.label.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.shortcut&&e.shortcut.toLowerCase().includes(t)});(0,V.useEffect)(()=>{i&&(w.current?.focus(),y(``),x(0))},[i]);let E=(0,V.useCallback)(e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>e<T.length-1?e+1:e);break;case`ArrowUp`:e.preventDefault(),x(e=>e>0?e-1:e);break;case`Enter`:e.preventDefault(),T[b]&&(T[b].action(),a(!1));break;case`Escape`:e.preventDefault(),a(!1);break}},[T,b,a]);(0,V.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 D=e=>{e.action(),a(!1)},O=(0,Y.jsxs)(`div`,{className:`command-palette-search`,children:[(0,Y.jsx)(Q,{className:`command-palette-search-icon`,semantic:`nav.search`,size:16}),(0,Y.jsx)(`input`,{ref:w,type:`text`,className:`command-palette-input`,placeholder:e(`placeholder.command`),value:v,onChange:e=>{y(e.target.value),x(0)}})]}),k=(0,Y.jsx)(`div`,{className:`command-palette-list`,children:T.length>0?T.map((e,t)=>(0,Y.jsxs)(`div`,{className:`command-palette-item ${t===b?`command-palette-item-selected`:``}`,onClick:()=>D(e),onMouseEnter:()=>x(t),children:[(0,Y.jsxs)(`div`,{className:`command-palette-item-content`,children:[(0,Y.jsx)(`span`,{className:`command-palette-item-label`,children:e.label}),(0,Y.jsx)(`span`,{className:`command-palette-item-desc`,children:e.description})]}),e.shortcut?(0,Y.jsx)(`span`,{className:`command-palette-item-shortcut`,children:e.shortcut}):null]},e.id)):(0,Y.jsx)(Pm,{className:`command-palette-empty`,style:jg,title:(0,Y.jsx)(`p`,{style:Mg,children:e(`command.no_results`)})})});return S?(0,Y.jsx)(Ag,{onClose:()=>C(!1)}):i?r?(0,Y.jsx)(Op,{title:`Quick Actions`,kicker:e(`command.palette`).toUpperCase(),onClose:()=>a(!1),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`command-palette-sheet-layer`,body:(0,Y.jsx)(`div`,{className:`command-palette-sheet-shell`,onKeyDown:E,children:(0,Y.jsxs)(`div`,{className:`command-palette-sheet`,children:[(0,Y.jsxs)(`div`,{className:`command-palette-sheet__search`,children:[O,(0,Y.jsxs)(`div`,{className:`command-palette-sheet__meta`,children:[(0,Y.jsx)(`span`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),(0,Y.jsxs)(`span`,{className:`command-palette-meta`,children:[T.length,` actions`]})]})]}),k]})})}):(0,Y.jsx)(`div`,{className:`command-palette-overlay`,onClick:()=>a(!1),children:(0,Y.jsxs)(`div`,{className:`command-palette command-palette--desktop`,onClick:e=>e.stopPropagation(),onKeyDown:E,children:[(0,Y.jsxs)(`div`,{className:`command-palette-header`,children:[(0,Y.jsx)(`span`,{className:`command-palette-kicker`,children:e(`command.palette`).toUpperCase()}),(0,Y.jsxs)(`span`,{className:`command-palette-meta`,children:[T.length,` actions`]})]}),O,(0,Y.jsx)(`div`,{className:`command-palette-hint`,children:e(`placeholder.command`)}),k]})}):null}function Pg(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,setShowWorkspaceLaunch:_}=e,v=[{id:`new-workspace`,label:g(`workspace.open`),description:g(`workspace.open_hint`),shortcut:`Ctrl+N`,action:()=>{_(!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`&&v.push({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=Xh(e)||e.id;v.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&&v.push({id:`go-home`,label:g(`action.back`),description:g(`workspace.no_workspace`),action:()=>{d(null),h(`/`)}}),v}var Fg={minHeight:`auto`,padding:0,gap:`var(--sp-5)`};function Ig(){let e=X(),t=qt(),n=Wt(),r=Pr()===`mobile`;return(0,Y.jsx)(`div`,{className:`welcome-container ${r?`welcome-container--mobile`:``}`,children:(0,Y.jsxs)(`div`,{className:`welcome-card ${r?`welcome-card--mobile`:``}`,children:[(0,Y.jsx)(`div`,{className:`welcome-card__hero`,children:(0,Y.jsx)(Pm,{style:Fg,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`not_found.kicker`)}),(0,Y.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`not_found.title`)})]}),description:(0,Y.jsx)(`div`,{className:`welcome-content`,children:(0,Y.jsx)(`p`,{className:`welcome-body meta-text`,children:e(`not_found.description`)})})})}),(0,Y.jsx)(`div`,{className:`welcome-card__actions`,children:(0,Y.jsx)(`button`,{className:`welcome-btn`,onClick:()=>t(`/`),children:(0,Y.jsx)(`span`,{children:e(`not_found.go_home`)})})}),(0,Y.jsx)(`div`,{className:`welcome-card__panel`,children:(0,Y.jsxs)(`div`,{className:`auth-status-panel`,children:[(0,Y.jsx)(`div`,{className:`auth-status-eyebrow`,children:e(`not_found.path_label`)}),(0,Y.jsx)(`p`,{className:`auth-status-detail`,children:n.pathname})]})})]})})}var Lg=Gr(`ui.notificationPreferences`,{enabled:!0,soundEnabled:!0}),Rg=B([]),zg=B(null,(e,t,n)=>{let r=`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,i={...n,id:r,createdAt:Date.now()};t(Rg,e=>[...e.slice(-4),i])}),Bg=B(null,(e,t,n)=>{t(Rg,e=>e.filter(e=>e.id!==n))});function Vg(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 Hg({toast:e}){let t=U(Bg),n=U(qf),r=U(wa),i=qt(),a=rg(),o=e.duration??5e3;(0,V.useEffect)(()=>{if(o<=0)return;let n=setTimeout(()=>t(e.id),o);return()=>clearTimeout(n)},[e.id,o,t]);let s=(0,V.useCallback)(()=>{e.workspaceId&&e.sessionId?Vg({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,Y.jsx)(Vh,{description:e.body,onClick:e.workspaceId?s:void 0,onDismiss:()=>t(e.id),title:e.title,tone:e.kind})}function Ug(){let e=H(Rg),t=Pr()===`mobile`;return e.length===0?null:(0,Y.jsx)(Bh,{"aria-live":`polite`,mobile:t,children:e.map(e=>(0,Y.jsx)(Hg,{toast:e},e.id))})}var Wg=4e3,Gg=new Set([`running`]),Kg=new Set([`idle`,`ended`]);function qg(e,t,n,r,i){return n===e?r===`mobile`?i===t:!0:!1}function Jg(e,t){return e?`system`:t?`none`:`toast`}function Yg(){return!!(typeof document<`u`&&document.hidden)}async function Xg(){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 Zg(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(),Vg({workspaceId:e.workspaceId,sessionId:e.sessionId,setActiveWorkspaceId:e.setActiveWorkspaceId,persistLastViewedTarget:e.persistLastViewedTarget,setPendingFocus:e.setPendingFocus}),t.close()}}catch{}}function Qg(){let e=H(rp),t=H(Lf),n=H(Wf),r=H(Lg),i=U(Lg),a=H(tp),o=H(Ea),s=U(qf),c=U(zg),l=U(wa),u=X(),d=Pr(),f=rg(),p=me(),m=(0,V.useRef)(new Map);(0,V.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,V.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=Gg.has(m)&&(!e||!Gg.has(e.state)),g={state:m,activeSince:h?Date.now():e?.activeSince??(Gg.has(m)?Date.now():null),notifiedForTurn:h?!1:e?.notifiedForTurn??!1};if(t.set(n.id,g),!r.enabled||!i||!Gg.has(i)||!Kg.has(m)||g.notifiedForTurn)continue;if(m===`idle`&&g.activeSince!==null&&Date.now()-g.activeSince<Wg){g.notifiedForTurn=!0;continue}g.notifiedForTurn=!0;let _=Yg(),v=Jg(_,_?!1:qg(n.workspaceId,n.id,a,d,o));if(v===`none`)continue;let y=u(`notification.session_completed_title`,{session:n.title?.trim()||$g(n.id)}),b=p.get(Jf)[n.workspaceId],x=[],S=Yh(n.providerId).replace(/\s+/g,` `).trim();S&&x.push(S);let C=Xh(b??null).replace(/\s+/g,` `).trim();C&&x.push(C);let w=g.activeSince===null?null:Date.now()-g.activeSince,T=w===null?``:Qh(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(`
104
104
  `);r.soundEnabled&&Xg(),v===`system`?Zg({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 $g(e){let t=e.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.replace(/[_-]/g,` `).toUpperCase()}var e_={copyOnSelect:!1};function t_(e){let t=e[`appearance.terminalCopyOnSelect`];return typeof t==`boolean`?t:e_.copyOnSelect}var n_=Gr(`ui.terminalPreferences`,e_),r_=globalThis,i_=new Set;r_.MonacoEnvironment??={getWorker(e,t){return t===`json`?new s:t===`css`||t===`scss`||t===`less`?new r:t===`html`||t===`handlebars`||t===`razor`?new c:t===`typescript`||t===`javascript`?new o:new i}};var a_=({workspaceId:e,filePath:t,content:n,visible:r=!0,onContentChange:i,onSave:o})=>{let s=H(ba),c=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(r),p=(0,V.useRef)(i),m=(0,V.useRef)(o);(0,V.useEffect)(()=>{p.current=i},[i]),(0,V.useEffect)(()=>{m.current=o},[o]);let h=o_(t),g=ma(s),_=`coder-studio-${g.id}`;return(0,V.useEffect)(()=>{i_.has(_)||(u.defineTheme(_,g.monaco),i_.add(_))},[_,g]),(0,V.useEffect)(()=>{if(!c.current||d.current)return;let e=u.create(c.current,{value:n,language:h,theme:_,fontSize:13,fontFamily:`JetBrains Mono, monospace`,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:12,bottom:12},automaticLayout:!0});d.current=e;let t=e.onDidChangeModelContent(()=>{p.current?.(e.getValue())});return e.addCommand(l.CtrlCmd|a.KeyS,()=>{m.current?.()}),()=>{t.dispose(),e.dispose(),d.current=null}},[]),(0,V.useEffect)(()=>{let e=d.current;if(!e)return;let t=e.getModel();t&&u.setModelLanguage(t,h)},[h]),(0,V.useEffect)(()=>{u.setTheme(_)},[_]),(0,V.useEffect)(()=>{let e=d.current;!e||e.getValue()===n||e.setValue(n)},[n]),(0,V.useEffect)(()=>{let e=d.current,t=f.current;f.current=r,!(!e||!r||t)&&e.layout()},[r]),(0,Y.jsx)(`div`,{ref:c,className:`monaco-host`})};function o_(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 s_={minHeight:`200px`,padding:0,gap:0},c_={margin:0,color:`var(--text-tertiary)`,fontSize:`var(--text-base)`,fontWeight:`var(--font-normal)`};function l_({configType:e,visible:t=!0,fillHeight:n=!1}){let r=X(),i=H(Wf),a=U(zg),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(!0),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(()=>{let t=localStorage.getItem(`config-expanded-${e}`);return t===null?!0:t===`true`}),S=(0,V.useMemo)(()=>g?`saving`:v?`error`:o===c?`saved`:`dirty`,[g,v,o,c]),C=S===`dirty`;(0,V.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,V.useEffect)(()=>{localStorage.setItem(`config-expanded-${e}`,String(b))},[b,e]);let w=(0,V.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,V.useCallback)(()=>{s(c),y(null)},[c]),E=(0,V.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,V.useCallback)(e=>{s(e),y(null)},[]),O=(0,V.useCallback)(()=>{x(e=>!e)},[]);return m?(0,Y.jsx)(`div`,{className:`config-card`,children:(0,Y.jsx)(Pm,{className:`config-card-loading`,style:s_,title:(0,Y.jsx)(`p`,{style:c_,children:r(`common.loading`)})})}):v&&!u?(0,Y.jsx)(`div`,{className:`config-card`,children:(0,Y.jsx)(`div`,{className:`config-card-error`,children:(0,Y.jsx)(`span`,{className:`config-card-error-message`,children:v})})}):(0,Y.jsxs)(`div`,{className:`config-card ${n?`config-card--fill-height`:``}`,children:[(0,Y.jsxs)(`div`,{className:`config-card-header`,onClick:O,children:[(0,Y.jsxs)(`div`,{className:`config-card-title`,children:[(0,Y.jsx)(Q,{semantic:`state.configFile`,size:16}),(0,Y.jsx)($,{content:u,children:(0,Y.jsx)(`span`,{className:`config-card-path`,children:u})})]}),(0,Y.jsx)(`div`,{className:`config-card-header-right`,children:b?(0,Y.jsx)(ui,{size:16}):(0,Y.jsx)(si,{size:16})})]}),b&&(0,Y.jsxs)(`div`,{className:`config-card-body ${n?`config-card-body--fill-height`:``}`,children:[!f&&(0,Y.jsx)(Pm,{className:`config-empty-state`,description:(0,Y.jsx)(`div`,{className:`config-empty-desc`,children:r(`settings.config_files.file_not_found_hint`)}),icon:(0,Y.jsx)(Q,{className:`config-empty-icon`,semantic:`state.emptyConfig`,size:16}),title:(0,Y.jsx)(`div`,{className:`config-empty-title`,children:r(`settings.config_files.file_not_found`)})}),(0,Y.jsx)(a_,{workspaceId:`config-editor-${e}`,filePath:u,content:o,onContentChange:D,visible:t}),(0,Y.jsxs)(`div`,{className:`config-card-actions`,children:[(0,Y.jsx)(`div`,{className:`config-actions-left`,children:(0,Y.jsx)(()=>{if(!f&&!g&&!v&&!C)return(0,Y.jsxs)(`div`,{className:`config-status config-status--warning`,children:[(0,Y.jsx)(Q,{"aria-hidden":`true`,className:`config-status__icon`,semantic:`state.warning`,size:14}),(0,Y.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,Y.jsxs)(`div`,{className:`config-status config-status--${e.color}`,children:[S===`saving`?(0,Y.jsx)(_h,{label:e.text,size:`sm`}):(0,Y.jsx)(Q,{"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,Y.jsx)(`span`,{children:e.text})]})},{})}),(0,Y.jsxs)(`div`,{className:`config-actions-right`,children:[e===`claude`&&(0,Y.jsx)($,{content:r(`settings.config_files.format_hint`),children:(0,Y.jsxs)(Lp,{size:`sm`,onClick:E,children:[(0,Y.jsx)(Ki,{size:14}),(0,Y.jsx)(`span`,{children:r(`settings.config_files.format`)})]})}),(0,Y.jsx)(Lp,{size:`sm`,onClick:T,disabled:!C||g,children:r(`action.reset`)}),(0,Y.jsx)(Lp,{variant:`primary`,size:`sm`,onClick:w,disabled:!C||g,children:r(g?`settings.config_files.saving`:`action.save`)})]})]})]})]})}function u_(e){return e.split(`
105
105
  `).map(e=>e.trim()).filter(e=>e.length>0)}function d_(e,t){return Object.fromEntries(e.map(e=>[e.id,t()]))}function f_({providers:e,additionalArgsById:t,setAdditionalArgsById:n,isMobile:r,onLayoutModeChange:i}){let a=X(),o=H(Wf),s=H(Lf),c=a(`settings.provider.command_preview_title`),l=a(`settings.provider.command_preview_hint`),[u,d]=(0,V.useState)(e[0]?.id??`claude`),[f,p]=(0,V.useState)(`base`),[m,h]=(0,V.useState)(`base`),[g,_]=(0,V.useState)(()=>d_(e,()=>``)),[v,y]=(0,V.useState)(()=>d_(e,()=>!1)),b=(0,V.useRef)(d_(e,()=>0));(0,V.useEffect)(()=>{e.some(e=>e.id===u)||d(e[0]?.id??`claude`)},[e,u]),(0,V.useEffect)(()=>{_(t=>{let n=d_(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}),y(t=>{let n=d_(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=d_(e,()=>0);for(let n of e)n.id in b.current&&(t[n.id]=b.current[n.id]);b.current=t},[e]);let x=e.find(e=>e.id===u),S=x?t[x.id]??``:``,C=(0,V.useMemo)(()=>u_(S),[S]),w=r?m===`base`:f===`base`,T=r?m===`config`:f===`config`,E=x?g[x.id]??``:``,D=T;(0,V.useEffect)(()=>{i?.(D?`fill-height`:`default`)},[i,D]),(0,V.useEffect)(()=>{if(s!==`connected`||!x)return;let e=(b.current[x.id]??0)+1;b.current[x.id]=e;let t=!1;return(async()=>{let n=await o(`settings.previewCommand`,{providerId:x.id,config:{additionalArgs:C}});t||b.current[x.id]===e&&_(e=>({...e,[x.id]:n.ok&&n.data?n.data.preview:`Error loading preview`}))})(),()=>{t=!0}},[C,S,s,o,x]),(0,V.useEffect)(()=>{!x||!T||y(e=>e[x.id]?e:{...e,[x.id]:!0})},[x,T]);let O=e=>{d(e),r&&h(`base`)},k=async(e,t)=>{await o(`settings.update`,{settings:{providers:{[e]:{additionalArgs:u_(t)}}}})};return(0,Y.jsxs)(`div`,{className:`settings-section ${D?`settings-section--fill-height settings-provider-section--config-active`:``}`,children:[(0,Y.jsx)(nh,{"aria-label":a(`settings.providers`),className:`settings-provider-tabs`,onChange:e=>O(e),optionClassName:`settings-provider-tab`,options:e.map(e=>({label:e.displayName,value:e.id})),value:u}),r?null:(0,Y.jsx)(nh,{className:`settings-provider-subnav`,"aria-label":a(`settings.provider.config`),onChange:e=>p(e),optionClassName:`settings-provider-subnav-button`,options:[{label:a(`settings.provider.base`),value:`base`},{label:a(`settings.provider.config_file`),value:`config`}],value:f}),x&&w?(0,Y.jsxs)(`div`,{className:`settings-provider-content ${D?`settings-provider-content--fill-height`:``}`,children:[(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:a(`settings.provider.config`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:a(`settings.provider.startup_args_hint`)}),(0,Y.jsxs)(`div`,{className:`settings-config-field`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`provider-startup-args`,children:a(`settings.provider.startup_args`)}),(0,Y.jsx)(Fh,{id:`provider-startup-args`,className:`settings-provider-args-input`,rows:4,placeholder:a(`settings.provider.startup_args_placeholder`),value:S,onChange:e=>{let t=e.target.value;n(e=>({...e,[x.id]:t})),k(x.id,t)}})]})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:c}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:l}),(0,Y.jsx)(`div`,{className:`settings-config-field`,children:(0,Y.jsx)(`code`,{className:`settings-command-preview`,children:E})})]}),r?(0,Y.jsxs)(`button`,{type:`button`,className:`settings-provider-mobile-entry`,"aria-label":a(`settings.provider.open_config_file_editor`),onClick:()=>h(`config`),children:[(0,Y.jsx)(`span`,{className:`settings-provider-mobile-entry__title`,children:a(`settings.provider.open_config_file_editor`)}),(0,Y.jsx)(`span`,{className:`settings-provider-mobile-entry__meta`,children:x.id===`codex`?a(`settings.config_files.codex_config`):a(`settings.config_files.claude_config`)})]}):null]}):null,(0,Y.jsx)(`div`,{className:`settings-provider-config-stack ${D?`settings-provider-config-stack--fill-height`:``}`,children:e.filter(e=>v[e.id]||x?.id===e.id&&T).map(e=>{let t=x?.id===e.id&&T;return(0,Y.jsx)(`div`,{className:`settings-provider-config-panel ${D?`settings-provider-config-panel--fill-height`:``} ${t?``:`settings-provider-config-panel-hidden`}`,"aria-hidden":!t,children:(0,Y.jsx)(`div`,{className:`settings-provider-content ${D?`settings-provider-content--fill-height`:``}`,children:(0,Y.jsxs)(`div`,{className:`settings-group ${D?`settings-group--fill-height`:``}`,children:[r?(0,Y.jsx)(`div`,{className:`settings-provider-mobile-config-header`,children:(0,Y.jsx)(`button`,{type:`button`,className:`settings-link`,onClick:()=>h(`base`),children:a(`settings.provider.back_to_base`)})}):null,(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:a(`settings.config_files.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:e.id===`codex`?a(`settings.config_files.codex_config`):a(`settings.config_files.claude_config`)}),(0,Y.jsx)(l_,{configType:e.id,visible:t,fillHeight:D})]})})},e.id)})})]})}function p_({historyIndex:e,historyLength:t,hasActiveWorkspace:n}){return(typeof e==`number`?e>0:t>1)?`history`:n?`/workspace`:`/`}function m_(e){let{history:t,hasActiveWorkspace:n}=e,r=t.state;return p_({historyIndex:r?.idx??null,historyLength:t.length,hasActiveWorkspace:n})}function h_(e){return m_({history:typeof window<`u`?window.history:{state:null,length:1},hasActiveWorkspace:e})}var g_=[{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`}],__=g_,v_=[{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:`Mod+Shift+[`,category:`global`},{id:`workspace.next`,name:`下一个工作区`,description:`切换到下一个工作区标签`,defaultBinding:`Mod+Shift+]`,category:`global`},{id:`focus-mode.toggle`,name:`专注模式`,description:`切换专注模式(隐藏非必要面板)`,defaultBinding:`F`,category:`global`},{id:`agent.split-vertical`,name:`垂直分屏`,description:`垂直分割 Agent 面板`,defaultBinding:`Mod+D`,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`}],y_=Gr(`ui.customShortcuts`,{});function b_(e){return e.replace(`Mod`,navigator.platform.includes(`Mac`)?`⌘`:`Ctrl`).replace(`Shift`,`⇧`).replace(`Alt`,navigator.platform.includes(`Mac`)?`⌥`:`Alt`)}function x_(e,t){return t[e]||v_.find(t=>t.id===e)?.defaultBinding||``}var S_={global:`全局`,workspace:`工作区`,editor:`编辑器`,terminal:`终端`};function C_(){let e=X(),t=H(Wf),n=e(`settings.shortcuts.reset_hint`),[r,i]=xe(y_),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(`global`),l=(0,V.useRef)(null);(0,V.useEffect)(()=>{a&&l.current&&l.current.focus()},[a]);let u=(0,V.useCallback)((e,n)=>{e.preventDefault(),e.stopPropagation();let r=[];if((navigator.platform.includes(`Mac`)?e.metaKey:e.ctrlKey)&&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 a=r.join(`+`);i(e=>({...e,[n]:a})),t(`settings.update`,{settings:{shortcuts:{[n]:a}}}),o(null)},[i,t]),d=(0,V.useCallback)(e=>{i(t=>{let n={...t};return delete n[e],n}),t(`settings.update`,{settings:{shortcuts:{[e]:null}}})},[i,t]),f=(0,V.useCallback)(()=>{i({}),t(`settings.update`,{settings:{shortcuts:{}}})},[i,t]),p=v_.filter(e=>e.category===s);return(0,Y.jsxs)(`div`,{className:`settings-section`,children:[(0,Y.jsx)(nh,{"aria-label":e(`settings.shortcuts.title`),className:`shortcuts-category-tabs`,onChange:e=>c(e),optionClassName:`shortcuts-category-tab`,options:Object.keys(S_).map(e=>({label:S_[e],value:e})),size:`sm`,value:s}),(0,Y.jsx)(`div`,{className:`shortcuts-list`,children:p.map(e=>{let t=x_(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,Y.jsxs)(`div`,{className:`shortcuts-item ${i?`shortcuts-item-custom`:``}`,children:[(0,Y.jsxs)(`div`,{className:`shortcuts-info`,children:[(0,Y.jsx)(`span`,{id:c,className:`shortcuts-name`,children:e.name}),(0,Y.jsx)(`span`,{id:f,className:`shortcuts-desc`,children:e.description})]}),(0,Y.jsx)(`div`,{className:`shortcuts-binding`,children:s?(0,Y.jsx)(vm,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Lm,{className:`shortcuts-key`,interactive:!0,onClick:()=>o(e.id),children:b_(t)}),i&&(0,Y.jsx)($,{content:n,children:(0,Y.jsx)(Z,{"aria-label":n,icon:`↺`,onClick:()=>d(e.id),size:`sm`})})]})})]},e.id)})}),(0,Y.jsx)(`div`,{className:`shortcuts-footer`,children:(0,Y.jsx)(Lp,{onClick:f,variant:`secondary`,children:e(`settings.shortcuts.reset_all`)})})]})}var w_=g_[0].id;function T_(){if(typeof window>`u`)return!1;let e=window.navigator;return window.matchMedia?.(`(display-mode: standalone)`).matches===!0||e.standalone===!0}function E_(){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 D_(){return typeof window>`u`||!(`Notification`in window)?`unsupported`:E_()?T_()?`available`:`limited`:`available`}function O_(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`
106
- `):``}function k_(e,t){return Object.fromEntries(t.map(t=>[t.id,O_(e[`providers.${t.id}.additionalArgs`])]))}function A_(){let e=X(),t=e(`settings.load_failed_unknown`),n=qt(),r=Pr()===`mobile`,i=H(Wf),a=H(Lf),o=H(Hf),s=H(tp),[c,l]=(0,V.useState)(()=>r?{kind:`root`,lastSection:w_}:{kind:`detail`,section:w_}),[u]=(0,V.useState)([{id:`claude`,displayName:`Claude`},{id:`codex`,displayName:`Codex`}]),[d,f]=(0,V.useState)(!0),[p,m]=(0,V.useState)(!0),[h,g]=(0,V.useState)(600),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(0),[x,S]=(0,V.useState)(10),[C,w]=(0,V.useState)(!0),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)(`standard`),[k,A]=(0,V.useState)({}),[j,M]=(0,V.useState)(`default`),[N,P]=(0,V.useState)(null),[F,ee]=(0,V.useState)(0),[I,te]=xe(xa),[L,R]=xe(ba),z=H(n_),ne=U(Lg),re=U(n_),ie=(0,V.useRef)(t),B=(0,V.useRef)({theme:0,locale:0,terminalRenderer:0,terminalCopyOnSelect:0}),ae=c.kind===`detail`?c.section:c.lastSection,oe=r?__:g_,se=oe.find(e=>e.id===ae)??oe[0];(0,V.useEffect)(()=>{ie.current=t},[t]),(0,V.useEffect)(()=>{l(e=>r?e.kind===`root`?e:{kind:`root`,lastSection:e.section}:e.kind===`detail`?e:{kind:`detail`,section:e.lastSection})},[r]),(0,V.useEffect)(()=>{if(a!==`connected`)return;let e=!1;return(async()=>{let t={...B.current},n=await i(`settings.get`,{});if(!n.ok||!n.data){e||P(n.error?.message??ie.current);return}let r=n.data;if(!e){if(P(null),typeof r[`notifications.enabled`]==`boolean`&&f(r[`notifications.enabled`]),typeof r[`notifications.soundEnabled`]==`boolean`&&m(r[`notifications.soundEnabled`]),g(ka(r[`supervisor.evaluationTimeoutSec`])),v(Aa(r[`supervisor.retryEnabled`])),b(ja(r[`supervisor.retryMaxCount`])),S(Ma(r[`supervisor.retryDelaySec`])),w(Na(r[`supervisor.retryOnTimeout`])),E(Pa(r[`supervisor.retryOnEvaluatorError`])),ne({enabled:typeof r[`notifications.enabled`]==`boolean`?r[`notifications.enabled`]:!0,soundEnabled:typeof r[`notifications.soundEnabled`]==`boolean`?r[`notifications.soundEnabled`]:!0}),(r[`appearance.terminalRenderer`]===`standard`||r[`appearance.terminalRenderer`]===`compatibility`)&&B.current.terminalRenderer===t.terminalRenderer&&O(r[`appearance.terminalRenderer`]),B.current.terminalCopyOnSelect===t.terminalCopyOnSelect&&re({copyOnSelect:t_(r)}),(r[`appearance.locale`]===`zh`||r[`appearance.locale`]===`en`)&&B.current.locale===t.locale&&te(r[`appearance.locale`]),(Object.hasOwn(r,`appearance.themeId`)||Object.hasOwn(r,`appearance.theme`))&&B.current.theme===t.theme){let e=ha(r[`appearance.themeId`]??r[`appearance.theme`]);R(e),document.documentElement.setAttribute(`data-theme`,ma(e).documentThemeAttr)}A(k_(r,u))}})(),()=>{e=!0}},[a,i,te,ne,re,R,F]);let ce=e=>{B.current.locale+=1,te(e)},le=e=>{B.current.theme+=1,R(e)},ue=e=>{B.current.terminalRenderer+=1,O(e)},de=e=>{B.current.terminalCopyOnSelect+=1,re({copyOnSelect:e})};(0,V.useEffect)(()=>{ae!==`providers`&&M(`default`)},[ae]);let fe=()=>{let e=h_(!!s);if(e===`history`){n(-1);return}n(e)},pe=()=>{if(r&&c.kind===`detail`){l({kind:`root`,lastSection:c.section});return}fe()},me=()=>{switch(ae){case`general`:return(0,Y.jsx)(F_,{isMobile:r,notificationsEnabled:d,setNotificationsEnabled:f,soundEnabled:p,setSoundEnabled:m,supervisorEvaluationTimeoutSec:h,setSupervisorEvaluationTimeoutSec:g,supervisorRetryEnabled:_,setSupervisorRetryEnabled:v,supervisorRetryMaxCount:y,setSupervisorRetryMaxCount:b,supervisorRetryDelaySec:x,setSupervisorRetryDelaySec:S,supervisorRetryOnTimeout:C,setSupervisorRetryOnTimeout:w,supervisorRetryOnEvaluatorError:T,setSupervisorRetryOnEvaluatorError:E,terminalRenderer:D,setTerminalRenderer:ue,terminalCopyOnSelect:z.copyOnSelect,setTerminalCopyOnSelect:de});case`appearance`:return(0,Y.jsx)(I_,{locale:I,setLocale:ce,theme:L,setTheme:le});case`providers`:return(0,Y.jsx)(f_,{providers:u,additionalArgsById:k,setAdditionalArgsById:A,isMobile:r,onLayoutModeChange:M});case`shortcuts`:return(0,Y.jsx)(C_,{});default:return null}},he=()=>(0,Y.jsx)(`main`,{className:`settings-content settings-content--mobile-root`,children:(0,Y.jsx)(`div`,{className:`settings-mobile-list`,children:oe.map(({id:t,labelKey:n,iconSemantic:r})=>(0,Y.jsxs)(`button`,{type:`button`,className:`settings-mobile-item`,onClick:()=>l({kind:`detail`,section:t}),children:[(0,Y.jsx)(`span`,{className:`settings-mobile-item__icon`,children:(0,Y.jsx)(Q,{semantic:r,size:18})}),(0,Y.jsx)(`span`,{className:`settings-mobile-item__label`,children:e(n)}),(0,Y.jsx)(li,{size:16,className:`settings-mobile-item__arrow`})]},t))})}),ge=r&&c.kind===`root`,_e=r&&c.kind===`detail`,ve=e(r?ge?`settings.title`:se.labelKey:`settings.title`);return(0,Y.jsxs)(`div`,{className:`settings-page ${r?`settings-page--mobile`:``}`,children:[(0,Y.jsx)(`header`,{className:`settings-header`,children:(0,Y.jsx)(yp,{title:ve,titleAs:`div`,onBack:pe,backLabel:e(`action.back`)})}),ge?he():(0,Y.jsxs)(`div`,{className:`settings-body ${r?`settings-body--mobile`:``} ${_e?`settings-body--mobile-detail`:``} ${j===`fill-height`?`settings-body--fill-height`:``}`,children:[r?null:(0,Y.jsx)(`aside`,{className:`settings-sidebar`,children:(0,Y.jsx)(`nav`,{className:`settings-nav`,children:oe.map(({id:t,labelKey:n,iconSemantic:r})=>(0,Y.jsx)(j_,{icon:(0,Y.jsx)(Q,{semantic:r,size:16}),label:e(n),active:ae===t,onClick:()=>l({kind:`detail`,section:t})},t))})}),(0,Y.jsxs)(`main`,{className:`settings-content ${r?`settings-content--mobile`:``} ${_e?`settings-content--mobile-detail`:``} ${j===`fill-height`?`settings-content--fill-height`:``}`,children:[N&&(0,Y.jsx)(Vm,{role:`alert`,tone:`error`,title:e(`settings.load_failed`),message:N,action:(0,Y.jsx)(`button`,{type:`button`,className:`settings-link`,onClick:()=>ee(e=>e+1),children:e(`action.refresh`)})}),me()]})]}),(0,Y.jsxs)(`footer`,{className:`settings-footer ${r?`settings-footer--mobile`:``}`,children:[(0,Y.jsx)(`span`,{className:`settings-autosave`,children:e(`settings.autosave_hint`)}),(0,Y.jsxs)(`span`,{className:`settings-version`,children:[`v`,o?.version??`0.0.0`]})]})]})}function j_({icon:e,label:t,active:n,onClick:r}){return(0,Y.jsxs)(`button`,{className:`settings-nav-item ${n?`settings-nav-item-active`:``}`,onClick:r,children:[(0,Y.jsx)(`span`,{className:`settings-nav-icon`,children:e}),(0,Y.jsx)(`span`,{className:`settings-nav-label`,children:t}),n&&(0,Y.jsx)(li,{size:14,className:`settings-nav-arrow`})]})}function M_(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 N_(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 P_(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 F_({isMobile:e,notificationsEnabled:t,setNotificationsEnabled:n,soundEnabled:r,setSoundEnabled:i,supervisorEvaluationTimeoutSec:a,setSupervisorEvaluationTimeoutSec:o,supervisorRetryEnabled:s,setSupervisorRetryEnabled:c,supervisorRetryMaxCount:l,setSupervisorRetryMaxCount:u,supervisorRetryDelaySec:d,setSupervisorRetryDelaySec:f,supervisorRetryOnTimeout:p,setSupervisorRetryOnTimeout:m,supervisorRetryOnEvaluatorError:h,setSupervisorRetryOnEvaluatorError:g,terminalRenderer:_,setTerminalRenderer:v,terminalCopyOnSelect:y,setTerminalCopyOnSelect:b}){let x=X(),S=(0,V.useId)(),C=(0,V.useId)(),w=(0,V.useId)(),T=(0,V.useId)(),E=(0,V.useId)(),D=(0,V.useId)(),O=(0,V.useId)(),k=(0,V.useId)(),A=H(Wf),j=U(Lg),[M,N]=(0,V.useState)(`unavailable`),[P,F]=(0,V.useState)(`unsupported`),[ee,I]=(0,V.useState)(String(a)),[te,L]=(0,V.useState)(null),[R,z]=(0,V.useState)(String(l)),[ne,re]=(0,V.useState)(String(d)),[ie,B]=(0,V.useState)(null),[ae,oe]=(0,V.useState)(null),se=async e=>await A(`settings.update`,{settings:e}),ce=e=>{j(e)};(0,V.useEffect)(()=>{if(F(D_()),`Notification`in window){N(Notification.permission);return}N(`unavailable`)},[]),(0,V.useEffect)(()=>{I(String(a))},[a]),(0,V.useEffect)(()=>{z(String(l))},[l]),(0,V.useEffect)(()=>{re(String(d))},[d]),(0,V.useEffect)(()=>{L(null)},[a]),(0,V.useEffect)(()=>{B(null)},[l]),(0,V.useEffect)(()=>{oe(null)},[d]);let le=async()=>{`Notification`in window&&N(await Notification.requestPermission())},ue=async()=>{let e=M_(ee);if(e===null){I(String(a)),L(x(`settings.supervisor.validation_error`,{max:Da}));return}if(e===a){I(String(e)),L(null);return}let t=await se({supervisor:{evaluationTimeoutSec:e}});if(!t.ok){I(String(a)),L(t.error?.message||x(`settings.config_files.save_failed`));return}o(e),I(String(e)),L(null)},de=async()=>{let e=N_(R);if(e===null){z(String(l)),B(x(`settings.supervisor.retry_max_count_validation_error`,{max:20}));return}if(e===l){z(String(e)),B(null);return}let t=await se({supervisor:{retryMaxCount:e}});if(!t.ok){z(String(l)),B(t.error?.message||x(`settings.config_files.save_failed`));return}u(e),z(String(e)),B(null)},fe=async()=>{let e=P_(ne);if(e===null){re(String(d)),oe(x(`settings.supervisor.retry_delay_validation_error`,{max:Oa}));return}if(e===d){re(String(e)),oe(null);return}let t=await se({supervisor:{retryDelaySec:e}});if(!t.ok){re(String(d)),oe(t.error?.message||x(`settings.config_files.save_failed`));return}f(e),re(String(e)),oe(null)};return(0,Y.jsxs)(`div`,{className:`settings-section`,children:[(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:x(`settings.notifications`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:x(`settings.notifications_channel_hint`)}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:S,children:x(`settings.notifications_enabled`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:C,children:x(`settings.notifications_enabled_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":C,"aria-labelledby":S,checked:t,className:`settings-toggle`,onCheckedChange:e=>{n(e),ce({enabled:e,soundEnabled:r}),se({notifications:{enabled:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:w,children:x(`settings.notification_sound`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:T,children:x(`settings.notification_sound_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":T,"aria-labelledby":w,checked:r,className:`settings-toggle`,disabled:!t,onCheckedChange:e=>{i(e),ce({enabled:t,soundEnabled:e}),se({notifications:{soundEnabled:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-info-row`,children:[(0,Y.jsx)(`span`,{className:`settings-info-label`,children:x(`settings.notification_status`)}),(0,Y.jsxs)(`span`,{className:`settings-info-value settings-capability-${P}`,children:[P===`available`&&x(`settings.notification_status_available`),P===`limited`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.notification_status_limited`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.notification_status_limited_hint`)})]}),P===`unsupported`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.notification_status_unsupported`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.notification_status_unsupported_hint`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`settings-info-row`,children:[(0,Y.jsx)(`span`,{className:`settings-info-label`,children:x(`settings.notification_permission`)}),(0,Y.jsxs)(`span`,{className:`settings-info-value settings-permission-${M}`,children:[M===`granted`&&x(`settings.permission_granted`),M===`denied`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.permission_denied`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.permission_denied_hint`)})]}),M===`default`&&P===`available`&&(0,Y.jsx)(`button`,{className:`settings-link`,onClick:le,children:x(`settings.permission_request`)}),M===`default`&&P===`limited`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.permission_unavailable`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.permission_limited_hint`)})]}),M===`unavailable`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.permission_unavailable`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.permission_unavailable_hint`)})]})]})]})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,id:E,children:x(`settings.terminal_renderer`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,id:D,children:x(`settings.terminal_renderer_hint`)}),(0,Y.jsxs)(`div`,{"aria-describedby":D,"aria-labelledby":E,className:`settings-pills`,role:`group`,children:[(0,Y.jsx)(Um,{leadingIcon:_===`standard`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{v(`standard`),se({appearance:{terminalRenderer:`standard`}})},active:_===`standard`,children:x(`settings.terminal_standard`)}),(0,Y.jsx)(Um,{leadingIcon:_===`compatibility`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{v(`compatibility`),se({appearance:{terminalRenderer:`compatibility`}})},active:_===`compatibility`,children:x(`settings.terminal_compatibility`)})]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:O,children:x(`settings.copy_on_select`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:k,children:x(`settings.copy_on_select_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":k,"aria-labelledby":O,checked:y,className:`settings-toggle`,onCheckedChange:e=>{b(e),se({appearance:{terminalCopyOnSelect:e}})}})]})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:x(`settings.supervisor.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:x(`settings.supervisor.hint`)}),(0,Y.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-evaluation-timeout`,children:x(`settings.supervisor.evaluation_timeout`)}),(0,Y.jsx)(`div`,{className:`settings-config-control`,children:(0,Y.jsx)(vm,{id:`supervisor-evaluation-timeout`,className:`settings-input-compact`,type:`number`,min:1,max:Da,step:1,inputMode:`numeric`,invalid:!!te,value:ee,onChange:e=>{I(e.target.value),te&&L(null)},onBlur:()=>{ue()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())}})}),te?(0,Y.jsx)(`span`,{className:`form-error`,role:`alert`,children:te}):null]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-enabled-label`,children:x(`settings.supervisor.retry_enabled`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-enabled-desc`,children:x(`settings.supervisor.retry_enabled_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":`supervisor-retry-enabled-desc`,"aria-labelledby":`supervisor-retry-enabled-label`,checked:s,className:`settings-toggle`,onCheckedChange:e=>{c(e),se({supervisor:{retryEnabled:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-max-count`,children:x(`settings.supervisor.retry_max_count`)}),(0,Y.jsx)(`div`,{className:`settings-config-control`,children:(0,Y.jsx)(vm,{id:`supervisor-retry-max-count`,className:`settings-input-compact`,type:`number`,min:0,max:20,step:1,inputMode:`numeric`,invalid:!!ie,value:R,onChange:e=>{z(e.target.value),ie&&B(null)},onBlur:()=>{de()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),de())}})}),ie?(0,Y.jsx)(`span`,{className:`form-error`,role:`alert`,children:ie}):null]}),(0,Y.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-delay-sec`,children:x(`settings.supervisor.retry_delay_sec`)}),(0,Y.jsx)(`div`,{className:`settings-config-control`,children:(0,Y.jsx)(vm,{id:`supervisor-retry-delay-sec`,className:`settings-input-compact`,type:`number`,min:1,max:Oa,step:1,inputMode:`numeric`,invalid:!!ae,value:ne,onChange:e=>{re(e.target.value),ae&&oe(null)},onBlur:()=>{fe()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),fe())}})}),ae?(0,Y.jsx)(`span`,{className:`form-error`,role:`alert`,children:ae}):null]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-timeout-label`,children:x(`settings.supervisor.retry_on_timeout`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-timeout-desc`,children:x(`settings.supervisor.retry_on_timeout_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":`supervisor-retry-on-timeout-desc`,"aria-labelledby":`supervisor-retry-on-timeout-label`,checked:p,className:`settings-toggle`,onCheckedChange:e=>{m(e),se({supervisor:{retryOnTimeout:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-evaluator-error-label`,children:x(`settings.supervisor.retry_on_evaluator_error`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-evaluator-error-desc`,children:x(`settings.supervisor.retry_on_evaluator_error_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":`supervisor-retry-on-evaluator-error-desc`,"aria-labelledby":`supervisor-retry-on-evaluator-error-label`,checked:h,className:`settings-toggle`,onCheckedChange:e=>{g(e),se({supervisor:{retryOnEvaluatorError:e}})}})]})]})]})}function I_({locale:e,setLocale:t,theme:n,setTheme:r}){let i=X(),a=(0,V.useId)(),o=(0,V.useId)(),s=(0,V.useId)(),c=(0,V.useId)(),l=(0,V.useId)(),u=H(Wf),d=ha(n),f=la.map(e=>({value:e.id,label:i(e.labelKey)})),p=async e=>{await u(`settings.update`,{settings:e})};return(0,Y.jsxs)(`div`,{className:`settings-section`,children:[(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,id:a,children:i(`settings.theme.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,id:o,children:i(`settings.theme.hint`)}),(0,Y.jsx)(mh,{desktopMode:`listbox`,id:s,"aria-describedby":o,"aria-label":i(`settings.theme.title`),className:`settings-input-compact`,mobileSheetTitle:i(`settings.theme.title`),options:f,value:d,onValueChange:e=>{let t=ma(e);t.id!==d&&(r(t.id),document.documentElement.setAttribute(`data-theme`,t.documentThemeAttr),p({appearance:{themeId:t.id}}))}})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,id:c,children:i(`settings.language.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,id:l,children:i(`settings.language.hint`)}),(0,Y.jsxs)(`div`,{"aria-describedby":l,"aria-labelledby":c,className:`settings-pills`,role:`group`,children:[(0,Y.jsx)(Um,{leadingIcon:e===`zh`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{t(`zh`),p({appearance:{locale:`zh`}})},active:e===`zh`,children:i(`settings.language.zh`)}),(0,Y.jsx)(Um,{leadingIcon:e===`en`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{t(`en`),p({appearance:{locale:`en`}})},active:e===`en`,children:i(`settings.language.en`)})]})]})]})}var L_={minHeight:`auto`,padding:0,gap:`var(--sp-5)`},R_=()=>{let e=X(),t=qt(),[n,r]=(0,V.useState)(!1),i=Pr()===`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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`welcome-container ${i?`welcome-container--mobile`:``}`,children:(0,Y.jsxs)(`div`,{className:`welcome-card ${i?`welcome-card--mobile`:``}`,children:[(0,Y.jsx)(Pm,{style:L_,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker`,children:e(`welcome.kicker`)}),(0,Y.jsx)(`h1`,{className:`welcome-title`,children:e(`welcome.title`)})]}),description:(0,Y.jsx)(`p`,{className:`welcome-body`,children:e(`welcome.description`)}),action:(0,Y.jsxs)(`button`,{className:`welcome-btn`,onClick:()=>{r(!0)},children:[(0,Y.jsx)(Q,{semantic:`nav.newWorkspace`,size:18}),(0,Y.jsx)(`span`,{children:e(`action.open_workspace`)})]})}),(0,Y.jsxs)(`button`,{className:`welcome-link`,onClick:()=>{t(`/settings`)},children:[(0,Y.jsx)(Q,{semantic:`nav.settings`,size:14}),(0,Y.jsx)(`span`,{children:e(`action.settings`)})]}),(0,Y.jsx)(`div`,{className:`welcome-divider`}),(0,Y.jsx)(`div`,{className:`welcome-features`,children:a.map((e,t)=>(0,Y.jsxs)(`div`,{className:`welcome-feature`,children:[(0,Y.jsx)(Q,{className:`welcome-feature-icon`,semantic:e.iconSemantic,size:18}),(0,Y.jsxs)(`div`,{className:`welcome-feature-text`,children:[(0,Y.jsx)(`div`,{className:`welcome-feature-title`,children:e.title}),(0,Y.jsx)(`div`,{className:`welcome-feature-desc`,children:e.description})]})]},t))})]})}),n?(0,Y.jsx)(Ag,{onClose:()=>r(!1)}):null]})};function z_(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 B_(e){let t=H(Wf),n=U(Jf),r=me();return{persistUiState:(0,V.useCallback)(async i=>{if(!e||e.startsWith(`__workspace_`))return!1;let a=r.get(Jf)[e];if(!a)return!1;let o={...a.uiState,leftPanelWidth:r.get(bg),bottomPanelHeight:r.get(xg),focusMode:r.get(yg),...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?(z_(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])}}var V_=`ui.paneLayout.`,H_=`ui.paneRatio.`,U_={id:`root`,type:`leaf`},W_=Kf(e=>B(U_));function G_(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function K_(e){let t=G_();if(!t)return null;try{let n=t.getItem(`${V_}${e}`);return n?JSON.parse(n):null}catch{return null}}function q_(e){let t=G_();if(t)try{t.removeItem(`${V_}${e}`)}catch{}}function J_(e,t){let n=G_();if(!n)return null;try{let r=n.getItem(`${H_}${e}.${t}`);if(r===null)return null;let i=Number(r);return Number.isFinite(i)?i:null}catch{return null}}function Y_(e,t,n){let r=G_();if(r)try{r.setItem(`${H_}${e}.${t}`,String(n))}catch{}}function X_(e){return{id:e,type:`leaf`}}function Z_(e,t){return{id:e,type:`leaf`,sessionId:t}}function Q_(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},X_(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=Q_(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function $_(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},X_(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=$_(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function ev(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=ev(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function tv(e,t){return t.startsWith(`__draft__`)?rv(e,t.replace(`__draft__`,``)):iv(e,t)}function nv(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=nv(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 rv(e,t){return nv(e,t)??{id:e.id,type:`leaf`}}function iv(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=iv(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function av(e,t){return ov(e,t)??{id:e.id,type:`leaf`}}function ov(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=ov(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){return e.type===`leaf`?e.sessionId?[e.sessionId]:[]:e.children?.flatMap(e=>sv(e))??[]}function cv(e,t,n,r=`horizontal`){let i=dv(e,t);if(i)return i;if(n){let i=fv(e,t,r,n);if(i)return i}return fv(e,t,r)||(e.type===`leaf`&&!e.sessionId?{...e,sessionId:t}:{id:`root`,type:`leaf`,sessionId:t})}function lv(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},pv(n,2)]}}function uv(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=uv(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function dv(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=dv(i,t);if(a)return{...e,children:n.map((e,t)=>t===r?a:e)}}return null}function fv(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},Z_(`${i}-session`,t)]}}let i=e.children??[];for(let a=0;a<i.length;a+=1){let o=i[a],s=fv(o,t,n,r);if(s)return{...e,children:i.map((e,t)=>t===a?s:e)}}return null}function pv(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},pv(r,t+1)]}}function mv(e){let t=U(W_(e)),n=me(),{persistUiState:r}=B_(e),i=(0,V.useCallback)(i=>{let a=n.get(W_(e)),o=typeof i==`function`?i(a):i;return t(o),r({paneLayout:o}),o},[r,t,n,e]),a=(0,V.useCallback)((e,t)=>{i(n=>$_(n,e,t))},[i]),o=(0,V.useCallback)((e,t)=>{i(n=>Q_(n,e,t))},[i]),s=(0,V.useCallback)(e=>{i(t=>tv(t,e))},[i]),c=(0,V.useCallback)(e=>{i(t=>rv(t,e))},[i]),l=(0,V.useCallback)(e=>{i(t=>av(t,e))},[i]),u=(0,V.useCallback)((e,t)=>{i(n=>ev(n,e,t))},[i]),d=(0,V.useCallback)(e=>{i({id:`root`,type:`leaf`,sessionId:e})},[i]);return{appendSession:(0,V.useCallback)((e,t,n=`horizontal`)=>{i(r=>cv(r,e,t,n))},[i]),assignSession:u,closeDraftPane:c,closeSessionPane:s,removeSessionPane:l,replaceWithSession:d,splitDraftPane:o,splitSessionPane:a}}var hv=new TextEncoder,gv=100,_v=5e3;function vv(e){return new Promise(t=>{setTimeout(t,e)})}function yv(){let e=H(Wf),t=H(If),n=me(),r=(0,V.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,V.useCallback)(async t=>{let r=n.get(ap(t));if(!r)return!1;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)}let i=await e(`session.stop`,{sessionId:t});if(!i.ok&&i.error?.code!==`invalid_state`)return console.error(`Failed to stop session before removal:`,i.error?.message),!1;let a=Date.now()+_v;for(;Date.now()<a;){let r=n.get(ap(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 vv(gv)}return console.error(`Timed out waiting for session to end before removal:`,t),!1},[e,n]),submitSessionPrompt:(0,V.useCallback)(async(e,n)=>{let r=n.trim();if(!t||!r)return!1;try{return await t.sendTerminalInput(e,hv.encode(`${r}\r`),`submit`,r),!0}catch(e){return console.error(`Failed to submit session prompt:`,e),!1}},[t]),stopSession:r}}function bv(e,t){let n=H(np),r=e===void 0?n:e,i=r?.id??`__workspace_empty__`,a=t?.disabled??!1,o=H(Wf),s=H(Lf),c=H(ip(i)),l=H(W_(i)),u=U(rp),d=U(W_(i)),f=me(),{persistUiState:p}=B_(i);return(0,V.useEffect)(()=>{if(a||!r||s!==`connected`)return;let e=!1,t=new Set(Object.values(f.get(rp)).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(rp)).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(W_(i)),l=xv(r?.uiState.paneLayout),m=l?null:xv(K_(r.id)),h=l??m??c??U_,g=new Set(s.filter(e=>e.state!==`draft`).map(e=>e.id)),_=s.filter(e=>e.state!==`draft`),v=uv(h,g),y=new Set(sv(v)),b=s.filter(e=>e.state!==`draft`&&e.state!==`ended`&&!y.has(e.id)).map(e=>e.id);b.length>0&&(v=Sv(v,b)),sv(v).length>0||_.length>0&&(v=lv(_.map(e=>e.id))),v!==c&&d(v);let x=!l||m!==null||b.length>0,S=m!==null||sv(v).length>0;x&&S&&p({paneLayout:v}).then(e=>{e&&m!==null&&q_(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 xv(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=>xv(e)??U_)}:null}function Sv(e,t){let n=e,r=sv(n),i=r[r.length-1]??null;for(let e of t)n=cv(n,e,i,`horizontal`),i=e;return n}function Cv(e){return{providerId:e,available:!0,missingCommands:[],missingPrerequisites:[],autoInstallSupported:!1,installReadiness:`ready`,manualGuideKeys:[],docUrls:{provider:``,prerequisites:{}}}}function wv(e){return{claude:{runtime:e?.claude??Cv(`claude`),loading:!1},codex:{runtime:e?.codex??Cv(`codex`),loading:!1}}}function Tv(e,t,n){let[r,i]=(0,V.useState)(wv()),a=(0,V.useRef)({});(0,V.useEffect)(()=>{let t=!1;return(async()=>{let n=await e(`provider.runtimeStatus`,{});if(!t){if(!n.ok||!n.data){i(e=>({claude:{...e.claude,...wv().claude},codex:{...e.codex,...wv().codex}}));return}i(e=>({claude:{...e.claude,...wv(n.data.providers).claude},codex:{...e.codex,...wv(n.data.providers).codex}}))}})(),()=>{t=!0;for(let e of Object.values(a.current))typeof e==`number`&&window.clearTimeout(e)}},[e]);let o=async()=>{let t=await e(`provider.runtimeStatus`,{});!t.ok||!t.data||i(e=>({claude:{...e.claude,runtime:t.data.providers.claude,loading:!1},codex:{...e.codex,runtime:t.data.providers.codex,loading:!1}}))},s=(e,t,n)=>{i(r=>({...r,[e]:{...r[e],loading:!1,inlineError:n,installJob:r[e].installJob?{...r[e].installJob,failure:t}:r[e].installJob}}))};return{states:r,launch:async c=>{let l=r[c].runtime;if(!l)return;if(i(e=>({...e,[c]:{...e[c],loading:!0,inlineError:void 0}})),l.available){let r=await e(`session.create`,{workspaceId:t,providerId:c});if(r.ok&&r.data){n(r.data,c),i(e=>({...e,[c]:{...e[c],loading:!1}}));return}r.error?.code===`provider_cli_missing`&&await o(),i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:r.error?.message}}));return}if(!l.autoInstallSupported){i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:`manual`}}));return}let u=await e(`provider.install.start`,{providerId:c});if(!u.ok||!u.data){i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:u.error?.message}}));return}if(i(e=>({...e,[c]:{...e[c],installJob:u.data,loading:!1}})),u.data.status===`failed`){s(c,u.data.failure,u.data.failure?.message);return}if(u.data.status===`succeeded`){await o();let r=await e(`session.create`,{workspaceId:t,providerId:c});r.ok&&r.data&&n(r.data,c);return}let d=async()=>{let r=await e(`provider.install.get`,{jobId:u.data.jobId});if(!r.ok||!r.data){i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:r.error?.message}}));return}if(i(e=>({...e,[c]:{...e[c],installJob:r.data,loading:!1,inlineError:void 0}})),r.data.status===`queued`||r.data.status===`running`){a.current[c]=window.setTimeout(d,1500);return}if(r.data.status===`failed`){s(c,r.data.failure,r.data.failure?.message);return}await o();let l=await e(`session.create`,{workspaceId:t,providerId:c});if(l.ok&&l.data){n(l.data,c);return}i(e=>({...e,[c]:{...e[c],inlineError:l.error?.message,loading:!1}}))};a.current[c]=window.setTimeout(d,1500)}}}var Ev=({workspaceId:e,paneId:t,onAssignSession:n,onClosePane:r,onReplaceWithSession:i,onSplitPane:a})=>{let o=X(),s=H(Wf),c=U(rp),{states:l,launch:u}=Tv(s,e,(e,r)=>{c(t=>({...t,[e.id]:e})),t?n?.(t,e.id):i?.(e.id)}),d=e=>{let t=l[e];return t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`?o(`provider.install.cta.installing`):t.runtime?.available?o(`provider.install.cta.start`):t.runtime?.autoInstallSupported?o(`provider.install.cta.install_and_start`):o(`provider.install.cta.manual`)},f=e=>{let t=l[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`||t.runtime?.autoInstallSupported===!1?{message:t.runtime?.manualGuideKeys.map(e=>o(e)).join(` `),docUrl:t.runtime?.docUrls.provider}:{docUrl:t.runtime?.docUrls.provider}},p=Object.values(l).some(e=>e.loading||e.installJob?.status===`queued`||e.installJob?.status===`running`);return(0,Y.jsxs)(`div`,{className:`session-card agent-pane`,children:[(0,Y.jsxs)(`div`,{className:`session-header`,children:[(0,Y.jsxs)(`div`,{className:`session-header-left`,children:[(0,Y.jsx)(xh,{tone:`neutral`,className:`session-dot session-dot-idle`}),(0,Y.jsx)(`div`,{className:`session-header-copy`,children:(0,Y.jsxs)(`div`,{className:`session-title-row`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:o(`session.provider_select`)||`New Session`}),(0,Y.jsx)(kh,{color:`neutral`,className:`session-state-badge`,children:`DRAFT`})]})})]}),(0,Y.jsxs)(`div`,{className:`session-header-actions`,children:[(0,Y.jsx)($,{content:`Split horizontal`,children:(0,Y.jsx)(Z,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,Y.jsx)(Ji,{size:13}),onClick:()=>{t&&a?.(t,`horizontal`)},size:`sm`})}),(0,Y.jsx)($,{content:`Split vertical`,children:(0,Y.jsx)(Z,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,Y.jsx)(qi,{size:13}),onClick:()=>{t&&a?.(t,`vertical`)},size:`sm`})}),(0,Y.jsx)($,{content:`Close`,children:(0,Y.jsx)(Z,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>{t&&r?.(t)},size:`sm`})})]})]}),(0,Y.jsx)(`div`,{className:`agent-draft-launcher`,children:(0,Y.jsxs)(`div`,{className:`agent-draft-content`,children:[(0,Y.jsx)(`span`,{className:`agent-draft-kicker`,children:`SESSION LAUNCHER`}),(0,Y.jsx)(`p`,{className:`agent-draft-description`,children:`选择一个 AI 会话,在当前 workspace 里继续查看文件、运行命令和推进代码修改。`}),(0,Y.jsx)(`div`,{className:`agent-draft-providers`,children:[{id:`claude`,title:`Claude`,meta:`analysis`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.claude`,size:18}),description:`更适合长上下文梳理、方案分析和代码审查。`,className:`agent-provider-card-claude`},{id:`codex`,title:`Codex`,meta:`workspace`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.codex`,size:18}),description:`更适合终端操作、直接改文件和逐步修复问题。`,className:`agent-provider-card-codex`}].map(e=>{let t=l[e.id],n=f(e.id),r=t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`;return(0,Y.jsx)(Lp,{className:`agent-provider-card ${e.className}`,disabled:p,leadingIcon:(0,Y.jsx)(`span`,{className:`agent-provider-card-icon`,children:e.icon}),onClick:()=>{u(e.id)},trailingIcon:(0,Y.jsx)(ni,{size:16,className:`agent-provider-card-arrow`}),variant:`secondary`,children:(0,Y.jsxs)(`span`,{className:`agent-provider-card-body`,children:[(0,Y.jsxs)(`span`,{className:`agent-provider-card-title-row`,children:[(0,Y.jsx)(`span`,{className:`agent-provider-card-title`,children:e.title}),(0,Y.jsx)(`span`,{className:`agent-provider-card-meta`,children:e.meta})]}),(0,Y.jsx)(`span`,{className:`agent-provider-card-desc`,children:e.description}),(0,Y.jsx)(`span`,{className:`agent-provider-card-cta`,children:d(e.id)}),r?(0,Y.jsx)(`span`,{className:`agent-provider-card-status`,children:o(`provider.install.status.installing`)}):null,n.message?(0,Y.jsxs)(`span`,{className:`agent-provider-card-guide`,children:[(0,Y.jsx)(`span`,{children:n.message}),n.docUrl?(0,Y.jsx)(`a`,{href:n.docUrl,target:`_blank`,rel:`noreferrer`,children:o(`provider.install.open_docs`)}):null]}):null]})},e.id)})})]})})]})},Dv=({splitId:e,direction:t,ratio:n,children:r,onRatioCommit:i})=>{let[a,o]=(0,V.useState)(n),s=(0,V.useRef)(null),c=(0,V.useRef)(!1),l=(0,V.useRef)(n),u=(0,V.useCallback)(()=>{c.current=!0,l.current=a,document.body.classList.add(`is-resizing-panels`)},[a]),d=(0,V.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,V.useCallback)(()=>{c.current&&(c.current=!1,document.body.classList.remove(`is-resizing-panels`),i?.(l.current))},[i]);(0,V.useEffect)(()=>(document.addEventListener(`mousemove`,d),document.addEventListener(`mouseup`,f),()=>{document.removeEventListener(`mousemove`,d),document.removeEventListener(`mouseup`,f)}),[d,f]),(0,V.useEffect)(()=>{o(n),l.current=n},[n,e]);let[p,m]=Array.isArray(r)?r:[r],h=t===`horizontal`?{gridTemplateColumns:`${a*100}% 8px ${(1-a)*100}%`}:{gridTemplateRows:`${a*100}% 8px ${(1-a)*100}%`};return(0,Y.jsxs)(`div`,{ref:s,className:`pane-layout pane-layout-${t}`,style:{display:`grid`,...h},children:[(0,Y.jsx)(`div`,{className:`pane-layout-child`,children:p}),(0,Y.jsx)(`div`,{className:`pane-layout-divider`,onMouseDown:u,role:`separator`,"aria-orientation":t===`horizontal`?`vertical`:`horizontal`}),(0,Y.jsx)(`div`,{className:`pane-layout-child`,children:m})]})},Ov=B(new Map),kv=B(new Map),Av=Kf(e=>B(!1)),jv=B({open:!1,sessionId:null,mode:`enable`,draftObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``});B(e=>t=>e(Ov).get(t));var Mv=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}],Nv={open:!1,sessionId:null,mode:`enable`,draftObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``};function Pv(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 Fv(e){let t=Number.parseInt(e,10);return!Number.isSafeInteger(t)||t<0?0:t}function Iv(e){let t=(e??``).trim();if(!t)return!1;let n=Number(t);return Number.isSafeInteger(n)&&n>=0}function Lv(e){if(!e.trim())return;let t=Date.parse(e);if(Number.isFinite(t))return t}function Rv({workspaceId:e,sessionId:t}){let[n,r]=xe(jv),i=H(Ov),a=H(Wf),o=X(),s=t??n.sessionId,c=s?i.get(s):void 0,l=n.open&&(!t||n.sessionId===t),u=n.mode,d={title:o(`supervisor.dialog.${u}.title`),subtitle:o(`supervisor.dialog.${u}.subtitle`),confirm:o(`supervisor.dialog.${u}.confirm`)},f=u===`disable`,p=c?.objective??n.draftObjective,m=Iv(n.draftMaxSupervisionCount),h=(0,V.useCallback)(()=>{r(Nv)},[r]);return{dialog:n,supervisor:c,isVisible:l,mode:u,copy:d,isDisable:f,disableObjective:p,isMaxSupervisionCountValid:m,close:h,updateDraft:(0,V.useCallback)(e=>{r(t=>({...t,...e}))},[r]),confirm:(0,V.useCallback)(async()=>{if(!n.sessionId)return!1;if(n.mode===`disable`)return c&&(await a(`supervisor.delete`,{id:c.id})).ok?(h(),!0):!1;let t=n.draftObjective.trim();if(!t||!m)return!1;let r=n.draftEvaluatorModel.trim(),i=Fv(n.draftMaxSupervisionCount),o=Lv(n.draftScheduledAt);return n.mode===`enable`?(await a(`supervisor.create`,{sessionId:n.sessionId,workspaceId:e,objective:t,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:r||void 0,maxSupervisionCount:i,scheduledAt:o})).ok?(h(),!0):!1:c&&(await a(`supervisor.update`,{id:c.id,objective:t,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:r||null,maxSupervisionCount:i,scheduledAt:o??null})).ok?(h(),!0):!1},[h,n,a,m,c,e]),formatScheduledAtInput:Pv}}var zv=`__supervisor-empty__`;function Bv(e){let t=e?.id??zv,n=H(Wf),r=H(Av(t)),i=U(Av(t)),a=U(Ov),o=U(kv),s=U(jv);return(0,V.useEffect)(()=>{if(!e||r||e.capability!==`full`||e.state===`draft`||e.state===`ended`)return;let t=!1;return n(`supervisor.get`,{sessionId:e.id}).then(n=>{if(t||!n.ok)return;let r=n.data?.supervisor??null;r?(a(t=>{let n=new Map(t);return n.set(e.id,r),n}),o(e=>{let t=new Map(e);return t.set(r.id,r.cycles??[]),t})):a(t=>{let n=new Map(t);return n.delete(e.id),n}),i(!0)}),()=>{t=!0}},[n,r,e,o,i,a]),{openDialog:(0,V.useCallback)((e,n)=>{s({open:!0,sessionId:t,mode:e,draftObjective:n?.objective??``,draftEvaluatorProviderId:n?.evaluatorProviderId??`claude`,draftEvaluatorModel:n?.evaluatorModel??``,draftMaxSupervisionCount:String(n?.maxSupervisionCount??0),draftScheduledAt:Pv(n?.scheduledAt)})},[t,s])}}var Vv=Mv.map(e=>({value:e.id,label:e.label}));function Hv({mode:e}){return e===`enable`?(0,Y.jsx)(Q,{semantic:`supervisor.mode.enable`,size:14}):e===`edit`?(0,Y.jsx)(Q,{semantic:`supervisor.mode.edit`,size:14}):(0,Y.jsx)(Q,{semantic:`supervisor.mode.disable`,size:14})}function Uv({mode:e,draftObjective:t,draftEvaluatorProviderId:n,draftEvaluatorModel:r,draftMaxSupervisionCount:i,draftScheduledAt:a,isMaxSupervisionCountValid:o,disableObjective:s,onDraftObjectiveChange:c,onDraftEvaluatorProviderChange:l,onDraftEvaluatorModelChange:u,onDraftMaxSupervisionCountChange:d,onDraftScheduledAtChange:f}){let p=X(),m=(0,V.useId)(),h=(0,V.useId)(),g=(0,V.useId)(),_=(0,V.useId)(),v=(0,V.useId)(),y=(0,V.useId)();return e===`disable`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`supervisor-danger-callout`,role:`alert`,children:[(0,Y.jsx)(Q,{"aria-hidden":`true`,className:`supervisor-danger-callout-icon`,semantic:`state.warning`,size:16}),(0,Y.jsxs)(`div`,{className:`supervisor-danger-callout-copy`,children:[(0,Y.jsx)(`strong`,{children:p(`supervisor.dialog.disable.warning_title`)}),(0,Y.jsx)(`small`,{children:p(`supervisor.dialog.disable.warning_body`)})]})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{children:p(`supervisor.field.current_objective`)}),(0,Y.jsx)(`pre`,{className:`objective-preview`,children:s})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`objective`,children:p(`supervisor.field.objective`)}),(0,Y.jsx)(Fh,{id:`objective`,size:`lg`,rows:5,value:t,onChange:e=>c(e.target.value),"aria-describedby":m,placeholder:p(`supervisor.field.objective_placeholder`),autoFocus:!0}),(0,Y.jsx)(`span`,{id:m,className:`dialog-helper`,children:p(`supervisor.field.objective_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{id:h,htmlFor:`evaluator-provider`,children:p(`supervisor.field.evaluator`)}),(0,Y.jsx)(mh,{id:`evaluator-provider`,desktopMode:`listbox`,mobileSheetTitle:p(`supervisor.field.evaluator`),mobileSheetPresentation:`inline`,options:Vv,value:n,"aria-labelledby":h,"aria-describedby":g,onValueChange:l}),(0,Y.jsx)(`span`,{id:g,className:`dialog-helper`,children:p(`supervisor.field.evaluator_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`evaluator-model`,children:p(`supervisor.field.evaluator_model`)}),(0,Y.jsx)(vm,{id:`evaluator-model`,size:`lg`,value:r,onChange:e=>u(e.target.value),"aria-describedby":_,placeholder:p(`supervisor.field.evaluator_model_placeholder`)}),(0,Y.jsx)(`span`,{id:_,className:`dialog-helper`,children:p(`supervisor.field.evaluator_model_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`max-supervision-count`,children:p(`supervisor.field.max_supervision_count`)}),(0,Y.jsx)(vm,{id:`max-supervision-count`,size:`lg`,type:`number`,min:0,step:1,value:i,onChange:e=>d(e.target.value),invalid:!o,"aria-invalid":!o,"aria-describedby":v}),(0,Y.jsx)(`span`,{id:v,className:`dialog-helper`,children:p(`supervisor.field.max_supervision_count_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`scheduled-at`,children:p(`supervisor.field.scheduled_at`)}),(0,Y.jsx)(jm,{label:p(`supervisor.field.scheduled_at`),value:a,onValueChange:f,placeholder:p(`supervisor.field.scheduled_at_placeholder`),clearable:!0,minDate:new Date,"aria-describedby":y}),(0,Y.jsx)(`span`,{id:y,className:`dialog-helper`,children:p(`supervisor.field.scheduled_at_helper`)})]})]})}function Wv({workspaceId:e,sessionId:t}){let n=Pr(),r=X(),{dialog:i,isVisible:a,mode:o,copy:s,isDisable:c,disableObjective:l,isMaxSupervisionCountValid:u,close:d,updateDraft:f,confirm:p}=Rv({workspaceId:e,sessionId:t});return!a||n===`mobile`?null:(0,Y.jsxs)(qp,{className:`supervisor-dialog supervisor-dialog--${o}`,onOpenChange:d,open:!0,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(`div`,{className:`supervisor-dialog-header`,children:[(0,Y.jsx)(`span`,{className:`supervisor-dialog-header-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Hv,{mode:o})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(Yp,{children:s.title}),(0,Y.jsx)(`span`,{className:`supervisor-dialog-subtitle`,children:s.subtitle})]})]}),(0,Y.jsx)(Z,{"aria-label":r(`action.close`),icon:(0,Y.jsx)(ea,{size:14}),onClick:d,size:`sm`})]}),(0,Y.jsx)(Xp,{children:(0,Y.jsx)(Uv,{mode:o,draftObjective:i.draftObjective,draftEvaluatorProviderId:i.draftEvaluatorProviderId,draftEvaluatorModel:i.draftEvaluatorModel,draftMaxSupervisionCount:i.draftMaxSupervisionCount,draftScheduledAt:i.draftScheduledAt,isMaxSupervisionCountValid:u,disableObjective:l,onDraftObjectiveChange:e=>f({draftObjective:e}),onDraftEvaluatorProviderChange:e=>f({draftEvaluatorProviderId:e}),onDraftEvaluatorModelChange:e=>f({draftEvaluatorModel:e}),onDraftMaxSupervisionCountChange:e=>f({draftMaxSupervisionCount:e}),onDraftScheduledAtChange:e=>f({draftScheduledAt:e})})}),(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{onClick:d,children:r(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:c?`danger`:`primary`,onClick:()=>{p()},disabled:!c&&(!i.draftObjective.trim()||!u),children:s.confirm})]})]})}var Gv={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 Kv({sessionId:e}){let t=H(Ov),n=H(kv),r=H(Wf),i=U(jv),a=H(xa),o=X(),s=t.get(e),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!c)return;let e=window.setTimeout(()=>l(null),6e3);return()=>window.clearTimeout(e)},[c]);let u=(0,V.useCallback)(t=>{i({open:!0,sessionId:e,mode:t,draftObjective:s?.objective??``,draftEvaluatorProviderId:s?.evaluatorProviderId??`claude`,draftEvaluatorModel:s?.evaluatorModel??``,draftMaxSupervisionCount:String(s?.maxSupervisionCount??0),draftScheduledAt:Pv(s?.scheduledAt)})},[e,i,s]),d=(0,V.useCallback)(async(e,t,n)=>{l(null);let i=await r(e,{id:t});i.ok||l(i.error?.message?`${n}: ${i.error.message}`:n)},[r]),f=(0,V.useCallback)(async()=>{s&&await d(`supervisor.pause`,s.id,o(`supervisor.action.pause_failed`))},[d,s,o]),p=(0,V.useCallback)(async()=>{s&&await d(`supervisor.resume`,s.id,o(`supervisor.action.resume_failed`))},[d,s,o]),m=(0,V.useCallback)(async()=>{s&&await d(`supervisor.trigger`,s.id,o(`supervisor.action.trigger_failed`))},[d,s,o]),h=s?[...n.get(s.id)??s.cycles??[]].sort((e,t)=>(t.completedAt??t.createdAt)-(e.completedAt??e.createdAt)):[],g=h[0],_=h.some(e=>e.status===`evaluating`||e.status===`queued`),v=g?g.result??g.errorReason??(g.status===`completed`?o(`supervisor.cycle.no_guidance`):g.status===`evaluating`?o(`supervisor.cycle.evaluating`):g.status===`cancelled`?o(`supervisor.cycle.cancelled`):o(`supervisor.cycle.waiting`)):null,y=s?.currentTargetMemory??null,b=y?.plan??[],x=s?.recentTargetCycles??[],S=y?y.planGenerated?o(`supervisor.target_memory.plan_ready`):o(`supervisor.target_memory.plan_pending`):null,C=o(`supervisor.target_memory.progress_badge`),w=x[0]==null?null:o(`supervisor.target_memory.cycle_result.${x[0].result}`),T=s?.stopReason?o(`supervisor.stop_reason.${s.stopReason}`):null;return{actionError:c,cycles:h,executionPolicyItems:s?[s.evaluatorModel?{key:`model`,label:o(`supervisor.field.evaluator_model`),value:s.evaluatorModel}:null,{key:`max-count`,label:o(`supervisor.field.max_supervision_count`),value:s.maxSupervisionCount>0?String(s.maxSupervisionCount):o(`supervisor.meta.no_cap`)},s.scheduledAt?{key:`scheduled-at`,label:o(`supervisor.field.scheduled_at`),value:Dp(s.scheduledAt,a)}:null].filter(e=>e!==null):[],handlePause:f,handleResume:p,handleTrigger:m,isBusy:s?.state===`evaluating`||s?.state===`injecting`||_,latestCycle:g,latestCycleText:v,planGeneratedLabel:S,recentTargetCycles:x,targetCycleResultLabel:w,targetMemory:y,targetProgressLabel:C,targetPlanItems:b,openDialog:u,stopReasonLabel:T,stateClass:s?Gv[s.state]:Gv.inactive,stateLabel:o(`supervisor.state.${s?s.state:`inactive`}`),supervisor:s}}function qv({sessionId:e,workspaceId:t,defaultDetailsOpen:n=!1}){let r=X(),[i,a]=(0,V.useState)(n),{actionError:o,executionPolicyItems:s,handlePause:c,handleResume:l,handleTrigger:u,isBusy:d,latestCycle:f,latestCycleText:p,openDialog:m,planGeneratedLabel:h,recentTargetCycles:g,stopReasonLabel:_,stateClass:v,stateLabel:y,supervisor:b,targetCycleResultLabel:x,targetMemory:S,targetProgressLabel:C,targetPlanItems:w}=Kv({sessionId:e});if(!b)return(0,Y.jsx)(`div`,{className:`supervisor-card supervisor-card-inactive`,children:(0,Y.jsx)($,{content:r(`supervisor.action.enable`),children:(0,Y.jsxs)(`button`,{className:`supervisor-enable-btn`,onClick:()=>m(`enable`),"aria-label":r(`supervisor.action.enable`),children:[(0,Y.jsx)(Q,{semantic:`supervisor.entry`,size:13}),(0,Y.jsx)(`span`,{children:r(`supervisor.title`)})]})})});let T=g[0]??null,E=r(S?`supervisor.target_memory.title`:`supervisor.meta.title`),D=[S?`${r(`supervisor.target_memory.target`)}: ${b.targetId}`:null,S&&h?`${r(`supervisor.target_memory.plan`)}: ${h}`:null,S?`${r(`supervisor.target_memory.stalled`)}: ${String(S.stalledCount)}`:null,S?.progressSummary?`${C}: ${S.progressSummary}`:null].filter(e=>e!==null);return(0,Y.jsxs)(`div`,{className:`supervisor-card ${v}`,"data-workspace-id":t,children:[(0,Y.jsxs)(`div`,{className:`supervisor-strip-row`,children:[(0,Y.jsxs)(`span`,{className:`supervisor-strip-eyebrow`,children:[(0,Y.jsx)(`span`,{className:`supervisor-pulse ${v}`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`supervisor-label`,children:r(`supervisor.title`)})]}),(0,Y.jsx)(`span`,{className:`supervisor-state-tag ${v}`,children:y}),(0,Y.jsxs)(`div`,{className:`supervisor-actions`,children:[(0,Y.jsx)($,{content:r(`supervisor.action.edit_objective`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.edit_objective`),className:`supervisor-icon-btn`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.mode.edit`,size:12}),onClick:()=>m(`edit`),size:`sm`})}),b.state===`paused`?(0,Y.jsx)($,{content:r(`supervisor.action.resume`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.resume`),className:`supervisor-icon-btn`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.action.resume`,size:12}),onClick:()=>{l()},size:`sm`})}):(0,Y.jsx)($,{content:r(`supervisor.action.pause`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.pause`),className:`supervisor-icon-btn`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.action.pause`,size:12}),onClick:()=>{c()},size:`sm`})}),(0,Y.jsx)($,{content:r(`supervisor.action.trigger`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.trigger`),className:`supervisor-icon-btn`,disabled:d,icon:(0,Y.jsx)(Q,{semantic:`supervisor.action.trigger`,size:12}),onClick:()=>{u()},size:`sm`})}),(0,Y.jsx)($,{content:r(`supervisor.action.disable`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.disable`),className:`supervisor-icon-btn supervisor-icon-btn-danger`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.mode.disable`,size:12}),onClick:()=>m(`disable`),size:`sm`})})]})]}),(0,Y.jsxs)(`div`,{className:`supervisor-objective-row`,onDoubleClick:()=>m(`edit`),children:[(0,Y.jsx)($,{content:b.objective,children:(0,Y.jsx)(`span`,{className:`supervisor-objective-text`,children:b.objective})}),(0,Y.jsx)(`span`,{className:`supervisor-provider-pill`,children:b.evaluatorProviderId})]}),f?(0,Y.jsx)(`ol`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.latest_evaluation`),children:(0,Y.jsxs)(`li`,{className:`supervisor-history-item`,"data-trigger":f.trigger,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:f.trigger===`manual`?r(`supervisor.trigger.manual`):f.trigger===`scheduled`?r(`supervisor.trigger.scheduled`):r(`supervisor.trigger.auto`)}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:p})]})}):null,S||s.length>0||T?.reason?(0,Y.jsxs)(`div`,{className:`supervisor-details`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`supervisor-details-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,Y.jsxs)(`span`,{className:`supervisor-details-copy`,children:[(0,Y.jsx)(`span`,{className:`supervisor-details-label`,children:E}),(0,Y.jsx)(`span`,{className:`supervisor-details-summary`,children:D.length>0?D.join(` · `):r(`supervisor.meta.title`)})]}),(0,Y.jsx)(`span`,{className:`supervisor-details-chevron${i?` expanded`:``}`,"aria-hidden":`true`,children:(0,Y.jsx)(si,{size:14})}),(0,Y.jsx)(`span`,{className:`supervisor-details-toggle-text`,children:r(i?`action.collapse`:`action.expand`)})]}),i?(0,Y.jsxs)(`div`,{className:`supervisor-details-panel`,children:[S?(0,Y.jsxs)(`dl`,{className:`supervisor-meta-grid`,"aria-label":r(`supervisor.target_memory.title`),children:[(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.target`)}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:b.targetId})]}),(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.plan`)}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:h})]}),(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.stalled`)}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:String(S.stalledCount)})]})]}):null,s.length>0?(0,Y.jsx)(`dl`,{className:`supervisor-meta-grid`,"aria-label":r(`supervisor.meta.title`),children:s.map(e=>(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:e.label}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:e.value})]},e.key))}):null,S?.progressSummary?(0,Y.jsx)(`div`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.target_memory.progress_title`),children:(0,Y.jsxs)(`div`,{className:`supervisor-history-item`,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:C}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:S.progressSummary})]})}):null,w.length>0?(0,Y.jsx)(`ol`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.target_memory.plan_title`),children:w.slice(0,3).map(e=>(0,Y.jsxs)(`li`,{className:`supervisor-history-item`,"data-trigger":e.status,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:r(`supervisor.target_memory.step_status.${e.status}`)}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:e.title})]},e.id))}):null,T?.reason?(0,Y.jsx)(`ol`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.target_memory.reasoning_title`),children:(0,Y.jsxs)(`li`,{className:`supervisor-history-item`,"data-trigger":T.result,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:x}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:T.reason})]})}):null]}):null]}):null,b.state===`stopped`&&_?(0,Y.jsx)(`div`,{className:`supervisor-error`,role:`status`,children:_}):null,o?(0,Y.jsx)(`div`,{className:`supervisor-error`,role:`alert`,children:o}):b.errorReason?(0,Y.jsx)(`div`,{className:`supervisor-error`,role:`alert`,children:b.errorReason}):null]})}var Jv=Kf(e=>B({chunks:[],lastSeq:0})),Yv=Kf(e=>B(null));Kf(e=>B(e=>[]));var Xv=2,Zv={focused:0,"visible-active":1,"visible-other":2,background:3};function Qv(e,t){return Zv[e]-Zv[t]}function $v(e){let t=Math.max(1,e?.concurrency??Xv),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=>Qv(t,e.tier)<0);i<0&&(i=r.length),r.splice(i,0,e),o()},u=e=>{let t=r.findIndex(t=>Qv(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 Qv(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 ey=$v();function ty(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 ny(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 ry(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=ny(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=ty(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 iy(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 ay(e){let t=ry(e.rowsElement,e.screenElement,e.terminal,e.clientX,e.clientY);return t===null?null:iy(e.terminal,t)}var oy=400,sy=[{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 cy(e){(e.pointerType===`touch`||e.pointerType===`pen`)&&e.preventDefault()}function ly(e){return e.pointerType===`touch`||e.pointerType===`pen`}function uy(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 dy({ctrlMode:e,shiftArmed:t,disabled:n=!1,labels:r,onKeyPress:i,onCtrlTap:a,onCtrlLongPress:o,onShiftTap:s,onPaste:c,onUpload:l}){let u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(!1),p=(0,V.useRef)(null),m=(0,V.useRef)(!1),h=(0,V.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)=>{ly(e)&&(h.current={pointerId:e.pointerId,target:t})},C=(e,t)=>{if(!ly(e))return`none`;let n=h.current;return!n||n.pointerId!==e.pointerId?`none`:(h.current=null,n.target===t?`matched`:`mismatched`)};(0,V.useEffect)(()=>{g&&(_(),v(),x(),f.current=!1,p.current=null,m.current=!1)},[g]),(0,V.useEffect)(()=>()=>{_(),v(),x()},[]);let w=()=>{g||(_(),f.current=!1,p.current=null,u.current=setTimeout(()=>{f.current=!0,p.current=`pointer`,o()},oy))},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||!ly(e)||t===`none`)&&(y(),t===`matched`)){if(f.current){f.current=!1,p.current=null;return}a()}},k=(e,t,n)=>{if(g||!ly(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,Y.jsxs)(`div`,{className:`mobile-terminal-input-bar`,"data-expanded":`true`,"data-disabled":n?`true`:`false`,children:[(0,Y.jsxs)(`div`,{className:`mobile-terminal-input-bar__actions`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.paste,disabled:g,onClick:()=>{g||c()},children:r.paste}),(0,Y.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.upload,disabled:g,onClick:()=>{g||l()},children:r.upload})]}),(0,Y.jsxs)(`div`,{className:`mobile-terminal-input-bar__keys`,role:`group`,"aria-label":r.shortcuts,children:[(0,Y.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=>{cy(e),S(e,`ctrl`),w()},onPointerUp:O,onPointerCancel:()=>{x(),T()},onPointerLeave:()=>{x(),T()},onClick:D,onKeyDown:M,children:`Ctrl`}),(0,Y.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=>{cy(e),S(e,`shift`)},onPointerUp:e=>{k(e,`shift`,s)},onPointerCancel:x,onClick:A,children:`Shift`}),sy.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key`,"aria-label":uy(e.id,r),disabled:g,onPointerDown:t=>{cy(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 fy={escape:`\x1B`,tab:` `,enter:`\r`,arrow_up:`\x1B[A`,arrow_down:`\x1B[B`,arrow_left:`\x1B[D`,arrow_right:`\x1B[C`},py={tab:`\x1B[Z`,arrow_up:`\x1B[1;2A`,arrow_down:`\x1B[1;2B`,arrow_left:`\x1B[1;2D`,arrow_right:`\x1B[1;2C`},my=`control`;function hy(e,t){return t?.shift?py[e]??fy[e]:fy[e]}function gy(e){return e===`off`?`armed`:`off`}function _y(){return`locked`}function vy(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:my}}var yy=12e4;function by(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 xy(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Sy=class extends Error{constructor(e,t,n){super(n??e),this.code=e,this.status=t,this.name=`UploadError`}};async function Cy(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 Sy(`network_error`,0,e.message)}let r;try{r=await n.json()}catch{r={}}if(!n.ok||!r.ok)throw new Sy(r.error??`http_${n.status}`,n.status);return r.files??[]}async function wy(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 Ty(e){let{containerRef:t,workspaceId:n,sendTextToTerminal:r,enabled:i}=e,[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(0),c=(0,V.useRef)(0),l=(0,V.useRef)(0),u=(0,V.useRef)(new Map),d=(0,V.useRef)(Promise.resolve()),f=U(zg),p=(0,V.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,V.useCallback)(async e=>{let t=c.current;c.current+=1,s.current+=1,o(!0);try{await p(t,await e())}catch(e){await p(t,null),f({kind:`error`,title:`Upload failed`,body:`Could not upload file(s): ${e instanceof Sy?e.code:`unknown`}`,duration:5e3})}finally{s.current=Math.max(0,s.current-1),o(s.current>0)}},[f,p]),h=(0,V.useCallback)(async e=>{e.length!==0&&await m(async()=>{let t=await Cy({workspaceId:n,files:e});return t.length===0?null:`${t.map(e=>xy(e.path)).join(` `)} `})},[m,n]),g=(0,V.useCallback)(async e=>{e&&await m(async()=>e)},[m]),_=(0,V.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 wy(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,V.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;!t||t.length===0||(e.preventDefault(),e.stopPropagation(),h(Array.from(t)))},a=e=>{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:_,handleFiles:h}}var Ey=({state:e,queuePosition:t})=>{let n=X(),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,Y.jsx)(`div`,{className:`xterm-replay-overlay xterm-replay-overlay--placeholder`,role:`status`,"aria-live":`polite`,children:(0,Y.jsxs)(`div`,{className:`xterm-replay-overlay__card`,children:[e===`granting`?(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:r})]})})},Dy=16,Oy=80,ky=.12,Ay=.02,jy=.92,My=16,Ny=500,Py=10,Fy=new Set([`\x1B[I`,`\x1B[O`]),Iy=3e3;async function Ly(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()}}function Ry(e){return/^\x1b\[\d+;\d+R$/.test(e)||/^\x1b\[(?:\?|>)(?:\d+;)*\d*c$/.test(e)}function zy(e){return Fy.has(e)?`system`:e.includes(`\r`)||e.includes(`
107
- `)?`submit`:`typing`}function By(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 Vy(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=By(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 Hy(e,t){return e?`item`in e&&typeof e.item==`function`?e.item(t):e[t]??null:null}function Uy(e,t){if(t===null||!e)return null;for(let n=0;n<e.length;n+=1){let r=Hy(e,n);if(r?.identifier===t)return r}return null}function Wy(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 Dy}function Gy(e){return e.type!==`keydown`||e.shiftKey||e.altKey?!1:(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`}var Ky=new TextEncoder,qy=new TextDecoder(`utf-8`,{fatal:!1}),Jy=`coderStudio.terminalTrace`;function Yy(){try{return globalThis.localStorage?.getItem(Jy)===`1`}catch{return!1}}function Xy(){if(typeof document>`u`)return Promise.resolve();let e=document.fonts;return e?.ready?e.ready.then(()=>void 0,()=>void 0):Promise.resolve()}function Zy(e,t){return e.split(t).length-1}function Qy(e){let t=typeof e==`string`?e:qy.decode(e);return{length:typeof e==`string`?e.length:e.byteLength,syncStart:Zy(t,`\x1B[?2026h`),syncEnd:Zy(t,`\x1B[?2026l`),clearToEnd:Zy(t,`\x1B[J`),clearScreen:Zy(t,`\x1B[2J`),eraseLine:Zy(t,`\x1B[K`),cursorHome:Zy(t,`\x1B[1;1H`),dsr:Zy(t,`\x1B[6n`),da:Zy(t,`\x1B[c`),reverseIndex:Zy(t,`\x1BM`),cursorMoves:t.match(/\x1b\[[0-9;]*[Hf]/g)?.length??0,scrollRegions:t.match(/\x1b\[[0-9;]*r/g)?.slice(0,6)??[]}}function $y(e,t,n={}){Yy()&&console.debug(`[terminal-trace]`,{at:Math.round(performance.now()*100)/100,terminalId:e,event:t,...n})}function eb(e,t){let n=Math.min(t,e.chunks.length);return n===0?e:{...e,chunks:e.chunks.slice(n)}}function tb({terminalId:e,workspaceId:t,readOnly:n=!1,isActiveSession:r=!1,terminalKind:i}){let a=X(),o=Pr(),s=H(ba),c=H(n_),l=H(If),u=H(Wf),p=U(zg),[m,h]=xe(Jv(e)),g=H(Yv(e)),_=i??g?.kind??`shell`,v=!n&&g?.alive!==!1,y=(0,V.useRef)(null),b=(0,V.useRef)(null),x=(0,V.useRef)(null),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(!1),T=(0,V.useRef)([]),E=(0,V.useRef)(null),D=(0,V.useRef)(!0),O=(0,V.useRef)(null),k=(0,V.useRef)([]),A=(0,V.useRef)(!1),j=(0,V.useRef)(0),M=(0,V.useRef)(`idle`),N=(0,V.useRef)(null),P=(0,V.useRef)(0),F=(0,V.useRef)(null),ee=(0,V.useRef)(0),I=(0,V.useRef)(0),te=(0,V.useRef)(s),L=(0,V.useRef)(``),R=(0,V.useRef)(0),z=(0,V.useRef)(null),ne=(0,V.useRef)(!1),re=(0,V.useRef)(null),ie=(0,V.useRef)(``),B=(0,V.useRef)(0),ae=(0,V.useRef)(null),oe=(0,V.useRef)(()=>{}),se=(0,V.useRef)(()=>{}),ce=(0,V.useRef)({activeTouchId:null,lastClientY:0,carryPx:0,pxPerLine:null,velocityPxPerMs:0,lastMomentumFrameAt:0,momentumFrameId:null,gestureDidScroll:!1,samples:[]}),[le,ue]=(0,V.useState)({kind:`loading`}),[de,fe]=(0,V.useState)(o===`mobile`?{kind:`granted`}:{kind:`idle`}),[pe,me]=(0,V.useState)(`off`),[he,ge]=(0,V.useState)(!1),_e=(0,V.useRef)(`off`),ve=(0,V.useRef)(!1),[ye,be]=(0,V.useState)(()=>!l||typeof l.getStatus!=`function`?`disconnected`:l.getStatus()),Se=(0,V.useRef)(()=>{}),Ce=(0,V.useRef)(()=>{});(0,V.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,V.useEffect)(()=>{te.current=s},[s]),(0,V.useLayoutEffect)(()=>{if(o===`mobile`){fe({kind:`granted`}),ne.current=!0,z.current=null;return}ne.current=!1;let t=g?.alive===!1?`background`:r?`visible-active`:`visible-other`,n=ey.request({terminalId:e,tier:t});z.current=n,fe(n.isGranted?{kind:`granted`}:{kind:`idle`});let i=!1,a=n.subscribePosition(e=>{i||fe({kind:`queued`,queuePosition:e})});return n.isGranted||n.granted.then(()=>{i||fe({kind:`granted`})}),()=>{i=!0,a(),ne.current||=(n.release(),!0),z.current=null}},[e,o]),(0,V.useEffect)(()=>{if(o===`mobile`)return;let e=g?.alive===!1?`background`:r?`visible-active`:`visible-other`;z.current?.promote(e)},[r,g?.alive,o]),(0,V.useEffect)(()=>{b.current&&(b.current.options.theme=ma(s).terminalTheme)},[s]),(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(pointer: coarse)`).matches)return;let t=ce.current,n=null,r=null,i=0,a=0,s=null,l=!1,u=()=>{n!==null&&(clearTimeout(n),n=null),r=null,i=0,a=0,s=null,l=!1},d=()=>{t.momentumFrameId!==null&&(cancelAnimationFrame(t.momentumFrameId),t.momentumFrameId=null),t.velocityPxPerMs=0,t.lastMomentumFrameAt=0},f=(e,n)=>{t.samples.push({clientY:e,at:n});let r=n-Oy;for(;t.samples.length>0&&t.samples[0].at<r;)t.samples.shift()},p=()=>{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??=Wy(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=b.current;if(!n){d();return}let r=t.lastMomentumFrameAt>0?t.lastMomentumFrameAt:e-My,i=Math.max(1,Math.min(64,e-r));t.lastMomentumFrameAt=e;let a=m(n,t.velocityPxPerMs*i),o=jy**+(i/My);if(t.velocityPxPerMs*=o,a===`blocked`||Math.abs(t.velocityPxPerMs)<=Ay){t.carryPx=0,d(),t.pxPerLine=null;return}t.momentumFrameId=requestAnimationFrame(h)},g=()=>{u(),d(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.gestureDidScroll=!1,t.samples=[]};se.current=g;let _=u=>{if(u.touches.length!==1){g();return}let p=Hy(u.touches,0);if(!p){g();return}if(d(),t.activeTouchId=p.identifier,t.lastClientY=p.clientY,t.carryPx=0,t.pxPerLine=b.current?Wy(b.current,e):Dy,t.gestureDidScroll=!1,t.samples=[],f(p.clientY,performance.now()),o===`mobile`&&c.copyOnSelect){r=p.identifier,i=p.clientX,a=p.clientY;let t=b.current,o=e.querySelector(`.xterm-rows`),c=e.querySelector(`.xterm-screen`);l=!1,s=t&&o instanceof HTMLElement?ay({clientX:p.clientX,clientY:p.clientY,rowsElement:o,screenElement:c instanceof HTMLElement?c:void 0,terminal:t}):null,n=setTimeout(()=>{n=null,l=!0},Ny)}},v=e=>{let n=Uy(e.changedTouches,t.activeTouchId),o=b.current;if(!n||!o)return;if(r===n.identifier)if(Math.abs(n.clientX-i)>Py||Math.abs(n.clientY-a)>Py)u();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,f(n.clientY,performance.now()),p();let c=m(o,s);(c===`buffered`||c===`scrolled`)&&e.cancelable&&e.preventDefault()},x=e=>{if(Uy(e.changedTouches,r)){if(l){let e=s;u(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0,t.gestureDidScroll=!1,t.samples=[],oe.current(e);return}u()}if(Uy(e.changedTouches,t.activeTouchId)){let n=t.gestureDidScroll,r=Uy(e.changedTouches,t.activeTouchId);if(r&&n&&(f(r.clientY,performance.now()),p()),t.activeTouchId=null,t.lastClientY=0,t.gestureDidScroll=!1,t.samples=[],n&&Math.abs(t.velocityPxPerMs)>=ky){t.lastMomentumFrameAt=0,t.momentumFrameId=requestAnimationFrame(h);return}t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0}},S=()=>{g()};return e.addEventListener(`touchstart`,_,{passive:!0}),e.addEventListener(`touchmove`,v,{passive:!1}),e.addEventListener(`touchend`,x,{passive:!0}),e.addEventListener(`touchcancel`,S,{passive:!0}),()=>{e.removeEventListener(`touchstart`,_),e.removeEventListener(`touchmove`,v),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S),se.current=()=>{},g()}},[c.copyOnSelect,o]);let we=(0,V.useCallback)(()=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null;try{let t=b.current?{cols:b.current.cols,rows:b.current.rows}:null;x.current?.fit(),$y(e,`fit`,{before:t,after:b.current?{cols:b.current.cols,rows:b.current.rows}:null})}catch(e){console.error(`Failed to fit xterm instance:`,e)}finally{let e=T.current;T.current=[];for(let t of e)t()}})},[e]),Te=(0,V.useCallback)(()=>new Promise(e=>{T.current.push(e)}),[]),Ee=(0,V.useCallback)(e=>{_e.current=e,me(e)},[]),De=(0,V.useCallback)(e=>{ve.current=e,ge(e)},[]),Oe=(0,V.useCallback)(()=>{let e=Date.now();e-B.current<Iy||(B.current=e,p({kind:`error`,title:a(o===`mobile`?`terminal.mobile_copy_current_line_failed_title`:`settings.copy_on_select_failed_title`),body:a(o===`mobile`?`terminal.mobile_copy_current_line_failed_body`:`settings.copy_on_select_failed_body`)}))},[p,a,o]),ke=(0,V.useCallback)(async e=>{if(!(o!==`mobile`||!c.copyOnSelect)&&(se.current(),e!==null))try{await Ly(e),p({kind:`success`,title:a(`terminal.copied_current_line`)}),typeof navigator<`u`&&typeof navigator.vibrate==`function`&&navigator.vibrate(10)}catch{Oe()}},[Oe,p,a,c.copyOnSelect,o]);(0,V.useEffect)(()=>{oe.current=e=>{ke(e)}},[ke]),(0,V.useLayoutEffect)(()=>{se.current()},[e,t]);let Ae=(0,V.useCallback)(async()=>{if(o===`mobile`||!c.copyOnSelect)return;let e=b.current;if(!e?.hasSelection())return;let t=ie.current||e.getSelection();if(t)try{await Ly(t)}catch{Oe()}},[Oe,c.copyOnSelect,o]),je=(0,V.useCallback)(async(t,n)=>{if(ee.current>0&&Ry(t)){$y(e,`input.suppressed-replay-response`,{summary:Qy(t)});return}if(!D.current)return;if(!l){console.error(`Cannot send terminal input: WebSocket not connected`);return}let r=R.current+1;R.current=r;let i=_e.current,a=L.current,o=vy(t,i),s=o.activity??n??zy(o.data),{nextDraft:c,submittedText:u}=Vy(a,o.data,s);try{o.nextCtrlMode!==i&&Ee(o.nextCtrlMode),$y(e,`input`,{activity:s,summary:Qy(o.data)}),L.current=c,await l.sendTerminalInput(e,Ky.encode(o.data),s,u)}catch(e){R.current===r&&(L.current=a,o.nextCtrlMode!==i&&_e.current===o.nextCtrlMode&&Ee(i)),console.error(`Failed to send terminal input:`,e)}},[e,Ee,l]),Me=(0,V.useCallback)(async({cols:t,rows:n})=>{if(!D.current)return;let r=O.current;if(r&&r.cols===t&&r.rows===n)return;O.current={cols:t,rows:n},$y(e,`resize.dispatch`,{previousSize:r,nextSize:{cols:t,rows:n}});let i=await u(`terminal.resize`,{terminalId:e,cols:t,rows:n});i.ok||console.error(`Failed to sync terminal size:`,i.error),$y(e,`resize.result`,{nextSize:{cols:t,rows:n},ok:i.ok,error:i.ok?void 0:i.error})},[e,u]),Ne=(0,V.useCallback)(async e=>{await je(e)},[je]),{busy:Pe,handleClipboardPaste:Fe,handleFiles:Ie}=Ty({containerRef:y,workspaceId:t,sendTextToTerminal:Ne,enabled:v});(0,V.useEffect)(()=>{D.current=v,b.current&&(b.current.options.disableStdin=!v||Pe,b.current.options.cursorBlink=v&&!Pe)},[v,Pe]),(0,V.useEffect)(()=>{if(!l){be(`disconnected`);return}if(typeof l.getStatus==`function`?be(l.getStatus()):be(`connected`),typeof l.onStatus==`function`)return l.onStatus(e=>{be(e)})},[l]),(0,V.useLayoutEffect)(()=>{Ee(`off`),De(!1),L.current=``,R.current+=1},[e,Ee,De]),(0,V.useEffect)(()=>{Se.current=je},[je]),(0,V.useEffect)(()=>{Ce.current=Me},[Me]),(0,V.useEffect)(()=>{if(o!==`mobile`&&de.kind!==`granted`||!y.current)return;let n=!1,r=null,i=I.current+1;I.current=i,ee.current=0,re.current=null,F.current=null,A.current=!1,j.current=0,M.current=`idle`,N.current=null,k.current=[],O.current=null,ue({kind:`loading`});let a=new f({theme:ma(te.current).terminalTheme,fontFamily:`JetBrains Mono, Fira Code, SF Mono, monospace`,fontSize:11,scrollback:5e3,cursorBlink:v&&!Pe,cursorStyle:`block`,disableStdin:!v||Pe,allowProposedApi:!0}),s=new d;a.loadAddon(s),a.onResize(e=>{Ce.current(e)}),a.onData(e=>{Se.current(e)});let c=typeof a.onSelectionChange==`function`?a.onSelectionChange(()=>{ie.current=a.hasSelection()?a.getSelection():``}):void 0;a.attachCustomKeyEventHandler(e=>!Gy(e)),a.open(y.current),$y(e,`mount.open`),b.current=a,x.current=s,we();let p=Te();o!==`mobile`&&p.then(async()=>{await Xy(),!(n||!w.current)&&we()}).catch(()=>{});let m=async()=>{l&&(typeof l.getStatus!=`function`||typeof l.onStatus!=`function`||l.getStatus()!==`connected`&&await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,r?.(),r=null,e())};r=l.onStatus(e=>{e===`connected`&&n()}),l.getStatus()===`connected`&&n()}))},g=p.then(async()=>{if(!l||(await m(),n||!w.current))return;let{cols:e,rows:t}=a;await Ce.current({cols:e,rows:t})}),_=(e,t)=>{ee.current+=1;let n=!1,r=()=>{n||(n=!0,I.current===i&&(ee.current=Math.max(0,ee.current-1),t?.()))};try{a.write(e,r)}catch(e){throw r(),e}},T=Df.terminalOutput(t,e),E=Df.terminalExit(t,e),D=e=>{let t=k.current;k.current=[];let n=[],r=e;for(let e of t)e.seq<=r||(n.push(e),r=e.seq);return{entries:n,latestCoveredSeq:r}},L=e=>{M.current=`done`,N.current=null,e&&F.current===e&&(F.current=`reconnect`),re.current?.()},R=(t,n,r)=>{if(j.current=n,A.current=!0,r.length===0){P.current=Math.max(P.current,n),L(t);return}let o=r.length,s=e=>{!w.current||I.current!==i||(P.current=Math.max(P.current,e),o=Math.max(0,o-1),o===0&&L(t))};for(let t of r){if(t.resetTerminalBeforeWrite&&typeof b.current?.reset==`function`&&b.current.reset(),t.kind===`historical`?$y(e,`write.historical`,{seq:t.seq,size:t.bytes.byteLength,summary:Qy(t.bytes)}):$y(e,`write.pending-replay-chunk`,{seq:t.seq,summary:Qy(t.bytes)}),t.kind===`historical`){_(t.bytes,()=>{s(t.seq)});continue}a.write(t.bytes,()=>{s(t.seq)})}},B=(e,t)=>{if(!w.current||!b.current||!e)return;let n=N.current,r=j.current,i=[];e.ok&&e.data?.status===t.successStatus?(t.successBytes&&i.push({kind:`historical`,bytes:t.successBytes,seq:t.coveredSeq??r,resetTerminalBeforeWrite:t.resetTerminalBeforeWrite}),r=t.coveredSeq??r,ue({kind:`ready`}),o!==`mobile`&&(z.current?.release(),ne.current=!0)):e.data?.status===`too_old`?(b.current&&b.current.writeln(`\r
109
- \x1B[33m[Session history truncated - output exceeds buffer size]\x1B[0m`),ue({kind:`degraded`,reason:`truncated`}),o!==`mobile`&&(z.current?.release(),ne.current=!0)):e.data?.status===`unknown`?(ue({kind:`degraded`,reason:`closed`}),o!==`mobile`&&(z.current?.release(),ne.current=!0)):e.ok||(console.error(`Failed to replay terminal output:`,e.error),ue({kind:`degraded`,reason:by(e.error)}),o!==`mobile`&&(z.current?.release(),ne.current=!0));let{entries:a,latestCoveredSeq:s}=D(r);r=s;for(let e of a)i.push({kind:`pending`,bytes:e.bytes,seq:e.seq});h(e=>({...e,chunks:[],lastSeq:Math.max(e.lastSeq,r)})),R(n,r,i)},ae=e=>{B(e,{successStatus:`ok`,successBytes:e?.data?.bytes,coveredSeq:e?.data?.seq})},oe=e=>{if(console.error(`Failed to recover terminal output:`,e),!w.current||!b.current)return;let t=N.current;ue({kind:`degraded`,reason:by(e)}),o!==`mobile`&&(z.current?.release(),ne.current=!0),h(e=>({...e,chunks:[],lastSeq:Math.max(e.lastSeq,j.current)}));let{entries:n,latestCoveredSeq:r}=D(j.current);R(t,r,n.map(e=>({kind:`pending`,bytes:e.bytes,seq:e.seq})))},se=t=>{l&&(M.current=`in-flight`,A.current=!1,ue({kind:`loading`}),l.sendCommand(`terminal.snapshot`,{terminalId:e},{timeoutMs:yy}).then(e=>({ok:!0,data:e})).catch(e=>({ok:!1,error:e})).then(e=>{if(!(!w.current||!b.current)){if(e.ok&&e.data?.status===`ok`&&e.data.bytes&&typeof e.data.seq==`number`){B(e,{successStatus:`ok`,successBytes:e.data.bytes,coveredSeq:e.data.seq,resetTerminalBeforeWrite:t?.resetTerminalBeforeWrite});return}if(t?.onUnavailable){t.onUnavailable(e);return}oe(e.ok?Error(`terminal.snapshot returned status ${e.data?.status??`unknown`}`):e.error)}}))},ce=(t,n)=>{l&&(M.current=`in-flight`,A.current=!1,t===0&&ue({kind:`loading`}),$y(e,`replay.request`,{lastSeq:t}),(l?l.sendCommand(`terminal.replay`,{terminalId:e,lastSeq:t},{timeoutMs:yy}).then(e=>({ok:!0,data:e})):u(`terminal.replay`,{terminalId:e,lastSeq:t})).then(e=>{if(e.ok&&e.data?.status===`too_old`&&n?.onTooOld){n.onTooOld();return}ae(e)}).catch(e=>{if(n?.onError){n.onError(e);return}oe(e)}))},le=()=>{F.current||=N.current??`reconnect`,M.current=`idle`,N.current=null,A.current=!1,re.current?.()},fe=()=>typeof l.getStatus==`function`?l.getStatus():`connected`,V=(t,n)=>{let r=fe();if(F.current===`reconnect`||r===`disconnected`||r===`reconnecting`){$y(e,`reconnect.snapshot-fallback.defer-until-reconnect`,{lastSeq:P.current,reason:t,error:n?String(n):void 0,connectionStatus:r}),le();return}$y(e,`reconnect.snapshot-fallback`,{lastSeq:P.current,reason:t,error:n?String(n):void 0}),se({resetTerminalBeforeWrite:!0,onUnavailable:t=>{let n=fe();if(F.current===`reconnect`||n===`disconnected`||n===`reconnecting`){$y(e,`reconnect.snapshot.defer-until-reconnect`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error),connectionStatus:n}),le();return}oe(t.ok?Error(`terminal.snapshot returned status ${t.data?.status??`unknown`}`):t.error)}})},pe=t=>{if(l){if(N.current=t,t===`reconnect`){ue({kind:`loading`}),ce(P.current,{onTooOld:()=>{V(`too_old`)},onError:e=>{V(`error`,e)}});return}se({onUnavailable:t=>{let n=fe();if(F.current===`initial`||n===`disconnected`||n===`reconnecting`){$y(e,`snapshot.defer-until-reconnect`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error),connectionStatus:n}),le();return}$y(e,`snapshot.fallback`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error)}),ce(0)}})}};return re.current=()=>{if(!F.current||typeof l.getStatus==`function`&&l.getStatus()!==`connected`||M.current===`in-flight`)return;let e=F.current;F.current=null,pe(e)},l&&(S.current=l.subscribe([T,E],(t,n,r)=>{if(t===T){let t=n;if($y(e,`live.output`,{seq:r,replayCompleted:A.current,replayedSeq:j.current,size:t.bytes.byteLength,summary:Qy(t.bytes)}),!A.current){k.current.push({bytes:t.bytes,seq:r});return}if(r<=j.current){$y(e,`live.drop-covered`,{seq:r,replayedSeq:j.current});return}let i=r-t.bytes.byteLength;if(i>j.current){$y(e,`live.gap`,{seq:r,chunkStartSeq:i,replayedSeq:j.current}),k.current.push({bytes:t.bytes,seq:r}),h(e=>({chunks:[],lastSeq:j.current})),ce(j.current);return}h(e=>r<=e.lastSeq?e:{chunks:[...e.chunks,t.bytes],lastSeq:r}),j.current=r}else if(t===E){let e=n;b.current&&b.current.writeln(`\r\n[Process exited with code ${e.code}]`)}})),(async()=>{await g,w.current&&pe(`initial`)})().catch(e=>{oe(e)}),()=>{if(n=!0,re.current=null,F.current=null,I.current===i&&(I.current+=1,ee.current=0),r&&=(r(),null),S.current&&=(S.current(),null),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null),b.current){try{b.current.dispose()}catch(e){console.error(`Failed to dispose xterm instance:`,e)}b.current=null,x.current=null}typeof c==`function`?c():c?.dispose?.()}},[u,de.kind,we,h,e,_,o,t,l]),(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof document>`u`||o===`mobile`||!c.copyOnSelect)return;let t=e=>{e.pointerType===`touch`||e.pointerType===`pen`||(ae.current=e.pointerId)},n=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target;n instanceof Node&&e.contains(n)||ae.current===t.pointerId&&(ae.current=null)},r=e=>{ae.current===e.pointerId&&(ae.current=null)},i=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target,r=n instanceof Node&&e.contains(n),i=ae.current!==null&&ae.current===t.pointerId;ae.current=null,!(!r&&!i)&&Ae()};return e.addEventListener(`pointerdown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,r),()=>{ae.current=null,e.removeEventListener(`pointerdown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,r)}},[Ae,c.copyOnSelect,o]),(0,V.useEffect)(()=>{if(!(!l||typeof l.onStatus!=`function`))return l.onStatus(e=>{if(e===`disconnected`||e===`reconnecting`){M.current!==`idle`&&(F.current=N.current??`reconnect`);return}e!==`connected`||!F.current||re.current?.()})},[l]),(0,V.useEffect)(()=>{if(!(!l||typeof l.onRecovery!=`function`))return l.onRecovery(e=>{e!==`reconnected`&&(F.current=`reconnect`,M.current!==`in-flight`&&re.current?.())})},[l]),(0,V.useEffect)(()=>{let t=b.current;if(!t)return;let{chunks:n}=m,r=n.length;if(r>0){let i=Array(n.length),a=m.lastSeq;for(let e=n.length-1;e>=0;--e)i[e]=a,a-=n[e]?.byteLength??0;for(let r=0;r<n.length;r++){let a=n[r];if(!a)continue;let o=i[r]??m.lastSeq;$y(e,`write.live-buffer`,{index:r,lastSeq:m.lastSeq,summary:Qy(a)}),t.write(a,()=>{P.current=Math.max(P.current,o)})}h(e=>eb(e,r))}},[de.kind,m,h,e]),(0,V.useEffect)(()=>{let t=y.current,n=x.current;if(!t||!n)return;let r=new ResizeObserver(()=>{$y(e,`resize-observer`,{clientWidth:t.clientWidth,clientHeight:t.clientHeight}),E.current!==null&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,we()},150)});return r.observe(t),()=>{r.disconnect(),E.current!==null&&(clearTimeout(E.current),E.current=null)}},[de.kind,we,e]),(0,V.useEffect)(()=>{o!==`mobile`&&de.kind===`granted`&&g?.alive&&b.current&&b.current.focus()},[de.kind,g?.alive,o]);let Le=o===`mobile`&&v,Re=!v||Pe||ye!==`connected`,ze={paste:a(`terminal.mobile_input.paste`),upload:a(`terminal.mobile_input.upload`),shortcuts:a(`terminal.mobile_input.shortcuts`),ctrl:a(`terminal.mobile_input.ctrl`),ctrlArmed:a(`terminal.mobile_input.ctrl_armed`),ctrlLocked:a(`terminal.mobile_input.ctrl_locked`),shift:a(`terminal.mobile_input.shift`),shiftArmed:a(`terminal.mobile_input.shift_armed`),escape:a(`terminal.mobile_input.escape`),tab:a(`terminal.mobile_input.tab`),enter:a(`terminal.mobile_input.enter`),up:a(`terminal.mobile_input.up`),down:a(`terminal.mobile_input.down`),left:a(`terminal.mobile_input.left`),right:a(`terminal.mobile_input.right`)},Be=(0,V.useCallback)(async e=>{let t=ve.current;t&&De(!1),await je(hy(e,{shift:t}))},[je,De]),Ve=(0,V.useCallback)(()=>{Ee(gy(_e.current))},[Ee]),He=(0,V.useCallback)(()=>{Ee(_y())},[Ee]),Ue=(0,V.useCallback)(()=>{De(!ve.current)},[De]),We=(0,V.useRef)(null),[Ge,Ke]=(0,V.useState)(!1),qe=(0,V.useRef)(null),Je=(0,V.useCallback)(async()=>{if(navigator.clipboard)try{await Fe();return}catch(e){console.debug(`Clipboard API failed, showing paste dialog:`,e)}Ke(!0)},[Fe]),Ye=(0,V.useCallback)(async()=>{let e=qe.current;if(!e)return;let t=e.value;t&&(await Ne(t),e.value=``),Ke(!1)},[Ne]),Xe=(0,V.useCallback)(()=>{let e=qe.current;e&&(e.value=``),Ke(!1)},[]),Ze=(0,V.useCallback)(()=>{We.current?.click()},[]),Qe=(0,V.useCallback)(async e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,t.length!==0&&await Ie(t)},[Ie]),$e=le.kind!==`ready`&&(o===`mobile`||de.kind===`granted`),et=``,tt=``,nt=`xterm-replay-overlay`;return le.kind===`loading`?(et=a(`terminal.replay.loading_title`),tt=a(`terminal.replay.loading_body`)):(nt+=` xterm-replay-overlay--degraded`,et=le.reason===`truncated`?a(`terminal.replay.truncated_title`):le.reason===`closed`?a(`terminal.replay.closed_title`):a(`terminal.replay.failed_title`),tt=le.reason===`truncated`?a(`terminal.replay.truncated_body`):le.reason===`closed`?a(`terminal.replay.closed_body`):a(`terminal.replay.failed_body`)),(0,Y.jsxs)(`div`,{className:`xterm-host-shell${Le?` xterm-host-shell--mobile-input`:``}`,children:[Le?(0,Y.jsx)(dy,{ctrlMode:pe,shiftArmed:he,disabled:Re,labels:ze,onKeyPress:e=>{Be(e)},onCtrlTap:Ve,onCtrlLongPress:He,onShiftTap:Ue,onPaste:Je,onUpload:Ze}):null,(0,Y.jsx)(`input`,{ref:We,type:`file`,accept:`image/*,video/*,audio/*,text/plain,.txt,.md,.json,.csv`,multiple:!0,hidden:!0,onChange:e=>{Qe(e)}}),(0,Y.jsx)(`div`,{ref:y,className:`xterm-host`,style:{width:`100%`,minHeight:0,overflow:`hidden`},onFocusCapture:()=>{v&&z.current?.promote(`focused`)},onMouseDown:()=>{v&&z.current?.promote(`focused`)}}),Pe?(0,Y.jsx)(`div`,{role:`status`,"aria-live":`polite`,style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0,0,0,0.35)`,pointerEvents:`none`,zIndex:5,fontSize:12,color:`var(--text-muted, #ddd)`},children:`Uploading…`}):null,Ge?(0,Y.jsx)(`div`,{className:`paste-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`paste-dialog-title`,children:(0,Y.jsxs)(`div`,{className:`paste-dialog`,children:[(0,Y.jsx)(`h3`,{id:`paste-dialog-title`,className:`paste-dialog__title`,children:a(`terminal.paste_dialog_title`)}),(0,Y.jsx)(`textarea`,{ref:qe,className:`paste-dialog__textarea`,placeholder:a(`terminal.paste_dialog_placeholder`),autoFocus:!0}),(0,Y.jsxs)(`div`,{className:`paste-dialog__actions`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--secondary`,onClick:Xe,children:a(`common.cancel`)}),(0,Y.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--primary`,onClick:()=>{Ye()},children:a(`terminal.paste_dialog_submit`)})]})]})}):null,o!==`mobile`&&de.kind===`queued`?(0,Y.jsx)(Ey,{state:`queued`,queuePosition:de.queuePosition}):null,$e?(0,Y.jsx)(`div`,{className:nt,role:`status`,"aria-live":`polite`,children:(0,Y.jsxs)(`div`,{className:`xterm-replay-overlay__card`,children:[le.kind===`loading`?(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:et}),tt?(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__body`,children:tt}):null]})}):null]})}var nb=({sessionId:e,showHeaderActions:t=!0,showSupervisorInline:n=!0,terminalReadOnlyOverride:r,headerAccessory:i,onClose:a,onSplitHorizontal:o,onSplitVertical:s,onStop:c})=>{let l=H(ap(e)),u=H(Qf(l?.workspaceId??`__workspace_empty__`)),d=H(wa),f=U(wa),p=(0,V.useRef)(null),[m,h]=(0,V.useState)(!1);Bv(l);let{persistUiState:g}=B_(l?.workspaceId??`__workspace_empty__`),_=rg();if((0,V.useEffect)(()=>{if(d!==e)return;let t=p.current;t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),h(!0),f(null);let n=setTimeout(()=>h(!1),1400);return()=>clearTimeout(n)},[d,e,f]),!l)return null;let v=rb(l.state),y=l.title?.trim()||ub(l.id),b=fb(l.providerId),x=db(l.state),S=r??!pb(l.state),C=u?.uiState.activeSessionId===l.id;return(0,Y.jsxs)(`div`,{ref:p,className:`session-card agent-pane${m?` session-card--focus-pulse`:``}`,"data-session-id":e,onClick:e=>{let t=e.target;t instanceof HTMLElement&&(t.closest(`button, a, input, textarea, select, [role="button"]`)||u?.uiState.activeSessionId!==l.id&&(_({workspaceId:l.workspaceId,sessionId:l.id}),g({activeSessionId:l.id})))},children:[(0,Y.jsx)(qm,{"aria-hidden":`true`,className:`session-progress`,fillClassName:`session-progress-bar ${ab(l.state)}`,max:100,tone:ib(l.state),value:v}),(0,Y.jsxs)(`div`,{className:`session-header`,children:[(0,Y.jsxs)(`div`,{className:`session-header-left`,children:[(0,Y.jsx)(xh,{tone:sb(l.state),pulse:cb(l.state),className:`session-dot ${ob(l.state)}`}),(0,Y.jsx)(`div`,{className:`session-header-copy`,children:(0,Y.jsxs)(`div`,{className:`session-title-row`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:y}),(0,Y.jsx)(kh,{color:`blue`,className:`session-provider-badge`,children:b}),(0,Y.jsx)(kh,{color:lb(l.state),className:`session-state-badge`,caps:!1,children:x})]})})]}),t||i?(0,Y.jsxs)(`div`,{className:`session-header-right`,children:[i?(0,Y.jsx)(`div`,{className:`session-header-accessory`,children:i}):null,t?(0,Y.jsxs)(`div`,{className:`session-header-actions`,children:[l.state===`running`?(0,Y.jsx)($,{content:`Stop`,children:(0,Y.jsx)(Z,{"aria-label":`Stop`,className:`session-action-btn`,icon:(0,Y.jsx)(Yi,{size:13}),onClick:()=>void c?.(),size:`sm`})}):null,(0,Y.jsx)($,{content:`Split horizontal`,children:(0,Y.jsx)(Z,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,Y.jsx)(Ji,{size:13}),onClick:()=>o?.(),size:`sm`})}),(0,Y.jsx)($,{content:`Split vertical`,children:(0,Y.jsx)(Z,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,Y.jsx)(qi,{size:13}),onClick:()=>s?.(),size:`sm`})}),(0,Y.jsx)($,{content:`Close`,children:(0,Y.jsx)(Z,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>void a?.(),size:`sm`})})]}):null]}):null]}),n&&l.capability===`full`&&l.state!==`draft`&&l.state!==`ended`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(qv,{sessionId:l.id,workspaceId:l.workspaceId}),(0,Y.jsx)(Wv,{workspaceId:l.workspaceId,sessionId:l.id})]}):null,(0,Y.jsx)(`div`,{className:`session-terminal`,children:(0,Y.jsx)(tb,{terminalId:l.terminalId,workspaceId:l.workspaceId,readOnly:S,isActiveSession:C,terminalKind:`agent`})})]})};function rb(e){switch(e){case`starting`:return 18;case`running`:return 42;case`ended`:return 100;default:return 8}}function ib(e){switch(e){case`starting`:return`warning`;case`running`:return`info`;case`idle`:return`neutral`;case`ended`:return`success`;default:return`neutral`}}function ab(e){switch(e){case`starting`:return`session-progress-starting`;case`running`:return`session-progress-running`;case`idle`:return`session-progress-idle`;case`ended`:return`session-progress-complete`;default:return`session-progress-idle`}}function ob(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 sb(e){switch(e){case`starting`:return`warning`;case`running`:return`info`;case`ended`:return`success`;default:return`neutral`}}function cb(e){switch(e){case`starting`:return!0;default:return!1}}function lb(e){switch(e){case`starting`:return`amber`;case`running`:return`green`;case`ended`:return`blue`;default:return`neutral`}}function ub(e){let t=e.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.replace(/[_-]/g,` `).toUpperCase()}function db(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function fb(e){return e.replace(/\b\w/g,e=>e.toUpperCase())}function pb(e){return e===`running`||e===`idle`||e===`starting`}var mb={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},hb=({hydrateSessions:e=!0})=>{let t=X(),n=H(np),{workspaceId:r,sessions:i,paneLayout:a}=bv(n,{disabled:!e}),o=mv(r),s=yv(),c=sv(a).length>0,l=i.length===0&&(c||a.type===`leaf`&&!a.sessionId&&a.id===`root`);return n?l?(0,Y.jsx)(Ev,{workspaceId:r,onReplaceWithSession:o.replaceWithSession}):(0,Y.jsx)(`div`,{className:`agent-panes`,children:(0,Y.jsx)(gb,{node:a,workspaceId:r,onCloseSession:o.closeSessionPane,onSplitDraftPane:o.splitDraftPane,onSplitSession:o.splitSessionPane,onCloseDraftPane:o.closeDraftPane,onAssignSession:o.assignSession,onReplaceWithSession:o.replaceWithSession,onCloseSessionCommand:s.closeSession,onStopSession:s.stopSession})}):(0,Y.jsx)(`div`,{className:`agent-panes-empty`,children:(0,Y.jsx)(Pm,{style:{padding:0},title:(0,Y.jsx)(`p`,{style:mb,children:t(`workspace.no_workspace`)})})})},gb=({node:e,workspaceId:t,onAssignSession:n,onCloseDraftPane:r,onCloseSession:i,onCloseSessionCommand:a,onReplaceWithSession:o,onSplitDraftPane:s,onSplitSession:c,onStopSession:l})=>{if(e.type===`leaf`)return e.sessionId?(0,Y.jsx)(nb,{sessionId:e.sessionId,onClose:async()=>{i(e.sessionId),await a(e.sessionId)},onSplitHorizontal:()=>c(e.sessionId,`horizontal`),onSplitVertical:()=>c(e.sessionId,`vertical`),onStop:()=>l(e.sessionId)}):(0,Y.jsx)(Ev,{workspaceId:t,paneId:e.id,onAssignSession:n,onClosePane:r,onReplaceWithSession:o,onSplitPane:s});let u=J_(t,e.id)??e.ratio??.5;return(0,Y.jsx)(Dv,{splitId:e.id,direction:e.direction||`horizontal`,ratio:u,onRatioCommit:n=>Y_(t,e.id,n),children:e.children?.map(e=>(0,Y.jsx)(gb,{node:e,workspaceId:t,onAssignSession:n,onCloseDraftPane:r,onCloseSession:i,onCloseSessionCommand:a,onReplaceWithSession:o,onSplitDraftPane:s,onSplitSession:c,onStopSession:l},e.id))})};function _b(){let e=H(np),t=H(Wf),n=U(fg(e?.id??``)),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=e?.id,[f,p]=xe(lg(d??``)),[m,h]=xe(cg(d??``)),g=H(ug(d??``)),_=d?m[f??``]:void 0,v=(0,V.useCallback)(async(e,n)=>{if(!d)return;c(t=>t?.path===e?null:t);let r=await t(`file.read`,{workspaceId:d,path:e});if(!r.ok||!r.data){let t=r.error?.message??`Failed to open file`;console.error(`Failed to open file:`,t),c({path:e,message:t});return}let i=r.data;if(n?.forceText&&i.kind===`image`&&i.isTextBacked){try{let t=await fetch(i.url,{credentials:`include`});if(!t.ok){let n=`Failed to fetch text-backed image bytes: ${t.status}`;console.error(n),c({path:e,message:n});return}let n={kind:`text`,path:e,content:await t.text(),baseHash:``,isDirty:!1,viewingTextBackedImageAsText:!0};h(t=>({...t,[e]:n})),c(t=>t?.path===e?null:t)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch text-backed image bytes`;console.error(`Failed to fetch text-backed image bytes:`,t),c({path:e,message:n})}return}let a=i.kind===`text`?{kind:`text`,path:e,content:i.content,baseHash:i.baseHash,isDirty:!1,externalState:void 0}:{kind:`image`,path:e,mime:i.mime,url:i.url,size:i.size,isTextBacked:i.isTextBacked,externalState:void 0};h(t=>({...t,[e]:a})),u(t=>t?.path===e?null:t),c(t=>t?.path===e?null:t)},[t,h,d]),y=(0,V.useCallback)(async()=>{if(!d||!_||_.kind!==`text`||r)return;i(!0),o(null);let e=await t(`file.write`,{workspaceId:d,path:_.path,content:_.content,baseHash:_.baseHash||void 0});e.ok&&e.data?(h(t=>{let n=t[_.path];return!n||n.kind!==`text`?t:{...t,[_.path]:{...n,baseHash:e.data.newHash,isDirty:!1,externalState:void 0}}}),u(e=>e?.path===_.path?null:e)):o(e.error?.message??`Failed to save file`),i(!1)},[_,t,r,h,d]),b=(0,V.useCallback)(e=>{!d||!_||_.kind!==`text`||h(t=>{let n=t[_.path];return!n||n.kind!==`text`?t:{...t,[_.path]:{...n,content:e,isDirty:e!==n.content}}})},[_,h,d]);(0,V.useEffect)(()=>{!d||!f||m[f]||v(f)},[f,v,m,d]),(0,V.useEffect)(()=>{if(!d||g<=0)return;let e=Object.entries(m);if(e.length===0)return;let n=!1;return(async()=>{for(let[r,i]of e){let e=await t(`file.read`,{workspaceId:d,path:r});if(n)return;if(!e.ok||!e.data){let t=e.error?.code===`not_found`;h(e=>{let n=e[r];return n?{...e,[r]:{...n,externalState:t?`deleted`:n.externalState}}:e}),t&&f===r&&u({path:r,status:`deleted`});continue}let a=e.data;if(i.kind===`text`&&a.kind===`text`){if(a.baseHash===i.baseHash)continue;if(i.isDirty){h(e=>{let t=e[r];return!t||t.kind!==`text`?e:{...e,[r]:{...t,externalState:`modified`}}}),f===r&&u({path:r,status:`modified`});continue}h(e=>({...e,[r]:{kind:`text`,path:r,content:a.content,baseHash:a.baseHash,isDirty:!1,externalState:void 0,viewingTextBackedImageAsText:i.viewingTextBackedImageAsText}})),f===r&&u(e=>e?.path===r?null:e);continue}if(i.kind===`image`&&a.kind===`image`){if(i.url===a.url&&i.size===a.size)continue;h(e=>({...e,[r]:{kind:`image`,path:r,mime:a.mime,url:a.url,size:a.size,isTextBacked:a.isTextBacked,externalState:void 0}})),f===r&&u(e=>e?.path===r?null:e);continue}h(e=>{let t={...e};return delete t[r],t}),f===r&&u({path:r,status:`modified`})}})(),()=>{n=!0}},[f,t,g,m,h,d]);let x=(0,V.useCallback)(()=>{if(!d)return;let e=_?.path;p(null),e&&h(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n}),o(null)},[_,p,h,d]),S=(0,V.useCallback)(()=>{if(!d||!_)return;let e=_.path,t=_.kind===`image`;h(t=>{let n={...t};return delete n[e],n}),v(e,t?{forceText:!0}:void 0)},[_,v,h,d]),C=(0,V.useCallback)(async()=>{if(!d||!_)return!1;let e=await t(`git.diff`,{workspaceId:d,path:_.path,staged:!1});return!e.ok||!e.data?!1:(n({path:_.path,diff:e.data.diff,staged:!1}),!0)},[_,t,n,d]),w=_?.kind===`text`,T=_?.kind===`image`,E=T&&_.isTextBacked||w&&_.viewingTextBackedImageAsText===!0,D=!!(w&&_.isDirty&&!r),O=f&&s?.path===f?s.message:null;return{activeFilePath:f,activeExternalStatus:f&&l?.path===f?l.status:null,activeLoadError:O,canSave:D,currentFile:_,handleClose:x,handleContentChange:b,handleSave:y,isImageFile:T,isSaving:r,isSvgTextBacked:E,isTextFile:w,openInDiffMode:C,saveError:a,toggleSvgTextMode:S,workspace:e,workspaceId:d}}function vb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function yb(e){return(e.split(`/`)[1]??e).split(`+`)[0].replace(/^x-/,``).toUpperCase()}var bb=({url:e,mime:t,sizeBytes:n,alt:r})=>{let[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{a(null),s(!1)},[e]),(0,Y.jsxs)(`div`,{className:`image-preview`,children:[(0,Y.jsx)(`div`,{className:`image-preview-canvas`,children:o?(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.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,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:`Preview unavailable`})}):(0,Y.jsx)(`img`,{className:`image-preview-img`,src:e,alt:r,draggable:!1,onLoad:e=>{let t=e.currentTarget;a({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>s(!0)})}),(0,Y.jsxs)(`div`,{className:`image-preview-meta`,children:[(0,Y.jsx)(`span`,{className:`image-preview-type`,children:yb(t)}),i&&(0,Y.jsxs)(`span`,{className:`image-preview-dim`,children:[i.w,` × `,i.h]}),(0,Y.jsx)(`span`,{className:`image-preview-size`,children:vb(n)})]})]})},xb=({state:e,variant:t=`full`})=>{let n=X(),{canSave:r,handleClose:i,handleSave:a,isImageFile:o,isSaving:s,isSvgTextBacked:c,toggleSvgTextMode:l}=e,u=n(s?`code_editor.saving`:`action.save_file`),d=n(o?`code_editor.edit_as_text`:`code_editor.preview_as_image`),f=n(o?`code_editor.mode_text`:`code_editor.mode_image`);return t===`mobile`?(0,Y.jsxs)(`div`,{className:`mobile-sheet__header-actions`,children:[c?(0,Y.jsx)($,{content:d,children:(0,Y.jsx)(Z,{"aria-label":d,className:`mobile-sheet__action mobile-sheet__action--icon`,icon:o?(0,Y.jsx)(vi,{size:16}):(0,Y.jsx)(Di,{size:16}),onClick:l})}):null,(0,Y.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:a,disabled:!r,"aria-label":u,children:u})]}):(0,Y.jsxs)(`div`,{className:`code-mode-toggle`,children:[c&&(0,Y.jsx)($,{content:d,children:(0,Y.jsxs)(`button`,{type:`button`,className:`code-mode-btn`,onClick:l,"aria-label":d,children:[o?(0,Y.jsx)(vi,{size:12}):(0,Y.jsx)(Di,{size:12}),(0,Y.jsx)(`span`,{children:f})]})}),(0,Y.jsx)($,{content:u,disabled:!r,children:(0,Y.jsxs)(`button`,{type:`button`,className:`code-mode-btn`,onClick:a,disabled:!r,"aria-label":u,children:[(0,Y.jsx)(Ui,{size:12}),(0,Y.jsx)(`span`,{children:u})]})}),(0,Y.jsx)($,{content:n(`action.close`),children:(0,Y.jsx)(Z,{"aria-label":n(`action.close`),className:`code-mode-btn`,icon:(0,Y.jsx)(ea,{size:12}),onClick:i,size:`sm`})})]})},Sb=({state:e,chrome:t=`full`})=>{let n=X(),{activeFilePath:r,activeExternalStatus:i,activeLoadError:a,currentFile:o,handleContentChange:s,handleSave:c,isImageFile:l,isTextFile:u,saveError:d,workspace:f}=e;if(!f)return(0,Y.jsx)(`div`,{className:`workspace-git-view`,children:(0,Y.jsx)(`div`,{className:`code-editor workspace-git-editor`,children:(0,Y.jsx)(`div`,{className:`code-editor-body`,children:(0,Y.jsx)(Pm,{className:`git-diff-empty`,title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`workspace.no_workspace`)})})})})});let p=u&&o.isDirty?(0,Y.jsx)(`span`,{className:`dirty-indicator`,children:`*`}):null;return(0,Y.jsx)(`div`,{className:`workspace-git-view`,children:(0,Y.jsxs)(`div`,{className:`code-editor workspace-git-editor`,children:[t===`full`?(0,Y.jsxs)(`div`,{className:`code-editor-header`,children:[(0,Y.jsx)(`span`,{className:`code-file-path`,children:o?(0,Y.jsxs)(Y.Fragment,{children:[o.path,p]}):r||n(`file.title`)}),(0,Y.jsx)(xb,{state:e})]}):null,d&&(0,Y.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,Y.jsx)(Q,{semantic:`state.error`,size:14}),(0,Y.jsx)(`span`,{children:d})]}),i&&(0,Y.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,Y.jsx)(Q,{semantic:i===`deleted`?`state.fileDeleted`:`state.fileModified`,size:14}),(0,Y.jsx)(`span`,{children:n(i===`deleted`?`code_editor.deleted_on_disk`:`code_editor.modified_on_disk`)})]}),(0,Y.jsx)(`div`,{className:`code-editor-body`,children:u?(0,Y.jsx)(a_,{workspaceId:f.id,filePath:o.path,content:o.content,onContentChange:s,onSave:c}):l?(0,Y.jsx)(bb,{url:o.url,mime:o.mime,sizeBytes:o.size,alt:o.path}):a?(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.jsx)(`p`,{className:`git-diff-empty-body`,children:a}),role:`alert`,title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`code_editor.open_failed_title`)})}):r?(0,Y.jsx)(Pm,{className:`git-diff-empty`,title:(0,Y.jsxs)(`p`,{className:`git-diff-empty-title`,children:[n(`status.connecting`),`…`]})}):(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.jsx)(`p`,{className:`git-diff-empty-body`,children:n(`code_editor.empty_hint`)}),title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`file.title`)})})})]})})},Cb=({chrome:e=`full`,editorState:t})=>(0,Y.jsx)(Sb,{state:t??_b(),chrome:e}),wb=`__terminal_panel_empty__`;function Tb(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 Eb(e){return{id:e.id,workspaceId:e.workspaceId,kind:e.kind,alive:e.alive,exitCode:e.exitCode,title:e.title}}function Db(){let e=X(),t=H(tp),n=H(Wf),r=H(If),i=U(zg),a=me(),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(null),u=(0,V.useRef)(null),d=H(Yv(c??wb)),f=c?d:null;(0,V.useEffect)(()=>{if(!t){s([]),l(null);return}let r=!1;return s([]),l(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(Yv(e.id),Eb(e));s(e=>Tb(e,o)),l(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,V.useEffect)(()=>{if(!r||!t)return;let e=Df.terminalsAll(t);return u.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;s(t=>t.includes(e.id)?t:[...t,e.id]),l(e.id);return}if(o!==`output`)return;let c=a.get(Yv(i));if(!c||c.kind!==`shell`)return;let u=t,d=Jv(i),f=a.get(d);n<=f.lastSeq||a.set(d,{chunks:[...f.chunks,u.bytes],lastSeq:n})}),()=>{u.current?.(),u.current=null}},[t,a,r]);let p=(0,V.useCallback)(async()=>{if(!t){i({kind:`warning`,title:e(`terminal.create_unavailable_title`),body:e(`terminal.create_unavailable_body`)});return}try{let r=await n(`terminal.create`,{workspaceId:t,kind:`shell`});if(!r.ok||!r.data){i({kind:`error`,title:e(`terminal.create_failed_title`),body:r.error?.message??e(`terminal.create_failed_body`)});return}let o=r.data;a.set(Yv(o.id),Eb(o)),s(e=>e.includes(o.id)?e:[...e,o.id]),l(o.id)}catch(t){i({kind:`error`,title:e(`terminal.create_failed_title`),body:t instanceof Error?t.message:e(`terminal.create_failed_body`)})}},[t,n,i,a,e]);return{activeTerminalId:c,activeTerminalMeta:f,activeWorkspaceId:t,handleCloseTerminal:(0,V.useCallback)(async e=>{(await n(`terminal.close`,{terminalId:e})).ok&&s(t=>{let n=t.filter(t=>t!==e);return l(t=>t===e?n[0]??null:t),n})},[n]),handleCreateTerminal:p,handleSwitchTerminal:(0,V.useCallback)(e=>{l(e)},[]),hasTerminals:o.length>0,terminalIds:o}}function Ob(e,t,n){let r=e?.title?.trim(),i=kb(r);return!r||Ab(r,n)?`${i??n} — ${t+1}`:i?`${i} — ${t+1}`:r}function kb(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 Ab(e,t){let n=e.toLowerCase();return n===t.trim().toLowerCase()||n===`shell terminal`||n===`shell 终端`}function jb({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=X(),o=Ob(H(Yv(e)),t,a(`terminal.shell`));return(0,Y.jsxs)(`div`,{className:`terminal-selector-item ${n?`terminal-selector-item-active`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`terminal-selector-item-trigger`,onClick:r,children:(0,Y.jsx)(`span`,{className:`terminal-selector-item-title`,children:o})}),(0,Y.jsx)(Z,{"aria-label":a(`action.close`),className:`terminal-selector-item-close`,icon:(0,Y.jsx)(ea,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function Mb({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=X(),o=Ob(H(Yv(e)),t,a(`terminal.shell`));return(0,Y.jsxs)(`div`,{className:`terminal-tab-shell ${n?`active`:``}`,role:`presentation`,children:[(0,Y.jsx)($m,{className:`terminal-tab ${n?`terminal-tab-active`:``}`,onClick:r,value:e,children:(0,Y.jsx)(`span`,{className:`terminal-tab-title`,children:o})}),(0,Y.jsx)(Z,{"aria-label":a(`action.close`),className:`terminal-tab-close`,icon:(0,Y.jsx)(ea,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function Nb({chrome:e=`default`}){let t=X(),n=me(),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1),{activeTerminalId:s,activeTerminalMeta:c,activeWorkspaceId:l,handleCloseTerminal:u,handleCreateTerminal:d,handleSwitchTerminal:f,hasTerminals:p,terminalIds:m}=Db(),h=s?m.indexOf(s):0,g=Ob(c,h>=0?h:0,t(`terminal.shell`)),_=s??m[0]??``,v=e===`mobile-fullscreen`,y=p&&(!v||m.length>1),b=m.length>1&&!v,x=m.map((e,r)=>({value:e,label:Ob(n.get(Yv(e)),r,t(`terminal.shell`))}));return(0,V.useEffect)(()=>{(!y||m.length<=1)&&(i(!1),o(!1))},[y,m.length]),(0,Y.jsxs)(`div`,{className:`bottom-terminal${v?` bottom-terminal--mobile-fullscreen`:``}`,children:[(0,Y.jsxs)(`div`,{className:`terminal-toolbar`,children:[(0,Y.jsx)(`div`,{className:`terminal-toolbar-left`,children:v?null:(0,Y.jsxs)(`div`,{className:`terminal-title-stack`,children:[(0,Y.jsx)(`span`,{className:`terminal-kicker`,children:t(`terminal.kicker`)}),c?(0,Y.jsx)(`span`,{className:`terminal-title`,children:g}):null]})}),(0,Y.jsxs)(`div`,{className:`terminal-toolbar-right`,children:[p&&(0,Y.jsxs)(Y.Fragment,{children:[y?(0,Y.jsxs)(`div`,{className:`terminal-selector`,children:[v?(0,Y.jsx)(mh,{mobile:!0,"aria-label":t(`terminal.selector.switch`),"aria-expanded":a,className:`terminal-selector-btn`,includeValueInAriaLabel:!1,options:x,value:_,valueLabel:g,onClick:e=>{a&&(e.preventDefault(),o(!1))},onOpen:()=>o(!0)}):m.length>1?(0,Y.jsx)(om,{content:(0,Y.jsx)(Y.Fragment,{children:m.map((e,t)=>(0,Y.jsx)(jb,{id:e,index:t,isActive:e===s,onSelect:()=>{f(e),i(!1)},onClose:()=>{i(!1),u(e)}},e))}),contentClassName:`terminal-selector-dropdown`,forceMode:`desktop`,open:r,placement:`bottom-end`,title:t(`terminal.selector.title`),onOpenChange:i,children:(0,Y.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":g,children:[(0,Y.jsx)(`span`,{children:g}),(0,Y.jsx)(si,{size:12})]})}):(0,Y.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":g,children:[(0,Y.jsx)(`span`,{children:g}),(0,Y.jsx)(si,{size:12})]}),v&&a?(0,Y.jsx)(sh,{className:`mobile-select-sheet--command`,title:t(`terminal.selector.title`),sections:[{kind:`options`,id:`terminals`,items:x.map((e,n)=>({id:e.value,label:e.label,meta:e.value===s?t(`terminal.selector.current`):t(`terminal.selector.indexed`,{index:n+1})}))}],selectedId:s,onSelect:f,onClose:()=>o(!1)}):null]}):null,(0,Y.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,Y.jsx)($,{content:t(`action.close`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":t(`terminal.close_terminal`),icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>{s&&(i(!1),o(!1),u(s))},size:`sm`})})})]}),(0,Y.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,Y.jsx)($,{content:t(`action.open`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":t(`terminal.new_terminal`),icon:(0,Y.jsx)(Q,{semantic:`terminal.action.new`,size:14}),onClick:d,size:`sm`})})})]})]}),(0,Y.jsx)(`div`,{className:`bottom-terminal-content`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[b?(0,Y.jsx)(Zm,{"aria-label":t(`terminal.selector.title`),className:`bottom-terminal-tabs-nav`,onValueChange:f,value:_,children:(0,Y.jsx)(Qm,{className:`bottom-terminal-tabs`,children:m.map((e,t)=>(0,Y.jsx)(Mb,{id:e,index:t,isActive:e===_,onSelect:()=>f(e),onClose:()=>u(e)},e))})}):null,c&&l&&(0,Y.jsx)(`div`,{className:`bottom-terminal-xterm`,children:(0,Y.jsx)(tb,{terminalId:c.id,workspaceId:l,terminalKind:c.kind??`shell`})})]}):(0,Y.jsx)(Pm,{action:(0,Y.jsx)(Lp,{variant:`primary`,size:`sm`,onClick:d,leadingIcon:(0,Y.jsx)(Q,{semantic:`terminal.action.new`,size:14}),children:t(`terminal.new_terminal`)}),className:`bottom-terminal-empty`,description:(0,Y.jsx)(`p`,{className:`bottom-terminal-empty-hint`,children:t(`terminal.empty_hint`)}),icon:(0,Y.jsx)(Q,{className:`bottom-terminal-empty-icon`,semantic:`state.emptyTerminal`,size:32}),title:(0,Y.jsx)(`p`,{className:`bottom-terminal-empty-text`,children:t(`terminal.no_terminal`)})})})]})}function Pb({controller:e,className:t,iconSize:n,dataTestId:r}){let i=X();if(!e)return null;let a=e.isFullscreen?i(`tooltip.exit_fullscreen`):i(`tooltip.enter_fullscreen`);return(0,Y.jsx)($,{content:a,children:(0,Y.jsx)(Z,{"aria-label":a,className:t,"data-testid":r,icon:(0,Y.jsx)(e.isFullscreen?Mi:Ai,{size:n}),onClick:()=>{e.toggleFullscreen()}})})}var Fb=()=>{let e=X(),t=H(Lf);if(t===`connected`)return null;let n=`connection-status-${t}`,r=`connection-status-dot connection-status-dot-${t}`,i=e(`status.${t}`);return(0,Y.jsx)($,{content:i,children:(0,Y.jsxs)(`div`,{className:`connection-status ${n}`,"aria-label":i,children:[(0,Y.jsx)(xh,{tone:Ib(t),size:`sm`,pulse:Lb(t),className:r}),(0,Y.jsx)(`span`,{className:`connection-status-text`,children:i})]})})};function Ib(e){switch(e){case`connected`:return`success`;case`disconnected`:return`error`;default:return`warning`}}function Lb(e){switch(e){case`connecting`:case`reconnecting`:return!0;default:return!1}}function Rb(){let e=qt(),t=H(Wf),n=H(Yf),r=U(qf),i=U(Jf),a=U(Yf);return(0,V.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 zb=({workspace:e,isActive:t})=>{let n=X(),r=Rb(),i=ig(),a=Xh(e)||e.id;return(0,Y.jsxs)(`div`,{className:`topbar-tab-shell ${t?`active`:``}`,role:`presentation`,children:[(0,Y.jsxs)($m,{className:`topbar-tab`,onClick:n=>{n.preventDefault(),!t&&i(e.id)},value:e.id,children:[(0,Y.jsx)(`span`,{className:`topbar-dot ${e.isActive?`active`:`idle`}`}),(0,Y.jsx)($,{content:e.path||e.id,children:(0,Y.jsx)(`span`,{className:`topbar-tab-name`,children:a})}),(0,Y.jsx)(Ap,{count:e.unreadCount??0,max:9})]}),(0,Y.jsx)(Z,{className:`topbar-close`,"aria-label":n(`action.close_workspace`),icon:(0,Y.jsx)(ea,{size:14}),onClick:async t=>{t.stopPropagation(),await r(e.id)},size:`sm`})]})},Bb={width:`auto`,minHeight:`auto`,padding:0,gap:0},Vb={color:`var(--text-tertiary)`,fontSize:`var(--text-sm)`,fontWeight:`var(--font-normal)`},Hb=({fullscreenController:e})=>{let t=X(),n=qt(),r=H(ep),i=H(tp)??r[0]?.id??``,a=ig(),[o,s]=xe(Ca),[c,l]=xe(Cg),[u,d]=xe(Sg),[f,p]=(0,V.useState)(!1);return(0,Y.jsxs)(`header`,{className:`app-topbar`,children:[(0,Y.jsxs)(`div`,{className:`topbar-tabs`,children:[r.length===0?(0,Y.jsx)(Pm,{className:`topbar-empty-state`,style:Bb,title:(0,Y.jsx)(`span`,{className:`topbar-hint`,style:Vb,children:t(`workspace.no_workspace`)})}):(0,Y.jsx)(Zm,{"aria-label":t(`workspace.tabs`),className:`topbar-tabs-nav`,onValueChange:e=>{a(e)},value:i,children:(0,Y.jsx)(Qm,{className:`topbar-tablist`,children:r.map(e=>(0,Y.jsx)(zb,{workspace:e,isActive:e.id===i},e.id))})}),(0,Y.jsx)($,{content:t(`tooltip.new_workspace`),children:(0,Y.jsx)(Z,{"aria-label":t(`tooltip.new_workspace`),className:`topbar-add`,icon:(0,Y.jsx)(Q,{semantic:`nav.newWorkspace`,size:14}),onClick:()=>p(!0)})})]}),(0,Y.jsxs)(`div`,{className:`topbar-actions`,children:[(0,Y.jsx)(Fb,{}),(0,Y.jsx)($,{content:t(`tooltip.quick_actions`),children:(0,Y.jsxs)(`button`,{className:`topbar-btn topbar-quick-actions`,onClick:()=>s(!o),"aria-label":t(`tooltip.quick_actions`),children:[(0,Y.jsx)(Q,{semantic:`nav.search`,size:14}),(0,Y.jsx)(`span`,{className:`topbar-btn-label`,children:t(`tooltip.quick_actions`)})]})}),(0,Y.jsx)($,{content:t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),children:(0,Y.jsx)(Z,{"aria-label":t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),className:`topbar-btn ${c?`topbar-btn--active`:`topbar-btn--muted`}`,icon:(0,Y.jsx)(Q,{semantic:`nav.panelTerminal`,size:14}),onClick:()=>l(!c)})}),(0,Y.jsx)($,{content:t(u?`tooltip.show_files`:`tooltip.hide_files`),children:(0,Y.jsx)(Z,{"aria-label":t(u?`tooltip.show_files`:`tooltip.hide_files`),className:`topbar-btn ${u?`topbar-btn--muted`:`topbar-btn--active`}`,icon:(0,Y.jsx)(Q,{semantic:`nav.panelFiles`,size:14}),onClick:()=>d(!u)})}),(0,Y.jsx)($,{content:t(`settings.title`),children:(0,Y.jsx)(Z,{"aria-label":t(`settings.title`),className:`topbar-btn`,"data-testid":`settings-open`,icon:(0,Y.jsx)(Q,{semantic:`nav.settings`,size:14}),onClick:()=>n(`/settings`)})}),(0,Y.jsx)(Pb,{controller:e,className:`topbar-btn`,iconSize:14,dataTestId:`workspace-fullscreen-open`})]}),f?(0,Y.jsx)(Ag,{onClose:()=>p(!1)}):null]})};function Ub(e){return e?.source===`commit`}var Wb=180*1e3,Gb={push:`git.operation_push`,pull:`git.operation_pull`,fetch:`git.operation_fetch`};function Kb(e,t){return e&&t?`${e}/${t}`:null}function qb(e){let t=X(),n=H(Wf),r=U(zg),i=U(dg(e)),a=U(mg(e)),o=U(og(e)),s=U(vg(e)),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=(0,V.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(Gb[e.operation])}):t(`git.auth_required_message`,{remote:e.remoteLabel}):t(`git.auth_failed_unsupported`,{remote:e.remoteLabel}),[t]),p=(0,V.useCallback)((e,n,r)=>{if(e===`git.fetch`)return n.message||r;let i=Kb(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,V.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,V.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:Wb});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,V.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,V.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,V.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 Jb(e){let t=[{title:`staged`,type:`staged`,changes:e.staged},{title:`modified`,type:`modified`,changes:e.modified},{title:`deleted`,type:`deleted`,changes:e.deleted},{title:`untracked`,type:`untracked`,changes:e.untracked}];for(let e of t)if(e.changes[0])return{change:e.changes[0],type:e.type};return null}function Yb(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 Xb({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,initialHistoryLimit:r=5}){let i=X(),a=H(dg(e)),o=H(fg(e)),s=H(pg(e)),c=H(Wf),l=U(zg),u=U(dg(e)),d=U(mg(e)),f=U(fg(e)),p=U(pg(e)),[m,h]=xe(gg(e)),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)([]),[b,x]=(0,V.useState)(r),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),E=(0,V.useRef)(!1),D=(0,V.useRef)(!1),O=(0,V.useCallback)(e=>{d({current:e?.current??``,branches:e?.branches??[],loading:!1})},[d]),k=(0,V.useCallback)(e=>{f(e)},[f]),A=(0,V.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`};return p(!1),k(i),i},[c,p,k,e]),j=(0,V.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),k(i),n?.(i),i},[c,n,p,k,e]),M=(0,V.useCallback)(async(e,t)=>{let r=await A(e,t);r&&n?.(r)},[n,A]),N=(0,V.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}O(t.data)},[c,d,O,e]),P=(0,V.useCallback)(async(t=b)=>{if(e){C(!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),y([]);return}y(Array.isArray(n.data?.entries)?n.data.entries:[])}finally{C(!1)}}},[c,b,e]),F=(0,V.useCallback)(async()=>{if(e){if(E.current){D.current=!0;return}E.current=!0,_(!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){k(null);return}if(Ub(o))return;let n=(o?Yb(t.data,o.path):null)??Jb(t.data);if(!n){k(null);return}(!o||o.path!==n.change.path||!!o.staged!=(n.type===`staged`))&&await A(n.change,n.type)}finally{E.current=!1,_(!1),D.current&&(D.current=!1,queueMicrotask(()=>{F()}))}}},[o,s,c,A,u,k,e]);(0,V.useEffect)(()=>{!a&&!E.current&&F()},[a,F]),(0,V.useEffect)(()=>{N()},[N]),(0,V.useEffect)(()=>{P(b)},[a?.headSha,b,P]),(0,V.useEffect)(()=>{if(!a||s||Ub(o))return;if(o){let e=Yb(a,o.path);if(e&&!!o.staged==(e.type===`staged`))return}let e=Jb(a);if(!e){k(null);return}A(e.change,e.type)},[o,s,a,A,k]),(0,V.useEffect)(()=>{t>0&&!E.current&&F()},[t,F]);let ee=(0,V.useCallback)(async(e,t,n,r,i)=>{let a=await c(e,t);return a.ok?(i?.(),await F(),!0):(l({kind:`error`,title:r,body:a.error?.message??n}),console.error(n,a.error?.message),!1)},[c,F,l]),I=(0,V.useCallback)(async t=>{t.length!==0&&await ee(`git.stage`,{workspaceId:e,paths:t},`Failed to stage all:`,i(`git.stage_failed_title`))},[ee,i,e]),te=(0,V.useCallback)(async t=>{t.length!==0&&await ee(`git.unstage`,{workspaceId:e,paths:t},`Failed to unstage all:`,i(`git.unstage_failed_title`))},[ee,i,e]),L=(0,V.useCallback)(async()=>{await I([...a?.modified.map(e=>e.path)??[],...a?.deleted.map(e=>e.path)??[],...a?.untracked.map(e=>e.path)??[]])},[a,I]),R=(0,V.useCallback)(async()=>{await te(a?.staged.map(e=>e.path)??[])},[a,te]),z=(0,V.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&&T({scope:`all`,paths:e})},[a]),ne=(0,V.useCallback)(e=>{e.length&&T({scope:`all`,paths:e})},[]),re=(0,V.useCallback)(e=>{T({scope:`single`,paths:[e],filePath:e})},[]),ie=(0,V.useCallback)(()=>{T(null)},[]),B=(0,V.useCallback)(async()=>{if(!w)return;let t=w;T(null),await ee(`git.discard`,{workspaceId:e,paths:t.paths},t.scope===`all`?`Failed to discard all:`:`Failed to discard:`,i(`git.discard_failed_title`))},[w,ee,i,e]),ae=(0,V.useCallback)(async()=>{!m.trim()||!a?.staged.length||await ee(`git.commit`,{workspaceId:e,message:m.trim()},`Failed to commit:`,i(`git.commit_failed_title`),()=>h(``))},[m,a?.staged.length,ee,i,e]),oe=!!(a&&(a.staged.length>0||a.modified.length>0||a.untracked.length>0||a.deleted.length>0));return{commitMessage:m,diffPreview:o,gitState:a,groups:(0,V.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:oe,history:v,historyLimit:b,historyLoading:S,isLoading:g,pendingDiscard:w,canShowMoreHistory:b<10&&v.length>0,setCommitMessage:h,handleCancelDiscard:ie,handleCommit:ae,handleConfirmDiscard:B,handleDiscardAll:z,handleRequestDiscardPaths:ne,handleRequestDiscardSingle:re,handleStageAll:L,handleStagePaths:I,handleUnstageAll:R,handleUnstagePaths:te,loadGitStatus:F,loadGitHistory:P,openDiff:M,openHistoryDiff:j,requestDiff:A,runGitMutation:ee,showMoreHistory:()=>x(10),t:i}}function Zb(e){let t=H(fg(e)),n=U(fg(e)),r=U(pg(e));return{closePreview:()=>{r(!0),n(null)},preview:t}}function Qb(){let e=X(),t=H(hg),n=U(hg),r=H(Wf),i=U(zg),a=t.workspaceId,o=H(mg(a??``)),s=U(mg(a??``)),{refreshBranchState:c}=qb(a??``),[l,u]=(0,V.useState)(t.inputValue),[d,f]=(0,V.useState)(0),[p,m]=(0,V.useState)(null);(0,V.useEffect)(()=>{u(t.inputValue)},[t.inputValue]),(0,V.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,V.useMemo)(()=>o.branches.filter(e=>(e.isCurrent||!e.linkedWorktreePath)&&e.name.toLowerCase().includes(l.toLowerCase())),[o.branches,l]),_=(0,V.useCallback)(e=>e.isCurrent||!e.linkedWorktreePath,[]),v=g.find(e=>e.name.toLowerCase()===l.toLowerCase()),y=(0,V.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,V.useMemo)(()=>y.findIndex(e=>e.type===`branch`&&e.branch&&(e.branch.isCurrent||e.branch.name===o.current)),[o.current,y]);(0,V.useEffect)(()=>{if(t.visible){if(m(null),h){f(0);return}f(b>=0?b:0)}},[b,t.visible,h]);let x=(0,V.useCallback)(()=>{m(null),n({visible:!1,inputValue:``})},[n]),S=(0,V.useCallback)(e=>{e&&m(e)},[]),C=(0,V.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,V.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 $b(e){let t=e;return e.fullscreenElement??t.webkitCurrentFullScreenElement??null}function ex(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 tx(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 nx(e){return!!(ex(e)&&tx(document))}function rx(e){return e instanceof Error&&e.message.trim().length>0?e.message:null}function ix(e){let t=X(),n=U(zg),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1),s=(0,V.useCallback)(()=>{n({kind:`info`,title:t(`workspace.fullscreen.unsupported_title`),body:t(`workspace.fullscreen.unsupported_body`)})},[n,t]);(0,V.useEffect)(()=>{let t=()=>{let t=e.current;i(nx(t)),o(!!(t&&$b(document)===t))};return t(),document.addEventListener(`fullscreenchange`,t),document.addEventListener(`webkitfullscreenchange`,t),()=>{document.removeEventListener(`fullscreenchange`,t),document.removeEventListener(`webkitfullscreenchange`,t)}},[e]);let c=(0,V.useCallback)(async()=>{let r=e.current,i=ex(r);if(!i||!tx(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:rx(e)??t(`workspace.fullscreen.enter_failed_body`)})}},[n,s,t,e]),l=(0,V.useCallback)(async()=>{let e=tx(document);if($b(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:rx(e)??t(`workspace.fullscreen.exit_failed_body`)})}}},[n,s,t]);return{supported:r,isFullscreen:a,enterFullscreen:c,exitFullscreen:l,toggleFullscreen:(0,V.useCallback)(async()=>{if(e.current&&$b(document)===e.current){await l();return}await c()},[c,l,e])}}var ax=220,ox=120;function sx(e,t,n){if(e>0)return e;let r=Number.parseFloat(t);return Number.isFinite(r)&&r>0?r:n}function cx(){let[e,t]=xe(bg),[n,r]=xe(xg),i=(0,V.useRef)(!1),a=(0,V.useRef)(null),o=(0,V.useRef)(0),s=(0,V.useRef)(0),c=(0,V.useRef)(e),l=(0,V.useRef)(null),u=(0,V.useCallback)(n=>{n.preventDefault(),i.current=!0,o.current=n.clientX,s.current=sx(a.current?.offsetWidth??0,a.current?.style.width??``,e),c.current=s.current,document.body.classList.add(`is-resizing-panels`);let r=e=>{if(!i.current)return;let t=e.clientX-o.current,n=Math.max(ax,s.current+t);c.current=n,a.current&&(a.current.style.width=`${n}px`)},l=()=>{i.current=!1,document.body.classList.remove(`is-resizing-panels`),t(c.current),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,l)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,l)},[t,e]),d=(0,V.useRef)(!1),f=(0,V.useRef)(0),p=(0,V.useRef)(0),m=(0,V.useRef)(n);return{bottomPanelHeight:n,bottomPanelRef:l,handleBottomMouseDown:(0,V.useCallback)(e=>{e.preventDefault(),d.current=!0,f.current=e.clientY,p.current=sx(l.current?.offsetHeight??0,l.current?.style.height??``,n),m.current=p.current,document.body.classList.add(`is-resizing-panels`);let t=e=>{if(!d.current)return;let t=f.current-e.clientY,n=Math.max(ox,p.current+t);m.current=n,l.current&&(l.current.style.height=`${n}px`)},i=()=>{d.current=!1,document.body.classList.remove(`is-resizing-panels`),r(m.current),document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,i)},[r,n]),handleLeftMouseDown:u,leftPanelRef:a,leftPanelWidth:e}}function lx(){let e=H(np),t=e?.id??`__workspace_placeholder__`,n=H(tp),r=U(qf),i=H(ep),a=H(dg(t)),o=H(lg(t)),s=H(fg(t)),c=H(yg),l=H(Cg),u=H(Sg),{sessions:d,paneLayout:f}=bv(e),p=H(Wf),m=U(hg),h=me(),g=cx(),_=mv(t),v=yv(),[y,b]=(0,V.useState)(`files`),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(0),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)({kind:`root`}),[k,A]=(0,V.useState)(null),j=(0,V.useRef)(0);(0,V.useEffect)(()=>{if(!e){r(null);return}return r(e.id),()=>{r(t=>t===e.id?null:t)}},[r,e]),(0,V.useEffect)(()=>{if(!e||a)return;let t=!1;return p(`git.status`,{workspaceId:e.id}).then(n=>{t||!n.ok||!n.data||h.set(dg(e.id),n.data)}).catch(e=>{t||console.error(`Failed to load git status:`,e)}),()=>{t=!0}},[p,a,h,e]);let M=(0,V.useCallback)(()=>{e&&(b(`git`),m({visible:!0,workspaceId:e.id,inputValue:``}))},[m,e]),N=(0,V.useCallback)(()=>{S(e=>({id:(e?.id??0)+1,mode:`file`,baseDir:null}))},[]),P=(0,V.useCallback)(()=>{S(e=>({id:(e?.id??0)+1,mode:`folder`,baseDir:null}))},[]),F=(0,V.useCallback)(()=>{S(null)},[]),ee=(0,V.useCallback)(()=>{w(e=>e+1)},[]),I=(0,V.useMemo)(()=>{let e=new Map(d.map(e=>[e.id,e]));return Array.from(new Set(sv(f))).map(t=>e.get(t)).filter(e=>!!e)},[f,d]),te=(0,V.useMemo)(()=>{let e=new Set(I.map(e=>e.id));return[...I,...d.filter(t=>t.state!==`draft`&&!e.has(t.id))]},[I,d]),L=te.find(e=>e.id===k)??null,R=(0,V.useCallback)(e=>{e&&!I.some(t=>t.id===e)&&d.some(t=>t.id===e&&t.state!==`draft`)&&_.appendSession(e,k,`vertical`),j.current+=1,A(e)},[k,I,_,d]),z=(0,V.useCallback)(e=>{_.appendSession(e,k,`vertical`),j.current+=1,A(e)},[k,_]),ne=(0,V.useCallback)(async e=>{let t=k===e,n=j.current,r=te.filter(t=>t.id!==e)[0]?.id??null;if(t&&A(r),!await v.closeSession(e)){if(!t||j.current!==n)return;A(t=>t===r?e:t);return}_.removeSessionPane(e)},[k,te,_,v]),re=(0,V.useCallback)(e=>{e&&!I.some(t=>t.id===e)&&d.some(t=>t.id===e&&t.state!==`draft`)&&_.appendSession(e,k,`vertical`),j.current+=1,A(e)},[k,I,_,d]),ie=(0,V.useCallback)(e=>{E(e),e!==`files`&&O({kind:`root`})},[]),B=(0,V.useCallback)(()=>{E(null),O({kind:`root`})},[]),ae=(0,V.useCallback)(e=>{O(e)},[]);return{activeSession:L,activeFilePath:o,activeWorkspaceId:n,createRequest:x,diffPreview:s,focusMode:c,gitState:a,handleConsumeCreateRequest:F,handleOpenBranchSwitcher:M,handleOpenFileCreate:N,handleOpenFolderCreate:P,handleRefreshSidebarPanel:ee,handleMobileSessionCreated:z,mainAreaMode:y===`git`&&s?`diff`:o?`editor`:`agent`,mobileActiveSessionId:k,mobileAgentSessions:te,mobileFilesRoute:D,mobileSheet:T,openMobileSheet:ie,orderedSessions:I,paneLayout:f,panelRefreshToken:C,paneLayout:f,closeMobileSession:ne,restoreMobileSession:re,selectMobileSession:R,sessions:d,setSidebarTab:b,sidebarCollapsed:u,sidebarTab:y,closeMobileSheet:B,terminalPanelVisible:l,updateMobileFilesRoute:ae,workspace:e,workspaces:i,workspaceId:t,...g}}function ux({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i}){let a=X(),o=H(ag(e)),s=H(og(e)),c=H(lg(e)),l=H(Wf),u=U(ag(e)),d=U(og(e)),f=U(lg(e)),p=U(cg(e)),m=H(sg(e)),h=U(sg(e)),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),w=(0,V.useRef)(t),T=(0,V.useRef)(0),E=(0,V.useCallback)(async()=>{if(!e||g)return!1;_(!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),h(new Set),_(!1),!0}return t.ok||console.error(`Failed to load file tree:`,t.error?.message),_(!1),!1},[e,g,l,u,h]),D=(0,V.useCallback)(async t=>{if(!e||v===t||m.has(t))return;y(t);let n=await l(`file.readTree`,{workspaceId:e,subPath:t});n.ok&&n.data&&(u(e=>{if(!e)return e;let r=new Map(e);return r.set(t,n.data.children),r}),h(e=>new Set(e).add(t))),y(null)},[e,v,m,l,u,h]),O=(0,V.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]),k=(0,V.useCallback)((e,t)=>{x({mode:e,draftPath:t?`${t.replace(/\/+$/,``)}/`:``,error:null})},[]),A=(0,V.useCallback)(()=>{x(null)},[]),j=(0,V.useCallback)(e=>{x(t=>t&&{...t,draftPath:e,error:null})},[]),M=(0,V.useCallback)(async()=>{if(!b)return;let t=b.draftPath.trim();if(!t){x(e=>e&&{...e,error:a(`file.path_required`)});return}if(b.mode===`file`&&t.endsWith(`/`)){x(e=>e&&{...e,error:a(`file.invalid_file_path`)});return}let n=await l(b.mode===`file`?`file.create`:`file.mkdir`,{workspaceId:e,path:t});if(!n.ok){x(e=>e&&{...e,error:n.error?.message??a(`file.create_failed`)});return}await E(),A(),b.mode===`file`&&f(t)},[b,l,e,E,A,f,a]),N=(0,V.useCallback)(()=>{C(null)},[]),P=(0,V.useCallback)(async()=>{if(!S)return;let t=await l(`file.delete`,{workspaceId:e,path:S.path});if(!t.ok){C(e=>e&&{...e,error:t.error?.message??a(`file.delete_failed`)});return}c===S.path&&f(null),p(e=>{if(!(S.path in e))return e;let t={...e};return delete t[S.path],t}),await E(),C(null)},[S,l,e,c,f,p,E,a]);return(0,V.useEffect)(()=>{!o&&!g&&E()},[o,g,E]),(0,V.useEffect)(()=>{s&&!g&&(d(!1),E())},[s,g,E,d]),(0,V.useEffect)(()=>{t<=w.current||g||(w.current=t,E())},[t,g,E]),(0,V.useEffect)(()=>{!n||n.id<=T.current||(T.current=n.id,k(n.mode,n.baseDir),r?.())},[n,k,r]),{activeFilePath:c,createDialog:b,fileTree:o,isLoading:g,isLoadingDir:v,pendingDelete:S,cancelDelete:N,confirmDelete:P,handleSelectFile:(0,V.useCallback)(e=>{f(e),i?.(e)},[i,f]),loadChildren:D,loadSearchResults:O,openCreateDialog:k,requestDelete:C,submitCreateDialog:M,updateDraftPath:j,closeCreateDialog:A}}function dx(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 fx={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},px={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`},mx={display:`block`,width:`auto`,minHeight:`auto`,padding:0,gap:0,textAlign:`left`},hx={margin:0,color:`inherit`,fontSize:`inherit`,fontWeight:`inherit`};function gx({title:e}){return(0,Y.jsx)(Pm,{className:`file-tree-empty`,style:fx,title:(0,Y.jsx)(`p`,{style:px,children:e})})}function _x({className:e,title:t}){return(0,Y.jsx)(Pm,{className:e,style:mx,title:(0,Y.jsx)(`p`,{style:hx,children:t})})}var vx=({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i,onVisibleCountChange:a,collapseVersion:o=0,variant:s=`desktop`})=>{let c=X(),{activeFilePath:l,createDialog:u,fileTree:d,isLoading:f,isLoadingDir:p,pendingDelete:m,cancelDelete:h,confirmDelete:g,handleSelectFile:_,loadChildren:v,loadSearchResults:y,openCreateDialog:b,requestDelete:x,submitCreateDialog:S,updateDraftPath:C,closeCreateDialog:w}=ux({workspaceId:e,refreshToken:t,createRequest:n,onCreateRequestConsumed:r,onSelectFile:i}),[T,E]=(0,V.useState)(``),D=T.trim(),O=(0,V.useMemo)(()=>d?Tx(wx(d)):[],[d]),[k,A]=(0,V.useState)([]),[j,M]=(0,V.useState)(!1),N=(0,V.useRef)(0),P=D.length>0,F=(0,V.useMemo)(()=>P?k.length:Cx(O),[P,k.length,O]);return(0,V.useEffect)(()=>{let e=!1;if(!P)return A([]),M(!1),()=>{e=!0};M(!0);let t=++N.current,n=setTimeout(()=>{(async()=>{let n=await y(D);e||t!==N.current||(A(n),M(!1))})()},150);return()=>{e=!0,clearTimeout(n)}},[P,y,D]),(0,V.useEffect)(()=>{a?.(F,j||f)},[f,a,j,F]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`file-tree-shell file-tree-shell--${s}`,children:[(0,Y.jsxs)(`label`,{className:`file-tree-search`,htmlFor:`file-tree-search-${e}`,children:[(0,Y.jsx)(Q,{semantic:`file.action.search`,size:14,className:`file-tree-search-icon`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{id:`file-tree-search-${e}`,className:`file-tree-search-input`,type:`search`,value:T,onChange:e=>E(e.target.value),placeholder:c(`action.search_files`),"aria-label":c(`action.search_files`)})]}),(0,Y.jsx)(`div`,{className:`file-tree`,children:P?j?(0,Y.jsx)(gx,{title:c(`common.loading`)}):k.length>0?k.map(e=>(0,Y.jsx)(yx,{node:e,selectedPath:l,onRequestDelete:(e,t)=>x({path:e,name:t,error:null}),onSelectFile:_},e.path)):(0,Y.jsx)(gx,{title:c(`command.no_results`)}):d&&d.size>0?O.map(e=>(0,Y.jsx)(bx,{node:e,depth:0,selectedPath:l,onRequestCreate:b,onRequestDelete:(e,t)=>x({path:e,name:t,error:null}),onSelectFile:_,onLoadChildren:v,isLoadingDir:p,collapseVersion:o},e.path)):(0,Y.jsx)(gx,{title:c(f?`common.loading`:`file.title`)})})]}),(0,Y.jsx)(xx,{dialog:u,onCancel:w,onConfirm:S,onDraftPathChange:C}),(0,Y.jsx)(Sx,{pendingDelete:m,onCancel:h,onConfirm:g})]})},yx=({node:e,selectedPath:t,onRequestDelete:n,onSelectFile:r})=>{let i=X(),a=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``;return(0,Y.jsxs)(`div`,{className:`tree-item ${t===e.path?`selected`:``}`,onClick:()=>r(e.path),style:{paddingLeft:12},children:[(0,Y.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:dx(e,!1),size:14})}),(0,Y.jsxs)(`span`,{className:`tree-search-labels`,children:[(0,Y.jsx)(`span`,{className:`tree-label`,children:e.name}),a?(0,Y.jsx)(`span`,{className:`tree-search-path`,children:a}):null]}),(0,Y.jsx)(`div`,{className:`tree-item-actions`,children:(0,Y.jsx)($,{content:i(`file.delete`),children:(0,Y.jsx)(Z,{"aria-label":`${i(`file.delete`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Zi,{size:12}),onClick:t=>{t.stopPropagation(),n(e.path,e.name)},size:`sm`})})})]})},bx=({node:e,depth:t,selectedPath:n,onRequestCreate:r,onRequestDelete:i,onSelectFile:a,onLoadChildren:o,isLoadingDir:s,collapseVersion:c})=>{let l=X(),u=e.kind===`dir`,[d,f]=(0,V.useState)(u&&t===0&&[`app`,`packages`,`src`].includes(e.name.toLowerCase())),p=(0,V.useRef)(!1);(0,V.useEffect)(()=>{e.children&&(p.current=!1)},[e.children]),(0,V.useEffect)(()=>{u&&d&&!e.children&&!p.current&&(p.current=!0,o(e.path))},[u,d,e.children,e.path,o]),(0,V.useEffect)(()=>{c>0&&f(!1)},[c]);let m=()=>{u?(d||o(e.path),f(!d)):a(e.path)},h=t*14+16;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tree-item ${n===e.path?`selected`:``}`,onClick:m,style:{paddingLeft:h},children:[(0,Y.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`,children:u?d?(0,Y.jsx)(si,{size:14}):(0,Y.jsx)(li,{size:14}):null}),(0,Y.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:dx(e,d),size:14})}),(0,Y.jsx)(`span`,{className:`tree-label`,children:e.name}),(0,Y.jsx)(`div`,{className:`tree-item-actions`,children:u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{content:l(`file.new_file`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.new_file`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Q,{semantic:`file.action.new`,size:12}),onClick:t=>{t.stopPropagation(),r(`file`,e.path)},size:`sm`})}),(0,Y.jsx)($,{content:l(`file.new_folder`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.new_folder`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Q,{semantic:`file.action.newFolder`,size:12}),onClick:t=>{t.stopPropagation(),r(`folder`,e.path)},size:`sm`})}),(0,Y.jsx)($,{content:l(`file.delete`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.delete`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Zi,{size:12}),onClick:t=>{t.stopPropagation(),i(e.path,e.name)},size:`sm`})})]}):(0,Y.jsx)($,{content:l(`file.delete`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.delete`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Zi,{size:12}),onClick:t=>{t.stopPropagation(),i(e.path,e.name)},size:`sm`})})})]}),u&&d&&e.children&&(0,Y.jsxs)(`div`,{className:`tree-children`,children:[Tx(e.children).map(e=>(0,Y.jsx)(bx,{node:e,depth:t+1,selectedPath:n,onRequestCreate:r,onRequestDelete:i,onSelectFile:a,onLoadChildren:o,isLoadingDir:s,collapseVersion:c},e.path)),e.children.length===0&&!s&&(0,Y.jsx)(_x,{className:`tree-empty-hint`,title:l(`file.empty_directory`)})]}),u&&d&&!e.children&&s===e.path&&(0,Y.jsx)(_x,{className:`tree-loading`,title:l(`common.loading`)})]})},xx=({dialog:e,onCancel:t,onConfirm:n,onDraftPathChange:r})=>{let i=X(),a=(0,V.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,Y.jsxs)(qp,{initialFocus:()=>a.current,onOpenChange:t,open:!0,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(Yp,{children:[e.mode===`file`?(0,Y.jsx)(Q,{"aria-hidden":`true`,semantic:`file.action.new`,size:16}):(0,Y.jsx)(Q,{"aria-hidden":`true`,semantic:`file.action.newFolder`,size:16}),(0,Y.jsx)(`span`,{children:e.mode===`file`?i(`file.new_file`):i(`file.new_folder`)})]}),(0,Y.jsx)(Z,{"aria-label":i(`action.close`),icon:(0,Y.jsx)(ea,{size:14}),onClick:t,size:`sm`})]}),(0,Y.jsx)(Xp,{children:(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`file-path`,children:i(`file.path`)}),(0,Y.jsx)(vm,{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,Y.jsx)(`span`,{id:o,className:`dialog-helper`,children:c}),e.error?(0,Y.jsx)(`span`,{id:s,className:`form-error`,role:`alert`,children:e.error}):null]})}),(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{onClick:t,children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:`primary`,onClick:()=>{n()},children:i(`action.confirm`)})]})]})},Sx=({pendingDelete:e,onCancel:t,onConfirm:n})=>{let r=X();return e?(0,Y.jsx)(tm,{open:!0,onOpenChange:t,title:r(`file.delete`),description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:r(`file.delete_confirm`,{name:e.name})}),e.error?(0,Y.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};function Cx(e){return e.reduce((e,t)=>t.kind===`file`?e+1:e+Cx(t.children??[]),0)}function wx(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 Tx(e){return[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`dir`?-1:1)}function Ex(e){return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `)||e.startsWith(`@@`)?`meta`:e.startsWith(`+`)?`added`:e.startsWith(`-`)?`removed`:`context`}var Dx=({workspaceId:e,onClose:t,showCloseButton:n=!0})=>{let r=X(),{preview:i,closePreview:a}=Zb(e),o=t??a,s=(0,V.useMemo)(()=>i?.diff.split(`
110
- `).map((e,t)=>({id:`${t}:${e}`,line:e,tone:Ex(e),lineNumber:t+1}))??[],[i]);return(0,Y.jsx)(`div`,{className:`workspace-git-view`,children:(0,Y.jsxs)(`div`,{className:`code-editor workspace-git-editor`,children:[(0,Y.jsxs)(`div`,{className:`code-editor-header`,children:[(0,Y.jsx)(`span`,{className:`code-file-path`,children:i?.title??i?.path??`Select a changed file to inspect`}),i&&n?(0,Y.jsx)(`div`,{className:`code-mode-toggle`,children:(0,Y.jsx)($,{content:r(`action.close`),children:(0,Y.jsx)(Z,{"aria-label":r(`action.close`),className:`code-mode-btn`,icon:(0,Y.jsx)(ea,{size:12}),onClick:o,size:`sm`})})}):null]}),(0,Y.jsx)(`div`,{className:`code-editor-body`,children:i?(0,Y.jsx)(`div`,{className:`code-lines git-diff-lines`,children:s.map(e=>(0,Y.jsxs)(`div`,{className:`code-line git-diff-line git-diff-line-${e.tone}`,children:[(0,Y.jsx)(`span`,{className:`code-line-num`,children:e.lineNumber}),(0,Y.jsx)(`span`,{className:`git-diff-line-text`,children:e.line||` `})]},e.id))}):(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.jsx)(`p`,{className:`git-diff-empty-body`,children:`Select a staged or modified file on the left to inspect its diff.`}),title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:r(`label.git`)})})})]})})};function Ox(e){return e.trim().replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}function kx(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=Ox(t||`worktree`);return`${s}${d}${u}-${f}`}function Ax(e){let t=e.trim();return t?/^[A-Za-z]:[\\/]+$/.test(t)?`${t.slice(0,2)}${t.includes(`\\`)?`\\`:`/`}`:t.replace(/[\\/]+$/,``)||t:``}function jx(e){return/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Mx(e){let t=X(),n=H(Wf),r=H(Qf(e)),[i,a]=xe(_g(e)),o=U(qf),s=U(Jf),c=U(Yf),l=U(Xf),u=U(Zf),d=U(zg),f=rg(),p=(0,V.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,V.useCallback)(async(r,i)=>{let a=Ax(i);if(!a||!jx(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,V.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,V.useMemo)(()=>i.items.find(e=>e.path===r?.path)??null,[i.items,r?.path]),_=(0,V.useMemo)(()=>i.items.filter(e=>e.status===`dirty`).length,[i.items]),v=(0,V.useCallback)(e=>r?.path?kx(r.path,e):``,[r?.path]),y=(0,V.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 Nx={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},Px={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function Fx({title:e}){return(0,Y.jsx)(Pm,{className:`worktree-loading`,style:Nx,title:(0,Y.jsx)(`p`,{style:Px,children:e})})}function Ix({workspaceId:e,worktree:t,mobile:n=!1}){let r=X(),{activeTab:i,diff:a,error:o,handleTabChange:s,loading:c,status:l,tree:u}=Tg(e,t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:n?`mobile-worktree-sheet__summary`:void 0,children:(0,Y.jsxs)(`div`,{className:`worktree-chips`,children:[(0,Y.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,t.branch]}),(0,Y.jsxs)(`span`,{className:`worktree-chip worktree-chip-path`,children:[`📁 `,t.path]}),(0,Y.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,Y.jsxs)(Zm,{"aria-label":r(`worktree.title`),onValueChange:e=>s(e),value:i,children:[(0,Y.jsx)(Qm,{className:`worktree-tabs${n?` mobile-worktree-sheet__tabs`:``}`,children:[`status`,`diff`,`tree`].map(e=>(0,Y.jsx)($m,{className:`worktree-tab`,value:e,children:r(e===`status`?`worktree.status_tab`:e===`diff`?`worktree.diff_tab`:`worktree.tree_tab`)},e))}),(0,Y.jsxs)(`div`,{className:n?`mobile-worktree-sheet__content`:void 0,children:[(0,Y.jsxs)(eh,{className:`worktree-content`,value:`status`,children:[o?(0,Y.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,Y.jsx)(Fx,{title:r(`worktree.loading`)}):(0,Y.jsxs)(`div`,{className:`worktree-status-tab`,children:[(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.path`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:t.path})]}),(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.branch`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:t.branch})]}),(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`git.latest_commit`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:l?.headShortSha||t.commit?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`code`,{children:l?.headShortSha??t.commit}),l?.headSubject?` ${l.headSubject}`:``]}):r(`git.no_commits`)})]}),(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`label.status`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:t.status===`clean`?r(`worktree.clean`):r(`worktree.dirty`)})]}),l?(0,Y.jsxs)(`div`,{className:`worktree-changes`,children:[(0,Y.jsx)(`h4`,{children:r(`worktree.changes`)}),l.staged.length>0?(0,Y.jsx)(`div`,{className:`worktree-change-group`,children:(0,Y.jsx)(`span`,{children:r(`worktree.staged_count`,{count:l.staged.length})})}):null,l.modified.length>0?(0,Y.jsx)(`div`,{className:`worktree-change-group`,children:(0,Y.jsx)(`span`,{children:r(`worktree.modified_count`,{count:l.modified.length})})}):null,l.untracked.length>0?(0,Y.jsx)(`div`,{className:`worktree-change-group`,children:(0,Y.jsx)(`span`,{children:r(`worktree.untracked_count`,{count:l.untracked.length})})}):null]}):null]})]}),(0,Y.jsxs)(eh,{className:`worktree-content`,value:`diff`,children:[o?(0,Y.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,Y.jsx)(Fx,{title:r(`worktree.loading`)}):(0,Y.jsx)(`div`,{className:`worktree-diff-tab`,children:a?(0,Y.jsx)(`pre`,{className:`worktree-diff-output`,children:a}):(0,Y.jsx)(Pm,{className:`worktree-empty`,style:Nx,title:(0,Y.jsx)(`p`,{style:Px,children:r(`git.no_changes`)})})})]}),(0,Y.jsxs)(eh,{className:`worktree-content`,value:`tree`,children:[o?(0,Y.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,Y.jsx)(Fx,{title:r(`worktree.loading`)}):(0,Y.jsx)(`div`,{className:`worktree-tree-tab`,children:u.length>0?(0,Y.jsx)(`div`,{className:`worktree-tree`,children:u.map(e=>(0,Y.jsxs)(`div`,{className:`worktree-tree-node`,children:[(0,Y.jsx)(`span`,{className:`worktree-tree-icon`,children:e.kind===`dir`?`📁`:`📄`}),(0,Y.jsx)(`span`,{className:`worktree-tree-name`,children:e.name})]},e.path))}):(0,Y.jsx)(Pm,{className:`worktree-empty`,style:Nx,title:(0,Y.jsx)(`p`,{style:Px,children:r(`worktree.empty_tree`)})})})]})]})]})]})}var Lx={minHeight:`auto`,padding:`var(--sp-4) 0`,gap:0},Rx={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function zx({title:e}){return(0,Y.jsx)(Pm,{className:`worktree-loading`,style:Lx,title:(0,Y.jsx)(`p`,{style:Rx,children:e})})}function Bx({workspaceId:e,openView:t,onClose:n}){let r=Pr()===`mobile`,i=X(),{createWorktree:a,currentWorktree:o,list:s,loadWorktrees:c,removeWorktreeByPath:l,suggestedPathForBranch:u}=Mx(e),[d,f]=(0,V.useState)(`list`),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),k=(0,V.useRef)(!1),A=(0,V.useRef)(null),j=()=>{g(``),v(``),b(!1),w(null)};(0,V.useEffect)(()=>{if(!t){k.current=!1;return}k.current||(k.current=!0,O(null),E(null),S(null),m(null),t===`create`?(j(),f(`create`)):f(`list`),!s.lastLoadedAt&&!s.loading&&c())},[s.lastLoadedAt,s.loading,c,t]),(0,V.useEffect)(()=>{d!==`create`||y||v(h.trim()?u(h):``)},[h,y,u,d]);let M=(0,V.useMemo)(()=>s.items.find(e=>e.path===p)??null,[s.items,p]),N=(0,V.useMemo)(()=>s.items.find(e=>e.path===x)??null,[x,s.items]);if((0,V.useEffect)(()=>{d===`detail`&&p&&!M&&(O(i(`worktree.selection_removed`)),m(null),f(`list`))},[M,p,i,d]),!t)return null;let P=d===`detail`&&M?M.name:i(d===`create`?`worktree.create_title`:`worktree.list_title`),F=h.trim().length>0&&/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(_.trim()),ee=`worktree-path-hint-${e}`,I=()=>{E(null),S(null),f(`list`)},te=()=>{j(),S(null),m(null),O(null),f(`create`)},L=()=>{N&&(E(null),l(N.path,N.status===`dirty`).then(e=>{if(e.ok){I();return}E(e.error)}))},R=d===`detail`&&M?(0,Y.jsx)(`div`,{className:r?`mobile-worktree-sheet`:void 0,children:(0,Y.jsx)(Ix,{workspaceId:e,worktree:M,mobile:r})}):d===`create`?(0,Y.jsxs)(`form`,{className:`worktree-manager__form`,onSubmit:e=>{e.preventDefault(),w(null),a(h.trim(),_.trim()).then(e=>{if(e.ok){j(),f(`list`);return}w(e.error)})},children:[C?(0,Y.jsx)(`div`,{className:`worktree-error`,children:C}):null,(0,Y.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,Y.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-branch-${e}`,children:i(`worktree.branch`)}),(0,Y.jsx)(vm,{id:`worktree-branch-${e}`,ref:A,value:h,onChange:e=>g(e.target.value),placeholder:`feature/worktree-manager`,autoFocus:!0})]}),(0,Y.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,Y.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-path-${e}`,children:i(`worktree.path`)}),(0,Y.jsx)(vm,{id:`worktree-path-${e}`,value:_,onChange:e=>{b(!0),v(e.target.value)},placeholder:`/home/spencer/workspace/coder-studio-feature-worktree-manager`,"aria-describedby":ee}),(0,Y.jsx)(`span`,{id:ee,className:`worktree-manager__field-hint`,children:i(`worktree.create_path_hint`)})]}),(0,Y.jsxs)(`div`,{className:`worktree-manager__form-actions`,children:[(0,Y.jsx)(Lp,{variant:`secondary`,onClick:()=>f(`list`),children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{type:`submit`,variant:`primary`,disabled:!F,children:i(`worktree.create_submit`)})]})]}):d===`confirm-delete`&&N?(0,Y.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[T?(0,Y.jsx)(`div`,{className:`worktree-error`,children:T}):null,(0,Y.jsx)(`p`,{children:N.status===`dirty`?i(`worktree.remove_force_confirm`):i(`worktree.remove_confirm`)}),(0,Y.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:N.path}),(0,Y.jsxs)(`div`,{className:`worktree-manager__confirm-actions`,children:[(0,Y.jsx)(Lp,{variant:`secondary`,onClick:I,children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:`danger`,onClick:()=>{L()},children:N.status===`dirty`?i(`worktree.force_remove`):i(`common.delete`)})]})]}):(0,Y.jsxs)(`div`,{className:`worktree-manager__list`,children:[D?(0,Y.jsx)(`div`,{className:`worktree-error`,children:D}):null,s.error?(0,Y.jsxs)(`div`,{className:`worktree-error`,children:[(0,Y.jsx)(`div`,{children:s.error}),(0,Y.jsx)(Lp,{variant:`secondary`,size:`sm`,onClick:()=>void c(),children:i(`action.refresh`)})]}):null,s.loading&&s.items.length===0?(0,Y.jsx)(zx,{title:i(`worktree.loading`)}):s.error&&s.items.length===0?null:s.items.length===0?(0,Y.jsx)(Pm,{className:`worktree-empty`,style:Lx,title:(0,Y.jsx)(`p`,{style:Rx,children:i(`worktree.list_empty`)})}):s.items.map((e,t)=>{let n=o?.path===e.path,r=t===0;return(0,Y.jsxs)(`div`,{className:`worktree-manager__row`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`worktree-manager__row-main`,onClick:()=>{O(null),m(e.path),f(`detail`)},children:[(0,Y.jsx)(`span`,{className:`worktree-manager__row-name`,children:e.name}),(0,Y.jsxs)(`div`,{className:`worktree-manager__meta`,children:[(0,Y.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,e.branch]}),(0,Y.jsx)(`span`,{className:`worktree-chip worktree-chip-status ${e.status===`clean`?`worktree-clean`:`worktree-dirty`}`,children:e.status===`clean`?i(`worktree.clean`):i(`worktree.dirty_status`)}),n?(0,Y.jsx)(`span`,{className:`worktree-chip`,children:i(`worktree.current`)}):null]}),(0,Y.jsx)(`span`,{className:`worktree-manager__row-path`,children:e.path})]}),!n&&!r?(0,Y.jsx)(Lp,{"aria-label":i(`worktree.remove_row_label`,{name:e.name}),size:`sm`,variant:`ghost`,onClick:()=>{E(null),S(e.path),f(`confirm-delete`)},children:i(`common.delete`)}):null]},e.path)})]});return!r&&d===`confirm-delete`&&N?(0,Y.jsx)(tm,{open:!0,className:`worktree-manager-surface`,title:i(`common.delete`),description:(0,Y.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[T?(0,Y.jsx)(`div`,{className:`worktree-error`,children:T}):null,(0,Y.jsx)(`p`,{children:N.status===`dirty`?i(`worktree.remove_force_confirm`):i(`worktree.remove_confirm`)}),(0,Y.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:N.path})]}),cancelText:i(`action.cancel`),closeLabel:i(`action.close`),confirmText:N.status===`dirty`?i(`worktree.force_remove`):i(`common.delete`),onOpenChange:e=>{e||I()},onConfirm:L,tone:`danger`}):r?(0,Y.jsx)(Op,{kicker:i(`worktree.title`).toUpperCase(),title:P,body:(0,Y.jsx)(`div`,{className:`worktree-manager-surface`,children:R}),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`mobile-sheet--worktree`,onBack:d===`list`?void 0:()=>f(`list`),headerAction:d===`list`?(0,Y.jsx)(Lp,{size:`sm`,variant:`primary`,onClick:te,children:i(`worktree.new`)}):void 0,onClose:n}):(0,Y.jsxs)(qp,{className:`worktree-manager-surface`,initialFocus:()=>d===`create`?A.current:null,onOpenChange:e=>{e||n()},open:!0,size:`lg`,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsx)(`div`,{className:`worktree-header-info`,children:(0,Y.jsx)(Yp,{children:P})}),(0,Y.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[d===`list`?(0,Y.jsx)(Lp,{size:`sm`,variant:`primary`,onClick:te,children:i(`worktree.new`)}):(0,Y.jsx)(Lp,{size:`sm`,variant:`ghost`,onClick:()=>f(`list`),children:i(`action.back`)}),(0,Y.jsx)(Lp,{size:`sm`,variant:`ghost`,onClick:n,children:i(`action.close`)})]})]}),R]})}var Vx={minHeight:`auto`,padding:`12px 0`,gap:`4px`},Hx={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`};function Ux({title:e,action:t}){return(0,Y.jsx)(Pm,{action:t,className:`git-panel-empty`,style:Vx,title:(0,Y.jsx)(`p`,{style:Hx,children:e})})}var Wx=({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,variant:r=`desktop`})=>{let i=r===`mobile`,a=H(xa)===`zh`?`zh`:`en`,o=X(),{commitMessage:s,diffPreview:c,gitState:l,groups:u,history:d,historyLoading:f,isLoading:p,pendingDiscard:m,setCommitMessage:h,handleCancelDiscard:g,handleCommit:_,handleConfirmDiscard:v,handleRequestDiscardPaths:y,handleRequestDiscardSingle:b,handleStagePaths:x,handleUnstagePaths:S,openHistoryDiff:C,openDiff:w,runGitMutation:T}=Xb({workspaceId:e,refreshToken:t,onPreviewOpen:n,initialHistoryLimit:20}),{currentWorktree:E,hasWorkspace:D,list:O,loadWorktrees:k,openWorktree:A}=Mx(e),[j,M]=(0,V.useState)(null),[N,P]=(0,V.useState)(!1),[F,ee]=(0,V.useState)(!1),I=(0,V.useRef)(!1),[te,L]=(0,V.useState)(()=>i?{staged:!1,changes:!0}:{staged:!1,changes:!1});(0,V.useEffect)(()=>{I.current=!1},[e]),(0,V.useEffect)(()=>{if(!D){I.current=!1;return}O.lastLoadedAt||O.loading||I.current||(I.current=!0,k())},[D,O.lastLoadedAt,O.loading,k]);let R=l?.staged.length??0,z=!!s.trim()&&R>0,ne=async e=>{if(E?.path===e.path){M(`list`);return}await A(e.path)};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`git-panel git-panel--${r}`,children:(0,Y.jsxs)(`div`,{className:`git-panel-scroll`,children:[(0,Y.jsxs)(`section`,{className:`git-commit-block`,children:[(0,Y.jsx)(Fh,{className:`git-commit-input`,placeholder:o(`git.commit_summary_placeholder`),value:s,onChange:e=>h(e.target.value),rows:3,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),_())}}),(0,Y.jsx)(`div`,{className:`git-commit-actions`,children:(0,Y.jsx)($,{content:o(z?`git.commit`:`git.nothing_staged`),children:(0,Y.jsxs)(`button`,{className:`git-commit-primary`,onClick:()=>void _(),disabled:!z,type:`button`,children:[(0,Y.jsx)(`span`,{children:o(`git.commit`)}),(0,Y.jsx)(Q,{semantic:`git.commit`,size:14})]})})})]}),(0,Y.jsxs)(`section`,{className:`git-panel-section`,children:[(0,Y.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>P(e=>!e),"aria-expanded":N,children:[(0,Y.jsx)(`span`,{children:o(`worktree.list_title`)}),(0,Y.jsx)(`span`,{className:`git-panel-section-count`,children:O.items.length}),(0,Y.jsx)(`span`,{className:`git-panel-section-chevron ${N?`expanded`:``}`,children:(0,Y.jsx)(si,{size:14})})]}),(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>M(`create`),children:[(0,Y.jsx)(Q,{semantic:`worktree.action.new`,size:12}),(0,Y.jsx)(`span`,{children:o(`worktree.new`)})]})]}),N?(0,Y.jsx)(`div`,{className:`git-panel-section-body`,children:O.loading&&O.items.length===0?(0,Y.jsx)(Ux,{title:o(`worktree.loading`)}):O.error?(0,Y.jsx)(Ux,{action:(0,Y.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void k(),children:o(`action.refresh`)}),title:O.error}):O.items.length===0?(0,Y.jsx)(Ux,{title:o(`worktree.list_empty`)}):O.items.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`git-worktree-row ${E?.path===e.path?`active`:``}`,onClick:()=>void ne(e),children:[(0,Y.jsx)(`span`,{className:`git-worktree-row__dot git-worktree-row__dot-${e.status}`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`git-worktree-row__copy`,children:[(0,Y.jsx)(`span`,{className:`git-worktree-row__name`,children:e.name}),(0,Y.jsxs)(`span`,{className:`git-worktree-row__meta`,children:[e.branch,` ·`,` `,e.status===`clean`?o(`worktree.clean`):o(`worktree.dirty_status`)]})]}),E?.path===e.path?(0,Y.jsx)(`span`,{className:`git-worktree-row__chip`,children:o(`worktree.current`)}):null]},e.path))}):null]}),(0,Y.jsx)(`div`,{className:`git-panel-groups`,children:l&&u.length>0?u.map(t=>(0,Y.jsx)(Gx,{title:t.title,changes:t.changes,mobile:i,collapsed:te[t.title]??!1,selectedPath:c?.path??null,onToggleCollapsed:()=>L(e=>({...e,[t.title]:!(e[t.title]??!1)})),onStageAll:async()=>{if(t.title===`staged`){await S(t.changes.map(({change:e})=>e.path));return}await x(t.changes.map(({change:e})=>e.path))},onDiscardAll:()=>y(t.changes.map(({change:e})=>e.path)),onViewDiff:w,onRunMutation:T,onRequestDiscard:b,workspaceId:e},t.title)):(0,Y.jsx)(Ux,{title:o(p?`common.loading`:`git.no_changes`)})}),(0,Y.jsxs)(`section`,{className:`git-panel-section git-panel-section-history`,children:[(0,Y.jsx)(`div`,{className:`git-panel-section-header`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>ee(e=>!e),"aria-expanded":F,children:[(0,Y.jsx)(`span`,{children:o(`git.history`)}),(0,Y.jsx)(`span`,{className:`git-panel-section-chevron ${F?`expanded`:``}`,children:(0,Y.jsx)(si,{size:14})})]})}),F?(0,Y.jsx)(`div`,{className:`git-panel-section-body`,children:f&&d.length===0?(0,Y.jsx)(Ux,{title:o(`common.loading`)}):d.length===0?(0,Y.jsx)(Ux,{title:o(`git.no_commits`)}):d.map((e,t)=>(0,Y.jsx)(qx,{entry:e,isCurrent:t===0,locale:a,onOpen:C},e.sha))}):null]})]})}),(0,Y.jsx)(Bx,{workspaceId:e,openView:j,onClose:()=>M(null)}),(0,Y.jsx)(Jx,{discard:m,onCancel:g,onConfirm:v})]})},Gx=({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=X(),p=e===`staged`?`git.staged`:`git.changes`,m=f(e===`staged`?`git.unstage_all`:`git.stage_all`);return(0,Y.jsxs)(`section`,{className:`git-panel-section git-panel-section-changes`,children:[(0,Y.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:u,"aria-expanded":!n,children:[(0,Y.jsx)(`span`,{children:f(p)}),(0,Y.jsx)(`span`,{className:`git-panel-section-count`,children:t.length}),(0,Y.jsx)(`span`,{className:`git-panel-section-chevron ${n?``:`expanded`}`,children:(0,Y.jsx)(si,{size:14})})]}),(0,Y.jsxs)(`div`,{className:`git-panel-section-actions`,children:[(0,Y.jsx)($,{content:m,children:(0,Y.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void l(),children:m})}),e===`changes`?(0,Y.jsx)($,{content:f(`git.discard_all`),children:(0,Y.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void o(),children:f(`git.discard_all`)})}):null]})]}),n?null:(0,Y.jsx)(`div`,{className:`git-panel-section-body`,children:t.map(({change:e,type:t})=>(0,Y.jsx)(Kx,{change:e,type:t,mobile:r,workspaceId:a,selected:i===e.path,onViewDiff:d,onRunMutation:c,onRequestDiscard:s},`${t}:${e.path}`))})]})},Kx=({change:e,type:t,mobile:n,workspaceId:r,selected:i,onViewDiff:a,onRunMutation:o,onRequestDiscard:s})=>{let c=X(),l=(0,V.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,Y.jsx)(Ni,{size:12}):(0,Y.jsx)(Bi,{size:12}),h=Xx(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,Y.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,Y.jsx)(`span`,{className:`git-row-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:h,size:13})}),(0,Y.jsxs)(`div`,{className:`git-row-content`,children:[(0,Y.jsx)(`span`,{className:`git-row-name`,children:u}),(0,Y.jsxs)(`span`,{className:`git-row-meta`,children:[d?(0,Y.jsx)(`span`,{className:`git-row-dir`,children:d}):null,e.oldPath?(0,Y.jsx)(`span`,{className:`git-row-rename`,children:e.oldPath}):null]})]}),(0,Y.jsxs)(`div`,{className:`git-row-actions`,children:[(0,Y.jsx)($,{content:f,children:(0,Y.jsx)(Z,{"aria-label":f,className:`git-row-action`,icon:m,onClick:e=>{e.stopPropagation(),g()},size:`sm`,type:`button`,variant:`ghost`})}),(0,Y.jsx)($,{content:p,children:(0,Y.jsx)(Z,{"aria-label":p,className:`git-row-action`,icon:(0,Y.jsx)(Hi,{size:12}),onClick:t=>{t.stopPropagation(),s(e.path)},size:`sm`,type:`button`,variant:`ghost`})})]})]})};function qx({entry:e,isCurrent:t,locale:n,onOpen:r}){return(0,Y.jsxs)(`button`,{type:`button`,className:`git-history-row ${t?`current`:``}`,onClick:()=>void r(e),children:[(0,Y.jsx)(`span`,{className:`git-history-row__dot`,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`git-history-row__copy`,children:[(0,Y.jsx)($,{content:e.subject,children:(0,Y.jsx)(`span`,{className:`git-history-row__title`,children:e.subject})}),(0,Y.jsxs)(`span`,{className:`git-history-row__meta`,children:[e.shortSha,` · `,e.authorName]})]}),(0,Y.jsx)(`span`,{className:`git-history-row__when`,children:Ep(e.authoredAt,n)})]})}var Jx=({discard:e,onCancel:t,onConfirm:n})=>{let r=X();return e?(0,Y.jsx)(tm,{open:!0,onOpenChange:t,title:e.scope===`all`?r(`git.discard_all_confirm_title`):r(`git.discard_file_confirm_title`),description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.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 Yx(e,t){return e.status?e.status:t===`deleted`?`deleted`:t===`untracked`?`untracked`:`modified`}function Xx(e,t){switch(Yx(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 Zx={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},Qx={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function $x({title:e}){return(0,Y.jsx)(Pm,{className:`branch-quick-pick-empty`,style:Zx,title:(0,Y.jsx)(`p`,{style:Qx,children:e})})}function eS(){let e=X(),{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}=Qb(),m=(0,V.useRef)(null),h=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{m.current?.focus()},0);return()=>{window.clearTimeout(e)}},[]),(0,V.useEffect)(()=>{h.current&&h.current.querySelector(`.branch-quick-pick-item:nth-child(${l+1})`)?.scrollIntoView({block:`nearest`})},[l]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`branch-quick-pick-search`,children:(0,Y.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,Y.jsx)(`div`,{className:`branch-quick-pick-list`,ref:h,children:t.loading?(0,Y.jsx)($x,{title:`Loading branches...`}):n.length>0?n.map((t,n)=>(0,Y.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,Y.jsxs)(Y.Fragment,{children:[t.branch.isCurrent&&(0,Y.jsx)(`span`,{className:`branch-quick-pick-check`,children:(0,Y.jsx)(oi,{size:14})}),(0,Y.jsx)(`span`,{className:`branch-quick-pick-name`,children:t.branch.name}),t.branch.linkedWorktreePath&&!t.branch.isCurrent&&(0,Y.jsx)(kh,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:e(`git.quick_pick.in_use`)}),t.branch.isRemote&&(0,Y.jsx)(kh,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:`Remote`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`branch-quick-pick-create-icon`,children:(0,Y.jsx)(Q,{semantic:`git.branch.create`,size:14})}),(0,Y.jsx)(`span`,{className:`branch-quick-pick-create-label`,children:t.label})]})},t.type===`branch`?t.branch?.name:`create`)):(0,Y.jsx)($x,{title:s?`No branches found`:`Type to search branches`})}),(0,Y.jsxs)(`div`,{className:`branch-quick-pick-hint`,children:[(0,Y.jsx)(`span`,{children:`↑↓ Navigate`}),(0,Y.jsx)(`span`,{children:`↵ Select`}),(0,Y.jsx)(`span`,{children:`Esc Close`})]})]})}function tS({children:e,workspaceId:t,onOpenBranchSwitcher:n}){let r=Pr(),i=X(),a=H(hg),o=U(hg);return r===`mobile`||!n?e:(0,Y.jsx)(om,{content:(0,Y.jsx)(eS,{}),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 nS(){let e=Pr(),t=X(),{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}=Qb(),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,Y.jsx)(oi,{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,Y.jsx)(`div`,{onKeyDown:g,children:(0,Y.jsx)(sh,{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 rS=({workspaceId:e,gitState:t,inline:n=!1,onRefresh:r})=>{let i=X(),a=H(xa),o=H(vg(e)),{authPrompt:s,clearAuthPrompt:c,getAuthPromptMessage:l,handleFetch:u,handlePull:d,handlePush:f,syncingIntent:p}=qb(e),m=`git-auth-form-${e}`,[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)({username:``,password:``});if((0,V.useLayoutEffect)(()=>{if(!s){v({username:``,password:``});return}v(e=>({username:e.username||s.details.usernameHint||``,password:``}))},[s]),!t)return null;let y=t.staged.length+t.modified.length+t.untracked.length+t.deleted.length,b=t.ahead,x=t.behind,S=o.status===`fetching`,C=o.lastFetchAt?i(`git.fetch_last_at`,{when:Dp(o.lastFetchAt,a)}):i(`git.fetch_last_never`),w=i(S?`git.fetch_in_progress`:`git.fetch_label`),T=h?.intent===`push`?i(`git.push_confirm_title`):i(`git.pull_confirm_title`),E=h?.intent===`push`?i(`git.push_confirm_message`,{count:h.count}):i(`git.pull_confirm_message`,{count:h?.count??0}),D=h?.intent===`push`?i(`action.push`):i(`action.pull`),O=h?.intent===`push`?i(`git.push_in_progress`):i(`git.pull_in_progress`),k=!!(h&&p===h.intent),A=s?.intent,j=A??h?.intent??`pull`,M=i(A===`push`?`action.push`:A===`pull`?`action.pull`:`git.fetch_label`),N=i(A===`push`?`git.push_in_progress`:A===`pull`?`git.pull_in_progress`:`git.fetch_in_progress`),P=!!(A&&p===A),F=k||P,ee=!!(h&&!s),I=!!s,te=(e,t)=>{t<=0||g({intent:e,count:t})},L=()=>{F||(g(null),c())},R=e=>{e||L()},z=async()=>{if(h){if(h.intent===`push`){await f()&&g(null);return}await d()&&g(null)}},ne=async()=>{if(!s)return;let e={username:_.username.trim(),password:_.password};!e.username||!e.password||(s.intent===`push`?await f(e):s.intent===`pull`?await d(e):await u(e))&&(c(),g(null),r?.())},re=async()=>{await u()&&r?.()};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`git-status-bar${n?` git-status-bar--inline`:``}`,children:[(0,Y.jsx)($,{content:i(`git.statusbar.changes`),children:(0,Y.jsxs)(`span`,{className:`git-status-bar__item git-status-bar__item--changes`,children:[(0,Y.jsx)(Q,{semantic:`git.footer.diff`,size:13}),(0,Y.jsx)(`span`,{className:`git-status-bar__value`,children:y})]})}),(0,Y.jsx)($,{content:i(`git.statusbar.ahead`),children:(0,Y.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--ahead`,type:`button`,"aria-label":i(`action.push`),disabled:b<=0,onClick:()=>te(`push`,b),children:[(0,Y.jsx)(Q,{semantic:`git.footer.push`,size:13}),(0,Y.jsx)(`span`,{className:`git-status-bar__value`,children:b})]})}),(0,Y.jsx)($,{content:i(`git.statusbar.behind`),children:(0,Y.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--behind`,type:`button`,"aria-label":i(`action.pull`),disabled:x<=0,onClick:()=>te(`pull`,x),children:[(0,Y.jsx)(Q,{semantic:`git.footer.pull`,size:13}),(0,Y.jsx)(`span`,{className:`git-status-bar__value`,children:x})]})}),(0,Y.jsx)($,{content:C,children:(0,Y.jsx)(Z,{"aria-label":w,className:`git-status-bar__item git-status-bar__item--actionable`,disabled:S,icon:(0,Y.jsx)(Q,{semantic:`git.footer.refresh`,size:13,className:S?`spin`:void 0}),onClick:()=>void re(),size:`sm`})})]}),ee?(0,Y.jsx)(tm,{className:`git-status-bar__confirm`,dismissible:!F,closeDisabled:F,open:!0,onOpenChange:R,title:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{semantic:`git.action.warning`,size:16}),(0,Y.jsx)(`span`,{children:T})]}),description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:E}),(0,Y.jsx)(`p`,{className:`dialog-helper`,children:i(`git.sync_confirm_helper`)})]}),cancelDisabled:F,cancelText:i(`action.cancel`),closeLabel:i(`action.close`),confirmText:k?O:D,confirmDisabled:k,onConfirm:()=>{z()}}):null,I?(0,Y.jsxs)(qp,{className:`git-status-bar__confirm`,dismissible:!F,open:!0,onOpenChange:R,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(Yp,{children:[(0,Y.jsx)(Q,{semantic:`git.action.warning`,size:16}),(0,Y.jsx)(`span`,{children:i(j===`push`?`git.push_confirm_title`:j===`pull`?`git.pull_confirm_title`:`git.fetch_label`)})]}),(0,Y.jsx)(Z,{"aria-label":i(`action.close`),disabled:F,icon:(0,Y.jsx)(ea,{size:14}),onClick:L,size:`sm`})]}),(0,Y.jsx)(Xp,{children:s.details.canPrompt?(0,Y.jsxs)(`form`,{id:m,className:`form-group`,onSubmit:e=>{e.preventDefault(),ne()},children:[(0,Y.jsx)(`p`,{children:l(s.details)}),(0,Y.jsx)(`span`,{className:`dialog-helper`,children:i(`git.auth_helper_http`)}),(0,Y.jsx)(`label`,{htmlFor:`git-auth-username-${e}`,children:i(`git.auth_username`)}),(0,Y.jsx)(vm,{id:`git-auth-username-${e}`,value:_.username,onChange:e=>v(t=>({...t,username:e.target.value})),placeholder:s.details.usernameHint??i(`git.auth_username_placeholder`),autoFocus:!0,disabled:P}),(0,Y.jsx)(`label`,{htmlFor:`git-auth-password-${e}`,children:i(`git.auth_password`)}),(0,Y.jsx)(vm,{id:`git-auth-password-${e}`,type:`password`,value:_.password,onChange:e=>v(t=>({...t,password:e.target.value})),placeholder:i(`git.auth_password_placeholder`),disabled:P})]}):(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`p`,{children:l(s.details)}),(0,Y.jsx)(`span`,{className:`dialog-helper`,children:i(`git.auth_helper_unsupported`)})]})}),(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{onClick:L,disabled:F,children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:`primary`,form:s.details.canPrompt?m:void 0,type:s.details.canPrompt?`submit`:`button`,disabled:!s.details.canPrompt||P||!_.username.trim()||!_.password,children:P?N:M})]})]}):null]})};function iS({"aria-controls":e,"aria-expanded":t,"aria-haspopup":n,ariaLabel:r,branchName:i,branchSummary:a,disabled:o,onClick:s,onKeyDown:c}){return(0,Y.jsx)($,{content:i,children:(0,Y.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,Y.jsx)(Q,{semantic:`git.footer.branch`,size:11}),(0,Y.jsx)(`span`,{className:`git-panel-status-strip__branch-text`,children:i})]})})}function aS({workspaceId:e,gitState:t,onOpenBranchSwitcher:n,align:r=`end`}){let i=X(),a=Pr(),o=t?.branch?.trim()||i(`git.no_branch`),s=t&&(t.ahead>0||t.behind>0)?[t.ahead>0?`↑${t.ahead}`:null,t.behind>0?`↓${t.behind}`:null].filter(Boolean).join(` `):null,c=(0,Y.jsx)(iS,{ariaLabel:`${i(`git.current_branch`)}: ${o}`,branchName:o,branchSummary:s,disabled:!n,onClick:a===`mobile`?n:void 0});return(0,Y.jsxs)(`div`,{className:`git-panel-status-strip git-panel-status-strip--${r}`,children:[a===`desktop`&&n?(0,Y.jsx)(tS,{workspaceId:e,onOpenBranchSwitcher:n,children:c}):c,(0,Y.jsx)(`div`,{className:`git-panel-status-strip__meta`,children:(0,Y.jsx)(rS,{workspaceId:e,gitState:t,inline:!0})})]})}function oS({workspaceId:e,gitState:t,onOpenBranchSwitcher:n,flush:r=!1,align:i=`end`}){return(0,Y.jsx)(`div`,{className:`workspace-status-bar${r?` workspace-status-bar--flush`:``}`,children:(0,Y.jsx)(aS,{align:i,workspaceId:e,gitState:t,onOpenBranchSwitcher:n})})}var sS=()=>{let e=(0,V.useRef)(null),t=ix(e),[n,r]=(0,V.useState)(0),i=X(),{createRequest:a,focusMode:o,gitState:s,handleBottomMouseDown:c,handleConsumeCreateRequest:l,handleLeftMouseDown:u,handleOpenBranchSwitcher:d,handleOpenFileCreate:f,handleOpenFolderCreate:p,leftPanelWidth:m,leftPanelRef:h,mainAreaMode:g,setSidebarTab:_,sidebarCollapsed:v,sidebarTab:y,terminalPanelVisible:b,workspace:x,bottomPanelHeight:S,bottomPanelRef:C,workspaceId:w}=lx(),T=U(lg(w)),E=U(Sg),{closePreview:D}=Zb(w);return(0,V.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey){if(e.key.toLowerCase()===`b`){e.preventDefault(),E(e=>!e);return}if(e.key===`1`){e.preventDefault(),_(`files`);return}e.key===`2`&&(e.preventDefault(),_(`git`))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,_]),x?(0,Y.jsxs)(`div`,{ref:e,className:`workspace-page`,children:[(0,Y.jsx)(Hb,{fullscreenController:t}),(0,Y.jsxs)(`div`,{className:`workspace-body`,children:[!o&&!v&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`aside`,{ref:h,className:`left-panel`,style:{width:`${m}px`},children:(0,Y.jsxs)(`div`,{className:`nav-panel workspace-sidebar-panel`,children:[(0,Y.jsxs)(`div`,{className:`workspace-sidebar-panel__header`,children:[(0,Y.jsx)(Zm,{"aria-label":`Workspace sections`,onValueChange:_,value:y,children:(0,Y.jsxs)(Qm,{className:`workspace-sidebar-panel__tabs`,children:[(0,Y.jsx)($m,{className:`workspace-sidebar-panel__tab`,value:`files`,children:(0,Y.jsx)(`span`,{children:i(`file.title`)})}),(0,Y.jsx)($m,{className:`workspace-sidebar-panel__tab`,value:`git`,children:(0,Y.jsx)(`span`,{children:i(`label.git`)})})]})}),(0,Y.jsx)(`div`,{className:`workspace-sidebar-panel__actions`,children:y===`files`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{content:i(`file.new_file`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":i(`file.new_file`),icon:(0,Y.jsx)(Q,{semantic:`file.action.new`,size:14}),onClick:f,size:`sm`})}),(0,Y.jsx)($,{content:i(`file.new_folder`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":i(`file.new_folder`),icon:(0,Y.jsx)(Q,{semantic:`file.action.newFolder`,size:14}),onClick:p,size:`sm`})}),(0,Y.jsx)($,{content:i(`file.collapse_all`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":i(`file.collapse_all`),icon:(0,Y.jsx)(di,{size:14}),onClick:()=>r(e=>e+1),size:`sm`})})]}):null})]}),(0,Y.jsx)(`div`,{className:`workspace-sidebar-panel__body`,children:y===`files`?(0,Y.jsx)(vx,{workspaceId:x.id,createRequest:a,onCreateRequestConsumed:l,collapseVersion:n,variant:`desktop`}):(0,Y.jsx)(Wx,{workspaceId:x.id,variant:`desktop`})})]})}),(0,Y.jsx)(`div`,{className:`split-divider-v`,onMouseDown:u,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize left panel`})]}),(0,Y.jsxs)(`div`,{className:`workspace-main-area`,children:[g===`diff`?(0,Y.jsx)(Dx,{workspaceId:x.id,onClose:()=>{D(),T(null)}}):g===`editor`?(0,Y.jsx)(Cb,{}):(0,Y.jsx)(`div`,{className:`agent-panes`,children:(0,Y.jsx)(hb,{hydrateSessions:!1})}),!o&&b&&(0,Y.jsx)(`div`,{className:`split-divider-h`,onMouseDown:c,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize bottom panel`}),!o&&b&&(0,Y.jsx)(`div`,{ref:C,className:`workspace-bottom-panel`,style:{height:`${S}px`},children:(0,Y.jsx)(Nb,{})})]})]}),(0,Y.jsx)(oS,{align:`start`,workspaceId:x.id,gitState:s,onOpenBranchSwitcher:d})]}):(0,Y.jsx)(`div`,{className:`workspace-page workspace-page-empty`,children:(0,Y.jsx)(`div`,{className:`workspace-empty-content`,children:(0,Y.jsx)(`div`,{className:`workspace-empty-inner`,children:(0,Y.jsx)(Pm,{style:{minHeight:`auto`,padding:0},title:(0,Y.jsx)(`p`,{children:i(`workspace.no_workspace`)})})})})})},cS={minHeight:`auto`,padding:0,gap:0,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function lS({title:e,description:t,testId:n}){return(0,Y.jsx)(`div`,{className:`workspace-resolving-shell`,"data-testid":n,children:(0,Y.jsx)(`div`,{className:`workspace-resolving-card`,children:(0,Y.jsx)(Pm,{style:cS,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`workspace-resolving-kicker`,children:X()(`workspace.title`)}),(0,Y.jsx)(`div`,{className:`workspace-resolving-title`,children:e})]}),description:(0,Y.jsx)(`div`,{className:`workspace-resolving-desc`,children:t})})})})}function uS({title:e,description:t}){let n=X();return(0,Y.jsx)(lS,{title:e??n(`workspace.load_failed_title`),description:t??n(`workspace.load_failed_description`)})}function dS(){let e=X();return(0,Y.jsx)(lS,{testId:`workspace-resolving-shell`,title:e(`workspace.loading_title`),description:e(`workspace.loading_description`)})}function fS({children:e}){let t=H(np),n=H(Xf),r=H(Zf),i=Wt().pathname===`/workspace`;return!t&&n===`error`?(0,Y.jsx)(uS,{description:r??`Failed to fetch workspace list`}):!t&&(n===`idle`||n===`loading`||i&&n===`ready`)?(0,Y.jsx)(dS,{}):(0,Y.jsx)(Y.Fragment,{children:e})}function pS(){let e=(0,V.useRef)(0),t=qt(),n=Wt(),r=H(Rr),i=H(Lf),a=H(Wf),o=H(ep),s=H(Sa),c=H(Uf),l=H(Xf),u=U(qf),d=U(Ta),f=U(Jf),p=U(Yf),m=U(Xf),h=U(Zf);(0,V.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 mS=25e3;function hS(){let e=H(Rr),t=H(Br),n=H(Lf),r=H(Bf),[i,a]=(0,V.useState)(()=>Date.now());if((0,V.useEffect)(()=>{if(r===null||n!==`reconnecting`&&n!==`disconnected`)return;let e=r+mS-Date.now();if(e<=0){a(Date.now());return}let t=setTimeout(()=>{a(Date.now())},e);return()=>{clearTimeout(t)}},[n,r]),n===`connected`||n===`connecting`)return null;if(n===`rejected`||e===`gated`&&t===`displaced`)return(0,Y.jsx)(`div`,{className:`connection-banner connection-banner--error`,role:`status`,"aria-live":`polite`,children:(0,Y.jsx)(`span`,{children:`另一个标签页已激活`})});let o=r!==null&&i-r>=mS&&(n===`reconnecting`||n===`disconnected`);return(0,Y.jsxs)(`div`,{className:`connection-banner`,role:`status`,"aria-live":`polite`,children:[(0,Y.jsx)(`span`,{children:`连接已断开,正在重新连接...`}),o?(0,Y.jsx)(`span`,{children:`连接恢复较慢,可能是网络问题。如果长时间没有恢复,可以刷新页面。`}):null]})}var gS={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function _S(){pS();let e=H(Uf),t=Wt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname===`/session-gate`;return(0,Y.jsxs)(`div`,{className:`app`,children:[(0,Y.jsx)(hS,{}),(0,Y.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,Y.jsx)(`div`,{className:`app-loading-shell`,children:(0,Y.jsx)(`div`,{className:`app-loading-card`,children:(0,Y.jsx)(Pm,{style:gS,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,Y.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,Y.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,Y.jsxs)(xn,{children:[(0,Y.jsx)(yn,{path:`/`,element:(0,Y.jsx)(R_,{})}),(0,Y.jsx)(yn,{path:`/login`,element:(0,Y.jsx)(Gh,{})}),(0,Y.jsx)(yn,{path:`/session-gate`,element:(0,Y.jsx)(qh,{})}),(0,Y.jsx)(yn,{path:`/workspace`,element:(0,Y.jsx)(fS,{children:(0,Y.jsx)(sS,{})})}),(0,Y.jsx)(yn,{path:`/settings`,element:(0,Y.jsx)(A_,{})}),(0,Y.jsx)(yn,{path:`*`,element:(0,Y.jsx)(Ig,{})})]})}),(0,Y.jsx)(Ng,{}),(0,Y.jsx)(Ug,{})]})}function vS({sessionId:e,onOpen:t}){let n=H(Ov),r=X(),i=(0,V.useMemo)(()=>{if(!e)return null;let t=n.get(e);return t?{state:t.state,label:r(`supervisor.title`)}:{state:`inactive`,label:r(`supervisor.title`)}},[e,n,r]);return i?(0,Y.jsxs)(`button`,{type:`button`,className:`mobile-supervisor-badge mobile-supervisor-badge--${i.state}`,"aria-label":r(`mobile.supervisor.open_sheet`),onClick:t,children:[(0,Y.jsx)(`span`,{className:`mobile-supervisor-badge__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`supervisor.entry`,size:13})}),(0,Y.jsx)(`span`,{className:`mobile-supervisor-badge__label`,children:i.label})]}):null}function yS({sessionId:e,workspaceId:t,onClose:n,defaultSupervisorDetailsOpen:r=!1}){let i=X(),[a,o]=(0,V.useState)(null),s=U(jv),{dialog:c,supervisor:l,mode:u,copy:d,isDisable:f,disableObjective:p,isMaxSupervisionCountValid:m,close:h,updateDraft:g,confirm:_}=Rv({workspaceId:t,sessionId:e});(0,V.useEffect)(()=>{l||a||s(t=>t.sessionId===e&&t.mode===`enable`&&!t.open?t:{open:!1,sessionId:e,mode:`enable`,draftObjective:t.sessionId===e&&t.mode===`enable`?t.draftObjective:``,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:``})},[a,e,s,l]),(0,V.useEffect)(()=>{if(!c.open||c.sessionId!==e){o(null);return}o(c.mode)},[c.mode,c.open,c.sessionId,e]);let v=t=>{s({open:!0,sessionId:e,mode:t,draftObjective:l?.objective??``,draftEvaluatorProviderId:l?.evaluatorProviderId??`claude`,draftEvaluatorModel:l?.evaluatorModel??``,draftMaxSupervisionCount:String(l?.maxSupervisionCount??0),draftScheduledAt:Pv(l?.scheduledAt)}),o(t)},y=(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__detail`,children:[(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__detail-header`,children:[(0,Y.jsx)(`span`,{className:`supervisor-dialog-header-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Hv,{mode:u})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:d.title}),(0,Y.jsx)(`p`,{children:d.subtitle})]})]}),(0,Y.jsx)(Uv,{mode:u,draftObjective:c.draftObjective,draftEvaluatorProviderId:c.draftEvaluatorProviderId,draftEvaluatorModel:c.draftEvaluatorModel,draftMaxSupervisionCount:c.draftMaxSupervisionCount,draftScheduledAt:c.draftScheduledAt,isMaxSupervisionCountValid:m,disableObjective:p,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})})]}),b=(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__footer`,children:[(0,Y.jsx)(Lp,{onClick:()=>{h(),o(null),l||n()},children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:f?`danger`:`primary`,onClick:()=>{(async()=>{await _()&&!l&&n()})()},disabled:!f&&!c.draftObjective.trim(),children:d.confirm})]});return a?(0,Y.jsx)(Op,{title:d.title,kicker:i(`supervisor.title`),onBack:()=>{h(),o(null)},onClose:()=>{h(),o(null),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:y,footer:b}):l?(0,Y.jsx)(Op,{title:i(`supervisor.title`),kicker:i(`supervisor.title`),onClose:n,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--root`,fullscreen:!0,body:(0,Y.jsx)(`div`,{className:`mobile-supervisor-sheet__root`,children:l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(qv,{sessionId:e,workspaceId:t,defaultDetailsOpen:r}),(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__actions`,children:[(0,Y.jsx)(Lp,{onClick:()=>v(`edit`),children:i(`supervisor.action.edit_objective`)}),(0,Y.jsx)(Lp,{onClick:()=>v(`disable`),children:i(`supervisor.action.disable`)})]})]}):null})}):(0,Y.jsx)(Op,{title:d.title,kicker:i(`supervisor.title`),onClose:()=>{h(),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:y,footer:b})}var bS=`(orientation: landscape)`,xS=`(max-height: 540px)`;function SS(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return`default`;let e=window.matchMedia(bS).matches,t=window.matchMedia(xS).matches;return e&&t?`landscape-compact`:`default`}function CS(){let[e,t]=(0,V.useState)(SS);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(bS),n=window.matchMedia(xS),r=()=>{t(SS())};return e.addEventListener(`change`,r),n.addEventListener(`change`,r),r(),()=>{e.removeEventListener(`change`,r),n.removeEventListener(`change`,r)}},[]),e}var wS=`(prefers-reduced-motion: reduce)`;function TS(){return typeof window>`u`||typeof window.matchMedia!=`function`?`default`:window.matchMedia(wS).matches?`reduced`:`default`}function ES(){let[e,t]=(0,V.useState)(TS);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(wS),n=()=>{t(e.matches?`reduced`:`default`)};return e.addEventListener(`change`,n),n(),()=>{e.removeEventListener(`change`,n)}},[]),e}function DS(){let[e,t]=(0,V.useState)(0);return(0,V.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 OS(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 kS({activeSessionId:e,activeWorkspaceId:t,defaultMode:n=`list`,sessions:r,onClose:i,onCloseSession:a,onSelectSession:o,onSessionCreated:s}){let c=H(Wf),l=U(rp),u=X(),d=rg(),[f,p]=(0,V.useState)(n===`create`?`providers`:`sessions`),m=r.find(t=>t.id===e)??r[0]??null,h=!!t,g=[{id:`claude`,title:`Claude`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.claude`,size:16})},{id:`codex`,title:`Codex`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.codex`,size:16})}],_=()=>{p(n===`create`?`providers`:`sessions`),i()},{states:v,launch:y}=Tv(c,t??`__workspace_placeholder__`,(e,t)=>{l(t=>({...t,[e.id]:e})),s(e.id),_()}),b=[{kind:`actions`,id:`agent-actions`,items:[{id:`create`,label:u(`action.create_session`),icon:(0,Y.jsx)(Q,{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:OS(e),description:u(`mobile.agent.switch_to_agent`,{name:OS(e)}),meta:e.providerId.toUpperCase(),trailingAction:{id:`${e.id}-close`,ariaLabel:u(`mobile.agent.close_current_session`),icon:(0,Y.jsx)(ea,{size:16}),tone:`danger`,onAction:async()=>{await a(e.id),_()}}})):[]}],x=[{kind:`options`,id:`providers`,items:g.map(e=>{let t=v[e.id],n=t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`;return{id:e.id,label:e.title,description:u(`mobile.agent.start_session`,{provider:e.title}),meta:u(n?`mobile.agent.starting`:`mobile.agent.start_new_session`),icon:e.icon,disabled:!h||n}})}];return(0,Y.jsx)(sh,{className:`mobile-select-sheet--command`,title:u(f===`sessions`?`mobile.agent.title`:`session.provider_select`),sections:f===`sessions`?b:x,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:_,onSelect:e=>{if(f===`sessions`){t&&d({workspaceId:t,sessionId:e}),o(e),_();return}return y(e)}})}function AS({activeItem:e,onSelectItem:t}){let n=X();return(0,Y.jsxs)(`nav`,{className:`mobile-dock`,"aria-label":n(`mobile.dock.aria_label`),children:[(0,Y.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,Y.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`mobile.dock.agent`,size:18})}),(0,Y.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.agent`)})]}),(0,Y.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,Y.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`mobile.dock.files`,size:18})}),(0,Y.jsx)(`span`,{className:`mobile-dock__label`,children:n(`file.title`)})]}),(0,Y.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,Y.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`mobile.dock.terminal`,size:18})}),(0,Y.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.terminal`)})]})]})}function jS({workspaceId:e,route:t,activeTab:n,createRequest:r=null,onCreateRequestConsumed:i,collapseVersion:a=0,onCreateFile:o,onCreateFolder:s,onCollapseAll:c,onRouteChange:l,onTabChange:u,onCloseSheet:d,editorState:f}){let p=X(),{closePreview:m}=Zb(e);return t.kind===`editor`?(0,Y.jsx)(`div`,{className:`mobile-files-sheet`,children:(0,Y.jsx)(`div`,{className:`mobile-files-sheet__detail`,children:(0,Y.jsx)(Cb,{chrome:`content-only`,editorState:f})})}):t.kind===`diff`?(0,Y.jsx)(`div`,{className:`mobile-files-sheet`,children:(0,Y.jsx)(`div`,{className:`mobile-files-sheet__detail`,children:(0,Y.jsx)(Dx,{workspaceId:e,onClose:()=>{m(),d?.()},showCloseButton:!1})})}):(0,Y.jsxs)(`div`,{className:`mobile-files-sheet mobile-files-sheet--root`,children:[(0,Y.jsxs)(`div`,{className:`mobile-files-sheet__segmented`,children:[(0,Y.jsx)(Zm,{"aria-label":p(`mobile.files.tabs`),onValueChange:e=>u?.(e),value:n,children:(0,Y.jsxs)(Qm,{className:`mobile-files-sheet__tabs`,children:[(0,Y.jsx)($m,{className:`mobile-files-sheet__segment`,value:`files`,children:(0,Y.jsx)(`span`,{children:p(`file.title`)})}),(0,Y.jsx)($m,{className:`mobile-files-sheet__segment`,value:`git`,children:(0,Y.jsx)(`span`,{children:p(`label.git`)})})]})}),n===`files`?(0,Y.jsxs)(`div`,{className:`mobile-files-sheet__tab-actions`,children:[(0,Y.jsx)($,{content:p(`file.new_file`),children:(0,Y.jsx)(Z,{className:`mobile-files-sheet__tab-action`,"aria-label":p(`file.new_file`),icon:(0,Y.jsx)(Q,{semantic:`file.action.new`,size:14}),onClick:o,size:`sm`})}),(0,Y.jsx)($,{content:p(`file.new_folder`),children:(0,Y.jsx)(Z,{className:`mobile-files-sheet__tab-action`,"aria-label":p(`file.new_folder`),icon:(0,Y.jsx)(Q,{semantic:`file.action.newFolder`,size:14}),onClick:s,size:`sm`})}),(0,Y.jsx)($,{content:p(`file.collapse_all`),children:(0,Y.jsx)(Z,{className:`mobile-files-sheet__tab-action`,"aria-label":p(`file.collapse_all`),icon:(0,Y.jsx)(di,{size:14}),onClick:c,size:`sm`})})]}):null]}),(0,Y.jsx)(`div`,{className:`mobile-files-sheet__content`,children:n===`files`?(0,Y.jsx)(vx,{workspaceId:e,createRequest:r,onCreateRequestConsumed:i,onSelectFile:e=>l?.({kind:`editor`,path:e}),collapseVersion:a,variant:`mobile`}):(0,Y.jsx)(Wx,{workspaceId:e,onPreviewOpen:e=>{l?.({kind:`diff`,path:e.path})},variant:`mobile`})})]})}function MS({activeWorkspace:e,drawerOpen:t,fullscreenController:n,onOpenSettings:r,onToggleDrawer:i}){let a=X(),o=Xh(e)||a(`mobile.workspace_drawer.select_title`);return(0,Y.jsxs)(`header`,{className:`mobile-topbar`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`mobile-topbar__workspace-button`,onClick:()=>{i()},"aria-label":a(`mobile.topbar.switch_workspace`),"aria-expanded":t,children:[(0,Y.jsx)(`span`,{className:`mobile-topbar__workspace-leading`,"aria-hidden":`true`,children:(0,Y.jsx)(ji,{size:18})}),(0,Y.jsx)(`span`,{className:`mobile-topbar__workspace-name`,children:o})]}),(0,Y.jsxs)(`div`,{className:`mobile-topbar__actions`,children:[(0,Y.jsx)(Z,{"aria-label":a(`mobile.topbar.open_settings`),className:`mobile-topbar__icon-button`,icon:(0,Y.jsx)(Q,{semantic:`nav.settings`,size:18}),onClick:r}),(0,Y.jsx)(Pb,{controller:n,className:`mobile-topbar__icon-button`,iconSize:18,dataTestId:`mobile-fullscreen-toggle`})]})]})}function NS({activeWorkspaceId:e,isOpen:t,workspaces:n,onClose:r,onOpenWorkspaceLauncher:i}){let a=qt(),o=U(qf),s=X(),c=Rb(),l=rg();return t?(0,Y.jsxs)(`div`,{className:`mobile-drawer-layer`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mobile-drawer-layer__backdrop`,"aria-label":s(`mobile.workspace_drawer.close`),onClick:r}),(0,Y.jsxs)(`aside`,{className:`mobile-workspace-drawer`,"aria-label":s(`mobile.workspace_drawer.aria_label`),children:[(0,Y.jsxs)(`div`,{className:`mobile-workspace-drawer__header`,children:[(0,Y.jsxs)(`div`,{className:`mobile-workspace-drawer__header-copy`,children:[(0,Y.jsx)(`div`,{className:`mobile-workspace-drawer__kicker`,children:s(`label.workspace`)}),(0,Y.jsx)(`h2`,{className:`mobile-workspace-drawer__title`,children:s(`mobile.workspace_drawer.select_title`)})]}),(0,Y.jsx)(Z,{"aria-label":s(`action.close`),className:`mobile-workspace-drawer__dismiss`,icon:(0,Y.jsx)(ea,{size:16}),onClick:r,size:`lg`})]}),(0,Y.jsx)(`div`,{className:`mobile-workspace-drawer__list`,children:n.map(t=>{let n=Xh(t)||t.id,i=t.id===e;return(0,Y.jsxs)(`div`,{className:`mobile-workspace-drawer__item ${i?`mobile-workspace-drawer__item--active`:``}`,children:[(0,Y.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,Y.jsxs)(`span`,{className:`mobile-workspace-drawer__item-name-row`,children:[(0,Y.jsx)(`span`,{className:`mobile-workspace-drawer__item-name`,children:n}),i?(0,Y.jsxs)(`span`,{className:`mobile-workspace-drawer__item-state`,children:[(0,Y.jsx)(oi,{size:12}),(0,Y.jsx)(`span`,{children:`Current`})]}):null]}),(0,Y.jsx)(`span`,{className:`mobile-workspace-drawer__item-path`,children:t.path})]}),(0,Y.jsx)(Z,{"aria-label":s(`mobile.workspace_drawer.close_workspace`,{name:n}),className:`mobile-workspace-drawer__item-close`,icon:(0,Y.jsx)(ea,{size:16}),onClick:()=>{c(t.id,{navigateHomeWhenEmpty:!0}).then(e=>{e&&r()})},size:`lg`})]},t.id)})}),(0,Y.jsx)(`div`,{className:`mobile-workspace-drawer__footer`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`mobile-workspace-drawer__footer-button`,onClick:()=>{i(),r()},children:[(0,Y.jsx)(Q,{semantic:`nav.newWorkspace`,size:14}),(0,Y.jsx)(`span`,{children:s(`tooltip.new_workspace`)})]})})]})]}):null}function PS(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 FS(){let e=(0,V.useRef)(null),t=(0,V.useRef)(null),n=(0,V.useRef)(null),r=ix(e),i=X(),a=qt(),o=H(wa),s=H(Ta),c=U(Ea),{activeSession:l,activeWorkspaceId:u,closeMobileSession:d,closeMobileSheet:f,handleMobileSessionCreated:p,handleOpenBranchSwitcher:m,gitState:h,mobileActiveSessionId:g,mobileAgentSessions:_,mobileFilesRoute:v,mobileSheet:y,openMobileSheet:b,orderedSessions:x,restoreMobileSession:S,selectMobileSession:C,updateMobileFilesRoute:w,workspace:T,workspaces:E}=lx(),{persistUiState:D}=B_(u??`__workspace_empty__`),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),[M,N]=(0,V.useState)(`files`),[P,F]=(0,V.useState)(null),[ee,I]=(0,V.useState)(0),[te,L]=(0,V.useState)(!1),R=DS(),z=CS(),ne=ES(),re=_b(),ie=T?.uiState?.activeSessionId??null,B=s?.workspaceId===T?.id?s.sessionId??null:null;(0,V.useEffect)(()=>{if(!T||t.current===T.id||_.length===0&&x.length===0)return;let e=PS(x.map(e=>e.id),x,_,B,ie);if(!e.sessionId){t.current=T.id;return}if(t.current=T.id,e.missingFromLayout){S(e.sessionId);return}e.sessionId!==g&&S(e.sessionId)},[g,_,x,B,ie,S,T]),(0,V.useEffect)(()=>{if(!T){t.current=null,n.current=null;return}g&&n.current!==g&&(n.current=g,T.uiState.activeSessionId!==g&&D({activeSessionId:g}))},[g,D,T]),(0,V.useEffect)(()=>{o&&o!==g&&x.some(e=>e.id===o)&&C(o)},[g,x,o,C]),(0,V.useEffect)(()=>(c(g),()=>{c(null)}),[g,c]);let ae=v.kind===`editor`?i(`file.title`):v.kind===`diff`?i(`label.git`):null,oe=e=>{F(t=>({id:(t?.id??0)+1,mode:e,baseDir:null}))},se=v.kind===`editor`?(0,Y.jsx)(xb,{state:re,variant:`mobile`}):null,ce=y===`files`?{title:v.kind===`editor`?v.path.split(`/`).pop()??i(`mobile.files.editor_fallback`):v.kind===`diff`?v.path.split(`/`).pop()??i(`worktree.diff_tab`):i(M===`files`?`file.title`:`label.git`),body:u?(0,Y.jsx)(jS,{workspaceId:u,route:v,activeTab:M,createRequest:P,onCreateRequestConsumed:()=>F(null),collapseVersion:ee,onCreateFile:()=>oe(`file`),onCreateFolder:()=>oe(`folder`),onCollapseAll:()=>I(e=>e+1),onRouteChange:w,onTabChange:N,onCloseSheet:f,editorState:re}):null,footer:u?(0,Y.jsx)(oS,{workspaceId:u,gitState:h,onOpenBranchSwitcher:m,flush:!0}):null,kicker:ae,onBack:v.kind===`root`?void 0:()=>w({kind:`root`}),backLabel:i(`action.back`),headerAction:se,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--files`}:y===`terminal`?{title:i(`label.terminal`),body:(0,Y.jsx)(`div`,{className:`mobile-terminal-sheet mobile-terminal-sheet--fullscreen`,children:(0,Y.jsx)(Nb,{chrome:`mobile-fullscreen`})}),footer:u?(0,Y.jsx)(oS,{workspaceId:u,gitState:h,onOpenBranchSwitcher:m,flush:!0}):null,kicker:null,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--terminal`}:null,le=e=>{if(e===`agent`){j(e=>!e);return}j(!1),b(e)},ue=A?`agent`:y===`files`||y===`terminal`?y:null;return(0,Y.jsxs)(`div`,{ref:e,className:`mobile-shell mobile-shell--${z} mobile-shell--motion-${ne}`,"data-testid":`mobile-shell`,"data-layout-mode":z,"data-motion-mode":ne,children:[(0,Y.jsx)(MS,{activeWorkspace:T,drawerOpen:O,fullscreenController:r,onOpenSettings:()=>{j(!1),a(`/settings`)},onToggleDrawer:()=>{j(!1),k(e=>!e)}}),(0,Y.jsx)(`main`,{className:`mobile-shell__viewport`,children:(0,Y.jsx)(`div`,{className:`mobile-shell__content`,children:x.length>0?(0,Y.jsx)(Y.Fragment,{children:l?(0,Y.jsx)(`section`,{className:`mobile-shell__agent-stage`,children:(0,Y.jsx)(nb,{sessionId:l.id,showHeaderActions:!1,showSupervisorInline:!1,headerAccessory:(0,Y.jsx)(vS,{sessionId:l.id,onOpen:()=>{j(!1),b(`supervisor`)}})})}):null}):(0,Y.jsx)(`section`,{className:`mobile-shell__agent-empty`,"data-testid":`mobile-agent-empty`,children:(0,Y.jsx)(`div`,{className:`mobile-shell__empty-content`,children:(0,Y.jsx)(Pm,{className:`mobile-shell__empty-state`,style:{minHeight:`auto`},title:(0,Y.jsxs)(`div`,{className:`mobile-shell__empty-heading`,children:[(0,Y.jsx)(`span`,{className:`mobile-shell__empty-kicker`,children:i(`label.agent`)}),(0,Y.jsx)(`p`,{className:`mobile-shell__empty-title`,children:i(`mobile.empty.start_session`)})]}),description:(0,Y.jsx)(`div`,{className:`mobile-shell__placeholder-copy`,children:(0,Y.jsx)(`p`,{children:i(`mobile.empty.files_terminal_hint`)})}),action:(0,Y.jsx)(`div`,{className:`mobile-shell__empty-action-row`,children:(0,Y.jsx)(`button`,{type:`button`,className:`mobile-shell__empty-cta`,onClick:()=>j(!0),children:i(`action.create_session`)})})})})})})}),(0,Y.jsxs)(`div`,{className:`mobile-shell__bottom-stack`,"data-testid":`mobile-bottom-stack`,style:{"--mobile-keyboard-inset":`${R}px`},children:[(0,Y.jsx)(`div`,{className:`mobile-dock-shell`,children:(0,Y.jsx)(AS,{activeItem:ue,onSelectItem:le})}),u?(0,Y.jsx)(oS,{workspaceId:u,gitState:h,onOpenBranchSwitcher:m}):null]}),A?(0,Y.jsx)(kS,{activeSessionId:g,activeWorkspaceId:u,defaultMode:_.length===0?`create`:`list`,sessions:_,onClose:()=>j(!1),onCloseSession:d,onSelectSession:C,onSessionCreated:p}):null,y===`supervisor`&&l?(0,Y.jsx)(yS,{sessionId:l.id,workspaceId:l.workspaceId,onClose:()=>{j(!1),f()}}):null,ce?(0,Y.jsx)(Op,{title:ce.title,body:ce.body,onClose:()=>{j(!1),f()},kicker:ce.kicker??void 0,onBack:ce.onBack,backLabel:ce.backLabel,headerAction:`headerAction`in ce?ce.headerAction:void 0,bodyClassName:ce.bodyClassName,contentClassName:ce.contentClassName,footer:`footer`in ce?ce.footer:void 0,fullscreen:ce.fullscreen}):null,(0,Y.jsx)(NS,{activeWorkspaceId:u,isOpen:O,workspaces:E,onClose:()=>k(!1),onOpenWorkspaceLauncher:()=>{j(!1),L(!0)}}),te?(0,Y.jsx)(Ag,{onClose:()=>L(!1)}):null]})}var IS={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function LS(){pS();let e=H(Uf),t=Wt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname===`/session-gate`;return(0,Y.jsxs)(`div`,{className:`app`,children:[(0,Y.jsx)(hS,{}),(0,Y.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,Y.jsx)(`div`,{className:`app-loading-shell`,children:(0,Y.jsx)(`div`,{className:`app-loading-card`,children:(0,Y.jsx)(Pm,{style:IS,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,Y.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,Y.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,Y.jsxs)(xn,{children:[(0,Y.jsx)(yn,{path:`/`,element:(0,Y.jsx)(R_,{})}),(0,Y.jsx)(yn,{path:`/login`,element:(0,Y.jsx)(Gh,{})}),(0,Y.jsx)(yn,{path:`/session-gate`,element:(0,Y.jsx)(qh,{})}),(0,Y.jsx)(yn,{path:`/workspace`,element:(0,Y.jsx)(fS,{children:(0,Y.jsx)(FS,{})})}),(0,Y.jsx)(yn,{path:`/settings`,element:(0,Y.jsx)(A_,{})}),(0,Y.jsx)(yn,{path:`*`,element:(0,Y.jsx)(Ig,{})})]})}),(0,Y.jsx)(Ng,{}),(0,Y.jsx)(nS,{}),(0,Y.jsx)(Ug,{})]})}function RS(){return Pr()===`mobile`?(0,Y.jsx)(LS,{}):(0,Y.jsx)(_S,{})}function zS(){return(0,Y.jsx)(cr,{children:(0,Y.jsx)(RS,{})})}var BS=1e3;function VS(){let e=H(If),t=H(Lf),n=H(Lr),[r,i]=xe(Rr),[a,o]=xe(zr),s=U(Br),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useCallback)(async()=>{if(!e)return!1;if(t!==`connected`)try{await e.connect()}catch{return s(null),i(e=>e===`gated`?e:`idle`),!1}if(c.current)return c.current;i(`claiming`);let r=e.sendCommand(`activation.claim`,{clientInstanceId:n}).then(e=>(o(e.generation),s(null),i(`active`),!0)).catch(()=>(s(null),i(e=>e===`gated`?e:`idle`),!1)).finally(()=>{c.current=null});return c.current=r,r},[n,t,o,s,i,e]);return(0,V.useEffect)(()=>{if(l.current!==null&&(clearTimeout(l.current),l.current=null),!(!e||t!==`connected`||r!==`idle`))return l.current=setTimeout(()=>{l.current=null,c.current||u()},BS),()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}},[u,t,r,e]),(0,V.useEffect)(()=>()=>{l.current!==null&&(clearTimeout(l.current),l.current=null),!(!e||a===null)&&e.sendCommand(`activation.release`,{clientInstanceId:n,generation:a}).catch(()=>{})},[n,a,e]),{status:r,generation:a,claim:u}}var HS=null,US=null,WS={refreshGit:!1,refreshBranches:!1,refreshWorktrees:!1,markTreeStale:!1,refreshEditorBuffers:!1},GS=250,KS=`ui.themeId`,qS=`ui.theme`;function JS(e){return e===`fs_change`}function YS(){let e=localStorage.getItem(KS);if(e!==null)try{return JSON.parse(e)}catch{return}let t=localStorage.getItem(qS);if(t!==null)try{return JSON.parse(t)}catch{return}}function XS(e){let t=ma(ha(e));return document.documentElement.setAttribute(`data-theme`,t.documentThemeAttr),t.id}function ZS(e,t){return{refreshGit:e.refreshGit||!!t.refreshGit,refreshBranches:e.refreshBranches||!!t.refreshBranches,refreshWorktrees:e.refreshWorktrees||!!t.refreshWorktrees,markTreeStale:e.markTreeStale||!!t.markTreeStale,refreshEditorBuffers:e.refreshEditorBuffers||!!t.refreshEditorBuffers}}function QS(e){let t=e.get(Yf),n=Object.values(e.get(rp)).map(e=>e.terminalId).filter(e=>!!e);e.set(Jf,{}),e.set(Yf,[]),e.set(Xf,`idle`),e.set(Zf,null),e.set(rp,{}),e.set(qf,null),e.set(Ov,new Map),e.set(kv,new Map);for(let n of t)e.set(ag(n),null),e.set(sg(n),new Set),e.set(dg(n),null),e.set(mg(n),{current:``,branches:[],loading:!1}),e.set(_g(n),{items:[],loading:!1}),e.set(og(n),!1),e.set(ug(n),0);for(let t of n)e.set(Yv(t),null)}function $S(e,t){let n=e.match(/^workspace\.([^.]+)\.(fs\.dirty|git\.state)$/);if(!n)return null;let r=n[1];if(n[2]===`fs.dirty`){let e=t??{};return{workspaceId:r,hint:{refreshGit:!0,refreshBranches:e.reason===`git_metadata`,refreshWorktrees:e.reason===`git_metadata`,markTreeStale:JS(e.reason),refreshEditorBuffers:e.reason===`fs_change`||e.reason===`file_content`}}}let i=t??{};return{workspaceId:r,hint:{refreshGit:!0,refreshBranches:!!i.branchChanged,refreshWorktrees:!!i.worktreeChanged,markTreeStale:!!i.treeChanged,refreshEditorBuffers:!!i.treeChanged}}}function eC({children:e}){let[,t]=xe(If),[n,r]=xe(ba),i=H(Uf),a=H(Sa),o=H(Lf),s=H(qf),c=U(Lf),l=U(Rf),u=U(Hf),d=U(Uf),f=U(Vf),p=U(Bf),m=U(zf),h=U(Jf),g=U(rp),_=U(Ov),v=U(kv),y=U(n_),b=me(),x=H(Wf),{claim:S}=VS();Qg();let C=(0,V.useRef)(null),w=(0,V.useRef)(x),T=(0,V.useRef)(new Map),E=(0,V.useRef)(new Map),D=(0,V.useRef)(s),O=(0,V.useRef)(o),k=(0,V.useRef)(null),A=(0,V.useRef)({mode:`inactive`,workspaceId:null}),j=(0,V.useRef)({theme:0}),M=(0,V.useRef)(!1);return(0,V.useEffect)(()=>{w.current=x},[x]),(0,V.useEffect)(()=>{if(o!==`connected`)return;let e=!1,t=!1,n=b.sub(n_,()=>{t=!0});return(async()=>{let n=await x(`settings.get`,{});e||!n.ok||!n.data||t||y({copyOnSelect:t_(n.data)})})(),()=>{e=!0,n()}},[o,x,y,b]),(0,V.useEffect)(()=>{D.current=s},[s]),(0,V.useEffect)(()=>{O.current=o},[o]),(0,V.useEffect)(()=>{o===`connected`&&b.get(Rr)!==`gated`&&S()},[S,o,b]),(0,V.useEffect)(()=>{M.current=localStorage.getItem(KS)!==null;let e=XS(YS());r(e),localStorage.setItem(KS,JSON.stringify(e))},[r]),(0,V.useEffect)(()=>{let e=ma(n);document.documentElement.setAttribute(`data-theme`,e.documentThemeAttr),localStorage.setItem(KS,JSON.stringify(e.id))},[n]),(0,V.useEffect)(()=>{if(o!==`connected`)return;let e=!1;return(async()=>{let t={...j.current},n=await x(`settings.get`,{});if(e||!n.ok||!n.data||j.current.theme!==t.theme)return;if(M.current){M.current=!1;return}let i=n.data;r(ha(i[`appearance.themeId`]??i[`appearance.theme`]??YS()))})(),()=>{e=!0}},[o,x,r]),(0,V.useEffect)(()=>{let e=b.sub(ba,()=>{j.current.theme+=1});return()=>{e()}},[b]),(0,V.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`/auth/status`)).json();d(!!e.authEnabled),b.set(Sa,!!e.authenticated||e.authEnabled===!1)}catch{b.set(Sa,!1)}})()},[d,b]),(0,V.useEffect)(()=>{if(i===null)return;if(i===!0&&!a){US&&=(clearTimeout(US),null),HS&&=(HS.disconnect(`auth_required`),null),C.current=null,t(null),c(`connecting`),l(null),u(null),f(0),p(null),m(!1);return}let e=e=>{c(e),e===`reconnecting`&&(f(e=>e+1),p(e=>e??Date.now())),(e===`disconnected`||e===`rejected`)&&m(!1),e===`connected`&&(f(0),p(null),s(!0))},n=e=>{w.current(`git.status`,{workspaceId:e}).then(t=>{t.ok&&t.data&&b.set(dg(e),t.data)}).catch(e=>{console.error(`[Git Status] git.status command threw error:`,e)})},r=()=>{if(A.current.mode===`inactive`)return;let e=C.current;e&&(A.current={mode:`inactive`,workspaceId:null},e.sendCommand(`workspace.deactivate`,{}).catch(()=>{}))},o=e=>{let t=A.current;if(t.mode===`active`&&t.workspaceId===e)return;let n=C.current;n&&(A.current={mode:`active`,workspaceId:e},n.sendCommand(`workspace.activate`,{workspaceId:e}).catch(()=>{}))},s=(e=!1)=>{if(document.visibilityState===`hidden`){r();return}let t=D.current;if(!t){r();return}e&&(A.current={mode:`inactive`,workspaceId:null}),o(t)},d=()=>{if(b.get(Rr)===`gated`)return;if(s(),document.visibilityState!==`visible`){k.current=null;return}let e=Date.now(),t=k.current;t!==null&&e-t<GS||(k.current=e,C.current?.recoverConnection(`visibility_resume`))},h=()=>{if(document.visibilityState===`hidden`){k.current=null,s();return}d()},g=()=>{d()},_=()=>{d()},v=()=>{b.get(Rr)!==`gated`&&C.current?.recoverConnection(`network_online`)},y=e=>{w.current(`git.branches`,{workspaceId:e}).then(t=>{if(t.ok&&t.data){b.set(mg(e),{current:t.data.current,branches:t.data.branches,loading:!1});return}b.set(mg(e),e=>({...e,loading:!1,error:t.error?.message??e.error}))}).catch(e=>{console.error(`[Git Branches] git.branches command threw error:`,e)})},x=e=>{b.set(_g(e),e=>({...e,loading:!0,error:void 0})),w.current(`worktree.list`,{workspaceId:e}).then(t=>{if(t.ok&&t.data&&Array.isArray(t.data.worktrees)){b.set(_g(e),{items:t.data.worktrees,loading:!1,lastLoadedAt:Date.now()});return}b.set(_g(e),e=>({...e,loading:!1,error:t.error?.message??e.error}))}).catch(t=>{console.error(`[Worktree List] worktree.list command threw error:`,t),b.set(_g(e),e=>({...e,loading:!1,error:t instanceof Error?t.message:String(t)}))})},S=(e,t)=>{let r=ZS(E.current.get(e)??WS,t);if(E.current.set(e,r),T.current.get(e))return;let i=setTimeout(()=>{T.current.delete(e);let t=E.current.get(e)??WS;E.current.delete(e),t.markTreeStale&&b.set(og(e),!0),t.refreshEditorBuffers&&b.set(ug(e),e=>e+1),t.refreshGit&&n(e),t.refreshBranches&&y(e),t.refreshWorktrees&&x(e)},60);T.current.set(e,i)},O=(e,t,n)=>{if(e===`activation.revoked`){let e=t??{};b.set(Rr,`gated`),b.set(Br,typeof e.reason==`string`&&e.reason.length>0?e.reason:`displaced`),b.set(zr,typeof e.generation==`number`?e.generation:null),QS(b),A.current={mode:`inactive`,workspaceId:null},C.current?.disconnect(`single_active_displaced`);return}let r=$S(e,t);r&&S(r.workspaceId,r.hint);try{nC(e,t,b)}catch(t){console.error(`Error handling event for topic ${e}:`,t)}},j=[`connection.*`,`activation.*`,`workspace.*`];if(US&&=(clearTimeout(US),null),HS){C.current=HS,t(HS);let n=HS.getStatus();c(n);let r=HS.onStatus(e),i=HS.subscribe(j,O);return(n===`disconnected`||n===`reconnecting`)&&HS.recoverConnection(`manual_retry`),s(),document.addEventListener(`visibilitychange`,h),window.addEventListener(`focus`,g),window.addEventListener(`pageshow`,_),window.addEventListener(`online`,v),()=>{document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`focus`,g),window.removeEventListener(`pageshow`,_),window.removeEventListener(`online`,v),r(),i(),T.current.forEach(e=>clearTimeout(e)),T.current.clear(),E.current.clear(),C.current=null,HS&&(US=setTimeout(()=>{HS&&=(HS.disconnect(`app_unmount`),null),US=null},50))}}let M=new Pf(Ff());HS=M,C.current=M,t(M);let N=M.onStatus(e),P=M.subscribe(j,O);return M.connect().catch(e=>{console.error(`Failed to connect WebSocket:`,e),l(e.message||`Connection failed`)}),s(),document.addEventListener(`visibilitychange`,h),window.addEventListener(`focus`,g),window.addEventListener(`pageshow`,_),window.addEventListener(`online`,v),()=>{document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`focus`,g),window.removeEventListener(`pageshow`,_),window.removeEventListener(`online`,v),N(),P(),T.current.forEach(e=>clearTimeout(e)),T.current.clear(),E.current.clear(),C.current=null,US=setTimeout(()=>{HS&&=(HS.disconnect(`app_unmount`),null),US=null},50)}},[t,c,l,u,d,f,p,m,h,g,_,v,b,i,a]),(0,V.useEffect)(()=>{if(i===null)return;if(i===!0&&!a){A.current={mode:`inactive`,workspaceId:null};return}if(o!==`connected`)return;if(document.visibilityState===`hidden`){if(A.current.mode!==`inactive`){let e=C.current;if(!e)return;A.current={mode:`inactive`,workspaceId:null},e.sendCommand(`workspace.deactivate`,{}).catch(()=>{})}return}if(!s){if(A.current.mode!==`inactive`){let e=C.current;if(!e)return;A.current={mode:`inactive`,workspaceId:null},e.sendCommand(`workspace.deactivate`,{}).catch(()=>{})}return}if(A.current.mode===`active`&&A.current.workspaceId===s)return;let e=C.current;e&&(A.current={mode:`active`,workspaceId:s},e.sendCommand(`workspace.activate`,{workspaceId:s}).catch(()=>{}))},[s,i,a,o]),(0,Y.jsx)(Y.Fragment,{children:e})}function tC(e,t){let n=e;return typeof n.version!=`string`||typeof n.serverInstanceId!=`string`?!1:(t.set(Hf,{version:n.version,serverInstanceId:n.serverInstanceId,authEnabled:typeof n.authEnabled==`boolean`?n.authEnabled:void 0}),typeof n.isWriter==`boolean`&&t.set(zf,n.isWriter),!0)}function nC(e,t,n){if(e===`connection.ready`){tC(t,n),n.set(Rf,null);return}if(e===`connection.status`){let e=t;e.status===`connected`&&tC(t,n),e.status===`connected`&&e.authEnabled===!1&&n.set(Sa,!0),e.status===`error`&&e.message&&n.set(Rf,e.message);return}let r=e.match(/^workspace\.([^.]+)\.(.+)$/);if(r){let e=r[1],i=r[2];if(i===`meta`){let r=t;if(!(n.get(Jf)[e]||r.path))return;n.set(Jf,t=>({...t,[e]:{...t[e],...r,id:e}})),n.set(Yf,t=>t.includes(e)?t:[...t,e]),n.set(Xf,`ready`),n.set(Zf,null);return}if(i===`fs.dirty`){if(JS((t??{}).reason)){let t=og(e);n.set(t,!0)}return}if(i===`git.state`)return;let a=i.match(/^session\.([^.]+)\.(.+)$/);if(a){let e=a[1],r=a[2];if(r===`lifecycle`){if(t.event===`removed`){let t=n.get(rp)[e];t?.terminalId&&n.set(Yv(t.terminalId),null),n.set(rp,t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}return}if(r===`state`){let e=t;n.set(rp,t=>({...t,[e.id]:e}));return}if(r===`progress`){console.log(`Session ${e} progress:`,t);return}if(r===`supervisor.state`){let e=t;if(e.event===`deleted`&&e.supervisorId)n.set(Ov,t=>{let n=new Map(t);for(let[t,r]of n.entries())if(r.id===e.supervisorId){n.delete(t);break}return n}),n.set(kv,t=>{let n=new Map(t);return n.delete(e.supervisorId),n});else if(e.supervisor){let t=e.supervisor;n.set(Ov,e=>{let n=new Map(e);return n.set(t.sessionId,t),n}),Array.isArray(t.cycles)&&n.set(kv,e=>{let n=new Map(e);return n.set(t.id,t.cycles),n})}return}if(r===`supervisor.cycle`){let e=t,r=e.cycle.supervisorId;n.set(kv,t=>{let n=new Map(t),i=(n.get(r)??[]).filter(t=>t.id!==e.cycle.id);return n.set(r,[e.cycle,...i].slice(0,20)),n});return}}let o=i.match(/^terminal\.([^.]+)\.(.+)$/);if(o){let r=o[1],i=o[2];if(i===`created`){let i=t,a=Yv(r);n.set(a,{id:i.id,workspaceId:e,kind:i.kind,alive:!0,title:i.title});return}if(i===`output`)return;if(i===`exit`){let e=t,i=Yv(r),a=n.get(i);a&&n.set(i,{...a,exitCode:e.code,alive:!1});return}}}console.log(`Unhandled event topic: ${e}`,t)}kr.createRoot(document.getElementById(`root`)).render((0,Y.jsx)(he,{children:(0,Y.jsx)(eC,{children:(0,Y.jsx)(zS,{})})}));
111
- //# sourceMappingURL=index-LQGuy5NX.js.map
106
+ `):``}function k_(e,t){return Object.fromEntries(t.map(t=>[t.id,O_(e[`providers.${t.id}.additionalArgs`])]))}function A_(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`}}var j_=[{titleKey:`settings.mobile_groups.workspace_runtime`,sections:[`general`,`providers`]},{titleKey:`settings.mobile_groups.interface_interaction`,sections:[`appearance`,`shortcuts`]}];function M_(e){let t=new Map(e.map(e=>[e.id,e])),n=j_.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 j_.map(e=>({titleKey:e.titleKey,sections:e.sections.map(e=>t.get(e))}))}function N_(){let e=X(),t=e(`settings.load_failed_unknown`),n=qt(),r=Pr()===`mobile`,i=H(Wf),a=H(Lf),o=H(Hf),s=H(tp),[c,l]=(0,V.useState)(()=>r?{kind:`root`,lastSection:w_}:{kind:`detail`,section:w_}),[u]=(0,V.useState)([{id:`claude`,displayName:`Claude`},{id:`codex`,displayName:`Codex`}]),[d,f]=(0,V.useState)(!0),[p,m]=(0,V.useState)(!0),[h,g]=(0,V.useState)(600),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(0),[x,S]=(0,V.useState)(10),[C,w]=(0,V.useState)(!0),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)(`standard`),[k,A]=(0,V.useState)({}),[j,M]=(0,V.useState)(`default`),[N,P]=(0,V.useState)(null),[F,ee]=(0,V.useState)(0),[I,te]=xe(xa),[L,R]=xe(ba),z=H(n_),ne=U(Lg),re=U(n_),ie=(0,V.useRef)(t),B=(0,V.useRef)({theme:0,locale:0,terminalRenderer:0,terminalCopyOnSelect:0}),ae=c.kind===`detail`?c.section:c.lastSection,oe=r?__:g_,se=oe.find(e=>e.id===ae)??oe[0];(0,V.useEffect)(()=>{ie.current=t},[t]),(0,V.useEffect)(()=>{l(e=>r?e.kind===`root`?e:{kind:`root`,lastSection:e.section}:e.kind===`detail`?e:{kind:`detail`,section:e.lastSection})},[r]),(0,V.useEffect)(()=>{if(a!==`connected`)return;let e=!1;return(async()=>{let t={...B.current},n=await i(`settings.get`,{});if(!n.ok||!n.data){e||P(n.error?.message??ie.current);return}let r=n.data;if(!e){if(P(null),typeof r[`notifications.enabled`]==`boolean`&&f(r[`notifications.enabled`]),typeof r[`notifications.soundEnabled`]==`boolean`&&m(r[`notifications.soundEnabled`]),g(ka(r[`supervisor.evaluationTimeoutSec`])),v(Aa(r[`supervisor.retryEnabled`])),b(ja(r[`supervisor.retryMaxCount`])),S(Ma(r[`supervisor.retryDelaySec`])),w(Na(r[`supervisor.retryOnTimeout`])),E(Pa(r[`supervisor.retryOnEvaluatorError`])),ne({enabled:typeof r[`notifications.enabled`]==`boolean`?r[`notifications.enabled`]:!0,soundEnabled:typeof r[`notifications.soundEnabled`]==`boolean`?r[`notifications.soundEnabled`]:!0}),(r[`appearance.terminalRenderer`]===`standard`||r[`appearance.terminalRenderer`]===`compatibility`)&&B.current.terminalRenderer===t.terminalRenderer&&O(r[`appearance.terminalRenderer`]),B.current.terminalCopyOnSelect===t.terminalCopyOnSelect&&re({copyOnSelect:t_(r)}),(r[`appearance.locale`]===`zh`||r[`appearance.locale`]===`en`)&&B.current.locale===t.locale&&te(r[`appearance.locale`]),(Object.hasOwn(r,`appearance.themeId`)||Object.hasOwn(r,`appearance.theme`))&&B.current.theme===t.theme){let e=ha(r[`appearance.themeId`]??r[`appearance.theme`]);R(e),document.documentElement.setAttribute(`data-theme`,ma(e).documentThemeAttr)}A(k_(r,u))}})(),()=>{e=!0}},[a,i,te,ne,re,R,F]);let ce=e=>{B.current.locale+=1,te(e)},le=e=>{B.current.theme+=1,R(e)},ue=e=>{B.current.terminalRenderer+=1,O(e)},de=e=>{B.current.terminalCopyOnSelect+=1,re({copyOnSelect:e})};(0,V.useEffect)(()=>{ae!==`providers`&&M(`default`)},[ae]);let fe=()=>{let e=h_(!!s);if(e===`history`){n(-1);return}n(e)},pe=()=>{if(r&&c.kind===`detail`){l({kind:`root`,lastSection:c.section});return}fe()},me=()=>{switch(ae){case`general`:return(0,Y.jsx)(R_,{isMobile:r,notificationsEnabled:d,setNotificationsEnabled:f,soundEnabled:p,setSoundEnabled:m,supervisorEvaluationTimeoutSec:h,setSupervisorEvaluationTimeoutSec:g,supervisorRetryEnabled:_,setSupervisorRetryEnabled:v,supervisorRetryMaxCount:y,setSupervisorRetryMaxCount:b,supervisorRetryDelaySec:x,setSupervisorRetryDelaySec:S,supervisorRetryOnTimeout:C,setSupervisorRetryOnTimeout:w,supervisorRetryOnEvaluatorError:T,setSupervisorRetryOnEvaluatorError:E,terminalRenderer:D,setTerminalRenderer:ue,terminalCopyOnSelect:z.copyOnSelect,setTerminalCopyOnSelect:de});case`appearance`:return(0,Y.jsx)(z_,{locale:I,setLocale:ce,theme:L,setTheme:le});case`providers`:return(0,Y.jsx)(f_,{providers:u,additionalArgsById:k,setAdditionalArgsById:A,isMobile:r,onLayoutModeChange:M});case`shortcuts`:return(0,Y.jsx)(C_,{});default:return null}},he=()=>(0,Y.jsx)(`main`,{className:`settings-content settings-content--mobile-root`,children:(0,Y.jsx)(`div`,{className:`settings-mobile-root`,"data-testid":`settings-mobile-root`,children:M_(oe).map(t=>(0,Y.jsxs)(`section`,{className:`settings-mobile-group`,children:[(0,Y.jsx)(`h2`,{className:`settings-mobile-group__title`,children:e(t.titleKey)}),(0,Y.jsx)(`div`,{className:`settings-mobile-group__list`,children:t.sections.map(t=>(0,Y.jsxs)(`button`,{type:`button`,className:`settings-mobile-item`,"aria-label":e(t.labelKey),onClick:()=>l({kind:`detail`,section:t.id}),children:[(0,Y.jsx)(`span`,{className:`settings-mobile-item__icon-shell`,"aria-hidden":`true`,children:(0,Y.jsx)(`span`,{className:`settings-mobile-item__icon`,children:(0,Y.jsx)(Q,{semantic:t.iconSemantic,size:18})})}),(0,Y.jsxs)(`span`,{className:`settings-mobile-item__copy`,children:[(0,Y.jsx)(`span`,{className:`settings-mobile-item__label`,children:e(t.labelKey)}),(0,Y.jsx)(`span`,{className:`settings-mobile-item__hint`,children:e(A_(t.id))})]}),(0,Y.jsx)(li,{size:16,className:`settings-mobile-item__arrow`})]},t.id))})]},t.titleKey))})}),ge=r&&c.kind===`root`,_e=r&&c.kind===`detail`,ve=e(r?ge?`settings.title`:se.labelKey:`settings.title`);return(0,Y.jsxs)(`div`,{className:`settings-page ${r?`settings-page--mobile`:``}`,children:[(0,Y.jsx)(`header`,{className:`settings-header`,children:r?(0,Y.jsx)(yp,{title:ve,titleAs:`div`,onBack:pe,backLabel:e(`action.back`)}):(0,Y.jsxs)(`div`,{className:`settings-header__desktop`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`page-header__back settings-header__back`,onClick:pe,children:[(0,Y.jsx)(ci,{size:16}),(0,Y.jsx)(`span`,{children:e(`action.back`)})]}),(0,Y.jsx)(`div`,{className:`settings-header__copy`,children:(0,Y.jsx)(`h1`,{className:`page-title settings-header__title`,children:e(`settings.title`)})})]})}),ge?he():(0,Y.jsxs)(`div`,{className:`settings-body ${r?`settings-body--mobile`:``} ${_e?`settings-body--mobile-detail`:``} ${j===`fill-height`?`settings-body--fill-height`:``}`,children:[r?null:(0,Y.jsx)(`aside`,{className:`settings-sidebar`,children:(0,Y.jsx)(`nav`,{className:`settings-nav`,children:oe.map(({id:t,labelKey:n,iconSemantic:r})=>(0,Y.jsx)(P_,{icon:(0,Y.jsx)(Q,{semantic:r,size:16}),label:e(n),active:ae===t,onClick:()=>l({kind:`detail`,section:t})},t))})}),(0,Y.jsx)(`main`,{className:`settings-content ${r?`settings-content--mobile`:``} ${_e?`settings-content--mobile-detail`:``} ${j===`fill-height`?`settings-content--fill-height`:``}`,children:(0,Y.jsxs)(`div`,{className:`settings-content-surface`,children:[N&&(0,Y.jsx)(Vm,{role:`alert`,tone:`error`,title:e(`settings.load_failed`),message:N,action:(0,Y.jsx)(`button`,{type:`button`,className:`settings-link`,onClick:()=>ee(e=>e+1),children:e(`action.refresh`)})}),me()]})})]}),(0,Y.jsx)(`footer`,{className:`settings-footer ${r?`settings-footer--mobile`:``}`,children:(0,Y.jsxs)(`div`,{className:`settings-footer__meta`,children:[(0,Y.jsx)(`span`,{className:`settings-autosave`,children:e(`settings.autosave_hint`)}),(0,Y.jsxs)(`span`,{className:`settings-version`,children:[`v`,o?.version??`0.0.0`]})]})})]})}function P_({icon:e,label:t,active:n,onClick:r}){return(0,Y.jsxs)(`button`,{className:`settings-nav-item ${n?`settings-nav-item-active`:``}`,onClick:r,children:[(0,Y.jsx)(`span`,{className:`settings-nav-icon`,children:e}),(0,Y.jsx)(`span`,{className:`settings-nav-label`,children:t}),n&&(0,Y.jsx)(li,{size:14,className:`settings-nav-arrow`})]})}function F_(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 I_(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 L_(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 R_({isMobile:e,notificationsEnabled:t,setNotificationsEnabled:n,soundEnabled:r,setSoundEnabled:i,supervisorEvaluationTimeoutSec:a,setSupervisorEvaluationTimeoutSec:o,supervisorRetryEnabled:s,setSupervisorRetryEnabled:c,supervisorRetryMaxCount:l,setSupervisorRetryMaxCount:u,supervisorRetryDelaySec:d,setSupervisorRetryDelaySec:f,supervisorRetryOnTimeout:p,setSupervisorRetryOnTimeout:m,supervisorRetryOnEvaluatorError:h,setSupervisorRetryOnEvaluatorError:g,terminalRenderer:_,setTerminalRenderer:v,terminalCopyOnSelect:y,setTerminalCopyOnSelect:b}){let x=X(),S=(0,V.useId)(),C=(0,V.useId)(),w=(0,V.useId)(),T=(0,V.useId)(),E=(0,V.useId)(),D=(0,V.useId)(),O=(0,V.useId)(),k=(0,V.useId)(),A=H(Wf),j=U(Lg),[M,N]=(0,V.useState)(`unavailable`),[P,F]=(0,V.useState)(`unsupported`),[ee,I]=(0,V.useState)(String(a)),[te,L]=(0,V.useState)(null),[R,z]=(0,V.useState)(String(l)),[ne,re]=(0,V.useState)(String(d)),[ie,B]=(0,V.useState)(null),[ae,oe]=(0,V.useState)(null),se=async e=>await A(`settings.update`,{settings:e}),ce=e=>{j(e)};(0,V.useEffect)(()=>{if(F(D_()),`Notification`in window){N(Notification.permission);return}N(`unavailable`)},[]),(0,V.useEffect)(()=>{I(String(a))},[a]),(0,V.useEffect)(()=>{z(String(l))},[l]),(0,V.useEffect)(()=>{re(String(d))},[d]),(0,V.useEffect)(()=>{L(null)},[a]),(0,V.useEffect)(()=>{B(null)},[l]),(0,V.useEffect)(()=>{oe(null)},[d]);let le=async()=>{`Notification`in window&&N(await Notification.requestPermission())},ue=async()=>{let e=F_(ee);if(e===null){I(String(a)),L(x(`settings.supervisor.validation_error`,{max:Da}));return}if(e===a){I(String(e)),L(null);return}let t=await se({supervisor:{evaluationTimeoutSec:e}});if(!t.ok){I(String(a)),L(t.error?.message||x(`settings.config_files.save_failed`));return}o(e),I(String(e)),L(null)},de=async()=>{let e=I_(R);if(e===null){z(String(l)),B(x(`settings.supervisor.retry_max_count_validation_error`,{max:20}));return}if(e===l){z(String(e)),B(null);return}let t=await se({supervisor:{retryMaxCount:e}});if(!t.ok){z(String(l)),B(t.error?.message||x(`settings.config_files.save_failed`));return}u(e),z(String(e)),B(null)},fe=async()=>{let e=L_(ne);if(e===null){re(String(d)),oe(x(`settings.supervisor.retry_delay_validation_error`,{max:Oa}));return}if(e===d){re(String(e)),oe(null);return}let t=await se({supervisor:{retryDelaySec:e}});if(!t.ok){re(String(d)),oe(t.error?.message||x(`settings.config_files.save_failed`));return}f(e),re(String(e)),oe(null)};return(0,Y.jsxs)(`div`,{className:`settings-section`,children:[(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:x(`settings.notifications`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:x(`settings.notifications_channel_hint`)}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:S,children:x(`settings.notifications_enabled`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:C,children:x(`settings.notifications_enabled_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":C,"aria-labelledby":S,checked:t,className:`settings-toggle`,onCheckedChange:e=>{n(e),ce({enabled:e,soundEnabled:r}),se({notifications:{enabled:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:w,children:x(`settings.notification_sound`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:T,children:x(`settings.notification_sound_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":T,"aria-labelledby":w,checked:r,className:`settings-toggle`,disabled:!t,onCheckedChange:e=>{i(e),ce({enabled:t,soundEnabled:e}),se({notifications:{soundEnabled:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-info-row`,children:[(0,Y.jsx)(`span`,{className:`settings-info-label`,children:x(`settings.notification_status`)}),(0,Y.jsxs)(`span`,{className:`settings-info-value settings-capability-${P}`,children:[P===`available`&&x(`settings.notification_status_available`),P===`limited`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.notification_status_limited`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.notification_status_limited_hint`)})]}),P===`unsupported`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.notification_status_unsupported`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.notification_status_unsupported_hint`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`settings-info-row`,children:[(0,Y.jsx)(`span`,{className:`settings-info-label`,children:x(`settings.notification_permission`)}),(0,Y.jsxs)(`span`,{className:`settings-info-value settings-permission-${M}`,children:[M===`granted`&&x(`settings.permission_granted`),M===`denied`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.permission_denied`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.permission_denied_hint`)})]}),M===`default`&&P===`available`&&(0,Y.jsx)(`button`,{className:`settings-link`,onClick:le,children:x(`settings.permission_request`)}),M===`default`&&P===`limited`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.permission_unavailable`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.permission_limited_hint`)})]}),M===`unavailable`&&(0,Y.jsxs)(Y.Fragment,{children:[x(`settings.permission_unavailable`),(0,Y.jsx)(`span`,{className:`settings-status-hint`,children:x(`settings.permission_unavailable_hint`)})]})]})]})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,id:E,children:x(`settings.terminal_renderer`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,id:D,children:x(`settings.terminal_renderer_hint`)}),(0,Y.jsxs)(`div`,{"aria-describedby":D,"aria-labelledby":E,className:`settings-pills`,role:`group`,children:[(0,Y.jsx)(Um,{leadingIcon:_===`standard`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{v(`standard`),se({appearance:{terminalRenderer:`standard`}})},active:_===`standard`,children:x(`settings.terminal_standard`)}),(0,Y.jsx)(Um,{leadingIcon:_===`compatibility`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{v(`compatibility`),se({appearance:{terminalRenderer:`compatibility`}})},active:_===`compatibility`,children:x(`settings.terminal_compatibility`)})]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:O,children:x(`settings.copy_on_select`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:k,children:x(`settings.copy_on_select_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":k,"aria-labelledby":O,checked:y,className:`settings-toggle`,onCheckedChange:e=>{b(e),se({appearance:{terminalCopyOnSelect:e}})}})]})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,children:x(`settings.supervisor.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,children:x(`settings.supervisor.hint`)}),(0,Y.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-evaluation-timeout`,children:x(`settings.supervisor.evaluation_timeout`)}),(0,Y.jsx)(`div`,{className:`settings-config-control`,children:(0,Y.jsx)(vm,{id:`supervisor-evaluation-timeout`,className:`settings-input-compact`,type:`number`,min:1,max:Da,step:1,inputMode:`numeric`,invalid:!!te,value:ee,onChange:e=>{I(e.target.value),te&&L(null)},onBlur:()=>{ue()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())}})}),te?(0,Y.jsx)(`span`,{className:`form-error`,role:`alert`,children:te}):null]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-enabled-label`,children:x(`settings.supervisor.retry_enabled`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-enabled-desc`,children:x(`settings.supervisor.retry_enabled_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":`supervisor-retry-enabled-desc`,"aria-labelledby":`supervisor-retry-enabled-label`,checked:s,className:`settings-toggle`,onCheckedChange:e=>{c(e),se({supervisor:{retryEnabled:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-max-count`,children:x(`settings.supervisor.retry_max_count`)}),(0,Y.jsx)(`div`,{className:`settings-config-control`,children:(0,Y.jsx)(vm,{id:`supervisor-retry-max-count`,className:`settings-input-compact`,type:`number`,min:0,max:20,step:1,inputMode:`numeric`,invalid:!!ie,value:R,onChange:e=>{z(e.target.value),ie&&B(null)},onBlur:()=>{de()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),de())}})}),ie?(0,Y.jsx)(`span`,{className:`form-error`,role:`alert`,children:ie}):null]}),(0,Y.jsxs)(`div`,{className:`settings-config-field settings-config-field--inline`,children:[(0,Y.jsx)(`label`,{className:`settings-config-label`,htmlFor:`supervisor-retry-delay-sec`,children:x(`settings.supervisor.retry_delay_sec`)}),(0,Y.jsx)(`div`,{className:`settings-config-control`,children:(0,Y.jsx)(vm,{id:`supervisor-retry-delay-sec`,className:`settings-input-compact`,type:`number`,min:1,max:Oa,step:1,inputMode:`numeric`,invalid:!!ae,value:ne,onChange:e=>{re(e.target.value),ae&&oe(null)},onBlur:()=>{fe()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),fe())}})}),ae?(0,Y.jsx)(`span`,{className:`form-error`,role:`alert`,children:ae}):null]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-timeout-label`,children:x(`settings.supervisor.retry_on_timeout`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-timeout-desc`,children:x(`settings.supervisor.retry_on_timeout_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":`supervisor-retry-on-timeout-desc`,"aria-labelledby":`supervisor-retry-on-timeout-label`,checked:p,className:`settings-toggle`,onCheckedChange:e=>{m(e),se({supervisor:{retryOnTimeout:e}})}})]}),(0,Y.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Y.jsxs)(`div`,{className:`settings-toggle-info`,children:[(0,Y.jsx)(`span`,{className:`settings-toggle-label`,id:`supervisor-retry-on-evaluator-error-label`,children:x(`settings.supervisor.retry_on_evaluator_error`)}),(0,Y.jsx)(`span`,{className:`settings-toggle-desc`,id:`supervisor-retry-on-evaluator-error-desc`,children:x(`settings.supervisor.retry_on_evaluator_error_hint`)})]}),(0,Y.jsx)(wh,{"aria-describedby":`supervisor-retry-on-evaluator-error-desc`,"aria-labelledby":`supervisor-retry-on-evaluator-error-label`,checked:h,className:`settings-toggle`,onCheckedChange:e=>{g(e),se({supervisor:{retryOnEvaluatorError:e}})}})]})]})]})}function z_({locale:e,setLocale:t,theme:n,setTheme:r}){let i=X(),a=(0,V.useId)(),o=(0,V.useId)(),s=(0,V.useId)(),c=(0,V.useId)(),l=(0,V.useId)(),u=H(Wf),d=ha(n),f=la.map(e=>({value:e.id,label:i(e.labelKey)})),p=async e=>{await u(`settings.update`,{settings:e})};return(0,Y.jsxs)(`div`,{className:`settings-section`,children:[(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,id:a,children:i(`settings.theme.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,id:o,children:i(`settings.theme.hint`)}),(0,Y.jsx)(mh,{desktopMode:`listbox`,id:s,"aria-describedby":o,"aria-label":i(`settings.theme.title`),className:`settings-input-compact`,mobileSheetTitle:i(`settings.theme.title`),options:f,value:d,onValueChange:e=>{let t=ma(e);t.id!==d&&(r(t.id),document.documentElement.setAttribute(`data-theme`,t.documentThemeAttr),p({appearance:{themeId:t.id}}))}})]}),(0,Y.jsxs)(`div`,{className:`settings-group`,children:[(0,Y.jsx)(`h3`,{className:`settings-group-title`,id:c,children:i(`settings.language.title`)}),(0,Y.jsx)(`p`,{className:`settings-group-desc`,id:l,children:i(`settings.language.hint`)}),(0,Y.jsxs)(`div`,{"aria-describedby":l,"aria-labelledby":c,className:`settings-pills`,role:`group`,children:[(0,Y.jsx)(Um,{leadingIcon:e===`zh`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{t(`zh`),p({appearance:{locale:`zh`}})},active:e===`zh`,children:i(`settings.language.zh`)}),(0,Y.jsx)(Um,{leadingIcon:e===`en`?(0,Y.jsx)(oi,{size:12}):void 0,onClick:()=>{t(`en`),p({appearance:{locale:`en`}})},active:e===`en`,children:i(`settings.language.en`)})]})]})]})}var B_={minHeight:`auto`,padding:0,gap:`var(--sp-5)`},V_=()=>{let e=X(),t=qt(),[n,r]=(0,V.useState)(!1),i=Pr()===`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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`welcome-container ${i?`welcome-container--mobile`:``}`,children:(0,Y.jsxs)(`div`,{className:`welcome-card ${i?`welcome-card--mobile`:``}`,children:[(0,Y.jsx)(`div`,{className:`welcome-card__hero`,children:(0,Y.jsx)(Pm,{style:B_,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`welcome-kicker page-kicker`,children:e(`welcome.kicker`)}),(0,Y.jsx)(`h1`,{className:`welcome-title page-title`,children:e(`welcome.title`)})]}),description:(0,Y.jsx)(`p`,{className:`welcome-body meta-text`,children:e(`welcome.description`)})})}),(0,Y.jsxs)(`div`,{className:`welcome-card__actions`,children:[(0,Y.jsxs)(`button`,{className:`welcome-btn`,onClick:()=>{r(!0)},children:[(0,Y.jsx)(Q,{semantic:`nav.newWorkspace`,size:18}),(0,Y.jsx)(`span`,{children:e(`action.open_workspace`)})]}),(0,Y.jsxs)(`button`,{className:`welcome-link`,onClick:()=>{t(`/settings`)},children:[(0,Y.jsx)(Q,{semantic:`nav.settings`,size:14}),(0,Y.jsx)(`span`,{children:e(`action.settings`)})]})]}),(0,Y.jsxs)(`div`,{className:`welcome-card__panel`,children:[(0,Y.jsx)(`div`,{className:`welcome-divider`}),(0,Y.jsx)(`div`,{className:`welcome-features`,children:a.map(e=>(0,Y.jsxs)(`div`,{className:`welcome-feature`,children:[(0,Y.jsx)(Q,{className:`welcome-feature-icon`,semantic:e.iconSemantic,size:18}),(0,Y.jsxs)(`div`,{className:`welcome-feature-text`,children:[(0,Y.jsx)(`div`,{className:`welcome-feature-title`,children:e.title}),(0,Y.jsx)(`div`,{className:`welcome-feature-desc`,children:e.description})]})]},e.iconSemantic))})]})]})}),n?(0,Y.jsx)(Ag,{onClose:()=>r(!1)}):null]})};function H_(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 U_(e){let t=H(Wf),n=U(Jf),r=me();return{persistUiState:(0,V.useCallback)(async i=>{if(!e||e.startsWith(`__workspace_`))return!1;let a=r.get(Jf)[e];if(!a)return!1;let o={...a.uiState,leftPanelWidth:r.get(bg),bottomPanelHeight:r.get(xg),focusMode:r.get(yg),...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?(H_(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])}}var W_=`ui.paneLayout.`,G_=`ui.paneRatio.`,K_={id:`root`,type:`leaf`},q_=Kf(e=>B(K_));function J_(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Y_(e){let t=J_();if(!t)return null;try{let n=t.getItem(`${W_}${e}`);return n?JSON.parse(n):null}catch{return null}}function X_(e){let t=J_();if(t)try{t.removeItem(`${W_}${e}`)}catch{}}function Z_(e,t){let n=J_();if(!n)return null;try{let r=n.getItem(`${G_}${e}.${t}`);if(r===null)return null;let i=Number(r);return Number.isFinite(i)?i:null}catch{return null}}function Q_(e,t,n){let r=J_();if(r)try{r.setItem(`${G_}${e}.${t}`,String(n))}catch{}}function $_(e){return{id:e,type:`leaf`}}function ev(e,t){return{id:e,type:`leaf`,sessionId:t}}function tv(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},$_(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=tv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function nv(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},$_(`${r}-draft`)]}}let r=e.children??[],i=!1,a=r.map(e=>{let r=nv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function rv(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=rv(e,t,n);return r!==e&&(i=!0),r});return i?{...e,children:a}:e}function iv(e,t){return t.startsWith(`__draft__`)?ov(e,t.replace(`__draft__`,``)):sv(e,t)}function av(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=av(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 ov(e,t){return av(e,t)??{id:e.id,type:`leaf`}}function sv(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=sv(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function cv(e,t){return lv(e,t)??{id:e.id,type:`leaf`}}function lv(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=lv(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 uv(e){return e.type===`leaf`?e.sessionId?[e.sessionId]:[]:e.children?.flatMap(e=>uv(e))??[]}function dv(e,t,n,r=`horizontal`){let i=mv(e,t);if(i)return i;if(n){let i=hv(e,t,r,n);if(i)return i}return hv(e,t,r)||(e.type===`leaf`&&!e.sessionId?{...e,sessionId:t}:{id:`root`,type:`leaf`,sessionId:t})}function fv(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},gv(n,2)]}}function pv(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=pv(e,t);return n!==e&&(r=!0),n});return r?{...e,children:i}:e}function mv(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=mv(i,t);if(a)return{...e,children:n.map((e,t)=>t===r?a:e)}}return null}function hv(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},ev(`${i}-session`,t)]}}let i=e.children??[];for(let a=0;a<i.length;a+=1){let o=i[a],s=hv(o,t,n,r);if(s)return{...e,children:i.map((e,t)=>t===a?s:e)}}return null}function gv(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},gv(r,t+1)]}}function _v(e){let t=U(q_(e)),n=me(),{persistUiState:r}=U_(e),i=(0,V.useCallback)(i=>{let a=n.get(q_(e)),o=typeof i==`function`?i(a):i;return t(o),r({paneLayout:o}),o},[r,t,n,e]),a=(0,V.useCallback)((e,t)=>{i(n=>nv(n,e,t))},[i]),o=(0,V.useCallback)((e,t)=>{i(n=>tv(n,e,t))},[i]),s=(0,V.useCallback)(e=>{i(t=>iv(t,e))},[i]),c=(0,V.useCallback)(e=>{i(t=>ov(t,e))},[i]),l=(0,V.useCallback)(e=>{i(t=>cv(t,e))},[i]),u=(0,V.useCallback)((e,t)=>{i(n=>rv(n,e,t))},[i]),d=(0,V.useCallback)(e=>{i({id:`root`,type:`leaf`,sessionId:e})},[i]);return{appendSession:(0,V.useCallback)((e,t,n=`horizontal`)=>{i(r=>dv(r,e,t,n))},[i]),assignSession:u,closeDraftPane:c,closeSessionPane:s,removeSessionPane:l,replaceWithSession:d,splitDraftPane:o,splitSessionPane:a}}var vv=new TextEncoder,yv=100,bv=5e3;function xv(e){return new Promise(t=>{setTimeout(t,e)})}function Sv(){let e=H(Wf),t=H(If),n=me(),r=(0,V.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,V.useCallback)(async t=>{let r=n.get(ap(t));if(!r)return!1;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)}let i=await e(`session.stop`,{sessionId:t});if(!i.ok&&i.error?.code!==`invalid_state`)return console.error(`Failed to stop session before removal:`,i.error?.message),!1;let a=Date.now()+bv;for(;Date.now()<a;){let r=n.get(ap(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 xv(yv)}return console.error(`Timed out waiting for session to end before removal:`,t),!1},[e,n]),submitSessionPrompt:(0,V.useCallback)(async(e,n)=>{let r=n.trim();if(!t||!r)return!1;try{return await t.sendTerminalInput(e,vv.encode(`${r}\r`),`submit`,r),!0}catch(e){return console.error(`Failed to submit session prompt:`,e),!1}},[t]),stopSession:r}}function Cv(e,t){let n=H(np),r=e===void 0?n:e,i=r?.id??`__workspace_empty__`,a=t?.disabled??!1,o=H(Wf),s=H(Lf),c=H(ip(i)),l=H(q_(i)),u=U(rp),d=U(q_(i)),f=me(),{persistUiState:p}=U_(i);return(0,V.useEffect)(()=>{if(a||!r||s!==`connected`)return;let e=!1,t=new Set(Object.values(f.get(rp)).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(rp)).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(q_(i)),l=wv(r?.uiState.paneLayout),m=l?null:wv(Y_(r.id)),h=l??m??c??K_,g=new Set(s.filter(e=>e.state!==`draft`).map(e=>e.id)),_=s.filter(e=>e.state!==`draft`),v=pv(h,g),y=new Set(uv(v)),b=s.filter(e=>e.state!==`draft`&&e.state!==`ended`&&!y.has(e.id)).map(e=>e.id);b.length>0&&(v=Tv(v,b)),uv(v).length>0||_.length>0&&(v=fv(_.map(e=>e.id))),v!==c&&d(v);let x=!l||m!==null||b.length>0,S=m!==null||uv(v).length>0;x&&S&&p({paneLayout:v}).then(e=>{e&&m!==null&&X_(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 wv(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=>wv(e)??K_)}:null}function Tv(e,t){let n=e,r=uv(n),i=r[r.length-1]??null;for(let e of t)n=dv(n,e,i,`horizontal`),i=e;return n}function Ev(e){return{providerId:e,available:!0,missingCommands:[],missingPrerequisites:[],autoInstallSupported:!1,installReadiness:`ready`,manualGuideKeys:[],docUrls:{provider:``,prerequisites:{}}}}function Dv(e){return{claude:{runtime:e?.claude??Ev(`claude`),loading:!1},codex:{runtime:e?.codex??Ev(`codex`),loading:!1}}}function Ov(e,t,n){let[r,i]=(0,V.useState)(Dv()),a=(0,V.useRef)({});(0,V.useEffect)(()=>{let t=!1;return(async()=>{let n=await e(`provider.runtimeStatus`,{});if(!t){if(!n.ok||!n.data){i(e=>({claude:{...e.claude,...Dv().claude},codex:{...e.codex,...Dv().codex}}));return}i(e=>({claude:{...e.claude,...Dv(n.data.providers).claude},codex:{...e.codex,...Dv(n.data.providers).codex}}))}})(),()=>{t=!0;for(let e of Object.values(a.current))typeof e==`number`&&window.clearTimeout(e)}},[e]);let o=async()=>{let t=await e(`provider.runtimeStatus`,{});!t.ok||!t.data||i(e=>({claude:{...e.claude,runtime:t.data.providers.claude,loading:!1},codex:{...e.codex,runtime:t.data.providers.codex,loading:!1}}))},s=(e,t,n)=>{i(r=>({...r,[e]:{...r[e],loading:!1,inlineError:n,installJob:r[e].installJob?{...r[e].installJob,failure:t}:r[e].installJob}}))};return{states:r,launch:async c=>{let l=r[c].runtime;if(!l)return;if(i(e=>({...e,[c]:{...e[c],loading:!0,inlineError:void 0}})),l.available){let r=await e(`session.create`,{workspaceId:t,providerId:c});if(r.ok&&r.data){n(r.data,c),i(e=>({...e,[c]:{...e[c],loading:!1}}));return}r.error?.code===`provider_cli_missing`&&await o(),i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:r.error?.message}}));return}if(!l.autoInstallSupported){i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:`manual`}}));return}let u=await e(`provider.install.start`,{providerId:c});if(!u.ok||!u.data){i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:u.error?.message}}));return}if(i(e=>({...e,[c]:{...e[c],installJob:u.data,loading:!1}})),u.data.status===`failed`){s(c,u.data.failure,u.data.failure?.message);return}if(u.data.status===`succeeded`){await o();let r=await e(`session.create`,{workspaceId:t,providerId:c});r.ok&&r.data&&n(r.data,c);return}let d=async()=>{let r=await e(`provider.install.get`,{jobId:u.data.jobId});if(!r.ok||!r.data){i(e=>({...e,[c]:{...e[c],loading:!1,inlineError:r.error?.message}}));return}if(i(e=>({...e,[c]:{...e[c],installJob:r.data,loading:!1,inlineError:void 0}})),r.data.status===`queued`||r.data.status===`running`){a.current[c]=window.setTimeout(d,1500);return}if(r.data.status===`failed`){s(c,r.data.failure,r.data.failure?.message);return}await o();let l=await e(`session.create`,{workspaceId:t,providerId:c});if(l.ok&&l.data){n(l.data,c);return}i(e=>({...e,[c]:{...e[c],inlineError:l.error?.message,loading:!1}}))};a.current[c]=window.setTimeout(d,1500)}}}var kv=({workspaceId:e,paneId:t,onAssignSession:n,onClosePane:r,onReplaceWithSession:i,onSplitPane:a})=>{let o=X(),s=H(Wf),c=U(rp),{states:l,launch:u}=Ov(s,e,(e,r)=>{c(t=>({...t,[e.id]:e})),t?n?.(t,e.id):i?.(e.id)}),d=e=>{let t=l[e];return t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`?o(`provider.install.cta.installing`):t.runtime?.available?o(`provider.install.cta.start`):t.runtime?.autoInstallSupported?o(`provider.install.cta.install_and_start`):o(`provider.install.cta.manual`)},f=e=>{let t=l[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`||t.runtime?.autoInstallSupported===!1?{message:t.runtime?.manualGuideKeys.map(e=>o(e)).join(` `),docUrl:t.runtime?.docUrls.provider}:{docUrl:t.runtime?.docUrls.provider}},p=Object.values(l).some(e=>e.loading||e.installJob?.status===`queued`||e.installJob?.status===`running`);return(0,Y.jsxs)(`div`,{className:`session-card agent-pane`,children:[(0,Y.jsxs)(`div`,{className:`session-header`,children:[(0,Y.jsxs)(`div`,{className:`session-header-left`,children:[(0,Y.jsx)(xh,{tone:`neutral`,className:`session-dot session-dot-idle`}),(0,Y.jsx)(`div`,{className:`session-header-copy`,children:(0,Y.jsxs)(`div`,{className:`session-title-row`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:o(`session.provider_select`)||`New Session`}),(0,Y.jsx)(kh,{color:`neutral`,className:`session-state-badge`,children:`DRAFT`})]})})]}),(0,Y.jsxs)(`div`,{className:`session-header-actions`,children:[(0,Y.jsx)($,{content:`Split horizontal`,children:(0,Y.jsx)(Z,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,Y.jsx)(Ji,{size:13}),onClick:()=>{t&&a?.(t,`horizontal`)},size:`sm`})}),(0,Y.jsx)($,{content:`Split vertical`,children:(0,Y.jsx)(Z,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,Y.jsx)(qi,{size:13}),onClick:()=>{t&&a?.(t,`vertical`)},size:`sm`})}),(0,Y.jsx)($,{content:`Close`,children:(0,Y.jsx)(Z,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>{t&&r?.(t)},size:`sm`})})]})]}),(0,Y.jsx)(`div`,{className:`agent-draft-launcher`,children:(0,Y.jsxs)(`div`,{className:`agent-draft-content`,children:[(0,Y.jsx)(`span`,{className:`agent-draft-kicker`,children:`SESSION LAUNCHER`}),(0,Y.jsx)(`p`,{className:`agent-draft-description`,children:`选择一个 AI 会话,在当前 workspace 里继续查看文件、运行命令和推进代码修改。`}),(0,Y.jsx)(`div`,{className:`agent-draft-providers`,children:[{id:`claude`,title:`Claude`,meta:`analysis`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.claude`,size:18}),description:`更适合长上下文梳理、方案分析和代码审查。`,className:`agent-provider-card-claude`},{id:`codex`,title:`Codex`,meta:`workspace`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.codex`,size:18}),description:`更适合终端操作、直接改文件和逐步修复问题。`,className:`agent-provider-card-codex`}].map(e=>{let t=l[e.id],n=f(e.id),r=t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`;return(0,Y.jsx)(Lp,{className:`agent-provider-card ${e.className}`,disabled:p,leadingIcon:(0,Y.jsx)(`span`,{className:`agent-provider-card-icon`,children:e.icon}),onClick:()=>{u(e.id)},trailingIcon:(0,Y.jsx)(ni,{size:16,className:`agent-provider-card-arrow`}),variant:`secondary`,children:(0,Y.jsxs)(`span`,{className:`agent-provider-card-body`,children:[(0,Y.jsxs)(`span`,{className:`agent-provider-card-title-row`,children:[(0,Y.jsx)(`span`,{className:`agent-provider-card-title`,children:e.title}),(0,Y.jsx)(`span`,{className:`agent-provider-card-meta`,children:e.meta})]}),(0,Y.jsx)(`span`,{className:`agent-provider-card-desc`,children:e.description}),(0,Y.jsx)(`span`,{className:`agent-provider-card-cta`,children:d(e.id)}),r?(0,Y.jsx)(`span`,{className:`agent-provider-card-status`,children:o(`provider.install.status.installing`)}):null,n.message?(0,Y.jsxs)(`span`,{className:`agent-provider-card-guide`,children:[(0,Y.jsx)(`span`,{children:n.message}),n.docUrl?(0,Y.jsx)(`a`,{href:n.docUrl,target:`_blank`,rel:`noreferrer`,children:o(`provider.install.open_docs`)}):null]}):null]})},e.id)})})]})})]})},Av=({splitId:e,direction:t,ratio:n,children:r,onRatioCommit:i})=>{let[a,o]=(0,V.useState)(n),s=(0,V.useRef)(null),c=(0,V.useRef)(!1),l=(0,V.useRef)(n),u=(0,V.useCallback)(()=>{c.current=!0,l.current=a,document.body.classList.add(`is-resizing-panels`)},[a]),d=(0,V.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,V.useCallback)(()=>{c.current&&(c.current=!1,document.body.classList.remove(`is-resizing-panels`),i?.(l.current))},[i]);(0,V.useEffect)(()=>(document.addEventListener(`mousemove`,d),document.addEventListener(`mouseup`,f),()=>{document.removeEventListener(`mousemove`,d),document.removeEventListener(`mouseup`,f)}),[d,f]),(0,V.useEffect)(()=>{o(n),l.current=n},[n,e]);let[p,m]=Array.isArray(r)?r:[r],h=t===`horizontal`?{gridTemplateColumns:`${a*100}% 8px ${(1-a)*100}%`}:{gridTemplateRows:`${a*100}% 8px ${(1-a)*100}%`};return(0,Y.jsxs)(`div`,{ref:s,className:`pane-layout pane-layout-${t}`,style:{display:`grid`,...h},children:[(0,Y.jsx)(`div`,{className:`pane-layout-child`,children:p}),(0,Y.jsx)(`div`,{className:`pane-layout-divider`,onMouseDown:u,role:`separator`,"aria-orientation":t===`horizontal`?`vertical`:`horizontal`}),(0,Y.jsx)(`div`,{className:`pane-layout-child`,children:m})]})},jv=B(new Map),Mv=B(new Map),Nv=Kf(e=>B(!1)),Pv=B({open:!1,sessionId:null,mode:`enable`,draftObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``});B(e=>t=>e(jv).get(t));var Fv=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}],Iv={open:!1,sessionId:null,mode:`enable`,draftObjective:``,draftEvaluatorProviderId:`claude`,draftEvaluatorModel:``,draftMaxSupervisionCount:`0`,draftScheduledAt:``};function Lv(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 Rv(e){let t=Number.parseInt(e,10);return!Number.isSafeInteger(t)||t<0?0:t}function zv(e){let t=(e??``).trim();if(!t)return!1;let n=Number(t);return Number.isSafeInteger(n)&&n>=0}function Bv(e){if(!e.trim())return;let t=Date.parse(e);if(Number.isFinite(t))return t}function Vv({workspaceId:e,sessionId:t}){let[n,r]=xe(Pv),i=H(jv),a=H(Wf),o=X(),s=t??n.sessionId,c=s?i.get(s):void 0,l=n.open&&(!t||n.sessionId===t),u=n.mode,d={title:o(`supervisor.dialog.${u}.title`),subtitle:o(`supervisor.dialog.${u}.subtitle`),confirm:o(`supervisor.dialog.${u}.confirm`)},f=u===`disable`,p=c?.objective??n.draftObjective,m=zv(n.draftMaxSupervisionCount),h=(0,V.useCallback)(()=>{r(Iv)},[r]);return{dialog:n,supervisor:c,isVisible:l,mode:u,copy:d,isDisable:f,disableObjective:p,isMaxSupervisionCountValid:m,close:h,updateDraft:(0,V.useCallback)(e=>{r(t=>({...t,...e}))},[r]),confirm:(0,V.useCallback)(async()=>{if(!n.sessionId)return!1;if(n.mode===`disable`)return c&&(await a(`supervisor.delete`,{id:c.id})).ok?(h(),!0):!1;let t=n.draftObjective.trim();if(!t||!m)return!1;let r=n.draftEvaluatorModel.trim(),i=Rv(n.draftMaxSupervisionCount),o=Bv(n.draftScheduledAt);return n.mode===`enable`?(await a(`supervisor.create`,{sessionId:n.sessionId,workspaceId:e,objective:t,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:r||void 0,maxSupervisionCount:i,scheduledAt:o})).ok?(h(),!0):!1:c&&(await a(`supervisor.update`,{id:c.id,objective:t,evaluatorProviderId:n.draftEvaluatorProviderId,evaluatorModel:r||null,maxSupervisionCount:i,scheduledAt:o??null})).ok?(h(),!0):!1},[h,n,a,m,c,e]),formatScheduledAtInput:Lv}}var Hv=`__supervisor-empty__`;function Uv(e){let t=e?.id??Hv,n=H(Wf),r=H(Nv(t)),i=U(Nv(t)),a=U(jv),o=U(Mv),s=U(Pv);return(0,V.useEffect)(()=>{if(!e||r||e.capability!==`full`||e.state===`draft`||e.state===`ended`)return;let t=!1;return n(`supervisor.get`,{sessionId:e.id}).then(n=>{if(t||!n.ok)return;let r=n.data?.supervisor??null;r?(a(t=>{let n=new Map(t);return n.set(e.id,r),n}),o(e=>{let t=new Map(e);return t.set(r.id,r.cycles??[]),t})):a(t=>{let n=new Map(t);return n.delete(e.id),n}),i(!0)}),()=>{t=!0}},[n,r,e,o,i,a]),{openDialog:(0,V.useCallback)((e,n)=>{s({open:!0,sessionId:t,mode:e,draftObjective:n?.objective??``,draftEvaluatorProviderId:n?.evaluatorProviderId??`claude`,draftEvaluatorModel:n?.evaluatorModel??``,draftMaxSupervisionCount:String(n?.maxSupervisionCount??0),draftScheduledAt:Lv(n?.scheduledAt)})},[t,s])}}var Wv=Fv.map(e=>({value:e.id,label:e.label}));function Gv({mode:e}){return e===`enable`?(0,Y.jsx)(Q,{semantic:`supervisor.mode.enable`,size:14}):e===`edit`?(0,Y.jsx)(Q,{semantic:`supervisor.mode.edit`,size:14}):(0,Y.jsx)(Q,{semantic:`supervisor.mode.disable`,size:14})}function Kv({mode:e,draftObjective:t,draftEvaluatorProviderId:n,draftEvaluatorModel:r,draftMaxSupervisionCount:i,draftScheduledAt:a,isMaxSupervisionCountValid:o,disableObjective:s,onDraftObjectiveChange:c,onDraftEvaluatorProviderChange:l,onDraftEvaluatorModelChange:u,onDraftMaxSupervisionCountChange:d,onDraftScheduledAtChange:f}){let p=X(),m=(0,V.useId)(),h=(0,V.useId)(),g=(0,V.useId)(),_=(0,V.useId)(),v=(0,V.useId)(),y=(0,V.useId)();return e===`disable`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`supervisor-danger-callout`,role:`alert`,children:[(0,Y.jsx)(Q,{"aria-hidden":`true`,className:`supervisor-danger-callout-icon`,semantic:`state.warning`,size:16}),(0,Y.jsxs)(`div`,{className:`supervisor-danger-callout-copy`,children:[(0,Y.jsx)(`strong`,{children:p(`supervisor.dialog.disable.warning_title`)}),(0,Y.jsx)(`small`,{children:p(`supervisor.dialog.disable.warning_body`)})]})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{children:p(`supervisor.field.current_objective`)}),(0,Y.jsx)(`pre`,{className:`objective-preview`,children:s})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`objective`,children:p(`supervisor.field.objective`)}),(0,Y.jsx)(Fh,{id:`objective`,size:`lg`,rows:5,value:t,onChange:e=>c(e.target.value),"aria-describedby":m,placeholder:p(`supervisor.field.objective_placeholder`),autoFocus:!0}),(0,Y.jsx)(`span`,{id:m,className:`dialog-helper`,children:p(`supervisor.field.objective_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{id:h,htmlFor:`evaluator-provider`,children:p(`supervisor.field.evaluator`)}),(0,Y.jsx)(mh,{id:`evaluator-provider`,desktopMode:`listbox`,mobileSheetTitle:p(`supervisor.field.evaluator`),mobileSheetPresentation:`inline`,options:Wv,value:n,"aria-labelledby":h,"aria-describedby":g,onValueChange:l}),(0,Y.jsx)(`span`,{id:g,className:`dialog-helper`,children:p(`supervisor.field.evaluator_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`evaluator-model`,children:p(`supervisor.field.evaluator_model`)}),(0,Y.jsx)(vm,{id:`evaluator-model`,size:`lg`,value:r,onChange:e=>u(e.target.value),"aria-describedby":_,placeholder:p(`supervisor.field.evaluator_model_placeholder`)}),(0,Y.jsx)(`span`,{id:_,className:`dialog-helper`,children:p(`supervisor.field.evaluator_model_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`max-supervision-count`,children:p(`supervisor.field.max_supervision_count`)}),(0,Y.jsx)(vm,{id:`max-supervision-count`,size:`lg`,type:`number`,min:0,step:1,value:i,onChange:e=>d(e.target.value),invalid:!o,"aria-invalid":!o,"aria-describedby":v}),(0,Y.jsx)(`span`,{id:v,className:`dialog-helper`,children:p(`supervisor.field.max_supervision_count_helper`)})]}),(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`scheduled-at`,children:p(`supervisor.field.scheduled_at`)}),(0,Y.jsx)(jm,{label:p(`supervisor.field.scheduled_at`),value:a,onValueChange:f,placeholder:p(`supervisor.field.scheduled_at_placeholder`),clearable:!0,minDate:new Date,"aria-describedby":y}),(0,Y.jsx)(`span`,{id:y,className:`dialog-helper`,children:p(`supervisor.field.scheduled_at_helper`)})]})]})}function qv({workspaceId:e,sessionId:t}){let n=Pr(),r=X(),{dialog:i,isVisible:a,mode:o,copy:s,isDisable:c,disableObjective:l,isMaxSupervisionCountValid:u,close:d,updateDraft:f,confirm:p}=Vv({workspaceId:e,sessionId:t});return!a||n===`mobile`?null:(0,Y.jsxs)(qp,{className:`supervisor-dialog supervisor-dialog--${o}`,onOpenChange:d,open:!0,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(`div`,{className:`supervisor-dialog-header`,children:[(0,Y.jsx)(`span`,{className:`supervisor-dialog-header-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Gv,{mode:o})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(Yp,{children:s.title}),(0,Y.jsx)(`span`,{className:`supervisor-dialog-subtitle`,children:s.subtitle})]})]}),(0,Y.jsx)(Z,{"aria-label":r(`action.close`),icon:(0,Y.jsx)(ea,{size:14}),onClick:d,size:`sm`})]}),(0,Y.jsx)(Xp,{children:(0,Y.jsx)(Kv,{mode:o,draftObjective:i.draftObjective,draftEvaluatorProviderId:i.draftEvaluatorProviderId,draftEvaluatorModel:i.draftEvaluatorModel,draftMaxSupervisionCount:i.draftMaxSupervisionCount,draftScheduledAt:i.draftScheduledAt,isMaxSupervisionCountValid:u,disableObjective:l,onDraftObjectiveChange:e=>f({draftObjective:e}),onDraftEvaluatorProviderChange:e=>f({draftEvaluatorProviderId:e}),onDraftEvaluatorModelChange:e=>f({draftEvaluatorModel:e}),onDraftMaxSupervisionCountChange:e=>f({draftMaxSupervisionCount:e}),onDraftScheduledAtChange:e=>f({draftScheduledAt:e})})}),(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{onClick:d,children:r(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:c?`danger`:`primary`,onClick:()=>{p()},disabled:!c&&(!i.draftObjective.trim()||!u),children:s.confirm})]})]})}var Jv={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 Yv({sessionId:e}){let t=H(jv),n=H(Mv),r=H(Wf),i=U(Pv),a=H(xa),o=X(),s=t.get(e),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!c)return;let e=window.setTimeout(()=>l(null),6e3);return()=>window.clearTimeout(e)},[c]);let u=(0,V.useCallback)(t=>{i({open:!0,sessionId:e,mode:t,draftObjective:s?.objective??``,draftEvaluatorProviderId:s?.evaluatorProviderId??`claude`,draftEvaluatorModel:s?.evaluatorModel??``,draftMaxSupervisionCount:String(s?.maxSupervisionCount??0),draftScheduledAt:Lv(s?.scheduledAt)})},[e,i,s]),d=(0,V.useCallback)(async(e,t,n)=>{l(null);let i=await r(e,{id:t});i.ok||l(i.error?.message?`${n}: ${i.error.message}`:n)},[r]),f=(0,V.useCallback)(async()=>{s&&await d(`supervisor.pause`,s.id,o(`supervisor.action.pause_failed`))},[d,s,o]),p=(0,V.useCallback)(async()=>{s&&await d(`supervisor.resume`,s.id,o(`supervisor.action.resume_failed`))},[d,s,o]),m=(0,V.useCallback)(async()=>{s&&await d(`supervisor.trigger`,s.id,o(`supervisor.action.trigger_failed`))},[d,s,o]),h=s?[...n.get(s.id)??s.cycles??[]].sort((e,t)=>(t.completedAt??t.createdAt)-(e.completedAt??e.createdAt)):[],g=h[0],_=h.some(e=>e.status===`evaluating`||e.status===`queued`),v=g?g.result??g.errorReason??(g.status===`completed`?o(`supervisor.cycle.no_guidance`):g.status===`evaluating`?o(`supervisor.cycle.evaluating`):g.status===`cancelled`?o(`supervisor.cycle.cancelled`):o(`supervisor.cycle.waiting`)):null,y=s?.currentTargetMemory??null,b=y?.plan??[],x=s?.recentTargetCycles??[],S=y?y.planGenerated?o(`supervisor.target_memory.plan_ready`):o(`supervisor.target_memory.plan_pending`):null,C=o(`supervisor.target_memory.progress_badge`),w=x[0]==null?null:o(`supervisor.target_memory.cycle_result.${x[0].result}`),T=s?.stopReason?o(`supervisor.stop_reason.${s.stopReason}`):null;return{actionError:c,cycles:h,executionPolicyItems:s?[s.evaluatorModel?{key:`model`,label:o(`supervisor.field.evaluator_model`),value:s.evaluatorModel}:null,{key:`max-count`,label:o(`supervisor.field.max_supervision_count`),value:s.maxSupervisionCount>0?String(s.maxSupervisionCount):o(`supervisor.meta.no_cap`)},s.scheduledAt?{key:`scheduled-at`,label:o(`supervisor.field.scheduled_at`),value:Dp(s.scheduledAt,a)}:null].filter(e=>e!==null):[],handlePause:f,handleResume:p,handleTrigger:m,isBusy:s?.state===`evaluating`||s?.state===`injecting`||_,latestCycle:g,latestCycleText:v,planGeneratedLabel:S,recentTargetCycles:x,targetCycleResultLabel:w,targetMemory:y,targetProgressLabel:C,targetPlanItems:b,openDialog:u,stopReasonLabel:T,stateClass:s?Jv[s.state]:Jv.inactive,stateLabel:o(`supervisor.state.${s?s.state:`inactive`}`),supervisor:s}}function Xv({sessionId:e,workspaceId:t,defaultDetailsOpen:n=!1}){let r=X(),[i,a]=(0,V.useState)(n),{actionError:o,executionPolicyItems:s,handlePause:c,handleResume:l,handleTrigger:u,isBusy:d,latestCycle:f,latestCycleText:p,openDialog:m,planGeneratedLabel:h,recentTargetCycles:g,stopReasonLabel:_,stateClass:v,stateLabel:y,supervisor:b,targetCycleResultLabel:x,targetMemory:S,targetProgressLabel:C,targetPlanItems:w}=Yv({sessionId:e});if(!b)return(0,Y.jsx)(`div`,{className:`supervisor-card supervisor-card-inactive`,children:(0,Y.jsx)($,{content:r(`supervisor.action.enable`),children:(0,Y.jsxs)(`button`,{className:`supervisor-enable-btn`,onClick:()=>m(`enable`),"aria-label":r(`supervisor.action.enable`),children:[(0,Y.jsx)(Q,{semantic:`supervisor.entry`,size:13}),(0,Y.jsx)(`span`,{children:r(`supervisor.title`)})]})})});let T=g[0]??null,E=r(S?`supervisor.target_memory.title`:`supervisor.meta.title`),D=[S?`${r(`supervisor.target_memory.target`)}: ${b.targetId}`:null,S&&h?`${r(`supervisor.target_memory.plan`)}: ${h}`:null,S?`${r(`supervisor.target_memory.stalled`)}: ${String(S.stalledCount)}`:null,S?.progressSummary?`${C}: ${S.progressSummary}`:null].filter(e=>e!==null);return(0,Y.jsxs)(`div`,{className:`supervisor-card ${v}`,"data-workspace-id":t,children:[(0,Y.jsxs)(`div`,{className:`supervisor-strip-row`,children:[(0,Y.jsxs)(`span`,{className:`supervisor-strip-eyebrow`,children:[(0,Y.jsx)(`span`,{className:`supervisor-pulse ${v}`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`supervisor-label`,children:r(`supervisor.title`)})]}),(0,Y.jsx)(`span`,{className:`supervisor-state-tag ${v}`,children:y}),(0,Y.jsxs)(`div`,{className:`supervisor-actions`,children:[(0,Y.jsx)($,{content:r(`supervisor.action.edit_objective`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.edit_objective`),className:`supervisor-icon-btn`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.mode.edit`,size:12}),onClick:()=>m(`edit`),size:`sm`})}),b.state===`paused`?(0,Y.jsx)($,{content:r(`supervisor.action.resume`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.resume`),className:`supervisor-icon-btn`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.action.resume`,size:12}),onClick:()=>{l()},size:`sm`})}):(0,Y.jsx)($,{content:r(`supervisor.action.pause`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.pause`),className:`supervisor-icon-btn`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.action.pause`,size:12}),onClick:()=>{c()},size:`sm`})}),(0,Y.jsx)($,{content:r(`supervisor.action.trigger`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.trigger`),className:`supervisor-icon-btn`,disabled:d,icon:(0,Y.jsx)(Q,{semantic:`supervisor.action.trigger`,size:12}),onClick:()=>{u()},size:`sm`})}),(0,Y.jsx)($,{content:r(`supervisor.action.disable`),children:(0,Y.jsx)(Z,{"aria-label":r(`supervisor.action.disable`),className:`supervisor-icon-btn supervisor-icon-btn-danger`,icon:(0,Y.jsx)(Q,{semantic:`supervisor.mode.disable`,size:12}),onClick:()=>m(`disable`),size:`sm`})})]})]}),(0,Y.jsxs)(`div`,{className:`supervisor-objective-row`,onDoubleClick:()=>m(`edit`),children:[(0,Y.jsx)($,{content:b.objective,children:(0,Y.jsx)(`span`,{className:`supervisor-objective-text`,children:b.objective})}),(0,Y.jsx)(`span`,{className:`supervisor-provider-pill`,children:b.evaluatorProviderId})]}),f?(0,Y.jsx)(`ol`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.latest_evaluation`),children:(0,Y.jsxs)(`li`,{className:`supervisor-history-item`,"data-trigger":f.trigger,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:f.trigger===`manual`?r(`supervisor.trigger.manual`):f.trigger===`scheduled`?r(`supervisor.trigger.scheduled`):r(`supervisor.trigger.auto`)}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:p})]})}):null,S||s.length>0||T?.reason?(0,Y.jsxs)(`div`,{className:`supervisor-details`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`supervisor-details-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,Y.jsxs)(`span`,{className:`supervisor-details-copy`,children:[(0,Y.jsx)(`span`,{className:`supervisor-details-label`,children:E}),(0,Y.jsx)(`span`,{className:`supervisor-details-summary`,children:D.length>0?D.join(` · `):r(`supervisor.meta.title`)})]}),(0,Y.jsx)(`span`,{className:`supervisor-details-chevron${i?` expanded`:``}`,"aria-hidden":`true`,children:(0,Y.jsx)(si,{size:14})}),(0,Y.jsx)(`span`,{className:`supervisor-details-toggle-text`,children:r(i?`action.collapse`:`action.expand`)})]}),i?(0,Y.jsxs)(`div`,{className:`supervisor-details-panel`,children:[S?(0,Y.jsxs)(`dl`,{className:`supervisor-meta-grid`,"aria-label":r(`supervisor.target_memory.title`),children:[(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.target`)}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:b.targetId})]}),(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.plan`)}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:h})]}),(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:r(`supervisor.target_memory.stalled`)}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:String(S.stalledCount)})]})]}):null,s.length>0?(0,Y.jsx)(`dl`,{className:`supervisor-meta-grid`,"aria-label":r(`supervisor.meta.title`),children:s.map(e=>(0,Y.jsxs)(`div`,{className:`supervisor-meta-item`,children:[(0,Y.jsx)(`dt`,{className:`supervisor-meta-label`,children:e.label}),(0,Y.jsx)(`dd`,{className:`supervisor-meta-value`,children:e.value})]},e.key))}):null,S?.progressSummary?(0,Y.jsx)(`div`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.target_memory.progress_title`),children:(0,Y.jsxs)(`div`,{className:`supervisor-history-item`,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:C}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:S.progressSummary})]})}):null,w.length>0?(0,Y.jsx)(`ol`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.target_memory.plan_title`),children:w.slice(0,3).map(e=>(0,Y.jsxs)(`li`,{className:`supervisor-history-item`,"data-trigger":e.status,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:r(`supervisor.target_memory.step_status.${e.status}`)}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:e.title})]},e.id))}):null,T?.reason?(0,Y.jsx)(`ol`,{className:`supervisor-history-list`,"aria-label":r(`supervisor.target_memory.reasoning_title`),children:(0,Y.jsxs)(`li`,{className:`supervisor-history-item`,"data-trigger":T.result,children:[(0,Y.jsx)(`span`,{className:`supervisor-history-trigger`,children:x}),(0,Y.jsx)(`span`,{className:`supervisor-history-result`,children:T.reason})]})}):null]}):null]}):null,b.state===`stopped`&&_?(0,Y.jsx)(`div`,{className:`supervisor-error`,role:`status`,children:_}):null,o?(0,Y.jsx)(`div`,{className:`supervisor-error`,role:`alert`,children:o}):b.errorReason?(0,Y.jsx)(`div`,{className:`supervisor-error`,role:`alert`,children:b.errorReason}):null]})}var Zv=Kf(e=>B({chunks:[],lastSeq:0})),Qv=Kf(e=>B(null));Kf(e=>B(e=>[]));var $v=2,ey={focused:0,"visible-active":1,"visible-other":2,background:3};function ty(e,t){return ey[e]-ey[t]}function ny(e){let t=Math.max(1,e?.concurrency??$v),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=>ty(t,e.tier)<0);i<0&&(i=r.length),r.splice(i,0,e),o()},u=e=>{let t=r.findIndex(t=>ty(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 ty(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 ry=ny();function iy(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 ay(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 oy(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=ay(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=iy(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 sy(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 cy(e){let t=oy(e.rowsElement,e.screenElement,e.terminal,e.clientX,e.clientY);return t===null?null:sy(e.terminal,t)}var ly=400,uy=[{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 dy(e){(e.pointerType===`touch`||e.pointerType===`pen`)&&e.preventDefault()}function fy(e){return e.pointerType===`touch`||e.pointerType===`pen`}function py(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 my({ctrlMode:e,shiftArmed:t,disabled:n=!1,labels:r,onKeyPress:i,onCtrlTap:a,onCtrlLongPress:o,onShiftTap:s,onPaste:c,onUpload:l}){let u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(!1),p=(0,V.useRef)(null),m=(0,V.useRef)(!1),h=(0,V.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)=>{fy(e)&&(h.current={pointerId:e.pointerId,target:t})},C=(e,t)=>{if(!fy(e))return`none`;let n=h.current;return!n||n.pointerId!==e.pointerId?`none`:(h.current=null,n.target===t?`matched`:`mismatched`)};(0,V.useEffect)(()=>{g&&(_(),v(),x(),f.current=!1,p.current=null,m.current=!1)},[g]),(0,V.useEffect)(()=>()=>{_(),v(),x()},[]);let w=()=>{g||(_(),f.current=!1,p.current=null,u.current=setTimeout(()=>{f.current=!0,p.current=`pointer`,o()},ly))},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||!fy(e)||t===`none`)&&(y(),t===`matched`)){if(f.current){f.current=!1,p.current=null;return}a()}},k=(e,t,n)=>{if(g||!fy(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,Y.jsxs)(`div`,{className:`mobile-terminal-input-bar`,"data-expanded":`true`,"data-disabled":n?`true`:`false`,children:[(0,Y.jsxs)(`div`,{className:`mobile-terminal-input-bar__actions`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.paste,disabled:g,onClick:()=>{g||c()},children:r.paste}),(0,Y.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__action`,"aria-label":r.upload,disabled:g,onClick:()=>{g||l()},children:r.upload})]}),(0,Y.jsxs)(`div`,{className:`mobile-terminal-input-bar__keys`,role:`group`,"aria-label":r.shortcuts,children:[(0,Y.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=>{dy(e),S(e,`ctrl`),w()},onPointerUp:O,onPointerCancel:()=>{x(),T()},onPointerLeave:()=>{x(),T()},onClick:D,onKeyDown:M,children:`Ctrl`}),(0,Y.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=>{dy(e),S(e,`shift`)},onPointerUp:e=>{k(e,`shift`,s)},onPointerCancel:x,onClick:A,children:`Shift`}),uy.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`mobile-terminal-input-bar__key`,"aria-label":py(e.id,r),disabled:g,onPointerDown:t=>{dy(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 hy={escape:`\x1B`,tab:` `,enter:`\r`,arrow_up:`\x1B[A`,arrow_down:`\x1B[B`,arrow_left:`\x1B[D`,arrow_right:`\x1B[C`},gy={tab:`\x1B[Z`,arrow_up:`\x1B[1;2A`,arrow_down:`\x1B[1;2B`,arrow_left:`\x1B[1;2D`,arrow_right:`\x1B[1;2C`},_y=`control`;function vy(e,t){return t?.shift?gy[e]??hy[e]:hy[e]}function yy(e){return e===`off`?`armed`:`off`}function by(){return`locked`}function xy(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:_y}}var Sy=12e4;function Cy(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 wy(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Ty=class extends Error{constructor(e,t,n){super(n??e),this.code=e,this.status=t,this.name=`UploadError`}};async function Ey(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 Ty(`network_error`,0,e.message)}let r;try{r=await n.json()}catch{r={}}if(!n.ok||!r.ok)throw new Ty(r.error??`http_${n.status}`,n.status);return r.files??[]}async function Dy(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 Oy(e){let{containerRef:t,workspaceId:n,sendTextToTerminal:r,enabled:i}=e,[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(0),c=(0,V.useRef)(0),l=(0,V.useRef)(0),u=(0,V.useRef)(new Map),d=(0,V.useRef)(Promise.resolve()),f=U(zg),p=(0,V.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,V.useCallback)(async e=>{let t=c.current;c.current+=1,s.current+=1,o(!0);try{await p(t,await e())}catch(e){await p(t,null),f({kind:`error`,title:`Upload failed`,body:`Could not upload file(s): ${e instanceof Ty?e.code:`unknown`}`,duration:5e3})}finally{s.current=Math.max(0,s.current-1),o(s.current>0)}},[f,p]),h=(0,V.useCallback)(async e=>{e.length!==0&&await m(async()=>{let t=await Ey({workspaceId:n,files:e});return t.length===0?null:`${t.map(e=>wy(e.path)).join(` `)} `})},[m,n]),g=(0,V.useCallback)(async e=>{e&&await m(async()=>e)},[m]),_=(0,V.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 Dy(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,V.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;!t||t.length===0||(e.preventDefault(),e.stopPropagation(),h(Array.from(t)))},a=e=>{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:_,handleFiles:h}}var ky=({state:e,queuePosition:t})=>{let n=X(),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,Y.jsx)(`div`,{className:`xterm-replay-overlay xterm-replay-overlay--placeholder`,role:`status`,"aria-live":`polite`,children:(0,Y.jsxs)(`div`,{className:`xterm-replay-overlay__card`,children:[e===`granting`?(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:r})]})})},Ay=16,jy=80,My=.12,Ny=.02,Py=.92,Fy=16,Iy=500,Ly=10,Ry=new Set([`\x1B[I`,`\x1B[O`]),zy=3e3;async function By(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()}}function Vy(e){return/^\x1b\[\d+;\d+R$/.test(e)||/^\x1b\[(?:\?|>)(?:\d+;)*\d*c$/.test(e)}function Hy(e){return Ry.has(e)?`system`:e.includes(`\r`)||e.includes(`
107
+ `)?`submit`:`typing`}function Uy(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 Wy(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=Uy(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 Gy(e,t){return e?`item`in e&&typeof e.item==`function`?e.item(t):e[t]??null:null}function Ky(e,t){if(t===null||!e)return null;for(let n=0;n<e.length;n+=1){let r=Gy(e,n);if(r?.identifier===t)return r}return null}function qy(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 Ay}function Jy(e){return e.type!==`keydown`||e.shiftKey||e.altKey?!1:(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`}var Yy=new TextEncoder,Xy=new TextDecoder(`utf-8`,{fatal:!1}),Zy=`coderStudio.terminalTrace`;function Qy(){try{return globalThis.localStorage?.getItem(Zy)===`1`}catch{return!1}}function $y(){if(typeof document>`u`)return Promise.resolve();let e=document.fonts;return e?.ready?e.ready.then(()=>void 0,()=>void 0):Promise.resolve()}function eb(e,t){return e.split(t).length-1}function tb(e){let t=typeof e==`string`?e:Xy.decode(e);return{length:typeof e==`string`?e.length:e.byteLength,syncStart:eb(t,`\x1B[?2026h`),syncEnd:eb(t,`\x1B[?2026l`),clearToEnd:eb(t,`\x1B[J`),clearScreen:eb(t,`\x1B[2J`),eraseLine:eb(t,`\x1B[K`),cursorHome:eb(t,`\x1B[1;1H`),dsr:eb(t,`\x1B[6n`),da:eb(t,`\x1B[c`),reverseIndex:eb(t,`\x1BM`),cursorMoves:t.match(/\x1b\[[0-9;]*[Hf]/g)?.length??0,scrollRegions:t.match(/\x1b\[[0-9;]*r/g)?.slice(0,6)??[]}}function nb(e,t,n={}){Qy()&&console.debug(`[terminal-trace]`,{at:Math.round(performance.now()*100)/100,terminalId:e,event:t,...n})}function rb(e,t){let n=Math.min(t,e.chunks.length);return n===0?e:{...e,chunks:e.chunks.slice(n)}}function ib({terminalId:e,workspaceId:t,readOnly:n=!1,isActiveSession:r=!1,terminalKind:i}){let a=X(),o=Pr(),s=H(ba),c=H(n_),l=H(If),u=H(Wf),p=U(zg),[m,h]=xe(Zv(e)),g=H(Qv(e)),_=i??g?.kind??`shell`,v=!n&&g?.alive!==!1,y=(0,V.useRef)(null),b=(0,V.useRef)(null),x=(0,V.useRef)(null),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(!1),T=(0,V.useRef)([]),E=(0,V.useRef)(null),D=(0,V.useRef)(!0),O=(0,V.useRef)(null),k=(0,V.useRef)([]),A=(0,V.useRef)(!1),j=(0,V.useRef)(0),M=(0,V.useRef)(`idle`),N=(0,V.useRef)(null),P=(0,V.useRef)(0),F=(0,V.useRef)(null),ee=(0,V.useRef)(0),I=(0,V.useRef)(0),te=(0,V.useRef)(s),L=(0,V.useRef)(``),R=(0,V.useRef)(0),z=(0,V.useRef)(null),ne=(0,V.useRef)(!1),re=(0,V.useRef)(null),ie=(0,V.useRef)(``),B=(0,V.useRef)(0),ae=(0,V.useRef)(null),oe=(0,V.useRef)(()=>{}),se=(0,V.useRef)(()=>{}),ce=(0,V.useRef)({activeTouchId:null,lastClientY:0,carryPx:0,pxPerLine:null,velocityPxPerMs:0,lastMomentumFrameAt:0,momentumFrameId:null,gestureDidScroll:!1,samples:[]}),[le,ue]=(0,V.useState)({kind:`loading`}),[de,fe]=(0,V.useState)(o===`mobile`?{kind:`granted`}:{kind:`idle`}),[pe,me]=(0,V.useState)(`off`),[he,ge]=(0,V.useState)(!1),_e=(0,V.useRef)(`off`),ve=(0,V.useRef)(!1),[ye,be]=(0,V.useState)(()=>!l||typeof l.getStatus!=`function`?`disconnected`:l.getStatus()),Se=(0,V.useRef)(()=>{}),Ce=(0,V.useRef)(()=>{});(0,V.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,V.useEffect)(()=>{te.current=s},[s]),(0,V.useLayoutEffect)(()=>{if(o===`mobile`){fe({kind:`granted`}),ne.current=!0,z.current=null;return}ne.current=!1;let t=g?.alive===!1?`background`:r?`visible-active`:`visible-other`,n=ry.request({terminalId:e,tier:t});z.current=n,fe(n.isGranted?{kind:`granted`}:{kind:`idle`});let i=!1,a=n.subscribePosition(e=>{i||fe({kind:`queued`,queuePosition:e})});return n.isGranted||n.granted.then(()=>{i||fe({kind:`granted`})}),()=>{i=!0,a(),ne.current||=(n.release(),!0),z.current=null}},[e,o]),(0,V.useEffect)(()=>{if(o===`mobile`)return;let e=g?.alive===!1?`background`:r?`visible-active`:`visible-other`;z.current?.promote(e)},[r,g?.alive,o]),(0,V.useEffect)(()=>{b.current&&(b.current.options.theme=ma(s).terminalTheme)},[s]),(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof window>`u`||typeof window.matchMedia!=`function`||!window.matchMedia(`(pointer: coarse)`).matches)return;let t=ce.current,n=null,r=null,i=0,a=0,s=null,l=!1,u=()=>{n!==null&&(clearTimeout(n),n=null),r=null,i=0,a=0,s=null,l=!1},d=()=>{t.momentumFrameId!==null&&(cancelAnimationFrame(t.momentumFrameId),t.momentumFrameId=null),t.velocityPxPerMs=0,t.lastMomentumFrameAt=0},f=(e,n)=>{t.samples.push({clientY:e,at:n});let r=n-jy;for(;t.samples.length>0&&t.samples[0].at<r;)t.samples.shift()},p=()=>{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??=qy(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=b.current;if(!n){d();return}let r=t.lastMomentumFrameAt>0?t.lastMomentumFrameAt:e-Fy,i=Math.max(1,Math.min(64,e-r));t.lastMomentumFrameAt=e;let a=m(n,t.velocityPxPerMs*i),o=Py**+(i/Fy);if(t.velocityPxPerMs*=o,a===`blocked`||Math.abs(t.velocityPxPerMs)<=Ny){t.carryPx=0,d(),t.pxPerLine=null;return}t.momentumFrameId=requestAnimationFrame(h)},g=()=>{u(),d(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.gestureDidScroll=!1,t.samples=[]};se.current=g;let _=u=>{if(u.touches.length!==1){g();return}let p=Gy(u.touches,0);if(!p){g();return}if(d(),t.activeTouchId=p.identifier,t.lastClientY=p.clientY,t.carryPx=0,t.pxPerLine=b.current?qy(b.current,e):Ay,t.gestureDidScroll=!1,t.samples=[],f(p.clientY,performance.now()),o===`mobile`&&c.copyOnSelect){r=p.identifier,i=p.clientX,a=p.clientY;let t=b.current,o=e.querySelector(`.xterm-rows`),c=e.querySelector(`.xterm-screen`);l=!1,s=t&&o instanceof HTMLElement?cy({clientX:p.clientX,clientY:p.clientY,rowsElement:o,screenElement:c instanceof HTMLElement?c:void 0,terminal:t}):null,n=setTimeout(()=>{n=null,l=!0},Iy)}},v=e=>{let n=Ky(e.changedTouches,t.activeTouchId),o=b.current;if(!n||!o)return;if(r===n.identifier)if(Math.abs(n.clientX-i)>Ly||Math.abs(n.clientY-a)>Ly)u();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,f(n.clientY,performance.now()),p();let c=m(o,s);(c===`buffered`||c===`scrolled`)&&e.cancelable&&e.preventDefault()},x=e=>{if(Ky(e.changedTouches,r)){if(l){let e=s;u(),t.activeTouchId=null,t.lastClientY=0,t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0,t.gestureDidScroll=!1,t.samples=[],oe.current(e);return}u()}if(Ky(e.changedTouches,t.activeTouchId)){let n=t.gestureDidScroll,r=Ky(e.changedTouches,t.activeTouchId);if(r&&n&&(f(r.clientY,performance.now()),p()),t.activeTouchId=null,t.lastClientY=0,t.gestureDidScroll=!1,t.samples=[],n&&Math.abs(t.velocityPxPerMs)>=My){t.lastMomentumFrameAt=0,t.momentumFrameId=requestAnimationFrame(h);return}t.carryPx=0,t.pxPerLine=null,t.velocityPxPerMs=0}},S=()=>{g()};return e.addEventListener(`touchstart`,_,{passive:!0}),e.addEventListener(`touchmove`,v,{passive:!1}),e.addEventListener(`touchend`,x,{passive:!0}),e.addEventListener(`touchcancel`,S,{passive:!0}),()=>{e.removeEventListener(`touchstart`,_),e.removeEventListener(`touchmove`,v),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S),se.current=()=>{},g()}},[c.copyOnSelect,o]);let we=(0,V.useCallback)(()=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null;try{let t=b.current?{cols:b.current.cols,rows:b.current.rows}:null;x.current?.fit(),nb(e,`fit`,{before:t,after:b.current?{cols:b.current.cols,rows:b.current.rows}:null})}catch(e){console.error(`Failed to fit xterm instance:`,e)}finally{let e=T.current;T.current=[];for(let t of e)t()}})},[e]),Te=(0,V.useCallback)(()=>new Promise(e=>{T.current.push(e)}),[]),Ee=(0,V.useCallback)(e=>{_e.current=e,me(e)},[]),De=(0,V.useCallback)(e=>{ve.current=e,ge(e)},[]),Oe=(0,V.useCallback)(()=>{let e=Date.now();e-B.current<zy||(B.current=e,p({kind:`error`,title:a(o===`mobile`?`terminal.mobile_copy_current_line_failed_title`:`settings.copy_on_select_failed_title`),body:a(o===`mobile`?`terminal.mobile_copy_current_line_failed_body`:`settings.copy_on_select_failed_body`)}))},[p,a,o]),ke=(0,V.useCallback)(async e=>{if(!(o!==`mobile`||!c.copyOnSelect)&&(se.current(),e!==null))try{await By(e),p({kind:`success`,title:a(`terminal.copied_current_line`)}),typeof navigator<`u`&&typeof navigator.vibrate==`function`&&navigator.vibrate(10)}catch{Oe()}},[Oe,p,a,c.copyOnSelect,o]);(0,V.useEffect)(()=>{oe.current=e=>{ke(e)}},[ke]),(0,V.useLayoutEffect)(()=>{se.current()},[e,t]);let Ae=(0,V.useCallback)(async()=>{if(o===`mobile`||!c.copyOnSelect)return;let e=b.current;if(!e?.hasSelection())return;let t=ie.current||e.getSelection();if(t)try{await By(t)}catch{Oe()}},[Oe,c.copyOnSelect,o]),je=(0,V.useCallback)(async(t,n)=>{if(ee.current>0&&Vy(t)){nb(e,`input.suppressed-replay-response`,{summary:tb(t)});return}if(!D.current)return;if(!l){console.error(`Cannot send terminal input: WebSocket not connected`);return}let r=R.current+1;R.current=r;let i=_e.current,a=L.current,o=xy(t,i),s=o.activity??n??Hy(o.data),{nextDraft:c,submittedText:u}=Wy(a,o.data,s);try{o.nextCtrlMode!==i&&Ee(o.nextCtrlMode),nb(e,`input`,{activity:s,summary:tb(o.data)}),L.current=c,await l.sendTerminalInput(e,Yy.encode(o.data),s,u)}catch(e){R.current===r&&(L.current=a,o.nextCtrlMode!==i&&_e.current===o.nextCtrlMode&&Ee(i)),console.error(`Failed to send terminal input:`,e)}},[e,Ee,l]),Me=(0,V.useCallback)(async({cols:t,rows:n})=>{if(!D.current)return;let r=O.current;if(r&&r.cols===t&&r.rows===n)return;O.current={cols:t,rows:n},nb(e,`resize.dispatch`,{previousSize:r,nextSize:{cols:t,rows:n}});let i=await u(`terminal.resize`,{terminalId:e,cols:t,rows:n});i.ok||console.error(`Failed to sync terminal size:`,i.error),nb(e,`resize.result`,{nextSize:{cols:t,rows:n},ok:i.ok,error:i.ok?void 0:i.error})},[e,u]),Ne=(0,V.useCallback)(async e=>{await je(e)},[je]),{busy:Pe,handleClipboardPaste:Fe,handleFiles:Ie}=Oy({containerRef:y,workspaceId:t,sendTextToTerminal:Ne,enabled:v});(0,V.useEffect)(()=>{D.current=v,b.current&&(b.current.options.disableStdin=!v||Pe,b.current.options.cursorBlink=v&&!Pe)},[v,Pe]),(0,V.useEffect)(()=>{if(!l){be(`disconnected`);return}if(typeof l.getStatus==`function`?be(l.getStatus()):be(`connected`),typeof l.onStatus==`function`)return l.onStatus(e=>{be(e)})},[l]),(0,V.useLayoutEffect)(()=>{Ee(`off`),De(!1),L.current=``,R.current+=1},[e,Ee,De]),(0,V.useEffect)(()=>{Se.current=je},[je]),(0,V.useEffect)(()=>{Ce.current=Me},[Me]),(0,V.useEffect)(()=>{if(o!==`mobile`&&de.kind!==`granted`||!y.current)return;let n=!1,r=null,i=I.current+1;I.current=i,ee.current=0,re.current=null,F.current=null,A.current=!1,j.current=0,M.current=`idle`,N.current=null,k.current=[],O.current=null,ue({kind:`loading`});let a=new f({theme:ma(te.current).terminalTheme,fontFamily:`JetBrains Mono, Fira Code, SF Mono, monospace`,fontSize:11,scrollback:5e3,cursorBlink:v&&!Pe,cursorStyle:`block`,disableStdin:!v||Pe,allowProposedApi:!0}),s=new d;a.loadAddon(s),a.onResize(e=>{Ce.current(e)}),a.onData(e=>{Se.current(e)});let c=typeof a.onSelectionChange==`function`?a.onSelectionChange(()=>{ie.current=a.hasSelection()?a.getSelection():``}):void 0;a.attachCustomKeyEventHandler(e=>!Jy(e)),a.open(y.current),nb(e,`mount.open`),b.current=a,x.current=s,we();let p=Te();o!==`mobile`&&p.then(async()=>{await $y(),!(n||!w.current)&&we()}).catch(()=>{});let m=async()=>{l&&(typeof l.getStatus!=`function`||typeof l.onStatus!=`function`||l.getStatus()!==`connected`&&await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,r?.(),r=null,e())};r=l.onStatus(e=>{e===`connected`&&n()}),l.getStatus()===`connected`&&n()}))},g=p.then(async()=>{if(!l||(await m(),n||!w.current))return;let{cols:e,rows:t}=a;await Ce.current({cols:e,rows:t})}),_=(e,t)=>{ee.current+=1;let n=!1,r=()=>{n||(n=!0,I.current===i&&(ee.current=Math.max(0,ee.current-1),t?.()))};try{a.write(e,r)}catch(e){throw r(),e}},T=Df.terminalOutput(t,e),E=Df.terminalExit(t,e),D=e=>{let t=k.current;k.current=[];let n=[],r=e;for(let e of t)e.seq<=r||(n.push(e),r=e.seq);return{entries:n,latestCoveredSeq:r}},L=e=>{M.current=`done`,N.current=null,e&&F.current===e&&(F.current=`reconnect`),re.current?.()},R=(t,n,r)=>{if(j.current=n,A.current=!0,r.length===0){P.current=Math.max(P.current,n),L(t);return}let o=r.length,s=e=>{!w.current||I.current!==i||(P.current=Math.max(P.current,e),o=Math.max(0,o-1),o===0&&L(t))};for(let t of r){if(t.resetTerminalBeforeWrite&&typeof b.current?.reset==`function`&&b.current.reset(),t.kind===`historical`?nb(e,`write.historical`,{seq:t.seq,size:t.bytes.byteLength,summary:tb(t.bytes)}):nb(e,`write.pending-replay-chunk`,{seq:t.seq,summary:tb(t.bytes)}),t.kind===`historical`){_(t.bytes,()=>{s(t.seq)});continue}a.write(t.bytes,()=>{s(t.seq)})}},B=(e,t)=>{if(!w.current||!b.current||!e)return;let n=N.current,r=j.current,i=[];e.ok&&e.data?.status===t.successStatus?(t.successBytes&&i.push({kind:`historical`,bytes:t.successBytes,seq:t.coveredSeq??r,resetTerminalBeforeWrite:t.resetTerminalBeforeWrite}),r=t.coveredSeq??r,ue({kind:`ready`}),o!==`mobile`&&(z.current?.release(),ne.current=!0)):e.data?.status===`too_old`?(b.current&&b.current.writeln(`\r
109
+ \x1B[33m[Session history truncated - output exceeds buffer size]\x1B[0m`),ue({kind:`degraded`,reason:`truncated`}),o!==`mobile`&&(z.current?.release(),ne.current=!0)):e.data?.status===`unknown`?(ue({kind:`degraded`,reason:`closed`}),o!==`mobile`&&(z.current?.release(),ne.current=!0)):e.ok||(console.error(`Failed to replay terminal output:`,e.error),ue({kind:`degraded`,reason:Cy(e.error)}),o!==`mobile`&&(z.current?.release(),ne.current=!0));let{entries:a,latestCoveredSeq:s}=D(r);r=s;for(let e of a)i.push({kind:`pending`,bytes:e.bytes,seq:e.seq});h(e=>({...e,chunks:[],lastSeq:Math.max(e.lastSeq,r)})),R(n,r,i)},ae=e=>{B(e,{successStatus:`ok`,successBytes:e?.data?.bytes,coveredSeq:e?.data?.seq})},oe=e=>{if(console.error(`Failed to recover terminal output:`,e),!w.current||!b.current)return;let t=N.current;ue({kind:`degraded`,reason:Cy(e)}),o!==`mobile`&&(z.current?.release(),ne.current=!0),h(e=>({...e,chunks:[],lastSeq:Math.max(e.lastSeq,j.current)}));let{entries:n,latestCoveredSeq:r}=D(j.current);R(t,r,n.map(e=>({kind:`pending`,bytes:e.bytes,seq:e.seq})))},se=t=>{l&&(M.current=`in-flight`,A.current=!1,ue({kind:`loading`}),l.sendCommand(`terminal.snapshot`,{terminalId:e},{timeoutMs:Sy}).then(e=>({ok:!0,data:e})).catch(e=>({ok:!1,error:e})).then(e=>{if(!(!w.current||!b.current)){if(e.ok&&e.data?.status===`ok`&&e.data.bytes&&typeof e.data.seq==`number`){B(e,{successStatus:`ok`,successBytes:e.data.bytes,coveredSeq:e.data.seq,resetTerminalBeforeWrite:t?.resetTerminalBeforeWrite});return}if(t?.onUnavailable){t.onUnavailable(e);return}oe(e.ok?Error(`terminal.snapshot returned status ${e.data?.status??`unknown`}`):e.error)}}))},ce=(t,n)=>{l&&(M.current=`in-flight`,A.current=!1,t===0&&ue({kind:`loading`}),nb(e,`replay.request`,{lastSeq:t}),(l?l.sendCommand(`terminal.replay`,{terminalId:e,lastSeq:t},{timeoutMs:Sy}).then(e=>({ok:!0,data:e})):u(`terminal.replay`,{terminalId:e,lastSeq:t})).then(e=>{if(e.ok&&e.data?.status===`too_old`&&n?.onTooOld){n.onTooOld();return}ae(e)}).catch(e=>{if(n?.onError){n.onError(e);return}oe(e)}))},le=()=>{F.current||=N.current??`reconnect`,M.current=`idle`,N.current=null,A.current=!1,re.current?.()},fe=()=>typeof l.getStatus==`function`?l.getStatus():`connected`,V=(t,n)=>{let r=fe();if(F.current===`reconnect`||r===`disconnected`||r===`reconnecting`){nb(e,`reconnect.snapshot-fallback.defer-until-reconnect`,{lastSeq:P.current,reason:t,error:n?String(n):void 0,connectionStatus:r}),le();return}nb(e,`reconnect.snapshot-fallback`,{lastSeq:P.current,reason:t,error:n?String(n):void 0}),se({resetTerminalBeforeWrite:!0,onUnavailable:t=>{let n=fe();if(F.current===`reconnect`||n===`disconnected`||n===`reconnecting`){nb(e,`reconnect.snapshot.defer-until-reconnect`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error),connectionStatus:n}),le();return}oe(t.ok?Error(`terminal.snapshot returned status ${t.data?.status??`unknown`}`):t.error)}})},pe=t=>{if(l){if(N.current=t,t===`reconnect`){ue({kind:`loading`}),ce(P.current,{onTooOld:()=>{V(`too_old`)},onError:e=>{V(`error`,e)}});return}se({onUnavailable:t=>{let n=fe();if(F.current===`initial`||n===`disconnected`||n===`reconnecting`){nb(e,`snapshot.defer-until-reconnect`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error),connectionStatus:n}),le();return}nb(e,`snapshot.fallback`,{reason:t.ok?t.data?.status??`unsupported`:String(t.error)}),ce(0)}})}};return re.current=()=>{if(!F.current||typeof l.getStatus==`function`&&l.getStatus()!==`connected`||M.current===`in-flight`)return;let e=F.current;F.current=null,pe(e)},l&&(S.current=l.subscribe([T,E],(t,n,r)=>{if(t===T){let t=n;if(nb(e,`live.output`,{seq:r,replayCompleted:A.current,replayedSeq:j.current,size:t.bytes.byteLength,summary:tb(t.bytes)}),!A.current){k.current.push({bytes:t.bytes,seq:r});return}if(r<=j.current){nb(e,`live.drop-covered`,{seq:r,replayedSeq:j.current});return}let i=r-t.bytes.byteLength;if(i>j.current){nb(e,`live.gap`,{seq:r,chunkStartSeq:i,replayedSeq:j.current}),k.current.push({bytes:t.bytes,seq:r}),h(e=>({chunks:[],lastSeq:j.current})),ce(j.current);return}h(e=>r<=e.lastSeq?e:{chunks:[...e.chunks,t.bytes],lastSeq:r}),j.current=r}else if(t===E){let e=n;b.current&&b.current.writeln(`\r\n[Process exited with code ${e.code}]`)}})),(async()=>{await g,w.current&&pe(`initial`)})().catch(e=>{oe(e)}),()=>{if(n=!0,re.current=null,F.current=null,I.current===i&&(I.current+=1,ee.current=0),r&&=(r(),null),S.current&&=(S.current(),null),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null),b.current){try{b.current.dispose()}catch(e){console.error(`Failed to dispose xterm instance:`,e)}b.current=null,x.current=null}typeof c==`function`?c():c?.dispose?.()}},[u,de.kind,we,h,e,_,o,t,l]),(0,V.useEffect)(()=>{let e=y.current;if(!e||typeof document>`u`||o===`mobile`||!c.copyOnSelect)return;let t=e=>{e.pointerType===`touch`||e.pointerType===`pen`||(ae.current=e.pointerId)},n=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target;n instanceof Node&&e.contains(n)||ae.current===t.pointerId&&(ae.current=null)},r=e=>{ae.current===e.pointerId&&(ae.current=null)},i=t=>{if(t.pointerType===`touch`||t.pointerType===`pen`)return;let n=t.target,r=n instanceof Node&&e.contains(n),i=ae.current!==null&&ae.current===t.pointerId;ae.current=null,!(!r&&!i)&&Ae()};return e.addEventListener(`pointerdown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,r),()=>{ae.current=null,e.removeEventListener(`pointerdown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,r)}},[Ae,c.copyOnSelect,o]),(0,V.useEffect)(()=>{if(!(!l||typeof l.onStatus!=`function`))return l.onStatus(e=>{if(e===`disconnected`||e===`reconnecting`){M.current!==`idle`&&(F.current=N.current??`reconnect`);return}e!==`connected`||!F.current||re.current?.()})},[l]),(0,V.useEffect)(()=>{if(!(!l||typeof l.onRecovery!=`function`))return l.onRecovery(e=>{e!==`reconnected`&&(F.current=`reconnect`,M.current!==`in-flight`&&re.current?.())})},[l]),(0,V.useEffect)(()=>{let t=b.current;if(!t)return;let{chunks:n}=m,r=n.length;if(r>0){let i=Array(n.length),a=m.lastSeq;for(let e=n.length-1;e>=0;--e)i[e]=a,a-=n[e]?.byteLength??0;for(let r=0;r<n.length;r++){let a=n[r];if(!a)continue;let o=i[r]??m.lastSeq;nb(e,`write.live-buffer`,{index:r,lastSeq:m.lastSeq,summary:tb(a)}),t.write(a,()=>{P.current=Math.max(P.current,o)})}h(e=>rb(e,r))}},[de.kind,m,h,e]),(0,V.useEffect)(()=>{let t=y.current,n=x.current;if(!t||!n)return;let r=new ResizeObserver(()=>{nb(e,`resize-observer`,{clientWidth:t.clientWidth,clientHeight:t.clientHeight}),E.current!==null&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,we()},150)});return r.observe(t),()=>{r.disconnect(),E.current!==null&&(clearTimeout(E.current),E.current=null)}},[de.kind,we,e]),(0,V.useEffect)(()=>{o!==`mobile`&&de.kind===`granted`&&g?.alive&&b.current&&b.current.focus()},[de.kind,g?.alive,o]);let Le=o===`mobile`&&v,Re=!v||Pe||ye!==`connected`,ze={paste:a(`terminal.mobile_input.paste`),upload:a(`terminal.mobile_input.upload`),shortcuts:a(`terminal.mobile_input.shortcuts`),ctrl:a(`terminal.mobile_input.ctrl`),ctrlArmed:a(`terminal.mobile_input.ctrl_armed`),ctrlLocked:a(`terminal.mobile_input.ctrl_locked`),shift:a(`terminal.mobile_input.shift`),shiftArmed:a(`terminal.mobile_input.shift_armed`),escape:a(`terminal.mobile_input.escape`),tab:a(`terminal.mobile_input.tab`),enter:a(`terminal.mobile_input.enter`),up:a(`terminal.mobile_input.up`),down:a(`terminal.mobile_input.down`),left:a(`terminal.mobile_input.left`),right:a(`terminal.mobile_input.right`)},Be=(0,V.useCallback)(async e=>{let t=ve.current;t&&De(!1),await je(vy(e,{shift:t}))},[je,De]),Ve=(0,V.useCallback)(()=>{Ee(yy(_e.current))},[Ee]),He=(0,V.useCallback)(()=>{Ee(by())},[Ee]),Ue=(0,V.useCallback)(()=>{De(!ve.current)},[De]),We=(0,V.useRef)(null),[Ge,Ke]=(0,V.useState)(!1),qe=(0,V.useRef)(null),Je=(0,V.useCallback)(async()=>{if(navigator.clipboard)try{await Fe();return}catch(e){console.debug(`Clipboard API failed, showing paste dialog:`,e)}Ke(!0)},[Fe]),Ye=(0,V.useCallback)(async()=>{let e=qe.current;if(!e)return;let t=e.value;t&&(await Ne(t),e.value=``),Ke(!1)},[Ne]),Xe=(0,V.useCallback)(()=>{let e=qe.current;e&&(e.value=``),Ke(!1)},[]),Ze=(0,V.useCallback)(()=>{We.current?.click()},[]),Qe=(0,V.useCallback)(async e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,t.length!==0&&await Ie(t)},[Ie]),$e=le.kind!==`ready`&&(o===`mobile`||de.kind===`granted`),et=``,tt=``,nt=`xterm-replay-overlay`;return le.kind===`loading`?(et=a(`terminal.replay.loading_title`),tt=a(`terminal.replay.loading_body`)):(nt+=` xterm-replay-overlay--degraded`,et=le.reason===`truncated`?a(`terminal.replay.truncated_title`):le.reason===`closed`?a(`terminal.replay.closed_title`):a(`terminal.replay.failed_title`),tt=le.reason===`truncated`?a(`terminal.replay.truncated_body`):le.reason===`closed`?a(`terminal.replay.closed_body`):a(`terminal.replay.failed_body`)),(0,Y.jsxs)(`div`,{className:`xterm-host-shell${Le?` xterm-host-shell--mobile-input`:``}`,children:[Le?(0,Y.jsx)(my,{ctrlMode:pe,shiftArmed:he,disabled:Re,labels:ze,onKeyPress:e=>{Be(e)},onCtrlTap:Ve,onCtrlLongPress:He,onShiftTap:Ue,onPaste:Je,onUpload:Ze}):null,(0,Y.jsx)(`input`,{ref:We,type:`file`,accept:`image/*,video/*,audio/*,text/plain,.txt,.md,.json,.csv`,multiple:!0,hidden:!0,onChange:e=>{Qe(e)}}),(0,Y.jsx)(`div`,{ref:y,className:`xterm-host`,style:{width:`100%`,minHeight:0,overflow:`hidden`},onFocusCapture:()=>{v&&z.current?.promote(`focused`)},onMouseDown:()=>{v&&z.current?.promote(`focused`)}}),Pe?(0,Y.jsx)(`div`,{role:`status`,"aria-live":`polite`,style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0,0,0,0.35)`,pointerEvents:`none`,zIndex:5,fontSize:12,color:`var(--text-muted, #ddd)`},children:`Uploading…`}):null,Ge?(0,Y.jsx)(`div`,{className:`paste-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`paste-dialog-title`,children:(0,Y.jsxs)(`div`,{className:`paste-dialog`,children:[(0,Y.jsx)(`h3`,{id:`paste-dialog-title`,className:`paste-dialog__title`,children:a(`terminal.paste_dialog_title`)}),(0,Y.jsx)(`textarea`,{ref:qe,className:`paste-dialog__textarea`,placeholder:a(`terminal.paste_dialog_placeholder`),autoFocus:!0}),(0,Y.jsxs)(`div`,{className:`paste-dialog__actions`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--secondary`,onClick:Xe,children:a(`common.cancel`)}),(0,Y.jsx)(`button`,{type:`button`,className:`paste-dialog__button paste-dialog__button--primary`,onClick:()=>{Ye()},children:a(`terminal.paste_dialog_submit`)})]})]})}):null,o!==`mobile`&&de.kind===`queued`?(0,Y.jsx)(ky,{state:`queued`,queuePosition:de.queuePosition}):null,$e?(0,Y.jsx)(`div`,{className:nt,role:`status`,"aria-live":`polite`,children:(0,Y.jsxs)(`div`,{className:`xterm-replay-overlay__card`,children:[le.kind===`loading`?(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__spinner`,"aria-hidden":`true`}):null,(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__title`,children:et}),tt?(0,Y.jsx)(`div`,{className:`xterm-replay-overlay__body`,children:tt}):null]})}):null]})}var ab=({sessionId:e,showHeaderActions:t=!0,showSupervisorInline:n=!0,terminalReadOnlyOverride:r,headerAccessory:i,onClose:a,onSplitHorizontal:o,onSplitVertical:s,onStop:c})=>{let l=H(ap(e)),u=H(Qf(l?.workspaceId??`__workspace_empty__`)),d=H(wa),f=U(wa),p=(0,V.useRef)(null),[m,h]=(0,V.useState)(!1);Uv(l);let{persistUiState:g}=U_(l?.workspaceId??`__workspace_empty__`),_=rg();if((0,V.useEffect)(()=>{if(d!==e)return;let t=p.current;t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),h(!0),f(null);let n=setTimeout(()=>h(!1),1400);return()=>clearTimeout(n)},[d,e,f]),!l)return null;let v=ob(l.state),y=l.title?.trim()||pb(l.id),b=hb(l.providerId),x=mb(l.state),S=r??!gb(l.state),C=u?.uiState.activeSessionId===l.id;return(0,Y.jsxs)(`div`,{ref:p,className:`session-card agent-pane${m?` session-card--focus-pulse`:``}`,"data-session-id":e,onClick:e=>{let t=e.target;t instanceof HTMLElement&&(t.closest(`button, a, input, textarea, select, [role="button"]`)||u?.uiState.activeSessionId!==l.id&&(_({workspaceId:l.workspaceId,sessionId:l.id}),g({activeSessionId:l.id})))},children:[(0,Y.jsx)(qm,{"aria-hidden":`true`,className:`session-progress`,fillClassName:`session-progress-bar ${cb(l.state)}`,max:100,tone:sb(l.state),value:v}),(0,Y.jsxs)(`div`,{className:`session-header`,children:[(0,Y.jsxs)(`div`,{className:`session-header-left`,children:[(0,Y.jsx)(xh,{tone:ub(l.state),pulse:db(l.state),className:`session-dot ${lb(l.state)}`}),(0,Y.jsx)(`div`,{className:`session-header-copy`,children:(0,Y.jsxs)(`div`,{className:`session-title-row`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:y}),(0,Y.jsx)(kh,{color:`blue`,className:`session-provider-badge`,children:b}),(0,Y.jsx)(kh,{color:fb(l.state),className:`session-state-badge`,caps:!1,children:x})]})})]}),t||i?(0,Y.jsxs)(`div`,{className:`session-header-right`,children:[i?(0,Y.jsx)(`div`,{className:`session-header-accessory`,children:i}):null,t?(0,Y.jsxs)(`div`,{className:`session-header-actions`,children:[l.state===`running`?(0,Y.jsx)($,{content:`Stop`,children:(0,Y.jsx)(Z,{"aria-label":`Stop`,className:`session-action-btn`,icon:(0,Y.jsx)(Yi,{size:13}),onClick:()=>void c?.(),size:`sm`})}):null,(0,Y.jsx)($,{content:`Split horizontal`,children:(0,Y.jsx)(Z,{"aria-label":`Split horizontal`,className:`session-action-btn`,icon:(0,Y.jsx)(Ji,{size:13}),onClick:()=>o?.(),size:`sm`})}),(0,Y.jsx)($,{content:`Split vertical`,children:(0,Y.jsx)(Z,{"aria-label":`Split vertical`,className:`session-action-btn`,icon:(0,Y.jsx)(qi,{size:13}),onClick:()=>s?.(),size:`sm`})}),(0,Y.jsx)($,{content:`Close`,children:(0,Y.jsx)(Z,{"aria-label":`Close`,className:`session-action-btn session-action-btn-close`,icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>void a?.(),size:`sm`})})]}):null]}):null]}),n&&l.capability===`full`&&l.state!==`draft`&&l.state!==`ended`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Xv,{sessionId:l.id,workspaceId:l.workspaceId}),(0,Y.jsx)(qv,{workspaceId:l.workspaceId,sessionId:l.id})]}):null,(0,Y.jsx)(`div`,{className:`session-terminal`,children:(0,Y.jsx)(ib,{terminalId:l.terminalId,workspaceId:l.workspaceId,readOnly:S,isActiveSession:C,terminalKind:`agent`})})]})};function ob(e){switch(e){case`starting`:return 18;case`running`:return 42;case`ended`:return 100;default:return 8}}function sb(e){switch(e){case`starting`:return`warning`;case`running`:return`info`;case`idle`:return`neutral`;case`ended`:return`success`;default:return`neutral`}}function cb(e){switch(e){case`starting`:return`session-progress-starting`;case`running`:return`session-progress-running`;case`idle`:return`session-progress-idle`;case`ended`:return`session-progress-complete`;default:return`session-progress-idle`}}function lb(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 ub(e){switch(e){case`starting`:return`warning`;case`running`:return`info`;case`ended`:return`success`;default:return`neutral`}}function db(e){switch(e){case`starting`:return!0;default:return!1}}function fb(e){switch(e){case`starting`:return`amber`;case`running`:return`green`;case`ended`:return`blue`;default:return`neutral`}}function pb(e){let t=e.match(/(\d+)/)?.[1];return t?`SESSION-${t.slice(-2).padStart(2,`0`)}`:e.replace(/[_-]/g,` `).toUpperCase()}function mb(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function hb(e){return e.replace(/\b\w/g,e=>e.toUpperCase())}function gb(e){return e===`running`||e===`idle`||e===`starting`}var _b={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`},vb=({hydrateSessions:e=!0})=>{let t=X(),n=H(np),{workspaceId:r,sessions:i,paneLayout:a}=Cv(n,{disabled:!e}),o=_v(r),s=Sv(),c=uv(a).length>0,l=i.length===0&&(c||a.type===`leaf`&&!a.sessionId&&a.id===`root`);return n?l?(0,Y.jsx)(kv,{workspaceId:r,onReplaceWithSession:o.replaceWithSession}):(0,Y.jsx)(`div`,{className:`agent-panes`,children:(0,Y.jsx)(yb,{node:a,workspaceId:r,onCloseSession:o.closeSessionPane,onSplitDraftPane:o.splitDraftPane,onSplitSession:o.splitSessionPane,onCloseDraftPane:o.closeDraftPane,onAssignSession:o.assignSession,onReplaceWithSession:o.replaceWithSession,onCloseSessionCommand:s.closeSession,onStopSession:s.stopSession})}):(0,Y.jsx)(`div`,{className:`agent-panes-empty`,children:(0,Y.jsx)(Pm,{style:{padding:0},title:(0,Y.jsx)(`p`,{style:_b,children:t(`workspace.no_workspace`)})})})},yb=({node:e,workspaceId:t,onAssignSession:n,onCloseDraftPane:r,onCloseSession:i,onCloseSessionCommand:a,onReplaceWithSession:o,onSplitDraftPane:s,onSplitSession:c,onStopSession:l})=>{if(e.type===`leaf`)return e.sessionId?(0,Y.jsx)(ab,{sessionId:e.sessionId,onClose:async()=>{i(e.sessionId),await a(e.sessionId)},onSplitHorizontal:()=>c(e.sessionId,`horizontal`),onSplitVertical:()=>c(e.sessionId,`vertical`),onStop:()=>l(e.sessionId)}):(0,Y.jsx)(kv,{workspaceId:t,paneId:e.id,onAssignSession:n,onClosePane:r,onReplaceWithSession:o,onSplitPane:s});let u=Z_(t,e.id)??e.ratio??.5;return(0,Y.jsx)(Av,{splitId:e.id,direction:e.direction||`horizontal`,ratio:u,onRatioCommit:n=>Q_(t,e.id,n),children:e.children?.map(e=>(0,Y.jsx)(yb,{node:e,workspaceId:t,onAssignSession:n,onCloseDraftPane:r,onCloseSession:i,onCloseSessionCommand:a,onReplaceWithSession:o,onSplitDraftPane:s,onSplitSession:c,onStopSession:l},e.id))})};function bb(){let e=H(np),t=H(Wf),n=U(fg(e?.id??``)),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=e?.id,[f,p]=xe(lg(d??``)),[m,h]=xe(cg(d??``)),g=H(ug(d??``)),_=d?m[f??``]:void 0,v=(0,V.useCallback)(async(e,n)=>{if(!d)return;c(t=>t?.path===e?null:t);let r=await t(`file.read`,{workspaceId:d,path:e});if(!r.ok||!r.data){let t=r.error?.message??`Failed to open file`;console.error(`Failed to open file:`,t),c({path:e,message:t});return}let i=r.data;if(n?.forceText&&i.kind===`image`&&i.isTextBacked){try{let t=await fetch(i.url,{credentials:`include`});if(!t.ok){let n=`Failed to fetch text-backed image bytes: ${t.status}`;console.error(n),c({path:e,message:n});return}let n={kind:`text`,path:e,content:await t.text(),baseHash:``,isDirty:!1,viewingTextBackedImageAsText:!0};h(t=>({...t,[e]:n})),c(t=>t?.path===e?null:t)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch text-backed image bytes`;console.error(`Failed to fetch text-backed image bytes:`,t),c({path:e,message:n})}return}let a=i.kind===`text`?{kind:`text`,path:e,content:i.content,baseHash:i.baseHash,isDirty:!1,externalState:void 0}:{kind:`image`,path:e,mime:i.mime,url:i.url,size:i.size,isTextBacked:i.isTextBacked,externalState:void 0};h(t=>({...t,[e]:a})),u(t=>t?.path===e?null:t),c(t=>t?.path===e?null:t)},[t,h,d]),y=(0,V.useCallback)(async()=>{if(!d||!_||_.kind!==`text`||r)return;i(!0),o(null);let e=await t(`file.write`,{workspaceId:d,path:_.path,content:_.content,baseHash:_.baseHash||void 0});e.ok&&e.data?(h(t=>{let n=t[_.path];return!n||n.kind!==`text`?t:{...t,[_.path]:{...n,baseHash:e.data.newHash,isDirty:!1,externalState:void 0}}}),u(e=>e?.path===_.path?null:e)):o(e.error?.message??`Failed to save file`),i(!1)},[_,t,r,h,d]),b=(0,V.useCallback)(e=>{!d||!_||_.kind!==`text`||h(t=>{let n=t[_.path];return!n||n.kind!==`text`?t:{...t,[_.path]:{...n,content:e,isDirty:e!==n.content}}})},[_,h,d]);(0,V.useEffect)(()=>{!d||!f||m[f]||v(f)},[f,v,m,d]),(0,V.useEffect)(()=>{if(!d||g<=0)return;let e=Object.entries(m);if(e.length===0)return;let n=!1;return(async()=>{for(let[r,i]of e){let e=await t(`file.read`,{workspaceId:d,path:r});if(n)return;if(!e.ok||!e.data){let t=e.error?.code===`not_found`;h(e=>{let n=e[r];return n?{...e,[r]:{...n,externalState:t?`deleted`:n.externalState}}:e}),t&&f===r&&u({path:r,status:`deleted`});continue}let a=e.data;if(i.kind===`text`&&a.kind===`text`){if(a.baseHash===i.baseHash)continue;if(i.isDirty){h(e=>{let t=e[r];return!t||t.kind!==`text`?e:{...e,[r]:{...t,externalState:`modified`}}}),f===r&&u({path:r,status:`modified`});continue}h(e=>({...e,[r]:{kind:`text`,path:r,content:a.content,baseHash:a.baseHash,isDirty:!1,externalState:void 0,viewingTextBackedImageAsText:i.viewingTextBackedImageAsText}})),f===r&&u(e=>e?.path===r?null:e);continue}if(i.kind===`image`&&a.kind===`image`){if(i.url===a.url&&i.size===a.size)continue;h(e=>({...e,[r]:{kind:`image`,path:r,mime:a.mime,url:a.url,size:a.size,isTextBacked:a.isTextBacked,externalState:void 0}})),f===r&&u(e=>e?.path===r?null:e);continue}h(e=>{let t={...e};return delete t[r],t}),f===r&&u({path:r,status:`modified`})}})(),()=>{n=!0}},[f,t,g,m,h,d]);let x=(0,V.useCallback)(()=>{if(!d)return;let e=_?.path;p(null),e&&h(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n}),o(null)},[_,p,h,d]),S=(0,V.useCallback)(()=>{if(!d||!_)return;let e=_.path,t=_.kind===`image`;h(t=>{let n={...t};return delete n[e],n}),v(e,t?{forceText:!0}:void 0)},[_,v,h,d]),C=(0,V.useCallback)(async()=>{if(!d||!_)return!1;let e=await t(`git.diff`,{workspaceId:d,path:_.path,staged:!1});return!e.ok||!e.data?!1:(n({path:_.path,diff:e.data.diff,staged:!1}),!0)},[_,t,n,d]),w=_?.kind===`text`,T=_?.kind===`image`,E=T&&_.isTextBacked||w&&_.viewingTextBackedImageAsText===!0,D=!!(w&&_.isDirty&&!r),O=f&&s?.path===f?s.message:null;return{activeFilePath:f,activeExternalStatus:f&&l?.path===f?l.status:null,activeLoadError:O,canSave:D,currentFile:_,handleClose:x,handleContentChange:b,handleSave:y,isImageFile:T,isSaving:r,isSvgTextBacked:E,isTextFile:w,openInDiffMode:C,saveError:a,toggleSvgTextMode:S,workspace:e,workspaceId:d}}function xb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function Sb(e){return(e.split(`/`)[1]??e).split(`+`)[0].replace(/^x-/,``).toUpperCase()}var Cb=({url:e,mime:t,sizeBytes:n,alt:r})=>{let[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{a(null),s(!1)},[e]),(0,Y.jsxs)(`div`,{className:`image-preview`,children:[(0,Y.jsx)(`div`,{className:`image-preview-canvas`,children:o?(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.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,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:`Preview unavailable`})}):(0,Y.jsx)(`img`,{className:`image-preview-img`,src:e,alt:r,draggable:!1,onLoad:e=>{let t=e.currentTarget;a({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>s(!0)})}),(0,Y.jsxs)(`div`,{className:`image-preview-meta`,children:[(0,Y.jsx)(`span`,{className:`image-preview-type`,children:Sb(t)}),i&&(0,Y.jsxs)(`span`,{className:`image-preview-dim`,children:[i.w,` × `,i.h]}),(0,Y.jsx)(`span`,{className:`image-preview-size`,children:xb(n)})]})]})},wb=({state:e,variant:t=`full`})=>{let n=X(),{canSave:r,handleClose:i,handleSave:a,isImageFile:o,isSaving:s,isSvgTextBacked:c,toggleSvgTextMode:l}=e,u=n(s?`code_editor.saving`:`action.save_file`),d=n(o?`code_editor.edit_as_text`:`code_editor.preview_as_image`),f=n(o?`code_editor.mode_text`:`code_editor.mode_image`);return t===`mobile`?(0,Y.jsxs)(`div`,{className:`mobile-sheet__header-actions`,children:[c?(0,Y.jsx)($,{content:d,children:(0,Y.jsx)(Z,{"aria-label":d,className:`mobile-sheet__action mobile-sheet__action--icon`,icon:o?(0,Y.jsx)(vi,{size:16}):(0,Y.jsx)(Di,{size:16}),onClick:l})}):null,(0,Y.jsx)(`button`,{type:`button`,className:`mobile-sheet__action`,onClick:a,disabled:!r,"aria-label":u,children:u})]}):(0,Y.jsxs)(`div`,{className:`code-mode-toggle`,children:[c&&(0,Y.jsx)($,{content:d,children:(0,Y.jsxs)(`button`,{type:`button`,className:`code-mode-btn`,onClick:l,"aria-label":d,children:[o?(0,Y.jsx)(vi,{size:12}):(0,Y.jsx)(Di,{size:12}),(0,Y.jsx)(`span`,{children:f})]})}),(0,Y.jsx)($,{content:u,disabled:!r,children:(0,Y.jsxs)(`button`,{type:`button`,className:`code-mode-btn`,onClick:a,disabled:!r,"aria-label":u,children:[(0,Y.jsx)(Ui,{size:12}),(0,Y.jsx)(`span`,{children:u})]})}),(0,Y.jsx)($,{content:n(`action.close`),children:(0,Y.jsx)(Z,{"aria-label":n(`action.close`),className:`code-mode-btn`,icon:(0,Y.jsx)(ea,{size:12}),onClick:i,size:`sm`})})]})},Tb=({state:e,chrome:t=`full`})=>{let n=X(),{activeFilePath:r,activeExternalStatus:i,activeLoadError:a,currentFile:o,handleContentChange:s,handleSave:c,isImageFile:l,isTextFile:u,saveError:d,workspace:f}=e;if(!f)return(0,Y.jsx)(`div`,{className:`workspace-git-view`,children:(0,Y.jsx)(`div`,{className:`code-editor workspace-git-editor`,children:(0,Y.jsx)(`div`,{className:`code-editor-body`,children:(0,Y.jsx)(Pm,{className:`git-diff-empty`,title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`workspace.no_workspace`)})})})})});let p=u&&o.isDirty?(0,Y.jsx)(`span`,{className:`dirty-indicator`,children:`*`}):null;return(0,Y.jsx)(`div`,{className:`workspace-git-view`,children:(0,Y.jsxs)(`div`,{className:`code-editor workspace-git-editor`,children:[t===`full`?(0,Y.jsxs)(`div`,{className:`code-editor-header`,children:[(0,Y.jsx)(`span`,{className:`code-file-path`,children:o?(0,Y.jsxs)(Y.Fragment,{children:[o.path,p]}):r||n(`file.title`)}),(0,Y.jsx)(wb,{state:e})]}):null,d&&(0,Y.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,Y.jsx)(Q,{semantic:`state.error`,size:14}),(0,Y.jsx)(`span`,{children:d})]}),i&&(0,Y.jsxs)(`div`,{className:`code-editor-error`,role:`alert`,children:[(0,Y.jsx)(Q,{semantic:i===`deleted`?`state.fileDeleted`:`state.fileModified`,size:14}),(0,Y.jsx)(`span`,{children:n(i===`deleted`?`code_editor.deleted_on_disk`:`code_editor.modified_on_disk`)})]}),(0,Y.jsx)(`div`,{className:`code-editor-body`,children:u?(0,Y.jsx)(a_,{workspaceId:f.id,filePath:o.path,content:o.content,onContentChange:s,onSave:c}):l?(0,Y.jsx)(Cb,{url:o.url,mime:o.mime,sizeBytes:o.size,alt:o.path}):a?(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.jsx)(`p`,{className:`git-diff-empty-body`,children:a}),role:`alert`,title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`code_editor.open_failed_title`)})}):r?(0,Y.jsx)(Pm,{className:`git-diff-empty`,title:(0,Y.jsxs)(`p`,{className:`git-diff-empty-title`,children:[n(`status.connecting`),`…`]})}):(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.jsx)(`p`,{className:`git-diff-empty-body`,children:n(`code_editor.empty_hint`)}),title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:n(`file.title`)})})})]})})},Eb=({chrome:e=`full`,editorState:t})=>(0,Y.jsx)(Tb,{state:t??bb(),chrome:e}),Db=`__terminal_panel_empty__`;function Ob(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 kb(e){return{id:e.id,workspaceId:e.workspaceId,kind:e.kind,alive:e.alive,exitCode:e.exitCode,title:e.title}}function Ab(){let e=X(),t=H(tp),n=H(Wf),r=H(If),i=U(zg),a=me(),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(null),u=(0,V.useRef)(null),d=H(Qv(c??Db)),f=c?d:null;(0,V.useEffect)(()=>{if(!t){s([]),l(null);return}let r=!1;return s([]),l(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(Qv(e.id),kb(e));s(e=>Ob(e,o)),l(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,V.useEffect)(()=>{if(!r||!t)return;let e=Df.terminalsAll(t);return u.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;s(t=>t.includes(e.id)?t:[...t,e.id]),l(e.id);return}if(o!==`output`)return;let c=a.get(Qv(i));if(!c||c.kind!==`shell`)return;let u=t,d=Zv(i),f=a.get(d);n<=f.lastSeq||a.set(d,{chunks:[...f.chunks,u.bytes],lastSeq:n})}),()=>{u.current?.(),u.current=null}},[t,a,r]);let p=(0,V.useCallback)(async()=>{if(!t){i({kind:`warning`,title:e(`terminal.create_unavailable_title`),body:e(`terminal.create_unavailable_body`)});return}try{let r=await n(`terminal.create`,{workspaceId:t,kind:`shell`});if(!r.ok||!r.data){i({kind:`error`,title:e(`terminal.create_failed_title`),body:r.error?.message??e(`terminal.create_failed_body`)});return}let o=r.data;a.set(Qv(o.id),kb(o)),s(e=>e.includes(o.id)?e:[...e,o.id]),l(o.id)}catch(t){i({kind:`error`,title:e(`terminal.create_failed_title`),body:t instanceof Error?t.message:e(`terminal.create_failed_body`)})}},[t,n,i,a,e]);return{activeTerminalId:c,activeTerminalMeta:f,activeWorkspaceId:t,handleCloseTerminal:(0,V.useCallback)(async e=>{(await n(`terminal.close`,{terminalId:e})).ok&&s(t=>{let n=t.filter(t=>t!==e);return l(t=>t===e?n[0]??null:t),n})},[n]),handleCreateTerminal:p,handleSwitchTerminal:(0,V.useCallback)(e=>{l(e)},[]),hasTerminals:o.length>0,terminalIds:o}}function jb(e,t,n){let r=e?.title?.trim(),i=Mb(r);return!r||Nb(r,n)?`${i??n} — ${t+1}`:i?`${i} — ${t+1}`:r}function Mb(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 Nb(e,t){let n=e.toLowerCase();return n===t.trim().toLowerCase()||n===`shell terminal`||n===`shell 终端`}function Pb({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=X(),o=jb(H(Qv(e)),t,a(`terminal.shell`));return(0,Y.jsxs)(`div`,{className:`terminal-selector-item ${n?`terminal-selector-item-active`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`terminal-selector-item-trigger`,onClick:r,children:(0,Y.jsx)(`span`,{className:`terminal-selector-item-title`,children:o})}),(0,Y.jsx)(Z,{"aria-label":a(`action.close`),className:`terminal-selector-item-close`,icon:(0,Y.jsx)(ea,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function Fb({id:e,index:t,isActive:n,onSelect:r,onClose:i}){let a=X(),o=jb(H(Qv(e)),t,a(`terminal.shell`));return(0,Y.jsxs)(`div`,{className:`terminal-tab-shell ${n?`active`:``}`,role:`presentation`,children:[(0,Y.jsx)($m,{className:`terminal-tab ${n?`terminal-tab-active`:``}`,onClick:r,value:e,children:(0,Y.jsx)(`span`,{className:`terminal-tab-title`,children:o})}),(0,Y.jsx)(Z,{"aria-label":a(`action.close`),className:`terminal-tab-close`,icon:(0,Y.jsx)(ea,{size:12}),onClick:e=>{e.stopPropagation(),i()},size:`sm`})]})}function Ib({chrome:e=`default`,onMobileHeaderActionsChange:t}){let n=X(),r=me(),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),{activeTerminalId:c,activeTerminalMeta:l,activeWorkspaceId:u,handleCloseTerminal:d,handleCreateTerminal:f,handleSwitchTerminal:p,hasTerminals:m,terminalIds:h}=Ab(),g=c?h.indexOf(c):0,_=jb(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:jb(r.get(Qv(e)),t,n(`terminal.shell`))}));return(0,V.useEffect)(()=>{(!b||h.length<=1)&&(a(!1),s(!1))},[b,h.length]),(0,V.useEffect)(()=>{if(t)return()=>{t(null)}},[t]),(0,V.useEffect)(()=>{t&&t(null)},[t]),(0,Y.jsxs)(`div`,{className:`bottom-terminal${y?` bottom-terminal--mobile-fullscreen`:``}`,children:[(0,Y.jsx)(`div`,{className:`terminal-toolbar`,children:y?(0,Y.jsxs)(`div`,{className:`terminal-toolbar-mobile-row`,children:[m?(0,Y.jsxs)(`div`,{className:`terminal-selector`,children:[b?(0,Y.jsx)(mh,{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,Y.jsx)(`div`,{className:`terminal-selector-btn terminal-selector-btn--static`,"aria-label":_,children:(0,Y.jsx)(`span`,{children:_})}),b&&o?(0,Y.jsx)(sh,{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,Y.jsx)(`div`,{className:`terminal-toolbar-mobile-placeholder`,"aria-hidden":`true`}),m&&c?(0,Y.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,Y.jsx)($,{content:n(`action.close`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.close_terminal`),icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>{a(!1),s(!1),d(c)},size:`sm`})})}):null,y?(0,Y.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,Y.jsx)($,{content:n(`action.open`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.new_terminal`),icon:(0,Y.jsx)(Q,{semantic:`terminal.action.new`,size:14}),onClick:f,size:`sm`})})}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`terminal-toolbar-left`,children:(0,Y.jsxs)(`div`,{className:`terminal-title-stack`,children:[(0,Y.jsx)(`span`,{className:`terminal-kicker`,children:n(`terminal.kicker`)}),l?(0,Y.jsx)(`span`,{className:`terminal-title`,children:_}):null]})}),(0,Y.jsxs)(`div`,{className:`terminal-toolbar-right`,children:[m&&(0,Y.jsxs)(Y.Fragment,{children:[b?(0,Y.jsx)(`div`,{className:`terminal-selector`,children:h.length>1?(0,Y.jsx)(om,{content:(0,Y.jsx)(Y.Fragment,{children:h.map((e,t)=>(0,Y.jsx)(Pb,{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,Y.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":_,children:[(0,Y.jsx)(`span`,{children:_}),(0,Y.jsx)(si,{size:12})]})}):(0,Y.jsxs)(`button`,{type:`button`,className:`terminal-selector-btn`,"aria-label":_,children:[(0,Y.jsx)(`span`,{children:_}),(0,Y.jsx)(si,{size:12})]})}):null,(0,Y.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,Y.jsx)($,{content:n(`action.close`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.close_terminal`),icon:(0,Y.jsx)(ea,{size:14}),onClick:()=>{c&&(a(!1),s(!1),d(c))},size:`sm`})})})]}),(0,Y.jsx)(`div`,{className:`terminal-toolbar-actions`,children:(0,Y.jsx)($,{content:n(`action.open`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":n(`terminal.new_terminal`),icon:(0,Y.jsx)(Q,{semantic:`terminal.action.new`,size:14}),onClick:f,size:`sm`})})})]})]})}),(0,Y.jsx)(`div`,{className:`bottom-terminal-content`,children:m?(0,Y.jsxs)(Y.Fragment,{children:[x?(0,Y.jsx)(Zm,{"aria-label":n(`terminal.selector.title`),className:`bottom-terminal-tabs-nav`,onValueChange:p,value:v,children:(0,Y.jsx)(Qm,{className:`bottom-terminal-tabs`,children:h.map((e,t)=>(0,Y.jsx)(Fb,{id:e,index:t,isActive:e===v,onSelect:()=>p(e),onClose:()=>d(e)},e))})}):null,l&&u&&(0,Y.jsx)(`div`,{className:`bottom-terminal-xterm`,children:(0,Y.jsx)(ib,{terminalId:l.id,workspaceId:u,terminalKind:l.kind??`shell`})})]}):(0,Y.jsx)(Pm,{action:(0,Y.jsx)(Lp,{variant:`primary`,size:`sm`,onClick:f,leadingIcon:(0,Y.jsx)(Q,{semantic:`terminal.action.new`,size:14}),children:n(`terminal.new_terminal`)}),className:`bottom-terminal-empty`,description:(0,Y.jsx)(`p`,{className:`bottom-terminal-empty-hint`,children:n(`terminal.empty_hint`)}),icon:(0,Y.jsx)(Q,{className:`bottom-terminal-empty-icon`,semantic:`state.emptyTerminal`,size:32}),title:(0,Y.jsx)(`p`,{className:`bottom-terminal-empty-text`,children:n(`terminal.no_terminal`)})})})]})}function Lb({controller:e,className:t,iconSize:n,dataTestId:r}){let i=X();if(!e)return null;let a=e.isFullscreen?i(`tooltip.exit_fullscreen`):i(`tooltip.enter_fullscreen`);return(0,Y.jsx)($,{content:a,children:(0,Y.jsx)(Z,{"aria-label":a,className:t,"data-testid":r,icon:(0,Y.jsx)(e.isFullscreen?Mi:Ai,{size:n}),onClick:()=>{e.toggleFullscreen()}})})}var Rb=()=>{let e=X(),t=H(Lf);if(t===`connected`)return null;let n=`connection-status-${t}`,r=`connection-status-dot connection-status-dot-${t}`,i=e(`status.${t}`);return(0,Y.jsx)($,{content:i,children:(0,Y.jsxs)(`div`,{className:`connection-status ${n}`,"aria-label":i,children:[(0,Y.jsx)(xh,{tone:zb(t),size:`sm`,pulse:Bb(t),className:r}),(0,Y.jsx)(`span`,{className:`connection-status-text`,children:i})]})})};function zb(e){switch(e){case`connected`:return`success`;case`disconnected`:return`error`;default:return`warning`}}function Bb(e){switch(e){case`connecting`:case`reconnecting`:return!0;default:return!1}}function Vb(){let e=qt(),t=H(Wf),n=H(Yf),r=U(qf),i=U(Jf),a=U(Yf);return(0,V.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 Hb=({workspace:e,isActive:t})=>{let n=X(),r=Vb(),i=ig(),a=Xh(e)||e.id;return(0,Y.jsxs)(`div`,{className:`topbar-tab-shell ${t?`active`:``}`,role:`presentation`,children:[(0,Y.jsxs)($m,{className:`topbar-tab`,onClick:n=>{n.preventDefault(),!t&&i(e.id)},value:e.id,children:[(0,Y.jsx)(`span`,{className:`topbar-dot ${e.isActive?`active`:`idle`}`}),(0,Y.jsx)($,{content:e.path||e.id,children:(0,Y.jsx)(`span`,{className:`topbar-tab-name`,children:a})}),(0,Y.jsx)(Ap,{count:e.unreadCount??0,max:9})]}),(0,Y.jsx)(Z,{className:`topbar-close`,"aria-label":n(`action.close_workspace`),icon:(0,Y.jsx)(ea,{size:14}),onClick:async t=>{t.stopPropagation(),await r(e.id)},size:`sm`})]})},Ub={width:`auto`,minHeight:`auto`,padding:0,gap:0},Wb={color:`var(--text-tertiary)`,fontSize:`var(--text-sm)`,fontWeight:`var(--font-normal)`},Gb=({fullscreenController:e})=>{let t=X(),n=qt(),r=H(ep),i=H(tp)??r[0]?.id??``,a=ig(),[o,s]=xe(Ca),[c,l]=xe(Cg),[u,d]=xe(Sg),[f,p]=(0,V.useState)(!1);return(0,Y.jsxs)(`header`,{className:`app-topbar`,children:[(0,Y.jsxs)(`div`,{className:`topbar-tabs`,children:[r.length===0?(0,Y.jsx)(Pm,{className:`topbar-empty-state`,style:Ub,title:(0,Y.jsx)(`span`,{className:`topbar-hint`,style:Wb,children:t(`workspace.no_workspace`)})}):(0,Y.jsx)(Zm,{"aria-label":t(`workspace.tabs`),className:`topbar-tabs-nav`,onValueChange:e=>{a(e)},value:i,children:(0,Y.jsx)(Qm,{className:`topbar-tablist`,children:r.map(e=>(0,Y.jsx)(Hb,{workspace:e,isActive:e.id===i},e.id))})}),(0,Y.jsx)($,{content:t(`tooltip.new_workspace`),children:(0,Y.jsx)(Z,{"aria-label":t(`tooltip.new_workspace`),className:`topbar-add`,icon:(0,Y.jsx)(Q,{semantic:`nav.newWorkspace`,size:14}),onClick:()=>p(!0)})})]}),(0,Y.jsxs)(`div`,{className:`topbar-actions`,children:[(0,Y.jsx)(Rb,{}),(0,Y.jsx)($,{content:t(`tooltip.quick_actions`),children:(0,Y.jsxs)(`button`,{className:`topbar-btn topbar-quick-actions`,onClick:()=>s(!o),"aria-label":t(`tooltip.quick_actions`),children:[(0,Y.jsx)(Q,{semantic:`nav.search`,size:14}),(0,Y.jsx)(`span`,{className:`topbar-btn-label`,children:t(`tooltip.quick_actions`)})]})}),(0,Y.jsx)($,{content:t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),children:(0,Y.jsx)(Z,{"aria-label":t(c?`tooltip.hide_terminal`:`tooltip.show_terminal`),className:`topbar-btn ${c?`topbar-btn--active`:`topbar-btn--muted`}`,icon:(0,Y.jsx)(Q,{semantic:`nav.panelTerminal`,size:14}),onClick:()=>l(!c)})}),(0,Y.jsx)($,{content:t(u?`tooltip.show_files`:`tooltip.hide_files`),children:(0,Y.jsx)(Z,{"aria-label":t(u?`tooltip.show_files`:`tooltip.hide_files`),className:`topbar-btn ${u?`topbar-btn--muted`:`topbar-btn--active`}`,icon:(0,Y.jsx)(Q,{semantic:`nav.panelFiles`,size:14}),onClick:()=>d(!u)})}),(0,Y.jsx)($,{content:t(`settings.title`),children:(0,Y.jsx)(Z,{"aria-label":t(`settings.title`),className:`topbar-btn`,"data-testid":`settings-open`,icon:(0,Y.jsx)(Q,{semantic:`nav.settings`,size:14}),onClick:()=>n(`/settings`)})}),(0,Y.jsx)(Lb,{controller:e,className:`topbar-btn`,iconSize:14,dataTestId:`workspace-fullscreen-open`})]}),f?(0,Y.jsx)(Ag,{onClose:()=>p(!1)}):null]})};function Kb(e){return e?.source===`commit`}var qb=180*1e3,Jb={push:`git.operation_push`,pull:`git.operation_pull`,fetch:`git.operation_fetch`};function Yb(e,t){return e&&t?`${e}/${t}`:null}function Xb(e){let t=X(),n=H(Wf),r=U(zg),i=U(dg(e)),a=U(mg(e)),o=U(og(e)),s=U(vg(e)),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=(0,V.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(Jb[e.operation])}):t(`git.auth_required_message`,{remote:e.remoteLabel}):t(`git.auth_failed_unsupported`,{remote:e.remoteLabel}),[t]),p=(0,V.useCallback)((e,n,r)=>{if(e===`git.fetch`)return n.message||r;let i=Yb(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,V.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,V.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:qb});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,V.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,V.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,V.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 Zb(e){let t=[{title:`staged`,type:`staged`,changes:e.staged},{title:`modified`,type:`modified`,changes:e.modified},{title:`deleted`,type:`deleted`,changes:e.deleted},{title:`untracked`,type:`untracked`,changes:e.untracked}];for(let e of t)if(e.changes[0])return{change:e.changes[0],type:e.type};return null}function Qb(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 $b({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,initialHistoryLimit:r=5}){let i=X(),a=H(dg(e)),o=H(fg(e)),s=H(pg(e)),c=H(Wf),l=U(zg),u=U(dg(e)),d=U(mg(e)),f=U(fg(e)),p=U(pg(e)),[m,h]=xe(gg(e)),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)([]),[b,x]=(0,V.useState)(r),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),E=(0,V.useRef)(!1),D=(0,V.useRef)(!1),O=(0,V.useCallback)(e=>{d({current:e?.current??``,branches:e?.branches??[],loading:!1})},[d]),k=(0,V.useCallback)(e=>{f(e)},[f]),A=(0,V.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`};return p(!1),k(i),i},[c,p,k,e]),j=(0,V.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),k(i),n?.(i),i},[c,n,p,k,e]),M=(0,V.useCallback)(async(e,t)=>{let r=await A(e,t);r&&n?.(r)},[n,A]),N=(0,V.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}O(t.data)},[c,d,O,e]),P=(0,V.useCallback)(async(t=b)=>{if(e){C(!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),y([]);return}y(Array.isArray(n.data?.entries)?n.data.entries:[])}finally{C(!1)}}},[c,b,e]),F=(0,V.useCallback)(async()=>{if(e){if(E.current){D.current=!0;return}E.current=!0,_(!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){k(null);return}if(Kb(o))return;let n=(o?Qb(t.data,o.path):null)??Zb(t.data);if(!n){k(null);return}(!o||o.path!==n.change.path||!!o.staged!=(n.type===`staged`))&&await A(n.change,n.type)}finally{E.current=!1,_(!1),D.current&&(D.current=!1,queueMicrotask(()=>{F()}))}}},[o,s,c,A,u,k,e]);(0,V.useEffect)(()=>{!a&&!E.current&&F()},[a,F]),(0,V.useEffect)(()=>{N()},[N]),(0,V.useEffect)(()=>{P(b)},[a?.headSha,b,P]),(0,V.useEffect)(()=>{if(!a||s||Kb(o))return;if(o){let e=Qb(a,o.path);if(e&&!!o.staged==(e.type===`staged`))return}let e=Zb(a);if(!e){k(null);return}A(e.change,e.type)},[o,s,a,A,k]),(0,V.useEffect)(()=>{t>0&&!E.current&&F()},[t,F]);let ee=(0,V.useCallback)(async(e,t,n,r,i)=>{let a=await c(e,t);return a.ok?(i?.(),await F(),!0):(l({kind:`error`,title:r,body:a.error?.message??n}),console.error(n,a.error?.message),!1)},[c,F,l]),I=(0,V.useCallback)(async t=>{t.length!==0&&await ee(`git.stage`,{workspaceId:e,paths:t},`Failed to stage all:`,i(`git.stage_failed_title`))},[ee,i,e]),te=(0,V.useCallback)(async t=>{t.length!==0&&await ee(`git.unstage`,{workspaceId:e,paths:t},`Failed to unstage all:`,i(`git.unstage_failed_title`))},[ee,i,e]),L=(0,V.useCallback)(async()=>{await I([...a?.modified.map(e=>e.path)??[],...a?.deleted.map(e=>e.path)??[],...a?.untracked.map(e=>e.path)??[]])},[a,I]),R=(0,V.useCallback)(async()=>{await te(a?.staged.map(e=>e.path)??[])},[a,te]),z=(0,V.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&&T({scope:`all`,paths:e})},[a]),ne=(0,V.useCallback)(e=>{e.length&&T({scope:`all`,paths:e})},[]),re=(0,V.useCallback)(e=>{T({scope:`single`,paths:[e],filePath:e})},[]),ie=(0,V.useCallback)(()=>{T(null)},[]),B=(0,V.useCallback)(async()=>{if(!w)return;let t=w;T(null),await ee(`git.discard`,{workspaceId:e,paths:t.paths},t.scope===`all`?`Failed to discard all:`:`Failed to discard:`,i(`git.discard_failed_title`))},[w,ee,i,e]),ae=(0,V.useCallback)(async()=>{!m.trim()||!a?.staged.length||await ee(`git.commit`,{workspaceId:e,message:m.trim()},`Failed to commit:`,i(`git.commit_failed_title`),()=>h(``))},[m,a?.staged.length,ee,i,e]),oe=!!(a&&(a.staged.length>0||a.modified.length>0||a.untracked.length>0||a.deleted.length>0));return{commitMessage:m,diffPreview:o,gitState:a,groups:(0,V.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:oe,history:v,historyLimit:b,historyLoading:S,isLoading:g,pendingDiscard:w,canShowMoreHistory:b<10&&v.length>0,setCommitMessage:h,handleCancelDiscard:ie,handleCommit:ae,handleConfirmDiscard:B,handleDiscardAll:z,handleRequestDiscardPaths:ne,handleRequestDiscardSingle:re,handleStageAll:L,handleStagePaths:I,handleUnstageAll:R,handleUnstagePaths:te,loadGitStatus:F,loadGitHistory:P,openDiff:M,openHistoryDiff:j,requestDiff:A,runGitMutation:ee,showMoreHistory:()=>x(10),t:i}}function ex(e){let t=H(fg(e)),n=U(fg(e)),r=U(pg(e));return{closePreview:()=>{r(!0),n(null)},preview:t}}function tx(){let e=X(),t=H(hg),n=U(hg),r=H(Wf),i=U(zg),a=t.workspaceId,o=H(mg(a??``)),s=U(mg(a??``)),{refreshBranchState:c}=Xb(a??``),[l,u]=(0,V.useState)(t.inputValue),[d,f]=(0,V.useState)(0),[p,m]=(0,V.useState)(null);(0,V.useEffect)(()=>{u(t.inputValue)},[t.inputValue]),(0,V.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,V.useMemo)(()=>o.branches.filter(e=>(e.isCurrent||!e.linkedWorktreePath)&&e.name.toLowerCase().includes(l.toLowerCase())),[o.branches,l]),_=(0,V.useCallback)(e=>e.isCurrent||!e.linkedWorktreePath,[]),v=g.find(e=>e.name.toLowerCase()===l.toLowerCase()),y=(0,V.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,V.useMemo)(()=>y.findIndex(e=>e.type===`branch`&&e.branch&&(e.branch.isCurrent||e.branch.name===o.current)),[o.current,y]);(0,V.useEffect)(()=>{if(t.visible){if(m(null),h){f(0);return}f(b>=0?b:0)}},[b,t.visible,h]);let x=(0,V.useCallback)(()=>{m(null),n({visible:!1,inputValue:``})},[n]),S=(0,V.useCallback)(e=>{e&&m(e)},[]),C=(0,V.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,V.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 nx(e){let t=e;return e.fullscreenElement??t.webkitCurrentFullScreenElement??null}function rx(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 ix(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 ax(e){return!!(rx(e)&&ix(document))}function ox(e){return e instanceof Error&&e.message.trim().length>0?e.message:null}function sx(e){let t=X(),n=U(zg),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1),s=(0,V.useCallback)(()=>{n({kind:`info`,title:t(`workspace.fullscreen.unsupported_title`),body:t(`workspace.fullscreen.unsupported_body`)})},[n,t]);(0,V.useEffect)(()=>{let t=()=>{let t=e.current;i(ax(t)),o(!!(t&&nx(document)===t))};return t(),document.addEventListener(`fullscreenchange`,t),document.addEventListener(`webkitfullscreenchange`,t),()=>{document.removeEventListener(`fullscreenchange`,t),document.removeEventListener(`webkitfullscreenchange`,t)}},[e]);let c=(0,V.useCallback)(async()=>{let r=e.current,i=rx(r);if(!i||!ix(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:ox(e)??t(`workspace.fullscreen.enter_failed_body`)})}},[n,s,t,e]),l=(0,V.useCallback)(async()=>{let e=ix(document);if(nx(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:ox(e)??t(`workspace.fullscreen.exit_failed_body`)})}}},[n,s,t]);return{supported:r,isFullscreen:a,enterFullscreen:c,exitFullscreen:l,toggleFullscreen:(0,V.useCallback)(async()=>{if(e.current&&nx(document)===e.current){await l();return}await c()},[c,l,e])}}var cx=220,lx=120;function ux(e,t,n){if(e>0)return e;let r=Number.parseFloat(t);return Number.isFinite(r)&&r>0?r:n}function dx(){let[e,t]=xe(bg),[n,r]=xe(xg),i=(0,V.useRef)(!1),a=(0,V.useRef)(null),o=(0,V.useRef)(0),s=(0,V.useRef)(0),c=(0,V.useRef)(e),l=(0,V.useRef)(null),u=(0,V.useCallback)(n=>{n.preventDefault(),i.current=!0,o.current=n.clientX,s.current=ux(a.current?.offsetWidth??0,a.current?.style.width??``,e),c.current=s.current,document.body.classList.add(`is-resizing-panels`);let r=e=>{if(!i.current)return;let t=e.clientX-o.current,n=Math.max(cx,s.current+t);c.current=n,a.current&&(a.current.style.width=`${n}px`)},l=()=>{i.current=!1,document.body.classList.remove(`is-resizing-panels`),t(c.current),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,l)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,l)},[t,e]),d=(0,V.useRef)(!1),f=(0,V.useRef)(0),p=(0,V.useRef)(0),m=(0,V.useRef)(n);return{bottomPanelHeight:n,bottomPanelRef:l,handleBottomMouseDown:(0,V.useCallback)(e=>{e.preventDefault(),d.current=!0,f.current=e.clientY,p.current=ux(l.current?.offsetHeight??0,l.current?.style.height??``,n),m.current=p.current,document.body.classList.add(`is-resizing-panels`);let t=e=>{if(!d.current)return;let t=f.current-e.clientY,n=Math.max(lx,p.current+t);m.current=n,l.current&&(l.current.style.height=`${n}px`)},i=()=>{d.current=!1,document.body.classList.remove(`is-resizing-panels`),r(m.current),document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,i)},[r,n]),handleLeftMouseDown:u,leftPanelRef:a,leftPanelWidth:e}}function fx(){let e=H(np),t=e?.id??`__workspace_placeholder__`,n=H(tp),r=U(qf),i=H(ep),a=H(dg(t)),o=H(lg(t)),s=H(fg(t)),c=H(yg),l=H(Cg),u=H(Sg),{sessions:d,paneLayout:f}=Cv(e),p=H(Wf),m=U(hg),h=me(),g=dx(),_=_v(t),v=Sv(),[y,b]=(0,V.useState)(`files`),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(0),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)({kind:`root`}),[k,A]=(0,V.useState)(null),j=(0,V.useRef)(0);(0,V.useEffect)(()=>{if(!e){r(null);return}return r(e.id),()=>{r(t=>t===e.id?null:t)}},[r,e]),(0,V.useEffect)(()=>{if(!e||a)return;let t=!1;return p(`git.status`,{workspaceId:e.id}).then(n=>{t||!n.ok||!n.data||h.set(dg(e.id),n.data)}).catch(e=>{t||console.error(`Failed to load git status:`,e)}),()=>{t=!0}},[p,a,h,e]);let M=(0,V.useCallback)(()=>{e&&(b(`git`),m({visible:!0,workspaceId:e.id,inputValue:``}))},[m,e]),N=(0,V.useCallback)(()=>{S(e=>({id:(e?.id??0)+1,mode:`file`,baseDir:null}))},[]),P=(0,V.useCallback)(()=>{S(e=>({id:(e?.id??0)+1,mode:`folder`,baseDir:null}))},[]),F=(0,V.useCallback)(()=>{S(null)},[]),ee=(0,V.useCallback)(()=>{w(e=>e+1)},[]),I=(0,V.useMemo)(()=>{let e=new Map(d.map(e=>[e.id,e]));return Array.from(new Set(uv(f))).map(t=>e.get(t)).filter(e=>!!e)},[f,d]),te=(0,V.useMemo)(()=>{let e=new Set(I.map(e=>e.id));return[...I,...d.filter(t=>t.state!==`draft`&&!e.has(t.id))]},[I,d]),L=te.find(e=>e.id===k)??null,R=(0,V.useCallback)(e=>{e&&!I.some(t=>t.id===e)&&d.some(t=>t.id===e&&t.state!==`draft`)&&_.appendSession(e,k,`vertical`),j.current+=1,A(e)},[k,I,_,d]),z=(0,V.useCallback)(e=>{_.appendSession(e,k,`vertical`),j.current+=1,A(e)},[k,_]),ne=(0,V.useCallback)(async e=>{let t=k===e,n=j.current,r=te.filter(t=>t.id!==e)[0]?.id??null;if(t&&A(r),!await v.closeSession(e)){if(!t||j.current!==n)return;A(t=>t===r?e:t);return}_.removeSessionPane(e)},[k,te,_,v]),re=(0,V.useCallback)(e=>{e&&!I.some(t=>t.id===e)&&d.some(t=>t.id===e&&t.state!==`draft`)&&_.appendSession(e,k,`vertical`),j.current+=1,A(e)},[k,I,_,d]),ie=(0,V.useCallback)(e=>{E(e),e!==`files`&&O({kind:`root`})},[]),B=(0,V.useCallback)(()=>{E(null),O({kind:`root`})},[]),ae=(0,V.useCallback)(e=>{O(e)},[]);return{activeSession:L,activeFilePath:o,activeWorkspaceId:n,createRequest:x,diffPreview:s,focusMode:c,gitState:a,handleConsumeCreateRequest:F,handleOpenBranchSwitcher:M,handleOpenFileCreate:N,handleOpenFolderCreate:P,handleRefreshSidebarPanel:ee,handleMobileSessionCreated:z,mainAreaMode:y===`git`&&s?`diff`:o?`editor`:`agent`,mobileActiveSessionId:k,mobileAgentSessions:te,mobileFilesRoute:D,mobileSheet:T,openMobileSheet:ie,orderedSessions:I,paneLayout:f,panelRefreshToken:C,paneLayout:f,closeMobileSession:ne,restoreMobileSession:re,selectMobileSession:R,sessions:d,setSidebarTab:b,sidebarCollapsed:u,sidebarTab:y,closeMobileSheet:B,terminalPanelVisible:l,updateMobileFilesRoute:ae,workspace:e,workspaces:i,workspaceId:t,...g}}function px({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i}){let a=X(),o=H(ag(e)),s=H(og(e)),c=H(lg(e)),l=H(Wf),u=U(ag(e)),d=U(og(e)),f=U(lg(e)),p=U(cg(e)),m=H(sg(e)),h=U(sg(e)),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),w=(0,V.useRef)(t),T=(0,V.useRef)(0),E=(0,V.useCallback)(async()=>{if(!e||g)return!1;_(!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),h(new Set),_(!1),!0}return t.ok||console.error(`Failed to load file tree:`,t.error?.message),_(!1),!1},[e,g,l,u,h]),D=(0,V.useCallback)(async t=>{if(!e||v===t||m.has(t))return;y(t);let n=await l(`file.readTree`,{workspaceId:e,subPath:t});n.ok&&n.data&&(u(e=>{if(!e)return e;let r=new Map(e);return r.set(t,n.data.children),r}),h(e=>new Set(e).add(t))),y(null)},[e,v,m,l,u,h]),O=(0,V.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]),k=(0,V.useCallback)((e,t)=>{x({mode:e,draftPath:t?`${t.replace(/\/+$/,``)}/`:``,error:null})},[]),A=(0,V.useCallback)(()=>{x(null)},[]),j=(0,V.useCallback)(e=>{x(t=>t&&{...t,draftPath:e,error:null})},[]),M=(0,V.useCallback)(async()=>{if(!b)return;let t=b.draftPath.trim();if(!t){x(e=>e&&{...e,error:a(`file.path_required`)});return}if(b.mode===`file`&&t.endsWith(`/`)){x(e=>e&&{...e,error:a(`file.invalid_file_path`)});return}let n=await l(b.mode===`file`?`file.create`:`file.mkdir`,{workspaceId:e,path:t});if(!n.ok){x(e=>e&&{...e,error:n.error?.message??a(`file.create_failed`)});return}await E(),A(),b.mode===`file`&&f(t)},[b,l,e,E,A,f,a]),N=(0,V.useCallback)(()=>{C(null)},[]),P=(0,V.useCallback)(async()=>{if(!S)return;let t=await l(`file.delete`,{workspaceId:e,path:S.path});if(!t.ok){C(e=>e&&{...e,error:t.error?.message??a(`file.delete_failed`)});return}c===S.path&&f(null),p(e=>{if(!(S.path in e))return e;let t={...e};return delete t[S.path],t}),await E(),C(null)},[S,l,e,c,f,p,E,a]);return(0,V.useEffect)(()=>{!o&&!g&&E()},[o,g,E]),(0,V.useEffect)(()=>{s&&!g&&(d(!1),E())},[s,g,E,d]),(0,V.useEffect)(()=>{t<=w.current||g||(w.current=t,E())},[t,g,E]),(0,V.useEffect)(()=>{!n||n.id<=T.current||(T.current=n.id,k(n.mode,n.baseDir),r?.())},[n,k,r]),{activeFilePath:c,createDialog:b,fileTree:o,isLoading:g,isLoadingDir:v,pendingDelete:S,cancelDelete:N,confirmDelete:P,handleSelectFile:(0,V.useCallback)(e=>{f(e),i?.(e)},[i,f]),loadChildren:D,loadSearchResults:O,openCreateDialog:k,requestDelete:C,submitCreateDialog:M,updateDraftPath:j,closeCreateDialog:A}}function mx(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 hx={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},gx={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`},_x={display:`block`,width:`auto`,minHeight:`auto`,padding:0,gap:0,textAlign:`left`},vx={margin:0,color:`inherit`,fontSize:`inherit`,fontWeight:`inherit`};function yx({title:e}){return(0,Y.jsx)(Pm,{className:`file-tree-empty`,style:hx,title:(0,Y.jsx)(`p`,{style:gx,children:e})})}function bx({className:e,title:t}){return(0,Y.jsx)(Pm,{className:e,style:_x,title:(0,Y.jsx)(`p`,{style:vx,children:t})})}var xx=({workspaceId:e,refreshToken:t=0,createRequest:n=null,onCreateRequestConsumed:r,onSelectFile:i,onVisibleCountChange:a,collapseVersion:o=0,variant:s=`desktop`})=>{let c=X(),{activeFilePath:l,createDialog:u,fileTree:d,isLoading:f,isLoadingDir:p,pendingDelete:m,cancelDelete:h,confirmDelete:g,handleSelectFile:_,loadChildren:v,loadSearchResults:y,openCreateDialog:b,requestDelete:x,submitCreateDialog:S,updateDraftPath:C,closeCreateDialog:w}=px({workspaceId:e,refreshToken:t,createRequest:n,onCreateRequestConsumed:r,onSelectFile:i}),[T,E]=(0,V.useState)(``),D=T.trim(),O=(0,V.useMemo)(()=>d?Ox(Dx(d)):[],[d]),[k,A]=(0,V.useState)([]),[j,M]=(0,V.useState)(!1),N=(0,V.useRef)(0),P=D.length>0,F=(0,V.useMemo)(()=>P?k.length:Ex(O),[P,k.length,O]);return(0,V.useEffect)(()=>{let e=!1;if(!P)return A([]),M(!1),()=>{e=!0};M(!0);let t=++N.current,n=setTimeout(()=>{(async()=>{let n=await y(D);e||t!==N.current||(A(n),M(!1))})()},150);return()=>{e=!0,clearTimeout(n)}},[P,y,D]),(0,V.useEffect)(()=>{a?.(F,j||f)},[f,a,j,F]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`file-tree-shell file-tree-shell--${s}`,children:[(0,Y.jsxs)(`label`,{className:`file-tree-search ${s===`desktop`?`file-tree-search--desktop`:``}`,htmlFor:`file-tree-search-${e}`,children:[(0,Y.jsx)(Q,{semantic:`file.action.search`,size:14,className:`file-tree-search-icon`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{id:`file-tree-search-${e}`,className:`file-tree-search-input`,type:`search`,value:T,onChange:e=>E(e.target.value),placeholder:c(`action.search_files`),"aria-label":c(`action.search_files`)})]}),(0,Y.jsx)(`div`,{className:`file-tree`,children:P?j?(0,Y.jsx)(yx,{title:c(`common.loading`)}):k.length>0?k.map(e=>(0,Y.jsx)(Sx,{node:e,selectedPath:l,onRequestDelete:(e,t)=>x({path:e,name:t,error:null}),onSelectFile:_},e.path)):(0,Y.jsx)(yx,{title:c(`command.no_results`)}):d&&d.size>0?O.map(e=>(0,Y.jsx)(Cx,{node:e,depth:0,selectedPath:l,onRequestCreate:b,onRequestDelete:(e,t)=>x({path:e,name:t,error:null}),onSelectFile:_,onLoadChildren:v,isLoadingDir:p,collapseVersion:o},e.path)):(0,Y.jsx)(yx,{title:c(f?`common.loading`:`file.title`)})})]}),(0,Y.jsx)(wx,{dialog:u,onCancel:w,onConfirm:S,onDraftPathChange:C}),(0,Y.jsx)(Tx,{pendingDelete:m,onCancel:h,onConfirm:g})]})},Sx=({node:e,selectedPath:t,onRequestDelete:n,onSelectFile:r})=>{let i=X(),a=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``;return(0,Y.jsxs)(`div`,{className:`tree-item ${t===e.path?`selected`:``}`,onClick:()=>r(e.path),style:{paddingLeft:12},children:[(0,Y.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:mx(e,!1),size:14})}),(0,Y.jsxs)(`span`,{className:`tree-search-labels`,children:[(0,Y.jsx)(`span`,{className:`tree-label`,children:e.name}),a?(0,Y.jsx)(`span`,{className:`tree-search-path`,children:a}):null]}),(0,Y.jsx)(`div`,{className:`tree-item-actions`,children:(0,Y.jsx)($,{content:i(`file.delete`),children:(0,Y.jsx)(Z,{"aria-label":`${i(`file.delete`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Zi,{size:12}),onClick:t=>{t.stopPropagation(),n(e.path,e.name)},size:`sm`})})})]})},Cx=({node:e,depth:t,selectedPath:n,onRequestCreate:r,onRequestDelete:i,onSelectFile:a,onLoadChildren:o,isLoadingDir:s,collapseVersion:c})=>{let l=X(),u=e.kind===`dir`,[d,f]=(0,V.useState)(u&&t===0&&[`app`,`packages`,`src`].includes(e.name.toLowerCase())),p=(0,V.useRef)(!1);(0,V.useEffect)(()=>{e.children&&(p.current=!1)},[e.children]),(0,V.useEffect)(()=>{u&&d&&!e.children&&!p.current&&(p.current=!0,o(e.path))},[u,d,e.children,e.path,o]),(0,V.useEffect)(()=>{c>0&&f(!1)},[c]);let m=()=>{u?(d||o(e.path),f(!d)):a(e.path)},h=t*14+16;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`tree-item ${n===e.path?`selected`:``}`,onClick:m,style:{paddingLeft:h},children:[(0,Y.jsx)(`span`,{className:`tree-chevron`,"aria-hidden":`true`,children:u?d?(0,Y.jsx)(si,{size:14}):(0,Y.jsx)(li,{size:14}):null}),(0,Y.jsx)(`span`,{className:`tree-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:mx(e,d),size:14})}),(0,Y.jsx)(`span`,{className:`tree-label`,children:e.name}),(0,Y.jsx)(`div`,{className:`tree-item-actions`,children:u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{content:l(`file.new_file`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.new_file`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Q,{semantic:`file.action.new`,size:12}),onClick:t=>{t.stopPropagation(),r(`file`,e.path)},size:`sm`})}),(0,Y.jsx)($,{content:l(`file.new_folder`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.new_folder`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Q,{semantic:`file.action.newFolder`,size:12}),onClick:t=>{t.stopPropagation(),r(`folder`,e.path)},size:`sm`})}),(0,Y.jsx)($,{content:l(`file.delete`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.delete`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Zi,{size:12}),onClick:t=>{t.stopPropagation(),i(e.path,e.name)},size:`sm`})})]}):(0,Y.jsx)($,{content:l(`file.delete`),children:(0,Y.jsx)(Z,{"aria-label":`${l(`file.delete`)} ${e.path}`,className:`git-row-action`,icon:(0,Y.jsx)(Zi,{size:12}),onClick:t=>{t.stopPropagation(),i(e.path,e.name)},size:`sm`})})})]}),u&&d&&e.children&&(0,Y.jsxs)(`div`,{className:`tree-children`,children:[Ox(e.children).map(e=>(0,Y.jsx)(Cx,{node:e,depth:t+1,selectedPath:n,onRequestCreate:r,onRequestDelete:i,onSelectFile:a,onLoadChildren:o,isLoadingDir:s,collapseVersion:c},e.path)),e.children.length===0&&!s&&(0,Y.jsx)(bx,{className:`tree-empty-hint`,title:l(`file.empty_directory`)})]}),u&&d&&!e.children&&s===e.path&&(0,Y.jsx)(bx,{className:`tree-loading`,title:l(`common.loading`)})]})},wx=({dialog:e,onCancel:t,onConfirm:n,onDraftPathChange:r})=>{let i=X(),a=(0,V.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,Y.jsxs)(qp,{initialFocus:()=>a.current,onOpenChange:t,open:!0,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(Yp,{children:[e.mode===`file`?(0,Y.jsx)(Q,{"aria-hidden":`true`,semantic:`file.action.new`,size:16}):(0,Y.jsx)(Q,{"aria-hidden":`true`,semantic:`file.action.newFolder`,size:16}),(0,Y.jsx)(`span`,{children:e.mode===`file`?i(`file.new_file`):i(`file.new_folder`)})]}),(0,Y.jsx)(Z,{"aria-label":i(`action.close`),icon:(0,Y.jsx)(ea,{size:14}),onClick:t,size:`sm`})]}),(0,Y.jsx)(Xp,{children:(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`label`,{htmlFor:`file-path`,children:i(`file.path`)}),(0,Y.jsx)(vm,{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,Y.jsx)(`span`,{id:o,className:`dialog-helper`,children:c}),e.error?(0,Y.jsx)(`span`,{id:s,className:`form-error`,role:`alert`,children:e.error}):null]})}),(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{onClick:t,children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:`primary`,onClick:()=>{n()},children:i(`action.confirm`)})]})]})},Tx=({pendingDelete:e,onCancel:t,onConfirm:n})=>{let r=X();return e?(0,Y.jsx)(tm,{open:!0,onOpenChange:t,title:r(`file.delete`),description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:r(`file.delete_confirm`,{name:e.name})}),e.error?(0,Y.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};function Ex(e){return e.reduce((e,t)=>t.kind===`file`?e+1:e+Ex(t.children??[]),0)}function Dx(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 Ox(e){return[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`dir`?-1:1)}function kx(e){return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `)||e.startsWith(`@@`)?`meta`:e.startsWith(`+`)?`added`:e.startsWith(`-`)?`removed`:`context`}var Ax=({workspaceId:e,onClose:t,showCloseButton:n=!0})=>{let r=X(),{preview:i,closePreview:a}=ex(e),o=t??a,s=(0,V.useMemo)(()=>i?.diff.split(`
110
+ `).map((e,t)=>({id:`${t}:${e}`,line:e,tone:kx(e),lineNumber:t+1}))??[],[i]);return(0,Y.jsx)(`div`,{className:`workspace-git-view`,children:(0,Y.jsxs)(`div`,{className:`code-editor workspace-git-editor`,children:[(0,Y.jsxs)(`div`,{className:`code-editor-header`,children:[(0,Y.jsx)(`span`,{className:`code-file-path`,children:i?.title??i?.path??`Select a changed file to inspect`}),i&&n?(0,Y.jsx)(`div`,{className:`code-mode-toggle`,children:(0,Y.jsx)($,{content:r(`action.close`),children:(0,Y.jsx)(Z,{"aria-label":r(`action.close`),className:`code-mode-btn`,icon:(0,Y.jsx)(ea,{size:12}),onClick:o,size:`sm`})})}):null]}),(0,Y.jsx)(`div`,{className:`code-editor-body`,children:i?(0,Y.jsx)(`div`,{className:`code-lines git-diff-lines`,children:s.map(e=>(0,Y.jsxs)(`div`,{className:`code-line git-diff-line git-diff-line-${e.tone}`,children:[(0,Y.jsx)(`span`,{className:`code-line-num`,children:e.lineNumber}),(0,Y.jsx)(`span`,{className:`git-diff-line-text`,children:e.line||` `})]},e.id))}):(0,Y.jsx)(Pm,{className:`git-diff-empty`,description:(0,Y.jsx)(`p`,{className:`git-diff-empty-body`,children:`Select a staged or modified file on the left to inspect its diff.`}),title:(0,Y.jsx)(`p`,{className:`git-diff-empty-title`,children:r(`label.git`)})})})]})})};function jx(e){return e.trim().replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}function Mx(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=jx(t||`worktree`);return`${s}${d}${u}-${f}`}function Nx(e){let t=e.trim();return t?/^[A-Za-z]:[\\/]+$/.test(t)?`${t.slice(0,2)}${t.includes(`\\`)?`\\`:`/`}`:t.replace(/[\\/]+$/,``)||t:``}function Px(e){return/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Fx(e){let t=X(),n=H(Wf),r=H(Qf(e)),[i,a]=xe(_g(e)),o=U(qf),s=U(Jf),c=U(Yf),l=U(Xf),u=U(Zf),d=U(zg),f=rg(),p=(0,V.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,V.useCallback)(async(r,i)=>{let a=Nx(i);if(!a||!Px(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,V.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,V.useMemo)(()=>i.items.find(e=>e.path===r?.path)??null,[i.items,r?.path]),_=(0,V.useMemo)(()=>i.items.filter(e=>e.status===`dirty`).length,[i.items]),v=(0,V.useCallback)(e=>r?.path?Mx(r.path,e):``,[r?.path]),y=(0,V.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 Ix={minHeight:`auto`,padding:`var(--sp-4)`,gap:0},Lx={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function Rx({title:e}){return(0,Y.jsx)(Pm,{className:`worktree-loading`,style:Ix,title:(0,Y.jsx)(`p`,{style:Lx,children:e})})}function zx({workspaceId:e,worktree:t,mobile:n=!1}){let r=X(),{activeTab:i,diff:a,error:o,handleTabChange:s,loading:c,status:l,tree:u}=Tg(e,t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:n?`mobile-worktree-sheet__summary`:void 0,children:(0,Y.jsxs)(`div`,{className:`worktree-chips`,children:[(0,Y.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,t.branch]}),(0,Y.jsxs)(`span`,{className:`worktree-chip worktree-chip-path`,children:[`📁 `,t.path]}),(0,Y.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,Y.jsxs)(Zm,{"aria-label":r(`worktree.title`),onValueChange:e=>s(e),value:i,children:[(0,Y.jsx)(Qm,{className:`worktree-tabs${n?` mobile-worktree-sheet__tabs`:``}`,children:[`status`,`diff`,`tree`].map(e=>(0,Y.jsx)($m,{className:`worktree-tab`,value:e,children:r(e===`status`?`worktree.status_tab`:e===`diff`?`worktree.diff_tab`:`worktree.tree_tab`)},e))}),(0,Y.jsxs)(`div`,{className:n?`mobile-worktree-sheet__content`:void 0,children:[(0,Y.jsxs)(eh,{className:`worktree-content`,value:`status`,children:[o?(0,Y.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,Y.jsx)(Rx,{title:r(`worktree.loading`)}):(0,Y.jsxs)(`div`,{className:`worktree-status-tab`,children:[(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.path`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:t.path})]}),(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`worktree.branch`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:t.branch})]}),(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`git.latest_commit`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:l?.headShortSha||t.commit?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`code`,{children:l?.headShortSha??t.commit}),l?.headSubject?` ${l.headSubject}`:``]}):r(`git.no_commits`)})]}),(0,Y.jsxs)(`div`,{className:`worktree-info-row`,children:[(0,Y.jsx)(`span`,{className:`worktree-info-label`,children:r(`label.status`)}),(0,Y.jsx)(`span`,{className:`worktree-info-value`,children:t.status===`clean`?r(`worktree.clean`):r(`worktree.dirty`)})]}),l?(0,Y.jsxs)(`div`,{className:`worktree-changes`,children:[(0,Y.jsx)(`h4`,{children:r(`worktree.changes`)}),l.staged.length>0?(0,Y.jsx)(`div`,{className:`worktree-change-group`,children:(0,Y.jsx)(`span`,{children:r(`worktree.staged_count`,{count:l.staged.length})})}):null,l.modified.length>0?(0,Y.jsx)(`div`,{className:`worktree-change-group`,children:(0,Y.jsx)(`span`,{children:r(`worktree.modified_count`,{count:l.modified.length})})}):null,l.untracked.length>0?(0,Y.jsx)(`div`,{className:`worktree-change-group`,children:(0,Y.jsx)(`span`,{children:r(`worktree.untracked_count`,{count:l.untracked.length})})}):null]}):null]})]}),(0,Y.jsxs)(eh,{className:`worktree-content`,value:`diff`,children:[o?(0,Y.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,Y.jsx)(Rx,{title:r(`worktree.loading`)}):(0,Y.jsx)(`div`,{className:`worktree-diff-tab`,children:a?(0,Y.jsx)(`pre`,{className:`worktree-diff-output`,children:a}):(0,Y.jsx)(Pm,{className:`worktree-empty`,style:Ix,title:(0,Y.jsx)(`p`,{style:Lx,children:r(`git.no_changes`)})})})]}),(0,Y.jsxs)(eh,{className:`worktree-content`,value:`tree`,children:[o?(0,Y.jsx)(`div`,{className:`worktree-error`,children:o}):null,c?(0,Y.jsx)(Rx,{title:r(`worktree.loading`)}):(0,Y.jsx)(`div`,{className:`worktree-tree-tab`,children:u.length>0?(0,Y.jsx)(`div`,{className:`worktree-tree`,children:u.map(e=>(0,Y.jsxs)(`div`,{className:`worktree-tree-node`,children:[(0,Y.jsx)(`span`,{className:`worktree-tree-icon`,children:e.kind===`dir`?`📁`:`📄`}),(0,Y.jsx)(`span`,{className:`worktree-tree-name`,children:e.name})]},e.path))}):(0,Y.jsx)(Pm,{className:`worktree-empty`,style:Ix,title:(0,Y.jsx)(`p`,{style:Lx,children:r(`worktree.empty_tree`)})})})]})]})]})]})}var Bx={minHeight:`auto`,padding:`var(--sp-4) 0`,gap:0},Vx={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function Hx({title:e}){return(0,Y.jsx)(Pm,{className:`worktree-loading`,style:Bx,title:(0,Y.jsx)(`p`,{style:Vx,children:e})})}function Ux({workspaceId:e,openView:t,onClose:n,desktopPreviewInline:r=!1}){let i=Pr()===`mobile`,a=X(),{createWorktree:o,currentWorktree:s,list:c,loadWorktrees:l,removeWorktreeByPath:u,suggestedPathForBranch:d}=Fx(e),[f,p]=(0,V.useState)(`list`),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)(null),[O,k]=(0,V.useState)(null),A=(0,V.useRef)(!1),j=(0,V.useRef)(null),M=()=>{_(``),y(``),x(!1),T(null)};(0,V.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,V.useEffect)(()=>{f!==`create`||b||y(g.trim()?d(g):``)},[g,b,d,f]);let N=(0,V.useMemo)(()=>c.items.find(e=>e.path===m)??null,[c.items,m]),P=(0,V.useMemo)(()=>c.items.find(e=>e.path===S)??null,[S,c.items]);if((0,V.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}`,te=()=>{D(null),C(null),p(`list`)},L=()=>{M(),C(null),h(null),k(null),p(`create`)},R=()=>{P&&(D(null),u(P.path,P.status===`dirty`).then(e=>{if(e.ok){te();return}D(e.error)}))},z=f===`detail`&&N?(0,Y.jsx)(`div`,{className:i?`mobile-worktree-sheet`:void 0,children:(0,Y.jsx)(zx,{workspaceId:e,worktree:N,mobile:i})}):f===`create`?(0,Y.jsxs)(`form`,{className:`worktree-manager__form`,onSubmit:e=>{e.preventDefault(),T(null),o(g.trim(),v.trim()).then(e=>{if(e.ok){M(),p(`list`);return}T(e.error)})},children:[w?(0,Y.jsx)(`div`,{className:`worktree-error`,children:w}):null,(0,Y.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,Y.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-branch-${e}`,children:a(`worktree.branch`)}),(0,Y.jsx)(vm,{id:`worktree-branch-${e}`,ref:j,value:g,onChange:e=>_(e.target.value),placeholder:`feature/worktree-manager`,autoFocus:!0})]}),(0,Y.jsxs)(`div`,{className:`worktree-manager__field`,children:[(0,Y.jsx)(`label`,{className:`worktree-manager__field-label`,htmlFor:`worktree-path-${e}`,children:a(`worktree.path`)}),(0,Y.jsx)(vm,{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,Y.jsx)(`span`,{id:I,className:`worktree-manager__field-hint`,children:a(`worktree.create_path_hint`)})]}),(0,Y.jsxs)(`div`,{className:`worktree-manager__form-actions`,children:[(0,Y.jsx)(Lp,{variant:`secondary`,onClick:()=>p(`list`),children:a(`action.cancel`)}),(0,Y.jsx)(Lp,{type:`submit`,variant:`primary`,disabled:!ee,children:a(`worktree.create_submit`)})]})]}):f===`confirm-delete`&&P?(0,Y.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[E?(0,Y.jsx)(`div`,{className:`worktree-error`,children:E}):null,(0,Y.jsx)(`p`,{children:P.status===`dirty`?a(`worktree.remove_force_confirm`):a(`worktree.remove_confirm`)}),(0,Y.jsx)(`code`,{className:`worktree-manager__confirm-path`,children:P.path}),(0,Y.jsxs)(`div`,{className:`worktree-manager__confirm-actions`,children:[(0,Y.jsx)(Lp,{variant:`secondary`,onClick:te,children:a(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:`danger`,onClick:()=>{R()},children:P.status===`dirty`?a(`worktree.force_remove`):a(`common.delete`)})]})]}):(0,Y.jsxs)(`div`,{className:`worktree-manager__list`,children:[O?(0,Y.jsx)(`div`,{className:`worktree-error`,children:O}):null,c.error?(0,Y.jsxs)(`div`,{className:`worktree-error`,children:[(0,Y.jsx)(`div`,{children:c.error}),(0,Y.jsx)(Lp,{variant:`secondary`,size:`sm`,onClick:()=>void l(),children:a(`action.refresh`)})]}):null,c.loading&&c.items.length===0?(0,Y.jsx)(Hx,{title:a(`worktree.loading`)}):c.error&&c.items.length===0?null:c.items.length===0?(0,Y.jsx)(Pm,{className:`worktree-empty`,style:Bx,title:(0,Y.jsx)(`p`,{style:Vx,children:a(`worktree.list_empty`)})}):c.items.map((e,t)=>{let n=s?.path===e.path,r=t===0;return(0,Y.jsxs)(`div`,{className:`worktree-manager__row`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`worktree-manager__row-main`,onClick:()=>{k(null),h(e.path),p(`detail`)},children:[(0,Y.jsx)(`span`,{className:`worktree-manager__row-name`,children:e.name}),(0,Y.jsxs)(`div`,{className:`worktree-manager__meta`,children:[(0,Y.jsxs)(`span`,{className:`worktree-chip worktree-chip-branch`,children:[`🌿 `,e.branch]}),(0,Y.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,Y.jsx)(`span`,{className:`worktree-chip`,children:a(`worktree.current`)}):null]}),(0,Y.jsx)(`span`,{className:`worktree-manager__row-path`,children:e.path})]}),!n&&!r?(0,Y.jsx)(Lp,{"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,Y.jsx)(tm,{open:!0,className:`worktree-manager-surface`,title:a(`common.delete`),description:(0,Y.jsxs)(`div`,{className:`worktree-manager__confirm`,children:[E?(0,Y.jsx)(`div`,{className:`worktree-error`,children:E}):null,(0,Y.jsx)(`p`,{children:P.status===`dirty`?a(`worktree.remove_force_confirm`):a(`worktree.remove_confirm`)}),(0,Y.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||te()},onConfirm:R,tone:`danger`}):i?(0,Y.jsx)(Op,{kicker:a(`worktree.title`).toUpperCase(),title:F,body:(0,Y.jsx)(`div`,{className:`worktree-manager-surface`,children:z}),bodyClassName:`mobile-sheet__body--flush`,contentClassName:`mobile-sheet--worktree`,onBack:f===`list`?void 0:()=>p(`list`),headerAction:f===`list`?(0,Y.jsx)(Lp,{size:`sm`,variant:`primary`,onClick:L,children:a(`worktree.new`)}):void 0,onClose:n}):r?(0,Y.jsxs)(`div`,{className:`modal-card modal-card-lg worktree-manager-surface worktree-manager-surface--inline-preview`,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsx)(`div`,{className:`worktree-header-info`,children:(0,Y.jsx)(Yp,{children:F})}),(0,Y.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[f===`list`?(0,Y.jsx)(Lp,{size:`sm`,variant:`primary`,onClick:L,children:a(`worktree.new`)}):(0,Y.jsx)(Lp,{size:`sm`,variant:`ghost`,onClick:()=>p(`list`),children:a(`action.back`)}),(0,Y.jsx)(Lp,{size:`sm`,variant:`ghost`,onClick:n,children:a(`action.close`)})]})]}),(0,Y.jsx)(`div`,{className:`modal-body`,children:z})]}):(0,Y.jsxs)(qp,{className:`worktree-manager-surface`,initialFocus:()=>f===`create`?j.current:null,onOpenChange:e=>{e||n()},open:!0,size:`lg`,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsx)(`div`,{className:`worktree-header-info`,children:(0,Y.jsx)(Yp,{children:F})}),(0,Y.jsxs)(`div`,{className:`worktree-manager-surface__header-actions`,children:[f===`list`?(0,Y.jsx)(Lp,{size:`sm`,variant:`primary`,onClick:L,children:a(`worktree.new`)}):(0,Y.jsx)(Lp,{size:`sm`,variant:`ghost`,onClick:()=>p(`list`),children:a(`action.back`)}),(0,Y.jsx)(Lp,{size:`sm`,variant:`ghost`,onClick:n,children:a(`action.close`)})]})]}),z]})}var Wx={minHeight:`auto`,padding:`12px 0`,gap:`4px`},Gx={margin:0,color:`var(--text-tertiary)`,fontSize:`inherit`,fontWeight:`var(--font-normal)`};function Kx({title:e,action:t}){return(0,Y.jsx)(Pm,{action:t,className:`git-panel-empty`,style:Wx,title:(0,Y.jsx)(`p`,{style:Gx,children:e})})}var qx=({workspaceId:e,refreshToken:t=0,onPreviewOpen:n,variant:r=`desktop`})=>{let i=r===`mobile`,a=H(xa)===`zh`?`zh`:`en`,o=X(),{commitMessage:s,diffPreview:c,gitState:l,groups:u,history:d,historyLoading:f,isLoading:p,pendingDiscard:m,setCommitMessage:h,handleCancelDiscard:g,handleCommit:_,handleConfirmDiscard:v,handleRequestDiscardPaths:y,handleRequestDiscardSingle:b,handleStagePaths:x,handleUnstagePaths:S,openHistoryDiff:C,openDiff:w,runGitMutation:T}=$b({workspaceId:e,refreshToken:t,onPreviewOpen:n,initialHistoryLimit:20}),{currentWorktree:E,hasWorkspace:D,list:O,loadWorktrees:k,openWorktree:A}=Fx(e),[j,M]=(0,V.useState)(null),[N,P]=(0,V.useState)(!1),[F,ee]=(0,V.useState)(!1),I=(0,V.useRef)(!1),[te,L]=(0,V.useState)(()=>i?{staged:!1,changes:!0}:{staged:!1,changes:!1});(0,V.useEffect)(()=>{I.current=!1},[e]),(0,V.useEffect)(()=>{if(!D){I.current=!1;return}O.lastLoadedAt||O.loading||I.current||(I.current=!0,k())},[D,O.lastLoadedAt,O.loading,k]);let R=l?.staged.length??0,z=!!s.trim()&&R>0,ne=async e=>{if(E?.path===e.path){M(`list`);return}await A(e.path)};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`git-panel git-panel--${r}`,children:(0,Y.jsxs)(`div`,{className:`git-panel-scroll`,children:[(0,Y.jsxs)(`section`,{className:`git-commit-block`,children:[(0,Y.jsx)(Fh,{className:`git-commit-input`,placeholder:o(`git.commit_summary_placeholder`),value:s,onChange:e=>h(e.target.value),rows:3,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),_())}}),(0,Y.jsx)(`div`,{className:`git-commit-actions`,children:(0,Y.jsx)($,{content:o(z?`git.commit`:`git.nothing_staged`),children:(0,Y.jsxs)(`button`,{className:`git-commit-primary`,onClick:()=>void _(),disabled:!z,type:`button`,children:[(0,Y.jsx)(`span`,{children:o(`git.commit`)}),(0,Y.jsx)(Q,{semantic:`git.commit`,size:14})]})})})]}),(0,Y.jsxs)(`section`,{className:`git-panel-section`,children:[(0,Y.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>P(e=>!e),"aria-expanded":N,children:[(0,Y.jsx)(`span`,{children:o(`worktree.list_title`)}),(0,Y.jsx)(`span`,{className:`git-panel-section-count`,children:O.items.length}),(0,Y.jsx)(`span`,{className:`git-panel-section-chevron ${N?`expanded`:``}`,children:(0,Y.jsx)(si,{size:14})})]}),(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>M(`create`),children:[(0,Y.jsx)(Q,{semantic:`worktree.action.new`,size:12}),(0,Y.jsx)(`span`,{children:o(`worktree.new`)})]})]}),N?(0,Y.jsx)(`div`,{className:`git-panel-section-body`,children:O.loading&&O.items.length===0?(0,Y.jsx)(Kx,{title:o(`worktree.loading`)}):O.error?(0,Y.jsx)(Kx,{action:(0,Y.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void k(),children:o(`action.refresh`)}),title:O.error}):O.items.length===0?(0,Y.jsx)(Kx,{title:o(`worktree.list_empty`)}):O.items.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`git-worktree-row ${E?.path===e.path?`active`:``}`,onClick:()=>void ne(e),children:[(0,Y.jsx)(`span`,{className:`git-worktree-row__dot git-worktree-row__dot-${e.status}`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`git-worktree-row__copy`,children:[(0,Y.jsx)(`span`,{className:`git-worktree-row__name`,children:e.name}),(0,Y.jsxs)(`span`,{className:`git-worktree-row__meta`,children:[e.branch,` ·`,` `,e.status===`clean`?o(`worktree.clean`):o(`worktree.dirty_status`)]})]}),E?.path===e.path?(0,Y.jsx)(`span`,{className:`git-worktree-row__chip`,children:o(`worktree.current`)}):null]},e.path))}):null]}),(0,Y.jsx)(`div`,{className:`git-panel-groups`,children:l&&u.length>0?u.map(t=>(0,Y.jsx)(Jx,{title:t.title,changes:t.changes,mobile:i,collapsed:te[t.title]??!1,selectedPath:c?.path??null,onToggleCollapsed:()=>L(e=>({...e,[t.title]:!(e[t.title]??!1)})),onStageAll:async()=>{if(t.title===`staged`){await S(t.changes.map(({change:e})=>e.path));return}await x(t.changes.map(({change:e})=>e.path))},onDiscardAll:()=>y(t.changes.map(({change:e})=>e.path)),onViewDiff:w,onRunMutation:T,onRequestDiscard:b,workspaceId:e},t.title)):(0,Y.jsx)(Kx,{title:o(p?`common.loading`:`git.no_changes`)})}),(0,Y.jsxs)(`section`,{className:`git-panel-section git-panel-section-history`,children:[(0,Y.jsx)(`div`,{className:`git-panel-section-header`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:()=>ee(e=>!e),"aria-expanded":F,children:[(0,Y.jsx)(`span`,{children:o(`git.history`)}),(0,Y.jsx)(`span`,{className:`git-panel-section-chevron ${F?`expanded`:``}`,children:(0,Y.jsx)(si,{size:14})})]})}),F?(0,Y.jsx)(`div`,{className:`git-panel-section-body`,children:f&&d.length===0?(0,Y.jsx)(Kx,{title:o(`common.loading`)}):d.length===0?(0,Y.jsx)(Kx,{title:o(`git.no_commits`)}):d.map((e,t)=>(0,Y.jsx)(Xx,{entry:e,isCurrent:t===0,locale:a,onOpen:C},e.sha))}):null]})]})}),(0,Y.jsx)(Ux,{workspaceId:e,openView:j,onClose:()=>M(null)}),(0,Y.jsx)(Zx,{discard:m,onCancel:g,onConfirm:v})]})},Jx=({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=X(),p=e===`staged`?`git.staged`:`git.changes`,m=f(e===`staged`?`git.unstage_all`:`git.stage_all`);return(0,Y.jsxs)(`section`,{className:`git-panel-section git-panel-section-changes`,children:[(0,Y.jsxs)(`div`,{className:`git-panel-section-header`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`git-panel-section-toggle`,onClick:u,"aria-expanded":!n,children:[(0,Y.jsx)(`span`,{children:f(p)}),(0,Y.jsx)(`span`,{className:`git-panel-section-count`,children:t.length}),(0,Y.jsx)(`span`,{className:`git-panel-section-chevron ${n?``:`expanded`}`,children:(0,Y.jsx)(si,{size:14})})]}),(0,Y.jsxs)(`div`,{className:`git-panel-section-actions`,children:[(0,Y.jsx)($,{content:m,children:(0,Y.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void l(),children:m})}),e===`changes`?(0,Y.jsx)($,{content:f(`git.discard_all`),children:(0,Y.jsx)(`button`,{type:`button`,className:`git-panel-section-link`,onClick:()=>void o(),children:f(`git.discard_all`)})}):null]})]}),n?null:(0,Y.jsx)(`div`,{className:`git-panel-section-body`,children:t.map(({change:e,type:t})=>(0,Y.jsx)(Yx,{change:e,type:t,mobile:r,workspaceId:a,selected:i===e.path,onViewDiff:d,onRunMutation:c,onRequestDiscard:s},`${t}:${e.path}`))})]})},Yx=({change:e,type:t,mobile:n,workspaceId:r,selected:i,onViewDiff:a,onRunMutation:o,onRequestDiscard:s})=>{let c=X(),l=(0,V.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,Y.jsx)(Ni,{size:12}):(0,Y.jsx)(Bi,{size:12}),h=$x(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,Y.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,Y.jsx)(`span`,{className:`git-row-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:h,size:13})}),(0,Y.jsxs)(`div`,{className:`git-row-content`,children:[(0,Y.jsx)(`span`,{className:`git-row-name`,children:u}),(0,Y.jsxs)(`span`,{className:`git-row-meta`,children:[d?(0,Y.jsx)(`span`,{className:`git-row-dir`,children:d}):null,e.oldPath?(0,Y.jsx)(`span`,{className:`git-row-rename`,children:e.oldPath}):null]})]}),(0,Y.jsxs)(`div`,{className:`git-row-actions`,children:[(0,Y.jsx)($,{content:f,children:(0,Y.jsx)(Z,{"aria-label":f,className:`git-row-action`,icon:m,onClick:e=>{e.stopPropagation(),g()},size:`sm`,type:`button`,variant:`ghost`})}),(0,Y.jsx)($,{content:p,children:(0,Y.jsx)(Z,{"aria-label":p,className:`git-row-action`,icon:(0,Y.jsx)(Hi,{size:12}),onClick:t=>{t.stopPropagation(),s(e.path)},size:`sm`,type:`button`,variant:`ghost`})})]})]})};function Xx({entry:e,isCurrent:t,locale:n,onOpen:r}){return(0,Y.jsxs)(`button`,{type:`button`,className:`git-history-row ${t?`current`:``}`,onClick:()=>void r(e),children:[(0,Y.jsx)(`span`,{className:`git-history-row__dot`,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`git-history-row__copy`,children:[(0,Y.jsx)($,{content:e.subject,children:(0,Y.jsx)(`span`,{className:`git-history-row__title`,children:e.subject})}),(0,Y.jsxs)(`span`,{className:`git-history-row__meta`,children:[e.shortSha,` · `,e.authorName]})]}),(0,Y.jsx)(`span`,{className:`git-history-row__when`,children:Ep(e.authoredAt,n)})]})}var Zx=({discard:e,onCancel:t,onConfirm:n})=>{let r=X();return e?(0,Y.jsx)(tm,{open:!0,onOpenChange:t,title:e.scope===`all`?r(`git.discard_all_confirm_title`):r(`git.discard_file_confirm_title`),description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.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 Qx(e,t){return e.status?e.status:t===`deleted`?`deleted`:t===`untracked`?`untracked`:`modified`}function $x(e,t){switch(Qx(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 eS={minHeight:`auto`,padding:`var(--sp-8)`,gap:0},tS={margin:0,color:`var(--text-tertiary)`,fontWeight:`var(--font-normal)`};function nS({title:e}){return(0,Y.jsx)(Pm,{className:`branch-quick-pick-empty`,style:eS,title:(0,Y.jsx)(`p`,{style:tS,children:e})})}function rS(){let e=X(),{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}=tx(),m=(0,V.useRef)(null),h=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{m.current?.focus()},0);return()=>{window.clearTimeout(e)}},[]),(0,V.useEffect)(()=>{h.current&&h.current.querySelector(`.branch-quick-pick-item:nth-child(${l+1})`)?.scrollIntoView({block:`nearest`})},[l]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`branch-quick-pick-search`,children:(0,Y.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,Y.jsx)(`div`,{className:`branch-quick-pick-list`,ref:h,children:t.loading?(0,Y.jsx)(nS,{title:`Loading branches...`}):n.length>0?n.map((t,n)=>(0,Y.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,Y.jsxs)(Y.Fragment,{children:[t.branch.isCurrent&&(0,Y.jsx)(`span`,{className:`branch-quick-pick-check`,children:(0,Y.jsx)(oi,{size:14})}),(0,Y.jsx)(`span`,{className:`branch-quick-pick-name`,children:t.branch.name}),t.branch.linkedWorktreePath&&!t.branch.isCurrent&&(0,Y.jsx)(kh,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:e(`git.quick_pick.in_use`)}),t.branch.isRemote&&(0,Y.jsx)(kh,{color:`neutral`,caps:!1,className:`branch-quick-pick-badge`,children:`Remote`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`branch-quick-pick-create-icon`,children:(0,Y.jsx)(Q,{semantic:`git.branch.create`,size:14})}),(0,Y.jsx)(`span`,{className:`branch-quick-pick-create-label`,children:t.label})]})},t.type===`branch`?t.branch?.name:`create`)):(0,Y.jsx)(nS,{title:s?`No branches found`:`Type to search branches`})}),(0,Y.jsxs)(`div`,{className:`branch-quick-pick-hint`,children:[(0,Y.jsx)(`span`,{children:`↑↓ Navigate`}),(0,Y.jsx)(`span`,{children:`↵ Select`}),(0,Y.jsx)(`span`,{children:`Esc Close`})]})]})}function iS({children:e,workspaceId:t,onOpenBranchSwitcher:n}){let r=Pr(),i=X(),a=H(hg),o=U(hg);return r===`mobile`||!n?e:(0,Y.jsx)(om,{content:(0,Y.jsx)(rS,{}),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 aS(){let e=Pr(),t=X(),{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}=tx(),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,Y.jsx)(oi,{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,Y.jsx)(`div`,{onKeyDown:g,children:(0,Y.jsx)(sh,{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 oS=({workspaceId:e,gitState:t,inline:n=!1,onRefresh:r})=>{let i=X(),a=H(xa),o=H(vg(e)),{authPrompt:s,clearAuthPrompt:c,getAuthPromptMessage:l,handleFetch:u,handlePull:d,handlePush:f,syncingIntent:p}=Xb(e),m=`git-auth-form-${e}`,[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)({username:``,password:``});if((0,V.useLayoutEffect)(()=>{if(!s){v({username:``,password:``});return}v(e=>({username:e.username||s.details.usernameHint||``,password:``}))},[s]),!t)return null;let y=t.staged.length+t.modified.length+t.untracked.length+t.deleted.length,b=t.ahead,x=t.behind,S=o.status===`fetching`,C=o.lastFetchAt?i(`git.fetch_last_at`,{when:Dp(o.lastFetchAt,a)}):i(`git.fetch_last_never`),w=i(S?`git.fetch_in_progress`:`git.fetch_label`),T=h?.intent===`push`?i(`git.push_confirm_title`):i(`git.pull_confirm_title`),E=h?.intent===`push`?i(`git.push_confirm_message`,{count:h.count}):i(`git.pull_confirm_message`,{count:h?.count??0}),D=h?.intent===`push`?i(`action.push`):i(`action.pull`),O=h?.intent===`push`?i(`git.push_in_progress`):i(`git.pull_in_progress`),k=!!(h&&p===h.intent),A=s?.intent,j=A??h?.intent??`pull`,M=i(A===`push`?`action.push`:A===`pull`?`action.pull`:`git.fetch_label`),N=i(A===`push`?`git.push_in_progress`:A===`pull`?`git.pull_in_progress`:`git.fetch_in_progress`),P=!!(A&&p===A),F=k||P,ee=!!(h&&!s),I=!!s,te=(e,t)=>{t<=0||g({intent:e,count:t})},L=()=>{F||(g(null),c())},R=e=>{e||L()},z=async()=>{if(h){if(h.intent===`push`){await f()&&g(null);return}await d()&&g(null)}},ne=async()=>{if(!s)return;let e={username:_.username.trim(),password:_.password};!e.username||!e.password||(s.intent===`push`?await f(e):s.intent===`pull`?await d(e):await u(e))&&(c(),g(null),r?.())},re=async()=>{await u()&&r?.()};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`git-status-bar${n?` git-status-bar--inline`:``}`,children:[(0,Y.jsx)($,{content:i(`git.statusbar.changes`),children:(0,Y.jsxs)(`span`,{className:`git-status-bar__item git-status-bar__item--changes`,children:[(0,Y.jsx)(Q,{semantic:`git.footer.diff`,size:13}),(0,Y.jsx)(`span`,{className:`git-status-bar__value`,children:y})]})}),(0,Y.jsx)($,{content:i(`git.statusbar.ahead`),children:(0,Y.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--ahead`,type:`button`,"aria-label":i(`action.push`),disabled:b<=0,onClick:()=>te(`push`,b),children:[(0,Y.jsx)(Q,{semantic:`git.footer.push`,size:13}),(0,Y.jsx)(`span`,{className:`git-status-bar__value`,children:b})]})}),(0,Y.jsx)($,{content:i(`git.statusbar.behind`),children:(0,Y.jsxs)(`button`,{className:`git-status-bar__item git-status-bar__item--actionable git-status-bar__item--behind`,type:`button`,"aria-label":i(`action.pull`),disabled:x<=0,onClick:()=>te(`pull`,x),children:[(0,Y.jsx)(Q,{semantic:`git.footer.pull`,size:13}),(0,Y.jsx)(`span`,{className:`git-status-bar__value`,children:x})]})}),(0,Y.jsx)($,{content:C,children:(0,Y.jsx)(Z,{"aria-label":w,className:`git-status-bar__item git-status-bar__item--actionable`,disabled:S,icon:(0,Y.jsx)(Q,{semantic:`git.footer.refresh`,size:13,className:S?`spin`:void 0}),onClick:()=>void re(),size:`sm`})})]}),ee?(0,Y.jsx)(tm,{className:`git-status-bar__confirm`,dismissible:!F,closeDisabled:F,open:!0,onOpenChange:R,title:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{semantic:`git.action.warning`,size:16}),(0,Y.jsx)(`span`,{children:T})]}),description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:E}),(0,Y.jsx)(`p`,{className:`dialog-helper`,children:i(`git.sync_confirm_helper`)})]}),cancelDisabled:F,cancelText:i(`action.cancel`),closeLabel:i(`action.close`),confirmText:k?O:D,confirmDisabled:k,onConfirm:()=>{z()}}):null,I?(0,Y.jsxs)(qp,{className:`git-status-bar__confirm`,dismissible:!F,open:!0,onOpenChange:R,children:[(0,Y.jsxs)(Jp,{children:[(0,Y.jsxs)(Yp,{children:[(0,Y.jsx)(Q,{semantic:`git.action.warning`,size:16}),(0,Y.jsx)(`span`,{children:i(j===`push`?`git.push_confirm_title`:j===`pull`?`git.pull_confirm_title`:`git.fetch_label`)})]}),(0,Y.jsx)(Z,{"aria-label":i(`action.close`),disabled:F,icon:(0,Y.jsx)(ea,{size:14}),onClick:L,size:`sm`})]}),(0,Y.jsx)(Xp,{children:s.details.canPrompt?(0,Y.jsxs)(`form`,{id:m,className:`form-group`,onSubmit:e=>{e.preventDefault(),ne()},children:[(0,Y.jsx)(`p`,{children:l(s.details)}),(0,Y.jsx)(`span`,{className:`dialog-helper`,children:i(`git.auth_helper_http`)}),(0,Y.jsx)(`label`,{htmlFor:`git-auth-username-${e}`,children:i(`git.auth_username`)}),(0,Y.jsx)(vm,{id:`git-auth-username-${e}`,value:_.username,onChange:e=>v(t=>({...t,username:e.target.value})),placeholder:s.details.usernameHint??i(`git.auth_username_placeholder`),autoFocus:!0,disabled:P}),(0,Y.jsx)(`label`,{htmlFor:`git-auth-password-${e}`,children:i(`git.auth_password`)}),(0,Y.jsx)(vm,{id:`git-auth-password-${e}`,type:`password`,value:_.password,onChange:e=>v(t=>({...t,password:e.target.value})),placeholder:i(`git.auth_password_placeholder`),disabled:P})]}):(0,Y.jsxs)(`div`,{className:`form-group`,children:[(0,Y.jsx)(`p`,{children:l(s.details)}),(0,Y.jsx)(`span`,{className:`dialog-helper`,children:i(`git.auth_helper_unsupported`)})]})}),(0,Y.jsxs)(Zp,{children:[(0,Y.jsx)(Lp,{onClick:L,disabled:F,children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:`primary`,form:s.details.canPrompt?m:void 0,type:s.details.canPrompt?`submit`:`button`,disabled:!s.details.canPrompt||P||!_.username.trim()||!_.password,children:P?N:M})]})]}):null]})};function sS({"aria-controls":e,"aria-expanded":t,"aria-haspopup":n,ariaLabel:r,branchName:i,branchSummary:a,disabled:o,onClick:s,onKeyDown:c}){return(0,Y.jsx)($,{content:i,children:(0,Y.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,Y.jsx)(Q,{semantic:`git.footer.branch`,size:11}),(0,Y.jsx)(`span`,{className:`git-panel-status-strip__branch-text`,children:i})]})})}function cS({workspaceId:e,gitState:t,onOpenBranchSwitcher:n,align:r=`end`}){let i=X(),a=Pr(),o=t?.branch?.trim()||i(`git.no_branch`),s=t&&(t.ahead>0||t.behind>0)?[t.ahead>0?`↑${t.ahead}`:null,t.behind>0?`↓${t.behind}`:null].filter(Boolean).join(` `):null,c=(0,Y.jsx)(sS,{ariaLabel:`${i(`git.current_branch`)}: ${o}`,branchName:o,branchSummary:s,disabled:!n,onClick:a===`mobile`?n:void 0});return(0,Y.jsxs)(`div`,{className:`git-panel-status-strip git-panel-status-strip--${r}`,children:[a===`desktop`&&n?(0,Y.jsx)(iS,{workspaceId:e,onOpenBranchSwitcher:n,children:c}):c,(0,Y.jsx)(`div`,{className:`git-panel-status-strip__meta`,children:(0,Y.jsx)(oS,{workspaceId:e,gitState:t,inline:!0})})]})}function lS({workspaceId:e,gitState:t,onOpenBranchSwitcher:n,flush:r=!1,align:i=`end`}){return(0,Y.jsx)(`div`,{className:`workspace-status-bar${r?` workspace-status-bar--flush`:``}`,children:(0,Y.jsx)(cS,{align:i,workspaceId:e,gitState:t,onOpenBranchSwitcher:n})})}var uS=()=>{let e=(0,V.useRef)(null),t=sx(e),[n,r]=(0,V.useState)(0),i=X(),{createRequest:a,focusMode:o,gitState:s,handleBottomMouseDown:c,handleConsumeCreateRequest:l,handleLeftMouseDown:u,handleOpenBranchSwitcher:d,handleOpenFileCreate:f,handleOpenFolderCreate:p,leftPanelWidth:m,leftPanelRef:h,mainAreaMode:g,setSidebarTab:_,sidebarCollapsed:v,sidebarTab:y,terminalPanelVisible:b,workspace:x,bottomPanelHeight:S,bottomPanelRef:C,workspaceId:w}=fx(),T=U(lg(w)),E=U(Sg),{closePreview:D}=ex(w);return(0,V.useEffect)(()=>{let e=e=>{if(e.metaKey||e.ctrlKey){if(e.key.toLowerCase()===`b`){e.preventDefault(),E(e=>!e);return}if(e.key===`1`){e.preventDefault(),_(`files`);return}e.key===`2`&&(e.preventDefault(),_(`git`))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,_]),x?(0,Y.jsxs)(`div`,{ref:e,className:`workspace-page workspace-page--desktop`,children:[(0,Y.jsx)(Gb,{fullscreenController:t}),(0,Y.jsxs)(`div`,{className:`workspace-body`,children:[!o&&!v&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`aside`,{ref:h,className:`left-panel`,style:{width:`${m}px`},children:(0,Y.jsxs)(`div`,{className:`nav-panel workspace-sidebar-panel`,children:[(0,Y.jsxs)(`div`,{className:`workspace-sidebar-panel__header`,children:[(0,Y.jsx)(Zm,{"aria-label":`Workspace sections`,onValueChange:_,value:y,children:(0,Y.jsxs)(Qm,{className:`workspace-sidebar-panel__tabs`,children:[(0,Y.jsx)($m,{className:`workspace-sidebar-panel__tab`,value:`files`,children:(0,Y.jsx)(`span`,{children:i(`file.title`)})}),(0,Y.jsx)($m,{className:`workspace-sidebar-panel__tab`,value:`git`,children:(0,Y.jsx)(`span`,{children:i(`label.git`)})})]})}),(0,Y.jsx)(`div`,{className:`workspace-sidebar-panel__actions`,children:y===`files`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{content:i(`file.new_file`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":i(`file.new_file`),icon:(0,Y.jsx)(Q,{semantic:`file.action.new`,size:14}),onClick:f,size:`sm`})}),(0,Y.jsx)($,{content:i(`file.new_folder`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":i(`file.new_folder`),icon:(0,Y.jsx)(Q,{semantic:`file.action.newFolder`,size:14}),onClick:p,size:`sm`})}),(0,Y.jsx)($,{content:i(`file.collapse_all`),children:(0,Y.jsx)(Z,{className:`panel-toolbar-btn`,"aria-label":i(`file.collapse_all`),icon:(0,Y.jsx)(di,{size:14}),onClick:()=>r(e=>e+1),size:`sm`})})]}):null})]}),(0,Y.jsx)(`div`,{className:`workspace-sidebar-panel__body`,children:y===`files`?(0,Y.jsx)(xx,{workspaceId:x.id,createRequest:a,onCreateRequestConsumed:l,collapseVersion:n,variant:`desktop`}):(0,Y.jsx)(qx,{workspaceId:x.id,variant:`desktop`})})]})}),(0,Y.jsx)(`div`,{className:`split-divider-v`,onMouseDown:u,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize left panel`})]}),(0,Y.jsxs)(`div`,{className:`workspace-main-area`,children:[(0,Y.jsx)(`div`,{className:`workspace-main-stage`,children:g===`diff`?(0,Y.jsx)(Ax,{workspaceId:x.id,onClose:()=>{D(),T(null)}}):g===`editor`?(0,Y.jsx)(Eb,{}):(0,Y.jsx)(`div`,{className:`agent-panes`,children:(0,Y.jsx)(vb,{hydrateSessions:!1})})}),!o&&b&&(0,Y.jsx)(`div`,{className:`split-divider-h`,onMouseDown:c,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize bottom panel`}),!o&&b&&(0,Y.jsx)(`div`,{ref:C,className:`workspace-bottom-panel`,style:{height:`${S}px`},children:(0,Y.jsx)(Ib,{})})]})]}),(0,Y.jsx)(lS,{align:`start`,workspaceId:x.id,gitState:s,onOpenBranchSwitcher:d})]}):(0,Y.jsx)(`div`,{className:`workspace-page workspace-page-empty`,children:(0,Y.jsx)(`div`,{className:`workspace-empty-content`,children:(0,Y.jsx)(`div`,{className:`workspace-empty-inner`,children:(0,Y.jsx)(Pm,{style:{minHeight:`auto`,padding:0},title:(0,Y.jsx)(`p`,{children:i(`workspace.no_workspace`)})})})})})},dS={minHeight:`auto`,padding:0,gap:0,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function fS({title:e,description:t,testId:n}){return(0,Y.jsx)(`div`,{className:`workspace-resolving-shell`,"data-testid":n,children:(0,Y.jsx)(`div`,{className:`workspace-resolving-card`,children:(0,Y.jsx)(Pm,{style:dS,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`workspace-resolving-kicker`,children:X()(`workspace.title`)}),(0,Y.jsx)(`div`,{className:`workspace-resolving-title`,children:e})]}),description:(0,Y.jsx)(`div`,{className:`workspace-resolving-desc`,children:t})})})})}function pS({title:e,description:t}){let n=X();return(0,Y.jsx)(fS,{title:e??n(`workspace.load_failed_title`),description:t??n(`workspace.load_failed_description`)})}function mS(){let e=X();return(0,Y.jsx)(fS,{testId:`workspace-resolving-shell`,title:e(`workspace.loading_title`),description:e(`workspace.loading_description`)})}function hS({children:e}){let t=H(np),n=H(Xf),r=H(Zf),i=Wt().pathname===`/workspace`;return!t&&n===`error`?(0,Y.jsx)(pS,{description:r??`Failed to fetch workspace list`}):!t&&(n===`idle`||n===`loading`||i&&n===`ready`)?(0,Y.jsx)(mS,{}):(0,Y.jsx)(Y.Fragment,{children:e})}function gS(){let e=(0,V.useRef)(0),t=qt(),n=Wt(),r=H(Rr),i=H(Lf),a=H(Wf),o=H(ep),s=H(Sa),c=H(Uf),l=H(Xf),u=U(qf),d=U(Ta),f=U(Jf),p=U(Yf),m=U(Xf),h=U(Zf);(0,V.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 _S=25e3;function vS(){let e=H(Rr),t=H(Br),n=H(Lf),r=H(Bf),[i,a]=(0,V.useState)(()=>Date.now());if((0,V.useEffect)(()=>{if(r===null||n!==`reconnecting`&&n!==`disconnected`)return;let e=r+_S-Date.now();if(e<=0){a(Date.now());return}let t=setTimeout(()=>{a(Date.now())},e);return()=>{clearTimeout(t)}},[n,r]),n===`connected`||n===`connecting`)return null;if(n===`rejected`||e===`gated`&&t===`displaced`)return(0,Y.jsx)(`div`,{className:`connection-banner connection-banner--error`,role:`status`,"aria-live":`polite`,children:(0,Y.jsx)(`span`,{children:`另一个标签页已激活`})});let o=r!==null&&i-r>=_S&&(n===`reconnecting`||n===`disconnected`);return(0,Y.jsxs)(`div`,{className:`connection-banner`,role:`status`,"aria-live":`polite`,children:[(0,Y.jsx)(`span`,{children:`连接已断开,正在重新连接...`}),o?(0,Y.jsx)(`span`,{children:`连接恢复较慢,可能是网络问题。如果长时间没有恢复,可以刷新页面。`}):null]})}var yS={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function bS(){gS();let e=H(Uf),t=Wt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname===`/session-gate`;return(0,Y.jsxs)(`div`,{className:`app`,children:[(0,Y.jsx)(vS,{}),(0,Y.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,Y.jsx)(`div`,{className:`app-loading-shell`,children:(0,Y.jsx)(`div`,{className:`app-loading-card`,children:(0,Y.jsx)(Pm,{style:yS,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,Y.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,Y.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,Y.jsxs)(xn,{children:[(0,Y.jsx)(yn,{path:`/`,element:(0,Y.jsx)(V_,{})}),(0,Y.jsx)(yn,{path:`/login`,element:(0,Y.jsx)(Gh,{})}),(0,Y.jsx)(yn,{path:`/session-gate`,element:(0,Y.jsx)(qh,{})}),(0,Y.jsx)(yn,{path:`/workspace`,element:(0,Y.jsx)(hS,{children:(0,Y.jsx)(uS,{})})}),(0,Y.jsx)(yn,{path:`/settings`,element:(0,Y.jsx)(N_,{})}),(0,Y.jsx)(yn,{path:`*`,element:(0,Y.jsx)(Ig,{})})]})}),(0,Y.jsx)(Ng,{}),(0,Y.jsx)(Ug,{})]})}function xS({sessionId:e,onOpen:t}){let n=H(jv),r=X(),i=(0,V.useMemo)(()=>{if(!e)return null;let t=n.get(e);return t?{state:t.state,label:r(`supervisor.title`)}:{state:`inactive`,label:r(`supervisor.title`)}},[e,n,r]);return i?(0,Y.jsxs)(`button`,{type:`button`,className:`mobile-supervisor-badge mobile-supervisor-badge--${i.state}`,"aria-label":r(`mobile.supervisor.open_sheet`),onClick:t,children:[(0,Y.jsx)(`span`,{className:`mobile-supervisor-badge__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`supervisor.entry`,size:13})}),(0,Y.jsx)(`span`,{className:`mobile-supervisor-badge__label`,children:i.label})]}):null}function SS({sessionId:e,workspaceId:t,onClose:n,defaultSupervisorDetailsOpen:r=!1}){let i=X(),[a,o]=(0,V.useState)(null),s=U(Pv),{dialog:c,supervisor:l,mode:u,copy:d,isDisable:f,disableObjective:p,isMaxSupervisionCountValid:m,close:h,updateDraft:g,confirm:_}=Vv({workspaceId:t,sessionId:e});(0,V.useEffect)(()=>{l||a||s(t=>t.sessionId===e&&t.mode===`enable`&&!t.open?t:{open:!1,sessionId:e,mode:`enable`,draftObjective:t.sessionId===e&&t.mode===`enable`?t.draftObjective:``,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:``})},[a,e,s,l]),(0,V.useEffect)(()=>{if(!c.open||c.sessionId!==e){o(null);return}o(c.mode)},[c.mode,c.open,c.sessionId,e]);let v=t=>{s({open:!0,sessionId:e,mode:t,draftObjective:l?.objective??``,draftEvaluatorProviderId:l?.evaluatorProviderId??`claude`,draftEvaluatorModel:l?.evaluatorModel??``,draftMaxSupervisionCount:String(l?.maxSupervisionCount??0),draftScheduledAt:Lv(l?.scheduledAt)}),o(t)},y=(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__detail`,children:[(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__detail-header`,children:[(0,Y.jsx)(`span`,{className:`supervisor-dialog-header-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Gv,{mode:u})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:d.title}),(0,Y.jsx)(`p`,{children:d.subtitle})]})]}),(0,Y.jsx)(Kv,{mode:u,draftObjective:c.draftObjective,draftEvaluatorProviderId:c.draftEvaluatorProviderId,draftEvaluatorModel:c.draftEvaluatorModel,draftMaxSupervisionCount:c.draftMaxSupervisionCount,draftScheduledAt:c.draftScheduledAt,isMaxSupervisionCountValid:m,disableObjective:p,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})})]}),b=(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__footer`,children:[(0,Y.jsx)(Lp,{onClick:()=>{h(),o(null),l||n()},children:i(`action.cancel`)}),(0,Y.jsx)(Lp,{variant:f?`danger`:`primary`,onClick:()=>{(async()=>{await _()&&!l&&n()})()},disabled:!f&&!c.draftObjective.trim(),children:d.confirm})]});return a?(0,Y.jsx)(Op,{title:d.title,kicker:i(`supervisor.title`),onBack:()=>{h(),o(null)},onClose:()=>{h(),o(null),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:y,footer:b}):l?(0,Y.jsx)(Op,{title:i(`supervisor.title`),kicker:i(`supervisor.title`),onClose:n,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--root`,fullscreen:!0,body:(0,Y.jsx)(`div`,{className:`mobile-supervisor-sheet__root`,children:l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Xv,{sessionId:e,workspaceId:t,defaultDetailsOpen:r}),(0,Y.jsxs)(`div`,{className:`mobile-supervisor-sheet__actions`,children:[(0,Y.jsx)(Lp,{onClick:()=>v(`edit`),children:i(`supervisor.action.edit_objective`)}),(0,Y.jsx)(Lp,{onClick:()=>v(`disable`),children:i(`supervisor.action.disable`)})]})]}):null})}):(0,Y.jsx)(Op,{title:d.title,kicker:i(`supervisor.title`),onClose:()=>{h(),n()},bodyClassName:`mobile-sheet__body--supervisor-detail`,contentClassName:`mobile-supervisor-sheet mobile-supervisor-sheet--detail`,fullscreen:!0,body:y,footer:b})}var CS=`(orientation: landscape)`,wS=`(max-height: 540px)`;function TS(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return`default`;let e=window.matchMedia(CS).matches,t=window.matchMedia(wS).matches;return e&&t?`landscape-compact`:`default`}function ES(){let[e,t]=(0,V.useState)(TS);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(CS),n=window.matchMedia(wS),r=()=>{t(TS())};return e.addEventListener(`change`,r),n.addEventListener(`change`,r),r(),()=>{e.removeEventListener(`change`,r),n.removeEventListener(`change`,r)}},[]),e}var DS=`(prefers-reduced-motion: reduce)`;function OS(){return typeof window>`u`||typeof window.matchMedia!=`function`?`default`:window.matchMedia(DS).matches?`reduced`:`default`}function kS(){let[e,t]=(0,V.useState)(OS);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(DS),n=()=>{t(e.matches?`reduced`:`default`)};return e.addEventListener(`change`,n),n(),()=>{e.removeEventListener(`change`,n)}},[]),e}function AS(){let[e,t]=(0,V.useState)(0);return(0,V.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 jS(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 MS({activeSessionId:e,activeWorkspaceId:t,defaultMode:n=`list`,sessions:r,onClose:i,onCloseSession:a,onSelectSession:o,onSessionCreated:s}){let c=H(Wf),l=U(rp),u=X(),d=rg(),[f,p]=(0,V.useState)(n===`create`?`providers`:`sessions`),m=r.find(t=>t.id===e)??r[0]??null,h=!!t,g=[{id:`claude`,title:`Claude`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.claude`,size:16})},{id:`codex`,title:`Codex`,icon:(0,Y.jsx)(Q,{semantic:`agent.provider.codex`,size:16})}],_=()=>{p(n===`create`?`providers`:`sessions`),i()},{states:v,launch:y}=Ov(c,t??`__workspace_placeholder__`,(e,t)=>{l(t=>({...t,[e.id]:e})),s(e.id),_()}),b=[{kind:`actions`,id:`agent-actions`,items:[{id:`create`,label:u(`action.create_session`),icon:(0,Y.jsx)(Q,{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:jS(e),description:u(`mobile.agent.switch_to_agent`,{name:jS(e)}),meta:e.providerId.toUpperCase(),trailingAction:{id:`${e.id}-close`,ariaLabel:u(`mobile.agent.close_current_session`),icon:(0,Y.jsx)(ea,{size:16}),tone:`danger`,onAction:async()=>{await a(e.id),_()}}})):[]}],x=[{kind:`options`,id:`providers`,items:g.map(e=>{let t=v[e.id],n=t.loading||t.installJob?.status===`queued`||t.installJob?.status===`running`;return{id:e.id,label:e.title,description:u(`mobile.agent.start_session`,{provider:e.title}),meta:u(n?`mobile.agent.starting`:`mobile.agent.start_new_session`),icon:e.icon,disabled:!h||n}})}];return(0,Y.jsx)(sh,{className:`mobile-select-sheet--command`,title:u(f===`sessions`?`mobile.agent.title`:`session.provider_select`),sections:f===`sessions`?b:x,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:_,onSelect:e=>{if(f===`sessions`){t&&d({workspaceId:t,sessionId:e}),o(e),_();return}return y(e)}})}function NS({activeItem:e,onSelectItem:t}){let n=X();return(0,Y.jsxs)(`nav`,{className:`mobile-dock`,"aria-label":n(`mobile.dock.aria_label`),children:[(0,Y.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,Y.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`mobile.dock.agent`,size:18})}),(0,Y.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.agent`)})]}),(0,Y.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,Y.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`mobile.dock.files`,size:18})}),(0,Y.jsx)(`span`,{className:`mobile-dock__label`,children:n(`file.title`)})]}),(0,Y.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,Y.jsx)(`span`,{className:`mobile-dock__icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Q,{semantic:`mobile.dock.terminal`,size:18})}),(0,Y.jsx)(`span`,{className:`mobile-dock__label`,children:n(`label.terminal`)})]})]})}function PS({workspaceId:e,route:t,activeTab:n,createRequest:r=null,onCreateRequestConsumed:i,collapseVersion:a=0,onCreateFile:o,onCreateFolder:s,onCollapseAll:c,onRouteChange:l,onTabChange:u,onCloseSheet:d,editorState:f}){let p=X(),{closePreview:m}=ex(e);return t.kind===`editor`?(0,Y.jsx)(`div`,{className:`mobile-files-sheet`,children:(0,Y.jsx)(`div`,{className:`mobile-files-sheet__detail`,children:(0,Y.jsx)(Eb,{chrome:`content-only`,editorState:f})})}):t.kind===`diff`?(0,Y.jsx)(`div`,{className:`mobile-files-sheet`,children:(0,Y.jsx)(`div`,{className:`mobile-files-sheet__detail`,children:(0,Y.jsx)(Ax,{workspaceId:e,onClose:()=>{m(),d?.()},showCloseButton:!1})})}):(0,Y.jsxs)(`div`,{className:`mobile-files-sheet mobile-files-sheet--root`,children:[(0,Y.jsxs)(`div`,{className:`mobile-files-sheet__segmented`,children:[(0,Y.jsx)(Zm,{"aria-label":p(`mobile.files.tabs`),onValueChange:e=>u?.(e),value:n,children:(0,Y.jsxs)(Qm,{className:`mobile-files-sheet__tabs`,children:[(0,Y.jsx)($m,{className:`mobile-files-sheet__segment`,value:`files`,children:(0,Y.jsx)(`span`,{children:p(`file.title`)})}),(0,Y.jsx)($m,{className:`mobile-files-sheet__segment`,value:`git`,children:(0,Y.jsx)(`span`,{children:p(`label.git`)})})]})}),n===`files`?(0,Y.jsxs)(`div`,{className:`mobile-files-sheet__tab-actions`,children:[(0,Y.jsx)($,{content:p(`file.new_file`),children:(0,Y.jsx)(Z,{className:`mobile-files-sheet__tab-action`,"aria-label":p(`file.new_file`),icon:(0,Y.jsx)(Q,{semantic:`file.action.new`,size:14}),onClick:o,size:`sm`})}),(0,Y.jsx)($,{content:p(`file.new_folder`),children:(0,Y.jsx)(Z,{className:`mobile-files-sheet__tab-action`,"aria-label":p(`file.new_folder`),icon:(0,Y.jsx)(Q,{semantic:`file.action.newFolder`,size:14}),onClick:s,size:`sm`})}),(0,Y.jsx)($,{content:p(`file.collapse_all`),children:(0,Y.jsx)(Z,{className:`mobile-files-sheet__tab-action`,"aria-label":p(`file.collapse_all`),icon:(0,Y.jsx)(di,{size:14}),onClick:c,size:`sm`})})]}):null]}),(0,Y.jsx)(`div`,{className:`mobile-files-sheet__content`,children:n===`files`?(0,Y.jsx)(xx,{workspaceId:e,createRequest:r,onCreateRequestConsumed:i,onSelectFile:e=>l?.({kind:`editor`,path:e}),collapseVersion:a,variant:`mobile`}):(0,Y.jsx)(qx,{workspaceId:e,onPreviewOpen:e=>{l?.({kind:`diff`,path:e.path})},variant:`mobile`})})]})}function FS({activeWorkspace:e,drawerOpen:t,fullscreenController:n,onOpenSettings:r,onToggleDrawer:i}){let a=X(),o=Xh(e)||a(`mobile.workspace_drawer.select_title`);return(0,Y.jsxs)(`header`,{className:`mobile-topbar`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`mobile-topbar__workspace-button`,onClick:()=>{i()},"aria-label":a(`mobile.topbar.switch_workspace`),"aria-expanded":t,children:[(0,Y.jsx)(`span`,{className:`mobile-topbar__workspace-leading`,"aria-hidden":`true`,children:(0,Y.jsx)(ji,{size:18})}),(0,Y.jsx)(`span`,{className:`mobile-topbar__workspace-name`,children:o})]}),(0,Y.jsxs)(`div`,{className:`mobile-topbar__actions`,children:[(0,Y.jsx)(Z,{"aria-label":a(`mobile.topbar.open_settings`),className:`mobile-topbar__icon-button`,icon:(0,Y.jsx)(Q,{semantic:`nav.settings`,size:18}),onClick:r}),(0,Y.jsx)(Lb,{controller:n,className:`mobile-topbar__icon-button`,iconSize:18,dataTestId:`mobile-fullscreen-toggle`})]})]})}function IS({activeWorkspaceId:e,isOpen:t,workspaces:n,onClose:r,onOpenWorkspaceLauncher:i}){let a=qt(),o=U(qf),s=X(),c=Vb(),l=rg();return t?(0,Y.jsxs)(`div`,{className:`mobile-drawer-layer`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mobile-drawer-layer__backdrop`,"aria-label":s(`mobile.workspace_drawer.close`),onClick:r}),(0,Y.jsxs)(`aside`,{className:`mobile-workspace-drawer`,"aria-label":s(`mobile.workspace_drawer.aria_label`),children:[(0,Y.jsxs)(`div`,{className:`mobile-workspace-drawer__header`,children:[(0,Y.jsxs)(`div`,{className:`mobile-workspace-drawer__header-copy`,children:[(0,Y.jsx)(`div`,{className:`mobile-workspace-drawer__kicker`,children:s(`label.workspace`)}),(0,Y.jsx)(`h2`,{className:`mobile-workspace-drawer__title`,children:s(`mobile.workspace_drawer.select_title`)})]}),(0,Y.jsx)(Z,{"aria-label":s(`action.close`),className:`mobile-workspace-drawer__dismiss`,icon:(0,Y.jsx)(ea,{size:16}),onClick:r,size:`lg`})]}),(0,Y.jsx)(`div`,{className:`mobile-workspace-drawer__list`,children:n.map(t=>{let n=Xh(t)||t.id,i=t.id===e;return(0,Y.jsxs)(`div`,{className:`mobile-workspace-drawer__item ${i?`mobile-workspace-drawer__item--active`:``}`,children:[(0,Y.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,Y.jsxs)(`span`,{className:`mobile-workspace-drawer__item-name-row`,children:[(0,Y.jsx)(`span`,{className:`mobile-workspace-drawer__item-name`,children:n}),i?(0,Y.jsxs)(`span`,{className:`mobile-workspace-drawer__item-state`,children:[(0,Y.jsx)(oi,{size:12}),(0,Y.jsx)(`span`,{children:s(`worktree.current`)})]}):null]}),(0,Y.jsx)(`span`,{className:`mobile-workspace-drawer__item-path`,children:t.path})]}),(0,Y.jsx)(Z,{"aria-label":s(`mobile.workspace_drawer.close_workspace`,{name:n}),className:`mobile-workspace-drawer__item-close`,icon:(0,Y.jsx)(ea,{size:16}),onClick:()=>{c(t.id,{navigateHomeWhenEmpty:!0}).then(e=>{e&&r()})},size:`lg`})]},t.id)})}),(0,Y.jsx)(`div`,{className:`mobile-workspace-drawer__footer`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`mobile-workspace-drawer__footer-button`,onClick:()=>{i(),r()},children:[(0,Y.jsx)(Q,{semantic:`nav.newWorkspace`,size:14}),(0,Y.jsx)(`span`,{children:s(`tooltip.new_workspace`)})]})})]})]}):null}function LS(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 RS(){let e=(0,V.useRef)(null),t=(0,V.useRef)(null),n=(0,V.useRef)(null),r=sx(e),i=X(),a=qt(),o=H(wa),s=H(Ta),c=U(Ea),{activeSession:l,activeWorkspaceId:u,closeMobileSession:d,closeMobileSheet:f,handleMobileSessionCreated:p,handleOpenBranchSwitcher:m,gitState:h,mobileActiveSessionId:g,mobileAgentSessions:_,mobileFilesRoute:v,mobileSheet:y,openMobileSheet:b,orderedSessions:x,restoreMobileSession:S,selectMobileSession:C,updateMobileFilesRoute:w,workspace:T,workspaces:E}=fx(),{persistUiState:D}=U_(u??`__workspace_empty__`),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),[M,N]=(0,V.useState)(`files`),[P,F]=(0,V.useState)(null),[ee,I]=(0,V.useState)(0),[te,L]=(0,V.useState)(!1),[R,z]=(0,V.useState)(null),ne=AS(),re=ES(),ie=kS(),B=bb(),ae=T?.uiState?.activeSessionId??null,oe=s?.workspaceId===T?.id?s.sessionId??null:null;(0,V.useEffect)(()=>{if(!T||t.current===T.id||_.length===0&&x.length===0)return;let e=LS(x.map(e=>e.id),x,_,oe,ae);if(!e.sessionId){t.current=T.id;return}if(t.current=T.id,e.missingFromLayout){S(e.sessionId);return}e.sessionId!==g&&S(e.sessionId)},[g,_,x,oe,ae,S,T]),(0,V.useEffect)(()=>{if(!T){t.current=null,n.current=null;return}g&&n.current!==g&&(n.current=g,T.uiState.activeSessionId!==g&&D({activeSessionId:g}))},[g,D,T]),(0,V.useEffect)(()=>{o&&o!==g&&x.some(e=>e.id===o)&&C(o)},[g,x,o,C]),(0,V.useEffect)(()=>(c(g),()=>{c(null)}),[g,c]);let se=v.kind===`editor`?i(`file.title`):v.kind===`diff`?i(`label.git`):null,ce=e=>{F(t=>({id:(t?.id??0)+1,mode:e,baseDir:null}))},le=v.kind===`editor`?(0,Y.jsx)(wb,{state:B,variant:`mobile`}):null,ue=y===`files`?{title:v.kind===`editor`?v.path.split(`/`).pop()??i(`mobile.files.editor_fallback`):v.kind===`diff`?v.path.split(`/`).pop()??i(`worktree.diff_tab`):i(M===`files`?`file.title`:`label.git`),body:u?(0,Y.jsx)(PS,{workspaceId:u,route:v,activeTab:M,createRequest:P,onCreateRequestConsumed:()=>F(null),collapseVersion:ee,onCreateFile:()=>ce(`file`),onCreateFolder:()=>ce(`folder`),onCollapseAll:()=>I(e=>e+1),onRouteChange:w,onTabChange:N,onCloseSheet:f,editorState:B}):null,footer:u?(0,Y.jsx)(lS,{workspaceId:u,gitState:h,onOpenBranchSwitcher:m,flush:!0}):null,kicker:se,onBack:v.kind===`root`?void 0:()=>w({kind:`root`}),backLabel:i(`action.back`),headerAction:le,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--files`}:y===`terminal`?{title:i(`label.terminal`),body:(0,Y.jsx)(`div`,{className:`mobile-terminal-sheet mobile-terminal-sheet--fullscreen`,children:(0,Y.jsx)(Ib,{chrome:`mobile-fullscreen`,onMobileHeaderActionsChange:z})}),footer:u?(0,Y.jsx)(lS,{workspaceId:u,gitState:h,onOpenBranchSwitcher:m,flush:!0}):null,kicker:null,headerAction:R,fullscreen:!0,bodyClassName:`mobile-sheet__body--flush mobile-sheet__body--fullscreen`,contentClassName:`mobile-sheet--terminal`}:null,de=e=>{if(e===`agent`){j(e=>!e);return}j(!1),b(e)},fe=A?`agent`:y===`files`||y===`terminal`?y:null;return(0,Y.jsxs)(`div`,{ref:e,className:`mobile-shell mobile-shell--${re} mobile-shell--motion-${ie}`,"data-testid":`mobile-shell`,"data-layout-mode":re,"data-motion-mode":ie,children:[(0,Y.jsx)(FS,{activeWorkspace:T,drawerOpen:O,fullscreenController:r,onOpenSettings:()=>{j(!1),a(`/settings`)},onToggleDrawer:()=>{j(!1),k(e=>!e)}}),(0,Y.jsx)(`main`,{className:`mobile-shell__viewport`,children:(0,Y.jsx)(`div`,{className:`mobile-shell__content`,children:x.length>0?(0,Y.jsx)(Y.Fragment,{children:l?(0,Y.jsx)(`section`,{className:`mobile-shell__agent-stage`,children:(0,Y.jsx)(ab,{sessionId:l.id,showHeaderActions:!1,showSupervisorInline:!1,headerAccessory:(0,Y.jsx)(xS,{sessionId:l.id,onOpen:()=>{j(!1),b(`supervisor`)}})})}):null}):(0,Y.jsx)(`section`,{className:`mobile-shell__agent-empty`,"data-testid":`mobile-agent-empty`,children:(0,Y.jsx)(`div`,{className:`mobile-shell__empty-content mobile-shell__empty-content--flat`,children:(0,Y.jsxs)(`div`,{className:`mobile-shell__empty-state`,children:[(0,Y.jsx)(`div`,{className:`mobile-shell__empty-heading`,children:(0,Y.jsx)(`p`,{className:`mobile-shell__empty-title`,children:i(`mobile.empty.start_session`)})}),(0,Y.jsx)(`div`,{className:`mobile-shell__placeholder-copy`,children:(0,Y.jsx)(`p`,{children:i(`mobile.empty.files_terminal_hint`)})}),(0,Y.jsx)(`div`,{className:`mobile-shell__empty-action-row`,children:(0,Y.jsx)(`button`,{type:`button`,className:`mobile-shell__empty-cta`,onClick:()=>j(!0),children:i(`action.create_session`)})})]})})})})}),(0,Y.jsxs)(`div`,{className:`mobile-shell__bottom-stack`,"data-testid":`mobile-bottom-stack`,style:{"--mobile-keyboard-inset":`${ne}px`},children:[(0,Y.jsx)(`div`,{className:`mobile-dock-shell`,children:(0,Y.jsx)(NS,{activeItem:fe,onSelectItem:de})}),u?(0,Y.jsx)(lS,{workspaceId:u,gitState:h,onOpenBranchSwitcher:m}):null]}),A?(0,Y.jsx)(MS,{activeSessionId:g,activeWorkspaceId:u,defaultMode:_.length===0?`create`:`list`,sessions:_,onClose:()=>j(!1),onCloseSession:d,onSelectSession:C,onSessionCreated:p}):null,y===`supervisor`&&l?(0,Y.jsx)(SS,{sessionId:l.id,workspaceId:l.workspaceId,onClose:()=>{j(!1),f()}}):null,ue?(0,Y.jsx)(Op,{title:ue.title,body:ue.body,onClose:()=>{j(!1),f()},kicker:ue.kicker??void 0,onBack:ue.onBack,backLabel:ue.backLabel,headerAction:`headerAction`in ue?ue.headerAction:void 0,bodyClassName:ue.bodyClassName,contentClassName:ue.contentClassName,footer:`footer`in ue?ue.footer:void 0,fullscreen:ue.fullscreen}):null,(0,Y.jsx)(IS,{activeWorkspaceId:u,isOpen:O,workspaces:E,onClose:()=>k(!1),onOpenWorkspaceLauncher:()=>{j(!1),L(!0)}}),te?(0,Y.jsx)(Ag,{onClose:()=>L(!1)}):null]})}var zS={minHeight:`auto`,padding:0,gap:`var(--sp-3)`,alignItems:`stretch`,justifyContent:`flex-start`,textAlign:`left`};function BS(){gS();let e=H(Uf),t=Wt(),n=e===null,r=t.pathname.startsWith(`/settings`)||t.pathname===`/session-gate`;return(0,Y.jsxs)(`div`,{className:`app`,children:[(0,Y.jsx)(vS,{}),(0,Y.jsx)(`main`,{className:`main-content`,children:n&&!r?(0,Y.jsx)(`div`,{className:`app-loading-shell`,children:(0,Y.jsx)(`div`,{className:`app-loading-card`,children:(0,Y.jsx)(Pm,{style:zS,title:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`app-loading-kicker`,children:`CODER STUDIO`}),(0,Y.jsx)(`h1`,{className:`app-loading-title`,children:`正在连接工作区...`})]}),description:(0,Y.jsx)(`p`,{className:`app-loading-desc`,children:`正在同步认证与连接状态,随后会自动进入当前 workspace。`})})})}):(0,Y.jsxs)(xn,{children:[(0,Y.jsx)(yn,{path:`/`,element:(0,Y.jsx)(V_,{})}),(0,Y.jsx)(yn,{path:`/login`,element:(0,Y.jsx)(Gh,{})}),(0,Y.jsx)(yn,{path:`/session-gate`,element:(0,Y.jsx)(qh,{})}),(0,Y.jsx)(yn,{path:`/workspace`,element:(0,Y.jsx)(hS,{children:(0,Y.jsx)(RS,{})})}),(0,Y.jsx)(yn,{path:`/settings`,element:(0,Y.jsx)(N_,{})}),(0,Y.jsx)(yn,{path:`*`,element:(0,Y.jsx)(Ig,{})})]})}),(0,Y.jsx)(Ng,{}),(0,Y.jsx)(aS,{}),(0,Y.jsx)(Ug,{})]})}function VS(){return Pr()===`mobile`?(0,Y.jsx)(BS,{}):(0,Y.jsx)(bS,{})}function HS(){return(0,Y.jsx)(cr,{children:(0,Y.jsx)(VS,{})})}var US=1e3;function WS(){let e=H(If),t=H(Lf),n=H(Lr),[r,i]=xe(Rr),[a,o]=xe(zr),s=U(Br),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useCallback)(async()=>{if(!e)return!1;if(t!==`connected`)try{await e.connect()}catch{return s(null),i(e=>e===`gated`?e:`idle`),!1}if(c.current)return c.current;i(`claiming`);let r=e.sendCommand(`activation.claim`,{clientInstanceId:n}).then(e=>(o(e.generation),s(null),i(`active`),!0)).catch(()=>(s(null),i(e=>e===`gated`?e:`idle`),!1)).finally(()=>{c.current=null});return c.current=r,r},[n,t,o,s,i,e]);return(0,V.useEffect)(()=>{if(l.current!==null&&(clearTimeout(l.current),l.current=null),!(!e||t!==`connected`||r!==`idle`))return l.current=setTimeout(()=>{l.current=null,c.current||u()},US),()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}},[u,t,r,e]),(0,V.useEffect)(()=>()=>{l.current!==null&&(clearTimeout(l.current),l.current=null),!(!e||a===null)&&e.sendCommand(`activation.release`,{clientInstanceId:n,generation:a}).catch(()=>{})},[n,a,e]),{status:r,generation:a,claim:u}}var GS=null,KS=null,qS={refreshGit:!1,refreshBranches:!1,refreshWorktrees:!1,markTreeStale:!1,refreshEditorBuffers:!1},JS=250,YS=`ui.themeId`,XS=`ui.theme`;function ZS(e){return e===`fs_change`}function QS(){let e=localStorage.getItem(YS);if(e!==null)try{return JSON.parse(e)}catch{return}let t=localStorage.getItem(XS);if(t!==null)try{return JSON.parse(t)}catch{return}}function $S(e){let t=ma(ha(e));return document.documentElement.setAttribute(`data-theme`,t.documentThemeAttr),t.id}function eC(e,t){return{refreshGit:e.refreshGit||!!t.refreshGit,refreshBranches:e.refreshBranches||!!t.refreshBranches,refreshWorktrees:e.refreshWorktrees||!!t.refreshWorktrees,markTreeStale:e.markTreeStale||!!t.markTreeStale,refreshEditorBuffers:e.refreshEditorBuffers||!!t.refreshEditorBuffers}}function tC(e){let t=e.get(Yf),n=Object.values(e.get(rp)).map(e=>e.terminalId).filter(e=>!!e);e.set(Jf,{}),e.set(Yf,[]),e.set(Xf,`idle`),e.set(Zf,null),e.set(rp,{}),e.set(qf,null),e.set(jv,new Map),e.set(Mv,new Map);for(let n of t)e.set(ag(n),null),e.set(sg(n),new Set),e.set(dg(n),null),e.set(mg(n),{current:``,branches:[],loading:!1}),e.set(_g(n),{items:[],loading:!1}),e.set(og(n),!1),e.set(ug(n),0);for(let t of n)e.set(Qv(t),null)}function nC(e,t){let n=e.match(/^workspace\.([^.]+)\.(fs\.dirty|git\.state)$/);if(!n)return null;let r=n[1];if(n[2]===`fs.dirty`){let e=t??{};return{workspaceId:r,hint:{refreshGit:!0,refreshBranches:e.reason===`git_metadata`,refreshWorktrees:e.reason===`git_metadata`,markTreeStale:ZS(e.reason),refreshEditorBuffers:e.reason===`fs_change`||e.reason===`file_content`}}}let i=t??{};return{workspaceId:r,hint:{refreshGit:!0,refreshBranches:!!i.branchChanged,refreshWorktrees:!!i.worktreeChanged,markTreeStale:!!i.treeChanged,refreshEditorBuffers:!!i.treeChanged}}}function rC({children:e}){let[,t]=xe(If),[n,r]=xe(ba),i=H(Uf),a=H(Sa),o=H(Lf),s=H(qf),c=U(Lf),l=U(Rf),u=U(Hf),d=U(Uf),f=U(Vf),p=U(Bf),m=U(zf),h=U(Jf),g=U(rp),_=U(jv),v=U(Mv),y=U(n_),b=me(),x=H(Wf),{claim:S}=WS();Qg();let C=(0,V.useRef)(null),w=(0,V.useRef)(x),T=(0,V.useRef)(new Map),E=(0,V.useRef)(new Map),D=(0,V.useRef)(s),O=(0,V.useRef)(o),k=(0,V.useRef)(null),A=(0,V.useRef)({mode:`inactive`,workspaceId:null}),j=(0,V.useRef)({theme:0}),M=(0,V.useRef)(!1);return(0,V.useEffect)(()=>{w.current=x},[x]),(0,V.useEffect)(()=>{if(o!==`connected`)return;let e=!1,t=!1,n=b.sub(n_,()=>{t=!0});return(async()=>{let n=await x(`settings.get`,{});e||!n.ok||!n.data||t||y({copyOnSelect:t_(n.data)})})(),()=>{e=!0,n()}},[o,x,y,b]),(0,V.useEffect)(()=>{D.current=s},[s]),(0,V.useEffect)(()=>{O.current=o},[o]),(0,V.useEffect)(()=>{o===`connected`&&b.get(Rr)!==`gated`&&S()},[S,o,b]),(0,V.useEffect)(()=>{M.current=localStorage.getItem(YS)!==null;let e=$S(QS());r(e),localStorage.setItem(YS,JSON.stringify(e))},[r]),(0,V.useEffect)(()=>{let e=ma(n);document.documentElement.setAttribute(`data-theme`,e.documentThemeAttr),localStorage.setItem(YS,JSON.stringify(e.id))},[n]),(0,V.useEffect)(()=>{if(o!==`connected`)return;let e=!1;return(async()=>{let t={...j.current},n=await x(`settings.get`,{});if(e||!n.ok||!n.data||j.current.theme!==t.theme)return;if(M.current){M.current=!1;return}let i=n.data;r(ha(i[`appearance.themeId`]??i[`appearance.theme`]??QS()))})(),()=>{e=!0}},[o,x,r]),(0,V.useEffect)(()=>{let e=b.sub(ba,()=>{j.current.theme+=1});return()=>{e()}},[b]),(0,V.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`/auth/status`)).json();d(!!e.authEnabled),b.set(Sa,!!e.authenticated||e.authEnabled===!1)}catch{b.set(Sa,!1)}})()},[d,b]),(0,V.useEffect)(()=>{if(i===null)return;if(i===!0&&!a){KS&&=(clearTimeout(KS),null),GS&&=(GS.disconnect(`auth_required`),null),C.current=null,t(null),c(`connecting`),l(null),u(null),f(0),p(null),m(!1);return}let e=e=>{c(e),e===`reconnecting`&&(f(e=>e+1),p(e=>e??Date.now())),(e===`disconnected`||e===`rejected`)&&m(!1),e===`connected`&&(f(0),p(null),s(!0))},n=e=>{w.current(`git.status`,{workspaceId:e}).then(t=>{t.ok&&t.data&&b.set(dg(e),t.data)}).catch(e=>{console.error(`[Git Status] git.status command threw error:`,e)})},r=()=>{if(A.current.mode===`inactive`)return;let e=C.current;e&&(A.current={mode:`inactive`,workspaceId:null},e.sendCommand(`workspace.deactivate`,{}).catch(()=>{}))},o=e=>{let t=A.current;if(t.mode===`active`&&t.workspaceId===e)return;let n=C.current;n&&(A.current={mode:`active`,workspaceId:e},n.sendCommand(`workspace.activate`,{workspaceId:e}).catch(()=>{}))},s=(e=!1)=>{if(document.visibilityState===`hidden`){r();return}let t=D.current;if(!t){r();return}e&&(A.current={mode:`inactive`,workspaceId:null}),o(t)},d=()=>{if(b.get(Rr)===`gated`)return;if(s(),document.visibilityState!==`visible`){k.current=null;return}let e=Date.now(),t=k.current;t!==null&&e-t<JS||(k.current=e,C.current?.recoverConnection(`visibility_resume`))},h=()=>{if(document.visibilityState===`hidden`){k.current=null,s();return}d()},g=()=>{d()},_=()=>{d()},v=()=>{b.get(Rr)!==`gated`&&C.current?.recoverConnection(`network_online`)},y=e=>{w.current(`git.branches`,{workspaceId:e}).then(t=>{if(t.ok&&t.data){b.set(mg(e),{current:t.data.current,branches:t.data.branches,loading:!1});return}b.set(mg(e),e=>({...e,loading:!1,error:t.error?.message??e.error}))}).catch(e=>{console.error(`[Git Branches] git.branches command threw error:`,e)})},x=e=>{b.set(_g(e),e=>({...e,loading:!0,error:void 0})),w.current(`worktree.list`,{workspaceId:e}).then(t=>{if(t.ok&&t.data&&Array.isArray(t.data.worktrees)){b.set(_g(e),{items:t.data.worktrees,loading:!1,lastLoadedAt:Date.now()});return}b.set(_g(e),e=>({...e,loading:!1,error:t.error?.message??e.error}))}).catch(t=>{console.error(`[Worktree List] worktree.list command threw error:`,t),b.set(_g(e),e=>({...e,loading:!1,error:t instanceof Error?t.message:String(t)}))})},S=(e,t)=>{let r=eC(E.current.get(e)??qS,t);if(E.current.set(e,r),T.current.get(e))return;let i=setTimeout(()=>{T.current.delete(e);let t=E.current.get(e)??qS;E.current.delete(e),t.markTreeStale&&b.set(og(e),!0),t.refreshEditorBuffers&&b.set(ug(e),e=>e+1),t.refreshGit&&n(e),t.refreshBranches&&y(e),t.refreshWorktrees&&x(e)},60);T.current.set(e,i)},O=(e,t,n)=>{if(e===`activation.revoked`){let e=t??{};b.set(Rr,`gated`),b.set(Br,typeof e.reason==`string`&&e.reason.length>0?e.reason:`displaced`),b.set(zr,typeof e.generation==`number`?e.generation:null),tC(b),A.current={mode:`inactive`,workspaceId:null},C.current?.disconnect(`single_active_displaced`);return}let r=nC(e,t);r&&S(r.workspaceId,r.hint);try{aC(e,t,b)}catch(t){console.error(`Error handling event for topic ${e}:`,t)}},j=[`connection.*`,`activation.*`,`workspace.*`];if(KS&&=(clearTimeout(KS),null),GS){C.current=GS,t(GS);let n=GS.getStatus();c(n);let r=GS.onStatus(e),i=GS.subscribe(j,O);return(n===`disconnected`||n===`reconnecting`)&&GS.recoverConnection(`manual_retry`),s(),document.addEventListener(`visibilitychange`,h),window.addEventListener(`focus`,g),window.addEventListener(`pageshow`,_),window.addEventListener(`online`,v),()=>{document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`focus`,g),window.removeEventListener(`pageshow`,_),window.removeEventListener(`online`,v),r(),i(),T.current.forEach(e=>clearTimeout(e)),T.current.clear(),E.current.clear(),C.current=null,GS&&(KS=setTimeout(()=>{GS&&=(GS.disconnect(`app_unmount`),null),KS=null},50))}}let M=new Pf(Ff());GS=M,C.current=M,t(M);let N=M.onStatus(e),P=M.subscribe(j,O);return M.connect().catch(e=>{console.error(`Failed to connect WebSocket:`,e),l(e.message||`Connection failed`)}),s(),document.addEventListener(`visibilitychange`,h),window.addEventListener(`focus`,g),window.addEventListener(`pageshow`,_),window.addEventListener(`online`,v),()=>{document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`focus`,g),window.removeEventListener(`pageshow`,_),window.removeEventListener(`online`,v),N(),P(),T.current.forEach(e=>clearTimeout(e)),T.current.clear(),E.current.clear(),C.current=null,KS=setTimeout(()=>{GS&&=(GS.disconnect(`app_unmount`),null),KS=null},50)}},[t,c,l,u,d,f,p,m,h,g,_,v,b,i,a]),(0,V.useEffect)(()=>{if(i===null)return;if(i===!0&&!a){A.current={mode:`inactive`,workspaceId:null};return}if(o!==`connected`)return;if(document.visibilityState===`hidden`){if(A.current.mode!==`inactive`){let e=C.current;if(!e)return;A.current={mode:`inactive`,workspaceId:null},e.sendCommand(`workspace.deactivate`,{}).catch(()=>{})}return}if(!s){if(A.current.mode!==`inactive`){let e=C.current;if(!e)return;A.current={mode:`inactive`,workspaceId:null},e.sendCommand(`workspace.deactivate`,{}).catch(()=>{})}return}if(A.current.mode===`active`&&A.current.workspaceId===s)return;let e=C.current;e&&(A.current={mode:`active`,workspaceId:s},e.sendCommand(`workspace.activate`,{workspaceId:s}).catch(()=>{}))},[s,i,a,o]),(0,Y.jsx)(Y.Fragment,{children:e})}function iC(e,t){let n=e;return typeof n.version!=`string`||typeof n.serverInstanceId!=`string`?!1:(t.set(Hf,{version:n.version,serverInstanceId:n.serverInstanceId,authEnabled:typeof n.authEnabled==`boolean`?n.authEnabled:void 0}),typeof n.isWriter==`boolean`&&t.set(zf,n.isWriter),!0)}function aC(e,t,n){if(e===`connection.ready`){iC(t,n),n.set(Rf,null);return}if(e===`connection.status`){let e=t;e.status===`connected`&&iC(t,n),e.status===`connected`&&e.authEnabled===!1&&n.set(Sa,!0),e.status===`error`&&e.message&&n.set(Rf,e.message);return}let r=e.match(/^workspace\.([^.]+)\.(.+)$/);if(r){let e=r[1],i=r[2];if(i===`meta`){let r=t;if(!(n.get(Jf)[e]||r.path))return;n.set(Jf,t=>({...t,[e]:{...t[e],...r,id:e}})),n.set(Yf,t=>t.includes(e)?t:[...t,e]),n.set(Xf,`ready`),n.set(Zf,null);return}if(i===`fs.dirty`){if(ZS((t??{}).reason)){let t=og(e);n.set(t,!0)}return}if(i===`git.state`)return;let a=i.match(/^session\.([^.]+)\.(.+)$/);if(a){let e=a[1],r=a[2];if(r===`lifecycle`){if(t.event===`removed`){let t=n.get(rp)[e];t?.terminalId&&n.set(Qv(t.terminalId),null),n.set(rp,t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}return}if(r===`state`){let e=t;n.set(rp,t=>({...t,[e.id]:e}));return}if(r===`progress`){console.log(`Session ${e} progress:`,t);return}if(r===`supervisor.state`){let e=t;if(e.event===`deleted`&&e.supervisorId)n.set(jv,t=>{let n=new Map(t);for(let[t,r]of n.entries())if(r.id===e.supervisorId){n.delete(t);break}return n}),n.set(Mv,t=>{let n=new Map(t);return n.delete(e.supervisorId),n});else if(e.supervisor){let t=e.supervisor;n.set(jv,e=>{let n=new Map(e);return n.set(t.sessionId,t),n}),Array.isArray(t.cycles)&&n.set(Mv,e=>{let n=new Map(e);return n.set(t.id,t.cycles),n})}return}if(r===`supervisor.cycle`){let e=t,r=e.cycle.supervisorId;n.set(Mv,t=>{let n=new Map(t),i=(n.get(r)??[]).filter(t=>t.id!==e.cycle.id);return n.set(r,[e.cycle,...i].slice(0,20)),n});return}}let o=i.match(/^terminal\.([^.]+)\.(.+)$/);if(o){let r=o[1],i=o[2];if(i===`created`){let i=t,a=Qv(r);n.set(a,{id:i.id,workspaceId:e,kind:i.kind,alive:!0,title:i.title});return}if(i===`output`)return;if(i===`exit`){let e=t,i=Qv(r),a=n.get(i);a&&n.set(i,{...a,exitCode:e.code,alive:!1});return}}}console.log(`Unhandled event topic: ${e}`,t)}kr.createRoot(document.getElementById(`root`)).render((0,Y.jsx)(he,{children:(0,Y.jsx)(rC,{children:(0,Y.jsx)(HS,{})})}));
111
+ //# sourceMappingURL=index-Z64V-v_U.js.map