runcastle 1.0.13 → 1.0.15

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.
@@ -69,7 +69,7 @@ Error generating stack: `+e.message+`
69
69
 
70
70
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Gi,s=!Mi.jitless,c=s&&Ki.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?hs([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function vs(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=>!sa(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=>da(e,r,Ni())))}),t)}var ys=N(`$ZodUnion`,(e,t)=>{Ao.init(e,t),F(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),F(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),F(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),F(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=>Ri(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=>vs(t,r,e,i)):vs(o,r,e,i)}}),bs=N(`$ZodIntersection`,(e,t)=>{Ao.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])=>Ss(e,t,n)):Ss(e,i,a)}});function xs(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qi(e)&&qi(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=xs(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=xs(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 Ss(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}),sa(e))return e;let o=xs(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Cs=N(`$ZodRecord`,(e,t)=>{Ao.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!qi(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=>da(e,r,Ni())),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(...la(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...la(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`&&oo.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=>da(e,r,Ni())),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(...la(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...la(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ws=N(`$ZodEnum`,(e,t)=>{Ao.init(e,t);let n=Pi(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Yi.has(typeof e)).map(e=>typeof e==`string`?Xi(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}}),Ts=N(`$ZodTransform`,(e,t)=>{Ao.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ji(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 Ai;return n.value=i,n.fallback=!0,n}});function Es(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ds=N(`$ZodOptional`,(e,t)=>{Ao.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,F(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),F(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Ri(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=>Es(e,r)):Es(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Os=N(`$ZodExactOptional`,(e,t)=>{Ds.init(e,t),F(e._zod,`values`,()=>t.innerType._zod.values),F(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ks=N(`$ZodNullable`,(e,t)=>{Ao.init(e,t),F(e._zod,`optin`,()=>t.innerType._zod.optin),F(e._zod,`optout`,()=>t.innerType._zod.optout),F(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Ri(e.source)}|null)$`):void 0}),F(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)}),As=N(`$ZodDefault`,(e,t)=>{Ao.init(e,t),e._zod.optin=`optional`,F(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=>js(e,t)):js(r,t)}});function js(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ms=N(`$ZodPrefault`,(e,t)=>{Ao.init(e,t),e._zod.optin=`optional`,F(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))}),Ns=N(`$ZodNonOptional`,(e,t)=>{Ao.init(e,t),F(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=>Ps(t,e)):Ps(i,e)}});function Ps(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 Fs=N(`$ZodCatch`,(e,t)=>{Ao.init(e,t),e._zod.optin=`optional`,F(e._zod,`optout`,()=>t.innerType._zod.optout),F(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=>da(e,n,Ni()))},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=>da(e,n,Ni()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Is=N(`$ZodPipe`,(e,t)=>{Ao.init(e,t),F(e._zod,`values`,()=>t.in._zod.values),F(e._zod,`optin`,()=>t.in._zod.optin),F(e._zod,`optout`,()=>t.out._zod.optout),F(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=>Ls(e,t.in,n)):Ls(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ls(e,t.out,n)):Ls(r,t.out,n)}});function Ls(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 Rs=N(`$ZodPreprocess`,(e,t)=>{Is.init(e,t)}),zs=N(`$ZodReadonly`,(e,t)=>{Ao.init(e,t),F(e._zod,`propValues`,()=>t.innerType._zod.propValues),F(e._zod,`values`,()=>t.innerType._zod.values),F(e._zod,`optin`,()=>t.innerType?._zod?.optin),F(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(Bs):Bs(r)}});function Bs(e){return e.value=Object.freeze(e.value),e}var Vs=N(`$ZodCustom`,(e,t)=>{fo.init(e,t),Ao.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=>Hs(t,n,r,e));Hs(i,n,r,e)}});function Hs(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(pa(e))}}var Us,Ws=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 Gs(){return new Ws}(Us=globalThis).__zod_globalRegistry??(Us.__zod_globalRegistry=Gs());var Ks=globalThis.__zod_globalRegistry;function qs(e,t){return new e({type:`string`,...I(t)})}function Js(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...I(t)})}function Ys(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...I(t)})}function Xs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...I(t)})}function Zs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...I(t)})}function Qs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...I(t)})}function $s(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...I(t)})}function ec(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...I(t)})}function tc(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...I(t)})}function nc(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...I(t)})}function rc(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...I(t)})}function ic(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...I(t)})}function ac(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...I(t)})}function oc(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...I(t)})}function sc(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...I(t)})}function cc(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...I(t)})}function lc(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...I(t)})}function uc(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...I(t)})}function dc(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...I(t)})}function fc(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...I(t)})}function pc(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...I(t)})}function mc(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...I(t)})}function hc(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...I(t)})}function gc(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...I(t)})}function _c(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...I(t)})}function vc(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...I(t)})}function yc(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...I(t)})}function bc(e,t){return new e({type:`number`,checks:[],...I(t)})}function xc(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...I(t)})}function Sc(e,t){return new e({type:`boolean`,...I(t)})}function Cc(e,t){return new e({type:`null`,...I(t)})}function wc(e){return new e({type:`unknown`})}function Tc(e,t){return new e({type:`never`,...I(t)})}function Ec(e,t){return new mo({check:`less_than`,...I(t),value:e,inclusive:!1})}function Dc(e,t){return new mo({check:`less_than`,...I(t),value:e,inclusive:!0})}function Oc(e,t){return new ho({check:`greater_than`,...I(t),value:e,inclusive:!1})}function kc(e,t){return new ho({check:`greater_than`,...I(t),value:e,inclusive:!0})}function Ac(e,t){return new go({check:`multiple_of`,...I(t),value:e})}function jc(e,t){return new _o({check:`max_length`,...I(t),maximum:e})}function Mc(e,t){return new vo({check:`min_length`,...I(t),minimum:e})}function Nc(e,t){return new yo({check:`length_equals`,...I(t),length:e})}function Pc(e,t){return new xo({check:`string_format`,format:`regex`,...I(t),pattern:e})}function Fc(e){return new So({check:`string_format`,format:`lowercase`,...I(e)})}function Ic(e){return new Co({check:`string_format`,format:`uppercase`,...I(e)})}function Lc(e,t){return new wo({check:`string_format`,format:`includes`,...I(t),includes:e})}function Rc(e,t){return new To({check:`string_format`,format:`starts_with`,...I(t),prefix:e})}function zc(e,t){return new Eo({check:`string_format`,format:`ends_with`,...I(t),suffix:e})}function Bc(e){return new Do({check:`overwrite`,tx:e})}function Vc(e){return Bc(t=>t.normalize(e))}function Hc(){return Bc(e=>e.trim())}function Uc(){return Bc(e=>e.toLowerCase())}function Wc(){return Bc(e=>e.toUpperCase())}function Gc(){return Bc(e=>Ui(e))}function Kc(e,t,n){return new e({type:`array`,element:t,...I(n)})}function qc(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...I(n)})}function Jc(e,t){let n=Yc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(pa(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(pa(r))}},e(t.value,t)),t);return n}function Yc(e,t){let n=new fo({check:`custom`,...I(t)});return n._zod.check=e,n}function Xc(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??Ks,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 Zc(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,Zc(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`&&el(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 Qc(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>
71
71
 
72
- 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 $c(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:nl(t,`input`,e.processors),output:nl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function el(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 el(r.element,n);if(r.type===`set`)return el(r.valueType,n);if(r.type===`lazy`)return el(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 el(r.innerType,n);if(r.type===`intersection`)return el(r.left,n)||el(r.right,n);if(r.type===`record`||r.type===`map`)return el(r.keyType,n)||el(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:el(r.in,n)||el(r.out,n);if(r.type===`object`){for(let e in r.shape)if(el(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(el(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(el(e,n))return!0;return!!(r.rest&&el(r.rest,n))}return!1}var tl=(e,t={})=>n=>{let r=Xc({...n,processors:t});return Zc(e,r),Qc(r,e),$c(r,e)},nl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Xc({...i??{},target:a,io:t,processors:n});return Zc(e,o),Qc(o,e),$c(o,e)},rl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},il=(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=rl[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}))])}},al=(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)},ol=(e,t,n,r)=>{n.type=`boolean`},sl=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},cl=(e,t,n,r)=>{n.not={}},ll=(e,t,n,r)=>{let i=e._zod.def,a=Pi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ul=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},dl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},fl=(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=Zc(a.element,t,{...r,path:[...r.path,`items`]})},pl=(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]=Zc(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=Zc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ml=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Zc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},hl=(e,t,n,r)=>{let i=e._zod.def,a=Zc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Zc(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]]},gl=(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=Zc(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=Zc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Zc(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)}},_l=(e,t,n,r)=>{let i=e._zod.def,a=Zc(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`}]},vl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},yl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},bl=(e,t,n,r)=>{let i=e._zod.def;Zc(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)))},xl=(e,t,n,r)=>{let i=e._zod.def;Zc(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},Sl=(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;Zc(o,t,r);let s=t.seen.get(e);s.ref=o},Cl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},wl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Tl=N(`ZodISODateTime`,(e,t)=>{Wo.init(e,t),U.init(e,t)});function El(e){return gc(Tl,e)}var Dl=N(`ZodISODate`,(e,t)=>{Go.init(e,t),U.init(e,t)});function Ol(e){return _c(Dl,e)}var kl=N(`ZodISOTime`,(e,t)=>{Ko.init(e,t),U.init(e,t)});function Al(e){return vc(kl,e)}var jl=N(`ZodISODuration`,(e,t)=>{qo.init(e,t),U.init(e,t)});function Ml(e){return yc(jl,e)}var Nl=N(`ZodError`,(e,t)=>{ha.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>va(e,t)},flatten:{value:t=>_a(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Fi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Fi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Pl=ya(Nl),Fl=ba(Nl),Il=xa(Nl),Ll=Ca(Nl),Rl=Ta(Nl),zl=Ea(Nl),Bl=Da(Nl),Vl=Oa(Nl),Hl=ka(Nl),Ul=Aa(Nl),Wl=ja(Nl),Gl=Ma(Nl),Kl=new WeakMap;function R(e,t,n){let r=Object.getPrototypeOf(e),i=Kl.get(r);if(i||(i=new Set,Kl.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 z=N(`ZodType`,(e,t)=>(Ao.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:nl(e,`input`),output:nl(e,`output`)}}),e.toJSONSchema=tl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Pl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Il(e,t,n),e.parseAsync=async(t,n)=>Fl(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ll(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Rl(e,t,n),e.decode=(t,n)=>zl(e,t,n),e.encodeAsync=async(t,n)=>Bl(e,t,n),e.decodeAsync=async(t,n)=>Vl(e,t,n),e.safeEncode=(t,n)=>Hl(e,t,n),e.safeDecode=(t,n)=>Ul(e,t,n),e.safeEncodeAsync=async(t,n)=>Wl(e,t,n),e.safeDecodeAsync=async(t,n)=>Gl(e,t,n),R(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Vi(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 Zi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(id(e,t))},superRefine(e,t){return this.check(ad(e,t))},overwrite(e){return this.check(Bc(e))},optional(){return zu(this)},exactOptional(){return Vu(this)},nullable(){return Uu(this)},nullish(){return zu(Uu(this))},nonoptional(e){return Yu(this,e)},array(){return Tu(this)},or(e){return ku([this,e])},and(e){return ju(this,e)},transform(e){return $u(this,Lu(e))},default(e){return Gu(this,e)},prefault(e){return qu(this,e)},catch(e){return Zu(this,e)},pipe(e){return $u(this,e)},readonly(){return nd(this)},describe(e){let t=this.clone();return Ks.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ks.get(this);let t=this.clone();return Ks.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 Ks.get(e)?.description},configurable:!0}),e)),B=N(`_ZodString`,(e,t)=>{jo.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,R(e,`_ZodString`,{regex(...e){return this.check(Pc(...e))},includes(...e){return this.check(Lc(...e))},startsWith(...e){return this.check(Rc(...e))},endsWith(...e){return this.check(zc(...e))},min(...e){return this.check(Mc(...e))},max(...e){return this.check(jc(...e))},length(...e){return this.check(Nc(...e))},nonempty(...e){return this.check(Mc(1,...e))},lowercase(e){return this.check(Fc(e))},uppercase(e){return this.check(Ic(e))},trim(){return this.check(Hc())},normalize(...e){return this.check(Vc(...e))},toLowerCase(){return this.check(Uc())},toUpperCase(){return this.check(Wc())},slugify(){return this.check(Gc())}})}),V=N(`ZodString`,(e,t)=>{jo.init(e,t),B.init(e,t),e.email=t=>e.check(Js(ql,t)),e.url=t=>e.check(ec(Xl,t)),e.jwt=t=>e.check(hc(du,t)),e.emoji=t=>e.check(tc(Zl,t)),e.guid=t=>e.check(Ys(Jl,t)),e.uuid=t=>e.check(Xs(Yl,t)),e.uuidv4=t=>e.check(Zs(Yl,t)),e.uuidv6=t=>e.check(Qs(Yl,t)),e.uuidv7=t=>e.check($s(Yl,t)),e.nanoid=t=>e.check(nc(Ql,t)),e.guid=t=>e.check(Ys(Jl,t)),e.cuid=t=>e.check(rc($l,t)),e.cuid2=t=>e.check(ic(eu,t)),e.ulid=t=>e.check(ac(tu,t)),e.base64=t=>e.check(fc(cu,t)),e.base64url=t=>e.check(pc(lu,t)),e.xid=t=>e.check(oc(nu,t)),e.ksuid=t=>e.check(sc(ru,t)),e.ipv4=t=>e.check(cc(iu,t)),e.ipv6=t=>e.check(lc(au,t)),e.cidrv4=t=>e.check(uc(ou,t)),e.cidrv6=t=>e.check(dc(su,t)),e.e164=t=>e.check(mc(uu,t)),e.datetime=t=>e.check(El(t)),e.date=t=>e.check(Ol(t)),e.time=t=>e.check(Al(t)),e.duration=t=>e.check(Ml(t))});function H(e){return qs(V,e)}var U=N(`ZodStringFormat`,(e,t)=>{Mo.init(e,t),B.init(e,t)}),ql=N(`ZodEmail`,(e,t)=>{Fo.init(e,t),U.init(e,t)}),Jl=N(`ZodGUID`,(e,t)=>{No.init(e,t),U.init(e,t)}),Yl=N(`ZodUUID`,(e,t)=>{Po.init(e,t),U.init(e,t)}),Xl=N(`ZodURL`,(e,t)=>{Io.init(e,t),U.init(e,t)}),Zl=N(`ZodEmoji`,(e,t)=>{Lo.init(e,t),U.init(e,t)}),Ql=N(`ZodNanoID`,(e,t)=>{Ro.init(e,t),U.init(e,t)}),$l=N(`ZodCUID`,(e,t)=>{zo.init(e,t),U.init(e,t)}),eu=N(`ZodCUID2`,(e,t)=>{Bo.init(e,t),U.init(e,t)}),tu=N(`ZodULID`,(e,t)=>{Vo.init(e,t),U.init(e,t)}),nu=N(`ZodXID`,(e,t)=>{Ho.init(e,t),U.init(e,t)}),ru=N(`ZodKSUID`,(e,t)=>{Uo.init(e,t),U.init(e,t)}),iu=N(`ZodIPv4`,(e,t)=>{Jo.init(e,t),U.init(e,t)}),au=N(`ZodIPv6`,(e,t)=>{Yo.init(e,t),U.init(e,t)}),ou=N(`ZodCIDRv4`,(e,t)=>{Xo.init(e,t),U.init(e,t)}),su=N(`ZodCIDRv6`,(e,t)=>{Zo.init(e,t),U.init(e,t)}),cu=N(`ZodBase64`,(e,t)=>{$o.init(e,t),U.init(e,t)}),lu=N(`ZodBase64URL`,(e,t)=>{ts.init(e,t),U.init(e,t)}),uu=N(`ZodE164`,(e,t)=>{ns.init(e,t),U.init(e,t)}),du=N(`ZodJWT`,(e,t)=>{is.init(e,t),U.init(e,t)}),fu=N(`ZodNumber`,(e,t)=>{as.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),R(e,`ZodNumber`,{gt(e,t){return this.check(Oc(e,t))},gte(e,t){return this.check(kc(e,t))},min(e,t){return this.check(kc(e,t))},lt(e,t){return this.check(Ec(e,t))},lte(e,t){return this.check(Dc(e,t))},max(e,t){return this.check(Dc(e,t))},int(e){return this.check(hu(e))},safe(e){return this.check(hu(e))},positive(e){return this.check(Oc(0,e))},nonnegative(e){return this.check(kc(0,e))},negative(e){return this.check(Ec(0,e))},nonpositive(e){return this.check(Dc(0,e))},multipleOf(e,t){return this.check(Ac(e,t))},step(e,t){return this.check(Ac(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 pu(e){return bc(fu,e)}var mu=N(`ZodNumberFormat`,(e,t)=>{os.init(e,t),fu.init(e,t)});function hu(e){return xc(mu,e)}var gu=N(`ZodBoolean`,(e,t)=>{ss.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r)});function _u(e){return Sc(gu,e)}var vu=N(`ZodNull`,(e,t)=>{cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r)});function yu(e){return Cc(vu,e)}var bu=N(`ZodUnknown`,(e,t)=>{ls.init(e,t),z.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function xu(){return wc(bu)}var Su=N(`ZodNever`,(e,t)=>{us.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r)});function Cu(e){return Tc(Su,e)}var wu=N(`ZodArray`,(e,t)=>{fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.element=t.element,R(e,`ZodArray`,{min(e,t){return this.check(Mc(e,t))},nonempty(e){return this.check(Mc(1,e))},max(e,t){return this.check(jc(e,t))},length(e,t){return this.check(Nc(e,t))},unwrap(){return this.element}})});function Tu(e,t){return Kc(wu,e,t)}var Eu=N(`ZodObject`,(e,t)=>{_s.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),F(e,`shape`,()=>t.shape),R(e,`ZodObject`,{keyof(){return Fu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:xu()})},loose(){return this.clone({...this._zod.def,catchall:xu()})},strict(){return this.clone({...this._zod.def,catchall:Cu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return na(this,e)},safeExtend(e){return ra(this,e)},merge(e){return ia(this,e)},pick(e){return ea(this,e)},omit(e){return ta(this,e)},partial(...e){return aa(Ru,this,e[0])},required(...e){return oa(Ju,this,e[0])}})});function Du(e,t){return new Eu({type:`object`,shape:e??{},...I(t)})}var Ou=N(`ZodUnion`,(e,t)=>{ys.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.options=t.options});function ku(e,t){return new Ou({type:`union`,options:e,...I(t)})}var Au=N(`ZodIntersection`,(e,t)=>{bs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r)});function ju(e,t){return new Au({type:`intersection`,left:e,right:t})}var Mu=N(`ZodRecord`,(e,t)=>{Cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nu(e,t,n){let r=Zi(e);return r._zod.values=void 0,new Mu({type:`record`,keyType:r,valueType:t,...I(n)})}var Pu=N(`ZodEnum`,(e,t)=>{ws.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(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 Pu({...t,checks:[],...I(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 Pu({...t,checks:[],...I(r),entries:i})}});function Fu(e,t){return new Pu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var Iu=N(`ZodTransform`,(e,t)=>{Ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ji(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(pa(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(pa(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 Lu(e){return new Iu({type:`transform`,transform:e})}var Ru=N(`ZodOptional`,(e,t)=>{Ds.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zu(e){return new Ru({type:`optional`,innerType:e})}var Bu=N(`ZodExactOptional`,(e,t)=>{Os.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Bu({type:`optional`,innerType:e})}var Hu=N(`ZodNullable`,(e,t)=>{ks.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_l(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e){return new Hu({type:`nullable`,innerType:e})}var Wu=N(`ZodDefault`,(e,t)=>{As.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gu(e,t){return new Wu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ku=N(`ZodPrefault`,(e,t)=>{Ms.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qu(e,t){return new Ku({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ju=N(`ZodNonOptional`,(e,t)=>{Ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Ju({type:`nonoptional`,innerType:e,...I(t)})}var Xu=N(`ZodCatch`,(e,t)=>{Fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zu(e,t){return new Xu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Qu=N(`ZodPipe`,(e,t)=>{Is.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sl(e,t,n,r),e.in=t.in,e.out=t.out});function $u(e,t){return new Qu({type:`pipe`,in:e,out:t})}var ed=N(`ZodPreprocess`,(e,t)=>{Qu.init(e,t),Rs.init(e,t)}),td=N(`ZodReadonly`,(e,t)=>{zs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nd(e){return new td({type:`readonly`,innerType:e})}var rd=N(`ZodCustom`,(e,t)=>{Vs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r)});function id(e,t={}){return qc(rd,e,t)}function ad(e,t){return Jc(e,t)}function od(e,t){return new ed({type:`pipe`,in:Lu(e),out:t})}var sd=Fu([`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`]),cd=Fu([`full`,`collapsed`]),ld=Fu([`pending`,`burning`,`done`,`failed`,`cancelled`]),ud=Fu([`ideation`,`qa`,`waypoint`,`converge`,`revisit`]),dd=Fu([`running`,`succeeded`,`failed`,`cancelled`]),fd=Fu([`active`,`shipped`]),pd=Fu([`launching`,`live`,`ended`]);Du({title:H(),goal:H(),context:H(),acceptanceCriteria:Tu(H()),seams:Tu(H()),blockedBy:Tu(pu())}).extend({id:H(),featureId:H(),seq:pu(),status:ld,commits:Tu(H()),error:H().optional()});var md=Fu([`grilling`,`research`,`prototype`,`task`]),hd=Fu([`open`,`claimed`,`resolved`,`dropped`]);Fu([`resolved`,`dropped`]),Du({title:H(),type:md,question:H(),blockedBy:Tu(ku([pu(),H()])),originWaypointId:H().optional()}).extend({id:H(),featureId:H(),seq:pu(),blockedBy:Tu(pu()),status:hd,claimedBy:H().optional(),lastSessionId:H().optional(),summary:H().optional()}),Du({id:H(),name:H(),repoPath:H(),mainBranch:H(),devCommand:H().optional(),model:H().optional()}),Du({id:H(),projectId:H(),slug:H(),title:H(),oneLiner:H(),size:cd,mapped:_u(),phase:sd,branch:H(),baseBranch:H().optional(),status:fd,createdAt:pu()}),Du({id:H(),featureId:H(),kind:ud,ccSessionId:H().optional(),transcriptPath:H().optional(),status:pd,worktreePath:H()}),Du({id:H(),featureId:H(),workflow:H(),status:dd,startedAt:pu(),endedAt:pu().optional(),summary:H().optional()});var gd=Fu([`env`,`project`,`file`,`default`]),_d=Fu([`global`,`project`]),vd=Du({key:H(),value:xu(),source:gd,editable:_u(),restartRequired:_u(),scope:_d});Du({projectId:H().optional(),fields:Tu(vd)}),Du({projectId:H().optional(),key:H(),value:ku([H(),pu(),_u(),yu()])}),Du({id:pu(),projectId:H(),featureId:H().optional(),runId:H().optional(),ticketId:H().optional(),ts:pu(),type:H(),message:H(),data:xu().optional()});var yd=[{phase:`ideation`},{phase:`spec`,gateToEnter:{id:`G1`,description:`Decisions captured before writing a spec`,check:`decisions-file-exists`}},{phase:`tickets`,gateToEnter:{id:`G2`,description:`Spec written before breaking into tickets (auto-satisfied for collapsed features)`,check:`spec-file-exists`}},{phase:`implementation`,gateToEnter:{id:`G3`,description:`Tickets approved by a human (the Burn click)`,check:`tickets-approved`}},{phase:`review`,gateToEnter:{id:`G4`,description:`Every ticket reached a terminal state`,check:`all-tickets-terminal`}},{phase:`shipped`,gateToEnter:{id:`G5`,description:`Human merged the feature branch (the Merge click)`,check:`human-merge`}}].map(e=>e.phase);function bd(e){let t=yd.indexOf(e.phase);if(t<0||t>=yd.length-1)return null;let n=yd[t+1];return e.size===`collapsed`&&n===`spec`?yd[t+2]??null:n}var W=Symbol.for(`drizzle:entityKind`);function xd(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var Sd=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[W]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Cd=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},wd=Symbol.for(`drizzle:Name`),Td=Symbol.for(`drizzle:isPgEnum`);function Ed(e){return!!e&&typeof e==`function`&&Td in e&&e[Td]===!0}var G=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Dd={startActiveSpan(e,t){return t()}},Od=Symbol.for(`drizzle:ViewBaseConfig`),kd=Symbol.for(`drizzle:Schema`),Ad=Symbol.for(`drizzle:Columns`),jd=Symbol.for(`drizzle:ExtraConfigColumns`),Md=Symbol.for(`drizzle:OriginalName`),Nd=Symbol.for(`drizzle:BaseName`),Pd=Symbol.for(`drizzle:IsAlias`),Fd=Symbol.for(`drizzle:ExtraConfigBuilder`),Id=Symbol.for(`drizzle:IsDrizzleTable`),Ld=class{static[W]=`Table`;static Symbol={Name:wd,Schema:kd,OriginalName:Md,Columns:Ad,ExtraConfigColumns:jd,BaseName:Nd,IsAlias:Pd,ExtraConfigBuilder:Fd};[wd];[Md];[kd];[Ad];[jd];[Nd];[Pd]=!1;[Id]=!0;[Fd]=void 0;constructor(e,t,n){this[wd]=this[Md]=e,this[kd]=t,this[Nd]=n}};function Rd(e){return e!=null&&typeof e.getSQL==`function`}function zd(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var K=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Bd([this])}},Bd=class e{constructor(e){this.queryChunks=e;for(let t of e)if(xd(t,Ld)){let e=t[Ld.Symbol.Schema];this.usedTables.push(e===void 0?t[Ld.Symbol.Name]:e+`.`+t[Ld.Symbol.Name])}}static[W]=`SQL`;decoder=Hd;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Dd.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return zd(t.map(t=>{if(xd(t,K))return{sql:t.value.join(``),params:[]};if(xd(t,Vd))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new K(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new K(`, `));return e.push(new K(`)`)),this.buildQueryFromSourceParams(e,r)}if(xd(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(xd(t,Ld)){let e=t[Ld.Symbol.Schema],n=t[Ld.Symbol.Name];return{sql:e===void 0||t[Pd]?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Sd)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Ld.Symbol.Schema];return{sql:t.table[Pd]||r===void 0?a(t.table[Ld.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Ld.Symbol.Name])+`.`+a(e),params:[]}}if(xd(t,Jd)){let e=t[Od].schema,n=t[Od].name;return{sql:e===void 0||t[Od].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Wd)){if(xd(t.value,Kd))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(xd(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return xd(t,Kd)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:xd(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:xd(t,G)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new K(`(`),t._.sql,new K(`) `),new Vd(t._.alias)],r):Ed(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Rd(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new K(`(`),t.getSQL(),new K(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Vd=class{constructor(e){this.value=e}static[W]=`Name`;brand;getSQL(){return new Bd([this])}},Hd={mapFromDriverValue:e=>e},Ud={mapToDriverValue:e=>e};({...Hd,...Ud});var Wd=class{constructor(e,t=Ud){this.value=e,this.encoder=t}static[W]=`Param`;brand;getSQL(){return new Bd([this])}};function Gd(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new K(e[0]));for(let[r,i]of t.entries())n.push(i,new K(e[r+1]));return new Bd(n)}(e=>{function t(){return new Bd([])}e.empty=t;function n(e){return new Bd(e)}e.fromList=n;function r(e){return new Bd([new K(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Bd(n)}e.join=i;function a(e){return new Vd(e)}e.identifier=a;function o(e){return new Kd(e)}e.placeholder=o;function s(e,t){return new Wd(e,t)}e.param=s})(Gd||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[W]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Bd||={});var Kd=class{constructor(e){this.name=e}static[W]=`Placeholder`;getSQL(){return new Bd([this])}},qd=Symbol.for(`drizzle:IsDrizzleView`),Jd=class{static[W]=`View`;[Od];[qd]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Od]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Bd([this])}};Sd.prototype.getSQL=function(){return new Bd([this])},Ld.prototype.getSQL=function(){return new Bd([this])},G.prototype.getSQL=function(){return new Bd([this])};function Yd(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var Xd=typeof TextDecoder>`u`?null:new TextDecoder,Zd=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new Qd(e,this)}},Qd=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[wd],...r,n[0].table[wd],...i];return e??`${a.join(`_`)}_fk`}};function $d(e,t){return`${e[wd]}_${t.join(`_`)}_unique`}var ef=class extends Cd{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new Zd(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},tf=class extends Sd{constructor(e,t){t.uniqueName||=$d(e,[t.name]),super(e,t),this.table=e}static[W]=`SQLiteColumn`},nf=class extends ef{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new rf(e,this.config)}},rf=class extends tf{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},af=class extends ef{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new of(e,this.config)}},of=class extends tf{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},sf=class extends ef{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new cf(e,this.config)}},cf=class extends tf{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function lf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`json`?new af(n):r?.mode===`bigint`?new nf(n):new sf(n)}var uf=class extends ef{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new df(e,this.config)}},df=class extends tf{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function ff(e){return(t,n)=>{let{name:r,config:i}=Yd(t,n);return new uf(r,i,e)}}var pf=class extends ef{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},mf=class extends tf{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},hf=class extends pf{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new gf(e,this.config)}},gf=class extends mf{static[W]=`SQLiteInteger`},_f=class extends pf{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Gd`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new vf(e,this.config)}},vf=class extends mf{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},yf=class extends pf{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new bf(e,this.config)}},bf=class extends mf{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function xf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new _f(n,r.mode):r?.mode===`boolean`?new yf(n,r.mode):new hf(n)}var Sf=class extends ef{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Cf(e,this.config)}},Cf=class extends tf{static[W]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},wf=class extends ef{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new Tf(e,this.config)}},Tf=class extends tf{static[W]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Ef=class extends ef{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Df(e,this.config)}},Df=class extends tf{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Of(e,t){let{name:n,config:r}=Yd(e,t),i=r?.mode;return i===`number`?new wf(n):i===`bigint`?new Ef(n):new Sf(n)}var kf=class extends ef{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Af(e,this.config)}},Af=class extends tf{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function jf(e){return new kf(e??``)}var Mf=class extends ef{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Nf(e,this.config)}},Nf=class extends tf{static[W]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Pf=class extends ef{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new Ff(e,this.config)}},Ff=class extends tf{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function q(e,t={}){let{name:n,config:r}=Yd(e,t);return r.mode===`json`?new Pf(n):new Mf(n,r)}function If(){return{blob:lf,customType:ff,integer:xf,numeric:Of,real:jf,text:q}}var Lf=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Rf=class extends Ld{static[W]=`SQLiteTable`;static Symbol=Object.assign({},Ld.Symbol,{InlineForeignKeys:Lf});[Ld.Symbol.Columns];[Lf]=[];[Ld.Symbol.ExtraConfigBuilder]=void 0};function zf(e,t,n,r,i=e){let a=new Rf(e,r,i),o=typeof t==`function`?t(If()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Lf].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Ld.Symbol.Columns]=s,c[Ld.Symbol.ExtraConfigColumns]=s,n&&(c[Rf.Symbol.ExtraConfigBuilder]=n),c}var Bf=(e,t,n)=>zf(e,t,n);Bf(`projects`,{id:q(`id`).primaryKey(),name:q(`name`).notNull(),repoPath:q(`repo_path`).notNull(),mainBranch:q(`main_branch`).notNull(),devCommand:q(`dev_command`),model:q(`model`),sandbox:q(`sandbox`),closedAt:xf(`closed_at`)}),Bf(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),size:q(`size`).notNull().$type(),mapped:xf(`mapped`,{mode:`boolean`}).notNull().default(!1),phase:q(`phase`).notNull().$type(),branch:q(`branch`).notNull(),baseBranch:q(`base_branch`),status:q(`status`).notNull().$type(),createdAt:xf(`created_at`).notNull()}),Bf(`sessions`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),kind:q(`kind`).notNull().$type(),ccSessionId:q(`cc_session_id`),transcriptPath:q(`transcript_path`),status:q(`status`).notNull().$type(),worktreePath:q(`worktree_path`).notNull()}),Bf(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),goal:q(`goal`).notNull(),context:q(`context`).notNull(),acceptanceCriteria:q(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:q(`seams`,{mode:`json`}).notNull().$type(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),status:q(`status`).notNull().$type(),commits:q(`commits`,{mode:`json`}).notNull().$type(),error:q(`error`)}),Bf(`waypoints`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),type:q(`type`).notNull().$type(),question:q(`question`).notNull(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),originWaypointId:q(`origin_waypoint_id`),status:q(`status`).notNull().$type(),claimedBy:q(`claimed_by`),lastSessionId:q(`last_session_id`),summary:q(`summary`)}),Bf(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:xf(`started_at`).notNull(),endedAt:xf(`ended_at`),summary:q(`summary`)}),Bf(`events`,{id:xf(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:xf(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})}),Bf(`gate_overrides`,{id:xf(`id`).primaryKey({autoIncrement:!0}),featureId:q(`feature_id`).notNull(),gate:q(`gate`).notNull(),reason:q(`reason`).notNull(),ts:xf(`ts`).notNull()});var Vf=[`ideation`,`qa`,`waypoint`,`converge`,`revisit`,`research`,`implement`,`smoke`],Hf=Fu(Vf),Uf=[{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-sonnet-5`,label:`Sonnet 5`},{id:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`},{id:`claude-fable-5`,label:`Fable 5`}];od(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=t.smokeModel;if(typeof n==`string`&&n.length>0){let e=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?t.stepModels:{};e.smoke===void 0&&(t.stepModels={...e,smoke:n})}return delete t.smokeModel,t},Du({serverPort:pu().default(4512),model:H().default(`claude-opus-4-8`),stepModels:Nu(Hf,H()).default({smoke:`claude-haiku-4-5-20251001`}),sandbox:Fu([`docker`,`podman`,`noSandbox`]).default(`docker`),mainBranch:H().default(`main`),sandboxImage:H().optional(),burnConcurrency:pu().int().min(1).max(8).default(3),burnMaxIterations:pu().int().min(1).max(10).default(3),setupCommand:H().optional(),burnWorkspace:Fu([`auto`,`mounted`,`isolated`]).default(`auto`)}));var Wf=[`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`];function Gf(e){switch(e){case`ideation`:return`◉`;case`spec`:return`◐`;case`tickets`:return`▤`;case`implementation`:return`⚙`;case`review`:return`◆`;case`shipped`:return`✓`}}function Kf(e){return e.status===`shipped`||e.activeRun?null:e.ticketCounts.failed>0?{kind:`attention`,label:`run failed — needs attention`}:e.phase===`ideation`?{kind:`grill`,label:`needs grilling`}:e.phase===`tickets`&&e.ticketCounts.total>0?{kind:`burn`,label:`review & burn tickets`}:e.phase===`review`?{kind:`ship`,label:`test & merge`}:null}function qf(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}var Jf={ideation:`ideation`,spec:`spec`,tickets:`tickets`,implementation:`build`,review:`review`,shipped:`shipped`},Yf={ideation:`Shape the idea in a grill session`,spec:`Write it up as a spec`,tickets:`Break the work into atomic tickets`,implementation:`Burn the tickets into commits`,review:`Test-drive the branch, then merge`,shipped:`Merged to the main branch`};function Xf(e){return Wf.indexOf(e)}function Zf(e){return e.size===`collapsed`}function Qf(e){return e.status===`shipped`?`shipped`:e.activeRun?`agentWorking`:Kf(e)?`needsYou`:`inProgress`}function $f(e){let t={needsYou:[],agentWorking:[],inProgress:[],shipped:[]};for(let n of e)t[Qf(n)].push(n);return[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`shipped`,label:`Shipped`}].map(({key:e,label:n})=>({key:e,label:n,features:t[e]})).filter(e=>e.features.length>0)}function ep(e,t){if(Zf(e)&&t===`spec`)return`skipped`;let n=Xf(e.phase),r=Xf(t);return r<n?`done`:r===n?`current`:`upcoming`}function tp(e){return Wf.map(t=>({phase:t,state:ep(e,t)}))}function np(e,t){return t??e.phase}function rp(e,t){return Xf(t)<Xf(e.phase)}function ip(e,t){return Wf.map(n=>{let r=ep(e,n);return{phase:n,label:Jf[n],state:r,isViewed:n===t,clickable:r===`done`||r===`current`,tip:Yf[n]}})}function ap(e,t){let{feature:n,tickets:r,sessions:i,runs:a,gate:o}=e,s=i.find(e=>e.status===`live`),c=r.length,l=r.filter(e=>e.status===`done`).length,u=r.filter(e=>e.status===`failed`).length,d=qf(a),f=d?.status===`running`,p=bd(n),m=!!o.next&&o.satisfied&&o.next.id!==`G3`&&o.next.id!==`G5`,h=p?`Promote to ${Jf[p]}`:`Promote`;switch(n.phase){case`ideation`:return n.mapped?{kick:`MAP`,title:o.satisfied?`Converge the map`:`Work the frontier`,desc:o.satisfied?`Every waypoint is resolved — converge to draft the spec and tickets.`:o.reason??`Resolve the open waypoints; converge once the frontier clears.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:void 0,secondary:[],busy:!1}:m?{kick:`NEXT STEP`,title:`Promote the idea`,desc:`Decisions are captured — promote the idea when it feels concrete.`,primary:{label:h,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Grill session in progress`,desc:`Shape the idea with Claude — decisions accumulate in Knowledge.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Shape the idea with Claude`,desc:`Launch a grill session to shape the idea before any code is written.`,primary:{label:`Start grill session`,kind:`startGrill`},secondary:[],busy:!1};case`spec`:return m?{kick:`NEXT STEP`,title:`Approve the spec`,desc:`The spec is written — approve it to move into tickets.`,primary:{label:`Approve spec → tickets`,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Writing the spec`,desc:`The spec takes shape beside the conversation.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Write the spec`,desc:`No spec yet — resume the grill to draft it.`,primary:{label:`Resume grill`,kind:`startGrill`},secondary:[],busy:!1};case`tickets`:return c>0?{kick:`NEXT STEP`,title:`Review & burn the tickets`,desc:`Each ticket is one atomic task Claude will implement. Review them, then burn.`,primary:{label:`Burn ${c} ticket${c===1?``:`s`}`,kind:`burn`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[{label:`Revisit`,kind:`revisit`}],busy:!1}:{kick:`WAITING`,title:`Waiting for tickets`,desc:`No tickets yet — a grill session emits them. Open a session to shape the work.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:{label:`Open grill to emit tickets`,kind:`startGrill`},secondary:[],busy:!1};case`implementation`:return f?{kick:`IN PROGRESS`,title:`Burning tickets`,desc:`Burning ${c} ticket${c===1?``:`s`} — ${l} done${u?`, ${u} failed`:``}.`,primary:{label:`Cancel run`,kind:`cancelRun`,danger:!0},secondary:[],busy:!0}:{kick:`NEXT STEP`,title:`Resume the burn`,desc:d?.status===`failed`?`The run failed — resume the burn to retry.`:d?.status===`cancelled`?`The run was cancelled — resume the burn to continue.`:`The burn has not started — resume to run the tickets.`,primary:{label:`Resume burn`,kind:`burn`},secondary:s?[]:[{label:`Revisit`,kind:`revisit`}],busy:!1};case`review`:{let e=t.driving?`Test-driving the branch — merge when it looks right.`:u>0?`Run finished with ${u} failed ticket${u===1?``:`s`} — review, then ship.`:`Checks are in. Test-drive the branch, then merge to ship.`;return{kick:`NEXT STEP`,title:t.driving?`Merge when it looks right`:`Test drive, then ship`,desc:e,primary:{label:`Merge & ship`,kind:`merge`},secondary:t.driving?[{label:`Stop test drive`,kind:`testDriveStop`}]:[{label:`Start test drive`,kind:`testDriveStart`}],busy:!1}}case`shipped`:return{kick:`SHIPPED`,title:`Shipped to main`,desc:`The branch is merged and the pipeline is complete. Ask a question anytime.`,primary:void 0,secondary:[{label:`Ask a question`,kind:`askQuestions`}],busy:!1}}}function op({projectId:e,selectedFeatureId:t,onSelect:n,onNewFeature:r}){let i=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),a=$f(i.data??[]);return(0,O.jsxs)(`nav`,{className:`sidebar`,children:[(0,O.jsxs)(`div`,{className:`sidebar-head`,children:[(0,O.jsx)(`span`,{className:`pane-title`,children:`Features`}),(0,O.jsx)(`button`,{className:`new-btn`,onClick:r,children:`+ New`})]}),(0,O.jsxs)(`div`,{className:`sidebar-list`,children:[i.isLoading&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`loading features…`})}),i.data&&i.data.length===0&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`no features yet — + New to begin`})}),a.map(e=>(0,O.jsxs)(`div`,{className:`triage-group triage-${e.key}`,children:[(0,O.jsxs)(`div`,{className:`triage-label`,children:[(0,O.jsx)(`span`,{className:`triage-name`,children:e.label}),(0,O.jsx)(`span`,{className:`triage-count`,children:e.features.length})]}),e.features.map(e=>(0,O.jsx)(sp,{f:e,active:e.id===t,onSelect:n},e.id))]},e.key))]}),(0,O.jsx)(`div`,{className:`sidebar-foot`,children:`Every feature moves through the same six-phase pipeline. Amber means it's waiting on you.`})]})}function sp({f:e,active:t,onSelect:n}){let r=Kf(e),i=tp(e);return(0,O.jsxs)(`button`,{className:`feature-row${t?` is-active`:``}${e.status===`shipped`?` is-shipped`:``}`,onClick:()=>n(e.id),title:e.title,children:[(0,O.jsx)(`span`,{className:`feature-glyph phase-fg-${e.phase}`,children:Gf(e.phase)}),(0,O.jsx)(`span`,{className:`feature-slug mono`,children:e.slug}),(0,O.jsx)(`span`,{className:`feature-flag`,children:e.activeRun?(0,O.jsx)(`span`,{className:`spin-ring`,title:`agent working`}):e.status===`shipped`?(0,O.jsx)(`span`,{className:`mini-check`,children:`✓`}):(0,O.jsxs)(O.Fragment,{children:[r&&(0,O.jsx)(`span`,{className:`needs-dot needs-${r.kind}`,title:r.label}),(0,O.jsx)(`span`,{className:`mini-map`,children:i.map((e,t)=>(0,O.jsx)(`span`,{className:`mini-seg is-${e.state}`},t))})]})})]})}var cp=(0,D.createContext)(null);function lp({children:e}){let[t,n]=(0,D.useState)([]),r=(0,D.useCallback)((e,t=`error`)=>{let r=Date.now()+Math.random();n(n=>[...n,{id:r,kind:t,message:e}]),setTimeout(()=>n(e=>e.filter(e=>e.id!==r)),6e3)},[]);return(0,O.jsxs)(cp.Provider,{value:{push:r},children:[e,(0,O.jsx)(`div`,{className:`toasts`,children:t.map(e=>(0,O.jsx)(`div`,{className:`toast toast-${e.kind}`,onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),children:e.message},e.id))})]})}function up(){let e=(0,D.useContext)(cp);if(!e)throw Error(`useToast used outside ToastProvider`);return e}function dp(e){let[t,n]=(0,D.useState)([]),r=t.length?t[t.length-1].id:void 0,i=j.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:1500});return(0,D.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}function fp(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pp(e){return e.slice(0,7)}function mp(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function hp(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${String(i).padStart(2,`0`)}m`:i>0?`${i}m ${String(a).padStart(2,`0`)}s`:`${a}s`}function gp({featureId:e,relPath:t,title:n,onClose:r}){let i=j.docs.read.useQuery({featureId:e,relPath:t});return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,O.jsx)(`div`,{className:`peek-backdrop`,onClick:r,children:(0,O.jsxs)(`div`,{className:`peek`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`peek-head`,children:[(0,O.jsx)(`span`,{className:`mono peek-path`,children:t}),(0,O.jsx)(`button`,{className:`peek-close`,onClick:r,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,O.jsxs)(`div`,{className:`peek-body mono`,children:[i.isLoading&&(0,O.jsxs)(M,{children:[`loading `,n,`…`]}),i.error&&(0,O.jsxs)(M,{children:[`could not read `,t,`: `,i.error.message]}),i.data&&(0,O.jsx)(`pre`,{className:`peek-pre`,children:i.data.content})]})]})})}function _p({featureId:e}){let t=j.feature.get.useQuery({id:e},{refetchInterval:1500});return t.isLoading?(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:`loading…`})}):t.data?(0,O.jsxs)(`aside`,{className:`inspector`,children:[(0,O.jsx)(bp,{featureId:e,gate:t.data.gate}),(0,O.jsx)(Cp,{featureId:e,docs:t.data.docs}),(0,O.jsx)(wp,{featureId:e})]}):(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:t.error?.message??`could not load inspector`})})}var vp={G1:`Decisions captured`,G2:`Spec written`,G3:`Tickets approved`,G4:`Run clean`,G5:`Merged`};function yp(e){return e.check===`all-waypoints-terminal`?`Waypoints resolved`:vp[e.id]??e.id}function bp({featureId:e,gate:t}){let n=up(),r=j.useUtils(),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(``),c=j.feature.overrideGate.useMutation({onSuccess:()=>{s(``),a(!1),r.feature.get.invalidate({id:e}),r.feature.list.invalidate()},onError:e=>n.push(e.message)});return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Current gate`}),t.next===null?(0,O.jsx)(`div`,{className:`gate-empty`,children:`No gate — this feature is shipped.`}):(0,O.jsx)(xp,{gateId:t.next.id,name:yp(t.next),description:t.next.description,satisfied:t.satisfied,reason:t.reason,open:i,reasonValue:o,pending:c.isPending,onOpen:()=>a(!0),onCancel:()=>{a(!1),s(``)},onReasonChange:s,onApply:()=>c.mutate({featureId:e,gate:t.next.id,reason:o.trim()})})]})}function xp({gateId:e,name:t,description:n,satisfied:r,reason:i,open:a,reasonValue:o,pending:s,onOpen:c,onCancel:l,onReasonChange:u,onApply:d}){return(0,O.jsxs)(`div`,{className:`gate-card`,children:[(0,O.jsxs)(`div`,{className:`gate-idrow`,children:[(0,O.jsx)(`span`,{className:`gate-id`,children:e}),(0,O.jsx)(`span`,{className:`gate-name`,children:t})]}),(0,O.jsx)(`div`,{className:`gate-req`,children:n}),(0,O.jsxs)(`div`,{className:`gate-state ${r?`is-ok`:`is-block`}`,children:[(0,O.jsx)(`span`,{className:`gate-state-dot`}),(0,O.jsx)(`span`,{children:r?`ready to advance`:i??`blocked`})]}),a?(0,O.jsxs)(`div`,{className:`override-form`,children:[(0,O.jsx)(`input`,{className:`override-input`,placeholder:`reason for override`,value:o,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(Ci,{variant:`solid`,className:`btn-xs`,disabled:!o.trim()||s,onClick:d,children:`Apply`}),(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:l,children:`Cancel`})]})]}):(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:c,children:`Override with reason…`}),(0,O.jsx)(`div`,{className:`gate-hint`,children:`The highlighted action in the workspace advances this gate.`})]})}function Sp(e){return e.split(/[\\/]/).pop()??e}function Cp({featureId:e,docs:t}){let[n,r]=(0,D.useState)(null);return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Knowledge`}),t.length===0?(0,O.jsx)(M,{children:`no docs yet`}):(0,O.jsx)(`ul`,{className:`doc-list`,children:t.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{className:`doc-link`,onClick:()=>r({relPath:e.relPath,title:e.title}),children:[(0,O.jsx)(`span`,{className:`doc-title`,children:e.title}),(0,O.jsx)(`span`,{className:`doc-meta`,children:Sp(e.relPath)})]})},e.relPath))}),n&&(0,O.jsx)(gp,{featureId:e,relPath:n.relPath,title:n.title,onClose:()=>r(null)})]})}function wp({featureId:e}){let t=dp(e).slice(-12).reverse();return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Activity`}),t.length===0?(0,O.jsx)(M,{children:`no activity yet`}):(0,O.jsx)(`div`,{className:`activity-log`,children:t.map(e=>(0,O.jsxs)(`div`,{className:`act-line`,children:[(0,O.jsx)(`span`,{className:`act-time`,children:mp(e.ts)}),(0,O.jsxs)(`div`,{className:`act-body`,children:[(0,O.jsx)(`div`,{className:`act-type`,children:e.type}),(0,O.jsx)(`div`,{className:`act-msg`,children:e.message})]})]},e.id))})]})}var Tp=`docker`,Ep=4512;function Dp({projectId:e,activeFeatureId:t,driving:n,onDriveChange:r}){let i=up(),a=j.useUtils(),o=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),s=!o.isError&&o.data!==void 0,c=o.data?.find(e=>e.id===t),l=o.data?.filter(e=>e.activeRun).length??0,u=j.feature.testDrive.useMutation({onSuccess:()=>{r(null),n&&a.feature.get.invalidate({id:n.featureId}),a.feature.list.invalidate()},onError:e=>i.push(e.message)});return(0,O.jsxs)(`footer`,{className:`statusbar`,children:[c&&(0,O.jsxs)(`button`,{className:`sb-branch`,onClick:()=>{c&&navigator.clipboard.writeText(c.branch).then(()=>i.push(`copied ${c.branch}`,`info`),()=>i.push(`copy failed`))},title:`copy branch`,children:[`⎇ `,c.branch]}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[`sandbox · `,Tp]}),n&&(0,O.jsxs)(`span`,{className:`sb-driving`,children:[(0,O.jsx)(`span`,{className:`sb-driving-dot`}),`driving `,(0,O.jsx)(`span`,{className:`mono`,children:n.branch}),(0,O.jsx)(`button`,{className:`sb-stop`,disabled:u.isPending,onClick:()=>u.mutate({featureId:n.featureId,action:`stop`}),children:`stop`})]}),(0,O.jsx)(`span`,{className:`sb-spacer`}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[l,` run`,l===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`sb-item sb-health ${s?`is-ok`:`is-down`}`,children:[(0,O.jsx)(`span`,{className:`health-dot`}),`:`,Ep,` `,s?`ok`:`down`]})]})}function Op({featureId:e,sessionId:t}){let n=j.useUtils(),r=up(),i=j.feature.endSession.useMutation({onSuccess:()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),r.push(`session ended`,`info`)},onError:e=>r.push(e.message)});return(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost sess-end`,disabled:i.isPending,title:`end this session — recoverable, you can relaunch it`,onClick:()=>i.mutate({sessionId:t}),children:i.isPending?`Ending…`:`End session`})}var kp=class extends D.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[runcastle] boundary caught`,e,t)}render(){return this.state.error?(0,O.jsx)(`div`,{className:`boundary-fallback`,children:(0,O.jsxs)(`span`,{className:`dim-line mono`,children:[this.props.label??`component`,` failed: `,this.state.error.message]})}):this.props.children}},Ap=2,jp=1,Mp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Ap,Math.floor(u/e.css.cell.width)),rows:Math.max(jp,Math.floor(l/e.css.cell.height))}}},Np=Object.defineProperty,Pp=Object.getOwnPropertyDescriptor,Fp=(e,t)=>{for(var n in t)Np(e,n,{get:t[n],enumerable:!0})},Ip=(e,t,n,r)=>{for(var i=r>1?void 0:r?Pp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Np(t,n,i),i},J=(e,t)=>(n,r)=>t(n,r,e),Lp=`Terminal input`,Rp={get:()=>Lp,set:e=>Lp=e},zp=`Too much output to announce, navigate to rows manually to read`,Bp={get:()=>zp,set:e=>zp=e};function Vp(e){return e.replace(/\r?\n/g,`\r`)}function Hp(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Up(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Wp(e,t,n,r){e.stopPropagation(),e.clipboardData&&Gp(e.clipboardData.getData(`text/plain`),t,n,r)}function Gp(e,t,n,r){e=Vp(e),e=Hp(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Kp(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function qp(e,t,n,r,i){Kp(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Jp(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Yp(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Xp=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Zp=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Qp=``,$p=` `,em=class e{constructor(){this.fg=0,this.bg=0,this.extended=new tm}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},tm=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},nm=class e extends em{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new tm,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Jp(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rm=`di$target`,im=`di$dependencies`,am=new Map;function om(e){return e[im]||[]}function sm(e){if(am.has(e))return am.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);cm(t,e,r)};return t._id=e,am.set(e,t),t}function cm(e,t,n){t[rm]===t?t[im].push({id:e,index:n}):(t[im]=[{id:e,index:n}],t[rm]=t)}var lm=sm(`BufferService`),um=sm(`CoreMouseService`),dm=sm(`CoreService`),fm=sm(`CharsetService`),pm=sm(`InstantiationService`),mm=sm(`LogService`),hm=sm(`OptionsService`),gm=sm(`OscLinkService`),_m=sm(`UnicodeService`),vm=sm(`DecorationService`),ym=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new nm,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):bm(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ym=Ip([J(0,lm),J(1,hm),J(2,gm)],ym);function bm(e,t){if(confirm(`Do you want to navigate to ${t}?
72
+ 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 $c(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:nl(t,`input`,e.processors),output:nl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function el(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 el(r.element,n);if(r.type===`set`)return el(r.valueType,n);if(r.type===`lazy`)return el(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 el(r.innerType,n);if(r.type===`intersection`)return el(r.left,n)||el(r.right,n);if(r.type===`record`||r.type===`map`)return el(r.keyType,n)||el(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:el(r.in,n)||el(r.out,n);if(r.type===`object`){for(let e in r.shape)if(el(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(el(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(el(e,n))return!0;return!!(r.rest&&el(r.rest,n))}return!1}var tl=(e,t={})=>n=>{let r=Xc({...n,processors:t});return Zc(e,r),Qc(r,e),$c(r,e)},nl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Xc({...i??{},target:a,io:t,processors:n});return Zc(e,o),Qc(o,e),$c(o,e)},rl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},il=(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=rl[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}))])}},al=(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)},ol=(e,t,n,r)=>{n.type=`boolean`},sl=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},cl=(e,t,n,r)=>{n.not={}},ll=(e,t,n,r)=>{let i=e._zod.def,a=Pi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ul=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},dl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},fl=(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=Zc(a.element,t,{...r,path:[...r.path,`items`]})},pl=(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]=Zc(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=Zc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ml=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Zc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},hl=(e,t,n,r)=>{let i=e._zod.def,a=Zc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Zc(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]]},gl=(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=Zc(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=Zc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Zc(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)}},_l=(e,t,n,r)=>{let i=e._zod.def,a=Zc(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`}]},vl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},yl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},bl=(e,t,n,r)=>{let i=e._zod.def;Zc(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)))},xl=(e,t,n,r)=>{let i=e._zod.def;Zc(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},Sl=(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;Zc(o,t,r);let s=t.seen.get(e);s.ref=o},Cl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},wl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Tl=N(`ZodISODateTime`,(e,t)=>{Wo.init(e,t),U.init(e,t)});function El(e){return gc(Tl,e)}var Dl=N(`ZodISODate`,(e,t)=>{Go.init(e,t),U.init(e,t)});function Ol(e){return _c(Dl,e)}var kl=N(`ZodISOTime`,(e,t)=>{Ko.init(e,t),U.init(e,t)});function Al(e){return vc(kl,e)}var jl=N(`ZodISODuration`,(e,t)=>{qo.init(e,t),U.init(e,t)});function Ml(e){return yc(jl,e)}var Nl=N(`ZodError`,(e,t)=>{ha.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>va(e,t)},flatten:{value:t=>_a(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Fi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Fi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Pl=ya(Nl),Fl=ba(Nl),Il=xa(Nl),Ll=Ca(Nl),Rl=Ta(Nl),zl=Ea(Nl),Bl=Da(Nl),Vl=Oa(Nl),Hl=ka(Nl),Ul=Aa(Nl),Wl=ja(Nl),Gl=Ma(Nl),Kl=new WeakMap;function R(e,t,n){let r=Object.getPrototypeOf(e),i=Kl.get(r);if(i||(i=new Set,Kl.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 z=N(`ZodType`,(e,t)=>(Ao.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:nl(e,`input`),output:nl(e,`output`)}}),e.toJSONSchema=tl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Pl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Il(e,t,n),e.parseAsync=async(t,n)=>Fl(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ll(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Rl(e,t,n),e.decode=(t,n)=>zl(e,t,n),e.encodeAsync=async(t,n)=>Bl(e,t,n),e.decodeAsync=async(t,n)=>Vl(e,t,n),e.safeEncode=(t,n)=>Hl(e,t,n),e.safeDecode=(t,n)=>Ul(e,t,n),e.safeEncodeAsync=async(t,n)=>Wl(e,t,n),e.safeDecodeAsync=async(t,n)=>Gl(e,t,n),R(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Vi(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 Zi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(id(e,t))},superRefine(e,t){return this.check(ad(e,t))},overwrite(e){return this.check(Bc(e))},optional(){return zu(this)},exactOptional(){return Vu(this)},nullable(){return Uu(this)},nullish(){return zu(Uu(this))},nonoptional(e){return Yu(this,e)},array(){return Tu(this)},or(e){return ku([this,e])},and(e){return ju(this,e)},transform(e){return $u(this,Lu(e))},default(e){return Gu(this,e)},prefault(e){return qu(this,e)},catch(e){return Zu(this,e)},pipe(e){return $u(this,e)},readonly(){return nd(this)},describe(e){let t=this.clone();return Ks.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ks.get(this);let t=this.clone();return Ks.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 Ks.get(e)?.description},configurable:!0}),e)),B=N(`_ZodString`,(e,t)=>{jo.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,R(e,`_ZodString`,{regex(...e){return this.check(Pc(...e))},includes(...e){return this.check(Lc(...e))},startsWith(...e){return this.check(Rc(...e))},endsWith(...e){return this.check(zc(...e))},min(...e){return this.check(Mc(...e))},max(...e){return this.check(jc(...e))},length(...e){return this.check(Nc(...e))},nonempty(...e){return this.check(Mc(1,...e))},lowercase(e){return this.check(Fc(e))},uppercase(e){return this.check(Ic(e))},trim(){return this.check(Hc())},normalize(...e){return this.check(Vc(...e))},toLowerCase(){return this.check(Uc())},toUpperCase(){return this.check(Wc())},slugify(){return this.check(Gc())}})}),V=N(`ZodString`,(e,t)=>{jo.init(e,t),B.init(e,t),e.email=t=>e.check(Js(ql,t)),e.url=t=>e.check(ec(Xl,t)),e.jwt=t=>e.check(hc(du,t)),e.emoji=t=>e.check(tc(Zl,t)),e.guid=t=>e.check(Ys(Jl,t)),e.uuid=t=>e.check(Xs(Yl,t)),e.uuidv4=t=>e.check(Zs(Yl,t)),e.uuidv6=t=>e.check(Qs(Yl,t)),e.uuidv7=t=>e.check($s(Yl,t)),e.nanoid=t=>e.check(nc(Ql,t)),e.guid=t=>e.check(Ys(Jl,t)),e.cuid=t=>e.check(rc($l,t)),e.cuid2=t=>e.check(ic(eu,t)),e.ulid=t=>e.check(ac(tu,t)),e.base64=t=>e.check(fc(cu,t)),e.base64url=t=>e.check(pc(lu,t)),e.xid=t=>e.check(oc(nu,t)),e.ksuid=t=>e.check(sc(ru,t)),e.ipv4=t=>e.check(cc(iu,t)),e.ipv6=t=>e.check(lc(au,t)),e.cidrv4=t=>e.check(uc(ou,t)),e.cidrv6=t=>e.check(dc(su,t)),e.e164=t=>e.check(mc(uu,t)),e.datetime=t=>e.check(El(t)),e.date=t=>e.check(Ol(t)),e.time=t=>e.check(Al(t)),e.duration=t=>e.check(Ml(t))});function H(e){return qs(V,e)}var U=N(`ZodStringFormat`,(e,t)=>{Mo.init(e,t),B.init(e,t)}),ql=N(`ZodEmail`,(e,t)=>{Fo.init(e,t),U.init(e,t)}),Jl=N(`ZodGUID`,(e,t)=>{No.init(e,t),U.init(e,t)}),Yl=N(`ZodUUID`,(e,t)=>{Po.init(e,t),U.init(e,t)}),Xl=N(`ZodURL`,(e,t)=>{Io.init(e,t),U.init(e,t)}),Zl=N(`ZodEmoji`,(e,t)=>{Lo.init(e,t),U.init(e,t)}),Ql=N(`ZodNanoID`,(e,t)=>{Ro.init(e,t),U.init(e,t)}),$l=N(`ZodCUID`,(e,t)=>{zo.init(e,t),U.init(e,t)}),eu=N(`ZodCUID2`,(e,t)=>{Bo.init(e,t),U.init(e,t)}),tu=N(`ZodULID`,(e,t)=>{Vo.init(e,t),U.init(e,t)}),nu=N(`ZodXID`,(e,t)=>{Ho.init(e,t),U.init(e,t)}),ru=N(`ZodKSUID`,(e,t)=>{Uo.init(e,t),U.init(e,t)}),iu=N(`ZodIPv4`,(e,t)=>{Jo.init(e,t),U.init(e,t)}),au=N(`ZodIPv6`,(e,t)=>{Yo.init(e,t),U.init(e,t)}),ou=N(`ZodCIDRv4`,(e,t)=>{Xo.init(e,t),U.init(e,t)}),su=N(`ZodCIDRv6`,(e,t)=>{Zo.init(e,t),U.init(e,t)}),cu=N(`ZodBase64`,(e,t)=>{$o.init(e,t),U.init(e,t)}),lu=N(`ZodBase64URL`,(e,t)=>{ts.init(e,t),U.init(e,t)}),uu=N(`ZodE164`,(e,t)=>{ns.init(e,t),U.init(e,t)}),du=N(`ZodJWT`,(e,t)=>{is.init(e,t),U.init(e,t)}),fu=N(`ZodNumber`,(e,t)=>{as.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),R(e,`ZodNumber`,{gt(e,t){return this.check(Oc(e,t))},gte(e,t){return this.check(kc(e,t))},min(e,t){return this.check(kc(e,t))},lt(e,t){return this.check(Ec(e,t))},lte(e,t){return this.check(Dc(e,t))},max(e,t){return this.check(Dc(e,t))},int(e){return this.check(hu(e))},safe(e){return this.check(hu(e))},positive(e){return this.check(Oc(0,e))},nonnegative(e){return this.check(kc(0,e))},negative(e){return this.check(Ec(0,e))},nonpositive(e){return this.check(Dc(0,e))},multipleOf(e,t){return this.check(Ac(e,t))},step(e,t){return this.check(Ac(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 pu(e){return bc(fu,e)}var mu=N(`ZodNumberFormat`,(e,t)=>{os.init(e,t),fu.init(e,t)});function hu(e){return xc(mu,e)}var gu=N(`ZodBoolean`,(e,t)=>{ss.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r)});function _u(e){return Sc(gu,e)}var vu=N(`ZodNull`,(e,t)=>{cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r)});function yu(e){return Cc(vu,e)}var bu=N(`ZodUnknown`,(e,t)=>{ls.init(e,t),z.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function xu(){return wc(bu)}var Su=N(`ZodNever`,(e,t)=>{us.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r)});function Cu(e){return Tc(Su,e)}var wu=N(`ZodArray`,(e,t)=>{fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.element=t.element,R(e,`ZodArray`,{min(e,t){return this.check(Mc(e,t))},nonempty(e){return this.check(Mc(1,e))},max(e,t){return this.check(jc(e,t))},length(e,t){return this.check(Nc(e,t))},unwrap(){return this.element}})});function Tu(e,t){return Kc(wu,e,t)}var Eu=N(`ZodObject`,(e,t)=>{_s.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),F(e,`shape`,()=>t.shape),R(e,`ZodObject`,{keyof(){return Fu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:xu()})},loose(){return this.clone({...this._zod.def,catchall:xu()})},strict(){return this.clone({...this._zod.def,catchall:Cu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return na(this,e)},safeExtend(e){return ra(this,e)},merge(e){return ia(this,e)},pick(e){return ea(this,e)},omit(e){return ta(this,e)},partial(...e){return aa(Ru,this,e[0])},required(...e){return oa(Ju,this,e[0])}})});function Du(e,t){return new Eu({type:`object`,shape:e??{},...I(t)})}var Ou=N(`ZodUnion`,(e,t)=>{ys.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.options=t.options});function ku(e,t){return new Ou({type:`union`,options:e,...I(t)})}var Au=N(`ZodIntersection`,(e,t)=>{bs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r)});function ju(e,t){return new Au({type:`intersection`,left:e,right:t})}var Mu=N(`ZodRecord`,(e,t)=>{Cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nu(e,t,n){let r=Zi(e);return r._zod.values=void 0,new Mu({type:`record`,keyType:r,valueType:t,...I(n)})}var Pu=N(`ZodEnum`,(e,t)=>{ws.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(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 Pu({...t,checks:[],...I(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 Pu({...t,checks:[],...I(r),entries:i})}});function Fu(e,t){return new Pu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var Iu=N(`ZodTransform`,(e,t)=>{Ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ji(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(pa(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(pa(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 Lu(e){return new Iu({type:`transform`,transform:e})}var Ru=N(`ZodOptional`,(e,t)=>{Ds.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zu(e){return new Ru({type:`optional`,innerType:e})}var Bu=N(`ZodExactOptional`,(e,t)=>{Os.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Bu({type:`optional`,innerType:e})}var Hu=N(`ZodNullable`,(e,t)=>{ks.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_l(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e){return new Hu({type:`nullable`,innerType:e})}var Wu=N(`ZodDefault`,(e,t)=>{As.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gu(e,t){return new Wu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ku=N(`ZodPrefault`,(e,t)=>{Ms.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qu(e,t){return new Ku({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ju=N(`ZodNonOptional`,(e,t)=>{Ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Ju({type:`nonoptional`,innerType:e,...I(t)})}var Xu=N(`ZodCatch`,(e,t)=>{Fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zu(e,t){return new Xu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Qu=N(`ZodPipe`,(e,t)=>{Is.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sl(e,t,n,r),e.in=t.in,e.out=t.out});function $u(e,t){return new Qu({type:`pipe`,in:e,out:t})}var ed=N(`ZodPreprocess`,(e,t)=>{Qu.init(e,t),Rs.init(e,t)}),td=N(`ZodReadonly`,(e,t)=>{zs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nd(e){return new td({type:`readonly`,innerType:e})}var rd=N(`ZodCustom`,(e,t)=>{Vs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r)});function id(e,t={}){return qc(rd,e,t)}function ad(e,t){return Jc(e,t)}function od(e,t){return new ed({type:`pipe`,in:Lu(e),out:t})}var sd=Fu([`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`]),cd=Fu([`full`,`collapsed`]),ld=Fu([`pending`,`burning`,`done`,`failed`,`cancelled`]),ud=Fu([`ideation`,`qa`,`waypoint`,`converge`,`revisit`]),dd=Fu([`running`,`succeeded`,`failed`,`cancelled`]),fd=Fu([`active`,`shipped`]),pd=Fu([`launching`,`live`,`ended`]);Du({title:H(),goal:H(),context:H(),acceptanceCriteria:Tu(H()),seams:Tu(H()),blockedBy:Tu(pu())}).extend({id:H(),featureId:H(),seq:pu(),status:ld,commits:Tu(H()),error:H().optional(),attemptBranch:H().optional()});var md=Fu([`grilling`,`research`,`prototype`,`task`]),hd=Fu([`open`,`claimed`,`resolved`,`dropped`]);Fu([`resolved`,`dropped`]),Du({title:H(),type:md,question:H(),blockedBy:Tu(ku([pu(),H()])),originWaypointId:H().optional()}).extend({id:H(),featureId:H(),seq:pu(),blockedBy:Tu(pu()),status:hd,claimedBy:H().optional(),lastSessionId:H().optional(),summary:H().optional()}),Du({id:H(),name:H(),repoPath:H(),mainBranch:H(),devCommand:H().optional(),model:H().optional()}),Du({id:H(),projectId:H(),slug:H(),title:H(),oneLiner:H(),size:cd,mapped:_u(),phase:sd,branch:H(),baseBranch:H().optional(),status:fd,createdAt:pu()}),Du({id:H(),featureId:H(),kind:ud,ccSessionId:H().optional(),transcriptPath:H().optional(),status:pd,worktreePath:H()}),Du({id:H(),featureId:H(),workflow:H(),status:dd,startedAt:pu(),endedAt:pu().optional(),summary:H().optional()});var gd=Fu([`env`,`project`,`file`,`default`]),_d=Fu([`global`,`project`]),vd=Du({key:H(),value:xu(),source:gd,editable:_u(),restartRequired:_u(),scope:_d});Du({projectId:H().optional(),fields:Tu(vd)}),Du({projectId:H().optional(),key:H(),value:ku([H(),pu(),_u(),yu()])}),Du({id:pu(),projectId:H(),featureId:H().optional(),runId:H().optional(),ticketId:H().optional(),ts:pu(),type:H(),message:H(),data:xu().optional()});var yd=[{phase:`ideation`},{phase:`spec`,gateToEnter:{id:`G1`,description:`Decisions captured before writing a spec`,check:`decisions-file-exists`}},{phase:`tickets`,gateToEnter:{id:`G2`,description:`Spec written before breaking into tickets (auto-satisfied for collapsed features)`,check:`spec-file-exists`}},{phase:`implementation`,gateToEnter:{id:`G3`,description:`Tickets approved by a human (the Burn click)`,check:`tickets-approved`}},{phase:`review`,gateToEnter:{id:`G4`,description:`Every ticket reached a terminal state`,check:`all-tickets-terminal`}},{phase:`shipped`,gateToEnter:{id:`G5`,description:`Human merged the feature branch (the Merge click)`,check:`human-merge`}}].map(e=>e.phase);function bd(e){let t=yd.indexOf(e.phase);if(t<0||t>=yd.length-1)return null;let n=yd[t+1];return e.size===`collapsed`&&n===`spec`?yd[t+2]??null:n}var W=Symbol.for(`drizzle:entityKind`);function xd(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var Sd=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[W]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Cd=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},wd=Symbol.for(`drizzle:Name`),Td=Symbol.for(`drizzle:isPgEnum`);function Ed(e){return!!e&&typeof e==`function`&&Td in e&&e[Td]===!0}var G=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Dd={startActiveSpan(e,t){return t()}},Od=Symbol.for(`drizzle:ViewBaseConfig`),kd=Symbol.for(`drizzle:Schema`),Ad=Symbol.for(`drizzle:Columns`),jd=Symbol.for(`drizzle:ExtraConfigColumns`),Md=Symbol.for(`drizzle:OriginalName`),Nd=Symbol.for(`drizzle:BaseName`),Pd=Symbol.for(`drizzle:IsAlias`),Fd=Symbol.for(`drizzle:ExtraConfigBuilder`),Id=Symbol.for(`drizzle:IsDrizzleTable`),Ld=class{static[W]=`Table`;static Symbol={Name:wd,Schema:kd,OriginalName:Md,Columns:Ad,ExtraConfigColumns:jd,BaseName:Nd,IsAlias:Pd,ExtraConfigBuilder:Fd};[wd];[Md];[kd];[Ad];[jd];[Nd];[Pd]=!1;[Id]=!0;[Fd]=void 0;constructor(e,t,n){this[wd]=this[Md]=e,this[kd]=t,this[Nd]=n}};function Rd(e){return e!=null&&typeof e.getSQL==`function`}function zd(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var K=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Bd([this])}},Bd=class e{constructor(e){this.queryChunks=e;for(let t of e)if(xd(t,Ld)){let e=t[Ld.Symbol.Schema];this.usedTables.push(e===void 0?t[Ld.Symbol.Name]:e+`.`+t[Ld.Symbol.Name])}}static[W]=`SQL`;decoder=Hd;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Dd.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return zd(t.map(t=>{if(xd(t,K))return{sql:t.value.join(``),params:[]};if(xd(t,Vd))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new K(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new K(`, `));return e.push(new K(`)`)),this.buildQueryFromSourceParams(e,r)}if(xd(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(xd(t,Ld)){let e=t[Ld.Symbol.Schema],n=t[Ld.Symbol.Name];return{sql:e===void 0||t[Pd]?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Sd)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Ld.Symbol.Schema];return{sql:t.table[Pd]||r===void 0?a(t.table[Ld.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Ld.Symbol.Name])+`.`+a(e),params:[]}}if(xd(t,Jd)){let e=t[Od].schema,n=t[Od].name;return{sql:e===void 0||t[Od].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Wd)){if(xd(t.value,Kd))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(xd(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return xd(t,Kd)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:xd(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:xd(t,G)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new K(`(`),t._.sql,new K(`) `),new Vd(t._.alias)],r):Ed(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Rd(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new K(`(`),t.getSQL(),new K(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Vd=class{constructor(e){this.value=e}static[W]=`Name`;brand;getSQL(){return new Bd([this])}},Hd={mapFromDriverValue:e=>e},Ud={mapToDriverValue:e=>e};({...Hd,...Ud});var Wd=class{constructor(e,t=Ud){this.value=e,this.encoder=t}static[W]=`Param`;brand;getSQL(){return new Bd([this])}};function Gd(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new K(e[0]));for(let[r,i]of t.entries())n.push(i,new K(e[r+1]));return new Bd(n)}(e=>{function t(){return new Bd([])}e.empty=t;function n(e){return new Bd(e)}e.fromList=n;function r(e){return new Bd([new K(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Bd(n)}e.join=i;function a(e){return new Vd(e)}e.identifier=a;function o(e){return new Kd(e)}e.placeholder=o;function s(e,t){return new Wd(e,t)}e.param=s})(Gd||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[W]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Bd||={});var Kd=class{constructor(e){this.name=e}static[W]=`Placeholder`;getSQL(){return new Bd([this])}},qd=Symbol.for(`drizzle:IsDrizzleView`),Jd=class{static[W]=`View`;[Od];[qd]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Od]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Bd([this])}};Sd.prototype.getSQL=function(){return new Bd([this])},Ld.prototype.getSQL=function(){return new Bd([this])},G.prototype.getSQL=function(){return new Bd([this])};function Yd(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var Xd=typeof TextDecoder>`u`?null:new TextDecoder,Zd=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new Qd(e,this)}},Qd=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[wd],...r,n[0].table[wd],...i];return e??`${a.join(`_`)}_fk`}};function $d(e,t){return`${e[wd]}_${t.join(`_`)}_unique`}var ef=class extends Cd{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new Zd(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},tf=class extends Sd{constructor(e,t){t.uniqueName||=$d(e,[t.name]),super(e,t),this.table=e}static[W]=`SQLiteColumn`},nf=class extends ef{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new rf(e,this.config)}},rf=class extends tf{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},af=class extends ef{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new of(e,this.config)}},of=class extends tf{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},sf=class extends ef{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new cf(e,this.config)}},cf=class extends tf{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function lf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`json`?new af(n):r?.mode===`bigint`?new nf(n):new sf(n)}var uf=class extends ef{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new df(e,this.config)}},df=class extends tf{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function ff(e){return(t,n)=>{let{name:r,config:i}=Yd(t,n);return new uf(r,i,e)}}var pf=class extends ef{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},mf=class extends tf{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},hf=class extends pf{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new gf(e,this.config)}},gf=class extends mf{static[W]=`SQLiteInteger`},_f=class extends pf{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Gd`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new vf(e,this.config)}},vf=class extends mf{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},yf=class extends pf{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new bf(e,this.config)}},bf=class extends mf{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function xf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new _f(n,r.mode):r?.mode===`boolean`?new yf(n,r.mode):new hf(n)}var Sf=class extends ef{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Cf(e,this.config)}},Cf=class extends tf{static[W]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},wf=class extends ef{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new Tf(e,this.config)}},Tf=class extends tf{static[W]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Ef=class extends ef{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Df(e,this.config)}},Df=class extends tf{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Of(e,t){let{name:n,config:r}=Yd(e,t),i=r?.mode;return i===`number`?new wf(n):i===`bigint`?new Ef(n):new Sf(n)}var kf=class extends ef{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Af(e,this.config)}},Af=class extends tf{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function jf(e){return new kf(e??``)}var Mf=class extends ef{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Nf(e,this.config)}},Nf=class extends tf{static[W]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Pf=class extends ef{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new Ff(e,this.config)}},Ff=class extends tf{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function q(e,t={}){let{name:n,config:r}=Yd(e,t);return r.mode===`json`?new Pf(n):new Mf(n,r)}function If(){return{blob:lf,customType:ff,integer:xf,numeric:Of,real:jf,text:q}}var Lf=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Rf=class extends Ld{static[W]=`SQLiteTable`;static Symbol=Object.assign({},Ld.Symbol,{InlineForeignKeys:Lf});[Ld.Symbol.Columns];[Lf]=[];[Ld.Symbol.ExtraConfigBuilder]=void 0};function zf(e,t,n,r,i=e){let a=new Rf(e,r,i),o=typeof t==`function`?t(If()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Lf].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Ld.Symbol.Columns]=s,c[Ld.Symbol.ExtraConfigColumns]=s,n&&(c[Rf.Symbol.ExtraConfigBuilder]=n),c}var Bf=(e,t,n)=>zf(e,t,n);Bf(`projects`,{id:q(`id`).primaryKey(),name:q(`name`).notNull(),repoPath:q(`repo_path`).notNull(),mainBranch:q(`main_branch`).notNull(),devCommand:q(`dev_command`),model:q(`model`),sandbox:q(`sandbox`),closedAt:xf(`closed_at`)}),Bf(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),size:q(`size`).notNull().$type(),mapped:xf(`mapped`,{mode:`boolean`}).notNull().default(!1),phase:q(`phase`).notNull().$type(),branch:q(`branch`).notNull(),baseBranch:q(`base_branch`),status:q(`status`).notNull().$type(),createdAt:xf(`created_at`).notNull()}),Bf(`sessions`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),kind:q(`kind`).notNull().$type(),ccSessionId:q(`cc_session_id`),transcriptPath:q(`transcript_path`),status:q(`status`).notNull().$type(),worktreePath:q(`worktree_path`).notNull()}),Bf(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),goal:q(`goal`).notNull(),context:q(`context`).notNull(),acceptanceCriteria:q(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:q(`seams`,{mode:`json`}).notNull().$type(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),status:q(`status`).notNull().$type(),commits:q(`commits`,{mode:`json`}).notNull().$type(),error:q(`error`),attemptBranch:q(`attempt_branch`)}),Bf(`waypoints`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),type:q(`type`).notNull().$type(),question:q(`question`).notNull(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),originWaypointId:q(`origin_waypoint_id`),status:q(`status`).notNull().$type(),claimedBy:q(`claimed_by`),lastSessionId:q(`last_session_id`),summary:q(`summary`)}),Bf(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:xf(`started_at`).notNull(),endedAt:xf(`ended_at`),summary:q(`summary`)}),Bf(`events`,{id:xf(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:xf(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})}),Bf(`gate_overrides`,{id:xf(`id`).primaryKey({autoIncrement:!0}),featureId:q(`feature_id`).notNull(),gate:q(`gate`).notNull(),reason:q(`reason`).notNull(),ts:xf(`ts`).notNull()});var Vf=[`ideation`,`qa`,`waypoint`,`converge`,`revisit`,`research`,`implement`,`smoke`],Hf=Fu(Vf),Uf=[{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-sonnet-5`,label:`Sonnet 5`},{id:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`},{id:`claude-fable-5`,label:`Fable 5`}];od(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=t.smokeModel;if(typeof n==`string`&&n.length>0){let e=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?t.stepModels:{};e.smoke===void 0&&(t.stepModels={...e,smoke:n})}return delete t.smokeModel,t},Du({serverPort:pu().default(4512),model:H().default(`claude-opus-4-8`),stepModels:Nu(Hf,H()).default({smoke:`claude-haiku-4-5-20251001`}),sandbox:Fu([`docker`,`podman`,`noSandbox`]).default(`docker`),mainBranch:H().default(`main`),sandboxImage:H().optional(),burnConcurrency:pu().int().min(1).max(8).default(3),burnMaxIterations:pu().int().min(1).max(10).default(3),burnAttempts:pu().int().min(1).max(5).default(3),setupCommand:H().optional(),burnWorkspace:Fu([`auto`,`mounted`,`isolated`]).default(`auto`)}));var Wf=[`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`];function Gf(e){switch(e){case`ideation`:return`◉`;case`spec`:return`◐`;case`tickets`:return`▤`;case`implementation`:return`⚙`;case`review`:return`◆`;case`shipped`:return`✓`}}function Kf(e){return e.status===`shipped`||e.activeRun?null:e.ticketCounts.failed>0?{kind:`attention`,label:`run failed — needs attention`}:e.phase===`ideation`?{kind:`grill`,label:`needs grilling`}:e.phase===`tickets`&&e.ticketCounts.total>0?{kind:`burn`,label:`review & burn tickets`}:e.phase===`review`?{kind:`ship`,label:`test & merge`}:null}function qf(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}var Jf={ideation:`ideation`,spec:`spec`,tickets:`tickets`,implementation:`build`,review:`review`,shipped:`shipped`},Yf={ideation:`Shape the idea in a grill session`,spec:`Write it up as a spec`,tickets:`Break the work into atomic tickets`,implementation:`Burn the tickets into commits`,review:`Test-drive the branch, then merge`,shipped:`Merged to the main branch`};function Xf(e){return Wf.indexOf(e)}function Zf(e){return e.size===`collapsed`}function Qf(e){return e.status===`shipped`?`shipped`:e.activeRun?`agentWorking`:Kf(e)?`needsYou`:`inProgress`}function $f(e){let t={needsYou:[],agentWorking:[],inProgress:[],shipped:[]};for(let n of e)t[Qf(n)].push(n);return[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`shipped`,label:`Shipped`}].map(({key:e,label:n})=>({key:e,label:n,features:t[e]})).filter(e=>e.features.length>0)}function ep(e,t){if(Zf(e)&&t===`spec`)return`skipped`;let n=Xf(e.phase),r=Xf(t);return r<n?`done`:r===n?`current`:`upcoming`}function tp(e){return Wf.map(t=>({phase:t,state:ep(e,t)}))}function np(e,t){return t??e.phase}function rp(e,t){return Xf(t)<Xf(e.phase)}function ip(e,t){return Wf.map(n=>{let r=ep(e,n);return{phase:n,label:Jf[n],state:r,isViewed:n===t,clickable:r===`done`||r===`current`,tip:Yf[n]}})}function ap(e,t){let{feature:n,tickets:r,sessions:i,runs:a,gate:o}=e,s=i.find(e=>e.status===`live`),c=r.length,l=r.filter(e=>e.status===`done`).length,u=r.filter(e=>e.status===`failed`).length,d=qf(a),f=d?.status===`running`,p=bd(n),m=!!o.next&&o.satisfied&&o.next.id!==`G3`&&o.next.id!==`G5`,h=p?`Promote to ${Jf[p]}`:`Promote`;switch(n.phase){case`ideation`:return n.mapped?{kick:`MAP`,title:o.satisfied?`Converge the map`:`Work the frontier`,desc:o.satisfied?`Every waypoint is resolved — converge to draft the spec and tickets.`:o.reason??`Resolve the open waypoints; converge once the frontier clears.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:void 0,secondary:[],busy:!1}:m?{kick:`NEXT STEP`,title:`Promote the idea`,desc:`Decisions are captured — promote the idea when it feels concrete.`,primary:{label:h,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Grill session in progress`,desc:`Shape the idea with Claude — decisions accumulate in Knowledge.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Shape the idea with Claude`,desc:`Launch a grill session to shape the idea before any code is written.`,primary:{label:`Start grill session`,kind:`startGrill`},secondary:[],busy:!1};case`spec`:return m?{kick:`NEXT STEP`,title:`Approve the spec`,desc:`The spec is written — approve it to move into tickets.`,primary:{label:`Approve spec → tickets`,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Writing the spec`,desc:`The spec takes shape beside the conversation.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Write the spec`,desc:`No spec yet — resume the grill to draft it.`,primary:{label:`Resume grill`,kind:`startGrill`},secondary:[],busy:!1};case`tickets`:return c>0?{kick:`NEXT STEP`,title:`Review & burn the tickets`,desc:`Each ticket is one atomic task Claude will implement. Review them, then burn.`,primary:{label:`Burn ${c} ticket${c===1?``:`s`}`,kind:`burn`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[{label:`Revisit`,kind:`revisit`}],busy:!1}:{kick:`WAITING`,title:`Waiting for tickets`,desc:`No tickets yet — a grill session emits them. Open a session to shape the work.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:{label:`Open grill to emit tickets`,kind:`startGrill`},secondary:[],busy:!1};case`implementation`:return f?{kick:`IN PROGRESS`,title:`Burning tickets`,desc:`Burning ${c} ticket${c===1?``:`s`} — ${l} done${u?`, ${u} failed`:``}.`,primary:{label:`Cancel run`,kind:`cancelRun`,danger:!0},secondary:[],busy:!0}:{kick:`NEXT STEP`,title:`Resume the burn`,desc:d?.status===`failed`?`The run failed — resume the burn to retry.`:d?.status===`cancelled`?`The run was cancelled — resume the burn to continue.`:`The burn has not started — resume to run the tickets.`,primary:{label:`Resume burn`,kind:`burn`},secondary:s?[]:[{label:`Revisit`,kind:`revisit`}],busy:!1};case`review`:{let e=t.driving?`Test-driving the branch — merge when it looks right.`:u>0?`Run finished with ${u} failed ticket${u===1?``:`s`} — review, then ship.`:`Checks are in. Test-drive the branch, then merge to ship.`;return{kick:`NEXT STEP`,title:t.driving?`Merge when it looks right`:`Test drive, then ship`,desc:e,primary:{label:`Merge & ship`,kind:`merge`},secondary:t.driving?[{label:`Stop test drive`,kind:`testDriveStop`}]:[{label:`Start test drive`,kind:`testDriveStart`}],busy:!1}}case`shipped`:return{kick:`SHIPPED`,title:`Shipped to main`,desc:`The branch is merged and the pipeline is complete. Ask a question anytime.`,primary:void 0,secondary:[{label:`Ask a question`,kind:`askQuestions`}],busy:!1}}}function op({projectId:e,selectedFeatureId:t,onSelect:n,onNewFeature:r}){let i=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),a=$f(i.data??[]);return(0,O.jsxs)(`nav`,{className:`sidebar`,children:[(0,O.jsxs)(`div`,{className:`sidebar-head`,children:[(0,O.jsx)(`span`,{className:`pane-title`,children:`Features`}),(0,O.jsx)(`button`,{className:`new-btn`,onClick:r,children:`+ New`})]}),(0,O.jsxs)(`div`,{className:`sidebar-list`,children:[i.isLoading&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`loading features…`})}),i.data&&i.data.length===0&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`no features yet — + New to begin`})}),a.map(e=>(0,O.jsxs)(`div`,{className:`triage-group triage-${e.key}`,children:[(0,O.jsxs)(`div`,{className:`triage-label`,children:[(0,O.jsx)(`span`,{className:`triage-name`,children:e.label}),(0,O.jsx)(`span`,{className:`triage-count`,children:e.features.length})]}),e.features.map(e=>(0,O.jsx)(sp,{f:e,active:e.id===t,onSelect:n},e.id))]},e.key))]}),(0,O.jsx)(`div`,{className:`sidebar-foot`,children:`Every feature moves through the same six-phase pipeline. Amber means it's waiting on you.`})]})}function sp({f:e,active:t,onSelect:n}){let r=Kf(e),i=tp(e);return(0,O.jsxs)(`button`,{className:`feature-row${t?` is-active`:``}${e.status===`shipped`?` is-shipped`:``}`,onClick:()=>n(e.id),title:e.title,children:[(0,O.jsx)(`span`,{className:`feature-glyph phase-fg-${e.phase}`,children:Gf(e.phase)}),(0,O.jsx)(`span`,{className:`feature-slug mono`,children:e.slug}),(0,O.jsx)(`span`,{className:`feature-flag`,children:e.activeRun?(0,O.jsx)(`span`,{className:`spin-ring`,title:`agent working`}):e.status===`shipped`?(0,O.jsx)(`span`,{className:`mini-check`,children:`✓`}):(0,O.jsxs)(O.Fragment,{children:[r&&(0,O.jsx)(`span`,{className:`needs-dot needs-${r.kind}`,title:r.label}),(0,O.jsx)(`span`,{className:`mini-map`,children:i.map((e,t)=>(0,O.jsx)(`span`,{className:`mini-seg is-${e.state}`},t))})]})})]})}var cp=(0,D.createContext)(null);function lp({children:e}){let[t,n]=(0,D.useState)([]),r=(0,D.useCallback)((e,t=`error`)=>{let r=Date.now()+Math.random();n(n=>[...n,{id:r,kind:t,message:e}]),setTimeout(()=>n(e=>e.filter(e=>e.id!==r)),6e3)},[]);return(0,O.jsxs)(cp.Provider,{value:{push:r},children:[e,(0,O.jsx)(`div`,{className:`toasts`,children:t.map(e=>(0,O.jsx)(`div`,{className:`toast toast-${e.kind}`,onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),children:e.message},e.id))})]})}function up(){let e=(0,D.useContext)(cp);if(!e)throw Error(`useToast used outside ToastProvider`);return e}function dp(e){let[t,n]=(0,D.useState)([]),r=t.length?t[t.length-1].id:void 0,i=j.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:1500});return(0,D.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}function fp(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pp(e){return e.slice(0,7)}function mp(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function hp(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${String(i).padStart(2,`0`)}m`:i>0?`${i}m ${String(a).padStart(2,`0`)}s`:`${a}s`}function gp({featureId:e,relPath:t,title:n,onClose:r}){let i=j.docs.read.useQuery({featureId:e,relPath:t});return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,O.jsx)(`div`,{className:`peek-backdrop`,onClick:r,children:(0,O.jsxs)(`div`,{className:`peek`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`peek-head`,children:[(0,O.jsx)(`span`,{className:`mono peek-path`,children:t}),(0,O.jsx)(`button`,{className:`peek-close`,onClick:r,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,O.jsxs)(`div`,{className:`peek-body mono`,children:[i.isLoading&&(0,O.jsxs)(M,{children:[`loading `,n,`…`]}),i.error&&(0,O.jsxs)(M,{children:[`could not read `,t,`: `,i.error.message]}),i.data&&(0,O.jsx)(`pre`,{className:`peek-pre`,children:i.data.content})]})]})})}function _p({featureId:e}){let t=j.feature.get.useQuery({id:e},{refetchInterval:1500});return t.isLoading?(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:`loading…`})}):t.data?(0,O.jsxs)(`aside`,{className:`inspector`,children:[(0,O.jsx)(bp,{featureId:e,gate:t.data.gate}),(0,O.jsx)(Cp,{featureId:e,docs:t.data.docs}),(0,O.jsx)(wp,{featureId:e})]}):(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:t.error?.message??`could not load inspector`})})}var vp={G1:`Decisions captured`,G2:`Spec written`,G3:`Tickets approved`,G4:`Run clean`,G5:`Merged`};function yp(e){return e.check===`all-waypoints-terminal`?`Waypoints resolved`:vp[e.id]??e.id}function bp({featureId:e,gate:t}){let n=up(),r=j.useUtils(),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(``),c=j.feature.overrideGate.useMutation({onSuccess:()=>{s(``),a(!1),r.feature.get.invalidate({id:e}),r.feature.list.invalidate()},onError:e=>n.push(e.message)});return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Current gate`}),t.next===null?(0,O.jsx)(`div`,{className:`gate-empty`,children:`No gate — this feature is shipped.`}):(0,O.jsx)(xp,{gateId:t.next.id,name:yp(t.next),description:t.next.description,satisfied:t.satisfied,reason:t.reason,open:i,reasonValue:o,pending:c.isPending,onOpen:()=>a(!0),onCancel:()=>{a(!1),s(``)},onReasonChange:s,onApply:()=>c.mutate({featureId:e,gate:t.next.id,reason:o.trim()})})]})}function xp({gateId:e,name:t,description:n,satisfied:r,reason:i,open:a,reasonValue:o,pending:s,onOpen:c,onCancel:l,onReasonChange:u,onApply:d}){return(0,O.jsxs)(`div`,{className:`gate-card`,children:[(0,O.jsxs)(`div`,{className:`gate-idrow`,children:[(0,O.jsx)(`span`,{className:`gate-id`,children:e}),(0,O.jsx)(`span`,{className:`gate-name`,children:t})]}),(0,O.jsx)(`div`,{className:`gate-req`,children:n}),(0,O.jsxs)(`div`,{className:`gate-state ${r?`is-ok`:`is-block`}`,children:[(0,O.jsx)(`span`,{className:`gate-state-dot`}),(0,O.jsx)(`span`,{children:r?`ready to advance`:i??`blocked`})]}),a?(0,O.jsxs)(`div`,{className:`override-form`,children:[(0,O.jsx)(`input`,{className:`override-input`,placeholder:`reason for override`,value:o,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(Ci,{variant:`solid`,className:`btn-xs`,disabled:!o.trim()||s,onClick:d,children:`Apply`}),(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:l,children:`Cancel`})]})]}):(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:c,children:`Override with reason…`}),(0,O.jsx)(`div`,{className:`gate-hint`,children:`The highlighted action in the workspace advances this gate.`})]})}function Sp(e){return e.split(/[\\/]/).pop()??e}function Cp({featureId:e,docs:t}){let[n,r]=(0,D.useState)(null);return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Knowledge`}),t.length===0?(0,O.jsx)(M,{children:`no docs yet`}):(0,O.jsx)(`ul`,{className:`doc-list`,children:t.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{className:`doc-link`,onClick:()=>r({relPath:e.relPath,title:e.title}),children:[(0,O.jsx)(`span`,{className:`doc-title`,children:e.title}),(0,O.jsx)(`span`,{className:`doc-meta`,children:Sp(e.relPath)})]})},e.relPath))}),n&&(0,O.jsx)(gp,{featureId:e,relPath:n.relPath,title:n.title,onClose:()=>r(null)})]})}function wp({featureId:e}){let t=dp(e).slice(-12).reverse();return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Activity`}),t.length===0?(0,O.jsx)(M,{children:`no activity yet`}):(0,O.jsx)(`div`,{className:`activity-log`,children:t.map(e=>(0,O.jsxs)(`div`,{className:`act-line`,children:[(0,O.jsx)(`span`,{className:`act-time`,children:mp(e.ts)}),(0,O.jsxs)(`div`,{className:`act-body`,children:[(0,O.jsx)(`div`,{className:`act-type`,children:e.type}),(0,O.jsx)(`div`,{className:`act-msg`,children:e.message})]})]},e.id))})]})}var Tp=`docker`,Ep=4512;function Dp({projectId:e,activeFeatureId:t,driving:n,onDriveChange:r}){let i=up(),a=j.useUtils(),o=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),s=!o.isError&&o.data!==void 0,c=o.data?.find(e=>e.id===t),l=o.data?.filter(e=>e.activeRun).length??0,u=j.feature.testDrive.useMutation({onSuccess:()=>{r(null),n&&a.feature.get.invalidate({id:n.featureId}),a.feature.list.invalidate()},onError:e=>i.push(e.message)});return(0,O.jsxs)(`footer`,{className:`statusbar`,children:[c&&(0,O.jsxs)(`button`,{className:`sb-branch`,onClick:()=>{c&&navigator.clipboard.writeText(c.branch).then(()=>i.push(`copied ${c.branch}`,`info`),()=>i.push(`copy failed`))},title:`copy branch`,children:[`⎇ `,c.branch]}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[`sandbox · `,Tp]}),n&&(0,O.jsxs)(`span`,{className:`sb-driving`,children:[(0,O.jsx)(`span`,{className:`sb-driving-dot`}),`driving `,(0,O.jsx)(`span`,{className:`mono`,children:n.branch}),(0,O.jsx)(`button`,{className:`sb-stop`,disabled:u.isPending,onClick:()=>u.mutate({featureId:n.featureId,action:`stop`}),children:`stop`})]}),(0,O.jsx)(`span`,{className:`sb-spacer`}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[l,` run`,l===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`sb-item sb-health ${s?`is-ok`:`is-down`}`,children:[(0,O.jsx)(`span`,{className:`health-dot`}),`:`,Ep,` `,s?`ok`:`down`]})]})}function Op({featureId:e,sessionId:t}){let n=j.useUtils(),r=up(),i=j.feature.endSession.useMutation({onSuccess:()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),r.push(`session ended`,`info`)},onError:e=>r.push(e.message)});return(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost sess-end`,disabled:i.isPending,title:`end this session — recoverable, you can relaunch it`,onClick:()=>i.mutate({sessionId:t}),children:i.isPending?`Ending…`:`End session`})}var kp=class extends D.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[runcastle] boundary caught`,e,t)}render(){return this.state.error?(0,O.jsx)(`div`,{className:`boundary-fallback`,children:(0,O.jsxs)(`span`,{className:`dim-line mono`,children:[this.props.label??`component`,` failed: `,this.state.error.message]})}):this.props.children}},Ap=2,jp=1,Mp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Ap,Math.floor(u/e.css.cell.width)),rows:Math.max(jp,Math.floor(l/e.css.cell.height))}}},Np=Object.defineProperty,Pp=Object.getOwnPropertyDescriptor,Fp=(e,t)=>{for(var n in t)Np(e,n,{get:t[n],enumerable:!0})},Ip=(e,t,n,r)=>{for(var i=r>1?void 0:r?Pp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Np(t,n,i),i},J=(e,t)=>(n,r)=>t(n,r,e),Lp=`Terminal input`,Rp={get:()=>Lp,set:e=>Lp=e},zp=`Too much output to announce, navigate to rows manually to read`,Bp={get:()=>zp,set:e=>zp=e};function Vp(e){return e.replace(/\r?\n/g,`\r`)}function Hp(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Up(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Wp(e,t,n,r){e.stopPropagation(),e.clipboardData&&Gp(e.clipboardData.getData(`text/plain`),t,n,r)}function Gp(e,t,n,r){e=Vp(e),e=Hp(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Kp(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function qp(e,t,n,r,i){Kp(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Jp(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Yp(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Xp=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Zp=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Qp=``,$p=` `,em=class e{constructor(){this.fg=0,this.bg=0,this.extended=new tm}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},tm=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},nm=class e extends em{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new tm,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Jp(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rm=`di$target`,im=`di$dependencies`,am=new Map;function om(e){return e[im]||[]}function sm(e){if(am.has(e))return am.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);cm(t,e,r)};return t._id=e,am.set(e,t),t}function cm(e,t,n){t[rm]===t?t[im].push({id:e,index:n}):(t[im]=[{id:e,index:n}],t[rm]=t)}var lm=sm(`BufferService`),um=sm(`CoreMouseService`),dm=sm(`CoreService`),fm=sm(`CharsetService`),pm=sm(`InstantiationService`),mm=sm(`LogService`),hm=sm(`OptionsService`),gm=sm(`OscLinkService`),_m=sm(`UnicodeService`),vm=sm(`DecorationService`),ym=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new nm,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):bm(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ym=Ip([J(0,lm),J(1,hm),J(2,gm)],ym);function bm(e,t){if(confirm(`Do you want to navigate to ${t}?
73
73
 
74
74
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var xm=sm(`CharSizeService`),Sm=sm(`CoreBrowserService`),Cm=sm(`MouseService`),wm=sm(`RenderService`),Tm=sm(`SelectionService`),Em=sm(`CharacterJoinerService`),Dm=sm(`ThemeService`),Om=sm(`LinkProviderService`),km=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Fm.isErrorNoTelemetry(e)?new Fm(e.message+`
75
75
 
@@ -105,4 +105,5 @@ ${s.join(`
105
105
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===jx+1&&(this._liveRegion.textContent+=Bp.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Mx=Ip([J(1,pm),J(2,Sm),J(3,wm)],Mx);var Nx=class extends Y{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new X),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new X),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(nh(()=>{eh(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Z(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Z(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Z(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Z(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Px(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,eh(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Nx=Ip([J(1,Cm),J(2,wm),J(3,lm),J(4,Om)],Nx);function Px(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Fx=class extends bx{constructor(e={}){super(e),this._linkifier=this._register(new ah),this.browser=Jv,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ah),this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new X),this.onKey=this._onKey.event,this._onRender=this._register(new X),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new X),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new X),this.onBell=this._onBell.event,this._onFocus=this._register(new X),this._onBlur=this._register(new X),this._onA11yCharEmitter=this._register(new X),this._onA11yTabEmitter=this._register(new X),this._onWillOpen=this._register(new X),this._setup(),this._decorationService=this._instantiationService.createInstance(Dx),this._instantiationService.setService(vm,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Uv),this._instantiationService.setService(Om,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ym)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(fh.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(fh.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(fh.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(fh.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(nh(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=dv.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${ix(r)}${rv.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=uv.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=uv.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Mx,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Z(this.element,`copy`,e=>{this.hasSelection()&&Up(e,this._selectionService)}));let e=e=>Wp(e,this.textarea,this.coreService,this.optionsService);this._register(Z(this.textarea,`paste`,e)),this._register(Z(this.element,`paste`,e)),Qv?this._register(Z(this.element,`mousedown`,e=>{e.button===2&&qp(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Z(this.element,`contextmenu`,e=>{qp(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),oy&&this._register(Z(this.element,`auxclick`,e=>{e.button===1&&Kp(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Z(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Z(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Z(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Z(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Z(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Z(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Z(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(Z(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Rp.get()),sy||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Vv,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Sm,this._coreBrowserService),this._register(Z(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Z(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Lv,this._document,this._helperContainer),this._instantiationService.setService(xm,this._charSizeService),this._themeService=this._instantiationService.createInstance(Gy),this._instantiationService.setService(Dm,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vv),this._instantiationService.setService(Em,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(py,this.rows,this.screenElement)),this._instantiationService.setService(wm,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(iv,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Kv),this._instantiationService.setService(Cm,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Nx,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Y_,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Fy,this.element,this.screenElement,r)),this._instantiationService.setService(Tm,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(fh.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(X_,this.screenElement)),this._register(Z(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Mx,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(tv,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(tv,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Iv,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Z(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Z(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Gp(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=Sx(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Q.ETX||n.key===Q.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Ix(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(eb));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Q.ESC+`[I`):this.coreService.triggerDataEvent(Q.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Ix(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Lx=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Rx=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new nm)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},zx=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Rx(t)}getNullCell(){return new nm}},Bx=class extends Y{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new X),this.onBufferChange=this._onBufferChange.event,this._normal=new zx(this._core.buffers.normal,`normal`),this._alternate=new zx(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Vx=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Hx=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Ux=[`cols`,`rows`],Wx=0,Gx=class extends Y{constructor(e){super(),this._core=this._register(new Fx(e)),this._addonManager=this._register(new Lx),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(Ux.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new Vx(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Hx(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new Bx(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
106
106
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Rp.get()},set promptLabel(e){Rp.set(e)},get tooMuchOutput(){return Bp.get()},set tooMuchOutput(e){Bp.set(e)}}}_verifyIntegers(...e){for(Wx of e)if(Wx===1/0||isNaN(Wx)||Wx%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Wx of e)if(Wx&&(Wx===1/0||isNaN(Wx)||Wx%1!=0||Wx<0))throw Error(`This API only accepts positive integers`)}},Kx=250,qx=5e3,Jx=8e3,Yx=3e3;function Xx(e){return`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}`}function Zx(){return Xx(window.location)}var Qx=class{opts;ws=null;backoff=Kx;reconnectTimer=null;connectTimer=null;stallTimer=null;disposed=!1;ended=!1;receivedData=!1;url;constructor(e){this.opts=e;let t=e.wsBase??Zx();this.url=`${t.replace(/\/$/,``)}/ws/terminal/${encodeURIComponent(e.sessionId)}`}connect(){if(this.disposed||this.ended)return;this.clearTimer(),this.opts.onStatus(this.backoff===Kx?`connecting`:`reconnecting`);let e=new WebSocket(this.url);e.binaryType=`arraybuffer`,this.ws=e,this.connectTimer=setTimeout(()=>{e.readyState===WebSocket.CONNECTING&&this.forceClose(e)},Jx),e.onopen=()=>{this.clearConnectTimer(),this.receivedData&&(this.receivedData=!1,this.opts.onReset?.())},e.onmessage=e=>{typeof e.data==`string`?this.handleControl(e.data):(this.receivedData=!0,this.opts.onData(new Uint8Array(e.data)))},e.onclose=()=>{this.ws=null,this.clearConnectTimer(),this.clearStallTimer(),!(this.disposed||this.ended)&&(this.opts.onStatus(`reconnecting`),this.scheduleReconnect())},e.onerror=()=>{this.forceClose(e)}}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.send(new TextEncoder().encode(e)),this.watchForStall())}resize(e,t){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.send(JSON.stringify({t:`resize`,cols:e,rows:t})),this.watchForStall())}dispose(){if(this.disposed=!0,this.clearTimer(),this.clearConnectTimer(),this.clearStallTimer(),this.ws){this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null;try{this.ws.close()}catch{}this.ws=null}}handleControl(e){let t;try{t=JSON.parse(e)}catch{return}t.t===`status`&&(t.status===`live`?(this.backoff=Kx,this.opts.onStatus(`live`)):t.status===`ended`&&(this.ended=!0,this.opts.onStatus(`ended`)))}watchForStall(){this.stallTimer===null&&(this.stallTimer=setTimeout(()=>{this.stallTimer=null;let e=this.ws;!e||e.readyState!==WebSocket.OPEN||e.bufferedAmount>0&&this.forceClose(e)},Yx))}forceClose(e){try{e.close()}catch{}if(this.ws===e&&e.readyState===WebSocket.CLOSED){if(e.onclose=null,this.ws=null,this.disposed||this.ended)return;this.opts.onStatus(`reconnecting`),this.scheduleReconnect()}}scheduleReconnect(){this.clearTimer();let e=this.backoff;this.backoff=Math.min(this.backoff*2,qx),this.reconnectTimer=setTimeout(()=>this.connect(),e)}clearTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}clearConnectTimer(){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null)}clearStallTimer(){this.stallTimer!==null&&(clearTimeout(this.stallTimer),this.stallTimer=null)}},$x={background:`#0A0C0F`,foreground:`#C9D1D9`,cursor:`#8B5CF6`,cursorAccent:`#0A0C0F`,selectionBackground:`rgba(139,92,246,0.25)`};function eS({sessionId:e,wsBase:t}){let n=(0,D.useRef)(null),[r,i]=(0,D.useState)(`connecting`);(0,D.useEffect)(()=>{let r=n.current;if(!r)return;let a=new Gx({theme:$x,fontFamily:`"Cascadia Code", "JetBrains Mono", Consolas, monospace`,fontSize:12.5,cursorBlink:!0,allowProposedApi:!0,scrollback:5e3}),o=new Mp;a.loadAddon(o),a.open(r);let s=()=>{try{o.fit()}catch{}};s();let c=requestAnimationFrame(s),l;l=new Qx({sessionId:e,wsBase:t,onData:e=>a.write(e),onReset:()=>a.reset(),onStatus:e=>{i(e),e===`live`&&l.resize(a.cols,a.rows)}});let u=a.onData(e=>l.send(e)),d=a.onResize(({cols:e,rows:t})=>l.resize(e,t));l.connect();let f=new ResizeObserver(()=>s());return f.observe(r),()=>{cancelAnimationFrame(c),f.disconnect(),u.dispose(),d.dispose(),l.dispose(),a.dispose()}},[e,t]);let a=r===`connecting`?{text:`connecting…`,tone:`dim`}:r===`reconnecting`?{text:`disconnected — reconnecting… keystrokes are dropped until the stream is back`,tone:`down`}:r===`ended`?{text:`session stream ended — relaunch or end the session above`,tone:`dim`}:null;return(0,O.jsxs)(`div`,{style:{position:`relative`,width:`100%`,height:`100%`,background:`#0A0C0F`,overflow:`hidden`},children:[(0,O.jsx)(`div`,{ref:n,style:{width:`100%`,height:`100%`},"data-session-id":e}),a&&(0,O.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,right:0,fontFamily:`"Cascadia Code", "JetBrains Mono", Consolas, monospace`,fontSize:11,padding:`4px 10px`,pointerEvents:`none`,color:a.tone===`down`?`#F4594E`:`#8B949E`,background:a.tone===`down`?`rgba(244,89,78,0.10)`:`rgba(14,17,22,0.85)`,borderBottom:`1px solid ${a.tone===`down`?`rgba(244,89,78,0.4)`:`#1A2028`}`},children:a.text})]})}function tS({full:e,effective:t}){let{feature:n,sessions:r,docs:i}=e,a=[...r].reverse(),o=a.find(e=>e.status===`live`||e.status===`launching`)??a[0],s=i.find(e=>e.relPath.endsWith(`spec.md`)),c=n.mapped?i.find(e=>e.relPath.endsWith(`map.md`)):void 0,l=r.some(e=>e.status===`live`||e.status===`launching`),u=n.mapped&&n.phase===`spec`&&t===`spec`&&!l&&e.tickets.length===0;return(0,O.jsxs)(`div`,{className:`grill`,children:[n.mapped&&(0,O.jsx)(iS,{full:e,relPath:c?.relPath}),t===`spec`&&(s?(0,O.jsx)(cS,{featureId:n.id,relPath:s.relPath}):(0,O.jsx)(`div`,{className:`spec-doc`,children:(0,O.jsx)(M,{children:`spec not written yet — continue the grill to draft it`})})),(0,O.jsxs)(`div`,{className:`body-title`,style:{marginTop:t===`spec`?18:0},children:[(0,O.jsx)(wi,{children:n.size===`collapsed`?`Session`:`Grill session`}),(0,O.jsx)(`span`,{className:`body-hint`,children:`— shape the idea with Claude; promote it when it feels concrete`})]}),(0,O.jsx)(`div`,{className:`grill-panel`,children:o?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`grill-strip`,children:[(0,O.jsx)(`span`,{className:`grill-kind`,children:o.kind}),(0,O.jsx)(`span`,{className:`grill-sid`,children:o.ccSessionId??o.id}),(0,O.jsx)(Oi,{status:o.status}),(0,O.jsx)(`span`,{className:`grill-strip-spacer`}),(o.status===`live`||o.status===`launching`)&&(0,O.jsx)(Op,{featureId:n.id,sessionId:o.id})]}),(0,O.jsx)(`div`,{className:`grill-term`,id:`grill-term`,children:o.status===`ended`?(0,O.jsx)(`div`,{className:`grill-empty`,children:(0,O.jsx)(M,{children:`session ended — its decisions live in Knowledge`})}):(0,O.jsx)(kp,{label:`terminal`,children:(0,O.jsx)(eS,{sessionId:o.id})})})]}):(0,O.jsxs)(`div`,{className:`grill-empty`,children:[(0,O.jsx)(M,{children:`no grill session yet`}),(0,O.jsx)(`span`,{className:`body-hint`,children:`Start a session from the next step to shape the idea with Claude before any code.`})]})}),u&&(0,O.jsx)(nS,{featureId:n.id})]})}function nS({featureId:e}){let t=j.useUtils(),n=up(),r=j.feature.converge.useMutation({onSuccess:()=>{t.feature.get.invalidate({id:e}),t.feature.list.invalidate()},onError:e=>n.push(e.message)});return(0,O.jsxs)(`div`,{className:`converge-resume`,children:[(0,O.jsx)(M,{children:`the converge session ended before tickets were emitted`}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost`,disabled:r.isPending,title:`restart the converge session over map.md + decisions.md`,onClick:()=>r.mutate({featureId:e}),children:r.isPending?`Resuming…`:`Resume converge`})]})}var rS=[`Destination`,`Notes`,`Not yet specified`,`Out of scope`];function iS({full:e,relPath:t}){let n=e.feature.id,r=j.docs.read.useQuery({featureId:n,relPath:t??`map.md`},{enabled:!!t}),i=r.data?sS(r.data.content):{};return(0,O.jsxs)(`div`,{className:`map-panel`,children:[(0,O.jsxs)(`div`,{className:`body-title`,children:[(0,O.jsx)(wi,{children:`Map`}),(0,O.jsx)(`span`,{className:`body-hint`,children:`— chart the destination and open questions before diving in`})]}),r.isLoading&&(0,O.jsx)(M,{children:`loading map…`}),!t&&!r.isLoading&&(0,O.jsx)(M,{children:`map not scaffolded yet`}),t&&(0,O.jsx)(`div`,{className:`map-sections`,children:rS.map(e=>{let t=i[e]?.trim();return(0,O.jsxs)(`section`,{className:`map-section`,children:[(0,O.jsx)(`div`,{className:`map-section-title`,children:e}),t?(0,O.jsx)(`div`,{className:`map-section-body`,children:t}):(0,O.jsx)(M,{children:`—`})]},e)})}),(0,O.jsx)(oS,{featureId:n,waypoints:e.waypoints,frontierIds:e.frontierIds,sessions:e.sessions}),(0,O.jsx)(aS,{full:e,fog:i[`Not yet specified`]?.trim()})]})}function aS({full:e,fog:t}){let{feature:n,gate:r}=e,i=j.useUtils(),a=up(),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(``),u=j.feature.converge.useMutation({onSuccess:()=>{s(!1),l(``),i.feature.get.invalidate({id:n.id}),i.feature.list.invalidate()},onError:e=>a.push(e.message)});return n.phase!==`ideation`||r.next?.id!==`G1`?null:(0,O.jsxs)(`section`,{className:`converge-bar`,children:[t&&(0,O.jsxs)(`div`,{className:`converge-fog`,role:`note`,children:[(0,O.jsx)(`span`,{className:`converge-fog-icon`,"aria-hidden":`true`,children:`⚑`}),(0,O.jsxs)(`span`,{className:`converge-fog-text`,children:[`Fog remains — still not specified: `,t,`. You can converge anyway.`]})]}),r.satisfied?(0,O.jsx)(`button`,{type:`button`,className:`btn btn-solid converge-btn`,disabled:u.isPending,onClick:()=>u.mutate({featureId:n.id}),children:u.isPending?`Converging…`:`Converge`}):o?(0,O.jsxs)(`div`,{className:`converge-override`,children:[(0,O.jsx)(`input`,{className:`override-input`,placeholder:`reason to converge past open waypoints`,value:c,autoFocus:!0,onChange:e=>l(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-solid`,disabled:!c.trim()||u.isPending,onClick:()=>u.mutate({featureId:n.id,overrideReason:c.trim()}),children:`Converge anyway`}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost`,onClick:()=>{s(!1),l(``)},children:`Cancel`})]}):(0,O.jsxs)(`div`,{className:`converge-blocked`,children:[(0,O.jsx)(M,{children:r.reason??`resolve the open waypoints to converge`}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost`,onClick:()=>s(!0),children:`Override & converge…`})]})]})}function oS({featureId:e,waypoints:t,frontierIds:n,sessions:r}){let i=j.useUtils(),a=up(),o=j.feature.workWaypoint.useMutation({onSuccess:()=>{i.feature.get.invalidate({id:e}),i.feature.list.invalidate()},onError:e=>a.push(e.message)}),s=r.some(e=>e.status===`live`||e.status===`launching`);if(t.length===0)return(0,O.jsx)(`div`,{className:`map-waypoints`,children:(0,O.jsx)(M,{children:`no waypoints yet — the frontier fills in as the map is charted`})});let c=new Set(n),l=new Map(t.map(e=>[e.id,e])),u=new Map(t.map(e=>[e.seq,e])),d=e=>e.title,f=e=>e.originWaypointId?l.get(e.originWaypointId)?.title:void 0,p=e=>e.status===`resolved`||e.status===`dropped`,m=t.filter(e=>c.has(e.id)),h=t.filter(e=>e.status===`open`&&!c.has(e.id)),g=t.filter(e=>e.status===`claimed`),_=t.filter(p),v=({w:e})=>{let t=f(e);return t?(0,O.jsxs)(`div`,{className:`wp-lineage`,children:[`surfaced by `,t]}):null};return(0,O.jsxs)(`div`,{className:`map-waypoints`,children:[m.length>0&&(0,O.jsxs)(`section`,{className:`wp-group wp-group-frontier`,children:[(0,O.jsxs)(`div`,{className:`wp-group-title`,children:[`Frontier · `,m.length]}),m.map(t=>{let n=t.type===`research`,r=!n&&!!t.lastSessionId,i=!n&&s;return(0,O.jsxs)(`div`,{className:`wp wp-frontier`,children:[(0,O.jsx)(`span`,{className:`wp-type`,children:t.type}),(0,O.jsx)(`span`,{className:`wp-title`,children:t.title}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-solid wp-work`,disabled:i||o.isPending,title:n?`start an AFK research run on this waypoint`:i?`a session is already live on this feature — end or finish it before starting another`:r?`resume the previous session on this waypoint`:`claim this waypoint and open a session`,onClick:()=>o.mutate({featureId:e,waypointId:t.id}),children:r?`Resume`:`Work`}),(0,O.jsx)(v,{w:t})]},t.id)})]}),h.length>0&&(0,O.jsxs)(`section`,{className:`wp-group wp-group-blocked`,children:[(0,O.jsxs)(`div`,{className:`wp-group-title`,children:[`Blocked · `,h.length]}),h.map(e=>{let t=e.blockedBy.map(e=>u.get(e)).filter(e=>!!e&&!p(e)).map(d);return(0,O.jsxs)(`div`,{className:`wp wp-blocked`,children:[(0,O.jsx)(`span`,{className:`wp-type`,children:e.type}),(0,O.jsx)(`span`,{className:`wp-title`,children:e.title}),t.length>0&&(0,O.jsxs)(`span`,{className:`wp-blockers`,children:[`blocked by `,t.join(`, `)]}),(0,O.jsx)(v,{w:e})]},e.id)})]}),g.length>0&&(0,O.jsxs)(`section`,{className:`wp-group wp-group-claimed`,children:[(0,O.jsxs)(`div`,{className:`wp-group-title`,children:[`Claimed · `,g.length]}),g.map(e=>{let t=e.claimedBy?.startsWith(`run_`)??!1;return(0,O.jsxs)(`div`,{className:`wp wp-claimed`,children:[(0,O.jsx)(`span`,{className:`wp-pulse`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`wp-type`,children:e.type}),(0,O.jsx)(`span`,{className:`wp-title`,children:e.title}),t&&(0,O.jsx)(`span`,{className:`wp-run-note`,children:`researching…`}),(0,O.jsx)(v,{w:e})]},e.id)})]}),_.length>0&&(0,O.jsxs)(`details`,{className:`wp-group wp-group-done`,children:[(0,O.jsxs)(`summary`,{className:`wp-group-title`,children:[`Resolved / dropped · `,_.length]}),_.map(e=>(0,O.jsxs)(`div`,{className:`wp wp-done wp-${e.status}`,children:[(0,O.jsx)(`span`,{className:`wp-type`,children:e.status}),(0,O.jsx)(`span`,{className:`wp-title`,children:e.title}),e.summary&&(0,O.jsx)(`span`,{className:`wp-summary`,children:e.summary})]},e.id))]})]})}function sS(e){let t={},n=null,r=[],i=()=>{n!==null&&(t[n]=r.join(`
107
107
  `)),r.length=0};for(let t of e.split(`
108
- `)){let e=t.match(/^##\s+(.+?)\s*$/);e?(i(),n=e[1]):n!==null&&r.push(t)}return i(),t}function cS({featureId:e,relPath:t}){let n=j.docs.read.useQuery({featureId:e,relPath:t});return(0,O.jsxs)(`div`,{className:`spec-doc`,children:[(0,O.jsx)(`div`,{className:`spec-meta`,children:t}),n.isLoading&&(0,O.jsxs)(M,{children:[`loading `,t,`…`]}),n.error&&(0,O.jsxs)(M,{children:[`could not read `,t]}),n.data&&(0,O.jsx)(`div`,{className:`spec-body`,children:n.data.content})]})}function lS({full:e,driving:t}){let{feature:n,tickets:r,runs:i}=e,a=qf(i),o=r.length,s=r.filter(e=>e.status===`done`).length,c=r.filter(e=>e.status===`failed`).length,l=r.reduce((e,t)=>e+t.commits.length,0),u=t?.featureId===n.id,d=c>0?`var(--danger)`:`var(--ok)`,f=a?.status===`succeeded`?`var(--ok)`:a?.status===`failed`?`var(--danger)`:`var(--text-3)`;return(0,O.jsxs)(`div`,{className:`review-body`,children:[(0,O.jsxs)(`div`,{className:`review-grid`,children:[(0,O.jsxs)(`div`,{className:`review-card`,children:[(0,O.jsx)(wi,{children:`Summary`}),(0,O.jsxs)(`div`,{className:`check-row`,children:[(0,O.jsx)(`span`,{className:`check-dot`,style:{background:d}}),(0,O.jsx)(`span`,{className:`check-k`,children:`tickets`}),(0,O.jsxs)(`span`,{className:`check-v`,children:[s,`/`,o,` done`,c>0?` · ${c} failed`:``]})]}),(0,O.jsxs)(`div`,{className:`check-row`,children:[(0,O.jsx)(`span`,{className:`check-dot`,style:{background:f}}),(0,O.jsx)(`span`,{className:`check-k`,children:`run`}),(0,O.jsx)(`span`,{className:`check-v`,children:a?`${a.status}${a.summary?` · ${a.summary}`:``}`:`no run recorded`})]}),(0,O.jsxs)(`div`,{className:`check-row`,children:[(0,O.jsx)(`span`,{className:`check-dot`,style:{background:`var(--ph-shipped)`}}),(0,O.jsx)(`span`,{className:`check-k`,children:`changes`}),(0,O.jsxs)(`span`,{className:`check-v`,children:[l,` commit`,l===1?``:`s`]})]}),(0,O.jsxs)(`div`,{className:`review-foot`,children:[`⎇ `,n.branch]})]}),(0,O.jsxs)(`div`,{className:`review-card`,children:[(0,O.jsx)(wi,{children:`Test drive`}),u&&t?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`drive-live`,children:[(0,O.jsx)(`span`,{className:`drive-pulse`}),(0,O.jsx)(`span`,{className:`drive-label`,children:`driving now`}),(0,O.jsx)(`span`,{className:`drive-loc`,children:t.branch})]}),(0,O.jsx)(`div`,{className:`drive-copy`,children:`Click through the feature. When it feels right, merge — or stop the drive and send feedback back through tickets.`})]}):(0,O.jsx)(`div`,{className:`drive-copy`,children:`Nothing is running yet. Start the test drive from the next step to boot this branch on its own port and click through the feature yourself — the merge gate wants a human behind the wheel.`})]})]}),u&&(0,O.jsx)(uS,{featureId:n.id})]})}function uS({featureId:e}){let[t,n]=(0,D.useState)(!1),r=j.feature.driveInfo.useQuery(void 0,{refetchInterval:1500}).data;return!r||r.featureId!==e?null:(0,O.jsxs)(`div`,{className:`drive-pane`,children:[(0,O.jsxs)(`div`,{className:`drive-pane-strip`,children:[(0,O.jsx)(`span`,{className:`drive-pane-kind`,children:`dev server`}),(0,O.jsx)(`span`,{className:`drive-pane-loc`,children:r.branch}),(0,O.jsx)(`span`,{className:`drive-pane-spacer`}),r.devUrl&&(0,O.jsx)(`a`,{className:`drive-open`,href:r.devUrl,target:`_blank`,rel:`noreferrer noopener`,children:`Open app ↗`}),r.devPaneId&&(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost drive-pane-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:t?`Hide output`:`Show output`})]}),t&&(r.devPaneId?(0,O.jsx)(`div`,{className:`drive-pane-term`,children:(0,O.jsx)(kp,{label:`dev terminal`,children:(0,O.jsx)(eS,{sessionId:r.devPaneId})})}):(0,O.jsx)(`div`,{className:`drive-pane-empty`,children:`no dev command configured for this project`}))]})}function dS({full:e}){let t=[...dp(e.feature.id)].reverse().find(e=>e.type===`feature.shipped`||e.type===`merge.conflict`||e.type===`feature.status`),n=t&&t.type===`feature.shipped`?mp(t.ts):``;return(0,O.jsxs)(`div`,{className:`shipped-hero`,children:[(0,O.jsx)(`div`,{className:`shipped-check`,children:`✓`}),(0,O.jsx)(`div`,{className:`shipped-title`,children:`Shipped to main`}),(0,O.jsxs)(`div`,{className:`shipped-meta`,children:[`⎇ `,e.feature.branch,n?` · merged ${n} ago`:``]}),(0,O.jsx)(`div`,{className:`shipped-sub`,children:`The branch is merged and the pipeline is complete. The full history stays in the activity log.`})]})}function fS({featureId:e,readonly:t=!1}){let n=up(),r=j.feature.get.useQuery({id:e},{refetchInterval:1500}),[i,a]=(0,D.useState)(()=>new Set),o=r.data?.feature.projectId,s=j.settings.get.useQuery({projectId:o},{enabled:!!o}),c=s.data?.fields.find(e=>e.key===`stepModels.implement`&&e.source===`file`)??s.data?.fields.find(e=>e.key===`model`),l=typeof c?.value==`string`?c.value:`…`;if(r.isLoading)return(0,O.jsx)(M,{children:`loading tickets…`});if(!r.data)return(0,O.jsxs)(M,{children:[`could not load tickets: `,r.error?.message??`unknown`]});let u=r.data.tickets,d=[...r.data.sessions].reverse().find(e=>e.status===`live`||e.status===`launching`),f=u.length,p=u.filter(e=>e.status===`done`).length,m=u.filter(e=>e.status===`failed`).length,h=u.filter(e=>e.status===`burning`).length,g=u.filter(e=>e.status===`cancelled`).length,_=[`${p}/${f} done`];m>0&&_.push(`${m} failed`),h>0&&_.push(`${h} burning`),g>0&&_.push(`${g} cancelled`);let v=_.join(` · `),y=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),b=e=>{navigator.clipboard.writeText(e),n.push(`copied ${pp(e)}`,`info`)};return(0,O.jsxs)(O.Fragment,{children:[d&&(0,O.jsxs)(`div`,{className:`grill-panel tickets-session`,children:[(0,O.jsxs)(`div`,{className:`grill-strip`,children:[(0,O.jsx)(`span`,{className:`grill-kind`,children:d.kind}),(0,O.jsx)(`span`,{className:`grill-sid`,children:d.ccSessionId??d.id}),(0,O.jsx)(Oi,{status:d.status}),(0,O.jsx)(`span`,{className:`grill-strip-spacer`}),(0,O.jsx)(Op,{featureId:e,sessionId:d.id})]}),(0,O.jsx)(`div`,{className:`grill-term`,id:`grill-term`,children:(0,O.jsx)(kp,{label:`terminal`,children:(0,O.jsx)(eS,{sessionId:d.id})})})]}),(0,O.jsxs)(`div`,{className:`body-title`,children:[(0,O.jsx)(wi,{children:`Tickets`}),(0,O.jsx)(`span`,{className:`body-meta`,children:v}),(0,O.jsx)(`span`,{style:{flex:1}}),(0,O.jsxs)(`span`,{className:`chip chip-neutral`,title:`sandbox`,children:[`sandbox · `,Tp]}),(0,O.jsx)(`span`,{className:`chip chip-neutral`,title:`model`,children:l})]}),f===0?(0,O.jsx)(M,{children:`no tickets yet — a grill session emits them.`}):(0,O.jsx)(`div`,{className:`ledger`,children:u.map(e=>{let t=i.has(e.id);return(0,O.jsxs)(`div`,{className:`ledger-row${t?` is-open`:``}`,children:[(0,O.jsxs)(`button`,{className:`ledger-head`,onClick:()=>y(e.id),children:[(0,O.jsx)(`span`,{className:`lg-caret`,children:`▸`}),(0,O.jsxs)(`span`,{className:`lg-seq`,children:[`#`,e.seq]}),(0,O.jsx)(`span`,{className:`lg-title`,children:e.title}),e.blockedBy.length>0&&(0,O.jsxs)(`span`,{className:`lg-block`,children:[`⊘ after `,e.blockedBy.join(`, `)]}),(0,O.jsx)(`span`,{className:`lg-meta`,children:(0,O.jsx)(Ei,{status:e.status})})]}),t&&(0,O.jsxs)(`div`,{className:`ledger-detail`,children:[(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`GOAL`}),(0,O.jsx)(`div`,{className:`td-body`,children:e.goal})]}),e.context&&(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`CONTEXT`}),(0,O.jsx)(`div`,{className:`td-body`,children:e.context})]}),(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`ACCEPTANCE`}),(0,O.jsx)(`ul`,{className:`td-list`,children:e.acceptanceCriteria.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]}),(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`SEAMS`}),(0,O.jsx)(`div`,{className:`td-seams`,children:e.seams.map((e,t)=>(0,O.jsx)(`span`,{className:`seam`,children:e},t))})]}),(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`COMMITS`}),e.commits.length===0?(0,O.jsx)(`div`,{className:`td-empty`,children:`no commits yet — the burn writes them`}):(0,O.jsx)(`div`,{className:`td-commits`,children:e.commits.map(e=>(0,O.jsx)(`button`,{className:`commit-sha`,onClick:()=>b(e),title:`copy full sha`,children:pp(e)},e))})]}),e.status===`failed`&&e.error&&(0,O.jsxs)(`div`,{className:`td-section td-error`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`Error`}),(0,O.jsx)(`div`,{className:`td-error-body`,children:e.error})]}),e.status===`cancelled`&&e.error&&(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`Cancelled`}),(0,O.jsx)(`div`,{className:`td-body`,children:e.error})]})]})]},e.id)})})]})}function pS({ticketId:e}){let{chunks:t,live:n,trimmed:r}=mS(e),i=(0,D.useRef)(null),[a,o]=(0,D.useState)(!0),s=(0,D.useMemo)(()=>hS(t),[t]);return(0,D.useEffect)(()=>{if(!a)return;let e=i.current;e&&(e.scrollTop=e.scrollHeight)},[s,n,a]),(0,O.jsxs)(`div`,{className:`agent-body`,ref:i,onScroll:()=>{let e=i.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;o(t)},children:[r&&(0,O.jsx)(`div`,{className:`agent-trimmed`,children:`… earlier output trimmed …`}),s.length===0&&!n&&(0,O.jsx)(M,{children:`no agent output captured — transcripts are held in server memory for the current burn; older runs keep only the event timeline.`}),s.length===0&&n&&(0,O.jsx)(M,{children:`waiting for the agent's first output…`}),s.map((e,t)=>e.kind===`text`?(0,O.jsxs)(`div`,{className:`agent-turn`,children:[(0,O.jsx)(`span`,{className:`agent-glyph is-text`,children:`⏺`}),(0,O.jsx)(`span`,{className:`agent-prose`,children:e.text})]},t):(0,O.jsxs)(`div`,{className:`agent-turn is-tool`,children:[(0,O.jsx)(`span`,{className:`agent-glyph is-tool`,children:`●`}),(0,O.jsxs)(`span`,{className:`agent-toolline`,children:[(0,O.jsx)(`span`,{className:`agent-toolname`,children:e.name}),e.args&&(0,O.jsxs)(`span`,{className:`agent-toolargs`,children:[`(`,e.args,`)`]})]})]},t)),n&&(0,O.jsxs)(`div`,{className:`agent-live-row`,children:[(0,O.jsx)(`span`,{className:`agent-spinner`,children:`✳`}),(0,O.jsx)(`span`,{className:`agent-live-label`,children:`Burning…`}),(0,O.jsx)(`span`,{className:`agent-cursor`,children:`▍`})]}),!a&&(0,O.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>o(!0),children:`Follow ⇣`})]})}function mS(e){let[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(!1),s=t.length>0?t[t.length-1].i:void 0,c=j.run.agentTranscript.useQuery({ticketId:e,after:s},{refetchInterval:1e3});return(0,D.useEffect)(()=>{let e=c.data;e&&(i(e.live),o(e.firstIndex>0),n(t=>{let n=t.length>0?t[t.length-1].i:-1;if(e.nextIndex<=n)return[];if(e.chunks.length===0)return t;let r=e.chunks.filter(e=>e.i>n);return r.length===0?t:[...t,...r]}))},[c.data]),{chunks:t,live:r,trimmed:a}}function hS(e){let t=[];for(let n of e){if(n.kind===`tool`){t.push({kind:`tool`,name:n.name??`tool`,args:gS(n.text)});continue}let e=t[t.length-1];e&&e.kind===`text`?e.text+=n.text:t.push({kind:`text`,text:n.text})}return t.map(e=>e.kind===`text`?{...e,text:e.text.trim()}:e).filter(e=>e.kind!==`text`||e.text.length>0)}function gS(e){let t=e.replace(/\s+/g,` `).trim();return t.length>300?`${t.slice(0,300)}…`:t}function _S({featureId:e,runId:t,readonly:n=!1}){let r=j.feature.get.useQuery({id:e},{refetchInterval:1500}),i=j.run.get.useQuery({runId:t},{refetchInterval:1500,enabled:!!t}),a=dp(e),o=r.data?.tickets??[],s=(0,D.useMemo)(()=>a.filter(e=>e.runId===t),[a,t]),c=(0,D.useMemo)(()=>xS(s),[s]),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(`agent`),p=o.find(e=>e.status===`burning`)??[...o].reverse().find(e=>e.status===`done`||e.status===`failed`),m=l??p?.id??null,h=o.find(e=>e.id===m)??null,g=o.filter(e=>e.status===`done`).length,_=o.length,v=i.data?hp(i.data.startedAt,i.data.endedAt??Date.now()):``,y=[...r.data?.sessions??[]].reverse().find(e=>e.status===`live`||e.status===`launching`);return!t&&!y?(0,O.jsx)(M,{children:`no run yet — start the burn from the workspace.`}):(0,O.jsxs)(`div`,{className:`ws-body-inner`,children:[y&&(0,O.jsxs)(`div`,{className:`grill-panel tickets-session`,children:[(0,O.jsxs)(`div`,{className:`grill-strip`,children:[(0,O.jsx)(`span`,{className:`grill-kind`,children:y.kind}),(0,O.jsx)(`span`,{className:`grill-sid`,children:y.ccSessionId??y.id}),(0,O.jsx)(Oi,{status:y.status}),(0,O.jsx)(`span`,{className:`grill-strip-spacer`}),(0,O.jsx)(Op,{featureId:e,sessionId:y.id})]}),(0,O.jsx)(`div`,{className:`grill-term`,id:`grill-term`,children:(0,O.jsx)(kp,{label:`terminal`,children:(0,O.jsx)(eS,{sessionId:y.id})})})]}),(0,O.jsxs)(`div`,{className:`body-title`,children:[(0,O.jsx)(`span`,{className:`section-title`,children:`Run`}),i.data&&(0,O.jsx)(Di,{status:i.data.status}),(0,O.jsxs)(`span`,{className:`body-meta`,children:[g,`/`,_,` done · `,v]})]}),(0,O.jsxs)(`div`,{className:`run-split`,children:[(0,O.jsxs)(`div`,{className:`run-lanes-panel`,children:[(0,O.jsx)(`div`,{className:`panel-cap`,children:`Ticket lanes`}),(0,O.jsxs)(`div`,{className:`run-lanes`,children:[o.length===0&&(0,O.jsx)(M,{children:`no ticket lanes`}),o.map(e=>(0,O.jsx)(vS,{ticket:e,duration:c.get(e.id),selected:e.id===m,onSelect:()=>{u(e.id),f(`agent`)}},e.id))]})]}),(0,O.jsxs)(`div`,{className:`run-stream-panel`,children:[(0,O.jsxs)(`div`,{className:`stream-head`,children:[(0,O.jsxs)(`div`,{className:`panel-tabs`,children:[(0,O.jsxs)(`button`,{className:`panel-tab${d===`agent`?` is-active`:``}`,onClick:()=>f(`agent`),children:[`Agent`,h&&(0,O.jsxs)(`span`,{className:`panel-tab-ctx`,children:[`#`,h.seq]})]}),(0,O.jsx)(`button`,{className:`panel-tab${d===`events`?` is-active`:``}`,onClick:()=>f(`events`),children:`Events`})]}),d===`agent`&&h?.status===`burning`&&(0,O.jsx)(`span`,{className:`agent-live-dot`,title:`agent running`})]}),d===`agent`?h?(0,O.jsx)(kp,{label:`agent transcript`,children:(0,O.jsx)(pS,{ticketId:h.id},h.id)}):(0,O.jsx)(`div`,{className:`agent-body`,children:(0,O.jsx)(M,{children:`no agent yet — lanes light up here as tickets start burning.`})}):(0,O.jsx)(yS,{events:s})]})]})]})}function vS({ticket:e,duration:t,selected:n,onSelect:r}){let i=up(),a=e=>{navigator.clipboard?.writeText(e).then(()=>i.push(`copied ${pp(e)}`,`info`),()=>i.push(`copy failed`))},o=[`burning`,`done`,`failed`].includes(e.status)?` status-${e.status}`:``,s=e.commits.length>0,c=t!==void 0;return(0,O.jsxs)(`div`,{className:`lane is-clickable${o}${n?` is-selected`:``}`,role:`button`,tabIndex:0,title:`show this ticket's agent`,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&r()},children:[(0,O.jsxs)(`div`,{className:`lane-head`,children:[(0,O.jsxs)(`span`,{className:`lane-seq`,children:[`#`,e.seq]}),(0,O.jsx)(`span`,{className:`lane-title`,children:e.title}),(0,O.jsx)(Ei,{status:e.status})]}),(s||c)&&(0,O.jsxs)(`div`,{className:`lane-foot`,children:[(0,O.jsx)(`span`,{className:`lane-commits`,children:e.commits.map(e=>(0,O.jsx)(`button`,{className:`commit-sha`,onClick:t=>{t.stopPropagation(),a(e)},title:`copy sha`,children:pp(e)},e))}),c&&(0,O.jsx)(`span`,{className:`lane-dur`,children:hp(0,t)})]})]})}function yS({events:e}){let t=(0,D.useRef)(null),[n,r]=(0,D.useState)(!0);return(0,D.useEffect)(()=>{if(!n)return;let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e,n]),(0,O.jsxs)(`div`,{className:`stream-body`,ref:t,onScroll:()=>{let e=t.current;if(!e)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight<24;r(n)},children:[e.length===0&&(0,O.jsx)(M,{children:`waiting for events…`}),e.map(e=>(0,O.jsxs)(`div`,{className:`stream-line level-${bS(e.type)}`,children:[(0,O.jsx)(`span`,{className:`sl-time`,children:fp(e.ts)}),(0,O.jsx)(`span`,{className:`sl-type`,children:e.type}),(0,O.jsx)(`span`,{className:`sl-msg`,children:e.message})]},e.id)),!n&&(0,O.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>r(!0),children:`Follow ⇣`})]})}function bS(e){return/(error|fail|conflict|cancel)/i.test(e)?`error`:/(done|succeed|finished|shipped|merged)/i.test(e)?`ok`:/(start|burn|launch|advance|running)/i.test(e)?`active`:`info`}function xS(e){let t=new Map;for(let n of e){if(!n.ticketId)continue;let e=t.get(n.ticketId);e?(e.min=Math.min(e.min,n.ts),e.max=Math.max(e.max,n.ts)):t.set(n.ticketId,{min:n.ts,max:n.ts})}let n=new Map;for(let[e,r]of t)r.max>r.min&&n.set(e,r.max-r.min);return n}function SS({featureId:e,viewedPhase:t,onViewPhase:n,guidance:r,driving:i,onDriveChange:a}){let o=j.useUtils(),s=up(),c=j.feature.get.useQuery({id:e},{refetchInterval:1500}),l=ES(e),u=()=>{o.feature.get.invalidate({id:e}),o.feature.list.invalidate()},d=j.feature.launchSession.useMutation({onSuccess:u,onError:e=>s.push(e.message)}),f=j.feature.advance.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),p=j.feature.burn.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),m=j.run.cancel.useMutation({onSuccess:()=>{u(),s.push(`cancel requested`,`info`)},onError:e=>s.push(e.message)}),h=j.feature.testDrive.useMutation({onError:e=>s.push(e.message)}),g=j.feature.merge.useMutation({onError:e=>s.push(e.message)});if(c.isLoading)return(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(`div`,{className:`ws-body`,children:(0,O.jsx)(M,{children:`loading feature…`})})});if(!c.data)return(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(`div`,{className:`ws-body`,children:(0,O.jsxs)(M,{children:[`could not load feature`,c.error?`: ${c.error.message}`:``]})})});let _=!!c.error,v=c.data,y=v.feature,b=np(y,t),x=rp(y,b),ee=ip(y,b),te=qf(v.runs),S=ap(v,{driving:i?.featureId===y.id}),ne=d.isPending||f.isPending||p.isPending||m.isPending||h.isPending||g.isPending;return(0,O.jsxs)(`section`,{className:`workspace`,children:[(0,O.jsxs)(`div`,{className:`ws-head`,children:[(0,O.jsxs)(`div`,{className:`ws-title-row`,children:[(0,O.jsx)(Ti,{phase:y.phase}),(0,O.jsx)(`span`,{className:`ws-title`,children:y.title}),(0,O.jsx)(`span`,{className:`ws-title-spacer`}),(0,O.jsxs)(`button`,{className:`ws-branch`,title:`copy branch`,onClick:()=>DS(y.branch,s),children:[`⎇ `,y.branch]})]}),(0,O.jsx)(wS,{steps:ee,onView:e=>n(e===y.phase?null:e)})]}),x?(0,O.jsxs)(`div`,{className:`readonly-bar`,children:[(0,O.jsx)(`span`,{className:`readonly-tag`,children:`READ-ONLY`}),(0,O.jsxs)(`span`,{children:[`You're viewing the `,Jf[b],` phase.`]}),(0,O.jsxs)(`button`,{className:`readonly-back`,onClick:()=>n(null),children:[`Back to `,Jf[y.phase],` →`]})]}):(0,O.jsx)(TS,{ns:S,guidance:r,busy:ne,onAction:t=>{switch(t){case`startGrill`:d.mutate({featureId:e,kind:`ideation`});break;case`askQuestions`:d.mutate({featureId:e,kind:`qa`});break;case`revisit`:d.mutate({featureId:e,kind:`revisit`});break;case`openGrill`:n(null),requestAnimationFrame(()=>document.getElementById(`grill-term`)?.scrollIntoView({behavior:`smooth`,block:`center`}));break;case`advance`:f.mutate({featureId:e});break;case`burn`:p.mutate({featureId:e});break;case`cancelRun`:te&&m.mutate({runId:te.id});break;case`testDriveStart`:h.mutate({featureId:e,action:`start`},{onSuccess:t=>{u(),t.ok&&t.branch?a({featureId:e,branch:t.branch}):t.ok||s.push(t.deniedReason??`test drive denied`)}});break;case`testDriveStop`:h.mutate({featureId:e,action:`stop`},{onSuccess:()=>{u(),a(null)}});break;case`merge`:g.mutate({featureId:e},{onSuccess:e=>{u(),e.ok?(a(null),s.push(`merged — feature shipped`,`success`)):e.conflict&&s.push(`merge conflict — resolve and retry`)}});break}}}),_&&(0,O.jsxs)(`div`,{className:`ws-banner is-offline`,role:`status`,children:[(0,O.jsx)(`span`,{className:`ws-banner-tag`,children:`OFFLINE`}),(0,O.jsx)(`span`,{children:`server unreachable — retrying…`})]}),l.message&&(0,O.jsxs)(`div`,{className:`ws-banner`,role:`alert`,onClick:l.dismiss,title:`dismiss`,children:[(0,O.jsx)(`span`,{className:`ws-banner-tag`,children:`RESUME FAILED`}),(0,O.jsx)(`span`,{children:l.message})]}),(0,O.jsx)(`div`,{className:`ws-body`,children:(0,O.jsx)(`div`,{className:`ws-body-inner`,children:(0,O.jsx)(CS,{effective:b,full:v,driving:i,runId:te?.id??null,readonly:x})},b)})]})}function CS({effective:e,full:t,driving:n,runId:r,readonly:i}){switch(e){case`ideation`:case`spec`:return(0,O.jsx)(tS,{full:t,effective:e});case`tickets`:return(0,O.jsx)(fS,{featureId:t.feature.id,readonly:i});case`implementation`:return(0,O.jsx)(_S,{featureId:t.feature.id,runId:r,readonly:i});case`review`:return(0,O.jsx)(lS,{full:t,driving:n});case`shipped`:return(0,O.jsx)(dS,{full:t})}}function wS({steps:e,onView:t}){return(0,O.jsx)(`div`,{className:`pipeline`,children:e.map((n,r)=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsxs)(`button`,{className:`pstep is-${n.state}${n.isViewed?` is-viewed`:``}${n.clickable?` is-clickable`:``}`,title:n.tip,disabled:!n.clickable,onClick:()=>n.clickable&&t(n.phase),children:[(0,O.jsx)(`span`,{className:`pstep-dot`}),(0,O.jsx)(`span`,{className:`pstep-label`,children:n.label})]}),r<e.length-1&&(0,O.jsx)(`span`,{className:`pconn${n.state===`done`?` is-done`:``}`})]},n.phase))})}function TS({ns:e,guidance:t,busy:n,onAction:r}){let i=e.kick===`IN PROGRESS`?`is-progress`:e.kick===`SHIPPED`?`is-shipped`:e.kick===`WAITING`?`is-waiting`:``;return(0,O.jsxs)(`div`,{className:`nextstep`,children:[e.busy&&(0,O.jsx)(`span`,{className:`spin-ring nextstep-spin`}),(0,O.jsxs)(`div`,{className:`nextstep-main`,children:[(0,O.jsx)(`div`,{className:`nextstep-kick ${i}`,children:e.kick}),(0,O.jsx)(`div`,{className:`nextstep-title`,children:e.title}),t&&(0,O.jsx)(`div`,{className:`nextstep-desc`,children:e.desc})]}),(0,O.jsxs)(`div`,{className:`nextstep-actions`,children:[e.secondary.map((e,t)=>(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,disabled:n,onClick:()=>r(e.kind),children:e.label},t)),e.primary&&(0,O.jsx)(Ci,{variant:e.primary.danger?`danger`:`solid`,disabled:n,onClick:()=>r(e.primary.kind),children:n?`Working…`:e.primary.label})]})]})}function ES(e){let t=dp(e),[n,r]=(0,D.useState)(null),i=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(t.length===0)return;let e=t[t.length-1].id;if(i.current===null){i.current=e;return}let n=i.current;i.current=e;let a=t.filter(e=>e.id>n&&e.type===`session.resume_failed`),o=a[a.length-1];o&&r(o.message||`session resume failed — relaunch to continue`)},[t]),(0,D.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(null),8e3);return()=>clearTimeout(e)},[n]),{message:n,dismiss:()=>r(null)}}function DS(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function OS({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,D.useState)(``),[a,o]=(0,D.useState)(``),[s,c]=(0,D.useState)(`full`),[l,u]=(0,D.useState)(!1),[d,f]=(0,D.useState)(``),p=j.useUtils(),m=up(),h=j.project.branches.useQuery({projectId:e}),g=h.data?.mainBranch??``,_=h.data?.current,v=h.data?.branches??[],y=h.data?.remoteBranches??[],b=v.length===0&&y.length===0,x=d||g,ee=j.feature.launchSession.useMutation(),te=j.feature.create.useMutation({onSuccess:async e=>{await p.feature.list.invalidate(),ee.mutate({featureId:e.id,kind:`ideation`},{onSettled:()=>void p.feature.get.invalidate({id:e.id})}),n(e.id)},onError:e=>m.push(e.message)}),S=kS(r),ne=te.isPending||ee.isPending,re=()=>{let t=r.trim();t&&te.mutate({projectId:e,title:t,oneLiner:a.trim(),size:s,mapped:l,baseBranch:d||void 0})};return(0,O.jsx)(`div`,{className:`nf-overlay`,children:(0,O.jsxs)(`div`,{className:`nf-card`,children:[(0,O.jsx)(`div`,{className:`nf-kick`,children:`NEW FEATURE`}),(0,O.jsx)(`div`,{className:`nf-h`,children:`What are we building?`}),(0,O.jsx)(`div`,{className:`nf-sub`,children:`Name it and pick a size — runcastle opens a grill session so you and Claude shape the idea before any code is written.`}),(0,O.jsx)(`input`,{className:`nf-input`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. Slack notifications on failed runs`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&re(),e.key===`Escape`&&t()}}),(0,O.jsx)(`input`,{className:`nf-input nf-oneliner`,value:a,onChange:e=>o(e.target.value),placeholder:`one-liner (optional) — what & why in a sentence`,onKeyDown:e=>{e.key===`Enter`&&re(),e.key===`Escape`&&t()}}),(0,O.jsxs)(`div`,{className:`nf-controls`,children:[(0,O.jsxs)(`div`,{className:`size-toggle`,children:[(0,O.jsx)(`button`,{className:s===`full`?`is-on`:``,onClick:()=>c(`full`),children:`Full`}),(0,O.jsx)(`button`,{className:s===`collapsed`?`is-on`:``,onClick:()=>c(`collapsed`),children:`Small`})]}),(0,O.jsx)(`span`,{className:`size-hint`,children:s===`collapsed`?`Small skips the spec phase.`:`Full runs the whole six-phase pipeline.`})]}),(0,O.jsxs)(`div`,{className:`nf-base`,children:[(0,O.jsx)(`label`,{className:`nf-base-label`,htmlFor:`nf-base-select`,children:`Branch from`}),(0,O.jsxs)(`select`,{id:`nf-base-select`,className:`nf-base-select`,value:x,disabled:h.isPending||b,onChange:e=>f(e.target.value),children:[v.map(e=>(0,O.jsxs)(`option`,{value:e,children:[e,e===g?` (default)`:``,e===_&&e!==g?` (current)`:``]},e)),y.length>0&&(0,O.jsx)(`optgroup`,{label:`Remote (creates a local branch)`,children:y.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))})]}),(0,O.jsx)(`span`,{className:`size-hint`,children:`forks off this branch — and merges back into it when shipped.`})]}),(0,O.jsxs)(`label`,{className:`nf-mapped`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,O.jsxs)(`span`,{className:`nf-mapped-text`,children:[(0,O.jsx)(`span`,{className:`nf-mapped-label`,children:`Start mapped`}),(0,O.jsx)(`span`,{className:`size-hint`,children:`Chart the idea as a waypoint map when it's too big for one grill — orthogonal to size.`})]})]}),(0,O.jsxs)(`div`,{className:`nf-branch`,children:[`branch · feature/`,S||`…`,` ← `,x||`…`]}),(0,O.jsxs)(`div`,{className:`nf-actions`,children:[(0,O.jsx)(Ci,{variant:`ghost`,onClick:t,disabled:ne,children:`Cancel`}),(0,O.jsx)(Ci,{variant:`solid`,onClick:re,disabled:!r.trim()||ne,children:ne?`Starting…`:`Start grill session`})]})]})})}function kS(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function AS(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onNewFeature:o,onOpenSettings:s,nav:c}=e,[l,u]=(0,D.useState)(``),[d,f]=(0,D.useState)(0),p=(0,D.useRef)(null),m=(0,D.useRef)([]);(0,D.useEffect)(()=>{t&&(u(``),f(0),p.current?.focus())},[t]),(0,D.useEffect)(()=>{f(0)},[l]);let h=l.trim().toLowerCase(),g=(0,D.useMemo)(()=>h===``?r:r.filter(e=>e.slug.toLowerCase().includes(h)||e.title.toLowerCase().includes(h)),[r,h]),_=(0,D.useMemo)(()=>(c.projects??[]).filter(e=>e.id!==c.currentProjectId),[c.projects,c.currentProjectId]),v=(0,D.useMemo)(()=>h===``?_:_.filter(e=>e.name.toLowerCase().includes(h)),[_,h]),y=`create new feature`.includes(h),b=`all projects home`.includes(h),x=`open a project`.includes(h),ee=`settings preferences`.includes(h),te=(0,D.useMemo)(()=>{let e=g.map(e=>({kind:`feature`,feature:e}));for(let t of v)e.push({kind:`project`,id:t.id,name:t.name,branch:t.mainBranch,current:!1});return y&&e.push({kind:`newFeature`}),b&&e.push({kind:`home`}),x&&e.push({kind:`openProject`}),ee&&e.push({kind:`settings`}),e},[g,v,y,b,x,ee]);if(!t)return null;let S=e=>{if(te.length===0)return;let t=(d+e+te.length)%te.length;f(t),m.current[t]?.scrollIntoView({block:`nearest`})},ne=e=>{let t=te[e];if(t){switch(t.kind){case`feature`:a(t.feature.id);break;case`project`:c.enterProject(t.id);break;case`newFeature`:o();break;case`home`:c.goHome();break;case`openProject`:c.showOpen();break;case`settings`:s();break}n()}},re=e=>{e.key===`ArrowDown`?(e.preventDefault(),S(1)):e.key===`ArrowUp`?(e.preventDefault(),S(-1)):e.key===`Enter`?(e.preventDefault(),ne(d)):e.key===`Escape`&&(e.preventDefault(),n())},ie=g.length,ae=ie+v.length,oe=e=>t=>{m.current[e]=t};return(0,O.jsx)(`div`,{className:`cmdk-backdrop`,onClick:n,children:(0,O.jsxs)(`div`,{className:`cmdk`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`input`,{ref:p,className:`cmdk-input`,placeholder:`Search features, projects, or jump to…`,value:l,onChange:e=>u(e.target.value),onKeyDown:re,"aria-label":`Search features, projects, or jump to`}),(0,O.jsxs)(`div`,{className:`cmdk-list`,children:[g.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`cmdk-group-label`,children:`Features`}),g.map((e,t)=>(0,O.jsxs)(`div`,{ref:oe(t),className:`cmdk-item${t===d?` is-active`:``}`,onMouseEnter:()=>f(t),onClick:()=>ne(t),children:[(0,O.jsx)(`span`,{className:`cmdk-item-glyph`,children:(0,O.jsx)(`span`,{className:`phase-fg-${e.phase}`,children:Gf(e.phase)})}),(0,O.jsx)(`span`,{className:`cmdk-item-label`,children:e.title}),(0,O.jsx)(`span`,{className:`cmdk-item-slug`,children:e.slug}),(0,O.jsx)(`span`,{className:`cmdk-item-hint`,children:e.id===i?`current`:e.phase})]},e.id))]}),v.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`cmdk-group-label`,children:`Switch project`}),v.map((e,t)=>{let n=ie+t;return(0,O.jsxs)(`div`,{ref:oe(n),className:`cmdk-item${n===d?` is-active`:``}`,onMouseEnter:()=>f(n),onClick:()=>ne(n),children:[(0,O.jsx)(`span`,{className:`cmdk-item-glyph`,children:`◫`}),(0,O.jsx)(`span`,{className:`cmdk-item-label`,children:e.name}),(0,O.jsxs)(`span`,{className:`cmdk-item-slug`,children:[`⎇ `,e.mainBranch]}),(0,O.jsx)(`span`,{className:`cmdk-item-hint`,children:`project`})]},e.id)})]}),(y||b||x||ee)&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`cmdk-group-label`,children:`Actions`}),y&&(0,O.jsx)(jS,{index:ae,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`+`,label:`Create new feature`}),b&&(0,O.jsx)(jS,{index:ae+ +!!y,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`⊞`,label:`All projects (home)`}),x&&(0,O.jsx)(jS,{index:ae+ +!!y+ +!!b,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`◌`,label:`Open a project…`}),ee&&(0,O.jsx)(jS,{index:ae+ +!!y+ +!!b+ +!!x,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`⚙`,label:`Settings`})]}),te.length===0&&(0,O.jsx)(`div`,{className:`cmdk-empty`,children:`No matches`})]}),(0,O.jsxs)(`div`,{className:`cmdk-foot`,children:[(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`span`,{className:`kbd`,children:`↑↓`}),` navigate`]}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`span`,{className:`kbd`,children:`↵`}),` select`]}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`span`,{className:`kbd`,children:`esc`}),` close`]})]})]})})}function jS({index:e,activeIndex:t,bindRow:n,setActiveIndex:r,activate:i,glyph:a,label:o}){return(0,O.jsxs)(`div`,{ref:n(e),className:`cmdk-item${e===t?` is-active`:``}`,onMouseEnter:()=>r(e),onClick:()=>i(e),children:[(0,O.jsx)(`span`,{className:`cmdk-item-glyph`,children:a}),(0,O.jsx)(`span`,{className:`cmdk-item-label`,children:o}),(0,O.jsx)(`span`,{className:`cmdk-item-hint`,children:`action`})]})}var MS={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,mainBranch:`RUNCASTLE_MAIN_BRANCH`},NS=Uf.map(e=>e.id),PS=`stepModels.`;function FS(e){return e.startsWith(PS)}function IS(e){return e.slice(11)}var LS={ideation:`Ideation`,qa:`Q&A`,waypoint:`Waypoint`,converge:`Converge`,research:`Research`,implement:`Implement`,smoke:`Smoke`},RS=Vf.map(e=>`${PS}${e}`),zS=new Set([`mainBranch`]),BS={serverPort:{label:`Server port`,help:`Port the runcastle server listens on.`,control:`number`},model:{label:`Default model`,help:`Claude model every step inherits unless overridden below.`,control:`select`,options:NS},sandbox:{label:`Sandbox`,help:`Where launched sessions run.`,control:`select`,options:[`docker`,`noSandbox`]},sandboxImage:{label:`Sandbox image`,help:`Docker image used when a session is sandboxed.`,control:`text`},burnConcurrency:{label:`Burn concurrency`,help:`Max tickets burned in parallel per run (1–8). Each is a full agent.`,control:`number`},mainBranch:{label:`Main branch`,help:`Branch features merge back into.`,control:`text`},devCommand:{label:`Dev command`,help:`Command that starts this project's dev server.`,control:`text`}};function VS(e){return e==null?``:String(e)}function HS(e){if(FS(e)){let t=IS(e);return{label:LS[t]??t,help:`Model for the ${LS[t]??t} step.`,control:`select`,options:NS}}return BS[e]??{label:e,help:``,control:`text`}}function US(e){let t=HS(e.key),n=zS.has(e.key),r=!e.editable||n,i=e.source===`project`,a=null;return e.source===`env`?a=`Set by ${MS[e.key]??`the environment`}`:n?a=`Read-only — detected from git`:e.scope===`project`&&(a=i?`Overridden for this project`:`Inherited from global`),{key:e.key,label:t.label,help:t.help,value:VS(e.value),control:t.control,options:t.options??[],readOnly:r,restartRequired:e.restartRequired,overridden:i,source:e.source,note:a,allowCustom:e.key===`model`||FS(e.key)}}function WS(e){return e.fields.filter(e=>!FS(e.key)).map(US)}function GS(e){return e.fields.filter(e=>e.scope===`project`).map(US)}function KS(e){return e.fields.filter(e=>FS(e.key)&&e.source===`file`).map(US).sort((e,t)=>RS.indexOf(e.key)-RS.indexOf(t.key))}function qS(e){let t=new Set(e.fields.filter(e=>FS(e.key)&&e.source===`file`).map(e=>e.key));return RS.filter(e=>!t.has(e)).map(e=>({key:e,label:LS[IS(e)]??IS(e)}))}function JS({onDismiss:e}){let t=j.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),n=t.data,r=e=>n?.results.find(t=>t.id===e),i=r(`container-runtime`),a=r(`sandcastle-image`),o=r(`afk-token`),s=()=>t.refetch();return(0,O.jsxs)(`div`,{className:`afk-card`,children:[(0,O.jsxs)(`div`,{className:`afk-card-head`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`op-kick`,children:`ENABLE AFK BURNS`}),(0,O.jsx)(`div`,{className:`afk-card-title`,children:`Run features unattended`})]}),e&&(0,O.jsx)(Ci,{variant:`ghost`,onClick:e,children:`Set up later`})]}),(0,O.jsx)(`p`,{className:`afk-card-sub`,children:`AFK burns run each feature to completion in a sandbox — no interactive session. They need a container runtime, the sandcastle image, and an auth token. Set them up now or anytime from Settings.`}),t.isLoading&&(0,O.jsx)(M,{children:`checking prerequisites…`}),t.error&&(0,O.jsxs)(M,{children:[`could not run checks: `,t.error.message]}),n&&(0,O.jsxs)(`div`,{className:`afk-rows`,children:[(0,O.jsx)(XS,{probe:i,onRecheck:s}),(0,O.jsx)(ZS,{probe:a,runtimeOk:i?.status===`ok`,onDone:s}),(0,O.jsx)(QS,{probe:o,onDone:s})]})]})}function YS({probe:e,children:t}){if(!e)return null;let n=e.status===`ok`;return(0,O.jsxs)(`div`,{className:`afk-row${n?` is-ok`:``}`,children:[(0,O.jsxs)(`div`,{className:`afk-row-head`,children:[(0,O.jsx)(`span`,{className:`afk-dot afk-dot-${n?`ok`:`warn`}`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`afk-row-text`,children:[(0,O.jsx)(`div`,{className:`afk-row-label`,children:e.label}),(0,O.jsx)(`div`,{className:`afk-row-detail mono`,children:e.detail})]})]}),!n&&(0,O.jsx)(`div`,{className:`afk-row-action`,children:t})]})}function XS({probe:e,onRecheck:t}){let n=j.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),r=up();if(!e)return null;let i=e.status===`missing`?n.data:void 0,a=i?.command??e.fix??``;return(0,O.jsxs)(YS,{probe:e,children:[a&&(0,O.jsxs)(`div`,{className:`afk-cmd`,children:[(0,O.jsx)(`code`,{className:`afk-cmd-text mono`,children:a}),(0,O.jsx)(Ci,{variant:`ghost`,onClick:()=>{navigator.clipboard?.writeText(a),r.push(`copied`,`info`)},children:`Copy`})]}),i?.note&&(0,O.jsx)(`div`,{className:`afk-note`,children:i.note}),(0,O.jsx)(Ci,{variant:`solid`,onClick:t,children:`Re-check`})]})}function ZS({probe:e,runtimeOk:t,onDone:n}){let[r,i]=(0,D.useState)(null),a=up(),o=j.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)});return e?(0,O.jsx)(YS,{probe:e,children:r?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`afk-term`,children:(0,O.jsx)(kp,{label:`build-image`,children:(0,O.jsx)(eS,{sessionId:r})})}),(0,O.jsx)(`div`,{className:`afk-term-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,onClick:()=>{i(null),n()},children:`Done — re-check`})})]}):(0,O.jsx)(Ci,{variant:`solid`,disabled:!t||o.isPending,title:t?void 0:`Install a container runtime first`,onClick:()=>o.mutate({kind:`build-image`}),children:o.isPending?`Starting…`:`Build image`})}):null}function QS({probe:e,onDone:t}){let[n,r]=(0,D.useState)(null),[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(null),c=up(),l=j.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>r(e),onError:e=>c.push(e.message)}),u=j.setup.afkToken.useMutation({onSuccess:e=>{s(e),e.valid&&t()},onError:e=>c.push(e.message)});return e?(0,O.jsxs)(YS,{probe:e,children:[n?(0,O.jsx)(`div`,{className:`afk-term`,children:(0,O.jsx)(kp,{label:`setup-token`,children:(0,O.jsx)(eS,{sessionId:n})})}):(0,O.jsx)(Ci,{variant:`ghost`,onClick:()=>l.mutate({kind:`setup-token`}),disabled:l.isPending,children:l.isPending?`Starting…`:`Run claude setup-token`}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`afk-token-input`,children:`Paste the token it prints`}),(0,O.jsx)(`input`,{id:`afk-token-input`,className:`op-input mono`,value:i,onChange:e=>a(e.target.value),placeholder:`sk-ant-oat01-…`,spellCheck:!1,autoComplete:`off`}),(0,O.jsx)(`div`,{className:`afk-term-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,disabled:i.trim()===``||u.isPending,onClick:()=>u.mutate({token:i}),children:u.isPending?`Verifying…`:`Save & verify`})}),o&&(0,O.jsxs)(`div`,{className:`afk-verdict ${o.valid?`is-ok`:`is-warn`}`,children:[o.valid?`✓ `:`⚠ `,o.detail]})]}):null}function $S({projectId:e,onClose:t}){let n=j.settings.get.useQuery(),r=j.settings.get.useQuery({projectId:e});return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,O.jsx)(`div`,{className:`peek-backdrop`,onClick:t,children:(0,O.jsxs)(`div`,{className:`peek settings`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`peek-head`,children:[(0,O.jsx)(`span`,{className:`settings-title`,children:`Settings`}),(0,O.jsx)(`button`,{className:`peek-close`,onClick:t,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,O.jsxs)(`div`,{className:`peek-body settings-body`,children:[(0,O.jsx)(eC,{title:`Global`,hint:`Machine-wide defaults for every project.`,query:n,rowsOf:WS}),(0,O.jsx)(iC,{query:n}),(0,O.jsx)(eC,{title:`This project`,hint:`Overrides that apply only to the current project.`,query:r,rowsOf:GS,projectId:e}),(0,O.jsxs)(`section`,{className:`settings-section`,children:[(0,O.jsxs)(`div`,{className:`settings-section-head`,children:[(0,O.jsx)(`h3`,{className:`settings-section-title`,children:`AFK burns`}),(0,O.jsx)(`span`,{className:`settings-section-hint`,children:`Prerequisites for unattended sandbox runs.`})]}),(0,O.jsx)(JS,{})]})]})]})})}function eC({title:e,hint:t,query:n,rowsOf:r,projectId:i}){let a=n.data?r(n.data):[];return(0,O.jsxs)(`section`,{className:`settings-section`,children:[(0,O.jsxs)(`div`,{className:`settings-section-head`,children:[(0,O.jsx)(`h3`,{className:`settings-section-title`,children:e}),(0,O.jsx)(`span`,{className:`settings-section-hint`,children:t})]}),n.isLoading&&(0,O.jsx)(M,{children:`loading…`}),n.error&&(0,O.jsxs)(M,{children:[`could not load settings: `,n.error.message]}),n.data&&a.length===0&&(0,O.jsx)(M,{children:`no settings in this scope`}),a.map(e=>(0,O.jsx)(tC,{row:e,projectId:i},e.key))]})}function tC({row:e,projectId:t}){let n=j.useUtils(),r=up(),[i,a]=(0,D.useState)(e.value);(0,D.useEffect)(()=>a(e.value),[e.value]);let o=j.settings.update.useMutation({onSuccess:()=>{n.settings.get.invalidate()},onError:t=>{a(e.value),r.push(t.message)}}),s=n=>{let r=n.trim();if(r===e.value.trim())return;let i=e.control===`number`?Number(r):r;o.mutate({...t?{projectId:t}:{},key:e.key,value:i})},c=()=>t&&o.mutate({projectId:t,key:e.key,value:null}),l=`set-${e.key}`;return(0,O.jsxs)(`div`,{className:`settings-field${e.readOnly?` is-locked`:``}`,children:[(0,O.jsxs)(`label`,{className:`settings-field-head`,htmlFor:l,children:[(0,O.jsx)(`span`,{className:`settings-field-label`,children:e.label}),e.restartRequired&&(0,O.jsx)(`span`,{className:`settings-badge is-warn`,title:`Takes effect after a server restart`,children:`restart required`}),e.overridden&&(0,O.jsx)(`span`,{className:`settings-badge is-override`,children:`overridden`}),o.isPending&&(0,O.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),e.help&&(0,O.jsx)(`div`,{className:`settings-field-help`,children:e.help}),e.readOnly?(0,O.jsx)(`div`,{className:`settings-readonly mono`,id:l,children:e.value||`—`}):e.control===`select`&&e.allowCustom?(0,O.jsx)(rC,{id:l,value:e.value,options:e.options,disabled:o.isPending,onCommit:s}):e.control===`select`?(0,O.jsx)(`select`,{id:l,className:`settings-input`,value:i,disabled:o.isPending,onChange:e=>{a(e.target.value),s(e.target.value)},children:e.options.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))}):(0,O.jsx)(`input`,{id:l,className:`settings-input mono`,type:e.control===`number`?`number`:`text`,value:i,disabled:o.isPending,onChange:e=>a(e.target.value),onBlur:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&(a(e.value),t.currentTarget.blur())}}),e.note&&(0,O.jsx)(`div`,{className:`settings-field-note`,children:e.note}),e.overridden&&t&&(0,O.jsx)(`button`,{className:`settings-clear`,onClick:c,disabled:o.isPending,children:`Clear override`})]})}var nC=`__custom__`;function rC({id:e,value:t,options:n,disabled:r,onCommit:i}){let[a,o]=(0,D.useState)(!n.includes(t)&&t!==``),[s,c]=(0,D.useState)(t);return(0,D.useEffect)(()=>{c(t),o(!n.includes(t)&&t!==``)},[t,n]),(0,O.jsxs)(`div`,{className:`settings-combo`,children:[(0,O.jsxs)(`select`,{id:e,className:`settings-input`,value:a?nC:t,disabled:r,onChange:e=>{if(e.target.value===nC){o(!0);return}o(!1),i(e.target.value)},children:[n.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e)),(0,O.jsx)(`option`,{value:nC,children:`Custom…`})]}),a&&(0,O.jsx)(`input`,{className:`settings-input mono`,type:`text`,placeholder:`model id (e.g. claude-opus-4-8)`,value:s,disabled:r,onChange:e=>c(e.target.value),onBlur:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})]})}function iC({query:e}){let t=j.useUtils(),n=up(),[r,i]=(0,D.useState)(!1),a=j.settings.update.useMutation({onSuccess:()=>{t.settings.get.invalidate()},onError:e=>n.push(e.message)}),o=e.data,s=o?KS(o):[],c=o?qS(o):[],l=o?.fields.find(e=>e.key===`model`),u=(e,t)=>{let n=t.trim();n!==``&&a.mutate({key:e,value:n})};return(0,O.jsxs)(`section`,{className:`settings-section`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`settings-advanced-toggle`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,O.jsx)(`span`,{className:`settings-section-title`,children:`Advanced — per-step models`}),(0,O.jsxs)(`span`,{className:`settings-section-hint`,children:[s.length>0?`${s.length} override${s.length===1?``:`s`}`:`none set`,r?` ▾`:` ▸`]})]}),r&&(0,O.jsxs)(`div`,{className:`settings-advanced-body`,children:[s.length===0&&(0,O.jsx)(M,{children:`every step uses the default model.`}),s.map(e=>(0,O.jsxs)(`div`,{className:`settings-field`,children:[(0,O.jsxs)(`div`,{className:`settings-field-head`,children:[(0,O.jsx)(`span`,{className:`settings-field-label`,children:e.label}),a.isPending&&(0,O.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),(0,O.jsx)(rC,{id:`step-${e.key}`,value:e.value,options:e.options,disabled:a.isPending,onCommit:t=>u(e.key,t)}),(0,O.jsx)(`button`,{className:`settings-clear`,disabled:a.isPending,onClick:()=>a.mutate({key:e.key,value:null}),children:`Reset to default`})]},e.key)),c.length>0&&(0,O.jsxs)(`div`,{className:`settings-field`,children:[(0,O.jsx)(`label`,{className:`settings-field-label`,htmlFor:`step-add`,children:`Add an override`}),(0,O.jsxs)(`select`,{id:`step-add`,className:`settings-input`,value:``,disabled:a.isPending,onChange:e=>{let t=e.target.value;t&&u(t,typeof l?.value==`string`?l.value:``)},children:[(0,O.jsx)(`option`,{value:``,children:`Choose a step…`}),c.map(e=>(0,O.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]})]})]})}function aC({projectId:e,nav:t}){let n=bi(e),{selectedFeatureId:r,select:i,setCmdk:a}=n,[o,s]=(0,D.useState)(null),c=j.feature.list.useQuery({projectId:e},{refetchInterval:1500});(0,D.useEffect)(()=>{!r&&c.data&&c.data.length>0&&i(c.data[0].id)},[r,c.data,i]),(0,D.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),a(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let l=!n.inspectorCollapsed&&!!n.selectedFeatureId&&!n.creating;return(0,O.jsxs)(`div`,{className:`shell${n.inspectorCollapsed?` inspector-collapsed`:``}`,children:[(0,O.jsx)(Si,{nav:t,onOpenCmdk:()=>n.setCmdk(!0),onOpenSettings:()=>n.setSettings(!0),onToggleInspector:n.toggleInspector,inspectorCollapsed:n.inspectorCollapsed}),(0,O.jsxs)(`div`,{className:`shell-body`,children:[(0,O.jsx)(op,{projectId:e,selectedFeatureId:n.selectedFeatureId,onSelect:n.select,onNewFeature:n.startCreate}),n.creating?(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(OS,{projectId:e,onCancel:n.cancelCreate,onCreated:n.select})}):n.selectedFeatureId?(0,O.jsx)(SS,{featureId:n.selectedFeatureId,viewedPhase:n.viewedPhase,onViewPhase:n.viewPhase,guidance:n.guidance,driving:o,onDriveChange:s},`ws-${n.selectedFeatureId}`):(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(oC,{onNewFeature:n.startCreate})}),l&&n.selectedFeatureId&&(0,O.jsx)(_p,{featureId:n.selectedFeatureId},`insp-${n.selectedFeatureId}`)]}),(0,O.jsx)(Dp,{projectId:e,activeFeatureId:n.selectedFeatureId,driving:o,onDriveChange:s}),(0,O.jsx)(AS,{open:n.cmdkOpen,onClose:()=>n.setCmdk(!1),features:c.data??[],selectedFeatureId:n.selectedFeatureId,onSelect:n.select,onNewFeature:n.startCreate,onOpenSettings:()=>n.setSettings(!0),nav:t}),n.settingsOpen&&(0,O.jsx)($S,{projectId:e,onClose:()=>n.setSettings(!1)})]})}function oC({onNewFeature:e}){return(0,O.jsxs)(`div`,{className:`ws-empty`,children:[(0,O.jsx)(`div`,{className:`ws-empty-logo mono`,children:`r`}),(0,O.jsx)(`span`,{className:`dim-line mono`,children:`select a feature to begin`}),(0,O.jsx)(`button`,{className:`btn btn-ghost btn-xs`,onClick:e,children:`+ New feature`})]})}function sC({nav:e}){let t=e.projects??[],n=j.useQueries(e=>t.map(t=>e.feature.list({projectId:t.id},{refetchInterval:1500})));return(0,O.jsxs)(`div`,{className:`home`,children:[(0,O.jsxs)(`header`,{className:`home-head`,children:[(0,O.jsxs)(`div`,{className:`home-title`,children:[(0,O.jsx)(`span`,{className:`tb-logo mono`,children:`r`}),(0,O.jsx)(`span`,{className:`home-title-text`,children:`Projects`}),(0,O.jsx)(`span`,{className:`home-count`,children:t.length})]}),(0,O.jsx)(`p`,{className:`home-sub`,children:`Every open project and where it stands. Open one to work its pipeline — runs keep going in the background while you switch.`})]}),(0,O.jsxs)(`div`,{className:`home-grid`,children:[t.map((t,r)=>{let i=n[r]?.data;return(0,O.jsx)(lC,{project:t,stats:di(i??[]),loading:i===void 0,onOpen:()=>e.enterProject(t.id)},t.id)}),(0,O.jsxs)(`button`,{className:`open-card`,onClick:e.showOpen,children:[(0,O.jsx)(`span`,{className:`open-card-plus`,children:`+`}),(0,O.jsx)(`span`,{className:`open-card-label`,children:`Open a project`}),(0,O.jsx)(`span`,{className:`open-card-sub`,children:`Point runcastle at a local git repo`})]})]})]})}var cC={attention:`Needs you`,working:`Agent working`,steady:`Steady`,empty:`No features yet`};function lC({project:e,stats:t,loading:n,onOpen:r}){let i=up(),a=j.useUtils(),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(e.name),u=j.project.rename.useMutation({onSuccess:async()=>{await a.project.list.invalidate(),s(!1)},onError:e=>i.push(e.message)}),d=j.project.close.useMutation({onSuccess:async()=>{await a.project.list.invalidate(),i.push(`closed ${e.name}`,`info`)},onError:e=>i.push(e.message)}),f=t.activeRuns>0,p=()=>{let t=c.trim();t&&t!==e.name?u.mutate({projectId:e.id,name:t}):s(!1)};return(0,O.jsxs)(`div`,{className:`project-card health-${t.health}`,children:[(0,O.jsxs)(`button`,{className:`pc-main`,onClick:r,title:`Open ${e.name}`,children:[(0,O.jsxs)(`div`,{className:`pc-head`,children:[o?(0,O.jsx)(`input`,{className:`pc-rename mono`,value:c,autoFocus:!0,onClick:e=>e.stopPropagation(),onChange:e=>l(e.target.value),onKeyDown:t=>{t.stopPropagation(),t.key===`Enter`&&p(),t.key===`Escape`&&(l(e.name),s(!1))},onBlur:p}):(0,O.jsx)(`span`,{className:`pc-name`,children:e.name}),(0,O.jsx)(`span`,{className:`pc-health-dot health-dot-${t.health}`,title:cC[t.health]})]}),(0,O.jsx)(`span`,{className:`pc-path mono`,children:e.repoPath}),(0,O.jsxs)(`span`,{className:`pc-branch mono`,children:[`⎇ `,e.mainBranch]}),(0,O.jsxs)(`div`,{className:`pc-stats`,children:[(0,O.jsx)(uC,{n:t.total,label:t.total===1?`feature`:`features`}),(0,O.jsx)(uC,{n:t.activeRuns,label:`running`,tone:f?`run`:void 0,spin:f}),(0,O.jsx)(uC,{n:t.needsYou,label:`needs you`,tone:t.needsYou>0?`needs`:void 0})]}),(0,O.jsx)(`span`,{className:`pc-health-label`,children:n?`loading…`:cC[t.health]})]}),(0,O.jsxs)(`div`,{className:`pc-actions`,children:[(0,O.jsx)(`button`,{className:`pc-action`,onClick:()=>{l(e.name),s(!0)},children:`Rename`}),(0,O.jsx)(`button`,{className:`pc-action pc-action-danger`,disabled:f||d.isPending,title:f?`a run is in flight — cannot close`:`Close project`,onClick:()=>d.mutate({projectId:e.id}),children:`Close`})]})]})}function uC({n:e,label:t,tone:n,spin:r}){return(0,O.jsxs)(`span`,{className:`pc-stat${n?` pc-stat-${n}`:``}`,children:[r&&(0,O.jsx)(`span`,{className:`spin-ring`}),(0,O.jsx)(`span`,{className:`pc-stat-n`,children:e}),(0,O.jsx)(`span`,{className:`pc-stat-label`,children:t})]})}function dC({firstRun:e,onOpened:t,onCancel:n}){let[r,i]=(0,D.useState)(``),a=up(),o=j.useUtils(),s=j.project.open.useMutation({onSuccess:async e=>{await o.project.list.invalidate(),a.push(`opened ${e.name} on ${e.mainBranch}`,`info`),t(e.id)},onError:e=>a.push(e.message)}),c=()=>{let e=r.trim();e&&s.mutate({repoPath:e})};return(0,O.jsx)(`div`,{className:`open-project`,children:(0,O.jsxs)(`div`,{className:`op-card`,children:[(0,O.jsx)(`div`,{className:`op-logo mono`,children:`r`}),(0,O.jsx)(`div`,{className:`op-kick`,children:e?`WELCOME TO RUNCASTLE`:`OPEN A PROJECT`}),(0,O.jsx)(`div`,{className:`op-h`,children:e?`Open your first project`:`Open a project`}),(0,O.jsx)(`div`,{className:`op-sub`,children:`Point runcastle at a local git repository. It detects the default branch and opens the project — every feature runs its pipeline against this repo.`}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`op-repo-path`,children:`Repository path`}),(0,O.jsx)(`input`,{id:`op-repo-path`,className:`op-input mono`,value:r,onChange:e=>i(e.target.value),placeholder:`/path/to/your/repo`,autoFocus:!0,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&c(),t.key===`Escape`&&!e&&n()}}),(0,O.jsx)(`div`,{className:`op-hint`,children:`The default branch is detected automatically when the project opens.`}),(0,O.jsxs)(`div`,{className:`op-actions`,children:[!e&&(0,O.jsx)(Ci,{variant:`ghost`,onClick:n,disabled:s.isPending,children:`Cancel`}),(0,O.jsx)(Ci,{variant:`solid`,onClick:c,disabled:s.isPending||r.trim()===``,children:s.isPending?`Opening…`:`Open`})]})]})})}function fC({onOpened:e,onCancel:t}){let n=j.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`)?.status===`ok`,[i,a]=(0,D.useState)(null),o=i??(r?`afk`:`identity`);return n.isLoading?(0,O.jsx)(`div`,{className:`open-project`,children:(0,O.jsx)(M,{children:`preparing setup…`})}):o===`project`?(0,O.jsx)(dC,{firstRun:!0,onOpened:e,onCancel:t}):(0,O.jsx)(`div`,{className:`open-project`,children:(0,O.jsxs)(`div`,{className:`op-card wizard-card`,children:[(0,O.jsx)(`div`,{className:`op-logo mono`,children:`r`}),(0,O.jsx)(mC,{current:o}),o===`identity`?(0,O.jsx)(hC,{onNext:()=>a(`afk`)}):(0,O.jsx)(gC,{onNext:()=>a(`project`)})]})})}var pC=[{key:`identity`,label:`Git identity`},{key:`afk`,label:`AFK burns`},{key:`project`,label:`First project`}];function mC({current:e}){let t=pC.findIndex(t=>t.key===e);return(0,O.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Setup progress`,children:pC.map((e,n)=>(0,O.jsxs)(`li`,{className:`wizard-step${n===t?` is-current`:``}${n<t?` is-done`:``}`,children:[(0,O.jsx)(`span`,{className:`wizard-step-dot`,"aria-hidden":!0}),e.label]},e.key))})}function hC({onNext:e}){let[t,n]=(0,D.useState)(``),[r,i]=(0,D.useState)(``),a=up(),o=j.useUtils(),s=j.setup.gitIdentity.useMutation({onSuccess:async()=>{await o.setup.doctor.invalidate(),e()},onError:e=>a.push(e.message)}),c=t.trim()!==``&&r.includes(`@`),l=()=>c&&s.mutate({name:t.trim(),email:r.trim()});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`op-kick`,children:`WELCOME TO RUNCASTLE`}),(0,O.jsx)(`div`,{className:`op-h`,children:`Set your git identity`}),(0,O.jsxs)(`div`,{className:`op-sub`,children:[`runcastle commits documentation and merges on your behalf, so it needs a name and email. This writes to `,(0,O.jsx)(`code`,{className:`mono`,children:`git config --global`}),`.`]}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-name`,children:`Name`}),(0,O.jsx)(`input`,{id:`wiz-name`,className:`op-input mono`,value:t,onChange:e=>n(e.target.value),placeholder:`Ada Lovelace`,autoFocus:!0,spellCheck:!1,onKeyDown:e=>e.key===`Enter`&&l()}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-email`,children:`Email`}),(0,O.jsx)(`input`,{id:`wiz-email`,className:`op-input mono`,value:r,onChange:e=>i(e.target.value),placeholder:`ada@example.com`,spellCheck:!1,onKeyDown:e=>e.key===`Enter`&&l()}),(0,O.jsx)(`div`,{className:`op-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,onClick:l,disabled:!c||s.isPending,children:s.isPending?`Saving…`:`Continue`})})]})}function gC({onNext:e}){return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(JS,{onDismiss:e}),(0,O.jsx)(`div`,{className:`op-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,onClick:e,children:`Continue to your first project`})})]})}var _C=`runcastle.update.dismissed`;function vC(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function yC(){let e=j.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[t,n]=(0,D.useState)(()=>{try{return localStorage.getItem(_C)}catch{return null}}),r=e.data;return!r||!r.latest||!vC(r,t)?null:(0,O.jsxs)(`div`,{className:`update-banner`,role:`status`,children:[(0,O.jsx)(`span`,{className:`update-banner-dot`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`update-banner-text`,children:[`runcastle `,(0,O.jsx)(`strong`,{children:r.latest}),` is available`,(0,O.jsx)(`span`,{className:`update-banner-sep`,children:` · `}),(0,O.jsxs)(`span`,{className:`update-banner-dim`,children:[`you're on `,r.current]})]}),(0,O.jsx)(`code`,{className:`update-banner-cmd`,children:r.command}),(0,O.jsx)(`button`,{className:`update-banner-dismiss`,onClick:()=>{try{localStorage.setItem(_C,r.latest)}catch{}n(r.latest)},"aria-label":`Dismiss update notice`,title:`Dismiss`,children:`×`})]})}function bC(){let e=pi(),t;return t=e.projects===void 0?(0,O.jsx)(`div`,{className:`app-loading`,children:(0,O.jsx)(M,{children:`loading projects…`})}):e.view===`open`&&e.projects.length===0?(0,O.jsx)(fC,{onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`open`?(0,O.jsx)(dC,{firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`project`&&e.currentProjectId?(0,O.jsx)(aC,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,O.jsx)(sC,{nav:e}),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(yC,{}),t]})}function xC(){return(0,O.jsx)(bC,{})}function SC(){let[e]=(0,D.useState)(()=>new Xe({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})),[t]=(0,D.useState)(()=>j.createClient({links:[Yn({url:`/api/trpc`})]}));return(0,O.jsx)(j.Provider,{client:t,queryClient:e,children:(0,O.jsx)(rt,{client:e,children:(0,O.jsx)(lp,{children:(0,O.jsx)(xC,{})})})})}var CC=document.getElementById(`root`);if(!CC)throw Error(`#root not found`);(0,Sr.createRoot)(CC).render((0,O.jsx)(D.StrictMode,{children:(0,O.jsx)(SC,{})}));
108
+ `)){let e=t.match(/^##\s+(.+?)\s*$/);e?(i(),n=e[1]):n!==null&&r.push(t)}return i(),t}function cS({featureId:e,relPath:t}){let n=j.docs.read.useQuery({featureId:e,relPath:t});return(0,O.jsxs)(`div`,{className:`spec-doc`,children:[(0,O.jsx)(`div`,{className:`spec-meta`,children:t}),n.isLoading&&(0,O.jsxs)(M,{children:[`loading `,t,`…`]}),n.error&&(0,O.jsxs)(M,{children:[`could not read `,t]}),n.data&&(0,O.jsx)(`div`,{className:`spec-body`,children:n.data.content})]})}function lS({full:e,driving:t}){let{feature:n,tickets:r,runs:i}=e,a=qf(i),o=r.length,s=r.filter(e=>e.status===`done`).length,c=r.filter(e=>e.status===`failed`).length,l=r.reduce((e,t)=>e+t.commits.length,0),u=t?.featureId===n.id,d=c>0?`var(--danger)`:`var(--ok)`,f=a?.status===`succeeded`?`var(--ok)`:a?.status===`failed`?`var(--danger)`:`var(--text-3)`;return(0,O.jsxs)(`div`,{className:`review-body`,children:[(0,O.jsxs)(`div`,{className:`review-grid`,children:[(0,O.jsxs)(`div`,{className:`review-card`,children:[(0,O.jsx)(wi,{children:`Summary`}),(0,O.jsxs)(`div`,{className:`check-row`,children:[(0,O.jsx)(`span`,{className:`check-dot`,style:{background:d}}),(0,O.jsx)(`span`,{className:`check-k`,children:`tickets`}),(0,O.jsxs)(`span`,{className:`check-v`,children:[s,`/`,o,` done`,c>0?` · ${c} failed`:``]})]}),(0,O.jsxs)(`div`,{className:`check-row`,children:[(0,O.jsx)(`span`,{className:`check-dot`,style:{background:f}}),(0,O.jsx)(`span`,{className:`check-k`,children:`run`}),(0,O.jsx)(`span`,{className:`check-v`,children:a?`${a.status}${a.summary?` · ${a.summary}`:``}`:`no run recorded`})]}),(0,O.jsxs)(`div`,{className:`check-row`,children:[(0,O.jsx)(`span`,{className:`check-dot`,style:{background:`var(--ph-shipped)`}}),(0,O.jsx)(`span`,{className:`check-k`,children:`changes`}),(0,O.jsxs)(`span`,{className:`check-v`,children:[l,` commit`,l===1?``:`s`]})]}),(0,O.jsxs)(`div`,{className:`review-foot`,children:[`⎇ `,n.branch]})]}),(0,O.jsxs)(`div`,{className:`review-card`,children:[(0,O.jsx)(wi,{children:`Test drive`}),u&&t?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`drive-live`,children:[(0,O.jsx)(`span`,{className:`drive-pulse`}),(0,O.jsx)(`span`,{className:`drive-label`,children:`driving now`}),(0,O.jsx)(`span`,{className:`drive-loc`,children:t.branch})]}),(0,O.jsx)(`div`,{className:`drive-copy`,children:`Click through the feature. When it feels right, merge — or stop the drive and send feedback back through tickets.`})]}):(0,O.jsx)(`div`,{className:`drive-copy`,children:`Nothing is running yet. Start the test drive from the next step to boot this branch on its own port and click through the feature yourself — the merge gate wants a human behind the wheel.`})]})]}),u&&(0,O.jsx)(uS,{featureId:n.id})]})}function uS({featureId:e}){let[t,n]=(0,D.useState)(!1),r=j.feature.driveInfo.useQuery(void 0,{refetchInterval:1500}).data;return!r||r.featureId!==e?null:(0,O.jsxs)(`div`,{className:`drive-pane`,children:[(0,O.jsxs)(`div`,{className:`drive-pane-strip`,children:[(0,O.jsx)(`span`,{className:`drive-pane-kind`,children:`dev server`}),(0,O.jsx)(`span`,{className:`drive-pane-loc`,children:r.branch}),(0,O.jsx)(`span`,{className:`drive-pane-spacer`}),r.devUrl&&(0,O.jsx)(`a`,{className:`drive-open`,href:r.devUrl,target:`_blank`,rel:`noreferrer noopener`,children:`Open app ↗`}),r.devPaneId&&(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost drive-pane-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:t?`Hide output`:`Show output`})]}),t&&(r.devPaneId?(0,O.jsx)(`div`,{className:`drive-pane-term`,children:(0,O.jsx)(kp,{label:`dev terminal`,children:(0,O.jsx)(eS,{sessionId:r.devPaneId})})}):(0,O.jsx)(`div`,{className:`drive-pane-empty`,children:`no dev command configured for this project`}))]})}function dS({full:e}){let t=[...dp(e.feature.id)].reverse().find(e=>e.type===`feature.shipped`||e.type===`merge.conflict`||e.type===`feature.status`),n=t&&t.type===`feature.shipped`?mp(t.ts):``;return(0,O.jsxs)(`div`,{className:`shipped-hero`,children:[(0,O.jsx)(`div`,{className:`shipped-check`,children:`✓`}),(0,O.jsx)(`div`,{className:`shipped-title`,children:`Shipped to main`}),(0,O.jsxs)(`div`,{className:`shipped-meta`,children:[`⎇ `,e.feature.branch,n?` · merged ${n} ago`:``]}),(0,O.jsx)(`div`,{className:`shipped-sub`,children:`The branch is merged and the pipeline is complete. The full history stays in the activity log.`})]})}function fS({featureId:e,readonly:t=!1}){let n=up(),r=j.feature.get.useQuery({id:e},{refetchInterval:1500}),[i,a]=(0,D.useState)(()=>new Set),o=r.data?.feature.projectId,s=j.settings.get.useQuery({projectId:o},{enabled:!!o}),c=s.data?.fields.find(e=>e.key===`stepModels.implement`&&e.source===`file`)??s.data?.fields.find(e=>e.key===`model`),l=typeof c?.value==`string`?c.value:`…`;if(r.isLoading)return(0,O.jsx)(M,{children:`loading tickets…`});if(!r.data)return(0,O.jsxs)(M,{children:[`could not load tickets: `,r.error?.message??`unknown`]});let u=r.data.tickets,d=[...r.data.sessions].reverse().find(e=>e.status===`live`||e.status===`launching`),f=u.length,p=u.filter(e=>e.status===`done`).length,m=u.filter(e=>e.status===`failed`).length,h=u.filter(e=>e.status===`burning`).length,g=u.filter(e=>e.status===`cancelled`).length,_=[`${p}/${f} done`];m>0&&_.push(`${m} failed`),h>0&&_.push(`${h} burning`),g>0&&_.push(`${g} cancelled`);let v=_.join(` · `),y=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),b=e=>{navigator.clipboard.writeText(e),n.push(`copied ${pp(e)}`,`info`)};return(0,O.jsxs)(O.Fragment,{children:[d&&(0,O.jsxs)(`div`,{className:`grill-panel tickets-session`,children:[(0,O.jsxs)(`div`,{className:`grill-strip`,children:[(0,O.jsx)(`span`,{className:`grill-kind`,children:d.kind}),(0,O.jsx)(`span`,{className:`grill-sid`,children:d.ccSessionId??d.id}),(0,O.jsx)(Oi,{status:d.status}),(0,O.jsx)(`span`,{className:`grill-strip-spacer`}),(0,O.jsx)(Op,{featureId:e,sessionId:d.id})]}),(0,O.jsx)(`div`,{className:`grill-term`,id:`grill-term`,children:(0,O.jsx)(kp,{label:`terminal`,children:(0,O.jsx)(eS,{sessionId:d.id})})})]}),(0,O.jsxs)(`div`,{className:`body-title`,children:[(0,O.jsx)(wi,{children:`Tickets`}),(0,O.jsx)(`span`,{className:`body-meta`,children:v}),(0,O.jsx)(`span`,{style:{flex:1}}),(0,O.jsxs)(`span`,{className:`chip chip-neutral`,title:`sandbox`,children:[`sandbox · `,Tp]}),(0,O.jsx)(`span`,{className:`chip chip-neutral`,title:`model`,children:l})]}),f===0?(0,O.jsx)(M,{children:`no tickets yet — a grill session emits them.`}):(0,O.jsx)(`div`,{className:`ledger`,children:u.map(e=>{let t=i.has(e.id);return(0,O.jsxs)(`div`,{className:`ledger-row${t?` is-open`:``}`,children:[(0,O.jsxs)(`button`,{className:`ledger-head`,onClick:()=>y(e.id),children:[(0,O.jsx)(`span`,{className:`lg-caret`,children:`▸`}),(0,O.jsxs)(`span`,{className:`lg-seq`,children:[`#`,e.seq]}),(0,O.jsx)(`span`,{className:`lg-title`,children:e.title}),e.blockedBy.length>0&&(0,O.jsxs)(`span`,{className:`lg-block`,children:[`⊘ after `,e.blockedBy.join(`, `)]}),(0,O.jsx)(`span`,{className:`lg-meta`,children:(0,O.jsx)(Ei,{status:e.status})})]}),t&&(0,O.jsxs)(`div`,{className:`ledger-detail`,children:[(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`GOAL`}),(0,O.jsx)(`div`,{className:`td-body`,children:e.goal})]}),e.context&&(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`CONTEXT`}),(0,O.jsx)(`div`,{className:`td-body`,children:e.context})]}),(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`ACCEPTANCE`}),(0,O.jsx)(`ul`,{className:`td-list`,children:e.acceptanceCriteria.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))})]}),(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`SEAMS`}),(0,O.jsx)(`div`,{className:`td-seams`,children:e.seams.map((e,t)=>(0,O.jsx)(`span`,{className:`seam`,children:e},t))})]}),(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`COMMITS`}),e.commits.length===0?(0,O.jsx)(`div`,{className:`td-empty`,children:`no commits yet — the burn writes them`}):(0,O.jsx)(`div`,{className:`td-commits`,children:e.commits.map(e=>(0,O.jsx)(`button`,{className:`commit-sha`,onClick:()=>b(e),title:`copy full sha`,children:pp(e)},e))})]}),e.status===`failed`&&e.error&&(0,O.jsxs)(`div`,{className:`td-section td-error`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`Error`}),(0,O.jsx)(`div`,{className:`td-error-body`,children:e.error})]}),e.status===`cancelled`&&e.error&&(0,O.jsxs)(`div`,{className:`td-section`,children:[(0,O.jsx)(`div`,{className:`td-heading`,children:`Cancelled`}),(0,O.jsx)(`div`,{className:`td-body`,children:e.error})]})]})]},e.id)})})]})}function pS({ticketId:e}){let{chunks:t,live:n,trimmed:r}=mS(e),i=(0,D.useRef)(null),[a,o]=(0,D.useState)(!0),s=(0,D.useMemo)(()=>hS(t),[t]);return(0,D.useEffect)(()=>{if(!a)return;let e=i.current;e&&(e.scrollTop=e.scrollHeight)},[s,n,a]),(0,O.jsxs)(`div`,{className:`agent-body`,ref:i,onScroll:()=>{let e=i.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;o(t)},children:[r&&(0,O.jsx)(`div`,{className:`agent-trimmed`,children:`… earlier output trimmed …`}),s.length===0&&!n&&(0,O.jsx)(M,{children:`no agent output captured — transcripts are held in server memory for the current burn; older runs keep only the event timeline.`}),s.length===0&&n&&(0,O.jsx)(M,{children:`waiting for the agent's first output…`}),s.map((e,t)=>e.kind===`text`?(0,O.jsxs)(`div`,{className:`agent-turn`,children:[(0,O.jsx)(`span`,{className:`agent-glyph is-text`,children:`⏺`}),(0,O.jsx)(`span`,{className:`agent-prose`,children:e.text})]},t):(0,O.jsxs)(`div`,{className:`agent-turn is-tool`,children:[(0,O.jsx)(`span`,{className:`agent-glyph is-tool`,children:`●`}),(0,O.jsxs)(`span`,{className:`agent-toolline`,children:[(0,O.jsx)(`span`,{className:`agent-toolname`,children:e.name}),e.args&&(0,O.jsxs)(`span`,{className:`agent-toolargs`,children:[`(`,e.args,`)`]})]})]},t)),n&&(0,O.jsxs)(`div`,{className:`agent-live-row`,children:[(0,O.jsx)(`span`,{className:`agent-spinner`,children:`✳`}),(0,O.jsx)(`span`,{className:`agent-live-label`,children:`Burning…`}),(0,O.jsx)(`span`,{className:`agent-cursor`,children:`▍`})]}),!a&&(0,O.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>o(!0),children:`Follow ⇣`})]})}function mS(e){let[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(!1),s=t.length>0?t[t.length-1].i:void 0,c=j.run.agentTranscript.useQuery({ticketId:e,after:s},{refetchInterval:1e3});return(0,D.useEffect)(()=>{let e=c.data;e&&(i(e.live),o(e.firstIndex>0),n(t=>{let n=t.length>0?t[t.length-1].i:-1;if(e.nextIndex<=n)return[];if(e.chunks.length===0)return t;let r=e.chunks.filter(e=>e.i>n);return r.length===0?t:[...t,...r]}))},[c.data]),{chunks:t,live:r,trimmed:a}}function hS(e){let t=[];for(let n of e){if(n.kind===`tool`){t.push({kind:`tool`,name:n.name??`tool`,args:gS(n.text)});continue}let e=t[t.length-1];e&&e.kind===`text`?e.text+=n.text:t.push({kind:`text`,text:n.text})}return t.map(e=>e.kind===`text`?{...e,text:e.text.trim()}:e).filter(e=>e.kind!==`text`||e.text.length>0)}function gS(e){let t=e.replace(/\s+/g,` `).trim();return t.length>300?`${t.slice(0,300)}…`:t}function _S({featureId:e,runId:t,readonly:n=!1}){let r=j.feature.get.useQuery({id:e},{refetchInterval:1500}),i=j.run.get.useQuery({runId:t},{refetchInterval:1500,enabled:!!t}),a=dp(e),o=r.data?.tickets??[],s=(0,D.useMemo)(()=>a.filter(e=>e.runId===t),[a,t]),c=(0,D.useMemo)(()=>xS(s),[s]),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(`agent`),p=o.find(e=>e.status===`burning`)??[...o].reverse().find(e=>e.status===`done`||e.status===`failed`),m=l??p?.id??null,h=o.find(e=>e.id===m)??null,g=o.filter(e=>e.status===`done`).length,_=o.length,v=i.data?hp(i.data.startedAt,i.data.endedAt??Date.now()):``,y=[...r.data?.sessions??[]].reverse().find(e=>e.status===`live`||e.status===`launching`);return!t&&!y?(0,O.jsx)(M,{children:`no run yet — start the burn from the workspace.`}):(0,O.jsxs)(`div`,{className:`ws-body-inner`,children:[y&&(0,O.jsxs)(`div`,{className:`grill-panel tickets-session`,children:[(0,O.jsxs)(`div`,{className:`grill-strip`,children:[(0,O.jsx)(`span`,{className:`grill-kind`,children:y.kind}),(0,O.jsx)(`span`,{className:`grill-sid`,children:y.ccSessionId??y.id}),(0,O.jsx)(Oi,{status:y.status}),(0,O.jsx)(`span`,{className:`grill-strip-spacer`}),(0,O.jsx)(Op,{featureId:e,sessionId:y.id})]}),(0,O.jsx)(`div`,{className:`grill-term`,id:`grill-term`,children:(0,O.jsx)(kp,{label:`terminal`,children:(0,O.jsx)(eS,{sessionId:y.id})})})]}),(0,O.jsxs)(`div`,{className:`body-title`,children:[(0,O.jsx)(`span`,{className:`section-title`,children:`Run`}),i.data&&(0,O.jsx)(Di,{status:i.data.status}),(0,O.jsxs)(`span`,{className:`body-meta`,children:[g,`/`,_,` done · `,v]})]}),(0,O.jsxs)(`div`,{className:`run-split`,children:[(0,O.jsxs)(`div`,{className:`run-lanes-panel`,children:[(0,O.jsx)(`div`,{className:`panel-cap`,children:`Ticket lanes`}),(0,O.jsxs)(`div`,{className:`run-lanes`,children:[o.length===0&&(0,O.jsx)(M,{children:`no ticket lanes`}),o.map(e=>(0,O.jsx)(vS,{ticket:e,duration:c.get(e.id),selected:e.id===m,readonly:n,onSelect:()=>{u(e.id),f(`agent`)}},e.id))]})]}),(0,O.jsxs)(`div`,{className:`run-stream-panel`,children:[(0,O.jsxs)(`div`,{className:`stream-head`,children:[(0,O.jsxs)(`div`,{className:`panel-tabs`,children:[(0,O.jsxs)(`button`,{className:`panel-tab${d===`agent`?` is-active`:``}`,onClick:()=>f(`agent`),children:[`Agent`,h&&(0,O.jsxs)(`span`,{className:`panel-tab-ctx`,children:[`#`,h.seq]})]}),(0,O.jsx)(`button`,{className:`panel-tab${d===`events`?` is-active`:``}`,onClick:()=>f(`events`),children:`Events`})]}),d===`agent`&&h?.status===`burning`&&(0,O.jsx)(`span`,{className:`agent-live-dot`,title:`agent running`})]}),d===`agent`?h?(0,O.jsx)(kp,{label:`agent transcript`,children:(0,O.jsx)(pS,{ticketId:h.id},h.id)}):(0,O.jsx)(`div`,{className:`agent-body`,children:(0,O.jsx)(M,{children:`no agent yet — lanes light up here as tickets start burning.`})}):(0,O.jsx)(yS,{events:s})]})]})]})}function vS({ticket:e,duration:t,selected:n,readonly:r,onSelect:i}){let a=up(),o=j.useUtils(),s={onSuccess:()=>o.feature.get.invalidate({id:e.featureId}),onError:e=>a.push(e.message)},c=j.ticket.retry.useMutation(s),l=j.ticket.stop.useMutation(s),u=e=>{navigator.clipboard?.writeText(e).then(()=>a.push(`copied ${pp(e)}`,`info`),()=>a.push(`copy failed`))},d=[`burning`,`done`,`failed`].includes(e.status)?` status-${e.status}`:``,f=e.commits.length>0,p=t!==void 0,m=e.status===`failed`?e.error?.split(`
109
+ `)[0]:void 0,h=c.isPending||l.isPending;return(0,O.jsxs)(`div`,{className:`lane is-clickable${d}${n?` is-selected`:``}`,role:`button`,tabIndex:0,title:`show this ticket's agent`,onClick:i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&i()},children:[(0,O.jsxs)(`div`,{className:`lane-head`,children:[(0,O.jsxs)(`span`,{className:`lane-seq`,children:[`#`,e.seq]}),(0,O.jsx)(`span`,{className:`lane-title`,children:e.title}),(0,O.jsx)(Ei,{status:e.status})]}),m&&(0,O.jsx)(`div`,{className:`lane-error`,title:e.error,children:m}),!r&&e.status===`failed`&&(0,O.jsxs)(`div`,{className:`lane-actions`,children:[(0,O.jsx)(`button`,{className:`lane-btn`,disabled:h,title:`retry this ticket — continues from any commits preserved by previous attempts`,onClick:t=>{t.stopPropagation(),c.mutate({ticketId:e.id},{onSuccess:t=>{t.resumedFrom&&a.push(`resuming ticket #${e.seq} from ${t.preservedCommits} preserved commit(s)`,`info`)}})},children:`Retry`}),(0,O.jsx)(`button`,{className:`lane-btn lane-btn-danger`,disabled:h,title:`discard any preserved commits from previous attempts and redo the ticket from the feature branch tip`,onClick:t=>{t.stopPropagation(),confirm(`Discard ticket #${e.seq}'s preserved work (if any) and start over?`)&&c.mutate({ticketId:e.id,fresh:!0})},children:`Retry fresh`})]}),!r&&e.status===`burning`&&(0,O.jsx)(`div`,{className:`lane-actions`,children:(0,O.jsx)(`button`,{className:`lane-btn lane-btn-danger`,disabled:h,title:`stop this ticket's agent — other lanes keep burning; committed work is preserved for retry`,onClick:t=>{t.stopPropagation(),l.mutate({ticketId:e.id},{onSuccess:e=>{e.stopped||a.push(`no live agent for this ticket (already finishing?)`,`info`)}})},children:`Stop ticket`})}),(f||p)&&(0,O.jsxs)(`div`,{className:`lane-foot`,children:[(0,O.jsx)(`span`,{className:`lane-commits`,children:e.commits.map(e=>(0,O.jsx)(`button`,{className:`commit-sha`,onClick:t=>{t.stopPropagation(),u(e)},title:`copy sha`,children:pp(e)},e))}),p&&(0,O.jsx)(`span`,{className:`lane-dur`,children:hp(0,t)})]})]})}function yS({events:e}){let t=(0,D.useRef)(null),[n,r]=(0,D.useState)(!0);return(0,D.useEffect)(()=>{if(!n)return;let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e,n]),(0,O.jsxs)(`div`,{className:`stream-body`,ref:t,onScroll:()=>{let e=t.current;if(!e)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight<24;r(n)},children:[e.length===0&&(0,O.jsx)(M,{children:`waiting for events…`}),e.map(e=>(0,O.jsxs)(`div`,{className:`stream-line level-${bS(e.type)}`,children:[(0,O.jsx)(`span`,{className:`sl-time`,children:fp(e.ts)}),(0,O.jsx)(`span`,{className:`sl-type`,children:e.type}),(0,O.jsx)(`span`,{className:`sl-msg`,children:e.message})]},e.id)),!n&&(0,O.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>r(!0),children:`Follow ⇣`})]})}function bS(e){return/(error|fail|conflict|cancel|stopped)/i.test(e)?`error`:/(done|succeed|finished|shipped|merged)/i.test(e)?`ok`:/(start|burn|launch|advance|running|retry|resum)/i.test(e)?`active`:`info`}function xS(e){let t=new Map;for(let n of e){if(!n.ticketId)continue;let e=t.get(n.ticketId);e?(e.min=Math.min(e.min,n.ts),e.max=Math.max(e.max,n.ts)):t.set(n.ticketId,{min:n.ts,max:n.ts})}let n=new Map;for(let[e,r]of t)r.max>r.min&&n.set(e,r.max-r.min);return n}function SS({featureId:e,viewedPhase:t,onViewPhase:n,guidance:r,driving:i,onDriveChange:a}){let o=j.useUtils(),s=up(),c=j.feature.get.useQuery({id:e},{refetchInterval:1500}),l=ES(e),u=()=>{o.feature.get.invalidate({id:e}),o.feature.list.invalidate()},d=j.feature.launchSession.useMutation({onSuccess:u,onError:e=>s.push(e.message)}),f=j.feature.advance.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),p=j.feature.burn.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),m=j.run.cancel.useMutation({onSuccess:()=>{u(),s.push(`cancel requested`,`info`)},onError:e=>s.push(e.message)}),h=j.feature.testDrive.useMutation({onError:e=>s.push(e.message)}),g=j.feature.merge.useMutation({onError:e=>s.push(e.message)});if(c.isLoading)return(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(`div`,{className:`ws-body`,children:(0,O.jsx)(M,{children:`loading feature…`})})});if(!c.data)return(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(`div`,{className:`ws-body`,children:(0,O.jsxs)(M,{children:[`could not load feature`,c.error?`: ${c.error.message}`:``]})})});let _=!!c.error,v=c.data,y=v.feature,b=np(y,t),x=rp(y,b),ee=ip(y,b),te=qf(v.runs),S=ap(v,{driving:i?.featureId===y.id}),ne=d.isPending||f.isPending||p.isPending||m.isPending||h.isPending||g.isPending;return(0,O.jsxs)(`section`,{className:`workspace`,children:[(0,O.jsxs)(`div`,{className:`ws-head`,children:[(0,O.jsxs)(`div`,{className:`ws-title-row`,children:[(0,O.jsx)(Ti,{phase:y.phase}),(0,O.jsx)(`span`,{className:`ws-title`,children:y.title}),(0,O.jsx)(`span`,{className:`ws-title-spacer`}),(0,O.jsxs)(`button`,{className:`ws-branch`,title:`copy branch`,onClick:()=>DS(y.branch,s),children:[`⎇ `,y.branch]})]}),(0,O.jsx)(wS,{steps:ee,onView:e=>n(e===y.phase?null:e)})]}),x?(0,O.jsxs)(`div`,{className:`readonly-bar`,children:[(0,O.jsx)(`span`,{className:`readonly-tag`,children:`READ-ONLY`}),(0,O.jsxs)(`span`,{children:[`You're viewing the `,Jf[b],` phase.`]}),(0,O.jsxs)(`button`,{className:`readonly-back`,onClick:()=>n(null),children:[`Back to `,Jf[y.phase],` →`]})]}):(0,O.jsx)(TS,{ns:S,guidance:r,busy:ne,onAction:t=>{switch(t){case`startGrill`:d.mutate({featureId:e,kind:`ideation`});break;case`askQuestions`:d.mutate({featureId:e,kind:`qa`});break;case`revisit`:d.mutate({featureId:e,kind:`revisit`});break;case`openGrill`:n(null),requestAnimationFrame(()=>document.getElementById(`grill-term`)?.scrollIntoView({behavior:`smooth`,block:`center`}));break;case`advance`:f.mutate({featureId:e});break;case`burn`:p.mutate({featureId:e});break;case`cancelRun`:te&&m.mutate({runId:te.id});break;case`testDriveStart`:h.mutate({featureId:e,action:`start`},{onSuccess:t=>{u(),t.ok&&t.branch?a({featureId:e,branch:t.branch}):t.ok||s.push(t.deniedReason??`test drive denied`)}});break;case`testDriveStop`:h.mutate({featureId:e,action:`stop`},{onSuccess:()=>{u(),a(null)}});break;case`merge`:g.mutate({featureId:e},{onSuccess:e=>{u(),e.ok?(a(null),s.push(`merged — feature shipped`,`success`)):e.conflict&&s.push(`merge conflict — resolve and retry`)}});break}}}),_&&(0,O.jsxs)(`div`,{className:`ws-banner is-offline`,role:`status`,children:[(0,O.jsx)(`span`,{className:`ws-banner-tag`,children:`OFFLINE`}),(0,O.jsx)(`span`,{children:`server unreachable — retrying…`})]}),l.message&&(0,O.jsxs)(`div`,{className:`ws-banner`,role:`alert`,onClick:l.dismiss,title:`dismiss`,children:[(0,O.jsx)(`span`,{className:`ws-banner-tag`,children:`RESUME FAILED`}),(0,O.jsx)(`span`,{children:l.message})]}),(0,O.jsx)(`div`,{className:`ws-body`,children:(0,O.jsx)(`div`,{className:`ws-body-inner`,children:(0,O.jsx)(CS,{effective:b,full:v,driving:i,runId:te?.id??null,readonly:x})},b)})]})}function CS({effective:e,full:t,driving:n,runId:r,readonly:i}){switch(e){case`ideation`:case`spec`:return(0,O.jsx)(tS,{full:t,effective:e});case`tickets`:return(0,O.jsx)(fS,{featureId:t.feature.id,readonly:i});case`implementation`:return(0,O.jsx)(_S,{featureId:t.feature.id,runId:r,readonly:i});case`review`:return(0,O.jsx)(lS,{full:t,driving:n});case`shipped`:return(0,O.jsx)(dS,{full:t})}}function wS({steps:e,onView:t}){return(0,O.jsx)(`div`,{className:`pipeline`,children:e.map((n,r)=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsxs)(`button`,{className:`pstep is-${n.state}${n.isViewed?` is-viewed`:``}${n.clickable?` is-clickable`:``}`,title:n.tip,disabled:!n.clickable,onClick:()=>n.clickable&&t(n.phase),children:[(0,O.jsx)(`span`,{className:`pstep-dot`}),(0,O.jsx)(`span`,{className:`pstep-label`,children:n.label})]}),r<e.length-1&&(0,O.jsx)(`span`,{className:`pconn${n.state===`done`?` is-done`:``}`})]},n.phase))})}function TS({ns:e,guidance:t,busy:n,onAction:r}){let i=e.kick===`IN PROGRESS`?`is-progress`:e.kick===`SHIPPED`?`is-shipped`:e.kick===`WAITING`?`is-waiting`:``;return(0,O.jsxs)(`div`,{className:`nextstep`,children:[e.busy&&(0,O.jsx)(`span`,{className:`spin-ring nextstep-spin`}),(0,O.jsxs)(`div`,{className:`nextstep-main`,children:[(0,O.jsx)(`div`,{className:`nextstep-kick ${i}`,children:e.kick}),(0,O.jsx)(`div`,{className:`nextstep-title`,children:e.title}),t&&(0,O.jsx)(`div`,{className:`nextstep-desc`,children:e.desc})]}),(0,O.jsxs)(`div`,{className:`nextstep-actions`,children:[e.secondary.map((e,t)=>(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,disabled:n,onClick:()=>r(e.kind),children:e.label},t)),e.primary&&(0,O.jsx)(Ci,{variant:e.primary.danger?`danger`:`solid`,disabled:n,onClick:()=>r(e.primary.kind),children:n?`Working…`:e.primary.label})]})]})}function ES(e){let t=dp(e),[n,r]=(0,D.useState)(null),i=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(t.length===0)return;let e=t[t.length-1].id;if(i.current===null){i.current=e;return}let n=i.current;i.current=e;let a=t.filter(e=>e.id>n&&e.type===`session.resume_failed`),o=a[a.length-1];o&&r(o.message||`session resume failed — relaunch to continue`)},[t]),(0,D.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(null),8e3);return()=>clearTimeout(e)},[n]),{message:n,dismiss:()=>r(null)}}function DS(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function OS({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,D.useState)(``),[a,o]=(0,D.useState)(``),[s,c]=(0,D.useState)(`full`),[l,u]=(0,D.useState)(!1),[d,f]=(0,D.useState)(``),p=j.useUtils(),m=up(),h=j.project.branches.useQuery({projectId:e}),g=h.data?.mainBranch??``,_=h.data?.current,v=h.data?.branches??[],y=h.data?.remoteBranches??[],b=v.length===0&&y.length===0,x=d||g,ee=j.feature.launchSession.useMutation(),te=j.feature.create.useMutation({onSuccess:async e=>{await p.feature.list.invalidate(),ee.mutate({featureId:e.id,kind:`ideation`},{onSettled:()=>void p.feature.get.invalidate({id:e.id})}),n(e.id)},onError:e=>m.push(e.message)}),S=kS(r),ne=te.isPending||ee.isPending,re=()=>{let t=r.trim();t&&te.mutate({projectId:e,title:t,oneLiner:a.trim(),size:s,mapped:l,baseBranch:d||void 0})};return(0,O.jsx)(`div`,{className:`nf-overlay`,children:(0,O.jsxs)(`div`,{className:`nf-card`,children:[(0,O.jsx)(`div`,{className:`nf-kick`,children:`NEW FEATURE`}),(0,O.jsx)(`div`,{className:`nf-h`,children:`What are we building?`}),(0,O.jsx)(`div`,{className:`nf-sub`,children:`Name it and pick a size — runcastle opens a grill session so you and Claude shape the idea before any code is written.`}),(0,O.jsx)(`input`,{className:`nf-input`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. Slack notifications on failed runs`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&re(),e.key===`Escape`&&t()}}),(0,O.jsx)(`input`,{className:`nf-input nf-oneliner`,value:a,onChange:e=>o(e.target.value),placeholder:`one-liner (optional) — what & why in a sentence`,onKeyDown:e=>{e.key===`Enter`&&re(),e.key===`Escape`&&t()}}),(0,O.jsxs)(`div`,{className:`nf-controls`,children:[(0,O.jsxs)(`div`,{className:`size-toggle`,children:[(0,O.jsx)(`button`,{className:s===`full`?`is-on`:``,onClick:()=>c(`full`),children:`Full`}),(0,O.jsx)(`button`,{className:s===`collapsed`?`is-on`:``,onClick:()=>c(`collapsed`),children:`Small`})]}),(0,O.jsx)(`span`,{className:`size-hint`,children:s===`collapsed`?`Small skips the spec phase.`:`Full runs the whole six-phase pipeline.`})]}),(0,O.jsxs)(`div`,{className:`nf-base`,children:[(0,O.jsx)(`label`,{className:`nf-base-label`,htmlFor:`nf-base-select`,children:`Branch from`}),(0,O.jsxs)(`select`,{id:`nf-base-select`,className:`nf-base-select`,value:x,disabled:h.isPending||b,onChange:e=>f(e.target.value),children:[v.map(e=>(0,O.jsxs)(`option`,{value:e,children:[e,e===g?` (default)`:``,e===_&&e!==g?` (current)`:``]},e)),y.length>0&&(0,O.jsx)(`optgroup`,{label:`Remote (creates a local branch)`,children:y.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))})]}),(0,O.jsx)(`span`,{className:`size-hint`,children:`forks off this branch — and merges back into it when shipped.`})]}),(0,O.jsxs)(`label`,{className:`nf-mapped`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,O.jsxs)(`span`,{className:`nf-mapped-text`,children:[(0,O.jsx)(`span`,{className:`nf-mapped-label`,children:`Start mapped`}),(0,O.jsx)(`span`,{className:`size-hint`,children:`Chart the idea as a waypoint map when it's too big for one grill — orthogonal to size.`})]})]}),(0,O.jsxs)(`div`,{className:`nf-branch`,children:[`branch · feature/`,S||`…`,` ← `,x||`…`]}),(0,O.jsxs)(`div`,{className:`nf-actions`,children:[(0,O.jsx)(Ci,{variant:`ghost`,onClick:t,disabled:ne,children:`Cancel`}),(0,O.jsx)(Ci,{variant:`solid`,onClick:re,disabled:!r.trim()||ne,children:ne?`Starting…`:`Start grill session`})]})]})})}function kS(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function AS(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onNewFeature:o,onOpenSettings:s,nav:c}=e,[l,u]=(0,D.useState)(``),[d,f]=(0,D.useState)(0),p=(0,D.useRef)(null),m=(0,D.useRef)([]);(0,D.useEffect)(()=>{t&&(u(``),f(0),p.current?.focus())},[t]),(0,D.useEffect)(()=>{f(0)},[l]);let h=l.trim().toLowerCase(),g=(0,D.useMemo)(()=>h===``?r:r.filter(e=>e.slug.toLowerCase().includes(h)||e.title.toLowerCase().includes(h)),[r,h]),_=(0,D.useMemo)(()=>(c.projects??[]).filter(e=>e.id!==c.currentProjectId),[c.projects,c.currentProjectId]),v=(0,D.useMemo)(()=>h===``?_:_.filter(e=>e.name.toLowerCase().includes(h)),[_,h]),y=`create new feature`.includes(h),b=`all projects home`.includes(h),x=`open a project`.includes(h),ee=`settings preferences`.includes(h),te=(0,D.useMemo)(()=>{let e=g.map(e=>({kind:`feature`,feature:e}));for(let t of v)e.push({kind:`project`,id:t.id,name:t.name,branch:t.mainBranch,current:!1});return y&&e.push({kind:`newFeature`}),b&&e.push({kind:`home`}),x&&e.push({kind:`openProject`}),ee&&e.push({kind:`settings`}),e},[g,v,y,b,x,ee]);if(!t)return null;let S=e=>{if(te.length===0)return;let t=(d+e+te.length)%te.length;f(t),m.current[t]?.scrollIntoView({block:`nearest`})},ne=e=>{let t=te[e];if(t){switch(t.kind){case`feature`:a(t.feature.id);break;case`project`:c.enterProject(t.id);break;case`newFeature`:o();break;case`home`:c.goHome();break;case`openProject`:c.showOpen();break;case`settings`:s();break}n()}},re=e=>{e.key===`ArrowDown`?(e.preventDefault(),S(1)):e.key===`ArrowUp`?(e.preventDefault(),S(-1)):e.key===`Enter`?(e.preventDefault(),ne(d)):e.key===`Escape`&&(e.preventDefault(),n())},ie=g.length,ae=ie+v.length,oe=e=>t=>{m.current[e]=t};return(0,O.jsx)(`div`,{className:`cmdk-backdrop`,onClick:n,children:(0,O.jsxs)(`div`,{className:`cmdk`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`input`,{ref:p,className:`cmdk-input`,placeholder:`Search features, projects, or jump to…`,value:l,onChange:e=>u(e.target.value),onKeyDown:re,"aria-label":`Search features, projects, or jump to`}),(0,O.jsxs)(`div`,{className:`cmdk-list`,children:[g.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`cmdk-group-label`,children:`Features`}),g.map((e,t)=>(0,O.jsxs)(`div`,{ref:oe(t),className:`cmdk-item${t===d?` is-active`:``}`,onMouseEnter:()=>f(t),onClick:()=>ne(t),children:[(0,O.jsx)(`span`,{className:`cmdk-item-glyph`,children:(0,O.jsx)(`span`,{className:`phase-fg-${e.phase}`,children:Gf(e.phase)})}),(0,O.jsx)(`span`,{className:`cmdk-item-label`,children:e.title}),(0,O.jsx)(`span`,{className:`cmdk-item-slug`,children:e.slug}),(0,O.jsx)(`span`,{className:`cmdk-item-hint`,children:e.id===i?`current`:e.phase})]},e.id))]}),v.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`cmdk-group-label`,children:`Switch project`}),v.map((e,t)=>{let n=ie+t;return(0,O.jsxs)(`div`,{ref:oe(n),className:`cmdk-item${n===d?` is-active`:``}`,onMouseEnter:()=>f(n),onClick:()=>ne(n),children:[(0,O.jsx)(`span`,{className:`cmdk-item-glyph`,children:`◫`}),(0,O.jsx)(`span`,{className:`cmdk-item-label`,children:e.name}),(0,O.jsxs)(`span`,{className:`cmdk-item-slug`,children:[`⎇ `,e.mainBranch]}),(0,O.jsx)(`span`,{className:`cmdk-item-hint`,children:`project`})]},e.id)})]}),(y||b||x||ee)&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`cmdk-group-label`,children:`Actions`}),y&&(0,O.jsx)(jS,{index:ae,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`+`,label:`Create new feature`}),b&&(0,O.jsx)(jS,{index:ae+ +!!y,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`⊞`,label:`All projects (home)`}),x&&(0,O.jsx)(jS,{index:ae+ +!!y+ +!!b,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`◌`,label:`Open a project…`}),ee&&(0,O.jsx)(jS,{index:ae+ +!!y+ +!!b+ +!!x,activeIndex:d,bindRow:oe,setActiveIndex:f,activate:ne,glyph:`⚙`,label:`Settings`})]}),te.length===0&&(0,O.jsx)(`div`,{className:`cmdk-empty`,children:`No matches`})]}),(0,O.jsxs)(`div`,{className:`cmdk-foot`,children:[(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`span`,{className:`kbd`,children:`↑↓`}),` navigate`]}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`span`,{className:`kbd`,children:`↵`}),` select`]}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`span`,{className:`kbd`,children:`esc`}),` close`]})]})]})})}function jS({index:e,activeIndex:t,bindRow:n,setActiveIndex:r,activate:i,glyph:a,label:o}){return(0,O.jsxs)(`div`,{ref:n(e),className:`cmdk-item${e===t?` is-active`:``}`,onMouseEnter:()=>r(e),onClick:()=>i(e),children:[(0,O.jsx)(`span`,{className:`cmdk-item-glyph`,children:a}),(0,O.jsx)(`span`,{className:`cmdk-item-label`,children:o}),(0,O.jsx)(`span`,{className:`cmdk-item-hint`,children:`action`})]})}var MS={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,burnAttempts:`RUNCASTLE_BURN_ATTEMPTS`,mainBranch:`RUNCASTLE_MAIN_BRANCH`},NS=Uf.map(e=>e.id),PS=`stepModels.`;function FS(e){return e.startsWith(PS)}function IS(e){return e.slice(11)}var LS={ideation:`Ideation`,qa:`Q&A`,waypoint:`Waypoint`,converge:`Converge`,research:`Research`,implement:`Implement`,smoke:`Smoke`},RS=Vf.map(e=>`${PS}${e}`),zS=new Set([`mainBranch`]),BS={serverPort:{label:`Server port`,help:`Port the runcastle server listens on.`,control:`number`},model:{label:`Default model`,help:`Claude model every step inherits unless overridden below.`,control:`select`,options:NS},sandbox:{label:`Sandbox`,help:`Where launched sessions run.`,control:`select`,options:[`docker`,`noSandbox`]},sandboxImage:{label:`Sandbox image`,help:`Docker image used when a session is sandboxed.`,control:`text`},burnConcurrency:{label:`Burn concurrency`,help:`Max tickets burned in parallel per run (1–8). Each is a full agent.`,control:`number`},burnAttempts:{label:`Burn attempts`,help:`Max agent attempts per ticket per run (1–5). A transient crash (API drop, network) retries with committed work preserved.`,control:`number`},mainBranch:{label:`Main branch`,help:`Branch features merge back into.`,control:`text`},devCommand:{label:`Dev command`,help:`Command that starts this project's dev server.`,control:`text`}};function VS(e){return e==null?``:String(e)}function HS(e){if(FS(e)){let t=IS(e);return{label:LS[t]??t,help:`Model for the ${LS[t]??t} step.`,control:`select`,options:NS}}return BS[e]??{label:e,help:``,control:`text`}}function US(e){let t=HS(e.key),n=zS.has(e.key),r=!e.editable||n,i=e.source===`project`,a=null;return e.source===`env`?a=`Set by ${MS[e.key]??`the environment`}`:n?a=`Read-only — detected from git`:e.scope===`project`&&(a=i?`Overridden for this project`:`Inherited from global`),{key:e.key,label:t.label,help:t.help,value:VS(e.value),control:t.control,options:t.options??[],readOnly:r,restartRequired:e.restartRequired,overridden:i,source:e.source,note:a,allowCustom:e.key===`model`||FS(e.key)}}function WS(e){return e.fields.filter(e=>!FS(e.key)).map(US)}function GS(e){return e.fields.filter(e=>e.scope===`project`).map(US)}function KS(e){return e.fields.filter(e=>FS(e.key)&&e.source===`file`).map(US).sort((e,t)=>RS.indexOf(e.key)-RS.indexOf(t.key))}function qS(e){let t=new Set(e.fields.filter(e=>FS(e.key)&&e.source===`file`).map(e=>e.key));return RS.filter(e=>!t.has(e)).map(e=>({key:e,label:LS[IS(e)]??IS(e)}))}function JS({onDismiss:e}){let t=j.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),n=t.data,r=e=>n?.results.find(t=>t.id===e),i=r(`container-runtime`),a=r(`sandcastle-image`),o=r(`afk-token`),s=()=>t.refetch();return(0,O.jsxs)(`div`,{className:`afk-card`,children:[(0,O.jsxs)(`div`,{className:`afk-card-head`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`op-kick`,children:`ENABLE AFK BURNS`}),(0,O.jsx)(`div`,{className:`afk-card-title`,children:`Run features unattended`})]}),e&&(0,O.jsx)(Ci,{variant:`ghost`,onClick:e,children:`Set up later`})]}),(0,O.jsx)(`p`,{className:`afk-card-sub`,children:`AFK burns run each feature to completion in a sandbox — no interactive session. They need a container runtime, the sandcastle image, and an auth token. Set them up now or anytime from Settings.`}),t.isLoading&&(0,O.jsx)(M,{children:`checking prerequisites…`}),t.error&&(0,O.jsxs)(M,{children:[`could not run checks: `,t.error.message]}),n&&(0,O.jsxs)(`div`,{className:`afk-rows`,children:[(0,O.jsx)(XS,{probe:i,onRecheck:s}),(0,O.jsx)(ZS,{probe:a,runtimeOk:i?.status===`ok`,onDone:s}),(0,O.jsx)(QS,{probe:o,onDone:s})]})]})}function YS({probe:e,children:t}){if(!e)return null;let n=e.status===`ok`;return(0,O.jsxs)(`div`,{className:`afk-row${n?` is-ok`:``}`,children:[(0,O.jsxs)(`div`,{className:`afk-row-head`,children:[(0,O.jsx)(`span`,{className:`afk-dot afk-dot-${n?`ok`:`warn`}`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`afk-row-text`,children:[(0,O.jsx)(`div`,{className:`afk-row-label`,children:e.label}),(0,O.jsx)(`div`,{className:`afk-row-detail mono`,children:e.detail})]})]}),!n&&(0,O.jsx)(`div`,{className:`afk-row-action`,children:t})]})}function XS({probe:e,onRecheck:t}){let n=j.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),r=up();if(!e)return null;let i=e.status===`missing`?n.data:void 0,a=i?.command??e.fix??``;return(0,O.jsxs)(YS,{probe:e,children:[a&&(0,O.jsxs)(`div`,{className:`afk-cmd`,children:[(0,O.jsx)(`code`,{className:`afk-cmd-text mono`,children:a}),(0,O.jsx)(Ci,{variant:`ghost`,onClick:()=>{navigator.clipboard?.writeText(a),r.push(`copied`,`info`)},children:`Copy`})]}),i?.note&&(0,O.jsx)(`div`,{className:`afk-note`,children:i.note}),(0,O.jsx)(Ci,{variant:`solid`,onClick:t,children:`Re-check`})]})}function ZS({probe:e,runtimeOk:t,onDone:n}){let[r,i]=(0,D.useState)(null),a=up(),o=j.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)});return e?(0,O.jsx)(YS,{probe:e,children:r?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`afk-term`,children:(0,O.jsx)(kp,{label:`build-image`,children:(0,O.jsx)(eS,{sessionId:r})})}),(0,O.jsx)(`div`,{className:`afk-term-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,onClick:()=>{i(null),n()},children:`Done — re-check`})})]}):(0,O.jsx)(Ci,{variant:`solid`,disabled:!t||o.isPending,title:t?void 0:`Install a container runtime first`,onClick:()=>o.mutate({kind:`build-image`}),children:o.isPending?`Starting…`:`Build image`})}):null}function QS({probe:e,onDone:t}){let[n,r]=(0,D.useState)(null),[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(null),c=up(),l=j.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>r(e),onError:e=>c.push(e.message)}),u=j.setup.afkToken.useMutation({onSuccess:e=>{s(e),e.valid&&t()},onError:e=>c.push(e.message)});return e?(0,O.jsxs)(YS,{probe:e,children:[n?(0,O.jsx)(`div`,{className:`afk-term`,children:(0,O.jsx)(kp,{label:`setup-token`,children:(0,O.jsx)(eS,{sessionId:n})})}):(0,O.jsx)(Ci,{variant:`ghost`,onClick:()=>l.mutate({kind:`setup-token`}),disabled:l.isPending,children:l.isPending?`Starting…`:`Run claude setup-token`}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`afk-token-input`,children:`Paste the token it prints`}),(0,O.jsx)(`input`,{id:`afk-token-input`,className:`op-input mono`,value:i,onChange:e=>a(e.target.value),placeholder:`sk-ant-oat01-…`,spellCheck:!1,autoComplete:`off`}),(0,O.jsx)(`div`,{className:`afk-term-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,disabled:i.trim()===``||u.isPending,onClick:()=>u.mutate({token:i}),children:u.isPending?`Verifying…`:`Save & verify`})}),o&&(0,O.jsxs)(`div`,{className:`afk-verdict ${o.valid?`is-ok`:`is-warn`}`,children:[o.valid?`✓ `:`⚠ `,o.detail]})]}):null}function $S({projectId:e,onClose:t}){let n=j.settings.get.useQuery(),r=j.settings.get.useQuery({projectId:e});return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,O.jsx)(`div`,{className:`peek-backdrop`,onClick:t,children:(0,O.jsxs)(`div`,{className:`peek settings`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`peek-head`,children:[(0,O.jsx)(`span`,{className:`settings-title`,children:`Settings`}),(0,O.jsx)(`button`,{className:`peek-close`,onClick:t,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,O.jsxs)(`div`,{className:`peek-body settings-body`,children:[(0,O.jsx)(eC,{title:`Global`,hint:`Machine-wide defaults for every project.`,query:n,rowsOf:WS}),(0,O.jsx)(iC,{query:n}),(0,O.jsx)(eC,{title:`This project`,hint:`Overrides that apply only to the current project.`,query:r,rowsOf:GS,projectId:e}),(0,O.jsxs)(`section`,{className:`settings-section`,children:[(0,O.jsxs)(`div`,{className:`settings-section-head`,children:[(0,O.jsx)(`h3`,{className:`settings-section-title`,children:`AFK burns`}),(0,O.jsx)(`span`,{className:`settings-section-hint`,children:`Prerequisites for unattended sandbox runs.`})]}),(0,O.jsx)(JS,{})]})]})]})})}function eC({title:e,hint:t,query:n,rowsOf:r,projectId:i}){let a=n.data?r(n.data):[];return(0,O.jsxs)(`section`,{className:`settings-section`,children:[(0,O.jsxs)(`div`,{className:`settings-section-head`,children:[(0,O.jsx)(`h3`,{className:`settings-section-title`,children:e}),(0,O.jsx)(`span`,{className:`settings-section-hint`,children:t})]}),n.isLoading&&(0,O.jsx)(M,{children:`loading…`}),n.error&&(0,O.jsxs)(M,{children:[`could not load settings: `,n.error.message]}),n.data&&a.length===0&&(0,O.jsx)(M,{children:`no settings in this scope`}),a.map(e=>(0,O.jsx)(tC,{row:e,projectId:i},e.key))]})}function tC({row:e,projectId:t}){let n=j.useUtils(),r=up(),[i,a]=(0,D.useState)(e.value);(0,D.useEffect)(()=>a(e.value),[e.value]);let o=j.settings.update.useMutation({onSuccess:()=>{n.settings.get.invalidate()},onError:t=>{a(e.value),r.push(t.message)}}),s=n=>{let r=n.trim();if(r===e.value.trim())return;let i=e.control===`number`?Number(r):r;o.mutate({...t?{projectId:t}:{},key:e.key,value:i})},c=()=>t&&o.mutate({projectId:t,key:e.key,value:null}),l=`set-${e.key}`;return(0,O.jsxs)(`div`,{className:`settings-field${e.readOnly?` is-locked`:``}`,children:[(0,O.jsxs)(`label`,{className:`settings-field-head`,htmlFor:l,children:[(0,O.jsx)(`span`,{className:`settings-field-label`,children:e.label}),e.restartRequired&&(0,O.jsx)(`span`,{className:`settings-badge is-warn`,title:`Takes effect after a server restart`,children:`restart required`}),e.overridden&&(0,O.jsx)(`span`,{className:`settings-badge is-override`,children:`overridden`}),o.isPending&&(0,O.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),e.help&&(0,O.jsx)(`div`,{className:`settings-field-help`,children:e.help}),e.readOnly?(0,O.jsx)(`div`,{className:`settings-readonly mono`,id:l,children:e.value||`—`}):e.control===`select`&&e.allowCustom?(0,O.jsx)(rC,{id:l,value:e.value,options:e.options,disabled:o.isPending,onCommit:s}):e.control===`select`?(0,O.jsx)(`select`,{id:l,className:`settings-input`,value:i,disabled:o.isPending,onChange:e=>{a(e.target.value),s(e.target.value)},children:e.options.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))}):(0,O.jsx)(`input`,{id:l,className:`settings-input mono`,type:e.control===`number`?`number`:`text`,value:i,disabled:o.isPending,onChange:e=>a(e.target.value),onBlur:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&(a(e.value),t.currentTarget.blur())}}),e.note&&(0,O.jsx)(`div`,{className:`settings-field-note`,children:e.note}),e.overridden&&t&&(0,O.jsx)(`button`,{className:`settings-clear`,onClick:c,disabled:o.isPending,children:`Clear override`})]})}var nC=`__custom__`;function rC({id:e,value:t,options:n,disabled:r,onCommit:i}){let[a,o]=(0,D.useState)(!n.includes(t)&&t!==``),[s,c]=(0,D.useState)(t);return(0,D.useEffect)(()=>{c(t),o(!n.includes(t)&&t!==``)},[t,n]),(0,O.jsxs)(`div`,{className:`settings-combo`,children:[(0,O.jsxs)(`select`,{id:e,className:`settings-input`,value:a?nC:t,disabled:r,onChange:e=>{if(e.target.value===nC){o(!0);return}o(!1),i(e.target.value)},children:[n.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e)),(0,O.jsx)(`option`,{value:nC,children:`Custom…`})]}),a&&(0,O.jsx)(`input`,{className:`settings-input mono`,type:`text`,placeholder:`model id (e.g. claude-opus-4-8)`,value:s,disabled:r,onChange:e=>c(e.target.value),onBlur:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})]})}function iC({query:e}){let t=j.useUtils(),n=up(),[r,i]=(0,D.useState)(!1),a=j.settings.update.useMutation({onSuccess:()=>{t.settings.get.invalidate()},onError:e=>n.push(e.message)}),o=e.data,s=o?KS(o):[],c=o?qS(o):[],l=o?.fields.find(e=>e.key===`model`),u=(e,t)=>{let n=t.trim();n!==``&&a.mutate({key:e,value:n})};return(0,O.jsxs)(`section`,{className:`settings-section`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`settings-advanced-toggle`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,O.jsx)(`span`,{className:`settings-section-title`,children:`Advanced — per-step models`}),(0,O.jsxs)(`span`,{className:`settings-section-hint`,children:[s.length>0?`${s.length} override${s.length===1?``:`s`}`:`none set`,r?` ▾`:` ▸`]})]}),r&&(0,O.jsxs)(`div`,{className:`settings-advanced-body`,children:[s.length===0&&(0,O.jsx)(M,{children:`every step uses the default model.`}),s.map(e=>(0,O.jsxs)(`div`,{className:`settings-field`,children:[(0,O.jsxs)(`div`,{className:`settings-field-head`,children:[(0,O.jsx)(`span`,{className:`settings-field-label`,children:e.label}),a.isPending&&(0,O.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),(0,O.jsx)(rC,{id:`step-${e.key}`,value:e.value,options:e.options,disabled:a.isPending,onCommit:t=>u(e.key,t)}),(0,O.jsx)(`button`,{className:`settings-clear`,disabled:a.isPending,onClick:()=>a.mutate({key:e.key,value:null}),children:`Reset to default`})]},e.key)),c.length>0&&(0,O.jsxs)(`div`,{className:`settings-field`,children:[(0,O.jsx)(`label`,{className:`settings-field-label`,htmlFor:`step-add`,children:`Add an override`}),(0,O.jsxs)(`select`,{id:`step-add`,className:`settings-input`,value:``,disabled:a.isPending,onChange:e=>{let t=e.target.value;t&&u(t,typeof l?.value==`string`?l.value:``)},children:[(0,O.jsx)(`option`,{value:``,children:`Choose a step…`}),c.map(e=>(0,O.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]})]})]})}function aC({projectId:e,nav:t}){let n=bi(e),{selectedFeatureId:r,select:i,setCmdk:a}=n,[o,s]=(0,D.useState)(null),c=j.feature.list.useQuery({projectId:e},{refetchInterval:1500});(0,D.useEffect)(()=>{!r&&c.data&&c.data.length>0&&i(c.data[0].id)},[r,c.data,i]),(0,D.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),a(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let l=!n.inspectorCollapsed&&!!n.selectedFeatureId&&!n.creating;return(0,O.jsxs)(`div`,{className:`shell${n.inspectorCollapsed?` inspector-collapsed`:``}`,children:[(0,O.jsx)(Si,{nav:t,onOpenCmdk:()=>n.setCmdk(!0),onOpenSettings:()=>n.setSettings(!0),onToggleInspector:n.toggleInspector,inspectorCollapsed:n.inspectorCollapsed}),(0,O.jsxs)(`div`,{className:`shell-body`,children:[(0,O.jsx)(op,{projectId:e,selectedFeatureId:n.selectedFeatureId,onSelect:n.select,onNewFeature:n.startCreate}),n.creating?(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(OS,{projectId:e,onCancel:n.cancelCreate,onCreated:n.select})}):n.selectedFeatureId?(0,O.jsx)(SS,{featureId:n.selectedFeatureId,viewedPhase:n.viewedPhase,onViewPhase:n.viewPhase,guidance:n.guidance,driving:o,onDriveChange:s},`ws-${n.selectedFeatureId}`):(0,O.jsx)(`section`,{className:`workspace`,children:(0,O.jsx)(oC,{onNewFeature:n.startCreate})}),l&&n.selectedFeatureId&&(0,O.jsx)(_p,{featureId:n.selectedFeatureId},`insp-${n.selectedFeatureId}`)]}),(0,O.jsx)(Dp,{projectId:e,activeFeatureId:n.selectedFeatureId,driving:o,onDriveChange:s}),(0,O.jsx)(AS,{open:n.cmdkOpen,onClose:()=>n.setCmdk(!1),features:c.data??[],selectedFeatureId:n.selectedFeatureId,onSelect:n.select,onNewFeature:n.startCreate,onOpenSettings:()=>n.setSettings(!0),nav:t}),n.settingsOpen&&(0,O.jsx)($S,{projectId:e,onClose:()=>n.setSettings(!1)})]})}function oC({onNewFeature:e}){return(0,O.jsxs)(`div`,{className:`ws-empty`,children:[(0,O.jsx)(`div`,{className:`ws-empty-logo mono`,children:`r`}),(0,O.jsx)(`span`,{className:`dim-line mono`,children:`select a feature to begin`}),(0,O.jsx)(`button`,{className:`btn btn-ghost btn-xs`,onClick:e,children:`+ New feature`})]})}function sC({nav:e}){let t=e.projects??[],n=j.useQueries(e=>t.map(t=>e.feature.list({projectId:t.id},{refetchInterval:1500})));return(0,O.jsxs)(`div`,{className:`home`,children:[(0,O.jsxs)(`header`,{className:`home-head`,children:[(0,O.jsxs)(`div`,{className:`home-title`,children:[(0,O.jsx)(`span`,{className:`tb-logo mono`,children:`r`}),(0,O.jsx)(`span`,{className:`home-title-text`,children:`Projects`}),(0,O.jsx)(`span`,{className:`home-count`,children:t.length})]}),(0,O.jsx)(`p`,{className:`home-sub`,children:`Every open project and where it stands. Open one to work its pipeline — runs keep going in the background while you switch.`})]}),(0,O.jsxs)(`div`,{className:`home-grid`,children:[t.map((t,r)=>{let i=n[r]?.data;return(0,O.jsx)(lC,{project:t,stats:di(i??[]),loading:i===void 0,onOpen:()=>e.enterProject(t.id)},t.id)}),(0,O.jsxs)(`button`,{className:`open-card`,onClick:e.showOpen,children:[(0,O.jsx)(`span`,{className:`open-card-plus`,children:`+`}),(0,O.jsx)(`span`,{className:`open-card-label`,children:`Open a project`}),(0,O.jsx)(`span`,{className:`open-card-sub`,children:`Point runcastle at a local git repo`})]})]})]})}var cC={attention:`Needs you`,working:`Agent working`,steady:`Steady`,empty:`No features yet`};function lC({project:e,stats:t,loading:n,onOpen:r}){let i=up(),a=j.useUtils(),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(e.name),u=j.project.rename.useMutation({onSuccess:async()=>{await a.project.list.invalidate(),s(!1)},onError:e=>i.push(e.message)}),d=j.project.close.useMutation({onSuccess:async()=>{await a.project.list.invalidate(),i.push(`closed ${e.name}`,`info`)},onError:e=>i.push(e.message)}),f=t.activeRuns>0,p=()=>{let t=c.trim();t&&t!==e.name?u.mutate({projectId:e.id,name:t}):s(!1)};return(0,O.jsxs)(`div`,{className:`project-card health-${t.health}`,children:[(0,O.jsxs)(`button`,{className:`pc-main`,onClick:r,title:`Open ${e.name}`,children:[(0,O.jsxs)(`div`,{className:`pc-head`,children:[o?(0,O.jsx)(`input`,{className:`pc-rename mono`,value:c,autoFocus:!0,onClick:e=>e.stopPropagation(),onChange:e=>l(e.target.value),onKeyDown:t=>{t.stopPropagation(),t.key===`Enter`&&p(),t.key===`Escape`&&(l(e.name),s(!1))},onBlur:p}):(0,O.jsx)(`span`,{className:`pc-name`,children:e.name}),(0,O.jsx)(`span`,{className:`pc-health-dot health-dot-${t.health}`,title:cC[t.health]})]}),(0,O.jsx)(`span`,{className:`pc-path mono`,children:e.repoPath}),(0,O.jsxs)(`span`,{className:`pc-branch mono`,children:[`⎇ `,e.mainBranch]}),(0,O.jsxs)(`div`,{className:`pc-stats`,children:[(0,O.jsx)(uC,{n:t.total,label:t.total===1?`feature`:`features`}),(0,O.jsx)(uC,{n:t.activeRuns,label:`running`,tone:f?`run`:void 0,spin:f}),(0,O.jsx)(uC,{n:t.needsYou,label:`needs you`,tone:t.needsYou>0?`needs`:void 0})]}),(0,O.jsx)(`span`,{className:`pc-health-label`,children:n?`loading…`:cC[t.health]})]}),(0,O.jsxs)(`div`,{className:`pc-actions`,children:[(0,O.jsx)(`button`,{className:`pc-action`,onClick:()=>{l(e.name),s(!0)},children:`Rename`}),(0,O.jsx)(`button`,{className:`pc-action pc-action-danger`,disabled:f||d.isPending,title:f?`a run is in flight — cannot close`:`Close project`,onClick:()=>d.mutate({projectId:e.id}),children:`Close`})]})]})}function uC({n:e,label:t,tone:n,spin:r}){return(0,O.jsxs)(`span`,{className:`pc-stat${n?` pc-stat-${n}`:``}`,children:[r&&(0,O.jsx)(`span`,{className:`spin-ring`}),(0,O.jsx)(`span`,{className:`pc-stat-n`,children:e}),(0,O.jsx)(`span`,{className:`pc-stat-label`,children:t})]})}function dC({firstRun:e,onOpened:t,onCancel:n}){let[r,i]=(0,D.useState)(``),a=up(),o=j.useUtils(),s=j.project.open.useMutation({onSuccess:async e=>{await o.project.list.invalidate(),a.push(`opened ${e.name} on ${e.mainBranch}`,`info`),t(e.id)},onError:e=>a.push(e.message)}),c=()=>{let e=r.trim();e&&s.mutate({repoPath:e})};return(0,O.jsx)(`div`,{className:`open-project`,children:(0,O.jsxs)(`div`,{className:`op-card`,children:[(0,O.jsx)(`div`,{className:`op-logo mono`,children:`r`}),(0,O.jsx)(`div`,{className:`op-kick`,children:e?`WELCOME TO RUNCASTLE`:`OPEN A PROJECT`}),(0,O.jsx)(`div`,{className:`op-h`,children:e?`Open your first project`:`Open a project`}),(0,O.jsx)(`div`,{className:`op-sub`,children:`Point runcastle at a local git repository. It detects the default branch and opens the project — every feature runs its pipeline against this repo.`}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`op-repo-path`,children:`Repository path`}),(0,O.jsx)(`input`,{id:`op-repo-path`,className:`op-input mono`,value:r,onChange:e=>i(e.target.value),placeholder:`/path/to/your/repo`,autoFocus:!0,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&c(),t.key===`Escape`&&!e&&n()}}),(0,O.jsx)(`div`,{className:`op-hint`,children:`The default branch is detected automatically when the project opens.`}),(0,O.jsxs)(`div`,{className:`op-actions`,children:[!e&&(0,O.jsx)(Ci,{variant:`ghost`,onClick:n,disabled:s.isPending,children:`Cancel`}),(0,O.jsx)(Ci,{variant:`solid`,onClick:c,disabled:s.isPending||r.trim()===``,children:s.isPending?`Opening…`:`Open`})]})]})})}function fC({onOpened:e,onCancel:t}){let n=j.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`)?.status===`ok`,[i,a]=(0,D.useState)(null),o=i??(r?`afk`:`identity`);return n.isLoading?(0,O.jsx)(`div`,{className:`open-project`,children:(0,O.jsx)(M,{children:`preparing setup…`})}):o===`project`?(0,O.jsx)(dC,{firstRun:!0,onOpened:e,onCancel:t}):(0,O.jsx)(`div`,{className:`open-project`,children:(0,O.jsxs)(`div`,{className:`op-card wizard-card`,children:[(0,O.jsx)(`div`,{className:`op-logo mono`,children:`r`}),(0,O.jsx)(mC,{current:o}),o===`identity`?(0,O.jsx)(hC,{onNext:()=>a(`afk`)}):(0,O.jsx)(gC,{onNext:()=>a(`project`)})]})})}var pC=[{key:`identity`,label:`Git identity`},{key:`afk`,label:`AFK burns`},{key:`project`,label:`First project`}];function mC({current:e}){let t=pC.findIndex(t=>t.key===e);return(0,O.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Setup progress`,children:pC.map((e,n)=>(0,O.jsxs)(`li`,{className:`wizard-step${n===t?` is-current`:``}${n<t?` is-done`:``}`,children:[(0,O.jsx)(`span`,{className:`wizard-step-dot`,"aria-hidden":!0}),e.label]},e.key))})}function hC({onNext:e}){let[t,n]=(0,D.useState)(``),[r,i]=(0,D.useState)(``),a=up(),o=j.useUtils(),s=j.setup.gitIdentity.useMutation({onSuccess:async()=>{await o.setup.doctor.invalidate(),e()},onError:e=>a.push(e.message)}),c=t.trim()!==``&&r.includes(`@`),l=()=>c&&s.mutate({name:t.trim(),email:r.trim()});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`op-kick`,children:`WELCOME TO RUNCASTLE`}),(0,O.jsx)(`div`,{className:`op-h`,children:`Set your git identity`}),(0,O.jsxs)(`div`,{className:`op-sub`,children:[`runcastle commits documentation and merges on your behalf, so it needs a name and email. This writes to `,(0,O.jsx)(`code`,{className:`mono`,children:`git config --global`}),`.`]}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-name`,children:`Name`}),(0,O.jsx)(`input`,{id:`wiz-name`,className:`op-input mono`,value:t,onChange:e=>n(e.target.value),placeholder:`Ada Lovelace`,autoFocus:!0,spellCheck:!1,onKeyDown:e=>e.key===`Enter`&&l()}),(0,O.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-email`,children:`Email`}),(0,O.jsx)(`input`,{id:`wiz-email`,className:`op-input mono`,value:r,onChange:e=>i(e.target.value),placeholder:`ada@example.com`,spellCheck:!1,onKeyDown:e=>e.key===`Enter`&&l()}),(0,O.jsx)(`div`,{className:`op-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,onClick:l,disabled:!c||s.isPending,children:s.isPending?`Saving…`:`Continue`})})]})}function gC({onNext:e}){return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(JS,{onDismiss:e}),(0,O.jsx)(`div`,{className:`op-actions`,children:(0,O.jsx)(Ci,{variant:`solid`,onClick:e,children:`Continue to your first project`})})]})}var _C=`runcastle.update.dismissed`;function vC(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function yC(){let e=j.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[t,n]=(0,D.useState)(()=>{try{return localStorage.getItem(_C)}catch{return null}}),r=e.data;return!r||!r.latest||!vC(r,t)?null:(0,O.jsxs)(`div`,{className:`update-banner`,role:`status`,children:[(0,O.jsx)(`span`,{className:`update-banner-dot`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`update-banner-text`,children:[`runcastle `,(0,O.jsx)(`strong`,{children:r.latest}),` is available`,(0,O.jsx)(`span`,{className:`update-banner-sep`,children:` · `}),(0,O.jsxs)(`span`,{className:`update-banner-dim`,children:[`you're on `,r.current]})]}),(0,O.jsx)(`code`,{className:`update-banner-cmd`,children:r.command}),(0,O.jsx)(`button`,{className:`update-banner-dismiss`,onClick:()=>{try{localStorage.setItem(_C,r.latest)}catch{}n(r.latest)},"aria-label":`Dismiss update notice`,title:`Dismiss`,children:`×`})]})}function bC(){let e=pi(),t;return t=e.projects===void 0?(0,O.jsx)(`div`,{className:`app-loading`,children:(0,O.jsx)(M,{children:`loading projects…`})}):e.view===`open`&&e.projects.length===0?(0,O.jsx)(fC,{onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`open`?(0,O.jsx)(dC,{firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`project`&&e.currentProjectId?(0,O.jsx)(aC,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,O.jsx)(sC,{nav:e}),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(yC,{}),t]})}function xC(){return(0,O.jsx)(bC,{})}function SC(){let[e]=(0,D.useState)(()=>new Xe({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})),[t]=(0,D.useState)(()=>j.createClient({links:[Yn({url:`/api/trpc`})]}));return(0,O.jsx)(j.Provider,{client:t,queryClient:e,children:(0,O.jsx)(rt,{client:e,children:(0,O.jsx)(lp,{children:(0,O.jsx)(xC,{})})})})}var CC=document.getElementById(`root`);if(!CC)throw Error(`#root not found`);(0,Sr.createRoot)(CC).render((0,O.jsx)(D.StrictMode,{children:(0,O.jsx)(SC,{})}));