runcastle 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/runcastle.js +499 -65
- package/index.js +499 -65
- package/package.json +1 -1
- package/pty-host.cjs +5 -1
- package/skills/burner/implement-ticket.md +32 -3
- package/skills/burner/resolve-conflict.md +10 -1
- package/web/assets/{index-BcWKL2hj.js → index-Cpwb7Nqn.js} +2 -2
- package/web/assets/{index-fWdYT4eC.css → index-DBVAMsFt.css} +1 -1
- package/web/index.html +2 -2
|
@@ -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=pa,s=!Qi.jitless,c=s&&ma.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?Ls([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Bs(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=>!ka(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=>Na(e,r,$i())))}),t)}var Vs=I(`$ZodUnion`,(e,t)=>{Qo.init(e,t),sa(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),sa(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),sa(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),sa(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=>ia(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=>Bs(t,r,e,i)):Bs(o,r,e,i)}}),Hs=I(`$ZodIntersection`,(e,t)=>{Qo.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])=>Ws(e,t,n)):Ws(e,i,a)}});function Us(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ha(e)&&ha(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=Us(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=Us(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 Ws(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}),ka(e))return e;let o=Us(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Gs=I(`$ZodRecord`,(e,t)=>{Qo.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ha(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=>Na(e,r,$i())),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(...ja(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ja(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=>Na(e,r,$i())),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(...ja(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ja(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ks=I(`$ZodEnum`,(e,t)=>{Qo.init(e,t);let n=ea(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>_a.has(typeof e)).map(e=>typeof e==`string`?va(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}}),qs=I(`$ZodTransform`,(e,t)=>{Qo.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Zi(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 Xi;return n.value=i,n.fallback=!0,n}});function Js(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ys=I(`$ZodOptional`,(e,t)=>{Qo.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,sa(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),sa(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ia(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=>Js(e,r)):Js(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Xs=I(`$ZodExactOptional`,(e,t)=>{Ys.init(e,t),sa(e._zod,`values`,()=>t.innerType._zod.values),sa(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Zs=I(`$ZodNullable`,(e,t)=>{Qo.init(e,t),sa(e._zod,`optin`,()=>t.innerType._zod.optin),sa(e._zod,`optout`,()=>t.innerType._zod.optout),sa(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ia(e.source)}|null)$`):void 0}),sa(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)}),Qs=I(`$ZodDefault`,(e,t)=>{Qo.init(e,t),e._zod.optin=`optional`,sa(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=>$s(e,t)):$s(r,t)}});function $s(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ec=I(`$ZodPrefault`,(e,t)=>{Qo.init(e,t),e._zod.optin=`optional`,sa(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))}),tc=I(`$ZodNonOptional`,(e,t)=>{Qo.init(e,t),sa(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=>nc(t,e)):nc(i,e)}});function nc(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 rc=I(`$ZodCatch`,(e,t)=>{Qo.init(e,t),e._zod.optin=`optional`,sa(e._zod,`optout`,()=>t.innerType._zod.optout),sa(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=>Na(e,n,$i()))},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=>Na(e,n,$i()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ic=I(`$ZodPipe`,(e,t)=>{Qo.init(e,t),sa(e._zod,`values`,()=>t.in._zod.values),sa(e._zod,`optin`,()=>t.in._zod.optin),sa(e._zod,`optout`,()=>t.out._zod.optout),sa(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=>ac(e,t.in,n)):ac(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ac(e,t.out,n)):ac(r,t.out,n)}});function ac(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 oc=I(`$ZodPreprocess`,(e,t)=>{ic.init(e,t)}),sc=I(`$ZodReadonly`,(e,t)=>{Qo.init(e,t),sa(e._zod,`propValues`,()=>t.innerType._zod.propValues),sa(e._zod,`values`,()=>t.innerType._zod.values),sa(e._zod,`optin`,()=>t.innerType?._zod?.optin),sa(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(cc):cc(r)}});function cc(e){return e.value=Object.freeze(e.value),e}var lc=I(`$ZodCustom`,(e,t)=>{No.init(e,t),Qo.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=>uc(t,n,r,e));uc(i,n,r,e)}});function uc(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(Fa(e))}}var dc,fc=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 pc(){return new fc}(dc=globalThis).__zod_globalRegistry??(dc.__zod_globalRegistry=pc());var mc=globalThis.__zod_globalRegistry;function hc(e,t){return new e({type:`string`,...L(t)})}function gc(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function _c(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function vc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function yc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function bc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function xc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Sc(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function Cc(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function wc(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Tc(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Ec(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Dc(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Oc(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function kc(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function Ac(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function jc(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Mc(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function Nc(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Pc(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function Fc(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function Ic(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function Lc(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function Rc(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function zc(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function Bc(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function Vc(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Hc(e,t){return new e({type:`number`,checks:[],...L(t)})}function Uc(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Wc(e,t){return new e({type:`boolean`,...L(t)})}function Gc(e,t){return new e({type:`null`,...L(t)})}function Kc(e){return new e({type:`unknown`})}function qc(e,t){return new e({type:`never`,...L(t)})}function Jc(e,t){return new Fo({check:`less_than`,...L(t),value:e,inclusive:!1})}function Yc(e,t){return new Fo({check:`less_than`,...L(t),value:e,inclusive:!0})}function Xc(e,t){return new Io({check:`greater_than`,...L(t),value:e,inclusive:!1})}function Zc(e,t){return new Io({check:`greater_than`,...L(t),value:e,inclusive:!0})}function Qc(e,t){return new Lo({check:`multiple_of`,...L(t),value:e})}function $c(e,t){return new zo({check:`max_length`,...L(t),maximum:e})}function el(e,t){return new Bo({check:`min_length`,...L(t),minimum:e})}function tl(e,t){return new Vo({check:`length_equals`,...L(t),length:e})}function nl(e,t){return new Uo({check:`string_format`,format:`regex`,...L(t),pattern:e})}function rl(e){return new Wo({check:`string_format`,format:`lowercase`,...L(e)})}function il(e){return new Go({check:`string_format`,format:`uppercase`,...L(e)})}function al(e,t){return new Ko({check:`string_format`,format:`includes`,...L(t),includes:e})}function ol(e,t){return new qo({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function sl(e,t){return new Jo({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function cl(e){return new Yo({check:`overwrite`,tx:e})}function ll(e){return cl(t=>t.normalize(e))}function ul(){return cl(e=>e.trim())}function dl(){return cl(e=>e.toLowerCase())}function fl(){return cl(e=>e.toUpperCase())}function pl(){return cl(e=>da(e))}function ml(e,t,n){return new e({type:`array`,element:t,...L(n)})}function hl(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function gl(e,t){let n=_l(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Fa(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(Fa(r))}},e(t.value,t)),t);return n}function _l(e,t){let n=new No({check:`custom`,...L(t)});return n._zod.check=e,n}function vl(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??mc,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 yl(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,yl(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`&&Sl(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 bl(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 xl(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:wl(t,`input`,e.processors),output:wl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Sl(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 Sl(r.element,n);if(r.type===`set`)return Sl(r.valueType,n);if(r.type===`lazy`)return Sl(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 Sl(r.innerType,n);if(r.type===`intersection`)return Sl(r.left,n)||Sl(r.right,n);if(r.type===`record`||r.type===`map`)return Sl(r.keyType,n)||Sl(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Sl(r.in,n)||Sl(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Sl(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Sl(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Sl(e,n))return!0;return!!(r.rest&&Sl(r.rest,n))}return!1}var Cl=(e,t={})=>n=>{let r=vl({...n,processors:t});return yl(e,r),bl(r,e),xl(r,e)},wl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=vl({...i??{},target:a,io:t,processors:n});return yl(e,o),bl(o,e),xl(o,e)},Tl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},El=(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=Tl[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}))])}},Dl=(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`},kl=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Al=(e,t,n,r)=>{n.not={}},jl=(e,t,n,r)=>{let i=e._zod.def,a=ea(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ml=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Nl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Pl=(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=yl(a.element,t,{...r,path:[...r.path,`items`]})},Fl=(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]=yl(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=yl(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Il=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>yl(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ll=(e,t,n,r)=>{let i=e._zod.def,a=yl(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=yl(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]]},Rl=(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=yl(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=yl(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=yl(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)}},zl=(e,t,n,r)=>{let i=e._zod.def,a=yl(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`}]},Bl=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vl=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Hl=(e,t,n,r)=>{let i=e._zod.def;yl(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)))},Ul=(e,t,n,r)=>{let i=e._zod.def;yl(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},Wl=(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;yl(o,t,r);let s=t.seen.get(e);s.ref=o},Gl=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},z=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Kl=I(`ZodISODateTime`,(e,t)=>{fs.init(e,t),hu.init(e,t)});function B(e){return Rc(Kl,e)}var V=I(`ZodISODate`,(e,t)=>{ps.init(e,t),hu.init(e,t)});function ql(e){return zc(V,e)}var Jl=I(`ZodISOTime`,(e,t)=>{ms.init(e,t),hu.init(e,t)});function Yl(e){return Bc(Jl,e)}var Xl=I(`ZodISODuration`,(e,t)=>{hs.init(e,t),hu.init(e,t)});function Zl(e){return Vc(Xl,e)}var Ql=I(`ZodError`,(e,t)=>{La.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ba(e,t)},flatten:{value:t=>za(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ta,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ta,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),$l=Va(Ql),eu=Ha(Ql),tu=Ua(Ql),nu=Ga(Ql),ru=qa(Ql),iu=Ja(Ql),au=Ya(Ql),ou=Xa(Ql),su=Za(Ql),cu=Qa(Ql),lu=$a(Ql),uu=eo(Ql),du=new WeakMap;function fu(e,t,n){let r=Object.getPrototypeOf(e),i=du.get(r);if(i||(i=new Set,du.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 H=I(`ZodType`,(e,t)=>(Qo.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:wl(e,`input`),output:wl(e,`output`)}}),e.toJSONSchema=Cl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>$l(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>tu(e,t,n),e.parseAsync=async(t,n)=>eu(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>nu(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ru(e,t,n),e.decode=(t,n)=>iu(e,t,n),e.encodeAsync=async(t,n)=>au(e,t,n),e.decodeAsync=async(t,n)=>ou(e,t,n),e.safeEncode=(t,n)=>su(e,t,n),e.safeDecode=(t,n)=>cu(e,t,n),e.safeEncodeAsync=async(t,n)=>lu(e,t,n),e.safeDecodeAsync=async(t,n)=>uu(e,t,n),fu(e,`ZodType`,{check(...e){let t=this.def;return this.clone(la(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 ya(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ed(e,t))},superRefine(e,t){return this.check(G(e,t))},overwrite(e){return this.check(cl(e))},optional(){return sd(this)},exactOptional(){return ld(this)},nullable(){return dd(this)},nullish(){return sd(dd(this))},nonoptional(e){return _d(this,e)},array(){return Ju(this)},or(e){return W([this,e])},and(e){return $u(this,e)},transform(e){return xd(this,ad(e))},default(e){return pd(this,e)},prefault(e){return hd(this,e)},catch(e){return yd(this,e)},pipe(e){return xd(this,e)},readonly(){return wd(this)},describe(e){let t=this.clone();return mc.add(t,{description:e}),t},meta(...e){if(e.length===0)return mc.get(this);let t=this.clone();return mc.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 mc.get(e)?.description},configurable:!0}),e)),pu=I(`_ZodString`,(e,t)=>{$o.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>El(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,fu(e,`_ZodString`,{regex(...e){return this.check(nl(...e))},includes(...e){return this.check(al(...e))},startsWith(...e){return this.check(ol(...e))},endsWith(...e){return this.check(sl(...e))},min(...e){return this.check(el(...e))},max(...e){return this.check($c(...e))},length(...e){return this.check(tl(...e))},nonempty(...e){return this.check(el(1,...e))},lowercase(e){return this.check(rl(e))},uppercase(e){return this.check(il(e))},trim(){return this.check(ul())},normalize(...e){return this.check(ll(...e))},toLowerCase(){return this.check(dl())},toUpperCase(){return this.check(fl())},slugify(){return this.check(pl())}})}),mu=I(`ZodString`,(e,t)=>{$o.init(e,t),pu.init(e,t),e.email=t=>e.check(gc(gu,t)),e.url=t=>e.check(Sc(yu,t)),e.jwt=t=>e.check(Lc(Pu,t)),e.emoji=t=>e.check(Cc(bu,t)),e.guid=t=>e.check(_c(_u,t)),e.uuid=t=>e.check(vc(vu,t)),e.uuidv4=t=>e.check(yc(vu,t)),e.uuidv6=t=>e.check(bc(vu,t)),e.uuidv7=t=>e.check(xc(vu,t)),e.nanoid=t=>e.check(wc(xu,t)),e.guid=t=>e.check(_c(_u,t)),e.cuid=t=>e.check(Tc(Su,t)),e.cuid2=t=>e.check(Ec(Cu,t)),e.ulid=t=>e.check(Dc(wu,t)),e.base64=t=>e.check(Pc(ju,t)),e.base64url=t=>e.check(Fc(Mu,t)),e.xid=t=>e.check(Oc(Tu,t)),e.ksuid=t=>e.check(kc(Eu,t)),e.ipv4=t=>e.check(Ac(Du,t)),e.ipv6=t=>e.check(jc(Ou,t)),e.cidrv4=t=>e.check(Mc(ku,t)),e.cidrv6=t=>e.check(Nc(Au,t)),e.e164=t=>e.check(Ic(Nu,t)),e.datetime=t=>e.check(B(t)),e.date=t=>e.check(ql(t)),e.time=t=>e.check(Yl(t)),e.duration=t=>e.check(Zl(t))});function U(e){return hc(mu,e)}var hu=I(`ZodStringFormat`,(e,t)=>{es.init(e,t),pu.init(e,t)}),gu=I(`ZodEmail`,(e,t)=>{rs.init(e,t),hu.init(e,t)}),_u=I(`ZodGUID`,(e,t)=>{ts.init(e,t),hu.init(e,t)}),vu=I(`ZodUUID`,(e,t)=>{ns.init(e,t),hu.init(e,t)}),yu=I(`ZodURL`,(e,t)=>{is.init(e,t),hu.init(e,t)}),bu=I(`ZodEmoji`,(e,t)=>{as.init(e,t),hu.init(e,t)}),xu=I(`ZodNanoID`,(e,t)=>{os.init(e,t),hu.init(e,t)}),Su=I(`ZodCUID`,(e,t)=>{ss.init(e,t),hu.init(e,t)}),Cu=I(`ZodCUID2`,(e,t)=>{cs.init(e,t),hu.init(e,t)}),wu=I(`ZodULID`,(e,t)=>{ls.init(e,t),hu.init(e,t)}),Tu=I(`ZodXID`,(e,t)=>{us.init(e,t),hu.init(e,t)}),Eu=I(`ZodKSUID`,(e,t)=>{ds.init(e,t),hu.init(e,t)}),Du=I(`ZodIPv4`,(e,t)=>{gs.init(e,t),hu.init(e,t)}),Ou=I(`ZodIPv6`,(e,t)=>{_s.init(e,t),hu.init(e,t)}),ku=I(`ZodCIDRv4`,(e,t)=>{vs.init(e,t),hu.init(e,t)}),Au=I(`ZodCIDRv6`,(e,t)=>{ys.init(e,t),hu.init(e,t)}),ju=I(`ZodBase64`,(e,t)=>{xs.init(e,t),hu.init(e,t)}),Mu=I(`ZodBase64URL`,(e,t)=>{Cs.init(e,t),hu.init(e,t)}),Nu=I(`ZodE164`,(e,t)=>{ws.init(e,t),hu.init(e,t)}),Pu=I(`ZodJWT`,(e,t)=>{Es.init(e,t),hu.init(e,t)}),Fu=I(`ZodNumber`,(e,t)=>{Ds.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dl(e,t,n,r),fu(e,`ZodNumber`,{gt(e,t){return this.check(Xc(e,t))},gte(e,t){return this.check(Zc(e,t))},min(e,t){return this.check(Zc(e,t))},lt(e,t){return this.check(Jc(e,t))},lte(e,t){return this.check(Yc(e,t))},max(e,t){return this.check(Yc(e,t))},int(e){return this.check(Ru(e))},safe(e){return this.check(Ru(e))},positive(e){return this.check(Xc(0,e))},nonnegative(e){return this.check(Zc(0,e))},negative(e){return this.check(Jc(0,e))},nonpositive(e){return this.check(Yc(0,e))},multipleOf(e,t){return this.check(Qc(e,t))},step(e,t){return this.check(Qc(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 Iu(e){return Hc(Fu,e)}var Lu=I(`ZodNumberFormat`,(e,t)=>{Os.init(e,t),Fu.init(e,t)});function Ru(e){return Uc(Lu,e)}var zu=I(`ZodBoolean`,(e,t)=>{ks.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ol(e,t,n,r)});function Bu(e){return Wc(zu,e)}var Vu=I(`ZodNull`,(e,t)=>{As.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kl(e,t,n,r)});function Hu(e){return Gc(Vu,e)}var Uu=I(`ZodUnknown`,(e,t)=>{js.init(e,t),H.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Wu(){return Kc(Uu)}var Gu=I(`ZodNever`,(e,t)=>{Ms.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Al(e,t,n,r)});function Ku(e){return qc(Gu,e)}var qu=I(`ZodArray`,(e,t)=>{Ps.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pl(e,t,n,r),e.element=t.element,fu(e,`ZodArray`,{min(e,t){return this.check(el(e,t))},nonempty(e){return this.check(el(1,e))},max(e,t){return this.check($c(e,t))},length(e,t){return this.check(tl(e,t))},unwrap(){return this.element}})});function Ju(e,t){return ml(qu,e,t)}var Yu=I(`ZodObject`,(e,t)=>{zs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fl(e,t,n,r),sa(e,`shape`,()=>t.shape),fu(e,`ZodObject`,{keyof(){return rd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Wu()})},loose(){return this.clone({...this._zod.def,catchall:Wu()})},strict(){return this.clone({...this._zod.def,catchall:Ku()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return wa(this,e)},safeExtend(e){return Ta(this,e)},merge(e){return Ea(this,e)},pick(e){return Sa(this,e)},omit(e){return Ca(this,e)},partial(...e){return Da(od,this,e[0])},required(...e){return Oa(gd,this,e[0])}})});function Xu(e,t){return new Yu({type:`object`,shape:e??{},...L(t)})}var Zu=I(`ZodUnion`,(e,t)=>{Vs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Il(e,t,n,r),e.options=t.options});function W(e,t){return new Zu({type:`union`,options:e,...L(t)})}var Qu=I(`ZodIntersection`,(e,t)=>{Hs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ll(e,t,n,r)});function $u(e,t){return new Qu({type:`intersection`,left:e,right:t})}var ed=I(`ZodRecord`,(e,t)=>{Gs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function td(e,t,n){let r=ya(e);return r._zod.values=void 0,new ed({type:`record`,keyType:r,valueType:t,...L(n)})}var nd=I(`ZodEnum`,(e,t)=>{Ks.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jl(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 nd({...t,checks:[],...L(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 nd({...t,checks:[],...L(r),entries:i})}});function rd(e,t){return new nd({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var id=I(`ZodTransform`,(e,t)=>{qs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Zi(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Fa(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(Fa(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 ad(e){return new id({type:`transform`,transform:e})}var od=I(`ZodOptional`,(e,t)=>{Ys.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>z(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sd(e){return new od({type:`optional`,innerType:e})}var cd=I(`ZodExactOptional`,(e,t)=>{Xs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>z(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ld(e){return new cd({type:`optional`,innerType:e})}var ud=I(`ZodNullable`,(e,t)=>{Zs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dd(e){return new ud({type:`nullable`,innerType:e})}var fd=I(`ZodDefault`,(e,t)=>{Qs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pd(e,t){return new fd({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ga(t)}})}var md=I(`ZodPrefault`,(e,t)=>{ec.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hd(e,t){return new md({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ga(t)}})}var gd=I(`ZodNonOptional`,(e,t)=>{tc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _d(e,t){return new gd({type:`nonoptional`,innerType:e,...L(t)})}var vd=I(`ZodCatch`,(e,t)=>{rc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yd(e,t){return new vd({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var bd=I(`ZodPipe`,(e,t)=>{ic.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wl(e,t,n,r),e.in=t.in,e.out=t.out});function xd(e,t){return new bd({type:`pipe`,in:e,out:t})}var Sd=I(`ZodPreprocess`,(e,t)=>{bd.init(e,t),oc.init(e,t)}),Cd=I(`ZodReadonly`,(e,t)=>{sc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wd(e){return new Cd({type:`readonly`,innerType:e})}var Td=I(`ZodCustom`,(e,t)=>{lc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ml(e,t,n,r)});function Ed(e,t={}){return hl(Td,e,t)}function G(e,t){return gl(e,t)}function Dd(e,t){return new Sd({type:`pipe`,in:ad(e),out:t})}var Od=rd([`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`]),kd=rd([`pending`,`burning`,`done`,`failed`,`cancelled`]),Ad=rd([`ideation`,`qa`,`waypoint`,`converge`,`revisit`]),jd=rd([`running`,`succeeded`,`failed`,`cancelled`]),Md=rd([`active`,`shipped`,`archived`]),Nd=rd([`launching`,`live`,`ended`]);Xu({title:U(),goal:U(),context:U(),acceptanceCriteria:Ju(U()),seams:Ju(U()),blockedBy:Ju(Iu())}).extend({id:U(),featureId:U(),seq:Iu(),status:kd,commits:Ju(U()),error:U().optional(),attemptBranch:U().optional(),conflictFiles:Ju(U()).optional()});var Pd=rd([`grilling`,`research`,`prototype`,`task`]),Fd=rd([`open`,`claimed`,`resolved`,`dropped`]);rd([`resolved`,`dropped`]),Xu({title:U(),type:Pd,question:U(),blockedBy:Ju(W([Iu(),U()])),originWaypointId:U().optional()}).extend({id:U(),featureId:U(),seq:Iu(),blockedBy:Ju(Iu()),status:Fd,claimedBy:U().optional(),lastSessionId:U().optional(),summary:U().optional()}),Xu({id:U(),name:U(),repoPath:U(),mainBranch:U(),devCommand:U().optional(),model:U().optional()}),Xu({id:U(),projectId:U(),slug:U(),title:U(),oneLiner:U(),mapped:Bu(),phase:Od,branch:U(),baseBranch:U().optional(),status:Md,createdAt:Iu()}),Xu({id:U(),featureId:U(),kind:Ad,ccSessionId:U().optional(),transcriptPath:U().optional(),status:Nd,worktreePath:U()}),Xu({id:U(),featureId:U(),workflow:U(),status:jd,startedAt:Iu(),endedAt:Iu().optional(),summary:U().optional()});var Id=rd([`env`,`project`,`file`,`default`]),Ld=rd([`global`,`project`]),Rd=Xu({key:U(),value:Wu(),source:Id,editable:Bu(),restartRequired:Bu(),scope:Ld});Xu({projectId:U().optional(),fields:Ju(Rd)}),Xu({projectId:U().optional(),key:U(),value:W([U(),Iu(),Bu(),Hu()])}),Xu({id:Iu(),projectId:U(),featureId:U().optional(),runId:U().optional(),ticketId:U().optional(),ts:Iu(),type:U(),message:U(),data:Wu().optional()});var zd=[{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`,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=zd.indexOf(e.phase);return t<0||t>=zd.length-1?null:zd[t+1]}var K=Symbol.for(`drizzle:entityKind`);function Vd(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,K))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(K in n&&n[K]===t[K])return!0;n=Object.getPrototypeOf(n)}return!1}var Hd=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[K]=`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`}},Ud=class{static[K]=`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`),Gd=Symbol.for(`drizzle:isPgEnum`);function Kd(e){return!!e&&typeof e==`function`&&Gd in e&&e[Gd]===!0}var qd=class{static[K]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Jd={startActiveSpan(e,t){return t()}},Yd=Symbol.for(`drizzle:ViewBaseConfig`),Xd=Symbol.for(`drizzle:Schema`),Zd=Symbol.for(`drizzle:Columns`),Qd=Symbol.for(`drizzle:ExtraConfigColumns`),$d=Symbol.for(`drizzle:OriginalName`),ef=Symbol.for(`drizzle:BaseName`),tf=Symbol.for(`drizzle:IsAlias`),nf=Symbol.for(`drizzle:ExtraConfigBuilder`),rf=Symbol.for(`drizzle:IsDrizzleTable`),af=class{static[K]=`Table`;static Symbol={Name:Wd,Schema:Xd,OriginalName:$d,Columns:Zd,ExtraConfigColumns:Qd,BaseName:ef,IsAlias:tf,ExtraConfigBuilder:nf};[Wd];[$d];[Xd];[Zd];[Qd];[ef];[tf]=!1;[rf]=!0;[nf]=void 0;constructor(e,t,n){this[Wd]=this[$d]=e,this[Xd]=t,this[ef]=n}};function of(e){return e!=null&&typeof e.getSQL==`function`}function sf(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 cf=class{static[K]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new lf([this])}},lf=class e{constructor(e){this.queryChunks=e;for(let t of e)if(Vd(t,af)){let e=t[af.Symbol.Schema];this.usedTables.push(e===void 0?t[af.Symbol.Name]:e+`.`+t[af.Symbol.Name])}}static[K]=`SQL`;decoder=df;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Jd.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 sf(t.map(t=>{if(Vd(t,cf))return{sql:t.value.join(``),params:[]};if(Vd(t,uf))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new cf(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new cf(`, `));return e.push(new cf(`)`)),this.buildQueryFromSourceParams(e,r)}if(Vd(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(Vd(t,af)){let e=t[af.Symbol.Schema],n=t[af.Symbol.Name];return{sql:e===void 0||t[tf]?a(n):a(e)+`.`+a(n),params:[]}}if(Vd(t,Hd)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[af.Symbol.Schema];return{sql:t.table[tf]||r===void 0?a(t.table[af.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[af.Symbol.Name])+`.`+a(e),params:[]}}if(Vd(t,_f)){let e=t[Yd].schema,n=t[Yd].name;return{sql:e===void 0||t[Yd].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(Vd(t,pf)){if(Vd(t.value,hf))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(Vd(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 Vd(t,hf)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:Vd(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:Vd(t,qd)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new cf(`(`),t._.sql,new cf(`) `),new uf(t._.alias)],r):Kd(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:of(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new cf(`(`),t.getSQL(),new cf(`)`)],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}},uf=class{constructor(e){this.value=e}static[K]=`Name`;brand;getSQL(){return new lf([this])}},df={mapFromDriverValue:e=>e},ff={mapToDriverValue:e=>e};({...df,...ff});var pf=class{constructor(e,t=ff){this.value=e,this.encoder=t}static[K]=`Param`;brand;getSQL(){return new lf([this])}};function mf(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new cf(e[0]));for(let[r,i]of t.entries())n.push(i,new cf(e[r+1]));return new lf(n)}(e=>{function t(){return new lf([])}e.empty=t;function n(e){return new lf(e)}e.fromList=n;function r(e){return new lf([new cf(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 lf(n)}e.join=i;function a(e){return new uf(e)}e.identifier=a;function o(e){return new hf(e)}e.placeholder=o;function s(e,t){return new pf(e,t)}e.param=s})(mf||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[K]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(lf||={});var hf=class{constructor(e){this.name=e}static[K]=`Placeholder`;getSQL(){return new lf([this])}},gf=Symbol.for(`drizzle:IsDrizzleView`),_f=class{static[K]=`View`;[Yd];[gf]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Yd]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new lf([this])}};Hd.prototype.getSQL=function(){return new lf([this])},af.prototype.getSQL=function(){return new lf([this])},qd.prototype.getSQL=function(){return new lf([this])};function vf(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var yf=typeof TextDecoder>`u`?null:new TextDecoder,bf=class{static[K]=`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 xf(e,this)}},xf=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[K]=`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 Sf(e,t){return`${e[Wd]}_${t.join(`_`)}_unique`}var Cf=class extends Ud{static[K]=`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 bf(()=>{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))}},wf=class extends Hd{constructor(e,t){t.uniqueName||=Sf(e,[t.name]),super(e,t),this.table=e}static[K]=`SQLiteColumn`},Tf=class extends Cf{static[K]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new Ef(e,this.config)}},Ef=class extends wf{static[K]=`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(yf.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},Df=class extends Cf{static[K]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new Of(e,this.config)}},Of=class extends wf{static[K]=`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(yf.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},kf=class extends Cf{static[K]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new Af(e,this.config)}},Af=class extends wf{static[K]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function jf(e,t){let{name:n,config:r}=vf(e,t);return r?.mode===`json`?new Df(n):r?.mode===`bigint`?new Tf(n):new kf(n)}var Mf=class extends Cf{static[K]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new Nf(e,this.config)}},Nf=class extends wf{static[K]=`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 Pf(e){return(t,n)=>{let{name:r,config:i}=vf(t,n);return new Mf(r,i,e)}}var Ff=class extends Cf{static[K]=`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()}},If=class extends wf{static[K]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},Lf=class extends Ff{static[K]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new Rf(e,this.config)}},Rf=class extends If{static[K]=`SQLiteInteger`},zf=class extends Ff{static[K]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(mf`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new Bf(e,this.config)}},Bf=class extends If{static[K]=`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}},Vf=class extends Ff{static[K]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new Hf(e,this.config)}},Hf=class extends If{static[K]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function Uf(e,t){let{name:n,config:r}=vf(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new zf(n,r.mode):r?.mode===`boolean`?new Vf(n,r.mode):new Lf(n)}var Wf=class extends Cf{static[K]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Gf(e,this.config)}},Gf=class extends wf{static[K]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},Kf=class extends Cf{static[K]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new qf(e,this.config)}},qf=class extends wf{static[K]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Jf=class extends Cf{static[K]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Yf(e,this.config)}},Yf=class extends wf{static[K]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Xf(e,t){let{name:n,config:r}=vf(e,t),i=r?.mode;return i===`number`?new Kf(n):i===`bigint`?new Jf(n):new Wf(n)}var Zf=class extends Cf{static[K]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Qf(e,this.config)}},Qf=class extends wf{static[K]=`SQLiteReal`;getSQLType(){return`real`}};function $f(e){return new Zf(e??``)}var ep=class extends Cf{static[K]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new tp(e,this.config)}},tp=class extends wf{static[K]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},np=class extends Cf{static[K]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new rp(e,this.config)}},rp=class extends wf{static[K]=`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}=vf(e,t);return r.mode===`json`?new np(n):new ep(n,r)}function ip(){return{blob:jf,customType:Pf,integer:Uf,numeric:Xf,real:$f,text:q}}var ap=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),op=class extends af{static[K]=`SQLiteTable`;static Symbol=Object.assign({},af.Symbol,{InlineForeignKeys:ap});[af.Symbol.Columns];[ap]=[];[af.Symbol.ExtraConfigBuilder]=void 0};function sp(e,t,n,r,i=e){let a=new op(e,r,i),o=typeof t==`function`?t(ip()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[ap].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[af.Symbol.Columns]=s,c[af.Symbol.ExtraConfigColumns]=s,n&&(c[op.Symbol.ExtraConfigBuilder]=n),c}var cp=(e,t,n)=>sp(e,t,n);cp(`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:Uf(`closed_at`)}),cp(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),mapped:Uf(`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:Uf(`created_at`).notNull()}),cp(`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()}),cp(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:Uf(`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`),conflictFiles:q(`conflict_files`,{mode:`json`}).$type()}),cp(`waypoints`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:Uf(`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`)}),cp(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:Uf(`started_at`).notNull(),endedAt:Uf(`ended_at`),summary:q(`summary`)}),cp(`events`,{id:Uf(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:Uf(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})}),cp(`gate_overrides`,{id:Uf(`id`).primaryKey({autoIncrement:!0}),featureId:q(`feature_id`).notNull(),gate:q(`gate`).notNull(),reason:q(`reason`).notNull(),ts:Uf(`ts`).notNull()});var lp=[`ideation`,`qa`,`waypoint`,`converge`,`revisit`,`research`,`implement`,`smoke`],up=rd(lp),dp=[{id:`claude-opus-5`,label:`Opus 5`},{id:`claude-opus-5[1m]`,label:`Opus 5 (1M context)`},{id:`claude-sonnet-5`,label:`Sonnet 5`},{id:`claude-sonnet-5[1m]`,label:`Sonnet 5 (1M context)`},{id:`claude-fable-5`,label:`Fable 5`},{id:`claude-fable-5[1m]`,label:`Fable 5 (1M context)`},{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`}];Dd(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},Xu({serverPort:Iu().default(4512),model:U().default(`claude-opus-5`),stepModels:td(up,U()).default({smoke:`claude-haiku-4-5`}),sandbox:rd([`docker`,`podman`,`noSandbox`]).default(`docker`),mainBranch:U().default(`main`),sandboxImage:U().optional(),burnConcurrency:Iu().int().min(1).max(8).default(3),burnMaxIterations:Iu().int().min(1).max(10).default(3),burnAttempts:Iu().int().min(1).max(5).default(3),burnConflictAttempts:Iu().int().min(0).max(3).default(2),setupCommand:U().optional(),burnWorkspace:rd([`auto`,`mounted`,`isolated`]).default(`auto`)}));function fp(e){return e.branches.includes(e.current)?e.current:e.mainBranch}var pp=[`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`];function mp(e){return e.status===`shipped`||e.status===`archived`||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 hp(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}var gp={ideation:`ideation`,spec:`spec`,tickets:`tickets`,implementation:`build`,review:`review`,shipped:`shipped`},_p={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 vp(e){return pp.indexOf(e)}function yp(e){return e.status===`archived`?`archived`:e.status===`shipped`?`shipped`:e.activeRun?`agentWorking`:mp(e)?`needsYou`:`inProgress`}function bp(e,t={}){let n={needsYou:[],agentWorking:[],inProgress:[],shipped:[],archived:[]};for(let t of e)n[yp(t)].push(t);let r=[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`shipped`,label:`Shipped`}];return t.showArchived&&r.push({key:`archived`,label:`Archived`}),r.map(({key:e,label:t})=>({key:e,label:t,features:n[e]})).filter(e=>e.features.length>0)}function xp(e,t){let n=vp(e.phase),r=vp(t);return r<n?`done`:r===n?`current`:`upcoming`}function Sp(e){return pp.map(t=>({phase:t,state:xp(e,t)}))}function Cp(e,t){return t??e.phase}function wp(e,t){return vp(t)<vp(e.phase)}function Tp(e,t){return pp.map(n=>{let r=xp(e,n);return{phase:n,label:gp[n],state:r,isViewed:n===t,clickable:r===`done`||r===`current`,tip:_p[n]}})}var Ep=`Proceed with your task: invoke the /runcastle:revisit skill for a REVIEW ITERATION. Call get_feature_context to read the latest run outcome and every ticket’s state, then interview me about what the test drive surfaced — bugs, rough edges, tweaks. Turn what we settle on into fix tickets with emit_tickets, and use update_ticket / cancel_ticket on any stale pending tickets. Never call complete_phase — leave the phase at review. When the tickets are ready, tell me to review the cards and click Burn.`;function Dp(e,t,n){return`Proceed with your task: RESOLVE A MERGE CONFLICT. Merging ${e} into ${t} conflicts on: ${n.length?n.join(`, `):`(run git status to see the conflicts)`}. Your working directory IS the talk worktree, already checked out on ${t}. Run \`git merge ${e}\`, then resolve every conflict using this feature’s spec.md and decisions.md for intent, and commit the merge. Do NOT push and do NOT advance the phase (never call complete_phase). When the merge commit is in, tell me to click “Merge & ship” again for a clean retry.`}function Op(e){let t=e.files.length?e.files.join(`, `):`(run git status after the merge to see them)`;return`Proceed with your task: RESOLVE A MERGE CONFLICT. Ticket #${e.seq} (“${e.title}”) is fully implemented on branch ${e.branch}, but landing it on ${e.featureBranch} conflicts on: ${t}. Your working directory IS the talk worktree, already checked out on ${e.featureBranch}. Run \`git merge ${e.branch}\`, read both sides before resolving (the ticket's work on one side, the sibling tickets that landed first on the other), and resolve by intent using this feature's spec.md and decisions.md — keep BOTH sides working. Run the tests over the touched code, then commit the merge. Do NOT push and do NOT advance the phase (never call complete_phase). When the merge commit is in, tell me to click Retry on the ticket so runcastle records it as landed.`}function kp(e){let t=null;for(let n of e)if(n.type===`merge.conflict`){let e=n.data??{},r=Array.isArray(e.files)?e.files.filter(e=>typeof e==`string`):[];t={base:typeof e.base==`string`?e.base:``,files:r}}else n.type===`burn.started`&&(t=null);return t}function Ap(e,t){return e.some(e=>e.kind===t&&e.status===`ended`&&!!e.ccSessionId)}function jp(e,t){let{feature:n,tickets:r,sessions:i,runs:a,gate:o}=e,s=i.find(e=>e.status===`live`),c=Ap(i,`ideation`),l=r.length,u=r.filter(e=>e.status===`done`).length,d=r.filter(e=>e.status===`failed`).length,f=r.filter(e=>e.status!==`done`&&e.status!==`failed`&&e.status!==`cancelled`).length,p=hp(a),m=p?.status===`running`,h=Bd(n);if(n.status===`archived`)return{kick:`ARCHIVED`,title:`Feature archived`,desc:`This feature is archived and out of the pipeline. Unarchive it to pick the work back up.`,primary:{label:`Unarchive`,kind:`unarchive`},secondary:[],busy:!1};let g=!!o.next&&o.satisfied&&o.next.id!==`G3`&&o.next.id!==`G5`,_=h?`Promote to ${gp[h]}`:`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}:g?{kick:`NEXT STEP`,title:`Promote the idea`,desc:`Decisions are captured — promote the idea when it feels concrete.`,primary:{label:_,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}:c?{kick:`NEXT STEP`,title:`Pick the conversation back up`,desc:`The grill session ended, but its conversation is still on disk — resume it to carry on where you left off.`,primary:{label:`Resume grill session`,kind:`startGrill`},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 g?{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:c?`No spec yet — resume the grill conversation to draft it.`:`No spec yet — open a grill session to draft it.`,primary:{label:c?`Resume grill`:`Open grill`,kind:`startGrill`},secondary:[],busy:!1};case`tickets`:return l>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 ${l} ticket${l===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:c?`Resume grill to emit tickets`:`Open grill to emit tickets`,kind:`startGrill`},secondary:[],busy:!1};case`implementation`:return m?{kick:`IN PROGRESS`,title:`Burning tickets`,desc:`Burning ${l} ticket${l===1?``:`s`} — ${u} done${d?`, ${d} failed`:``}.`,primary:{label:`Cancel run`,kind:`cancelRun`,danger:!0},secondary:[],busy:!0}:{kick:`NEXT STEP`,title:`Resume the burn`,desc:p?.status===`failed`?`The run failed — resume the burn to retry.`:p?.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?{label:`Stop test drive`,kind:`testDriveStop`}:{label:`Start test drive`,kind:`testDriveStart`},n=s?[]:[{label:`Iterate`,kind:`revisit`}];if(f>0)return{kick:`NEXT STEP`,title:`Burn the fix tickets`,desc:t.driving?`Test-driving the branch — burn the fix tickets when you’re ready.`:`${f} fix ticket${f===1?``:`s`} ready — burn to run them, then review again.`,primary:{label:`Burn ${f} ticket${f===1?``:`s`}`,kind:`burn`},secondary:[{label:`Merge & ship`,kind:`merge`},e,...n],busy:!1};let r=t.driving?`Test-driving the branch — merge when it looks right.`:d>0?`Run finished with ${d} failed ticket${d===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:r,primary:{label:`Merge & ship`,kind:`merge`},secondary:[e,...n],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 Mp({actions:e}){let[t,n]=(0,k.useState)(!1),r=(0,k.useRef)(null);return(0,k.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),e.length===0?null:(0,A.jsxs)(`div`,{className:`row-actions`,ref:r,children:[(0,A.jsx)(`button`,{className:`row-actions-btn`,"aria-label":`feature actions`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n(e=>!e)},children:(0,A.jsx)(Ci,{size:14})}),t&&(0,A.jsx)(`div`,{className:`row-actions-menu`,role:`menu`,children:e.map(e=>(0,A.jsx)(`button`,{role:`menuitem`,className:`row-actions-item${e.danger?` is-danger`:``}`,onClick:t=>{t.stopPropagation(),n(!1),e.onSelect()},children:e.label},e.key))})]})}function Np({title:e,slug:t,busy:n,onConfirm:r,onCancel:i}){let[a,o]=(0,k.useState)(``),s=a.trim()===t;return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:i,children:(0,A.jsxs)(`div`,{className:`peek delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Delete feature ${t}`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`delete-dialog-title`,children:`Delete feature`}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:i,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`peek-body delete-dialog-body`,children:[(0,A.jsxs)(`p`,{className:`delete-dialog-lead`,children:[`Permanently delete `,(0,A.jsx)(`strong`,{children:e}),`? This stops any running agent, removes its worktree and branches, and erases all of its runcastle data. Committed docs stay in git history. `,(0,A.jsx)(`strong`,{children:`This cannot be undone.`})]}),(0,A.jsxs)(`label`,{className:`delete-dialog-field`,children:[(0,A.jsxs)(`span`,{children:[`Type `,(0,A.jsx)(`code`,{className:`mono`,children:t}),` to confirm`]}),(0,A.jsx)(`input`,{className:`settings-input mono`,value:a,onChange:e=>o(e.target.value),autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t})]}),(0,A.jsxs)(`div`,{className:`delete-dialog-actions`,children:[(0,A.jsx)(P,{variant:`ghost`,onClick:i,disabled:n,children:`Cancel`}),(0,A.jsx)(P,{variant:`danger`,onClick:r,disabled:!s||n,children:n?`Deleting…`:`Delete feature`})]})]})]})})}var Pp=`runcastle.sidebar.showArchived`;function Fp(){try{return localStorage.getItem(Pp)===`1`}catch{return!1}}function Ip({projectId:e,selectedFeatureId:t,onSelect:n,onNewFeature:r}){let i=N.useUtils(),a=Ji(),[o,s]=(0,k.useState)(Fp),[c,l]=(0,k.useState)(null),u=N.feature.list.useQuery({projectId:e},{refetchInterval:1500}),d=bp(u.data??[],{showArchived:o}),f=(u.data??[]).filter(e=>e.status===`archived`).length,p=()=>void i.feature.list.invalidate(),m=N.feature.archive.useMutation({onSuccess:p,onError:e=>a.push(e.message)}),h=N.feature.unarchive.useMutation({onSuccess:p,onError:e=>a.push(e.message)}),g=N.feature.delete.useMutation({onSuccess:(e,r)=>{if(p(),r.featureId===t){let e=(u.data??[]).find(e=>e.id!==r.featureId);e&&n(e.id)}l(null)},onError:e=>a.push(e.message)}),_=()=>{s(e=>{let t=!e;try{localStorage.setItem(Pp,t?`1`:`0`)}catch{}return t})},v=e=>{let t=e.status===`archived`?[{key:`unarchive`,label:`Unarchive`,onSelect:()=>h.mutate({featureId:e.id})}]:[{key:`archive`,label:`Archive`,onSelect:()=>m.mutate({featureId:e.id})}];return e.status!==`shipped`&&t.push({key:`delete`,label:`Delete…`,danger:!0,onSelect:()=>l(e)}),t};return(0,A.jsxs)(`nav`,{className:`sidebar`,children:[(0,A.jsxs)(`div`,{className:`sidebar-head`,children:[(0,A.jsx)(`span`,{className:`pane-title`,children:`Features`}),(0,A.jsxs)(`button`,{className:`new-btn`,onClick:r,children:[(0,A.jsx)(yi,{size:11}),`New`]})]}),(0,A.jsxs)(`div`,{className:`sidebar-list`,children:[u.isLoading&&(0,A.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,A.jsx)(F,{children:`loading features…`})}),u.data&&u.data.length===0&&(0,A.jsxs)(`div`,{className:`sidebar-empty`,children:[`No features yet.`,(0,A.jsx)(`br`,{}),`Create one to start the pipeline.`]}),d.map(e=>(0,A.jsxs)(`div`,{className:`triage-group triage-${e.key}`,children:[(0,A.jsxs)(`div`,{className:`triage-label`,children:[(0,A.jsx)(`span`,{className:`triage-name`,children:e.label}),(0,A.jsx)(`span`,{className:`triage-count`,children:e.features.length})]}),e.features.map(e=>(0,A.jsx)(Lp,{f:e,active:e.id===t,onSelect:n,actions:v(e)},e.id))]},e.key)),f>0&&(0,A.jsxs)(`button`,{className:`show-archived-toggle`,onClick:_,children:[o?`Hide`:`Show`,` archived (`,f,`)`]})]}),c&&(0,A.jsx)(Np,{title:c.title,slug:c.slug,busy:g.isPending,onConfirm:()=>g.mutate({featureId:c.id}),onCancel:()=>l(null)})]})}function Lp({f:e,active:t,onSelect:n,actions:r}){let i=mp(e),a=Sp(e),o=e.status===`shipped`||e.status===`archived`;return(0,A.jsxs)(`div`,{className:`feature-row${t?` is-active`:``}${o?` is-dim`:``}`,children:[(0,A.jsxs)(`button`,{className:`feature-row-main`,onClick:()=>n(e.id),title:`${e.title} — ${e.slug}`,children:[(0,A.jsx)(`span`,{className:`feature-dot phase-bg-${e.phase}`}),(0,A.jsx)(`span`,{className:`feature-slug`,children:e.title}),(0,A.jsx)(`span`,{className:`feature-flag`,children:e.activeRun?(0,A.jsx)(`span`,{className:`spin-ring`,title:`agent working`}):e.status===`shipped`?(0,A.jsx)(`span`,{className:`mini-check`,children:(0,A.jsx)(bi,{size:10})}):(0,A.jsxs)(A.Fragment,{children:[i&&(0,A.jsx)(`span`,{className:`needs-dot needs-${i.kind}`,title:i.label}),(0,A.jsx)(`span`,{className:`mini-map`,children:a.map((e,t)=>(0,A.jsx)(`span`,{className:`mini-seg is-${e.state}`},t))})]})})]}),(0,A.jsx)(Mp,{actions:r})]})}function Rp(e){let[t,n]=(0,k.useState)([]),r=t.length?t[t.length-1].id:void 0,i=N.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:1500});return(0,k.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 zp(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Bp(e){return e.slice(0,7)}function Vp(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 Up({featureId:e,relPath:t,title:n,onClose:r}){let i=N.docs.read.useQuery({featureId:e,relPath:t});return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:r,children:(0,A.jsxs)(`div`,{className:`peek`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`mono peek-path`,children:t}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:r,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`peek-body mono`,children:[i.isLoading&&(0,A.jsxs)(F,{children:[`loading `,n,`…`]}),i.error&&(0,A.jsxs)(F,{children:[`could not read `,t,`: `,i.error.message]}),i.data&&(0,A.jsx)(`pre`,{className:`peek-pre`,children:i.data.content})]})]})})}function Wp({featureId:e}){let[t,n]=(0,k.useState)(`details`),r=N.feature.get.useQuery({id:e},{refetchInterval:1500});return r.isLoading?(0,A.jsx)(`aside`,{className:`inspector`,children:(0,A.jsx)(F,{children:`loading…`})}):r.data?(0,A.jsxs)(`aside`,{className:`inspector`,children:[(0,A.jsxs)(`div`,{className:`insp-tabs`,role:`tablist`,children:[(0,A.jsx)(`button`,{role:`tab`,"aria-selected":t===`details`,className:`insp-tab${t===`details`?` is-active`:``}`,onClick:()=>n(`details`),children:`Details`}),(0,A.jsx)(`button`,{role:`tab`,"aria-selected":t===`activity`,className:`insp-tab${t===`activity`?` is-active`:``}`,onClick:()=>n(`activity`),children:`Activity`})]}),t===`details`?(0,A.jsxs)(`div`,{className:`insp-pane`,children:[(0,A.jsx)(qp,{featureId:e,gate:r.data.gate}),(0,A.jsx)(Xp,{featureId:e,docs:r.data.docs})]},`details`):(0,A.jsx)(`div`,{className:`insp-pane insp-pane-activity`,children:(0,A.jsx)($p,{featureId:e})},`activity`)]}):(0,A.jsx)(`aside`,{className:`inspector`,children:(0,A.jsx)(F,{children:r.error?.message??`could not load inspector`})})}var Gp={G1:`Decisions captured`,G2:`Spec written`,G3:`Tickets approved`,G4:`Run clean`,G5:`Merged`};function Kp(e){return e.check===`all-waypoints-terminal`?`Waypoints resolved`:Gp[e.id]??e.id}function qp({featureId:e,gate:t}){let n=Ji(),r=N.useUtils(),[i,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(``),c=N.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,A.jsxs)(`section`,{className:`insp-section`,children:[(0,A.jsx)(`div`,{className:`insp-cap`,children:`Current gate`}),t.next===null?(0,A.jsxs)(`div`,{className:`gate-shipped`,children:[(0,A.jsx)(bi,{size:13}),`Shipped — no gates left.`]}):(0,A.jsx)(Jp,{gateId:t.next.id,name:Kp(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 Jp({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,A.jsxs)(`div`,{className:`gate-card`,children:[(0,A.jsxs)(`div`,{className:`gate-idrow`,children:[(0,A.jsx)(`span`,{className:`gate-id`,children:e}),(0,A.jsx)(`span`,{className:`gate-name`,children:t})]}),(0,A.jsx)(`div`,{className:`gate-req`,children:n}),(0,A.jsxs)(`div`,{className:`gate-state ${r?`is-ok`:`is-block`}`,children:[(0,A.jsx)(`span`,{className:`gate-state-dot`}),(0,A.jsx)(`span`,{children:r?`Ready to advance`:i??`Blocked`})]}),a?(0,A.jsxs)(`div`,{className:`override-form`,children:[(0,A.jsx)(`input`,{className:`override-input`,placeholder:`Reason for override`,value:o,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,A.jsxs)(`div`,{className:`override-actions`,children:[(0,A.jsx)(P,{variant:`solid`,className:`btn-xs`,disabled:!o.trim()||s,onClick:d,children:`Apply`}),(0,A.jsx)(P,{variant:`ghost`,className:`btn-xs`,onClick:l,children:`Cancel`})]})]}):(0,A.jsx)(`button`,{className:`gate-override-link`,onClick:c,children:`Override with reason…`})]})}function Yp(e){return e.split(/[\\/]/).pop()??e}function Xp({featureId:e,docs:t}){let[n,r]=(0,k.useState)(null);return(0,A.jsxs)(`section`,{className:`insp-section`,children:[(0,A.jsx)(`div`,{className:`insp-cap`,children:`Knowledge`}),t.length===0?(0,A.jsx)(`div`,{className:`insp-empty`,children:`Docs the sessions write — decisions, the spec, the map — collect here.`}):(0,A.jsx)(`ul`,{className:`doc-list`,children:t.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{className:`doc-link`,onClick:()=>r({relPath:e.relPath,title:e.title}),children:[(0,A.jsx)(`span`,{className:`doc-link-icon`,children:(0,A.jsx)(Ti,{size:13})}),(0,A.jsx)(`span`,{className:`doc-title`,children:e.title}),(0,A.jsx)(`span`,{className:`doc-meta`,children:Yp(e.relPath)})]})},e.relPath))}),n&&(0,A.jsx)(Up,{featureId:e,relPath:n.relPath,title:n.title,onClose:()=>r(null)})]})}function Zp(e){return e.includes(`failed`)||e.includes(`error`)||e.includes(`blocked`)?`is-danger`:e.includes(`done`)||e.includes(`shipped`)||e.includes(`merged`)?`is-ok`:e.startsWith(`phase`)||e.startsWith(`gate`)?`is-accent`:``}function Qp(e){return e.replace(/_/g,` `).replace(`.`,` · `)}function $p({featureId:e}){let t=Rp(e).slice(-50).reverse();return(0,A.jsx)(`section`,{className:`insp-section`,children:t.length===0?(0,A.jsx)(`div`,{className:`insp-empty`,children:`Everything that happens to this feature shows up here.`}):(0,A.jsx)(`div`,{className:`activity-log`,children:t.map(e=>(0,A.jsxs)(`div`,{className:`act-line`,children:[(0,A.jsx)(`span`,{className:`act-dot ${Zp(e.type)}`}),(0,A.jsxs)(`div`,{className:`act-body`,children:[(0,A.jsx)(`div`,{className:`act-msg`,children:e.message}),(0,A.jsxs)(`div`,{className:`act-sub`,children:[(0,A.jsx)(`span`,{className:`act-type`,children:Qp(e.type)}),(0,A.jsx)(`span`,{className:`act-time`,children:Vp(e.ts)})]})]})]},e.id))})})}function em(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.status!=`string`||typeof t.summary!=`string`||t.status!==`succeeded`&&t.status!==`failed`&&t.status!==`cancelled`?null:{status:t.status,summary:t.summary}}function tm(e){let t=e.split(`
|
|
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 xl(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:wl(t,`input`,e.processors),output:wl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Sl(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 Sl(r.element,n);if(r.type===`set`)return Sl(r.valueType,n);if(r.type===`lazy`)return Sl(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 Sl(r.innerType,n);if(r.type===`intersection`)return Sl(r.left,n)||Sl(r.right,n);if(r.type===`record`||r.type===`map`)return Sl(r.keyType,n)||Sl(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Sl(r.in,n)||Sl(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Sl(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Sl(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Sl(e,n))return!0;return!!(r.rest&&Sl(r.rest,n))}return!1}var Cl=(e,t={})=>n=>{let r=vl({...n,processors:t});return yl(e,r),bl(r,e),xl(r,e)},wl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=vl({...i??{},target:a,io:t,processors:n});return yl(e,o),bl(o,e),xl(o,e)},Tl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},El=(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=Tl[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}))])}},Dl=(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`},kl=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Al=(e,t,n,r)=>{n.not={}},jl=(e,t,n,r)=>{let i=e._zod.def,a=ea(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ml=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Nl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Pl=(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=yl(a.element,t,{...r,path:[...r.path,`items`]})},Fl=(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]=yl(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=yl(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Il=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>yl(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ll=(e,t,n,r)=>{let i=e._zod.def,a=yl(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=yl(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]]},Rl=(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=yl(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=yl(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=yl(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)}},zl=(e,t,n,r)=>{let i=e._zod.def,a=yl(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`}]},Bl=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vl=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Hl=(e,t,n,r)=>{let i=e._zod.def;yl(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)))},Ul=(e,t,n,r)=>{let i=e._zod.def;yl(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},Wl=(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;yl(o,t,r);let s=t.seen.get(e);s.ref=o},Gl=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},z=(e,t,n,r)=>{let i=e._zod.def;yl(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Kl=I(`ZodISODateTime`,(e,t)=>{fs.init(e,t),hu.init(e,t)});function B(e){return Rc(Kl,e)}var V=I(`ZodISODate`,(e,t)=>{ps.init(e,t),hu.init(e,t)});function ql(e){return zc(V,e)}var Jl=I(`ZodISOTime`,(e,t)=>{ms.init(e,t),hu.init(e,t)});function Yl(e){return Bc(Jl,e)}var Xl=I(`ZodISODuration`,(e,t)=>{hs.init(e,t),hu.init(e,t)});function Zl(e){return Vc(Xl,e)}var Ql=I(`ZodError`,(e,t)=>{La.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ba(e,t)},flatten:{value:t=>za(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ta,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ta,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),$l=Va(Ql),eu=Ha(Ql),tu=Ua(Ql),nu=Ga(Ql),ru=qa(Ql),iu=Ja(Ql),au=Ya(Ql),ou=Xa(Ql),su=Za(Ql),cu=Qa(Ql),lu=$a(Ql),uu=eo(Ql),du=new WeakMap;function fu(e,t,n){let r=Object.getPrototypeOf(e),i=du.get(r);if(i||(i=new Set,du.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 H=I(`ZodType`,(e,t)=>(Qo.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:wl(e,`input`),output:wl(e,`output`)}}),e.toJSONSchema=Cl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>$l(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>tu(e,t,n),e.parseAsync=async(t,n)=>eu(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>nu(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ru(e,t,n),e.decode=(t,n)=>iu(e,t,n),e.encodeAsync=async(t,n)=>au(e,t,n),e.decodeAsync=async(t,n)=>ou(e,t,n),e.safeEncode=(t,n)=>su(e,t,n),e.safeDecode=(t,n)=>cu(e,t,n),e.safeEncodeAsync=async(t,n)=>lu(e,t,n),e.safeDecodeAsync=async(t,n)=>uu(e,t,n),fu(e,`ZodType`,{check(...e){let t=this.def;return this.clone(la(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 ya(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ed(e,t))},superRefine(e,t){return this.check(G(e,t))},overwrite(e){return this.check(cl(e))},optional(){return sd(this)},exactOptional(){return ld(this)},nullable(){return dd(this)},nullish(){return sd(dd(this))},nonoptional(e){return _d(this,e)},array(){return Ju(this)},or(e){return W([this,e])},and(e){return $u(this,e)},transform(e){return xd(this,ad(e))},default(e){return pd(this,e)},prefault(e){return hd(this,e)},catch(e){return yd(this,e)},pipe(e){return xd(this,e)},readonly(){return wd(this)},describe(e){let t=this.clone();return mc.add(t,{description:e}),t},meta(...e){if(e.length===0)return mc.get(this);let t=this.clone();return mc.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 mc.get(e)?.description},configurable:!0}),e)),pu=I(`_ZodString`,(e,t)=>{$o.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>El(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,fu(e,`_ZodString`,{regex(...e){return this.check(nl(...e))},includes(...e){return this.check(al(...e))},startsWith(...e){return this.check(ol(...e))},endsWith(...e){return this.check(sl(...e))},min(...e){return this.check(el(...e))},max(...e){return this.check($c(...e))},length(...e){return this.check(tl(...e))},nonempty(...e){return this.check(el(1,...e))},lowercase(e){return this.check(rl(e))},uppercase(e){return this.check(il(e))},trim(){return this.check(ul())},normalize(...e){return this.check(ll(...e))},toLowerCase(){return this.check(dl())},toUpperCase(){return this.check(fl())},slugify(){return this.check(pl())}})}),mu=I(`ZodString`,(e,t)=>{$o.init(e,t),pu.init(e,t),e.email=t=>e.check(gc(gu,t)),e.url=t=>e.check(Sc(yu,t)),e.jwt=t=>e.check(Lc(Pu,t)),e.emoji=t=>e.check(Cc(bu,t)),e.guid=t=>e.check(_c(_u,t)),e.uuid=t=>e.check(vc(vu,t)),e.uuidv4=t=>e.check(yc(vu,t)),e.uuidv6=t=>e.check(bc(vu,t)),e.uuidv7=t=>e.check(xc(vu,t)),e.nanoid=t=>e.check(wc(xu,t)),e.guid=t=>e.check(_c(_u,t)),e.cuid=t=>e.check(Tc(Su,t)),e.cuid2=t=>e.check(Ec(Cu,t)),e.ulid=t=>e.check(Dc(wu,t)),e.base64=t=>e.check(Pc(ju,t)),e.base64url=t=>e.check(Fc(Mu,t)),e.xid=t=>e.check(Oc(Tu,t)),e.ksuid=t=>e.check(kc(Eu,t)),e.ipv4=t=>e.check(Ac(Du,t)),e.ipv6=t=>e.check(jc(Ou,t)),e.cidrv4=t=>e.check(Mc(ku,t)),e.cidrv6=t=>e.check(Nc(Au,t)),e.e164=t=>e.check(Ic(Nu,t)),e.datetime=t=>e.check(B(t)),e.date=t=>e.check(ql(t)),e.time=t=>e.check(Yl(t)),e.duration=t=>e.check(Zl(t))});function U(e){return hc(mu,e)}var hu=I(`ZodStringFormat`,(e,t)=>{es.init(e,t),pu.init(e,t)}),gu=I(`ZodEmail`,(e,t)=>{rs.init(e,t),hu.init(e,t)}),_u=I(`ZodGUID`,(e,t)=>{ts.init(e,t),hu.init(e,t)}),vu=I(`ZodUUID`,(e,t)=>{ns.init(e,t),hu.init(e,t)}),yu=I(`ZodURL`,(e,t)=>{is.init(e,t),hu.init(e,t)}),bu=I(`ZodEmoji`,(e,t)=>{as.init(e,t),hu.init(e,t)}),xu=I(`ZodNanoID`,(e,t)=>{os.init(e,t),hu.init(e,t)}),Su=I(`ZodCUID`,(e,t)=>{ss.init(e,t),hu.init(e,t)}),Cu=I(`ZodCUID2`,(e,t)=>{cs.init(e,t),hu.init(e,t)}),wu=I(`ZodULID`,(e,t)=>{ls.init(e,t),hu.init(e,t)}),Tu=I(`ZodXID`,(e,t)=>{us.init(e,t),hu.init(e,t)}),Eu=I(`ZodKSUID`,(e,t)=>{ds.init(e,t),hu.init(e,t)}),Du=I(`ZodIPv4`,(e,t)=>{gs.init(e,t),hu.init(e,t)}),Ou=I(`ZodIPv6`,(e,t)=>{_s.init(e,t),hu.init(e,t)}),ku=I(`ZodCIDRv4`,(e,t)=>{vs.init(e,t),hu.init(e,t)}),Au=I(`ZodCIDRv6`,(e,t)=>{ys.init(e,t),hu.init(e,t)}),ju=I(`ZodBase64`,(e,t)=>{xs.init(e,t),hu.init(e,t)}),Mu=I(`ZodBase64URL`,(e,t)=>{Cs.init(e,t),hu.init(e,t)}),Nu=I(`ZodE164`,(e,t)=>{ws.init(e,t),hu.init(e,t)}),Pu=I(`ZodJWT`,(e,t)=>{Es.init(e,t),hu.init(e,t)}),Fu=I(`ZodNumber`,(e,t)=>{Ds.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dl(e,t,n,r),fu(e,`ZodNumber`,{gt(e,t){return this.check(Xc(e,t))},gte(e,t){return this.check(Zc(e,t))},min(e,t){return this.check(Zc(e,t))},lt(e,t){return this.check(Jc(e,t))},lte(e,t){return this.check(Yc(e,t))},max(e,t){return this.check(Yc(e,t))},int(e){return this.check(Ru(e))},safe(e){return this.check(Ru(e))},positive(e){return this.check(Xc(0,e))},nonnegative(e){return this.check(Zc(0,e))},negative(e){return this.check(Jc(0,e))},nonpositive(e){return this.check(Yc(0,e))},multipleOf(e,t){return this.check(Qc(e,t))},step(e,t){return this.check(Qc(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 Iu(e){return Hc(Fu,e)}var Lu=I(`ZodNumberFormat`,(e,t)=>{Os.init(e,t),Fu.init(e,t)});function Ru(e){return Uc(Lu,e)}var zu=I(`ZodBoolean`,(e,t)=>{ks.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ol(e,t,n,r)});function Bu(e){return Wc(zu,e)}var Vu=I(`ZodNull`,(e,t)=>{As.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kl(e,t,n,r)});function Hu(e){return Gc(Vu,e)}var Uu=I(`ZodUnknown`,(e,t)=>{js.init(e,t),H.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Wu(){return Kc(Uu)}var Gu=I(`ZodNever`,(e,t)=>{Ms.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Al(e,t,n,r)});function Ku(e){return qc(Gu,e)}var qu=I(`ZodArray`,(e,t)=>{Ps.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pl(e,t,n,r),e.element=t.element,fu(e,`ZodArray`,{min(e,t){return this.check(el(e,t))},nonempty(e){return this.check(el(1,e))},max(e,t){return this.check($c(e,t))},length(e,t){return this.check(tl(e,t))},unwrap(){return this.element}})});function Ju(e,t){return ml(qu,e,t)}var Yu=I(`ZodObject`,(e,t)=>{zs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fl(e,t,n,r),sa(e,`shape`,()=>t.shape),fu(e,`ZodObject`,{keyof(){return rd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Wu()})},loose(){return this.clone({...this._zod.def,catchall:Wu()})},strict(){return this.clone({...this._zod.def,catchall:Ku()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return wa(this,e)},safeExtend(e){return Ta(this,e)},merge(e){return Ea(this,e)},pick(e){return Sa(this,e)},omit(e){return Ca(this,e)},partial(...e){return Da(od,this,e[0])},required(...e){return Oa(gd,this,e[0])}})});function Xu(e,t){return new Yu({type:`object`,shape:e??{},...L(t)})}var Zu=I(`ZodUnion`,(e,t)=>{Vs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Il(e,t,n,r),e.options=t.options});function W(e,t){return new Zu({type:`union`,options:e,...L(t)})}var Qu=I(`ZodIntersection`,(e,t)=>{Hs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ll(e,t,n,r)});function $u(e,t){return new Qu({type:`intersection`,left:e,right:t})}var ed=I(`ZodRecord`,(e,t)=>{Gs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function td(e,t,n){let r=ya(e);return r._zod.values=void 0,new ed({type:`record`,keyType:r,valueType:t,...L(n)})}var nd=I(`ZodEnum`,(e,t)=>{Ks.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jl(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 nd({...t,checks:[],...L(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 nd({...t,checks:[],...L(r),entries:i})}});function rd(e,t){return new nd({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var id=I(`ZodTransform`,(e,t)=>{qs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Zi(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Fa(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(Fa(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 ad(e){return new id({type:`transform`,transform:e})}var od=I(`ZodOptional`,(e,t)=>{Ys.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>z(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sd(e){return new od({type:`optional`,innerType:e})}var cd=I(`ZodExactOptional`,(e,t)=>{Xs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>z(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ld(e){return new cd({type:`optional`,innerType:e})}var ud=I(`ZodNullable`,(e,t)=>{Zs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dd(e){return new ud({type:`nullable`,innerType:e})}var fd=I(`ZodDefault`,(e,t)=>{Qs.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pd(e,t){return new fd({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ga(t)}})}var md=I(`ZodPrefault`,(e,t)=>{ec.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hd(e,t){return new md({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ga(t)}})}var gd=I(`ZodNonOptional`,(e,t)=>{tc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _d(e,t){return new gd({type:`nonoptional`,innerType:e,...L(t)})}var vd=I(`ZodCatch`,(e,t)=>{rc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yd(e,t){return new vd({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var bd=I(`ZodPipe`,(e,t)=>{ic.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wl(e,t,n,r),e.in=t.in,e.out=t.out});function xd(e,t){return new bd({type:`pipe`,in:e,out:t})}var Sd=I(`ZodPreprocess`,(e,t)=>{bd.init(e,t),oc.init(e,t)}),Cd=I(`ZodReadonly`,(e,t)=>{sc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wd(e){return new Cd({type:`readonly`,innerType:e})}var Td=I(`ZodCustom`,(e,t)=>{lc.init(e,t),H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ml(e,t,n,r)});function Ed(e,t={}){return hl(Td,e,t)}function G(e,t){return gl(e,t)}function Dd(e,t){return new Sd({type:`pipe`,in:ad(e),out:t})}var Od=rd([`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`]),kd=rd([`pending`,`burning`,`done`,`failed`,`cancelled`]),Ad=rd([`ideation`,`qa`,`waypoint`,`converge`,`revisit`]),jd=rd([`running`,`succeeded`,`failed`,`cancelled`]),Md=rd([`active`,`shipped`,`archived`]),Nd=rd([`launching`,`live`,`ended`]);Xu({title:U(),goal:U(),context:U(),acceptanceCriteria:Ju(U()),seams:Ju(U()),blockedBy:Ju(Iu())}).extend({id:U(),featureId:U(),seq:Iu(),status:kd,commits:Ju(U()),error:U().optional(),attemptBranch:U().optional(),conflictFiles:Ju(U()).optional()});var Pd=rd([`grilling`,`research`,`prototype`,`task`]),Fd=rd([`open`,`claimed`,`resolved`,`dropped`]);rd([`resolved`,`dropped`]),Xu({title:U(),type:Pd,question:U(),blockedBy:Ju(W([Iu(),U()])),originWaypointId:U().optional()}).extend({id:U(),featureId:U(),seq:Iu(),blockedBy:Ju(Iu()),status:Fd,claimedBy:U().optional(),lastSessionId:U().optional(),summary:U().optional()}),Xu({id:U(),name:U(),repoPath:U(),mainBranch:U(),devCommand:U().optional(),model:U().optional()}),Xu({id:U(),projectId:U(),slug:U(),title:U(),oneLiner:U(),mapped:Bu(),phase:Od,branch:U(),baseBranch:U().optional(),status:Md,createdAt:Iu()}),Xu({id:U(),featureId:U(),kind:Ad,ccSessionId:U().optional(),transcriptPath:U().optional(),status:Nd,worktreePath:U()}),Xu({id:U(),featureId:U(),workflow:U(),status:jd,startedAt:Iu(),endedAt:Iu().optional(),summary:U().optional()});var Id=rd([`env`,`project`,`file`,`default`]),Ld=rd([`global`,`project`]),Rd=Xu({key:U(),value:Wu(),source:Id,editable:Bu(),restartRequired:Bu(),scope:Ld});Xu({projectId:U().optional(),fields:Ju(Rd)}),Xu({projectId:U().optional(),key:U(),value:W([U(),Iu(),Bu(),Hu()])}),Xu({id:Iu(),projectId:U(),featureId:U().optional(),runId:U().optional(),ticketId:U().optional(),ts:Iu(),type:U(),message:U(),data:Wu().optional()});var zd=[{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`,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=zd.indexOf(e.phase);return t<0||t>=zd.length-1?null:zd[t+1]}var K=Symbol.for(`drizzle:entityKind`);function Vd(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,K))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(K in n&&n[K]===t[K])return!0;n=Object.getPrototypeOf(n)}return!1}var Hd=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[K]=`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`}},Ud=class{static[K]=`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`),Gd=Symbol.for(`drizzle:isPgEnum`);function Kd(e){return!!e&&typeof e==`function`&&Gd in e&&e[Gd]===!0}var qd=class{static[K]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Jd={startActiveSpan(e,t){return t()}},Yd=Symbol.for(`drizzle:ViewBaseConfig`),Xd=Symbol.for(`drizzle:Schema`),Zd=Symbol.for(`drizzle:Columns`),Qd=Symbol.for(`drizzle:ExtraConfigColumns`),$d=Symbol.for(`drizzle:OriginalName`),ef=Symbol.for(`drizzle:BaseName`),tf=Symbol.for(`drizzle:IsAlias`),nf=Symbol.for(`drizzle:ExtraConfigBuilder`),rf=Symbol.for(`drizzle:IsDrizzleTable`),af=class{static[K]=`Table`;static Symbol={Name:Wd,Schema:Xd,OriginalName:$d,Columns:Zd,ExtraConfigColumns:Qd,BaseName:ef,IsAlias:tf,ExtraConfigBuilder:nf};[Wd];[$d];[Xd];[Zd];[Qd];[ef];[tf]=!1;[rf]=!0;[nf]=void 0;constructor(e,t,n){this[Wd]=this[$d]=e,this[Xd]=t,this[ef]=n}};function of(e){return e!=null&&typeof e.getSQL==`function`}function sf(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 cf=class{static[K]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new lf([this])}},lf=class e{constructor(e){this.queryChunks=e;for(let t of e)if(Vd(t,af)){let e=t[af.Symbol.Schema];this.usedTables.push(e===void 0?t[af.Symbol.Name]:e+`.`+t[af.Symbol.Name])}}static[K]=`SQL`;decoder=df;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Jd.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 sf(t.map(t=>{if(Vd(t,cf))return{sql:t.value.join(``),params:[]};if(Vd(t,uf))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new cf(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new cf(`, `));return e.push(new cf(`)`)),this.buildQueryFromSourceParams(e,r)}if(Vd(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(Vd(t,af)){let e=t[af.Symbol.Schema],n=t[af.Symbol.Name];return{sql:e===void 0||t[tf]?a(n):a(e)+`.`+a(n),params:[]}}if(Vd(t,Hd)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[af.Symbol.Schema];return{sql:t.table[tf]||r===void 0?a(t.table[af.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[af.Symbol.Name])+`.`+a(e),params:[]}}if(Vd(t,_f)){let e=t[Yd].schema,n=t[Yd].name;return{sql:e===void 0||t[Yd].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(Vd(t,pf)){if(Vd(t.value,hf))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(Vd(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 Vd(t,hf)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:Vd(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:Vd(t,qd)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new cf(`(`),t._.sql,new cf(`) `),new uf(t._.alias)],r):Kd(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:of(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new cf(`(`),t.getSQL(),new cf(`)`)],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}},uf=class{constructor(e){this.value=e}static[K]=`Name`;brand;getSQL(){return new lf([this])}},df={mapFromDriverValue:e=>e},ff={mapToDriverValue:e=>e};({...df,...ff});var pf=class{constructor(e,t=ff){this.value=e,this.encoder=t}static[K]=`Param`;brand;getSQL(){return new lf([this])}};function mf(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new cf(e[0]));for(let[r,i]of t.entries())n.push(i,new cf(e[r+1]));return new lf(n)}(e=>{function t(){return new lf([])}e.empty=t;function n(e){return new lf(e)}e.fromList=n;function r(e){return new lf([new cf(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 lf(n)}e.join=i;function a(e){return new uf(e)}e.identifier=a;function o(e){return new hf(e)}e.placeholder=o;function s(e,t){return new pf(e,t)}e.param=s})(mf||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[K]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(lf||={});var hf=class{constructor(e){this.name=e}static[K]=`Placeholder`;getSQL(){return new lf([this])}},gf=Symbol.for(`drizzle:IsDrizzleView`),_f=class{static[K]=`View`;[Yd];[gf]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Yd]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new lf([this])}};Hd.prototype.getSQL=function(){return new lf([this])},af.prototype.getSQL=function(){return new lf([this])},qd.prototype.getSQL=function(){return new lf([this])};function vf(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var yf=typeof TextDecoder>`u`?null:new TextDecoder,bf=class{static[K]=`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 xf(e,this)}},xf=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[K]=`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 Sf(e,t){return`${e[Wd]}_${t.join(`_`)}_unique`}var Cf=class extends Ud{static[K]=`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 bf(()=>{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))}},wf=class extends Hd{constructor(e,t){t.uniqueName||=Sf(e,[t.name]),super(e,t),this.table=e}static[K]=`SQLiteColumn`},Tf=class extends Cf{static[K]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new Ef(e,this.config)}},Ef=class extends wf{static[K]=`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(yf.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},Df=class extends Cf{static[K]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new Of(e,this.config)}},Of=class extends wf{static[K]=`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(yf.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},kf=class extends Cf{static[K]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new Af(e,this.config)}},Af=class extends wf{static[K]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function jf(e,t){let{name:n,config:r}=vf(e,t);return r?.mode===`json`?new Df(n):r?.mode===`bigint`?new Tf(n):new kf(n)}var Mf=class extends Cf{static[K]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new Nf(e,this.config)}},Nf=class extends wf{static[K]=`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 Pf(e){return(t,n)=>{let{name:r,config:i}=vf(t,n);return new Mf(r,i,e)}}var Ff=class extends Cf{static[K]=`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()}},If=class extends wf{static[K]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},Lf=class extends Ff{static[K]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new Rf(e,this.config)}},Rf=class extends If{static[K]=`SQLiteInteger`},zf=class extends Ff{static[K]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(mf`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new Bf(e,this.config)}},Bf=class extends If{static[K]=`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}},Vf=class extends Ff{static[K]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new Hf(e,this.config)}},Hf=class extends If{static[K]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function Uf(e,t){let{name:n,config:r}=vf(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new zf(n,r.mode):r?.mode===`boolean`?new Vf(n,r.mode):new Lf(n)}var Wf=class extends Cf{static[K]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Gf(e,this.config)}},Gf=class extends wf{static[K]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},Kf=class extends Cf{static[K]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new qf(e,this.config)}},qf=class extends wf{static[K]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Jf=class extends Cf{static[K]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Yf(e,this.config)}},Yf=class extends wf{static[K]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Xf(e,t){let{name:n,config:r}=vf(e,t),i=r?.mode;return i===`number`?new Kf(n):i===`bigint`?new Jf(n):new Wf(n)}var Zf=class extends Cf{static[K]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Qf(e,this.config)}},Qf=class extends wf{static[K]=`SQLiteReal`;getSQLType(){return`real`}};function $f(e){return new Zf(e??``)}var ep=class extends Cf{static[K]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new tp(e,this.config)}},tp=class extends wf{static[K]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},np=class extends Cf{static[K]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new rp(e,this.config)}},rp=class extends wf{static[K]=`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}=vf(e,t);return r.mode===`json`?new np(n):new ep(n,r)}function ip(){return{blob:jf,customType:Pf,integer:Uf,numeric:Xf,real:$f,text:q}}var ap=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),op=class extends af{static[K]=`SQLiteTable`;static Symbol=Object.assign({},af.Symbol,{InlineForeignKeys:ap});[af.Symbol.Columns];[ap]=[];[af.Symbol.ExtraConfigBuilder]=void 0};function sp(e,t,n,r,i=e){let a=new op(e,r,i),o=typeof t==`function`?t(ip()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[ap].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[af.Symbol.Columns]=s,c[af.Symbol.ExtraConfigColumns]=s,n&&(c[op.Symbol.ExtraConfigBuilder]=n),c}var cp=(e,t,n)=>sp(e,t,n);cp(`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:Uf(`closed_at`)}),cp(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),mapped:Uf(`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:Uf(`created_at`).notNull()}),cp(`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()}),cp(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:Uf(`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`),conflictFiles:q(`conflict_files`,{mode:`json`}).$type()}),cp(`waypoints`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:Uf(`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`)}),cp(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:Uf(`started_at`).notNull(),endedAt:Uf(`ended_at`),summary:q(`summary`)}),cp(`events`,{id:Uf(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:Uf(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})}),cp(`gate_overrides`,{id:Uf(`id`).primaryKey({autoIncrement:!0}),featureId:q(`feature_id`).notNull(),gate:q(`gate`).notNull(),reason:q(`reason`).notNull(),ts:Uf(`ts`).notNull()});var lp=[`ideation`,`qa`,`waypoint`,`converge`,`revisit`,`research`,`implement`,`smoke`],up=rd(lp),dp=[{id:`claude-opus-5`,label:`Opus 5`},{id:`claude-opus-5[1m]`,label:`Opus 5 (1M context)`},{id:`claude-sonnet-5`,label:`Sonnet 5`},{id:`claude-sonnet-5[1m]`,label:`Sonnet 5 (1M context)`},{id:`claude-fable-5`,label:`Fable 5`},{id:`claude-fable-5[1m]`,label:`Fable 5 (1M context)`},{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`}];Dd(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},Xu({serverPort:Iu().default(4512),model:U().default(`claude-opus-5`),stepModels:td(up,U()).default({smoke:`claude-haiku-4-5`}),sandbox:rd([`docker`,`podman`,`noSandbox`]).default(`docker`),mainBranch:U().default(`main`),sandboxImage:U().optional(),burnConcurrency:Iu().int().min(1).max(8).default(3),burnCpus:Iu().positive().max(256).optional(),burnGuard:Bu().default(!0),burnMaxIterations:Iu().int().min(1).max(10).default(3),burnAttempts:Iu().int().min(1).max(5).default(3),burnConflictAttempts:Iu().int().min(0).max(3).default(2),setupCommand:U().optional(),verifyCommands:U().optional(),knownFailures:U().optional(),burnWorkspace:rd([`auto`,`mounted`,`isolated`]).default(`auto`)}));function fp(e){return e.branches.includes(e.current)?e.current:e.mainBranch}var pp=[`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`];function mp(e){return e.status===`shipped`||e.status===`archived`||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 hp(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}var gp={ideation:`ideation`,spec:`spec`,tickets:`tickets`,implementation:`build`,review:`review`,shipped:`shipped`},_p={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 vp(e){return pp.indexOf(e)}function yp(e){return e.status===`archived`?`archived`:e.status===`shipped`?`shipped`:e.activeRun?`agentWorking`:mp(e)?`needsYou`:`inProgress`}function bp(e,t={}){let n={needsYou:[],agentWorking:[],inProgress:[],shipped:[],archived:[]};for(let t of e)n[yp(t)].push(t);let r=[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`shipped`,label:`Shipped`}];return t.showArchived&&r.push({key:`archived`,label:`Archived`}),r.map(({key:e,label:t})=>({key:e,label:t,features:n[e]})).filter(e=>e.features.length>0)}function xp(e,t){let n=vp(e.phase),r=vp(t);return r<n?`done`:r===n?`current`:`upcoming`}function Sp(e){return pp.map(t=>({phase:t,state:xp(e,t)}))}function Cp(e,t){return t??e.phase}function wp(e,t){return vp(t)<vp(e.phase)}function Tp(e,t){return pp.map(n=>{let r=xp(e,n);return{phase:n,label:gp[n],state:r,isViewed:n===t,clickable:r===`done`||r===`current`,tip:_p[n]}})}var Ep=`Proceed with your task: invoke the /runcastle:revisit skill for a REVIEW ITERATION. Call get_feature_context to read the latest run outcome and every ticket’s state, then interview me about what the test drive surfaced — bugs, rough edges, tweaks. Turn what we settle on into fix tickets with emit_tickets, and use update_ticket / cancel_ticket on any stale pending tickets. Never call complete_phase — leave the phase at review. When the tickets are ready, tell me to review the cards and click Burn.`;function Dp(e,t,n){return`Proceed with your task: RESOLVE A MERGE CONFLICT. Merging ${e} into ${t} conflicts on: ${n.length?n.join(`, `):`(run git status to see the conflicts)`}. Your working directory IS the talk worktree, already checked out on ${t}. Run \`git merge ${e}\`, then resolve every conflict using this feature’s spec.md and decisions.md for intent, and commit the merge. Do NOT push and do NOT advance the phase (never call complete_phase). When the merge commit is in, tell me to click “Merge & ship” again for a clean retry.`}function Op(e){let t=e.files.length?e.files.join(`, `):`(run git status after the merge to see them)`;return`Proceed with your task: RESOLVE A MERGE CONFLICT. Ticket #${e.seq} (“${e.title}”) is fully implemented on branch ${e.branch}, but landing it on ${e.featureBranch} conflicts on: ${t}. Your working directory IS the talk worktree, already checked out on ${e.featureBranch}. Run \`git merge ${e.branch}\`, read both sides before resolving (the ticket's work on one side, the sibling tickets that landed first on the other), and resolve by intent using this feature's spec.md and decisions.md — keep BOTH sides working. Run the tests over the touched code, then commit the merge. Do NOT push and do NOT advance the phase (never call complete_phase). When the merge commit is in, tell me to click Retry on the ticket so runcastle records it as landed.`}function kp(e){let t=null;for(let n of e)if(n.type===`merge.conflict`){let e=n.data??{},r=Array.isArray(e.files)?e.files.filter(e=>typeof e==`string`):[];t={base:typeof e.base==`string`?e.base:``,files:r}}else n.type===`burn.started`&&(t=null);return t}function Ap(e,t){return e.some(e=>e.kind===t&&e.status===`ended`&&!!e.ccSessionId)}function jp(e,t){let{feature:n,tickets:r,sessions:i,runs:a,gate:o}=e,s=i.find(e=>e.status===`live`),c=Ap(i,`ideation`),l=r.length,u=r.filter(e=>e.status===`done`).length,d=r.filter(e=>e.status===`failed`).length,f=r.filter(e=>e.status!==`done`&&e.status!==`failed`&&e.status!==`cancelled`).length,p=hp(a),m=p?.status===`running`,h=Bd(n);if(n.status===`archived`)return{kick:`ARCHIVED`,title:`Feature archived`,desc:`This feature is archived and out of the pipeline. Unarchive it to pick the work back up.`,primary:{label:`Unarchive`,kind:`unarchive`},secondary:[],busy:!1};let g=!!o.next&&o.satisfied&&o.next.id!==`G3`&&o.next.id!==`G5`,_=h?`Promote to ${gp[h]}`:`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}:g?{kick:`NEXT STEP`,title:`Promote the idea`,desc:`Decisions are captured — promote the idea when it feels concrete.`,primary:{label:_,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}:c?{kick:`NEXT STEP`,title:`Pick the conversation back up`,desc:`The grill session ended, but its conversation is still on disk — resume it to carry on where you left off.`,primary:{label:`Resume grill session`,kind:`startGrill`},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 g?{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:c?`No spec yet — resume the grill conversation to draft it.`:`No spec yet — open a grill session to draft it.`,primary:{label:c?`Resume grill`:`Open grill`,kind:`startGrill`},secondary:[],busy:!1};case`tickets`:return l>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 ${l} ticket${l===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:c?`Resume grill to emit tickets`:`Open grill to emit tickets`,kind:`startGrill`},secondary:[],busy:!1};case`implementation`:return m?{kick:`IN PROGRESS`,title:`Burning tickets`,desc:`Burning ${l} ticket${l===1?``:`s`} — ${u} done${d?`, ${d} failed`:``}.`,primary:{label:`Cancel run`,kind:`cancelRun`,danger:!0},secondary:[],busy:!0}:{kick:`NEXT STEP`,title:`Resume the burn`,desc:p?.status===`failed`?`The run failed — resume the burn to retry.`:p?.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?{label:`Stop test drive`,kind:`testDriveStop`}:{label:`Start test drive`,kind:`testDriveStart`},n=s?[]:[{label:`Iterate`,kind:`revisit`}];if(f>0)return{kick:`NEXT STEP`,title:`Burn the fix tickets`,desc:t.driving?`Test-driving the branch — burn the fix tickets when you’re ready.`:`${f} fix ticket${f===1?``:`s`} ready — burn to run them, then review again.`,primary:{label:`Burn ${f} ticket${f===1?``:`s`}`,kind:`burn`},secondary:[{label:`Merge & ship`,kind:`merge`},e,...n],busy:!1};let r=t.driving?`Test-driving the branch — merge when it looks right.`:d>0?`Run finished with ${d} failed ticket${d===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:r,primary:{label:`Merge & ship`,kind:`merge`},secondary:[e,...n],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 Mp({actions:e}){let[t,n]=(0,k.useState)(!1),r=(0,k.useRef)(null);return(0,k.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),e.length===0?null:(0,A.jsxs)(`div`,{className:`row-actions`,ref:r,children:[(0,A.jsx)(`button`,{className:`row-actions-btn`,"aria-label":`feature actions`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n(e=>!e)},children:(0,A.jsx)(Ci,{size:14})}),t&&(0,A.jsx)(`div`,{className:`row-actions-menu`,role:`menu`,children:e.map(e=>(0,A.jsx)(`button`,{role:`menuitem`,className:`row-actions-item${e.danger?` is-danger`:``}`,onClick:t=>{t.stopPropagation(),n(!1),e.onSelect()},children:e.label},e.key))})]})}function Np({title:e,slug:t,busy:n,onConfirm:r,onCancel:i}){let[a,o]=(0,k.useState)(``),s=a.trim()===t;return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:i,children:(0,A.jsxs)(`div`,{className:`peek delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Delete feature ${t}`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`delete-dialog-title`,children:`Delete feature`}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:i,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`peek-body delete-dialog-body`,children:[(0,A.jsxs)(`p`,{className:`delete-dialog-lead`,children:[`Permanently delete `,(0,A.jsx)(`strong`,{children:e}),`? This stops any running agent, removes its worktree and branches, and erases all of its runcastle data. Committed docs stay in git history. `,(0,A.jsx)(`strong`,{children:`This cannot be undone.`})]}),(0,A.jsxs)(`label`,{className:`delete-dialog-field`,children:[(0,A.jsxs)(`span`,{children:[`Type `,(0,A.jsx)(`code`,{className:`mono`,children:t}),` to confirm`]}),(0,A.jsx)(`input`,{className:`settings-input mono`,value:a,onChange:e=>o(e.target.value),autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t})]}),(0,A.jsxs)(`div`,{className:`delete-dialog-actions`,children:[(0,A.jsx)(P,{variant:`ghost`,onClick:i,disabled:n,children:`Cancel`}),(0,A.jsx)(P,{variant:`danger`,onClick:r,disabled:!s||n,children:n?`Deleting…`:`Delete feature`})]})]})]})})}var Pp=`runcastle.sidebar.showArchived`;function Fp(){try{return localStorage.getItem(Pp)===`1`}catch{return!1}}function Ip({projectId:e,selectedFeatureId:t,onSelect:n,onNewFeature:r}){let i=N.useUtils(),a=Ji(),[o,s]=(0,k.useState)(Fp),[c,l]=(0,k.useState)(null),u=N.feature.list.useQuery({projectId:e},{refetchInterval:1500}),d=bp(u.data??[],{showArchived:o}),f=(u.data??[]).filter(e=>e.status===`archived`).length,p=()=>void i.feature.list.invalidate(),m=N.feature.archive.useMutation({onSuccess:p,onError:e=>a.push(e.message)}),h=N.feature.unarchive.useMutation({onSuccess:p,onError:e=>a.push(e.message)}),g=N.feature.delete.useMutation({onSuccess:(e,r)=>{if(p(),r.featureId===t){let e=(u.data??[]).find(e=>e.id!==r.featureId);e&&n(e.id)}l(null)},onError:e=>a.push(e.message)}),_=()=>{s(e=>{let t=!e;try{localStorage.setItem(Pp,t?`1`:`0`)}catch{}return t})},v=e=>{let t=e.status===`archived`?[{key:`unarchive`,label:`Unarchive`,onSelect:()=>h.mutate({featureId:e.id})}]:[{key:`archive`,label:`Archive`,onSelect:()=>m.mutate({featureId:e.id})}];return e.status!==`shipped`&&t.push({key:`delete`,label:`Delete…`,danger:!0,onSelect:()=>l(e)}),t};return(0,A.jsxs)(`nav`,{className:`sidebar`,children:[(0,A.jsxs)(`div`,{className:`sidebar-head`,children:[(0,A.jsx)(`span`,{className:`pane-title`,children:`Features`}),(0,A.jsxs)(`button`,{className:`new-btn`,onClick:r,children:[(0,A.jsx)(yi,{size:11}),`New`]})]}),(0,A.jsxs)(`div`,{className:`sidebar-list`,children:[u.isLoading&&(0,A.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,A.jsx)(F,{children:`loading features…`})}),u.data&&u.data.length===0&&(0,A.jsxs)(`div`,{className:`sidebar-empty`,children:[`No features yet.`,(0,A.jsx)(`br`,{}),`Create one to start the pipeline.`]}),d.map(e=>(0,A.jsxs)(`div`,{className:`triage-group triage-${e.key}`,children:[(0,A.jsxs)(`div`,{className:`triage-label`,children:[(0,A.jsx)(`span`,{className:`triage-name`,children:e.label}),(0,A.jsx)(`span`,{className:`triage-count`,children:e.features.length})]}),e.features.map(e=>(0,A.jsx)(Lp,{f:e,active:e.id===t,onSelect:n,actions:v(e)},e.id))]},e.key)),f>0&&(0,A.jsxs)(`button`,{className:`show-archived-toggle`,onClick:_,children:[o?`Hide`:`Show`,` archived (`,f,`)`]})]}),c&&(0,A.jsx)(Np,{title:c.title,slug:c.slug,busy:g.isPending,onConfirm:()=>g.mutate({featureId:c.id}),onCancel:()=>l(null)})]})}function Lp({f:e,active:t,onSelect:n,actions:r}){let i=mp(e),a=Sp(e),o=e.status===`shipped`||e.status===`archived`;return(0,A.jsxs)(`div`,{className:`feature-row${t?` is-active`:``}${o?` is-dim`:``}`,children:[(0,A.jsxs)(`button`,{className:`feature-row-main`,onClick:()=>n(e.id),title:`${e.title} — ${e.slug}`,children:[(0,A.jsx)(`span`,{className:`feature-dot phase-bg-${e.phase}`}),(0,A.jsx)(`span`,{className:`feature-slug`,children:e.title}),(0,A.jsx)(`span`,{className:`feature-flag`,children:e.activeRun?(0,A.jsx)(`span`,{className:`spin-ring`,title:`agent working`}):e.status===`shipped`?(0,A.jsx)(`span`,{className:`mini-check`,children:(0,A.jsx)(bi,{size:10})}):(0,A.jsxs)(A.Fragment,{children:[i&&(0,A.jsx)(`span`,{className:`needs-dot needs-${i.kind}`,title:i.label}),(0,A.jsx)(`span`,{className:`mini-map`,children:a.map((e,t)=>(0,A.jsx)(`span`,{className:`mini-seg is-${e.state}`},t))})]})})]}),(0,A.jsx)(Mp,{actions:r})]})}function Rp(e){let[t,n]=(0,k.useState)([]),r=t.length?t[t.length-1].id:void 0,i=N.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:1500});return(0,k.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 zp(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Bp(e){return e.slice(0,7)}function Vp(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 Up({featureId:e,relPath:t,title:n,onClose:r}){let i=N.docs.read.useQuery({featureId:e,relPath:t});return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:r,children:(0,A.jsxs)(`div`,{className:`peek`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`mono peek-path`,children:t}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:r,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`peek-body mono`,children:[i.isLoading&&(0,A.jsxs)(F,{children:[`loading `,n,`…`]}),i.error&&(0,A.jsxs)(F,{children:[`could not read `,t,`: `,i.error.message]}),i.data&&(0,A.jsx)(`pre`,{className:`peek-pre`,children:i.data.content})]})]})})}function Wp({featureId:e}){let[t,n]=(0,k.useState)(`details`),r=N.feature.get.useQuery({id:e},{refetchInterval:1500});return r.isLoading?(0,A.jsx)(`aside`,{className:`inspector`,children:(0,A.jsx)(F,{children:`loading…`})}):r.data?(0,A.jsxs)(`aside`,{className:`inspector`,children:[(0,A.jsxs)(`div`,{className:`insp-tabs`,role:`tablist`,children:[(0,A.jsx)(`button`,{role:`tab`,"aria-selected":t===`details`,className:`insp-tab${t===`details`?` is-active`:``}`,onClick:()=>n(`details`),children:`Details`}),(0,A.jsx)(`button`,{role:`tab`,"aria-selected":t===`activity`,className:`insp-tab${t===`activity`?` is-active`:``}`,onClick:()=>n(`activity`),children:`Activity`})]}),t===`details`?(0,A.jsxs)(`div`,{className:`insp-pane`,children:[(0,A.jsx)(qp,{featureId:e,gate:r.data.gate}),(0,A.jsx)(Xp,{featureId:e,docs:r.data.docs})]},`details`):(0,A.jsx)(`div`,{className:`insp-pane insp-pane-activity`,children:(0,A.jsx)($p,{featureId:e})},`activity`)]}):(0,A.jsx)(`aside`,{className:`inspector`,children:(0,A.jsx)(F,{children:r.error?.message??`could not load inspector`})})}var Gp={G1:`Decisions captured`,G2:`Spec written`,G3:`Tickets approved`,G4:`Run clean`,G5:`Merged`};function Kp(e){return e.check===`all-waypoints-terminal`?`Waypoints resolved`:Gp[e.id]??e.id}function qp({featureId:e,gate:t}){let n=Ji(),r=N.useUtils(),[i,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(``),c=N.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,A.jsxs)(`section`,{className:`insp-section`,children:[(0,A.jsx)(`div`,{className:`insp-cap`,children:`Current gate`}),t.next===null?(0,A.jsxs)(`div`,{className:`gate-shipped`,children:[(0,A.jsx)(bi,{size:13}),`Shipped — no gates left.`]}):(0,A.jsx)(Jp,{gateId:t.next.id,name:Kp(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 Jp({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,A.jsxs)(`div`,{className:`gate-card`,children:[(0,A.jsxs)(`div`,{className:`gate-idrow`,children:[(0,A.jsx)(`span`,{className:`gate-id`,children:e}),(0,A.jsx)(`span`,{className:`gate-name`,children:t})]}),(0,A.jsx)(`div`,{className:`gate-req`,children:n}),(0,A.jsxs)(`div`,{className:`gate-state ${r?`is-ok`:`is-block`}`,children:[(0,A.jsx)(`span`,{className:`gate-state-dot`}),(0,A.jsx)(`span`,{children:r?`Ready to advance`:i??`Blocked`})]}),a?(0,A.jsxs)(`div`,{className:`override-form`,children:[(0,A.jsx)(`input`,{className:`override-input`,placeholder:`Reason for override`,value:o,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,A.jsxs)(`div`,{className:`override-actions`,children:[(0,A.jsx)(P,{variant:`solid`,className:`btn-xs`,disabled:!o.trim()||s,onClick:d,children:`Apply`}),(0,A.jsx)(P,{variant:`ghost`,className:`btn-xs`,onClick:l,children:`Cancel`})]})]}):(0,A.jsx)(`button`,{className:`gate-override-link`,onClick:c,children:`Override with reason…`})]})}function Yp(e){return e.split(/[\\/]/).pop()??e}function Xp({featureId:e,docs:t}){let[n,r]=(0,k.useState)(null);return(0,A.jsxs)(`section`,{className:`insp-section`,children:[(0,A.jsx)(`div`,{className:`insp-cap`,children:`Knowledge`}),t.length===0?(0,A.jsx)(`div`,{className:`insp-empty`,children:`Docs the sessions write — decisions, the spec, the map — collect here.`}):(0,A.jsx)(`ul`,{className:`doc-list`,children:t.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{className:`doc-link`,onClick:()=>r({relPath:e.relPath,title:e.title}),children:[(0,A.jsx)(`span`,{className:`doc-link-icon`,children:(0,A.jsx)(Ti,{size:13})}),(0,A.jsx)(`span`,{className:`doc-title`,children:e.title}),(0,A.jsx)(`span`,{className:`doc-meta`,children:Yp(e.relPath)})]})},e.relPath))}),n&&(0,A.jsx)(Up,{featureId:e,relPath:n.relPath,title:n.title,onClose:()=>r(null)})]})}function Zp(e){return e.includes(`failed`)||e.includes(`error`)||e.includes(`blocked`)?`is-danger`:e.includes(`done`)||e.includes(`shipped`)||e.includes(`merged`)?`is-ok`:e.startsWith(`phase`)||e.startsWith(`gate`)?`is-accent`:``}function Qp(e){return e.replace(/_/g,` `).replace(`.`,` · `)}function $p({featureId:e}){let t=Rp(e).slice(-50).reverse();return(0,A.jsx)(`section`,{className:`insp-section`,children:t.length===0?(0,A.jsx)(`div`,{className:`insp-empty`,children:`Everything that happens to this feature shows up here.`}):(0,A.jsx)(`div`,{className:`activity-log`,children:t.map(e=>(0,A.jsxs)(`div`,{className:`act-line`,children:[(0,A.jsx)(`span`,{className:`act-dot ${Zp(e.type)}`}),(0,A.jsxs)(`div`,{className:`act-body`,children:[(0,A.jsx)(`div`,{className:`act-msg`,children:e.message}),(0,A.jsxs)(`div`,{className:`act-sub`,children:[(0,A.jsx)(`span`,{className:`act-type`,children:Qp(e.type)}),(0,A.jsx)(`span`,{className:`act-time`,children:Vp(e.ts)})]})]})]},e.id))})})}function em(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.status!=`string`||typeof t.summary!=`string`||t.status!==`succeeded`&&t.status!==`failed`&&t.status!==`cancelled`?null:{status:t.status,summary:t.summary}}function tm(e){let t=e.split(`
|
|
73
73
|
`)[0].trim();return t.length>140?`${t.slice(0,139)}…`:t}function nm(e,t){if(e.type!==`run.finished`)return null;let n=em(e.data);if(!n)return null;let r=t??`your feature`;return n.status===`succeeded`?{title:`Burn complete — review is ready`,body:r}:n.status===`failed`?{title:`Burn failed`,body:`${r}: ${tm(n.summary)}`}:null}var rm=`runcastle:notifications`,im=typeof Notification<`u`;function am(){try{return localStorage.getItem(rm)===`on`}catch{return!1}}function om(e){try{localStorage.setItem(rm,e?`on`:`off`)}catch{}}function sm({title:e,body:t}){try{let n=new Notification(e,{body:t});n.onclick=()=>{window.focus(),n.close()}}catch{}}function cm(e,t){let[n,r]=(0,k.useState)(()=>im&&am()),[i,a]=(0,k.useState)(void 0),o=(0,k.useRef)(!1),s=(0,k.useRef)(new Map);s.current=new Map(t.map(e=>[e.id,e.title]));let c=N.events.listByProject.useQuery({projectId:e,afterId:i},{refetchInterval:1500,enabled:im&&n});return(0,k.useEffect)(()=>{let e=c.data;if(!e||e.length===0)return;let t=e[e.length-1].id,n=document.hidden||!document.hasFocus();if(o.current&&Notification.permission===`granted`&&n)for(let t of e){let e=nm(t,t.featureId?s.current.get(t.featureId):void 0);e&&sm(e)}o.current=!0,a(t)},[c.data]),{supported:im,enabled:n,toggle:(0,k.useCallback)(()=>{if(im){if(n){r(!1),om(!1);return}o.current=!1,a(void 0),r(!0),om(!0),Notification.permission==="default"&&Notification.requestPermission().then(e=>{e!==`granted`&&(r(!1),om(!1))})}},[n])}}var lm=`docker`,um=4512;function dm({projectId:e,activeFeatureId:t,driving:n,onDriveChange:r}){let i=Ji(),a=N.useUtils(),o=N.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=cm(e,o.data??[]),d=N.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,A.jsxs)(`footer`,{className:`statusbar`,children:[c&&(0,A.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 name`,children:[(0,A.jsx)(gi,{size:11}),c.branch]}),(0,A.jsxs)(`span`,{className:`sb-item`,title:`Agent sessions run sandboxed via ${lm}`,children:[(0,A.jsx)(Di,{size:11}),lm]}),n&&(0,A.jsxs)(`span`,{className:`sb-driving`,children:[(0,A.jsx)(`span`,{className:`sb-driving-dot`}),`driving `,(0,A.jsx)(`span`,{className:`mono`,children:n.branch}),(0,A.jsx)(`button`,{className:`sb-stop`,disabled:d.isPending,onClick:()=>d.mutate({featureId:n.featureId,action:`stop`}),children:`stop`})]}),(0,A.jsx)(`span`,{className:`sb-spacer`}),u.supported&&(0,A.jsxs)(`button`,{className:`sb-notify${u.enabled?` is-on`:``}`,onClick:u.toggle,title:u.enabled?`Desktop notifications on — click to disable`:`Notify me when a burn finishes`,children:[u.enabled?(0,A.jsx)(_i,{size:12}):(0,A.jsx)(vi,{size:12}),`notify`]}),(0,A.jsxs)(`span`,{className:`sb-item`,children:[l,` run`,l===1?``:`s`]}),(0,A.jsxs)(`span`,{className:`sb-item sb-health ${s?`is-ok`:`is-down`}`,children:[(0,A.jsx)(`span`,{className:`health-dot`}),`:`,um,` `,s?`ok`:`down`]})]})}function fm({featureId:e,sessionId:t}){let n=N.useUtils(),r=Ji(),i=N.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,A.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 pm=class extends k.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,A.jsx)(`div`,{className:`boundary-fallback`,children:(0,A.jsxs)(`span`,{className:`dim-line mono`,children:[this.props.label??`component`,` failed: `,this.state.error.message]})}):this.props.children}},mm=2,hm=1,gm=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(mm,Math.floor(u/e.css.cell.width)),rows:Math.max(hm,Math.floor(l/e.css.cell.height))}}},_m=Object.defineProperty,vm=Object.getOwnPropertyDescriptor,ym=(e,t)=>{for(var n in t)_m(e,n,{get:t[n],enumerable:!0})},bm=(e,t,n,r)=>{for(var i=r>1?void 0:r?vm(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&&_m(t,n,i),i},J=(e,t)=>(n,r)=>t(n,r,e),xm=`Terminal input`,Sm={get:()=>xm,set:e=>xm=e},Cm=`Too much output to announce, navigate to rows manually to read`,wm={get:()=>Cm,set:e=>Cm=e};function Tm(e){return e.replace(/\r?\n/g,`\r`)}function Em(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Dm(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Om(e,t,n,r){e.stopPropagation(),e.clipboardData&&km(e.clipboardData.getData(`text/plain`),t,n,r)}function km(e,t,n,r){e=Tm(e),e=Em(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Am(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 jm(e,t,n,r,i){Am(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Mm(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Nm(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 Pm=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}},Fm=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}},Im=``,Lm=` `,Rm=class e{constructor(){this.fg=0,this.bg=0,this.extended=new zm}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}},zm=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}},Bm=class e extends Rm{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new zm,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?Mm(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()]}},Vm=`di$target`,Hm=`di$dependencies`,Um=new Map;function Wm(e){return e[Hm]||[]}function Gm(e){if(Um.has(e))return Um.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Km(t,e,r)};return t._id=e,Um.set(e,t),t}function Km(e,t,n){t[Vm]===t?t[Hm].push({id:e,index:n}):(t[Hm]=[{id:e,index:n}],t[Vm]=t)}var qm=Gm(`BufferService`),Jm=Gm(`CoreMouseService`),Ym=Gm(`CoreService`),Xm=Gm(`CharsetService`),Zm=Gm(`InstantiationService`),Qm=Gm(`LogService`),$m=Gm(`OptionsService`),eh=Gm(`OscLinkService`),th=Gm(`UnicodeService`),nh=Gm(`DecorationService`),rh=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 Bm,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):ih(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)}};rh=bm([J(0,qm),J(1,$m),J(2,eh)],rh);function ih(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
74
74
|
|
|
75
75
|
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 ah=Gm(`CharSizeService`),oh=Gm(`CoreBrowserService`),sh=Gm(`MouseService`),ch=Gm(`RenderService`),lh=Gm(`SelectionService`),uh=Gm(`CharacterJoinerService`),dh=Gm(`ThemeService`),fh=Gm(`LinkProviderService`),ph=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?yh.isErrorNoTelemetry(e)?new yh(e.message+`
|
|
@@ -107,4 +107,4 @@ ${s.join(`
|
|
|
107
107
|
`,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 Sm.get()},set promptLabel(e){Sm.set(e)},get tooMuchOutput(){return wm.get()},set tooMuchOutput(e){wm.set(e)}}}_verifyIntegers(...e){for(OS of e)if(OS===1/0||isNaN(OS)||OS%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(OS of e)if(OS&&(OS===1/0||isNaN(OS)||OS%1!=0||OS<0))throw Error(`This API only accepts positive integers`)}},AS=250,jS=5e3,MS=8e3,NS=3e3;function PS(e){return`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}`}function FS(){return PS(window.location)}var IS=class{opts;ws=null;backoff=AS;reconnectTimer=null;connectTimer=null;stallTimer=null;disposed=!1;ended=!1;receivedData=!1;url;constructor(e){this.opts=e;let t=e.wsBase??FS();this.url=`${t.replace(/\/$/,``)}/ws/terminal/${encodeURIComponent(e.sessionId)}`}connect(){if(this.disposed||this.ended)return;this.clearTimer(),this.opts.onStatus(this.backoff===AS?`connecting`:`reconnecting`);let e=new WebSocket(this.url);e.binaryType=`arraybuffer`,this.ws=e,this.connectTimer=setTimeout(()=>{e.readyState===WebSocket.CONNECTING&&this.forceClose(e)},MS),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=AS,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)},NS))}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,jS),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)}};function LS(e){if(e.key===`Enter`&&(e.shiftKey||e.ctrlKey)){if(e.type===`keydown`)return{intercept:!0,bytes:`\x1B\r`};if(e.type===`keypress`)return{intercept:!0,bytes:``}}return{intercept:!1}}var RS={background:`#07080b`,foreground:`#C9D1D9`,cursor:`#7c6cf6`,cursorAccent:`#07080b`,selectionBackground:`rgba(124,108,246,0.25)`};function zS({sessionId:e,wsBase:t}){let n=(0,k.useRef)(null),[r,i]=(0,k.useState)(`connecting`);(0,k.useEffect)(()=>{let r=n.current;if(!r)return;let a=new kS({theme:RS,fontFamily:`"JetBrains Mono Variable", "Cascadia Code", Consolas, monospace`,fontSize:12.5,cursorBlink:!0,allowProposedApi:!0,scrollback:5e3}),o=new gm;a.loadAddon(o),a.open(r);let s=()=>{try{o.fit()}catch{}};s();let c=requestAnimationFrame(s),l;l=new IS({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));a.attachCustomKeyEventHandler(e=>{let t=LS(e);return t.intercept?(t.bytes&&l.send(t.bytes),!1):!0}),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,A.jsxs)(`div`,{style:{position:`relative`,width:`100%`,height:`100%`,background:`#07080b`,overflow:`hidden`,boxSizing:`border-box`,padding:`8px 2px 6px 10px`},children:[(0,A.jsx)(`div`,{ref:n,style:{width:`100%`,height:`100%`},"data-session-id":e}),a&&(0,A.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 BS({featureId:e,sessions:t,className:n,showResume:r=!0}){let i=VS(t);return i?i.status===`ended`?(0,A.jsx)(US,{featureId:e,session:i,showResume:r}):(0,A.jsxs)(`div`,{className:`grill-panel${n?` ${n}`:``}`,children:[(0,A.jsxs)(`div`,{className:`grill-strip`,children:[(0,A.jsx)(`span`,{className:`grill-kind`,children:i.kind}),(0,A.jsx)(Gi,{status:i.status}),(0,A.jsx)(`span`,{className:`grill-live-label`,children:i.status===`launching`?`launching…`:`live`}),(0,A.jsx)(`span`,{className:`grill-strip-spacer`}),(0,A.jsx)(`span`,{className:`grill-sid`,title:i.ccSessionId??i.id,children:(i.ccSessionId??i.id).slice(0,8)}),(0,A.jsx)(fm,{featureId:e,sessionId:i.id})]}),(0,A.jsx)(`div`,{className:`grill-term`,id:`grill-term`,children:(0,A.jsx)(pm,{label:`terminal`,children:(0,A.jsx)(zS,{sessionId:i.id})})})]}):null}function VS(e){let t=[...e].reverse();return t.find(e=>e.status===`live`||e.status===`launching`)??t.find(e=>e.status===`ended`&&!!e.ccSessionId)??t[0]}function HS(e){return!!e.ccSessionId&&e.kind!==`waypoint`}function US({featureId:e,session:t,showResume:n}){let r=N.useUtils(),i=Ji(),a=N.feature.launchSession.useMutation({onSuccess:()=>{r.feature.get.invalidate({id:e}),r.feature.list.invalidate()},onError:e=>i.push(e.message)}),o=n&&HS(t);return(0,A.jsxs)(`div`,{className:`session-ended-card`,id:`grill-term`,children:[(0,A.jsx)(`span`,{className:`session-ended-dot`}),(0,A.jsxs)(`div`,{className:`session-ended-main`,children:[(0,A.jsx)(`div`,{className:`session-ended-title`,children:`Session ended`}),(0,A.jsx)(`div`,{className:`session-ended-sub`,children:o?`The conversation is still on disk — resume it to pick up where you left off.`:`Decisions from this conversation were captured to Knowledge.`})]}),o&&(0,A.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost session-ended-resume`,disabled:a.isPending,title:`resume the ${t.kind} conversation in a new terminal`,onClick:()=>a.mutate({featureId:e,kind:t.kind}),children:a.isPending?`Resuming…`:`Resume session`})]})}function WS({full:e,effective:t}){let{feature:n,sessions:r,docs:i}=e,a=i.find(e=>e.relPath.endsWith(`spec.md`)),o=n.mapped?i.find(e=>e.relPath.endsWith(`map.md`)):void 0,s=r.some(e=>e.status===`live`||e.status===`launching`),c=n.mapped&&n.phase===`spec`&&t===`spec`&&!s&&e.tickets.length===0,l=n.mapped||t===`spec`;return(0,A.jsxs)(`div`,{className:`grill${l?` has-context`:``}`,children:[n.mapped&&(0,A.jsx)(JS,{full:e,relPath:o?.relPath}),t===`spec`&&(0,A.jsx)(GS,{featureId:n.id,relPath:a?.relPath}),(0,A.jsxs)(`div`,{className:`body-title`,style:{marginTop:l?18:0},children:[(0,A.jsx)(Bi,{children:`Session`}),(0,A.jsx)(`span`,{className:`body-hint`,children:`shape the idea with Claude — promote it when it feels concrete`})]}),r.length>0?(0,A.jsx)(BS,{featureId:n.id,sessions:r,showResume:!c}):(0,A.jsx)(`div`,{className:`grill-panel`,children:(0,A.jsx)(Vi,{icon:(0,A.jsx)(wi,{size:16}),title:`No session yet`,hint:`Start a session from the bar above — you and Claude shape the idea here before any code is written.`})}),c&&(0,A.jsx)(KS,{featureId:n.id})]})}function GS({featureId:e,relPath:t}){let[n,r]=(0,k.useState)(!1);return t?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{className:`doc-card`,onClick:()=>r(!0),title:`View the spec`,children:[(0,A.jsx)(Ti,{size:14}),(0,A.jsx)(`span`,{className:`doc-card-title`,children:`Specification`}),(0,A.jsx)(`span`,{className:`doc-card-meta`,children:t.split(/[\\/]/).pop()}),(0,A.jsxs)(`span`,{className:`doc-card-open`,children:[`View`,(0,A.jsx)(Si,{size:11})]})]}),n&&(0,A.jsx)(Up,{featureId:e,relPath:t,title:`Specification`,onClose:()=>r(!1)})]}):(0,A.jsxs)(`div`,{className:`doc-card is-empty`,children:[(0,A.jsx)(Ti,{size:14}),(0,A.jsx)(`span`,{className:`doc-card-title`,children:`Spec not written yet`}),(0,A.jsx)(`span`,{className:`doc-card-hint`,children:`continue the session to draft it`})]})}function KS({featureId:e}){let t=N.useUtils(),n=Ji(),r=N.feature.converge.useMutation({onSuccess:()=>{t.feature.get.invalidate({id:e}),t.feature.list.invalidate()},onError:e=>n.push(e.message)});return(0,A.jsxs)(`div`,{className:`converge-resume`,children:[(0,A.jsx)(`span`,{className:`converge-resume-text`,children:`The converge session ended before tickets were emitted.`}),(0,A.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 qS=[`Destination`,`Notes`,`Not yet specified`,`Out of scope`];function JS({full:e,relPath:t}){let n=e.feature.id,r=N.docs.read.useQuery({featureId:n,relPath:t??`map.md`},{enabled:!!t}),i=r.data?ZS(r.data.content):{};return!t&&e.waypoints.length===0?(0,A.jsxs)(`div`,{className:`map-panel`,children:[(0,A.jsxs)(`div`,{className:`body-title`,children:[(0,A.jsx)(Bi,{children:`Map`}),(0,A.jsx)(`span`,{className:`body-hint`,children:`the destination and open questions, charted before diving in`})]}),(0,A.jsxs)(`div`,{className:`doc-card is-empty`,children:[(0,A.jsx)(Ti,{size:14}),(0,A.jsx)(`span`,{className:`doc-card-title`,children:`Not charted yet`}),(0,A.jsx)(`span`,{className:`doc-card-hint`,children:`the session writes the map as you explore the idea`})]})]}):(0,A.jsxs)(`div`,{className:`map-panel`,children:[(0,A.jsxs)(`div`,{className:`body-title`,children:[(0,A.jsx)(Bi,{children:`Map`}),(0,A.jsx)(`span`,{className:`body-hint`,children:`the destination and open questions, charted before diving in`})]}),r.isLoading&&(0,A.jsx)(F,{children:`loading map…`}),t&&(0,A.jsx)(`div`,{className:`map-sections`,children:qS.map(e=>{let t=i[e]?.trim();return(0,A.jsxs)(`section`,{className:`map-section`,children:[(0,A.jsx)(`div`,{className:`map-section-title`,children:e}),t?(0,A.jsx)(`div`,{className:`map-section-body`,children:t}):(0,A.jsx)(F,{children:`—`})]},e)})}),(0,A.jsx)(XS,{featureId:n,waypoints:e.waypoints,frontierIds:e.frontierIds,sessions:e.sessions}),(0,A.jsx)(YS,{full:e,fog:i[`Not yet specified`]?.trim()})]})}function YS({full:e,fog:t}){let{feature:n,gate:r}=e,i=N.useUtils(),a=Ji(),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(``),u=N.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,A.jsxs)(`section`,{className:`converge-bar`,children:[t&&(0,A.jsxs)(`div`,{className:`converge-fog`,role:`note`,children:[(0,A.jsx)(`span`,{className:`converge-fog-icon`,"aria-hidden":`true`,children:`⚑`}),(0,A.jsxs)(`span`,{className:`converge-fog-text`,children:[`Fog remains — still not specified: `,t,`. You can converge anyway.`]})]}),r.satisfied?(0,A.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,A.jsxs)(`div`,{className:`converge-override`,children:[(0,A.jsx)(`input`,{className:`override-input`,placeholder:`reason to converge past open waypoints`,value:c,autoFocus:!0,onChange:e=>l(e.target.value)}),(0,A.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,A.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost`,onClick:()=>{s(!1),l(``)},children:`Cancel`})]}):(0,A.jsxs)(`div`,{className:`converge-blocked`,children:[(0,A.jsx)(F,{children:r.reason??`resolve the open waypoints to converge`}),(0,A.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost`,onClick:()=>s(!0),children:`Override & converge…`})]})]})}function XS({featureId:e,waypoints:t,frontierIds:n,sessions:r}){let i=N.useUtils(),a=Ji(),o=N.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,A.jsx)(`div`,{className:`map-waypoints`,children:(0,A.jsx)(F,{children:`No waypoints yet — they appear here as the map takes shape.`})});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,A.jsxs)(`div`,{className:`wp-lineage`,children:[`surfaced by `,t]}):null};return(0,A.jsxs)(`div`,{className:`map-waypoints`,children:[m.length>0&&(0,A.jsxs)(`section`,{className:`wp-group wp-group-frontier`,children:[(0,A.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,A.jsxs)(`div`,{className:`wp wp-frontier`,children:[(0,A.jsx)(`span`,{className:`wp-type`,children:t.type}),(0,A.jsx)(`span`,{className:`wp-title`,children:t.title}),(0,A.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,A.jsx)(v,{w:t})]},t.id)})]}),h.length>0&&(0,A.jsxs)(`section`,{className:`wp-group wp-group-blocked`,children:[(0,A.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,A.jsxs)(`div`,{className:`wp wp-blocked`,children:[(0,A.jsx)(`span`,{className:`wp-type`,children:e.type}),(0,A.jsx)(`span`,{className:`wp-title`,children:e.title}),t.length>0&&(0,A.jsxs)(`span`,{className:`wp-blockers`,children:[`blocked by `,t.join(`, `)]}),(0,A.jsx)(v,{w:e})]},e.id)})]}),g.length>0&&(0,A.jsxs)(`section`,{className:`wp-group wp-group-claimed`,children:[(0,A.jsxs)(`div`,{className:`wp-group-title`,children:[`Claimed · `,g.length]}),g.map(e=>{let t=e.claimedBy?.startsWith(`run_`)??!1;return(0,A.jsxs)(`div`,{className:`wp wp-claimed`,children:[(0,A.jsx)(`span`,{className:`wp-pulse`,"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`wp-type`,children:e.type}),(0,A.jsx)(`span`,{className:`wp-title`,children:e.title}),t&&(0,A.jsx)(`span`,{className:`wp-run-note`,children:`researching…`}),(0,A.jsx)(v,{w:e})]},e.id)})]}),_.length>0&&(0,A.jsxs)(`details`,{className:`wp-group wp-group-done`,children:[(0,A.jsxs)(`summary`,{className:`wp-group-title`,children:[`Resolved / dropped · `,_.length]}),_.map(e=>(0,A.jsxs)(`div`,{className:`wp wp-done wp-${e.status}`,children:[(0,A.jsx)(`span`,{className:`wp-type`,children:e.status}),(0,A.jsx)(`span`,{className:`wp-title`,children:e.title}),e.summary&&(0,A.jsx)(`span`,{className:`wp-summary`,children:e.summary})]},e.id))]})]})}function ZS(e){let t={},n=null,r=[],i=()=>{n!==null&&(t[n]=r.join(`
|
|
108
108
|
`)),r.length=0};for(let t of e.split(`
|
|
109
109
|
`)){let e=t.match(/^##\s+(.+?)\s*$/);e?(i(),n=e[1]):n!==null&&r.push(t)}return i(),t}function QS({full:e,driving:t}){let{feature:n,tickets:r,runs:i}=e,a=e.sessions.some(e=>e.status===`live`||e.status===`launching`),o=kp(Rp(n.id)),s=hp(i),c=r.length,l=r.filter(e=>e.status===`done`).length,u=r.filter(e=>e.status===`failed`).length,d=r.reduce((e,t)=>e+t.commits.length,0),f=t?.featureId===n.id,p=u>0?`var(--danger)`:`var(--ok)`,m=s?.status===`succeeded`?`var(--ok)`:s?.status===`failed`?`var(--danger)`:`var(--text-3)`;return(0,A.jsxs)(`div`,{className:`review-body`,children:[(0,A.jsx)(BS,{featureId:n.id,sessions:e.sessions,className:`review-session`}),o&&(0,A.jsx)($S,{featureId:n.id,branch:n.branch,conflict:o,sessionLive:a}),(0,A.jsxs)(`div`,{className:`review-grid`,children:[(0,A.jsxs)(`div`,{className:`review-card`,children:[(0,A.jsx)(Bi,{children:`Summary`}),(0,A.jsxs)(`div`,{className:`check-row`,children:[(0,A.jsx)(`span`,{className:`check-dot`,style:{background:p}}),(0,A.jsx)(`span`,{className:`check-k`,children:`tickets`}),(0,A.jsxs)(`span`,{className:`check-v`,children:[l,`/`,c,` done`,u>0?` · ${u} failed`:``]})]}),(0,A.jsxs)(`div`,{className:`check-row`,children:[(0,A.jsx)(`span`,{className:`check-dot`,style:{background:m}}),(0,A.jsx)(`span`,{className:`check-k`,children:`run`}),(0,A.jsx)(`span`,{className:`check-v`,children:s?`${s.status}${s.summary?` · ${s.summary}`:``}`:`no run recorded`})]}),(0,A.jsxs)(`div`,{className:`check-row`,children:[(0,A.jsx)(`span`,{className:`check-dot`,style:{background:`var(--ph-shipped)`}}),(0,A.jsx)(`span`,{className:`check-k`,children:`changes`}),(0,A.jsxs)(`span`,{className:`check-v`,children:[d,` commit`,d===1?``:`s`]})]}),(0,A.jsx)(`div`,{className:`review-foot`,children:n.branch})]}),(0,A.jsxs)(`div`,{className:`review-card`,children:[(0,A.jsx)(Bi,{children:`Test drive`}),f&&t?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`drive-live`,children:[(0,A.jsx)(`span`,{className:`drive-pulse`}),(0,A.jsx)(`span`,{className:`drive-label`,children:`driving now`}),(0,A.jsx)(`span`,{className:`drive-loc`,children:t.branch})]}),(0,A.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,A.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.`})]})]}),f&&(0,A.jsx)(eC,{featureId:n.id})]})}function $S({featureId:e,branch:t,conflict:n,sessionLive:r}){let i=N.useUtils(),a=Ji(),o=N.feature.launchSession.useMutation({onSuccess:()=>void i.feature.get.invalidate({id:e}),onError:e=>a.push(e.message)});return(0,A.jsxs)(`div`,{className:`review-card conflict-card`,children:[(0,A.jsx)(Bi,{children:`Merge conflict`}),(0,A.jsxs)(`div`,{className:`drive-copy`,children:[`Merging `,(0,A.jsx)(`code`,{children:n.base}),` into `,(0,A.jsx)(`code`,{children:t}),` hit conflicts. An agent can merge the base into this branch in the talk worktree, resolve with full spec context, and commit — then retry Merge & ship.`]}),n.files.length>0&&(0,A.jsx)(`ul`,{className:`conflict-files`,children:n.files.map(e=>(0,A.jsx)(`li`,{children:e},e))}),!r&&(0,A.jsx)(P,{variant:`solid`,className:`conflict-resolve`,disabled:o.isPending,onClick:()=>o.mutate({featureId:e,kind:`revisit`,kickoffLine:Dp(n.base,t,n.files)}),children:`Resolve with agent`})]})}function eC({featureId:e}){let[t,n]=(0,k.useState)(!1),r=N.feature.driveInfo.useQuery(void 0,{refetchInterval:1500}).data;return!r||r.featureId!==e?null:(0,A.jsxs)(`div`,{className:`drive-pane`,children:[(0,A.jsxs)(`div`,{className:`drive-pane-strip`,children:[(0,A.jsx)(`span`,{className:`drive-pane-kind`,children:`dev server`}),(0,A.jsx)(`span`,{className:`drive-pane-loc`,children:r.branch}),(0,A.jsx)(`span`,{className:`drive-pane-spacer`}),r.devUrl&&(0,A.jsx)(`a`,{className:`drive-open`,href:r.devUrl,target:`_blank`,rel:`noreferrer noopener`,children:`Open app ↗`}),r.devPaneId&&(0,A.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,A.jsx)(`div`,{className:`drive-pane-term`,children:(0,A.jsx)(pm,{label:`dev terminal`,children:(0,A.jsx)(zS,{sessionId:r.devPaneId})})}):(0,A.jsx)(`div`,{className:`drive-pane-empty`,children:`no dev command configured for this project`}))]})}function tC({full:e}){let t=[...Rp(e.feature.id)].reverse().find(e=>e.type===`feature.shipped`||e.type===`merge.conflict`||e.type===`feature.status`),n=t&&t.type===`feature.shipped`?Vp(t.ts):``;return(0,A.jsxs)(`div`,{className:`shipped-hero`,children:[(0,A.jsx)(`div`,{className:`shipped-check`,children:(0,A.jsx)(bi,{size:17})}),(0,A.jsx)(`div`,{className:`shipped-title`,children:`Shipped to main`}),(0,A.jsxs)(`div`,{className:`shipped-meta`,children:[(0,A.jsx)(gi,{size:12}),e.feature.branch,n?` · merged ${n} ago`:``]}),(0,A.jsx)(`div`,{className:`shipped-sub`,children:`The branch is merged and the pipeline is complete. The full history lives in the Activity tab.`})]})}function nC({featureId:e,readonly:t=!1}){let n=Ji(),r=N.feature.get.useQuery({id:e},{refetchInterval:1500}),[i,a]=(0,k.useState)(()=>new Set),o=r.data?.feature.projectId,s=N.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,A.jsx)(F,{children:`loading tickets…`});if(!r.data)return(0,A.jsxs)(F,{children:[`could not load tickets: `,r.error?.message??`unknown`]});let u=r.data.tickets,d=u.length,f=u.filter(e=>e.status===`done`).length,p=u.filter(e=>e.status===`failed`).length,m=u.filter(e=>e.status===`burning`).length,h=u.filter(e=>e.status===`cancelled`).length,g=[`${f}/${d} done`];p>0&&g.push(`${p} failed`),m>0&&g.push(`${m} burning`),h>0&&g.push(`${h} cancelled`);let _=g.join(` · `),v=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),y=e=>{navigator.clipboard.writeText(e),n.push(`copied ${Bp(e)}`,`info`)};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(BS,{featureId:e,sessions:r.data.sessions,className:`tickets-session`}),(0,A.jsxs)(`div`,{className:`body-title`,children:[(0,A.jsx)(Bi,{children:`Tickets`}),(0,A.jsx)(`span`,{className:`body-meta`,children:_}),(0,A.jsx)(`span`,{style:{flex:1}}),(0,A.jsxs)(`span`,{className:`chip chip-neutral`,title:`sandbox`,children:[`sandbox · `,lm]}),(0,A.jsx)(`span`,{className:`chip chip-neutral`,title:`model`,children:l})]}),d===0?(0,A.jsx)(`div`,{className:`ledger`,children:(0,A.jsx)(Vi,{icon:(0,A.jsx)(Ti,{size:16}),title:`No tickets yet`,hint:`A session breaks the spec into atomic, reviewable tickets — start one from the bar above.`,compact:!0})}):(0,A.jsx)(`div`,{className:`ledger`,children:u.map(e=>{let t=i.has(e.id);return(0,A.jsxs)(`div`,{className:`ledger-row${t?` is-open`:``}`,children:[(0,A.jsxs)(`button`,{className:`ledger-head`,onClick:()=>v(e.id),children:[(0,A.jsx)(`span`,{className:`lg-caret`,children:(0,A.jsx)(Si,{size:11})}),(0,A.jsxs)(`span`,{className:`lg-seq`,children:[`#`,e.seq]}),(0,A.jsx)(`span`,{className:`lg-title`,children:e.title}),e.blockedBy.length>0&&(0,A.jsxs)(`span`,{className:`lg-block`,title:`Runs after these tickets land`,children:[`after #`,e.blockedBy.join(`, #`)]}),(0,A.jsx)(`span`,{className:`lg-meta`,children:(0,A.jsx)(Ui,{status:e.status})})]}),t&&(0,A.jsxs)(`div`,{className:`ledger-detail`,children:[(0,A.jsxs)(`div`,{className:`td-section`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`GOAL`}),(0,A.jsx)(`div`,{className:`td-body`,children:e.goal})]}),e.context&&(0,A.jsxs)(`div`,{className:`td-section`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`CONTEXT`}),(0,A.jsx)(`div`,{className:`td-body`,children:e.context})]}),(0,A.jsxs)(`div`,{className:`td-section`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`ACCEPTANCE`}),(0,A.jsx)(`ul`,{className:`td-list`,children:e.acceptanceCriteria.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))})]}),(0,A.jsxs)(`div`,{className:`td-section`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`SEAMS`}),(0,A.jsx)(`div`,{className:`td-seams`,children:e.seams.map((e,t)=>(0,A.jsx)(`span`,{className:`seam`,children:e},t))})]}),(0,A.jsxs)(`div`,{className:`td-section`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`COMMITS`}),e.commits.length===0?(0,A.jsx)(`div`,{className:`td-empty`,children:`no commits yet — the burn writes them`}):(0,A.jsx)(`div`,{className:`td-commits`,children:e.commits.map(e=>(0,A.jsx)(`button`,{className:`commit-sha`,onClick:()=>y(e),title:`copy full sha`,children:Bp(e)},e))})]}),e.status===`failed`&&e.error&&(0,A.jsxs)(`div`,{className:`td-section td-error`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`Error`}),(0,A.jsx)(`div`,{className:`td-error-body`,children:e.error})]}),e.status===`cancelled`&&e.error&&(0,A.jsxs)(`div`,{className:`td-section`,children:[(0,A.jsx)(`div`,{className:`td-heading`,children:`Cancelled`}),(0,A.jsx)(`div`,{className:`td-body`,children:e.error})]})]})]},e.id)})})]})}function rC({ticketId:e}){let{chunks:t,live:n,trimmed:r}=iC(e),i=(0,k.useRef)(null),[a,o]=(0,k.useState)(!0),s=(0,k.useMemo)(()=>aC(t),[t]);return(0,k.useEffect)(()=>{if(!a)return;let e=i.current;e&&(e.scrollTop=e.scrollHeight)},[s,n,a]),(0,A.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,A.jsx)(`div`,{className:`agent-trimmed`,children:`… earlier output trimmed …`}),s.length===0&&!n&&(0,A.jsx)(F,{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,A.jsx)(F,{children:`waiting for the agent's first output…`}),s.map((e,t)=>e.kind===`text`?(0,A.jsxs)(`div`,{className:`agent-turn`,children:[(0,A.jsx)(`span`,{className:`agent-glyph is-text`,children:`⏺`}),(0,A.jsx)(`span`,{className:`agent-prose`,children:e.text})]},t):(0,A.jsxs)(`div`,{className:`agent-turn is-tool`,children:[(0,A.jsx)(`span`,{className:`agent-glyph is-tool`,children:`●`}),(0,A.jsxs)(`span`,{className:`agent-toolline`,children:[(0,A.jsx)(`span`,{className:`agent-toolname`,children:e.name}),e.args&&(0,A.jsxs)(`span`,{className:`agent-toolargs`,children:[`(`,e.args,`)`]})]})]},t)),n&&(0,A.jsxs)(`div`,{className:`agent-live-row`,children:[(0,A.jsx)(`span`,{className:`agent-spinner`,children:`✳`}),(0,A.jsx)(`span`,{className:`agent-live-label`,children:`Burning…`}),(0,A.jsx)(`span`,{className:`agent-cursor`,children:`▍`})]}),!a&&(0,A.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>o(!0),children:`Follow ⇣`})]})}function iC(e){let[t,n]=(0,k.useState)([]),[r,i]=(0,k.useState)(!1),[a,o]=(0,k.useState)(!1),s=t.length>0?t[t.length-1].i:void 0,c=N.run.agentTranscript.useQuery({ticketId:e,after:s},{refetchInterval:1e3});return(0,k.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 aC(e){let t=[];for(let n of e){if(n.kind===`tool`){t.push({kind:`tool`,name:n.name??`tool`,args:oC(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 oC(e){let t=e.replace(/\s+/g,` `).trim();return t.length>300?`${t.slice(0,300)}…`:t}function sC({featureId:e,runId:t,readonly:n=!1}){let r=N.feature.get.useQuery({id:e},{refetchInterval:1500}),i=N.run.get.useQuery({runId:t},{refetchInterval:1500,enabled:!!t}),a=Rp(e),o=r.data?.tickets??[],s=(0,k.useMemo)(()=>a.filter(e=>e.runId===t),[a,t]),c=(0,k.useMemo)(()=>dC(s),[s]),[l,u]=(0,k.useState)(null),[d,f]=(0,k.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??[],b=y.some(e=>e.status===`live`||e.status===`launching`),x=b||i.data?.status===`running`;return!t&&!b?(0,A.jsx)(`div`,{className:`surface`,children:(0,A.jsx)(Vi,{icon:(0,A.jsx)(wi,{size:16}),title:`No run yet`,hint:`Burning the tickets starts a run — one agent per ticket, each in its own lane.`})}):(0,A.jsxs)(`div`,{children:[(0,A.jsx)(BS,{featureId:e,sessions:y,className:`tickets-session`}),(0,A.jsxs)(`div`,{className:`body-title`,children:[(0,A.jsx)(`span`,{className:`section-title`,children:`Run`}),i.data&&(0,A.jsx)(Wi,{status:i.data.status}),(0,A.jsxs)(`span`,{className:`body-meta`,children:[g,`/`,_,` done · `,v]})]}),(0,A.jsxs)(`div`,{className:`run-split`,children:[(0,A.jsxs)(`div`,{className:`run-lanes-panel`,children:[(0,A.jsx)(`div`,{className:`panel-cap`,children:`Ticket lanes`}),(0,A.jsxs)(`div`,{className:`run-lanes`,children:[o.length===0&&(0,A.jsx)(F,{children:`no ticket lanes`}),o.map(e=>(0,A.jsx)(cC,{ticket:e,featureBranch:r.data?.feature.branch??``,duration:c.get(e.id),selected:e.id===m,readonly:n,terminalBlocked:x,onSelect:()=>{u(e.id),f(`agent`)}},e.id))]})]}),(0,A.jsxs)(`div`,{className:`run-stream-panel`,children:[(0,A.jsxs)(`div`,{className:`stream-head`,children:[(0,A.jsxs)(`div`,{className:`panel-tabs`,children:[(0,A.jsxs)(`button`,{className:`panel-tab${d===`agent`?` is-active`:``}`,onClick:()=>f(`agent`),children:[`Agent`,h&&(0,A.jsxs)(`span`,{className:`panel-tab-ctx`,children:[`#`,h.seq]})]}),(0,A.jsx)(`button`,{className:`panel-tab${d===`events`?` is-active`:``}`,onClick:()=>f(`events`),children:`Events`})]}),d===`agent`&&h?.status===`burning`&&(0,A.jsx)(`span`,{className:`agent-live-dot`,title:`agent running`})]}),d===`agent`?h?(0,A.jsx)(pm,{label:`agent transcript`,children:(0,A.jsx)(rC,{ticketId:h.id},h.id)}):(0,A.jsx)(`div`,{className:`agent-body`,children:(0,A.jsx)(F,{children:`No agent yet — lanes light up here as tickets start burning.`})}):(0,A.jsx)(lC,{events:s})]})]})]})}function cC({ticket:e,featureBranch:t,duration:n,selected:r,readonly:i,terminalBlocked:a,onSelect:o}){let s=Ji(),c=N.useUtils(),l={onSuccess:()=>c.feature.get.invalidate({id:e.featureId}),onError:e=>s.push(e.message)},u=N.ticket.retry.useMutation(l),d=N.ticket.stop.useMutation(l),f=N.feature.launchSession.useMutation(l),p=e=>{navigator.clipboard?.writeText(e).then(()=>s.push(`copied ${Bp(e)}`,`info`),()=>s.push(`copy failed`))},m=[`burning`,`done`,`failed`].includes(e.status)?` status-${e.status}`:``,h=e.commits.length>0,g=n!==void 0,_=e.status===`failed`?e.error?.split(`
|
|
110
|
-
`)[0]:void 0,v=u.isPending||d.isPending||f.isPending,y=e.status===`failed`?e.conflictFiles:void 0;return(0,A.jsxs)(`div`,{className:`lane is-clickable${m}${r?` is-selected`:``}`,role:`button`,tabIndex:0,title:`show this ticket's agent`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o()},children:[(0,A.jsxs)(`div`,{className:`lane-head`,children:[(0,A.jsxs)(`span`,{className:`lane-seq`,children:[`#`,e.seq]}),(0,A.jsx)(`span`,{className:`lane-title`,children:e.title}),(0,A.jsx)(Ui,{status:e.status})]}),_&&!y&&(0,A.jsx)(`div`,{className:`lane-error`,title:e.error,children:_}),y&&(0,A.jsxs)(`div`,{className:`lane-conflict`,children:[(0,A.jsxs)(`div`,{className:`lane-conflict-head`,children:[`Merge conflict — the work is committed but could not land on`,` `,(0,A.jsx)(`code`,{children:t})]}),y.length>0&&(0,A.jsx)(`ul`,{className:`lane-conflict-files`,children:y.map(e=>(0,A.jsx)(`li`,{title:e,children:e},e))}),e.error&&(0,A.jsx)(`div`,{className:`lane-error`,title:e.error,children:_})]}),!i&&e.status===`failed`&&(0,A.jsxs)(`div`,{className:`lane-actions`,children:[(0,A.jsx)(`button`,{className:`lane-btn`,disabled:v,title:y?`run an agent that merges the feature branch into this ticket’s branch and resolves the conflict — it gets the ticket, the feature docs, and the commits it is reconciling against`:`retry this ticket — continues from any commits preserved by previous attempts`,onClick:t=>{t.stopPropagation(),u.mutate({ticketId:e.id},{onSuccess:t=>{t.resolvingConflict?s.push(`resolving ticket #${e.seq}'s conflict with an agent`,`info`):t.resumedFrom&&s.push(`resuming ticket #${e.seq} from ${t.preservedCommits} preserved commit(s)`,`info`)}})},children:y?`Resolve with agent`:`Retry`}),y&&(0,A.jsx)(`button`,{className:`lane-btn`,disabled:v||a,title:a?`available once this run finishes and no terminal is open`:`open a terminal on the feature branch, briefed with this ticket and its conflicting files, and resolve it yourself`,onClick:n=>{n.stopPropagation(),f.mutate({featureId:e.featureId,kind:`revisit`,kickoffLine:Op({seq:e.seq,title:e.title,branch:e.attemptBranch??``,featureBranch:t,files:y})})},children:`Resolve in terminal`}),(0,A.jsx)(`button`,{className:`lane-btn lane-btn-danger`,disabled:v,title:y?`throw away the conflicting branch and re-implement the ticket from the current feature branch tip`:`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?`)&&u.mutate({ticketId:e.id,fresh:!0})},children:`Retry fresh`})]}),!i&&e.status===`burning`&&(0,A.jsx)(`div`,{className:`lane-actions`,children:(0,A.jsx)(`button`,{className:`lane-btn lane-btn-danger`,disabled:v,title:`stop this ticket's agent — other lanes keep burning; committed work is preserved for retry`,onClick:t=>{t.stopPropagation(),d.mutate({ticketId:e.id},{onSuccess:e=>{e.stopped||s.push(`no live agent for this ticket (already finishing?)`,`info`)}})},children:`Stop ticket`})}),(h||g)&&(0,A.jsxs)(`div`,{className:`lane-foot`,children:[(0,A.jsx)(`span`,{className:`lane-commits`,children:e.commits.map(e=>(0,A.jsx)(`button`,{className:`commit-sha`,onClick:t=>{t.stopPropagation(),p(e)},title:`copy sha`,children:Bp(e)},e))}),g&&(0,A.jsx)(`span`,{className:`lane-dur`,children:Hp(0,n)})]})]})}function lC({events:e}){let t=(0,k.useRef)(null),[n,r]=(0,k.useState)(!0);return(0,k.useEffect)(()=>{if(!n)return;let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e,n]),(0,A.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,A.jsx)(F,{children:`waiting for events…`}),e.map(e=>(0,A.jsxs)(`div`,{className:`stream-line level-${uC(e.type)}`,children:[(0,A.jsx)(`span`,{className:`sl-time`,children:zp(e.ts)}),(0,A.jsx)(`span`,{className:`sl-type`,children:e.type}),(0,A.jsx)(`span`,{className:`sl-msg`,children:e.message})]},e.id)),!n&&(0,A.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>r(!0),children:`Follow ⇣`})]})}function uC(e){return e===`merge.conflict.resolved`?`ok`:e===`merge.conflict.resolving`?`active`:/(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 dC(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 fC({featureId:e,viewedPhase:t,onViewPhase:n,guidance:r,driving:i,onDriveChange:a}){let o=N.useUtils(),s=Ji(),c=N.feature.get.useQuery({id:e},{refetchInterval:1500}),l=gC(e),u=()=>{o.feature.get.invalidate({id:e}),o.feature.list.invalidate()},d=N.feature.launchSession.useMutation({onSuccess:u,onError:e=>s.push(e.message)}),f=N.feature.advance.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),p=N.feature.burn.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),m=N.run.cancel.useMutation({onSuccess:()=>{u(),s.push(`cancel requested`,`info`)},onError:e=>s.push(e.message)}),h=N.feature.testDrive.useMutation({onError:e=>s.push(e.message)}),g=N.feature.merge.useMutation({onError:e=>s.push(e.message)}),_=N.feature.unarchive.useMutation({onSuccess:()=>{u(),s.push(`feature unarchived`,`success`)},onError:e=>s.push(e.message)});if(c.isLoading)return(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(`div`,{className:`ws-body`,children:(0,A.jsx)(F,{children:`loading feature…`})})});if(!c.data)return(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(`div`,{className:`ws-body`,children:(0,A.jsxs)(F,{children:[`could not load feature`,c.error?`: ${c.error.message}`:``]})})});let v=!!c.error,y=c.data,b=y.feature,x=Cp(b,t),S=wp(b,x),ee=Tp(b,x),C=hp(y.runs),w=jp(y,{driving:i?.featureId===b.id}),te=d.isPending||f.isPending||p.isPending||m.isPending||h.isPending||g.isPending||_.isPending;return(0,A.jsxs)(`section`,{className:`workspace`,children:[(0,A.jsxs)(`div`,{className:`ws-head`,children:[(0,A.jsxs)(`div`,{className:`ws-title-row`,children:[(0,A.jsx)(Hi,{phase:b.phase}),(0,A.jsx)(`span`,{className:`ws-title`,children:b.title}),(0,A.jsx)(`span`,{className:`ws-title-spacer`}),(0,A.jsxs)(`button`,{className:`ws-branch`,title:`Copy branch name`,onClick:()=>_C(b.branch,s),children:[(0,A.jsx)(gi,{size:11}),b.branch]})]}),(0,A.jsx)(mC,{steps:ee,onView:e=>n(e===b.phase?null:e)})]}),S?(0,A.jsxs)(`div`,{className:`readonly-bar`,children:[(0,A.jsx)(`span`,{className:`readonly-tag`,children:`READ-ONLY`}),(0,A.jsxs)(`span`,{children:[`You're viewing the `,gp[x],` phase.`]}),(0,A.jsxs)(`button`,{className:`readonly-back`,onClick:()=>n(null),children:[`Back to `,gp[b.phase],` →`]})]}):(0,A.jsx)(hC,{ns:w,guidance:r,busy:te,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`,kickoffLine:b.phase===`review`?Ep:void 0});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`:C&&m.mutate({runId:C.id});break;case`unarchive`:_.mutate({featureId:e});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=>{if(u(),e.ok)a(null),s.push(`merged — feature shipped`,`success`);else if(e.conflict){let t=e.files.length;s.push(t>0?`merge conflict in ${t} file${t===1?``:`s`} — resolve below and retry`:`merge conflict — resolve below and retry`)}}});break}}}),v&&(0,A.jsxs)(`div`,{className:`ws-banner is-offline`,role:`status`,children:[(0,A.jsx)(`span`,{className:`ws-banner-tag`,children:`OFFLINE`}),(0,A.jsx)(`span`,{children:`server unreachable — retrying…`})]}),l.message&&(0,A.jsxs)(`div`,{className:`ws-banner`,role:`alert`,onClick:l.dismiss,title:`dismiss`,children:[(0,A.jsx)(`span`,{className:`ws-banner-tag`,children:`RESUME FAILED`}),(0,A.jsx)(`span`,{children:l.message})]}),(0,A.jsx)(`div`,{className:`ws-body`,children:(0,A.jsx)(`div`,{className:`ws-body-inner`,children:(0,A.jsx)(pC,{effective:x,full:y,driving:i,runId:C?.id??null,readonly:S})},x)})]})}function pC({effective:e,full:t,driving:n,runId:r,readonly:i}){switch(e){case`ideation`:case`spec`:return(0,A.jsx)(WS,{full:t,effective:e});case`tickets`:return(0,A.jsx)(nC,{featureId:t.feature.id,readonly:i});case`implementation`:return(0,A.jsx)(sC,{featureId:t.feature.id,runId:r,readonly:i});case`review`:return(0,A.jsx)(QS,{full:t,driving:n});case`shipped`:return(0,A.jsx)(tC,{full:t})}}function mC({steps:e,onView:t}){return(0,A.jsx)(`div`,{className:`pipeline`,children:e.map((n,r)=>(0,A.jsxs)(k.Fragment,{children:[(0,A.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,A.jsx)(`span`,{className:`pstep-dot`}),(0,A.jsx)(`span`,{className:`pstep-label`,children:n.label})]}),r<e.length-1&&(0,A.jsx)(`span`,{className:`pconn${n.state===`done`?` is-done`:``}`})]},n.phase))})}function hC({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,A.jsxs)(`div`,{className:`nextstep`,children:[e.busy&&(0,A.jsx)(`span`,{className:`spin-ring nextstep-spin`}),(0,A.jsxs)(`div`,{className:`nextstep-main`,children:[(0,A.jsx)(`div`,{className:`nextstep-kick ${i}`,children:e.kick}),(0,A.jsx)(`div`,{className:`nextstep-title`,children:e.title}),t&&(0,A.jsx)(`div`,{className:`nextstep-desc`,children:e.desc})]}),(0,A.jsxs)(`div`,{className:`nextstep-actions`,children:[e.secondary.map((e,t)=>(0,A.jsx)(P,{variant:`ghost`,className:`btn-xs`,disabled:n,onClick:()=>r(e.kind),children:e.label},t)),e.primary&&(0,A.jsx)(P,{variant:e.primary.danger?`danger`:`solid`,disabled:n,onClick:()=>r(e.primary.kind),children:n?`Working…`:e.primary.label})]})]})}function gC(e){let t=Rp(e),[n,r]=(0,k.useState)(null),i=(0,k.useRef)(null);return(0,k.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,k.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(null),8e3);return()=>clearTimeout(e)},[n]),{message:n,dismiss:()=>r(null)}}function _C(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function vC({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(``),[s,c]=(0,k.useState)(``),l=N.useUtils(),u=Ji(),d=N.project.branches.useQuery({projectId:e}),f=d.data?.mainBranch??``,p=d.data?.current,m=d.data?.branches??[],h=d.data?.remoteBranches??[],g=m.length===0&&h.length===0,_=d.data?fp(d.data):f,v=s||_,y=N.feature.launchSession.useMutation(),b=N.feature.create.useMutation({onSuccess:async e=>{await l.feature.list.invalidate(),y.mutate({featureId:e.id,kind:`ideation`},{onSettled:()=>void l.feature.get.invalidate({id:e.id})}),n(e.id)},onError:e=>u.push(e.message)}),x=yC(r),S=b.isPending||y.isPending,ee=()=>{let t=r.trim();t&&!d.isPending&&b.mutate({projectId:e,title:t,oneLiner:a.trim(),baseBranch:v||void 0})};return(0,A.jsx)(`div`,{className:`nf-overlay`,children:(0,A.jsxs)(`div`,{className:`nf-card`,children:[(0,A.jsx)(`div`,{className:`nf-kick`,children:`NEW FEATURE`}),(0,A.jsx)(`div`,{className:`nf-h`,children:`What are we building?`}),(0,A.jsx)(`div`,{className:`nf-sub`,children:`Name it — runcastle opens a grill session so you and Claude shape the idea before any code is written.`}),(0,A.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`&&ee(),e.key===`Escape`&&t()}}),(0,A.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`&&ee(),e.key===`Escape`&&t()}}),(0,A.jsxs)(`details`,{className:`nf-advanced`,children:[(0,A.jsx)(`summary`,{className:`nf-advanced-summary`,children:`Advanced`}),(0,A.jsxs)(`div`,{className:`nf-base`,children:[(0,A.jsx)(`label`,{className:`nf-base-label`,htmlFor:`nf-base-select`,children:`Branch from`}),(0,A.jsxs)(`select`,{id:`nf-base-select`,className:`nf-base-select`,value:v,disabled:d.isPending||g,onChange:e=>c(e.target.value),children:[m.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,e===f?` (default)`:``,e===p&&e!==f?` (current)`:``]},e)),h.length>0&&(0,A.jsx)(`optgroup`,{label:`Remote (creates a local branch)`,children:h.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]}),(0,A.jsx)(`span`,{className:`size-hint`,children:`forks off this branch — and merges back into it when shipped.`})]}),(0,A.jsxs)(`div`,{className:`nf-branch`,children:[`branch · feature/`,x||`…`,` ← `,v||`…`]})]}),(0,A.jsxs)(`div`,{className:`nf-actions`,children:[(0,A.jsx)(P,{variant:`ghost`,onClick:t,disabled:S,children:`Cancel`}),(0,A.jsx)(P,{variant:`solid`,onClick:ee,disabled:!r.trim()||S||d.isPending,children:S?`Starting…`:`Start grill session`})]})]})})}function yC(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function bC(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onNewFeature:o,onOpenSettings:s,nav:c}=e,[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(0),p=(0,k.useRef)(null),m=(0,k.useRef)([]);(0,k.useEffect)(()=>{t&&(u(``),f(0),p.current?.focus())},[t]),(0,k.useEffect)(()=>{f(0)},[l]);let h=l.trim().toLowerCase(),g=(0,k.useMemo)(()=>h===``?r:r.filter(e=>e.slug.toLowerCase().includes(h)||e.title.toLowerCase().includes(h)),[r,h]),_=(0,k.useMemo)(()=>(c.projects??[]).filter(e=>e.id!==c.currentProjectId),[c.projects,c.currentProjectId]),v=(0,k.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),S=`settings preferences`.includes(h),ee=(0,k.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`}),S&&e.push({kind:`settings`}),e},[g,v,y,b,x,S]);if(!t)return null;let C=e=>{if(ee.length===0)return;let t=(d+e+ee.length)%ee.length;f(t),m.current[t]?.scrollIntoView({block:`nearest`})},w=e=>{let t=ee[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()}},te=e=>{e.key===`ArrowDown`?(e.preventDefault(),C(1)):e.key===`ArrowUp`?(e.preventDefault(),C(-1)):e.key===`Enter`?(e.preventDefault(),w(d)):e.key===`Escape`&&(e.preventDefault(),n())},ne=g.length,re=ne+v.length,ie=e=>t=>{m.current[e]=t};return(0,A.jsx)(`div`,{className:`cmdk-backdrop`,onClick:n,children:(0,A.jsxs)(`div`,{className:`cmdk`,onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`input`,{ref:p,className:`cmdk-input`,placeholder:`Search features, projects, or jump to…`,value:l,onChange:e=>u(e.target.value),onKeyDown:te,"aria-label":`Search features, projects, or jump to`}),(0,A.jsxs)(`div`,{className:`cmdk-list`,children:[g.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`cmdk-group-label`,children:`Features`}),g.map((e,t)=>(0,A.jsxs)(`div`,{ref:ie(t),className:`cmdk-item${t===d?` is-active`:``}`,onMouseEnter:()=>f(t),onClick:()=>w(t),children:[(0,A.jsx)(`span`,{className:`cmdk-item-glyph`,children:(0,A.jsx)(`span`,{className:`feature-dot phase-bg-${e.phase}`})}),(0,A.jsx)(`span`,{className:`cmdk-item-label`,children:e.title}),(0,A.jsx)(`span`,{className:`cmdk-item-slug`,children:e.slug}),(0,A.jsx)(`span`,{className:`cmdk-item-hint`,children:e.id===i?`current`:e.phase})]},e.id))]}),v.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`cmdk-group-label`,children:`Switch project`}),v.map((e,t)=>{let n=ne+t;return(0,A.jsxs)(`div`,{ref:ie(n),className:`cmdk-item${n===d?` is-active`:``}`,onMouseEnter:()=>f(n),onClick:()=>w(n),children:[(0,A.jsx)(`span`,{className:`cmdk-item-glyph`,children:(0,A.jsx)(Ei,{size:13})}),(0,A.jsx)(`span`,{className:`cmdk-item-label`,children:e.name}),(0,A.jsx)(`span`,{className:`cmdk-item-slug`,children:e.mainBranch}),(0,A.jsx)(`span`,{className:`cmdk-item-hint`,children:`project`})]},e.id)})]}),(y||b||x||S)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`cmdk-group-label`,children:`Actions`}),y&&(0,A.jsx)(xC,{index:re,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(yi,{size:13}),label:`Create new feature`}),b&&(0,A.jsx)(xC,{index:re+ +!!y,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(Ei,{size:13}),label:`All projects (home)`}),x&&(0,A.jsx)(xC,{index:re+ +!!y+ +!!b,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(Ei,{size:13}),label:`Open a project…`}),S&&(0,A.jsx)(xC,{index:re+ +!!y+ +!!b+ +!!x,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(mi,{size:13}),label:`Settings`})]}),ee.length===0&&(0,A.jsx)(`div`,{className:`cmdk-empty`,children:`No matches`})]}),(0,A.jsxs)(`div`,{className:`cmdk-foot`,children:[(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`kbd`,children:`↑↓`}),` navigate`]}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`kbd`,children:`↵`}),` select`]}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`kbd`,children:`esc`}),` close`]})]})]})})}function xC({index:e,activeIndex:t,bindRow:n,setActiveIndex:r,activate:i,glyph:a,label:o}){return(0,A.jsxs)(`div`,{ref:n(e),className:`cmdk-item${e===t?` is-active`:``}`,onMouseEnter:()=>r(e),onClick:()=>i(e),children:[(0,A.jsx)(`span`,{className:`cmdk-item-glyph`,children:a}),(0,A.jsx)(`span`,{className:`cmdk-item-label`,children:o}),(0,A.jsx)(`span`,{className:`cmdk-item-hint`,children:`action`})]})}var SC={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,burnAttempts:`RUNCASTLE_BURN_ATTEMPTS`,burnConflictAttempts:`RUNCASTLE_BURN_CONFLICT_ATTEMPTS`,mainBranch:`RUNCASTLE_MAIN_BRANCH`},CC=dp.map(e=>e.id),wC=`stepModels.`;function TC(e){return e.startsWith(wC)}function EC(e){return e.slice(11)}var DC={ideation:`Ideation`,qa:`Q&A`,waypoint:`Waypoint`,converge:`Converge`,research:`Research`,implement:`Implement`,smoke:`Smoke`},OC=lp.map(e=>`${wC}${e}`),kC=new Set([`mainBranch`]),AC={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:CC},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`},burnConflictAttempts:{label:`Conflict resolver passes`,help:`Max agent passes spent resolving a ticket’s landing conflict before asking you (0–3). 0 sends every conflict straight to you.`,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 jC(e){return e==null?``:String(e)}function MC(e){if(TC(e)){let t=EC(e);return{label:DC[t]??t,help:`Model for the ${DC[t]??t} step.`,control:`select`,options:CC}}return AC[e]??{label:e,help:``,control:`text`}}function NC(e){let t=MC(e.key),n=kC.has(e.key),r=!e.editable||n,i=e.source===`project`,a=null;return e.source===`env`?a=`Set by ${SC[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:jC(e.value),control:t.control,options:t.options??[],readOnly:r,restartRequired:e.restartRequired,overridden:i,source:e.source,note:a,allowCustom:e.key===`model`||TC(e.key)}}function PC(e){return e.fields.filter(e=>!TC(e.key)).map(NC)}function FC(e){return e.fields.filter(e=>e.scope===`project`).map(NC)}function IC(e){return e.fields.filter(e=>TC(e.key)&&e.source===`file`).map(NC).sort((e,t)=>OC.indexOf(e.key)-OC.indexOf(t.key))}function LC(e){let t=new Set(e.fields.filter(e=>TC(e.key)&&e.source===`file`).map(e=>e.key));return OC.filter(e=>!t.has(e)).map(e=>({key:e,label:DC[EC(e)]??EC(e)}))}function RC({onDismiss:e}){let t=N.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,A.jsxs)(`div`,{className:`afk-card`,children:[(0,A.jsxs)(`div`,{className:`afk-card-head`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`op-kick`,children:`ENABLE AFK BURNS`}),(0,A.jsx)(`div`,{className:`afk-card-title`,children:`Run features unattended`})]}),e&&(0,A.jsx)(P,{variant:`ghost`,onClick:e,children:`Set up later`})]}),(0,A.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,A.jsx)(F,{children:`checking prerequisites…`}),t.error&&(0,A.jsxs)(F,{children:[`could not run checks: `,t.error.message]}),n&&(0,A.jsxs)(`div`,{className:`afk-rows`,children:[(0,A.jsx)(BC,{probe:i,onRecheck:s}),(0,A.jsx)(VC,{probe:a,runtimeOk:i?.status===`ok`,onDone:s}),(0,A.jsx)(HC,{probe:o,onDone:s})]})]})}function zC({probe:e,children:t}){if(!e)return null;let n=e.status===`ok`;return(0,A.jsxs)(`div`,{className:`afk-row${n?` is-ok`:``}`,children:[(0,A.jsxs)(`div`,{className:`afk-row-head`,children:[(0,A.jsx)(`span`,{className:`afk-dot afk-dot-${n?`ok`:`warn`}`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`afk-row-text`,children:[(0,A.jsx)(`div`,{className:`afk-row-label`,children:e.label}),(0,A.jsx)(`div`,{className:`afk-row-detail mono`,children:e.detail})]})]}),!n&&(0,A.jsx)(`div`,{className:`afk-row-action`,children:t})]})}function BC({probe:e,onRecheck:t}){let n=N.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),r=Ji();if(!e)return null;let i=e.status===`missing`?n.data:void 0,a=i?.command??e.fix??``;return(0,A.jsxs)(zC,{probe:e,children:[a&&(0,A.jsxs)(`div`,{className:`afk-cmd`,children:[(0,A.jsx)(`code`,{className:`afk-cmd-text mono`,children:a}),(0,A.jsx)(P,{variant:`ghost`,onClick:()=>{navigator.clipboard?.writeText(a),r.push(`copied`,`info`)},children:`Copy`})]}),i?.note&&(0,A.jsx)(`div`,{className:`afk-note`,children:i.note}),(0,A.jsx)(P,{variant:`solid`,onClick:t,children:`Re-check`})]})}function VC({probe:e,runtimeOk:t,onDone:n}){let[r,i]=(0,k.useState)(null),a=Ji(),o=N.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)});return e?(0,A.jsx)(zC,{probe:e,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`afk-term`,children:(0,A.jsx)(pm,{label:`build-image`,children:(0,A.jsx)(zS,{sessionId:r})})}),(0,A.jsx)(`div`,{className:`afk-term-actions`,children:(0,A.jsx)(P,{variant:`solid`,onClick:()=>{i(null),n()},children:`Done — re-check`})})]}):(0,A.jsx)(P,{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 HC({probe:e,onDone:t}){let[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(null),c=Ji(),l=N.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>r(e),onError:e=>c.push(e.message)}),u=N.setup.afkToken.useMutation({onSuccess:e=>{s(e),e.valid&&t()},onError:e=>c.push(e.message)});return e?(0,A.jsxs)(zC,{probe:e,children:[n?(0,A.jsx)(`div`,{className:`afk-term`,children:(0,A.jsx)(pm,{label:`setup-token`,children:(0,A.jsx)(zS,{sessionId:n})})}):(0,A.jsx)(P,{variant:`ghost`,onClick:()=>l.mutate({kind:`setup-token`}),disabled:l.isPending,children:l.isPending?`Starting…`:`Run claude setup-token`}),(0,A.jsx)(`label`,{className:`op-label`,htmlFor:`afk-token-input`,children:`Paste the token it prints`}),(0,A.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,A.jsx)(`div`,{className:`afk-term-actions`,children:(0,A.jsx)(P,{variant:`solid`,disabled:i.trim()===``||u.isPending,onClick:()=>u.mutate({token:i}),children:u.isPending?`Verifying…`:`Save & verify`})}),o&&(0,A.jsxs)(`div`,{className:`afk-verdict ${o.valid?`is-ok`:`is-warn`}`,children:[o.valid?`✓ `:`⚠ `,o.detail]})]}):null}function UC({projectId:e,onClose:t}){let n=N.settings.get.useQuery(),r=N.settings.get.useQuery({projectId:e});return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:t,children:(0,A.jsxs)(`div`,{className:`peek settings`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`settings-title`,children:`Settings`}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:t,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`peek-body settings-body`,children:[(0,A.jsx)(WC,{title:`Global`,hint:`Machine-wide defaults for every project.`,query:n,rowsOf:PC}),(0,A.jsx)(JC,{query:n}),(0,A.jsx)(WC,{title:`This project`,hint:`Overrides that apply only to the current project.`,query:r,rowsOf:FC,projectId:e}),(0,A.jsxs)(`section`,{className:`settings-section`,children:[(0,A.jsxs)(`div`,{className:`settings-section-head`,children:[(0,A.jsx)(`h3`,{className:`settings-section-title`,children:`AFK burns`}),(0,A.jsx)(`span`,{className:`settings-section-hint`,children:`Prerequisites for unattended sandbox runs.`})]}),(0,A.jsx)(RC,{})]})]})]})})}function WC({title:e,hint:t,query:n,rowsOf:r,projectId:i}){let a=n.data?r(n.data):[];return(0,A.jsxs)(`section`,{className:`settings-section`,children:[(0,A.jsxs)(`div`,{className:`settings-section-head`,children:[(0,A.jsx)(`h3`,{className:`settings-section-title`,children:e}),(0,A.jsx)(`span`,{className:`settings-section-hint`,children:t})]}),n.isLoading&&(0,A.jsx)(F,{children:`loading…`}),n.error&&(0,A.jsxs)(F,{children:[`could not load settings: `,n.error.message]}),n.data&&a.length===0&&(0,A.jsx)(F,{children:`no settings in this scope`}),a.map(e=>(0,A.jsx)(GC,{row:e,projectId:i},e.key))]})}function GC({row:e,projectId:t}){let n=N.useUtils(),r=Ji(),[i,a]=(0,k.useState)(e.value);(0,k.useEffect)(()=>a(e.value),[e.value]);let o=N.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,A.jsxs)(`div`,{className:`settings-field${e.readOnly?` is-locked`:``}`,children:[(0,A.jsxs)(`label`,{className:`settings-field-head`,htmlFor:l,children:[(0,A.jsx)(`span`,{className:`settings-field-label`,children:e.label}),e.restartRequired&&(0,A.jsx)(`span`,{className:`settings-badge is-warn`,title:`Takes effect after a server restart`,children:`restart required`}),e.overridden&&(0,A.jsx)(`span`,{className:`settings-badge is-override`,children:`overridden`}),o.isPending&&(0,A.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),e.help&&(0,A.jsx)(`div`,{className:`settings-field-help`,children:e.help}),e.readOnly?(0,A.jsx)(`div`,{className:`settings-readonly mono`,id:l,children:e.value||`—`}):e.control===`select`&&e.allowCustom?(0,A.jsx)(qC,{id:l,value:e.value,options:e.options,disabled:o.isPending,onCommit:s}):e.control===`select`?(0,A.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,A.jsx)(`option`,{value:e,children:e},e))}):(0,A.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,A.jsx)(`div`,{className:`settings-field-note`,children:e.note}),e.overridden&&t&&(0,A.jsx)(`button`,{className:`settings-clear`,onClick:c,disabled:o.isPending,children:`Clear override`})]})}var KC=`__custom__`;function qC({id:e,value:t,options:n,disabled:r,onCommit:i}){let[a,o]=(0,k.useState)(!n.includes(t)&&t!==``),[s,c]=(0,k.useState)(t);return(0,k.useEffect)(()=>{c(t),o(!n.includes(t)&&t!==``)},[t,n]),(0,A.jsxs)(`div`,{className:`settings-combo`,children:[(0,A.jsxs)(`select`,{id:e,className:`settings-input`,value:a?KC:t,disabled:r,onChange:e=>{if(e.target.value===KC){o(!0);return}o(!1),i(e.target.value)},children:[n.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e)),(0,A.jsx)(`option`,{value:KC,children:`Custom…`})]}),a&&(0,A.jsx)(`input`,{className:`settings-input mono`,type:`text`,placeholder:`model id (e.g. claude-opus-5, claude-opus-5[1m])`,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 JC({query:e}){let t=N.useUtils(),n=Ji(),[r,i]=(0,k.useState)(!1),a=N.settings.update.useMutation({onSuccess:()=>{t.settings.get.invalidate()},onError:e=>n.push(e.message)}),o=e.data,s=o?IC(o):[],c=o?LC(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,A.jsxs)(`section`,{className:`settings-section`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`settings-advanced-toggle`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,A.jsx)(`span`,{className:`settings-section-title`,children:`Advanced — per-step models`}),(0,A.jsxs)(`span`,{className:`settings-section-hint`,children:[s.length>0?`${s.length} override${s.length===1?``:`s`}`:`none set`,r?` ▾`:` ▸`]})]}),r&&(0,A.jsxs)(`div`,{className:`settings-advanced-body`,children:[s.length===0&&(0,A.jsx)(F,{children:`every step uses the default model.`}),s.map(e=>(0,A.jsxs)(`div`,{className:`settings-field`,children:[(0,A.jsxs)(`div`,{className:`settings-field-head`,children:[(0,A.jsx)(`span`,{className:`settings-field-label`,children:e.label}),a.isPending&&(0,A.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),(0,A.jsx)(qC,{id:`step-${e.key}`,value:e.value,options:e.options,disabled:a.isPending,onCommit:t=>u(e.key,t)}),(0,A.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,A.jsxs)(`div`,{className:`settings-field`,children:[(0,A.jsx)(`label`,{className:`settings-field-label`,htmlFor:`step-add`,children:`Add an override`}),(0,A.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,A.jsx)(`option`,{value:``,children:`Choose a step…`}),c.map(e=>(0,A.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]})]})]})}function YC({projectId:e,nav:t}){let n=Li(e),{selectedFeatureId:r,select:i,setCmdk:a}=n,[o,s]=(0,k.useState)(null),c=N.feature.list.useQuery({projectId:e},{refetchInterval:1500});(0,k.useEffect)(()=>{!r&&c.data&&c.data.length>0&&i(c.data[0].id)},[r,c.data,i]),(0,k.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,A.jsxs)(`div`,{className:`shell${n.inspectorCollapsed?` inspector-collapsed`:``}`,children:[(0,A.jsx)(zi,{nav:t,onOpenCmdk:()=>n.setCmdk(!0),onOpenSettings:()=>n.setSettings(!0),onToggleInspector:n.toggleInspector,inspectorCollapsed:n.inspectorCollapsed}),(0,A.jsxs)(`div`,{className:`shell-body`,children:[(0,A.jsx)(Ip,{projectId:e,selectedFeatureId:n.selectedFeatureId,onSelect:n.select,onNewFeature:n.startCreate}),n.creating?(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(vC,{projectId:e,onCancel:n.cancelCreate,onCreated:n.select})}):n.selectedFeatureId?(0,A.jsx)(fC,{featureId:n.selectedFeatureId,viewedPhase:n.viewedPhase,onViewPhase:n.viewPhase,guidance:n.guidance,driving:o,onDriveChange:s},`ws-${n.selectedFeatureId}`):(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(XC,{onNewFeature:n.startCreate})}),l&&n.selectedFeatureId&&(0,A.jsx)(Wp,{featureId:n.selectedFeatureId},`insp-${n.selectedFeatureId}`)]}),(0,A.jsx)(dm,{projectId:e,activeFeatureId:n.selectedFeatureId,driving:o,onDriveChange:s}),(0,A.jsx)(bC,{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,A.jsx)(UC,{projectId:e,onClose:()=>n.setSettings(!1)})]})}function XC({onNewFeature:e}){return(0,A.jsxs)(`div`,{className:`ws-empty`,children:[(0,A.jsx)(`div`,{className:`ws-empty-logo`,children:(0,A.jsx)(ki,{size:44,variant:`outline`})}),(0,A.jsx)(`div`,{className:`ws-empty-title`,children:`Select a feature to begin`}),(0,A.jsx)(`div`,{className:`ws-empty-sub`,children:`Or create one — every feature moves through the same guided pipeline.`}),(0,A.jsx)(`button`,{className:`btn btn-ghost`,onClick:e,children:`New feature`})]})}function ZC({nav:e}){let t=e.projects??[],n=N.useQueries(e=>t.map(t=>e.feature.list({projectId:t.id},{refetchInterval:1500})));return(0,A.jsxs)(`div`,{className:`home-frame`,children:[(0,A.jsxs)(`header`,{className:`home-topbar`,children:[(0,A.jsxs)(`span`,{className:`tb-home`,children:[(0,A.jsx)(`span`,{className:`tb-logo`,children:(0,A.jsx)(ki,{size:17})}),(0,A.jsx)(Ai,{})]}),(0,A.jsx)(`span`,{className:`tb-spacer`}),(0,A.jsxs)(`button`,{className:`btn btn-ghost btn-xs`,onClick:e.showOpen,children:[(0,A.jsx)(yi,{size:11}),`Open a project`]})]}),(0,A.jsxs)(`div`,{className:`home`,children:[(0,A.jsxs)(`header`,{className:`home-head`,children:[(0,A.jsxs)(`div`,{className:`home-title`,children:[(0,A.jsx)(`span`,{className:`home-title-text`,children:`Projects`}),(0,A.jsx)(`span`,{className:`home-count`,children:t.length})]}),(0,A.jsx)(`p`,{className:`home-sub`,children:`Every open project and where it stands — runs keep going in the background while you switch.`})]}),(0,A.jsxs)(`div`,{className:`home-grid`,children:[t.map((t,r)=>{let i=n[r]?.data;return(0,A.jsx)($C,{project:t,stats:li(i??[]),loading:i===void 0,onOpen:()=>e.enterProject(t.id)},t.id)}),(0,A.jsxs)(`button`,{className:`open-card`,onClick:e.showOpen,children:[(0,A.jsx)(`span`,{className:`open-card-plus`,children:(0,A.jsx)(yi,{size:16})}),(0,A.jsx)(`span`,{className:`open-card-label`,children:`Open a project`}),(0,A.jsx)(`span`,{className:`open-card-sub`,children:`Point runcastle at a local git repo`})]})]})]})]})}var QC={attention:`Needs you`,working:`Agent working`,steady:`Steady`,empty:`No features yet`};function $C({project:e,stats:t,loading:n,onOpen:r}){let i=Ji(),a=N.useUtils(),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(e.name),u=N.project.rename.useMutation({onSuccess:async()=>{await a.project.list.invalidate(),s(!1)},onError:e=>i.push(e.message)}),d=N.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,A.jsxs)(`div`,{className:`project-card health-${t.health}`,children:[(0,A.jsxs)(`button`,{className:`pc-main`,onClick:r,title:`Open ${e.name}`,children:[(0,A.jsxs)(`div`,{className:`pc-head`,children:[o?(0,A.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,A.jsx)(`span`,{className:`pc-name`,children:e.name}),(0,A.jsx)(`span`,{className:`pc-health-dot health-dot-${t.health}`,title:QC[t.health]})]}),(0,A.jsx)(`span`,{className:`pc-path mono`,children:e.repoPath}),(0,A.jsxs)(`span`,{className:`pc-branch`,children:[(0,A.jsx)(gi,{size:11}),e.mainBranch]}),(0,A.jsxs)(`div`,{className:`pc-stats`,children:[(0,A.jsx)(ew,{n:t.total,label:t.total===1?`feature`:`features`}),(0,A.jsx)(ew,{n:t.activeRuns,label:`running`,tone:f?`run`:void 0,spin:f}),(0,A.jsx)(ew,{n:t.needsYou,label:`needs you`,tone:t.needsYou>0?`needs`:void 0})]}),(0,A.jsx)(`span`,{className:`pc-health-label`,children:n?`loading…`:QC[t.health]})]}),(0,A.jsxs)(`div`,{className:`pc-actions`,children:[(0,A.jsx)(`button`,{className:`pc-action`,onClick:()=>{l(e.name),s(!0)},children:`Rename`}),(0,A.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 ew({n:e,label:t,tone:n,spin:r}){return(0,A.jsxs)(`span`,{className:`pc-stat${n?` pc-stat-${n}`:``}`,children:[r&&(0,A.jsx)(`span`,{className:`spin-ring`}),(0,A.jsx)(`span`,{className:`pc-stat-n`,children:e}),(0,A.jsx)(`span`,{className:`pc-stat-label`,children:t})]})}function tw({onPick:e,onCancel:t}){let[n,r]=(0,k.useState)(void 0),[i,a]=(0,k.useState)(!1),o=N.project.roots.useQuery(),s=N.project.browse.useQuery({dir:n,showHidden:i},{placeholderData:e=>e,retry:!1});(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let c=s.data,l=c?.dir??n;return(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:t,children:(0,A.jsxs)(`div`,{className:`peek dir-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":`Choose a repository`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`dir-picker-title`,children:`Choose a repository`}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:t,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`dir-picker-bar`,children:[(0,A.jsx)(P,{variant:`ghost`,className:`dir-up`,onClick:()=>c?.parent&&r(c.parent),disabled:!c?.parent,"aria-label":`Up one level`,title:`Up one level`,children:`↑`}),(0,A.jsx)(`div`,{className:`dir-crumbs mono`,"aria-label":`Current path`,children:(c?.crumbs??[]).map((e,t)=>(0,A.jsxs)(`span`,{className:`dir-crumb-wrap`,children:[t>0&&(0,A.jsx)(Si,{size:11}),(0,A.jsx)(`button`,{className:`dir-crumb`,onClick:()=>r(e.path),children:e.name})]},e.path))}),(0,A.jsxs)(`label`,{className:`dir-hidden-toggle`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),(0,A.jsx)(`span`,{children:`Hidden`})]})]}),(0,A.jsxs)(`div`,{className:`dir-picker-body`,children:[(0,A.jsx)(`div`,{className:`dir-rail`,children:(o.data??[]).map(e=>(0,A.jsxs)(`button`,{className:`dir-rail-item${l===e.path?` is-active`:``}`,onClick:()=>r(e.path),title:e.path,children:[(0,A.jsx)(Ei,{size:13}),(0,A.jsx)(`span`,{className:`dir-rail-label mono`,children:e.label})]},e.path))}),(0,A.jsxs)(`div`,{className:`dir-list`,children:[s.isError?(0,A.jsx)(F,{children:s.error.message}):s.isLoading?(0,A.jsx)(F,{children:`Loading…`}):(c?.entries.length??0)===0?(0,A.jsxs)(F,{children:[`No subfolders here`,i?``:` (hidden folders are filtered)`,`.`]}):(c?.entries??[]).map(t=>(0,A.jsxs)(`button`,{className:`dir-item${t.isRepo?` is-repo`:``}`,onClick:()=>r(t.path),onDoubleClick:()=>t.isRepo&&e(t.path),title:t.path,children:[(0,A.jsx)(Ei,{size:13}),(0,A.jsx)(`span`,{className:`dir-item-name mono`,children:t.name}),t.isSymlink&&(0,A.jsx)(`span`,{className:`dir-item-tag`,children:`link`}),t.isRepo&&(0,A.jsxs)(`span`,{className:`dir-item-repo`,children:[(0,A.jsx)(gi,{size:11}),` git`]})]},t.path)),c?.truncated&&(0,A.jsx)(F,{children:`Listing truncated — this folder is very large.`})]})]}),(0,A.jsxs)(`div`,{className:`dir-picker-foot`,children:[(0,A.jsx)(`div`,{className:`dir-picked mono`,title:l,children:(0,A.jsx)(`bdi`,{children:l??`—`})}),(0,A.jsxs)(`div`,{className:`dir-picker-actions`,children:[(0,A.jsx)(P,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,A.jsx)(P,{variant:`solid`,onClick:()=>l&&e(l),disabled:!l,children:`Open this folder`})]})]})]})})}function nw({firstRun:e,onOpened:t,onCancel:n}){let[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(!1),s=Ji(),c=N.useUtils(),l=N.project.open.useMutation({onSuccess:async e=>{await c.project.list.invalidate(),s.push(`opened ${e.name} on ${e.mainBranch}`,`info`),t(e.id)},onError:e=>s.push(e.message)}),u=e=>{let t=(e??r).trim();t&&l.mutate({repoPath:t})};return(0,A.jsxs)(`div`,{className:`open-project`,children:[(0,A.jsxs)(`div`,{className:`op-card`,children:[(0,A.jsx)(`div`,{className:`op-logo`,children:(0,A.jsx)(ki,{size:22,variant:`ink`})}),(0,A.jsx)(`div`,{className:`op-kick`,children:e?`WELCOME TO RUNCASTLE`:`OPEN A PROJECT`}),(0,A.jsx)(`div`,{className:`op-h`,children:e?`Open your first project`:`Open a project`}),(0,A.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,A.jsx)(`label`,{className:`op-label`,htmlFor:`op-repo-path`,children:`Repository path`}),(0,A.jsxs)(`div`,{className:`op-input-row`,children:[(0,A.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`&&u(),t.key===`Escape`&&!e&&n()}}),(0,A.jsx)(P,{variant:`ghost`,onClick:()=>o(!0),disabled:l.isPending,children:`Browse…`})]}),(0,A.jsx)(`div`,{className:`op-hint`,children:`Browse your machine, or paste a path. The default branch is detected automatically when the project opens.`}),(0,A.jsxs)(`div`,{className:`op-actions`,children:[!e&&(0,A.jsx)(P,{variant:`ghost`,onClick:n,disabled:l.isPending,children:`Cancel`}),(0,A.jsx)(P,{variant:`solid`,onClick:()=>u(),disabled:l.isPending||r.trim()===``,children:l.isPending?`Opening…`:`Open`})]})]}),a&&(0,A.jsx)(tw,{onPick:e=>{i(e),o(!1),u(e)},onCancel:()=>o(!1)})]})}function rw({onOpened:e,onCancel:t}){let n=N.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`)?.status===`ok`,[i,a]=(0,k.useState)(null),o=i??(r?`afk`:`identity`);return n.isLoading?(0,A.jsx)(`div`,{className:`open-project`,children:(0,A.jsx)(F,{children:`preparing setup…`})}):o===`project`?(0,A.jsx)(nw,{firstRun:!0,onOpened:e,onCancel:t}):(0,A.jsx)(`div`,{className:`open-project`,children:(0,A.jsxs)(`div`,{className:`op-card wizard-card`,children:[(0,A.jsx)(`div`,{className:`op-logo`,children:(0,A.jsx)(ki,{size:22,variant:`ink`})}),(0,A.jsx)(aw,{current:o}),o===`identity`?(0,A.jsx)(ow,{onNext:()=>a(`afk`)}):(0,A.jsx)(sw,{onNext:()=>a(`project`)})]})})}var iw=[{key:`identity`,label:`Git identity`},{key:`afk`,label:`AFK burns`},{key:`project`,label:`First project`}];function aw({current:e}){let t=iw.findIndex(t=>t.key===e);return(0,A.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Setup progress`,children:iw.map((e,n)=>(0,A.jsxs)(`li`,{className:`wizard-step${n===t?` is-current`:``}${n<t?` is-done`:``}`,children:[(0,A.jsx)(`span`,{className:`wizard-step-dot`,"aria-hidden":!0}),e.label]},e.key))})}function ow({onNext:e}){let[t,n]=(0,k.useState)(``),[r,i]=(0,k.useState)(``),a=Ji(),o=N.useUtils(),s=N.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`op-kick`,children:`WELCOME TO RUNCASTLE`}),(0,A.jsx)(`div`,{className:`op-h`,children:`Set your git identity`}),(0,A.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,A.jsx)(`code`,{className:`mono`,children:`git config --global`}),`.`]}),(0,A.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-name`,children:`Name`}),(0,A.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,A.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-email`,children:`Email`}),(0,A.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,A.jsx)(`div`,{className:`op-actions`,children:(0,A.jsx)(P,{variant:`solid`,onClick:l,disabled:!c||s.isPending,children:s.isPending?`Saving…`:`Continue`})})]})}function sw({onNext:e}){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(RC,{onDismiss:e}),(0,A.jsx)(`div`,{className:`op-actions`,children:(0,A.jsx)(P,{variant:`solid`,onClick:e,children:`Continue to your first project`})})]})}var cw=`runcastle.update.dismissed`;function lw(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function uw(){let e=N.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[t,n]=(0,k.useState)(()=>{try{return localStorage.getItem(cw)}catch{return null}}),r=e.data;return!r||!r.latest||!lw(r,t)?null:(0,A.jsxs)(`div`,{className:`update-banner`,role:`status`,children:[(0,A.jsx)(`span`,{className:`update-banner-dot`,"aria-hidden":`true`}),(0,A.jsxs)(`span`,{className:`update-banner-text`,children:[`runcastle `,(0,A.jsx)(`strong`,{children:r.latest}),` is available`,(0,A.jsx)(`span`,{className:`update-banner-sep`,children:` · `}),(0,A.jsxs)(`span`,{className:`update-banner-dim`,children:[`you're on `,r.current]})]}),(0,A.jsx)(`code`,{className:`update-banner-cmd`,children:r.command}),(0,A.jsx)(`button`,{className:`update-banner-dismiss`,onClick:()=>{try{localStorage.setItem(cw,r.latest)}catch{}n(r.latest)},"aria-label":`Dismiss update notice`,title:`Dismiss`,children:`×`})]})}function dw(){let e=di(),t;return t=e.projects===void 0?(0,A.jsx)(`div`,{className:`app-loading`,children:(0,A.jsx)(F,{children:`loading projects…`})}):e.view===`open`&&e.projects.length===0?(0,A.jsx)(rw,{onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`open`?(0,A.jsx)(nw,{firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`project`&&e.currentProjectId?(0,A.jsx)(YC,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,A.jsx)(ZC,{nav:e}),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(uw,{}),t]})}function fw(){let e=N.useUtils(),[t,n]=(0,k.useState)(`connecting`),r=(0,k.useRef)(e);return r.current=e,(0,k.useEffect)(()=>{let e=()=>{let e=r.current;e.events.invalidate(),e.feature.list.invalidate(),e.feature.get.invalidate(),e.feature.driveInfo.invalidate(),e.run.get.invalidate(),e.project.list.invalidate(),e.docs.read.invalidate()},t=()=>{r.current.run.agentTranscript.invalidate()},i=new EventSource(`/api/stream`);return i.addEventListener(`ready`,()=>{n(`live`),e(),t()}),i.addEventListener(`live`,r=>{n(`live`);let i;try{i=JSON.parse(r.data)}catch{e();return}i.kind===`transcript`?t():e()}),i.addEventListener(`error`,()=>{n(i.readyState===EventSource.CLOSED?`offline`:`connecting`)}),()=>{i.close()}},[]),t}function pw(){return fw(),(0,A.jsx)(dw,{})}function mw(){let[e]=(0,k.useState)(()=>new Je({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}}})),[t]=(0,k.useState)(()=>N.createClient({links:[qn({url:`/api/trpc`})]}));return(0,A.jsx)(N.Provider,{client:t,queryClient:e,children:(0,A.jsx)(tt,{client:e,children:(0,A.jsx)(qi,{children:(0,A.jsx)(pw,{})})})})}var hw=document.getElementById(`root`);if(!hw)throw Error(`#root not found`);(0,br.createRoot)(hw).render((0,A.jsx)(k.StrictMode,{children:(0,A.jsx)(mw,{})}));
|
|
110
|
+
`)[0]:void 0,v=u.isPending||d.isPending||f.isPending,y=e.status===`failed`?e.conflictFiles:void 0;return(0,A.jsxs)(`div`,{className:`lane is-clickable${m}${r?` is-selected`:``}`,role:`button`,tabIndex:0,title:`show this ticket's agent`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o()},children:[(0,A.jsxs)(`div`,{className:`lane-head`,children:[(0,A.jsxs)(`span`,{className:`lane-seq`,children:[`#`,e.seq]}),(0,A.jsx)(`span`,{className:`lane-title`,children:e.title}),(0,A.jsx)(Ui,{status:e.status})]}),_&&!y&&(0,A.jsx)(`div`,{className:`lane-error`,title:e.error,children:_}),y&&(0,A.jsxs)(`div`,{className:`lane-conflict`,children:[(0,A.jsxs)(`div`,{className:`lane-conflict-head`,children:[`Merge conflict — the work is committed but could not land on`,` `,(0,A.jsx)(`code`,{children:t})]}),y.length>0&&(0,A.jsx)(`ul`,{className:`lane-conflict-files`,children:y.map(e=>(0,A.jsx)(`li`,{title:e,children:e},e))}),e.error&&(0,A.jsx)(`div`,{className:`lane-error`,title:e.error,children:_})]}),!i&&e.status===`failed`&&(0,A.jsxs)(`div`,{className:`lane-actions`,children:[(0,A.jsx)(`button`,{className:`lane-btn`,disabled:v,title:y?`run an agent that merges the feature branch into this ticket’s branch and resolves the conflict — it gets the ticket, the feature docs, and the commits it is reconciling against`:`retry this ticket — continues from any commits preserved by previous attempts`,onClick:t=>{t.stopPropagation(),u.mutate({ticketId:e.id},{onSuccess:t=>{t.resolvingConflict?s.push(`resolving ticket #${e.seq}'s conflict with an agent`,`info`):t.resumedFrom&&s.push(`resuming ticket #${e.seq} from ${t.preservedCommits} preserved commit(s)`,`info`)}})},children:y?`Resolve with agent`:`Retry`}),y&&(0,A.jsx)(`button`,{className:`lane-btn`,disabled:v||a,title:a?`available once this run finishes and no terminal is open`:`open a terminal on the feature branch, briefed with this ticket and its conflicting files, and resolve it yourself`,onClick:n=>{n.stopPropagation(),f.mutate({featureId:e.featureId,kind:`revisit`,kickoffLine:Op({seq:e.seq,title:e.title,branch:e.attemptBranch??``,featureBranch:t,files:y})})},children:`Resolve in terminal`}),(0,A.jsx)(`button`,{className:`lane-btn lane-btn-danger`,disabled:v,title:y?`throw away the conflicting branch and re-implement the ticket from the current feature branch tip`:`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?`)&&u.mutate({ticketId:e.id,fresh:!0})},children:`Retry fresh`})]}),!i&&e.status===`burning`&&(0,A.jsx)(`div`,{className:`lane-actions`,children:(0,A.jsx)(`button`,{className:`lane-btn lane-btn-danger`,disabled:v,title:`stop this ticket's agent — other lanes keep burning; committed work is preserved for retry`,onClick:t=>{t.stopPropagation(),d.mutate({ticketId:e.id},{onSuccess:e=>{e.swept?s.push(`no live agent — the lane was orphaned; marked failed, retry to resume it`,`info`):e.stopped||s.push(`no live agent for this ticket (already finishing?)`,`info`)}})},children:`Stop ticket`})}),(h||g)&&(0,A.jsxs)(`div`,{className:`lane-foot`,children:[(0,A.jsx)(`span`,{className:`lane-commits`,children:e.commits.map(e=>(0,A.jsx)(`button`,{className:`commit-sha`,onClick:t=>{t.stopPropagation(),p(e)},title:`copy sha`,children:Bp(e)},e))}),g&&(0,A.jsx)(`span`,{className:`lane-dur`,children:Hp(0,n)})]})]})}function lC({events:e}){let t=(0,k.useRef)(null),[n,r]=(0,k.useState)(!0);return(0,k.useEffect)(()=>{if(!n)return;let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e,n]),(0,A.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,A.jsx)(F,{children:`waiting for events…`}),e.map(e=>(0,A.jsxs)(`div`,{className:`stream-line level-${uC(e.type)}`,children:[(0,A.jsx)(`span`,{className:`sl-time`,children:zp(e.ts)}),(0,A.jsx)(`span`,{className:`sl-type`,children:e.type}),(0,A.jsx)(`span`,{className:`sl-msg`,children:e.message})]},e.id)),!n&&(0,A.jsx)(`button`,{className:`follow-pill agent-follow`,onClick:()=>r(!0),children:`Follow ⇣`})]})}function uC(e){return e===`merge.conflict.resolved`?`ok`:e===`merge.conflict.resolving`?`active`:/(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 dC(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 fC({featureId:e,viewedPhase:t,onViewPhase:n,guidance:r,driving:i,onDriveChange:a}){let o=N.useUtils(),s=Ji(),c=N.feature.get.useQuery({id:e},{refetchInterval:1500}),l=gC(e),u=()=>{o.feature.get.invalidate({id:e}),o.feature.list.invalidate()},d=N.feature.launchSession.useMutation({onSuccess:u,onError:e=>s.push(e.message)}),f=N.feature.advance.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),p=N.feature.burn.useMutation({onSuccess:()=>{u(),n(null)},onError:e=>s.push(e.message)}),m=N.run.cancel.useMutation({onSuccess:()=>{u(),s.push(`cancel requested`,`info`)},onError:e=>s.push(e.message)}),h=N.feature.testDrive.useMutation({onError:e=>s.push(e.message)}),g=N.feature.merge.useMutation({onError:e=>s.push(e.message)}),_=N.feature.unarchive.useMutation({onSuccess:()=>{u(),s.push(`feature unarchived`,`success`)},onError:e=>s.push(e.message)});if(c.isLoading)return(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(`div`,{className:`ws-body`,children:(0,A.jsx)(F,{children:`loading feature…`})})});if(!c.data)return(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(`div`,{className:`ws-body`,children:(0,A.jsxs)(F,{children:[`could not load feature`,c.error?`: ${c.error.message}`:``]})})});let v=!!c.error,y=c.data,b=y.feature,x=Cp(b,t),S=wp(b,x),ee=Tp(b,x),C=hp(y.runs),w=jp(y,{driving:i?.featureId===b.id}),te=d.isPending||f.isPending||p.isPending||m.isPending||h.isPending||g.isPending||_.isPending;return(0,A.jsxs)(`section`,{className:`workspace`,children:[(0,A.jsxs)(`div`,{className:`ws-head`,children:[(0,A.jsxs)(`div`,{className:`ws-title-row`,children:[(0,A.jsx)(Hi,{phase:b.phase}),(0,A.jsx)(`span`,{className:`ws-title`,children:b.title}),(0,A.jsx)(`span`,{className:`ws-title-spacer`}),(0,A.jsxs)(`button`,{className:`ws-branch`,title:`Copy branch name`,onClick:()=>_C(b.branch,s),children:[(0,A.jsx)(gi,{size:11}),b.branch]})]}),(0,A.jsx)(mC,{steps:ee,onView:e=>n(e===b.phase?null:e)})]}),S?(0,A.jsxs)(`div`,{className:`readonly-bar`,children:[(0,A.jsx)(`span`,{className:`readonly-tag`,children:`READ-ONLY`}),(0,A.jsxs)(`span`,{children:[`You're viewing the `,gp[x],` phase.`]}),(0,A.jsxs)(`button`,{className:`readonly-back`,onClick:()=>n(null),children:[`Back to `,gp[b.phase],` →`]})]}):(0,A.jsx)(hC,{ns:w,guidance:r,busy:te,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`,kickoffLine:b.phase===`review`?Ep:void 0});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`:C&&m.mutate({runId:C.id});break;case`unarchive`:_.mutate({featureId:e});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=>{if(u(),e.ok)a(null),s.push(`merged — feature shipped`,`success`);else if(e.conflict){let t=e.files.length;s.push(t>0?`merge conflict in ${t} file${t===1?``:`s`} — resolve below and retry`:`merge conflict — resolve below and retry`)}}});break}}}),v&&(0,A.jsxs)(`div`,{className:`ws-banner is-offline`,role:`status`,children:[(0,A.jsx)(`span`,{className:`ws-banner-tag`,children:`OFFLINE`}),(0,A.jsx)(`span`,{children:`server unreachable — retrying…`})]}),l.message&&(0,A.jsxs)(`div`,{className:`ws-banner`,role:`alert`,onClick:l.dismiss,title:`dismiss`,children:[(0,A.jsx)(`span`,{className:`ws-banner-tag`,children:`RESUME FAILED`}),(0,A.jsx)(`span`,{children:l.message})]}),(0,A.jsx)(`div`,{className:`ws-body`,children:(0,A.jsx)(`div`,{className:`ws-body-inner`,children:(0,A.jsx)(pC,{effective:x,full:y,driving:i,runId:C?.id??null,readonly:S})},x)})]})}function pC({effective:e,full:t,driving:n,runId:r,readonly:i}){switch(e){case`ideation`:case`spec`:return(0,A.jsx)(WS,{full:t,effective:e});case`tickets`:return(0,A.jsx)(nC,{featureId:t.feature.id,readonly:i});case`implementation`:return(0,A.jsx)(sC,{featureId:t.feature.id,runId:r,readonly:i});case`review`:return(0,A.jsx)(QS,{full:t,driving:n});case`shipped`:return(0,A.jsx)(tC,{full:t})}}function mC({steps:e,onView:t}){return(0,A.jsx)(`div`,{className:`pipeline`,children:e.map((n,r)=>(0,A.jsxs)(k.Fragment,{children:[(0,A.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,A.jsx)(`span`,{className:`pstep-dot`}),(0,A.jsx)(`span`,{className:`pstep-label`,children:n.label})]}),r<e.length-1&&(0,A.jsx)(`span`,{className:`pconn${n.state===`done`?` is-done`:``}`})]},n.phase))})}function hC({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,A.jsxs)(`div`,{className:`nextstep`,children:[e.busy&&(0,A.jsx)(`span`,{className:`spin-ring nextstep-spin`}),(0,A.jsxs)(`div`,{className:`nextstep-main`,children:[(0,A.jsx)(`div`,{className:`nextstep-kick ${i}`,children:e.kick}),(0,A.jsx)(`div`,{className:`nextstep-title`,children:e.title}),t&&(0,A.jsx)(`div`,{className:`nextstep-desc`,children:e.desc})]}),(0,A.jsxs)(`div`,{className:`nextstep-actions`,children:[e.secondary.map((e,t)=>(0,A.jsx)(P,{variant:`ghost`,className:`btn-xs`,disabled:n,onClick:()=>r(e.kind),children:e.label},t)),e.primary&&(0,A.jsx)(P,{variant:e.primary.danger?`danger`:`solid`,disabled:n,onClick:()=>r(e.primary.kind),children:n?`Working…`:e.primary.label})]})]})}function gC(e){let t=Rp(e),[n,r]=(0,k.useState)(null),i=(0,k.useRef)(null);return(0,k.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,k.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(null),8e3);return()=>clearTimeout(e)},[n]),{message:n,dismiss:()=>r(null)}}function _C(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function vC({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(``),[s,c]=(0,k.useState)(``),l=N.useUtils(),u=Ji(),d=N.project.branches.useQuery({projectId:e}),f=d.data?.mainBranch??``,p=d.data?.current,m=d.data?.branches??[],h=d.data?.remoteBranches??[],g=m.length===0&&h.length===0,_=d.data?fp(d.data):f,v=s||_,y=N.feature.launchSession.useMutation(),b=N.feature.create.useMutation({onSuccess:async e=>{await l.feature.list.invalidate(),y.mutate({featureId:e.id,kind:`ideation`},{onSettled:()=>void l.feature.get.invalidate({id:e.id})}),n(e.id)},onError:e=>u.push(e.message)}),x=yC(r),S=b.isPending||y.isPending,ee=()=>{let t=r.trim();t&&!d.isPending&&b.mutate({projectId:e,title:t,oneLiner:a.trim(),baseBranch:v||void 0})};return(0,A.jsx)(`div`,{className:`nf-overlay`,children:(0,A.jsxs)(`div`,{className:`nf-card`,children:[(0,A.jsx)(`div`,{className:`nf-kick`,children:`NEW FEATURE`}),(0,A.jsx)(`div`,{className:`nf-h`,children:`What are we building?`}),(0,A.jsx)(`div`,{className:`nf-sub`,children:`Name it — runcastle opens a grill session so you and Claude shape the idea before any code is written.`}),(0,A.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`&&ee(),e.key===`Escape`&&t()}}),(0,A.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`&&ee(),e.key===`Escape`&&t()}}),(0,A.jsxs)(`details`,{className:`nf-advanced`,children:[(0,A.jsx)(`summary`,{className:`nf-advanced-summary`,children:`Advanced`}),(0,A.jsxs)(`div`,{className:`nf-base`,children:[(0,A.jsx)(`label`,{className:`nf-base-label`,htmlFor:`nf-base-select`,children:`Branch from`}),(0,A.jsxs)(`select`,{id:`nf-base-select`,className:`nf-base-select`,value:v,disabled:d.isPending||g,onChange:e=>c(e.target.value),children:[m.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,e===f?` (default)`:``,e===p&&e!==f?` (current)`:``]},e)),h.length>0&&(0,A.jsx)(`optgroup`,{label:`Remote (creates a local branch)`,children:h.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]}),(0,A.jsx)(`span`,{className:`size-hint`,children:`forks off this branch — and merges back into it when shipped.`})]}),(0,A.jsxs)(`div`,{className:`nf-branch`,children:[`branch · feature/`,x||`…`,` ← `,v||`…`]})]}),(0,A.jsxs)(`div`,{className:`nf-actions`,children:[(0,A.jsx)(P,{variant:`ghost`,onClick:t,disabled:S,children:`Cancel`}),(0,A.jsx)(P,{variant:`solid`,onClick:ee,disabled:!r.trim()||S||d.isPending,children:S?`Starting…`:`Start grill session`})]})]})})}function yC(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function bC(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onNewFeature:o,onOpenSettings:s,nav:c}=e,[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(0),p=(0,k.useRef)(null),m=(0,k.useRef)([]);(0,k.useEffect)(()=>{t&&(u(``),f(0),p.current?.focus())},[t]),(0,k.useEffect)(()=>{f(0)},[l]);let h=l.trim().toLowerCase(),g=(0,k.useMemo)(()=>h===``?r:r.filter(e=>e.slug.toLowerCase().includes(h)||e.title.toLowerCase().includes(h)),[r,h]),_=(0,k.useMemo)(()=>(c.projects??[]).filter(e=>e.id!==c.currentProjectId),[c.projects,c.currentProjectId]),v=(0,k.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),S=`settings preferences`.includes(h),ee=(0,k.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`}),S&&e.push({kind:`settings`}),e},[g,v,y,b,x,S]);if(!t)return null;let C=e=>{if(ee.length===0)return;let t=(d+e+ee.length)%ee.length;f(t),m.current[t]?.scrollIntoView({block:`nearest`})},w=e=>{let t=ee[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()}},te=e=>{e.key===`ArrowDown`?(e.preventDefault(),C(1)):e.key===`ArrowUp`?(e.preventDefault(),C(-1)):e.key===`Enter`?(e.preventDefault(),w(d)):e.key===`Escape`&&(e.preventDefault(),n())},ne=g.length,re=ne+v.length,ie=e=>t=>{m.current[e]=t};return(0,A.jsx)(`div`,{className:`cmdk-backdrop`,onClick:n,children:(0,A.jsxs)(`div`,{className:`cmdk`,onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`input`,{ref:p,className:`cmdk-input`,placeholder:`Search features, projects, or jump to…`,value:l,onChange:e=>u(e.target.value),onKeyDown:te,"aria-label":`Search features, projects, or jump to`}),(0,A.jsxs)(`div`,{className:`cmdk-list`,children:[g.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`cmdk-group-label`,children:`Features`}),g.map((e,t)=>(0,A.jsxs)(`div`,{ref:ie(t),className:`cmdk-item${t===d?` is-active`:``}`,onMouseEnter:()=>f(t),onClick:()=>w(t),children:[(0,A.jsx)(`span`,{className:`cmdk-item-glyph`,children:(0,A.jsx)(`span`,{className:`feature-dot phase-bg-${e.phase}`})}),(0,A.jsx)(`span`,{className:`cmdk-item-label`,children:e.title}),(0,A.jsx)(`span`,{className:`cmdk-item-slug`,children:e.slug}),(0,A.jsx)(`span`,{className:`cmdk-item-hint`,children:e.id===i?`current`:e.phase})]},e.id))]}),v.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`cmdk-group-label`,children:`Switch project`}),v.map((e,t)=>{let n=ne+t;return(0,A.jsxs)(`div`,{ref:ie(n),className:`cmdk-item${n===d?` is-active`:``}`,onMouseEnter:()=>f(n),onClick:()=>w(n),children:[(0,A.jsx)(`span`,{className:`cmdk-item-glyph`,children:(0,A.jsx)(Ei,{size:13})}),(0,A.jsx)(`span`,{className:`cmdk-item-label`,children:e.name}),(0,A.jsx)(`span`,{className:`cmdk-item-slug`,children:e.mainBranch}),(0,A.jsx)(`span`,{className:`cmdk-item-hint`,children:`project`})]},e.id)})]}),(y||b||x||S)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`cmdk-group-label`,children:`Actions`}),y&&(0,A.jsx)(xC,{index:re,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(yi,{size:13}),label:`Create new feature`}),b&&(0,A.jsx)(xC,{index:re+ +!!y,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(Ei,{size:13}),label:`All projects (home)`}),x&&(0,A.jsx)(xC,{index:re+ +!!y+ +!!b,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(Ei,{size:13}),label:`Open a project…`}),S&&(0,A.jsx)(xC,{index:re+ +!!y+ +!!b+ +!!x,activeIndex:d,bindRow:ie,setActiveIndex:f,activate:w,glyph:(0,A.jsx)(mi,{size:13}),label:`Settings`})]}),ee.length===0&&(0,A.jsx)(`div`,{className:`cmdk-empty`,children:`No matches`})]}),(0,A.jsxs)(`div`,{className:`cmdk-foot`,children:[(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`kbd`,children:`↑↓`}),` navigate`]}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`kbd`,children:`↵`}),` select`]}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`kbd`,children:`esc`}),` close`]})]})]})})}function xC({index:e,activeIndex:t,bindRow:n,setActiveIndex:r,activate:i,glyph:a,label:o}){return(0,A.jsxs)(`div`,{ref:n(e),className:`cmdk-item${e===t?` is-active`:``}`,onMouseEnter:()=>r(e),onClick:()=>i(e),children:[(0,A.jsx)(`span`,{className:`cmdk-item-glyph`,children:a}),(0,A.jsx)(`span`,{className:`cmdk-item-label`,children:o}),(0,A.jsx)(`span`,{className:`cmdk-item-hint`,children:`action`})]})}var SC={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,burnAttempts:`RUNCASTLE_BURN_ATTEMPTS`,burnConflictAttempts:`RUNCASTLE_BURN_CONFLICT_ATTEMPTS`,burnCpus:`RUNCASTLE_BURN_CPUS`,verifyCommands:`RUNCASTLE_VERIFY_COMMANDS`,knownFailures:`RUNCASTLE_KNOWN_FAILURES`,mainBranch:`RUNCASTLE_MAIN_BRANCH`},CC=dp.map(e=>e.id),wC=`stepModels.`;function TC(e){return e.startsWith(wC)}function EC(e){return e.slice(11)}var DC={ideation:`Ideation`,qa:`Q&A`,waypoint:`Waypoint`,converge:`Converge`,research:`Research`,implement:`Implement`,smoke:`Smoke`},OC=lp.map(e=>`${wC}${e}`),kC=new Set([`mainBranch`]),AC={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:CC},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`},burnConflictAttempts:{label:`Conflict resolver passes`,help:`Max agent passes spent resolving a ticket’s landing conflict before asking you (0–3). 0 sends every conflict straight to you.`,control:`number`},burnCpus:{label:`Burn CPU limit`,help:`CPU ceiling per burn container (--cpus). Blank leaves it unconstrained. Roughly cores ÷ concurrency keeps parallel tickets from oversubscribing the machine.`,control:`number`},verifyCommands:{label:`Verify commands`,help:`Exact typecheck/test/lint commands for this repo, one per line. Given these, burn agents stop discovering workspace filter names by running suites that error out.`,control:`textarea`},knownFailures:{label:`Known failing tests`,help:`Tests already red on main — a count plus suite names is enough. Saves every burn agent a full pre-work suite run to establish its own baseline.`,control:`textarea`},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 jC(e){return e==null?``:String(e)}function MC(e){if(TC(e)){let t=EC(e);return{label:DC[t]??t,help:`Model for the ${DC[t]??t} step.`,control:`select`,options:CC}}return AC[e]??{label:e,help:``,control:`text`}}function NC(e){let t=MC(e.key),n=kC.has(e.key),r=!e.editable||n,i=e.source===`project`,a=null;return e.source===`env`?a=`Set by ${SC[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:jC(e.value),control:t.control,options:t.options??[],readOnly:r,restartRequired:e.restartRequired,overridden:i,source:e.source,note:a,allowCustom:e.key===`model`||TC(e.key)}}function PC(e){return e.fields.filter(e=>!TC(e.key)).map(NC)}function FC(e){return e.fields.filter(e=>e.scope===`project`).map(NC)}function IC(e){return e.fields.filter(e=>TC(e.key)&&e.source===`file`).map(NC).sort((e,t)=>OC.indexOf(e.key)-OC.indexOf(t.key))}function LC(e){let t=new Set(e.fields.filter(e=>TC(e.key)&&e.source===`file`).map(e=>e.key));return OC.filter(e=>!t.has(e)).map(e=>({key:e,label:DC[EC(e)]??EC(e)}))}function RC({onDismiss:e}){let t=N.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,A.jsxs)(`div`,{className:`afk-card`,children:[(0,A.jsxs)(`div`,{className:`afk-card-head`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`op-kick`,children:`ENABLE AFK BURNS`}),(0,A.jsx)(`div`,{className:`afk-card-title`,children:`Run features unattended`})]}),e&&(0,A.jsx)(P,{variant:`ghost`,onClick:e,children:`Set up later`})]}),(0,A.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,A.jsx)(F,{children:`checking prerequisites…`}),t.error&&(0,A.jsxs)(F,{children:[`could not run checks: `,t.error.message]}),n&&(0,A.jsxs)(`div`,{className:`afk-rows`,children:[(0,A.jsx)(BC,{probe:i,onRecheck:s}),(0,A.jsx)(VC,{probe:a,runtimeOk:i?.status===`ok`,onDone:s}),(0,A.jsx)(HC,{probe:o,onDone:s})]})]})}function zC({probe:e,children:t}){if(!e)return null;let n=e.status===`ok`;return(0,A.jsxs)(`div`,{className:`afk-row${n?` is-ok`:``}`,children:[(0,A.jsxs)(`div`,{className:`afk-row-head`,children:[(0,A.jsx)(`span`,{className:`afk-dot afk-dot-${n?`ok`:`warn`}`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`afk-row-text`,children:[(0,A.jsx)(`div`,{className:`afk-row-label`,children:e.label}),(0,A.jsx)(`div`,{className:`afk-row-detail mono`,children:e.detail})]})]}),!n&&(0,A.jsx)(`div`,{className:`afk-row-action`,children:t})]})}function BC({probe:e,onRecheck:t}){let n=N.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),r=Ji();if(!e)return null;let i=e.status===`missing`?n.data:void 0,a=i?.command??e.fix??``;return(0,A.jsxs)(zC,{probe:e,children:[a&&(0,A.jsxs)(`div`,{className:`afk-cmd`,children:[(0,A.jsx)(`code`,{className:`afk-cmd-text mono`,children:a}),(0,A.jsx)(P,{variant:`ghost`,onClick:()=>{navigator.clipboard?.writeText(a),r.push(`copied`,`info`)},children:`Copy`})]}),i?.note&&(0,A.jsx)(`div`,{className:`afk-note`,children:i.note}),(0,A.jsx)(P,{variant:`solid`,onClick:t,children:`Re-check`})]})}function VC({probe:e,runtimeOk:t,onDone:n}){let[r,i]=(0,k.useState)(null),a=Ji(),o=N.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)});return e?(0,A.jsx)(zC,{probe:e,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`afk-term`,children:(0,A.jsx)(pm,{label:`build-image`,children:(0,A.jsx)(zS,{sessionId:r})})}),(0,A.jsx)(`div`,{className:`afk-term-actions`,children:(0,A.jsx)(P,{variant:`solid`,onClick:()=>{i(null),n()},children:`Done — re-check`})})]}):(0,A.jsx)(P,{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 HC({probe:e,onDone:t}){let[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(null),c=Ji(),l=N.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>r(e),onError:e=>c.push(e.message)}),u=N.setup.afkToken.useMutation({onSuccess:e=>{s(e),e.valid&&t()},onError:e=>c.push(e.message)});return e?(0,A.jsxs)(zC,{probe:e,children:[n?(0,A.jsx)(`div`,{className:`afk-term`,children:(0,A.jsx)(pm,{label:`setup-token`,children:(0,A.jsx)(zS,{sessionId:n})})}):(0,A.jsx)(P,{variant:`ghost`,onClick:()=>l.mutate({kind:`setup-token`}),disabled:l.isPending,children:l.isPending?`Starting…`:`Run claude setup-token`}),(0,A.jsx)(`label`,{className:`op-label`,htmlFor:`afk-token-input`,children:`Paste the token it prints`}),(0,A.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,A.jsx)(`div`,{className:`afk-term-actions`,children:(0,A.jsx)(P,{variant:`solid`,disabled:i.trim()===``||u.isPending,onClick:()=>u.mutate({token:i}),children:u.isPending?`Verifying…`:`Save & verify`})}),o&&(0,A.jsxs)(`div`,{className:`afk-verdict ${o.valid?`is-ok`:`is-warn`}`,children:[(0,A.jsxs)(`div`,{children:[o.valid?`✓ `:`⚠ `,o.detail]}),o.fix&&(0,A.jsx)(`div`,{className:`afk-verdict-fix`,children:o.fix})]})]}):null}function UC({projectId:e,onClose:t}){let n=N.settings.get.useQuery(),r=N.settings.get.useQuery({projectId:e});return(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:t,children:(0,A.jsxs)(`div`,{className:`peek settings`,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`settings-title`,children:`Settings`}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:t,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`peek-body settings-body`,children:[(0,A.jsx)(WC,{title:`Global`,hint:`Machine-wide defaults for every project.`,query:n,rowsOf:PC}),(0,A.jsx)(JC,{query:n}),(0,A.jsx)(WC,{title:`This project`,hint:`Overrides that apply only to the current project.`,query:r,rowsOf:FC,projectId:e}),(0,A.jsxs)(`section`,{className:`settings-section`,children:[(0,A.jsxs)(`div`,{className:`settings-section-head`,children:[(0,A.jsx)(`h3`,{className:`settings-section-title`,children:`AFK burns`}),(0,A.jsx)(`span`,{className:`settings-section-hint`,children:`Prerequisites for unattended sandbox runs.`})]}),(0,A.jsx)(RC,{})]})]})]})})}function WC({title:e,hint:t,query:n,rowsOf:r,projectId:i}){let a=n.data?r(n.data):[];return(0,A.jsxs)(`section`,{className:`settings-section`,children:[(0,A.jsxs)(`div`,{className:`settings-section-head`,children:[(0,A.jsx)(`h3`,{className:`settings-section-title`,children:e}),(0,A.jsx)(`span`,{className:`settings-section-hint`,children:t})]}),n.isLoading&&(0,A.jsx)(F,{children:`loading…`}),n.error&&(0,A.jsxs)(F,{children:[`could not load settings: `,n.error.message]}),n.data&&a.length===0&&(0,A.jsx)(F,{children:`no settings in this scope`}),a.map(e=>(0,A.jsx)(GC,{row:e,projectId:i},e.key))]})}function GC({row:e,projectId:t}){let n=N.useUtils(),r=Ji(),[i,a]=(0,k.useState)(e.value);(0,k.useEffect)(()=>a(e.value),[e.value]);let o=N.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,A.jsxs)(`div`,{className:`settings-field${e.readOnly?` is-locked`:``}`,children:[(0,A.jsxs)(`label`,{className:`settings-field-head`,htmlFor:l,children:[(0,A.jsx)(`span`,{className:`settings-field-label`,children:e.label}),e.restartRequired&&(0,A.jsx)(`span`,{className:`settings-badge is-warn`,title:`Takes effect after a server restart`,children:`restart required`}),e.overridden&&(0,A.jsx)(`span`,{className:`settings-badge is-override`,children:`overridden`}),o.isPending&&(0,A.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),e.help&&(0,A.jsx)(`div`,{className:`settings-field-help`,children:e.help}),e.readOnly?(0,A.jsx)(`div`,{className:`settings-readonly mono`,id:l,children:e.value||`—`}):e.control===`select`&&e.allowCustom?(0,A.jsx)(qC,{id:l,value:e.value,options:e.options,disabled:o.isPending,onCommit:s}):e.control===`select`?(0,A.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,A.jsx)(`option`,{value:e,children:e},e))}):e.control===`textarea`?(0,A.jsx)(`textarea`,{id:l,className:`settings-input mono settings-textarea`,rows:4,value:i,disabled:o.isPending,onChange:e=>a(e.target.value),onBlur:e=>s(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(a(e.value),t.currentTarget.blur())}}):(0,A.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,A.jsx)(`div`,{className:`settings-field-note`,children:e.note}),e.overridden&&t&&(0,A.jsx)(`button`,{className:`settings-clear`,onClick:c,disabled:o.isPending,children:`Clear override`})]})}var KC=`__custom__`;function qC({id:e,value:t,options:n,disabled:r,onCommit:i}){let[a,o]=(0,k.useState)(!n.includes(t)&&t!==``),[s,c]=(0,k.useState)(t);return(0,k.useEffect)(()=>{c(t),o(!n.includes(t)&&t!==``)},[t,n]),(0,A.jsxs)(`div`,{className:`settings-combo`,children:[(0,A.jsxs)(`select`,{id:e,className:`settings-input`,value:a?KC:t,disabled:r,onChange:e=>{if(e.target.value===KC){o(!0);return}o(!1),i(e.target.value)},children:[n.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e)),(0,A.jsx)(`option`,{value:KC,children:`Custom…`})]}),a&&(0,A.jsx)(`input`,{className:`settings-input mono`,type:`text`,placeholder:`model id (e.g. claude-opus-5, claude-opus-5[1m])`,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 JC({query:e}){let t=N.useUtils(),n=Ji(),[r,i]=(0,k.useState)(!1),a=N.settings.update.useMutation({onSuccess:()=>{t.settings.get.invalidate()},onError:e=>n.push(e.message)}),o=e.data,s=o?IC(o):[],c=o?LC(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,A.jsxs)(`section`,{className:`settings-section`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`settings-advanced-toggle`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,A.jsx)(`span`,{className:`settings-section-title`,children:`Advanced — per-step models`}),(0,A.jsxs)(`span`,{className:`settings-section-hint`,children:[s.length>0?`${s.length} override${s.length===1?``:`s`}`:`none set`,r?` ▾`:` ▸`]})]}),r&&(0,A.jsxs)(`div`,{className:`settings-advanced-body`,children:[s.length===0&&(0,A.jsx)(F,{children:`every step uses the default model.`}),s.map(e=>(0,A.jsxs)(`div`,{className:`settings-field`,children:[(0,A.jsxs)(`div`,{className:`settings-field-head`,children:[(0,A.jsx)(`span`,{className:`settings-field-label`,children:e.label}),a.isPending&&(0,A.jsx)(`span`,{className:`settings-saving`,children:`saving…`})]}),(0,A.jsx)(qC,{id:`step-${e.key}`,value:e.value,options:e.options,disabled:a.isPending,onCommit:t=>u(e.key,t)}),(0,A.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,A.jsxs)(`div`,{className:`settings-field`,children:[(0,A.jsx)(`label`,{className:`settings-field-label`,htmlFor:`step-add`,children:`Add an override`}),(0,A.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,A.jsx)(`option`,{value:``,children:`Choose a step…`}),c.map(e=>(0,A.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]})]})]})}function YC({projectId:e,nav:t}){let n=Li(e),{selectedFeatureId:r,select:i,setCmdk:a}=n,[o,s]=(0,k.useState)(null),c=N.feature.list.useQuery({projectId:e},{refetchInterval:1500});(0,k.useEffect)(()=>{!r&&c.data&&c.data.length>0&&i(c.data[0].id)},[r,c.data,i]),(0,k.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,A.jsxs)(`div`,{className:`shell${n.inspectorCollapsed?` inspector-collapsed`:``}`,children:[(0,A.jsx)(zi,{nav:t,onOpenCmdk:()=>n.setCmdk(!0),onOpenSettings:()=>n.setSettings(!0),onToggleInspector:n.toggleInspector,inspectorCollapsed:n.inspectorCollapsed}),(0,A.jsxs)(`div`,{className:`shell-body`,children:[(0,A.jsx)(Ip,{projectId:e,selectedFeatureId:n.selectedFeatureId,onSelect:n.select,onNewFeature:n.startCreate}),n.creating?(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(vC,{projectId:e,onCancel:n.cancelCreate,onCreated:n.select})}):n.selectedFeatureId?(0,A.jsx)(fC,{featureId:n.selectedFeatureId,viewedPhase:n.viewedPhase,onViewPhase:n.viewPhase,guidance:n.guidance,driving:o,onDriveChange:s},`ws-${n.selectedFeatureId}`):(0,A.jsx)(`section`,{className:`workspace`,children:(0,A.jsx)(XC,{onNewFeature:n.startCreate})}),l&&n.selectedFeatureId&&(0,A.jsx)(Wp,{featureId:n.selectedFeatureId},`insp-${n.selectedFeatureId}`)]}),(0,A.jsx)(dm,{projectId:e,activeFeatureId:n.selectedFeatureId,driving:o,onDriveChange:s}),(0,A.jsx)(bC,{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,A.jsx)(UC,{projectId:e,onClose:()=>n.setSettings(!1)})]})}function XC({onNewFeature:e}){return(0,A.jsxs)(`div`,{className:`ws-empty`,children:[(0,A.jsx)(`div`,{className:`ws-empty-logo`,children:(0,A.jsx)(ki,{size:44,variant:`outline`})}),(0,A.jsx)(`div`,{className:`ws-empty-title`,children:`Select a feature to begin`}),(0,A.jsx)(`div`,{className:`ws-empty-sub`,children:`Or create one — every feature moves through the same guided pipeline.`}),(0,A.jsx)(`button`,{className:`btn btn-ghost`,onClick:e,children:`New feature`})]})}function ZC({nav:e}){let t=e.projects??[],n=N.useQueries(e=>t.map(t=>e.feature.list({projectId:t.id},{refetchInterval:1500})));return(0,A.jsxs)(`div`,{className:`home-frame`,children:[(0,A.jsxs)(`header`,{className:`home-topbar`,children:[(0,A.jsxs)(`span`,{className:`tb-home`,children:[(0,A.jsx)(`span`,{className:`tb-logo`,children:(0,A.jsx)(ki,{size:17})}),(0,A.jsx)(Ai,{})]}),(0,A.jsx)(`span`,{className:`tb-spacer`}),(0,A.jsxs)(`button`,{className:`btn btn-ghost btn-xs`,onClick:e.showOpen,children:[(0,A.jsx)(yi,{size:11}),`Open a project`]})]}),(0,A.jsxs)(`div`,{className:`home`,children:[(0,A.jsxs)(`header`,{className:`home-head`,children:[(0,A.jsxs)(`div`,{className:`home-title`,children:[(0,A.jsx)(`span`,{className:`home-title-text`,children:`Projects`}),(0,A.jsx)(`span`,{className:`home-count`,children:t.length})]}),(0,A.jsx)(`p`,{className:`home-sub`,children:`Every open project and where it stands — runs keep going in the background while you switch.`})]}),(0,A.jsxs)(`div`,{className:`home-grid`,children:[t.map((t,r)=>{let i=n[r]?.data;return(0,A.jsx)($C,{project:t,stats:li(i??[]),loading:i===void 0,onOpen:()=>e.enterProject(t.id)},t.id)}),(0,A.jsxs)(`button`,{className:`open-card`,onClick:e.showOpen,children:[(0,A.jsx)(`span`,{className:`open-card-plus`,children:(0,A.jsx)(yi,{size:16})}),(0,A.jsx)(`span`,{className:`open-card-label`,children:`Open a project`}),(0,A.jsx)(`span`,{className:`open-card-sub`,children:`Point runcastle at a local git repo`})]})]})]})]})}var QC={attention:`Needs you`,working:`Agent working`,steady:`Steady`,empty:`No features yet`};function $C({project:e,stats:t,loading:n,onOpen:r}){let i=Ji(),a=N.useUtils(),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(e.name),u=N.project.rename.useMutation({onSuccess:async()=>{await a.project.list.invalidate(),s(!1)},onError:e=>i.push(e.message)}),d=N.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,A.jsxs)(`div`,{className:`project-card health-${t.health}`,children:[(0,A.jsxs)(`button`,{className:`pc-main`,onClick:r,title:`Open ${e.name}`,children:[(0,A.jsxs)(`div`,{className:`pc-head`,children:[o?(0,A.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,A.jsx)(`span`,{className:`pc-name`,children:e.name}),(0,A.jsx)(`span`,{className:`pc-health-dot health-dot-${t.health}`,title:QC[t.health]})]}),(0,A.jsx)(`span`,{className:`pc-path mono`,children:e.repoPath}),(0,A.jsxs)(`span`,{className:`pc-branch`,children:[(0,A.jsx)(gi,{size:11}),e.mainBranch]}),(0,A.jsxs)(`div`,{className:`pc-stats`,children:[(0,A.jsx)(ew,{n:t.total,label:t.total===1?`feature`:`features`}),(0,A.jsx)(ew,{n:t.activeRuns,label:`running`,tone:f?`run`:void 0,spin:f}),(0,A.jsx)(ew,{n:t.needsYou,label:`needs you`,tone:t.needsYou>0?`needs`:void 0})]}),(0,A.jsx)(`span`,{className:`pc-health-label`,children:n?`loading…`:QC[t.health]})]}),(0,A.jsxs)(`div`,{className:`pc-actions`,children:[(0,A.jsx)(`button`,{className:`pc-action`,onClick:()=>{l(e.name),s(!0)},children:`Rename`}),(0,A.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 ew({n:e,label:t,tone:n,spin:r}){return(0,A.jsxs)(`span`,{className:`pc-stat${n?` pc-stat-${n}`:``}`,children:[r&&(0,A.jsx)(`span`,{className:`spin-ring`}),(0,A.jsx)(`span`,{className:`pc-stat-n`,children:e}),(0,A.jsx)(`span`,{className:`pc-stat-label`,children:t})]})}function tw({onPick:e,onCancel:t}){let[n,r]=(0,k.useState)(void 0),[i,a]=(0,k.useState)(!1),o=N.project.roots.useQuery(),s=N.project.browse.useQuery({dir:n,showHidden:i},{placeholderData:e=>e,retry:!1});(0,k.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let c=s.data,l=c?.dir??n;return(0,A.jsx)(`div`,{className:`peek-backdrop`,onClick:t,children:(0,A.jsxs)(`div`,{className:`peek dir-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":`Choose a repository`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`peek-head`,children:[(0,A.jsx)(`span`,{className:`dir-picker-title`,children:`Choose a repository`}),(0,A.jsx)(`button`,{className:`peek-close`,onClick:t,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`dir-picker-bar`,children:[(0,A.jsx)(P,{variant:`ghost`,className:`dir-up`,onClick:()=>c?.parent&&r(c.parent),disabled:!c?.parent,"aria-label":`Up one level`,title:`Up one level`,children:`↑`}),(0,A.jsx)(`div`,{className:`dir-crumbs mono`,"aria-label":`Current path`,children:(c?.crumbs??[]).map((e,t)=>(0,A.jsxs)(`span`,{className:`dir-crumb-wrap`,children:[t>0&&(0,A.jsx)(Si,{size:11}),(0,A.jsx)(`button`,{className:`dir-crumb`,onClick:()=>r(e.path),children:e.name})]},e.path))}),(0,A.jsxs)(`label`,{className:`dir-hidden-toggle`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),(0,A.jsx)(`span`,{children:`Hidden`})]})]}),(0,A.jsxs)(`div`,{className:`dir-picker-body`,children:[(0,A.jsx)(`div`,{className:`dir-rail`,children:(o.data??[]).map(e=>(0,A.jsxs)(`button`,{className:`dir-rail-item${l===e.path?` is-active`:``}`,onClick:()=>r(e.path),title:e.path,children:[(0,A.jsx)(Ei,{size:13}),(0,A.jsx)(`span`,{className:`dir-rail-label mono`,children:e.label})]},e.path))}),(0,A.jsxs)(`div`,{className:`dir-list`,children:[s.isError?(0,A.jsx)(F,{children:s.error.message}):s.isLoading?(0,A.jsx)(F,{children:`Loading…`}):(c?.entries.length??0)===0?(0,A.jsxs)(F,{children:[`No subfolders here`,i?``:` (hidden folders are filtered)`,`.`]}):(c?.entries??[]).map(t=>(0,A.jsxs)(`button`,{className:`dir-item${t.isRepo?` is-repo`:``}`,onClick:()=>r(t.path),onDoubleClick:()=>t.isRepo&&e(t.path),title:t.path,children:[(0,A.jsx)(Ei,{size:13}),(0,A.jsx)(`span`,{className:`dir-item-name mono`,children:t.name}),t.isSymlink&&(0,A.jsx)(`span`,{className:`dir-item-tag`,children:`link`}),t.isRepo&&(0,A.jsxs)(`span`,{className:`dir-item-repo`,children:[(0,A.jsx)(gi,{size:11}),` git`]})]},t.path)),c?.truncated&&(0,A.jsx)(F,{children:`Listing truncated — this folder is very large.`})]})]}),(0,A.jsxs)(`div`,{className:`dir-picker-foot`,children:[(0,A.jsx)(`div`,{className:`dir-picked mono`,title:l,children:(0,A.jsx)(`bdi`,{children:l??`—`})}),(0,A.jsxs)(`div`,{className:`dir-picker-actions`,children:[(0,A.jsx)(P,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,A.jsx)(P,{variant:`solid`,onClick:()=>l&&e(l),disabled:!l,children:`Open this folder`})]})]})]})})}function nw({firstRun:e,onOpened:t,onCancel:n}){let[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(!1),s=Ji(),c=N.useUtils(),l=N.project.open.useMutation({onSuccess:async e=>{await c.project.list.invalidate(),s.push(`opened ${e.name} on ${e.mainBranch}`,`info`),t(e.id)},onError:e=>s.push(e.message)}),u=e=>{let t=(e??r).trim();t&&l.mutate({repoPath:t})};return(0,A.jsxs)(`div`,{className:`open-project`,children:[(0,A.jsxs)(`div`,{className:`op-card`,children:[(0,A.jsx)(`div`,{className:`op-logo`,children:(0,A.jsx)(ki,{size:22,variant:`ink`})}),(0,A.jsx)(`div`,{className:`op-kick`,children:e?`WELCOME TO RUNCASTLE`:`OPEN A PROJECT`}),(0,A.jsx)(`div`,{className:`op-h`,children:e?`Open your first project`:`Open a project`}),(0,A.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,A.jsx)(`label`,{className:`op-label`,htmlFor:`op-repo-path`,children:`Repository path`}),(0,A.jsxs)(`div`,{className:`op-input-row`,children:[(0,A.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`&&u(),t.key===`Escape`&&!e&&n()}}),(0,A.jsx)(P,{variant:`ghost`,onClick:()=>o(!0),disabled:l.isPending,children:`Browse…`})]}),(0,A.jsx)(`div`,{className:`op-hint`,children:`Browse your machine, or paste a path. The default branch is detected automatically when the project opens.`}),(0,A.jsxs)(`div`,{className:`op-actions`,children:[!e&&(0,A.jsx)(P,{variant:`ghost`,onClick:n,disabled:l.isPending,children:`Cancel`}),(0,A.jsx)(P,{variant:`solid`,onClick:()=>u(),disabled:l.isPending||r.trim()===``,children:l.isPending?`Opening…`:`Open`})]})]}),a&&(0,A.jsx)(tw,{onPick:e=>{i(e),o(!1),u(e)},onCancel:()=>o(!1)})]})}function rw({onOpened:e,onCancel:t}){let n=N.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`)?.status===`ok`,[i,a]=(0,k.useState)(null),o=i??(r?`afk`:`identity`);return n.isLoading?(0,A.jsx)(`div`,{className:`open-project`,children:(0,A.jsx)(F,{children:`preparing setup…`})}):o===`project`?(0,A.jsx)(nw,{firstRun:!0,onOpened:e,onCancel:t}):(0,A.jsx)(`div`,{className:`open-project`,children:(0,A.jsxs)(`div`,{className:`op-card wizard-card`,children:[(0,A.jsx)(`div`,{className:`op-logo`,children:(0,A.jsx)(ki,{size:22,variant:`ink`})}),(0,A.jsx)(aw,{current:o}),o===`identity`?(0,A.jsx)(ow,{onNext:()=>a(`afk`)}):(0,A.jsx)(sw,{onNext:()=>a(`project`)})]})})}var iw=[{key:`identity`,label:`Git identity`},{key:`afk`,label:`AFK burns`},{key:`project`,label:`First project`}];function aw({current:e}){let t=iw.findIndex(t=>t.key===e);return(0,A.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Setup progress`,children:iw.map((e,n)=>(0,A.jsxs)(`li`,{className:`wizard-step${n===t?` is-current`:``}${n<t?` is-done`:``}`,children:[(0,A.jsx)(`span`,{className:`wizard-step-dot`,"aria-hidden":!0}),e.label]},e.key))})}function ow({onNext:e}){let[t,n]=(0,k.useState)(``),[r,i]=(0,k.useState)(``),a=Ji(),o=N.useUtils(),s=N.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`op-kick`,children:`WELCOME TO RUNCASTLE`}),(0,A.jsx)(`div`,{className:`op-h`,children:`Set your git identity`}),(0,A.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,A.jsx)(`code`,{className:`mono`,children:`git config --global`}),`.`]}),(0,A.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-name`,children:`Name`}),(0,A.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,A.jsx)(`label`,{className:`op-label`,htmlFor:`wiz-email`,children:`Email`}),(0,A.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,A.jsx)(`div`,{className:`op-actions`,children:(0,A.jsx)(P,{variant:`solid`,onClick:l,disabled:!c||s.isPending,children:s.isPending?`Saving…`:`Continue`})})]})}function sw({onNext:e}){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(RC,{onDismiss:e}),(0,A.jsx)(`div`,{className:`op-actions`,children:(0,A.jsx)(P,{variant:`solid`,onClick:e,children:`Continue to your first project`})})]})}var cw=`runcastle.update.dismissed`;function lw(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function uw(){let e=N.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[t,n]=(0,k.useState)(()=>{try{return localStorage.getItem(cw)}catch{return null}}),r=e.data;return!r||!r.latest||!lw(r,t)?null:(0,A.jsxs)(`div`,{className:`update-banner`,role:`status`,children:[(0,A.jsx)(`span`,{className:`update-banner-dot`,"aria-hidden":`true`}),(0,A.jsxs)(`span`,{className:`update-banner-text`,children:[`runcastle `,(0,A.jsx)(`strong`,{children:r.latest}),` is available`,(0,A.jsx)(`span`,{className:`update-banner-sep`,children:` · `}),(0,A.jsxs)(`span`,{className:`update-banner-dim`,children:[`you're on `,r.current]})]}),(0,A.jsx)(`code`,{className:`update-banner-cmd`,children:r.command}),(0,A.jsx)(`button`,{className:`update-banner-dismiss`,onClick:()=>{try{localStorage.setItem(cw,r.latest)}catch{}n(r.latest)},"aria-label":`Dismiss update notice`,title:`Dismiss`,children:`×`})]})}function dw(){let e=di(),t;return t=e.projects===void 0?(0,A.jsx)(`div`,{className:`app-loading`,children:(0,A.jsx)(F,{children:`loading projects…`})}):e.view===`open`&&e.projects.length===0?(0,A.jsx)(rw,{onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`open`?(0,A.jsx)(nw,{firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen}):e.view===`project`&&e.currentProjectId?(0,A.jsx)(YC,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,A.jsx)(ZC,{nav:e}),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(uw,{}),t]})}function fw(){let e=N.useUtils(),[t,n]=(0,k.useState)(`connecting`),r=(0,k.useRef)(e);return r.current=e,(0,k.useEffect)(()=>{let e=()=>{let e=r.current;e.events.invalidate(),e.feature.list.invalidate(),e.feature.get.invalidate(),e.feature.driveInfo.invalidate(),e.run.get.invalidate(),e.project.list.invalidate(),e.docs.read.invalidate()},t=()=>{r.current.run.agentTranscript.invalidate()},i=new EventSource(`/api/stream`);return i.addEventListener(`ready`,()=>{n(`live`),e(),t()}),i.addEventListener(`live`,r=>{n(`live`);let i;try{i=JSON.parse(r.data)}catch{e();return}i.kind===`transcript`?t():e()}),i.addEventListener(`error`,()=>{n(i.readyState===EventSource.CLOSED?`offline`:`connecting`)}),()=>{i.close()}},[]),t}function pw(){return fw(),(0,A.jsx)(dw,{})}function mw(){let[e]=(0,k.useState)(()=>new Je({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}}})),[t]=(0,k.useState)(()=>N.createClient({links:[qn({url:`/api/trpc`})]}));return(0,A.jsx)(N.Provider,{client:t,queryClient:e,children:(0,A.jsx)(tt,{client:e,children:(0,A.jsx)(qi,{children:(0,A.jsx)(pw,{})})})})}var hw=document.getElementById(`root`);if(!hw)throw Error(`#root not found`);(0,br.createRoot)(hw).render((0,A.jsx)(k.StrictMode,{children:(0,A.jsx)(mw,{})}));
|