offsite 0.0.64 → 0.0.66

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.
@@ -54,4 +54,4 @@ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{c as n,l as r,r as i
54
54
 
55
55
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ka,c=!L.jitless,l=c&&qa.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?_l([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function bl(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=>!po(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=>yo(e,r,Uo())))}),t)}var xl=I(`$ZodUnion`,(e,t)=>{z.init(e,t),F(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),F(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),F(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),F(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Pa(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=>bl(t,r,e,i)):bl(o,r,e,i)}});function Sl(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Cl=I(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,xl.init(e,t);let n=e._zod.parse;F(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Ia(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=La(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Ma(()=>Sl(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Ka(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),wl=I(`$ZodIntersection`,(e,t)=>{z.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])=>El(e,t,n)):El(e,i,a)}});function Tl(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ja(e)&&Ja(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Tl(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=Tl(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 El(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Tl(t.value,n.value);if(!c.valid){if(po(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Dl=I(`$ZodEnum`,(e,t)=>{z.init(e,t);let n=Oa(t.entries),r=new Set(n);e._zod.values=r,F(e,`pattern`,e=>{let t=Oa(e.def.entries).filter(e=>Xa.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Za(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),Ol=I(`$ZodLiteral`,(e,t)=>{z.init(e,t);let n=new Set(t.values);e._zod.values=n,F(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Za(e):e?Za(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),kl=I(`$ZodTransform`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,L.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ho(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));if(i instanceof Promise)throw new Vo;return n.value=i,n}});function Al(e,t){return e.value=t.issues.length?void 0:t.value,e}var jl=I(`$ZodOptional`,(e,t)=>{z.init(e,t),F(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,F(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),F(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Pa(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Al(e,t)):Al(e,r)}return t.innerType._zod.run(e,n)}}),Ml=I(`$ZodExactOptional`,(e,t)=>{jl.init(e,t),F(e,`values`,e=>e.def.innerType._zod.values),F(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Nl=I(`$ZodNullable`,(e,t)=>{z.init(e,t),F(e,`optin`,e=>e.def.innerType._zod.optin),F(e,`optout`,e=>e.def.innerType._zod.optout),F(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Pa(t.source)}|null)$`):void 0}),F(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Pl=I(`$ZodDefault`,(e,t)=>{z.init(e,t),e._zod.optin=`defaulted`,F(e,`values`,e=>e.def.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=>Fl(e,t)):Fl(r,t)}});function Fl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Il=I(`$ZodPrefault`,(e,t)=>{z.init(e,t),e._zod.optin=`defaulted`,F(e,`values`,e=>e.def.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))}),Ll=I(`$ZodNonOptional`,(e,t)=>{z.init(e,t),F(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>Rl(t,e)):Rl(i,e)}});function Rl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function zl(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>yo(e,r,Uo()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Bl=I(`$ZodCatch`,(e,t)=>{z.init(e,t),F(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),F(e,`optout`,e=>e.def.innerType._zod.optout),F(e,`values`,e=>e.def.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({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>zl(e,r,t,n)):zl(e,r,t,n)}}),Vl=I(`$ZodPipe`,(e,t)=>{z.init(e,t),F(e,`values`,e=>e.def.in._zod.values),F(e,`optin`,e=>e.def.in._zod.optin),F(e,`optout`,e=>e.def.out._zod.optout),F(e,`propValues`,e=>e.def.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=>Hl(e,t.in,n)):Hl(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Hl(e,t.out,n)):Hl(r,t.out,n)}});function Hl(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Ul=I(`$ZodReadonly`,(e,t)=>{z.init(e,t),F(e,`propValues`,e=>e.def.innerType._zod.propValues),F(e,`values`,e=>e.def.innerType._zod.values),F(e,`optin`,e=>e.def.innerType?._zod?.optin),F(e,`optout`,e=>e.def.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(Wl):Wl(r)}});function Wl(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Gl=I(`$ZodCustom`,(e,t)=>{R.init(e,t),z.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=>Kl(t,n,r,e));Kl(i,n,r,e)}});function Kl(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(wo(e))}}var ql=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Jl=`~memo`,Yl=[];function Xl(e){return typeof e==`object`&&!!e}function Zl(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Ql=new WeakMap,$l=0,eu=1,tu=2;function nu(e,t,n){let r=Ql.get(e);if(r!==void 0)return r?tu:$l;if(t.has(e))return tu;t.add(e);let i=$l,a=e=>{if(i!==tu&&e?._zod){let r=nu(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=$l;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?eu:o.value?._zod?nu(o.value,t,n):$l;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=La(c);s(e?o(e,!0):eu),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?nu(r,t,!1):eu);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),ru(e,i)}function ru(e,t){return t!==eu&&Ql.set(e,t===tu),t}function iu(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var au,ou=[],su={alloc(e,t,n){let r=au;if(!r)return n;au=void 0;let i={value:n,issues:null};return r.set(t.value,i),ou.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&lu(n,e.value))throw new ql;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=nu(e,new Set,!1);if(i===$l)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===tu||r?n=!0:r=!0}let l=s.value;if(!Xl(l))return t(s,c);let u=c[Jl];u||(u={buckets:new WeakMap,backEdges:void 0},c[Jl]=u);let d;i===c?d=a:(d=iu(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Zl(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;au=d;let p=ou.length,m=t(s,c);au=void 0;let h=ou.length>p?ou.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Zl(e.issues):Yl),e)):(h&&(h.issues=m.issues.length?Zl(m.issues):Yl),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function cu(){return su}function lu(e,t){let n=e[Jl]?.backEdges;return n!==void 0&&Xl(t)&&n.has(t)}var uu=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Co(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${$a(e.values[0])}`:`Invalid option: expected one of ${ka(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${ka(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function du(){return{localeError:uu()}}var fu,pu=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 mu(){return new pu}(fu=globalThis).__zod_globalRegistry??(fu.__zod_globalRegistry=mu());var hu=globalThis.__zod_globalRegistry;function gu(e){return e.checks&&=[...e.checks],e}function _u(e,t){return new e(gu({type:`string`,...P(t)}))}function vu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...P(t)})}function yu(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...P(t)})}function bu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...P(t)})}function xu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...P(t)})}function Su(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...P(t)})}function Cu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...P(t)})}function wu(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...P(t)})}function Tu(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...P(t)})}function Eu(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...P(t)})}function Du(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...P(t)})}function Ou(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...P(t)})}function ku(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...P(t)})}function Au(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...P(t)})}function ju(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...P(t)})}function Mu(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...P(t)})}function Nu(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...P(t)})}function Pu(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...P(t)})}function Fu(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...P(t)})}function Iu(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...P(t)})}function Lu(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...P(t)})}function Ru(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...P(t)})}function zu(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...P(t)})}function Bu(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...P(t)})}function Vu(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...P(t)})}function Hu(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...P(t)})}function Uu(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...P(t)})}function Wu(e,t){return new e(gu({type:`number`,checks:[],...P(t)}))}function Gu(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...P(t)})}function Ku(e,t){return new e({type:`boolean`,...P(t)})}function qu(e){return new e({type:`unknown`})}function Ju(e,t){return new e({type:`never`,...P(t)})}function Yu(e,t){return new ec({check:`less_than`,...P(t),value:e,inclusive:!1})}function Xu(e,t){return new ec({check:`less_than`,...P(t),value:e,inclusive:!0})}function Zu(e,t){return new tc({check:`greater_than`,...P(t),value:e,inclusive:!1})}function Qu(e,t){return new tc({check:`greater_than`,...P(t),value:e,inclusive:!0})}function $u(e,t){return new nc({check:`multiple_of`,...P(t),value:e})}function ed(e,t){return new ic({check:`max_length`,...P(t),maximum:e})}function td(e,t){return new ac({check:`min_length`,...P(t),minimum:e})}function nd(e,t){return new oc({check:`length_equals`,...P(t),length:e})}function rd(e,t){return new cc({check:`string_format`,format:`regex`,...P(t),pattern:e})}function id(e){return new lc({check:`string_format`,format:`lowercase`,...P(e)})}function ad(e){return new uc({check:`string_format`,format:`uppercase`,...P(e)})}function od(e,t){return new dc({check:`string_format`,format:`includes`,...P(t),includes:e})}function sd(e,t){return new fc({check:`string_format`,format:`starts_with`,...P(t),prefix:e})}function cd(e,t){return new pc({check:`string_format`,format:`ends_with`,...P(t),suffix:e})}function ld(e){return new mc({check:`overwrite`,tx:e})}function ud(e){return ld(t=>t.normalize(e))}function dd(){return ld(e=>e.trim())}function fd(){return ld(e=>e.toLowerCase())}function pd(){return ld(e=>e.toUpperCase())}function md(){return ld(e=>Wa(e))}function hd(e,t,n){return new e({type:`array`,element:t,...P(n)})}function gd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...P(n)})}function _d(e,t){let n=vd(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(wo(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(wo(r))}},e(t.value,t)),t);return n}function vd(e,t){let n=new R({check:`custom`,...P(t)});return n._zod.check=e,n}function yd(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ia(e,t,n[t]);return e}function bd(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??hu,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function xd(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function V(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),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;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,V(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&yd(o.schema,c),t.io===`input`&&H(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 Sd(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Cd(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;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}/${Sd(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Sd(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>
56
56
 
57
- 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);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function wd(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;wd(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Td=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ed=[`oneOf`,`anyOf`];function Dd(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Od(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Td.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Dd(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ia(n,r,e.length===1?e[0]:Od(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Dd(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function kd(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Td)if(t in e)return;let n=t.filter(e=>Ed.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Od(t);else{let e=n[0],i=Ed.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Od([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,yd(e,r))}function Ad(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)):yd(i,s),yd(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())wd(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])kd(e)}}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)}yd(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ia(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:Md(t,`input`,e.processors),output:Md(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function H(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 H(r.element,n);if(r.type===`set`)return H(r.valueType,n);if(r.type===`lazy`)return H(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`||r.type===`catch`)return H(r.innerType,n);if(r.type===`intersection`)return H(r.left,n)||H(r.right,n);if(r.type===`record`||r.type===`map`)return H(r.keyType,n)||H(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:H(r.in,n)||H(r.out,n);if(r.type===`object`){for(let e in r.shape)if(H(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(H(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(H(e,n))return!0;return!!(r.rest&&H(r.rest,n))}return!1}var jd=(e,t={})=>n=>{let r=bd({...n,processors:t});return V(e,r),Cd(r,e),Ad(r,e)},Md=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=bd({...i??{},target:a,io:t,processors:n});return V(e,o),Cd(o,e),Ad(o,e)},Nd=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Pd=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Fd=(e,t)=>{Nd(e,`minimum`,t),Pd(e,`maximum`,t)},Id=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ld=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Rd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},zd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Bd=(e,t)=>Nd(e,`minimum`,t.minimum),Vd=(e,t)=>Pd(e,`maximum`,t.maximum),Hd=e=>(t,n)=>{zd(t,n.format);let[r,i]=e[n.format];Nd(t,`minimum`,r),Pd(t,`maximum`,i)},Ud={greater_than:(e,t)=>Nd(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Pd(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Id(e,t.value),number_format:Hd(to),bigint_format:Hd(no),min_length:Bd,max_length:Vd,length_equals:(e,t)=>Fd(e,t.length),min_size:Bd,max_size:Vd,size_equals:(e,t)=>Fd(e,t.size),string_format:(e,t)=>{zd(e,t.format),t.pattern&&Ld(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Rd(e,t.mime)};function U(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ud[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Nd(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Nd(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Pd(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Pd(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Id(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Rd(t,i.mime);for(let e of i.patterns??[])Ld(t,e);return t}var Wd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Gd=new Map([[Zc,Ls],[$c,Rs]]),Kd=e=>Gd.get(e)??e,qd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=U(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Wd[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Kd);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}))])}},Jd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=U(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):xd(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Yd=(e,t,n,r)=>{n.type=`boolean`},Xd=(e,t,n,r)=>{n.not={}},Zd=(e,t,n,r)=>{let i=e._zod.def,a=Oa(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Qd=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(xd(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(xd(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},$d=(e,t,n,r)=>{xd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ef=(e,t,n,r)=>{xd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},tf=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=U(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=V(a.element,t,{...r,path:[...r.path,`items`]})};function nf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?nf(t.out):t.type===`catch`?nf(t.innerType):e._zod.optin}var rf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&xd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ia(i.properties,e,V(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?nf(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=V(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},af=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>V(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},of=(e,t,n,r)=>{let i=e._zod.def,a=V(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=V(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},sf=(e,t,n,r)=>{let i=e._zod.def,a=V(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`}]},cf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},lf=Symbol();function uf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(xd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),lf):JSON.parse(o)}var df=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=uf(i.defaultValue,e,t,n,r);o!==lf&&(n.default=o)},ff=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=uf(i.defaultValue,e,t,n,r);o!==lf&&(n._prefault=o)},pf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{xd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},mf=(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;V(o,t,r);let s=t.seen.get(e);s.ref=o},hf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},gf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_f=new WeakSet([Object.prototype,Error.prototype]);function vf(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var W=I(`ZodError`,(e,t)=>{Yo.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);_f.has(n)||(_f.add(n),vf(n,`format`,e=>t=>Qo(e,t)),vf(n,`flatten`,e=>t=>Zo(e,t)),vf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Aa,2)}),vf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Aa,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),yf=ns(W),bf=rs(W),xf=is(W),Sf=os(W),Cf=fs(W),wf=ps(W),Tf=ms(W),Ef=hs(W),Df=gs(W),Of=_s(W),kf=vs(W),Af=ys(W);function jf(){L.localeError||Uo(du())}function Mf(){L.memoizer||Uo({memoizer:cu()})}var G=I(`ZodType`,(e,t)=>(jf(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(N(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 Qa(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xp(e,t))},superRefine(e,t){return this.check(Zp(e,t))},overwrite(e){return this.check(ld(e))},optional(){return Mp(this)},exactOptional(){return Pp(this)},nullable(){return Ip(this)},nullish(){return Mp(Ip(this))},nonoptional(e){return Hp(this,e)},array(){return hp(this)},or(e){return bp([this,e])},and(e){return wp(this,e)},transform(e){return Kp(this,Ap(e))},default(e){return Rp(this,e)},prefault(e){return Bp(this,e)},catch(e){return Wp(this,e)},pipe(e){return Kp(this,e)},readonly(){return Jp(this)},describe(e){let t=this.clone();return hu.add(t,{description:e}),t},meta(...e){if(e.length===0)return hu.get(this);let t=this.clone();return hu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Do(this,`~standard`,{...yc(this),jsonSchema:{input:Md(this,`input`),output:Md(this,`output`)}})},set"~standard"(e){Eo(this,`~standard`,e)},parse:function e(t,n){return yf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await bf(this,t,n,{callee:e})},safeParse(e,t){return xf(this,e,t)},async safeParseAsync(e,t){return Sf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Eo(this,`spa`,e)},validate(e,t){return ls(this,e,t)},validateAsync(e,t){return ds(this,e,t)},encode:function e(t,n){return Cf(this,t,n,{callee:e})},decode:function e(t,n){return wf(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Tf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ef(this,t,n,{callee:e})},safeEncode(e,t){return Df(this,e,t)},safeDecode(e,t){return Of(this,e,t)},async safeEncodeAsync(e,t){return kf(this,e,t)},async safeDecodeAsync(e,t){return Af(this,e,t)},toJSONSchema(e){return jd(this,{})(e)},get description(){return hu.get(this)?.description},get _def(){return this._zod.def}}),Nf=I(`_ZodString`,(e,t)=>{bc.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qd(e,t,n,r)},Oo({format:e=>U(e).format??null,minLength:e=>U(e).minimum??null,maxLength:e=>U(e).maximum??null},{regex(...e){return this.check(rd(...e))},includes(...e){return this.check(od(...e))},startsWith(...e){return this.check(sd(...e))},endsWith(...e){return this.check(cd(...e))},min(...e){return this.check(td(...e))},max(...e){return this.check(ed(...e))},length(...e){return this.check(nd(...e))},nonempty(...e){return this.check(td(1,...e))},lowercase(e){return this.check(id(e))},uppercase(e){return this.check(ad(e))},trim(){return this.check(dd())},normalize(...e){return this.check(ud(...e))},toLowerCase(){return this.check(fd())},toUpperCase(){return this.check(pd())},slugify(){return this.check(md())}})),Pf=I(`ZodString`,(e,t)=>{bc.init(e,t),Nf.init(e,t)},{email(e){return this.check(vu(Bf,e))},url(e){return this.check(wu(Uf,e))},jwt(e){return this.check(zu(ip,e))},emoji(e){return this.check(Tu(Wf,e))},guid(e){return this.check(yu(Vf,e))},uuid(e){return this.check(bu(Hf,e))},uuidv4(e){return this.check(xu(Hf,e))},uuidv6(e){return this.check(Su(Hf,e))},uuidv7(e){return this.check(Cu(Hf,e))},nanoid(e){return this.check(Eu(Gf,e))},cuid(e){return this.check(Du(Kf,e))},cuid2(e){return this.check(Ou(qf,e))},ulid(e){return this.check(ku(Jf,e))},base64(e){return this.check(Iu(tp,e))},base64url(e){return this.check(Lu(np,e))},xid(e){return this.check(Au(Yf,e))},ksuid(e){return this.check(ju(Xf,e))},ipv4(e){return this.check(Mu(Zf,e))},ipv6(e){return this.check(Nu(Qf,e))},cidrv4(e){return this.check(Pu($f,e))},cidrv6(e){return this.check(Fu(ep,e))},e164(e){return this.check(Ru(rp,e))},datetime(e){return this.check(Bu(If,e))},date(e){return this.check(Vu(Lf,e))},time(e){return this.check(Hu(Rf,e))},duration(e){return this.check(Uu(zf,e))}});function Ff(e){return _u(Pf,e)}var K=I(`ZodStringFormat`,(e,t)=>{B.init(e,t),Nf.init(e,t)}),If=I(`ZodISODateTime`,(e,t)=>{zc.init(e,t),K.init(e,t)}),Lf=I(`ZodISODate`,(e,t)=>{Bc.init(e,t),K.init(e,t)}),Rf=I(`ZodISOTime`,(e,t)=>{Vc.init(e,t),K.init(e,t)}),zf=I(`ZodISODuration`,(e,t)=>{Hc.init(e,t),K.init(e,t)}),Bf=I(`ZodEmail`,(e,t)=>{Cc.init(e,t),K.init(e,t)}),Vf=I(`ZodGUID`,(e,t)=>{xc.init(e,t),K.init(e,t)}),Hf=I(`ZodUUID`,(e,t)=>{Sc.init(e,t),K.init(e,t)}),Uf=I(`ZodURL`,(e,t)=>{jc.init(e,t),K.init(e,t)}),Wf=I(`ZodEmoji`,(e,t)=>{Mc.init(e,t),K.init(e,t)}),Gf=I(`ZodNanoID`,(e,t)=>{Nc.init(e,t),K.init(e,t)}),Kf=I(`ZodCUID`,(e,t)=>{Pc.init(e,t),K.init(e,t)}),qf=I(`ZodCUID2`,(e,t)=>{Fc.init(e,t),K.init(e,t)}),Jf=I(`ZodULID`,(e,t)=>{Ic.init(e,t),K.init(e,t)}),Yf=I(`ZodXID`,(e,t)=>{Lc.init(e,t),K.init(e,t)}),Xf=I(`ZodKSUID`,(e,t)=>{Rc.init(e,t),K.init(e,t)}),Zf=I(`ZodIPv4`,(e,t)=>{Uc.init(e,t),K.init(e,t)}),Qf=I(`ZodIPv6`,(e,t)=>{Kc.init(e,t),K.init(e,t)}),$f=I(`ZodCIDRv4`,(e,t)=>{qc.init(e,t),K.init(e,t)}),ep=I(`ZodCIDRv6`,(e,t)=>{Yc.init(e,t),K.init(e,t)}),tp=I(`ZodBase64`,(e,t)=>{Qc.init(e,t),K.init(e,t)}),np=I(`ZodBase64URL`,(e,t)=>{tl.init(e,t),K.init(e,t)}),rp=I(`ZodE164`,(e,t)=>{nl.init(e,t),K.init(e,t)}),ip=I(`ZodJWT`,(e,t)=>{il.init(e,t),K.init(e,t)}),ap=I(`ZodNumber`,(e,t)=>{al.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jd(e,t,n,r),e.isFinite=!0},Oo({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=U(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=U(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=U(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>U(e).format??null},{gt(e,t){return this.check(Zu(e,t))},gte(e,t){return this.check(Qu(e,t))},min(e,t){return this.check(Qu(e,t))},lt(e,t){return this.check(Yu(e,t))},lte(e,t){return this.check(Xu(e,t))},max(e,t){return this.check(Xu(e,t))},int(e){return this.check(cp(e))},safe(e){return this.check(cp(e))},positive(e){return this.check(Zu(0,e))},nonnegative(e){return this.check(Qu(0,e))},negative(e){return this.check(Yu(0,e))},nonpositive(e){return this.check(Xu(0,e))},multipleOf(e,t){return this.check($u(e,t))},step(e,t){return this.check($u(e,t))},finite(){return this}}));function op(e){return Wu(ap,e)}var sp=I(`ZodNumberFormat`,(e,t)=>{ol.init(e,t),ap.init(e,t)});function cp(e){return Gu(sp,e)}var lp=I(`ZodBoolean`,(e,t)=>{sl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yd(e,t,n,r)});function q(e){return Ku(lp,e)}var up=I(`ZodUnknown`,(e,t)=>{cl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function dp(){return qu(up)}var fp=I(`ZodNever`,(e,t)=>{ll.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xd(e,t,n,r)});function pp(e){return Ju(fp,e)}var mp=I(`ZodArray`,(e,t)=>{Mf(),pl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(e,t,n,r),e.element=t.element},{min(e,t){return this.check(td(e,t))},nonempty(e){return this.check(td(1,e))},max(e,t){return this.check(ed(e,t))},length(e,t){return this.check(nd(e,t))},unwrap(){return this.element}});function hp(e,t){return hd(mp,e,t)}var gp=I(`ZodObject`,(e,t)=>{Mf(),yl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r),Po(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ep(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(N(this._zod.def,{catchall:e}))},passthrough(){return this.clone(N(this._zod.def,{catchall:dp()}))},loose(){return this.clone(N(this._zod.def,{catchall:dp()}))},strict(){return this.clone(N(this._zod.def,{catchall:pp()}))},strip(){return this.clone(N(this._zod.def,{catchall:void 0}))},extend(e){return oo(this,e)},safeExtend(e){return co(this,e)},merge(e){return lo(this,e)},pick(e){return ro(this,e)},omit(e){return ao(this,e)},partial(...e){return uo(jp,this,e[0])},exactPartial(...e){return uo(Np,this,e[0],`exactPartial`)},required(...e){return fo(Vp,this,e[0])}});function _p(e,t){return new gp({type:`object`,shape:e??{},...P(t)})}function vp(e,t){return new gp({type:`object`,shape:e,catchall:pp(),...P(t)})}var yp=I(`ZodUnion`,(e,t)=>{xl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e.options=t.options});function bp(e,t){return new yp({type:`union`,options:e,...P(t)})}var xp=I(`ZodDiscriminatedUnion`,(e,t)=>{yp.init(e,t),Cl.init(e,t)});function Sp(e,t,n){return new xp({type:`union`,options:t,discriminator:e,...P(n)})}var Cp=I(`ZodIntersection`,(e,t)=>{wl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r)});function wp(e,t){return new Cp({type:`intersection`,left:e,right:t})}var Tp=I(`ZodEnum`,(e,t)=>{Dl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Tp({...t,checks:[],...P(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 Tp({...t,checks:[],...P(r),entries:i})}});function Ep(e,t){return new Tp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...P(t)})}var Dp=I(`ZodLiteral`,(e,t)=>{Ol.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Op(e,t){return new Dp({type:`literal`,values:Array.isArray(e)?e:[e],...P(t)})}var kp=I(`ZodTransform`,(e,t)=>{Mf(),kl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ho(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wo(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(wo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ap(e){return new kp({type:`transform`,transform:e})}var jp=I(`ZodOptional`,(e,t)=>{jl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mp(e){return new jp({type:`optional`,innerType:e})}var Np=I(`ZodExactOptional`,(e,t)=>{Ml.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new Np({type:`optional`,innerType:e})}var Fp=I(`ZodNullable`,(e,t)=>{Nl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Fp({type:`nullable`,innerType:e})}var Lp=I(`ZodDefault`,(e,t)=>{Pl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Rp(e,t){return new Lp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ya(t)}})}var zp=I(`ZodPrefault`,(e,t)=>{Il.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e,t){return new zp({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ya(t)}})}var Vp=I(`ZodNonOptional`,(e,t)=>{Ll.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hp(e,t){return new Vp({type:`nonoptional`,innerType:e,...P(t)})}var Up=I(`ZodCatch`,(e,t)=>{Bl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wp(e,t){return new Up({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Io(t)})}var Gp=I(`ZodPipe`,(e,t)=>{Vl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mf(e,t,n,r),e.in=t.in,e.out=t.out});function Kp(e,t){return new Gp({type:`pipe`,in:e,out:t})}var qp=I(`ZodReadonly`,(e,t)=>{Ul.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jp(e){return new qp({type:`readonly`,innerType:e})}var Yp=I(`ZodCustom`,(e,t)=>{Gl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r)});function Xp(e,t={}){return gd(Yp,e,t)}function Zp(e,t){return _d(e,t)}function Qp(){return J.parseLocation(J.history.location).search}function $p(){let e=/^\/terminal\/([^/]+)$/.exec(J.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Y().machines.some(e=>e.id===t)?t:null}function em(){let e=Lr({strict:!1,select:e=>e.machine??null});return mh(t=>t.machines.some(t=>t.id===e)?e:null)}function tm(){return Qp().project??`global`}function nm(){return Rr({strict:!1,select:e=>e.project??`global`})}function rm(e){let t=Qp();return t.machine===void 0||t.project===void 0||!e.includes(t.machine)?null:{machine:t.machine,projectId:t.project,sessionId:t.session??null}}function im(e){um({...Qp(),...e},!0,J.history.location.state.layer)}function am(e,t){um({...Qp(),...e},!1,t)}function om(e){let t=Y();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){im({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){im({panel:`browser`,browse:e});return}let n=hh(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);im({panel:`browser`,browse:`${n.path}/${e}`})}function sm(e,t){J.history.location.state.layer===e?J.history.back():t()}function cm(e,t){let n=(0,k.useEffectEvent)(t);(0,k.useEffect)(()=>{if(!e)return;let t,r=setTimeout(()=>{J.history.push(J.history.location.href);let e=J.history.location.state.__TSR_index,r=J.history.subscribe(()=>{J.history.location.state.__TSR_index<e&&n()});t=()=>{r(),J.history.location.state.__TSR_index===e&&J.history.back()}});return()=>{clearTimeout(r),t?.()}},[e])}function lm(){let e=Y().selection;if(e===null){um({project:$p()===null?void 0:Qp().project},!0,J.history.location.state.layer);return}let t={machine:e.machine,project:e.projectId,session:e.sessionId??void 0};$p()===null?Qp().machine===void 0?am(t,`chat`):im(t):J.navigate({to:`/`,search:t,state:{layer:`chat`},resetScroll:!1})}function um(e,t,n){let r=$p();r===null?J.navigate({to:`/`,search:e,replace:t,state:{layer:n},resetScroll:!1}):J.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t,state:{layer:n},resetScroll:!1})}function dm(e,t=null){let n=Z(Y(),e.machine),r=Y().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),X({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?r?.sessionId===null&&r.machine===e.machine?Y().settings:Bh(n):Ea(bh(e))??zh(n.composer,Y().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??n.composer?.provider??`claude`),context:null,paletteOpen:!1,unseen:Y().unseen.filter(t=>e.sessionId===null||t!==Vm(e.machine,e.sessionId))}),lm(),Wh(e.machine),e.sessionId!==null&&n.status===`online`&&fm(e.machine,e.projectId,e.sessionId,!0,t)}function fm(e,t,n,r,i){M(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Y().sessions.some(n=>n.machine===e&&n.id===t.id)||X({sessions:[...Y().sessions,{...t,machine:e}]})}).catch($)}function pm(){X({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),lm()}function mm(){let e=Y().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function hm(e,t){let n=$p();(n!==e||tm()!==t)&&(J.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null,state:{layer:`chat`},resetScroll:!1}),pm())}async function gm(e,t,n,r){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),X({sentAt:Date.now()}),await M(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t})}function _m(e){let t=Y().selection;t!==null&&t.sessionId!==null&&M(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function vm(e){let t=Y().selection;t!==null&&t.sessionId!==null&&M(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function ym(){let e=Y().selection;e!==null&&e.sessionId!==null&&M(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function bm(e,t,n){M(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function xm(e,t,n){let r=Y().selection;r!==null&&r.sessionId!==null&&M(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function Sm(e){let t=Y().selection;if(t!==null&&t.sessionId!==null)try{let n=await M(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});dm({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Cm(){let e=Y().selection,t=Y().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await M(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Y().selection!==e||Y().before!==t)return;X({earlier:[...n.items,...Y().earlier],before:n.before})}catch(e){$(e)}}async function wm(e,t){let n=Y().selection;if(n!==null&&n.sessionId!==null)try{let r=await M(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Y().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Y().items;X({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Tm(e,t,n){let r=Y();function i(n){return n.machine===e&&n.id===t}let a=[...r.sessions,...r.inactive].find(i);if(a!==void 0){let e={...a,...n};X({sessions:r.sessions.some(i)?r.sessions.map(t=>i(t)?e:t):e.status===`inactive`?r.sessions:[...r.sessions,e],inactive:e.status===`inactive`?r.inactive.some(i)?r.inactive.map(t=>i(t)?e:t):[e,...r.inactive]:r.inactive.filter(e=>!i(e))})}try{await M(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Em(e){let t=Vm(e.machine,e.id);X({generatingTitles:[...Y().generatingTitles,t]});try{await M(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{X({generatingTitles:Y().generatingTitles.filter(e=>e!==t)})}}async function Dm(e,t,n){let r=Y().selection;if(r?.machine===e&&r.sessionId===t){let i=Y().sessions.filter(r=>(r.status===`pinned`||r.status===`active`||r.status===`snoozed`)&&(r.machine!==e||r.id!==t)&&(n===null||r.machine===n.machine&&r.projectId===n.projectId)).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);dm(i===void 0?{...r,sessionId:null}:{machine:i.machine,projectId:i.projectId,sessionId:i.id})}await Tm(e,t,{status:`inactive`})}async function Om(e,t){X({sessions:Y().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Y().inactive.filter(n=>n.machine!==e||n.id!==t)}),wa(Vm(e,t));let n=Y().selection;n?.machine===e&&n.sessionId===t&&dm({...n,sessionId:null});try{await M(e,`sessions.remove`,{id:t})}catch(e){$(e)}}var km=_p({machine:Ff().optional().catch(void 0),project:Ff().optional().catch(void 0),session:Ff().optional().catch(void 0),panel:Ep([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:Ff().optional().catch(void 0),bottom:Op(`terminal`).optional().catch(void 0),terminal:Ff().optional().catch(void 0)}),Am=oi({validateSearch:km}),jm=ii({getParentRoute:()=>Am,path:`/`}),Mm=ii({getParentRoute:()=>Am,path:`/terminal`,beforeLoad:()=>{let e=mm();throw st(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Nm=ii({getParentRoute:()=>Am,path:`/terminal/$machine`}),J=ci({routeTree:Am.addChildren([jm,Mm,Nm]),disableGlobalCatchBoundary:!0,parseSearch:e=>km.parse(Object.fromEntries(new URLSearchParams(e))),stringifySearch:e=>{let t=new URLSearchParams;for(let n of Object.entries(e))n[1]!==void 0&&t.set(n[0],String(n[1]));let n=t.toString();return n===``?``:`?${n}`}}),Pm=`machines`,Fm=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function Im(){let e=localStorage.getItem(Pm);return e===null?[]:JSON.parse(e)}function Lm(e){localStorage.setItem(Pm,JSON.stringify(e))}async function Rm(e){if(!(`caches`in window))return;let t=e.map(e=>({id:e.id,addresses:e.addresses}));await(await caches.open(`offsite-worker`)).put(`/machines`,new Response(JSON.stringify(t)))}function zm(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));J.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:Bm(t).address,code:e.get(`code`)}}function Bm(e){let t=e.trim(),n=new URL(/^[a-z]+:\/\//i.test(t)?t:`http://${t}`);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`Use an http:// or https:// address`);let r=new URLSearchParams(n.hash.slice(1)),i=r.get(`machine`);return{address:i===null?n.origin:Bm(i).address,code:r.get(`code`)}}function Vm(e,t){return`${e} ${t}`}function Hm(e){return{id:e.id,addresses:e.addresses,via:null,status:`connecting`,name:e.label??e.name,hostname:e.name,label:e.label,icon:e.icon,pairedAt:e.pairedAt??null,config:null,composer:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function Um(e){return e.projects.map(t=>({...t,machine:e.id}))}function Wm(){let e=Im(),t=Y().machines;for(let n of t)e.some(e=>e.id===n.id)||$m(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Y();X({machines:[...e.machines,Hm(n)],projects:[...e.projects,...Um(n)]}),Ii(n.id,n.addresses)}else Q(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(Q(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),Zm(n.id))}let n=e.map(e=>e.id);X({machines:[...Y().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function Gm(e,t){let n=Y().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await Km(n.id,t),n.id;let r=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);return t!==null&&await Si(r,await qm(e,t)),X({machines:[...Y().machines,Hm({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),eh(),Ii(r,e),r}async function Km(e,t){await Si(e,await qm(Z(Y(),e).addresses,t)),Q(e,{pairedAt:Date.now()}),eh(),Zm(e)}async function qm(e,t){let n;for(let r of e){let e=await fetch(`${r}/api/pair`,{method:`POST`,headers:{authorization:`Bearer ${t}`}}).catch(e=>(n??=e,null));if(e!==null){if(!e.ok)throw Error(await e.text());return(await e.json()).token}}throw Error(`Could not reach the machine to pair: ${String(n)}`)}function Jm(e,t){let n=Z(Y(),e),r={...n,...t};Q(e,{...t,name:r.label??r.hostname}),eh(),r.addresses.join(` `)!==n.addresses.join(` `)&&Zm(e)}function Ym(e){X({machines:[...Y().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),eh()}function Xm(e){Rm(e).catch(e=>console.error(`could not share the machines with the service worker`,e))}function Zm(e){Li(e),Q(e,{status:`connecting`,via:null}),Ii(e,Z(Y(),e).addresses)}function Qm(e){$m(e),eh(),Ci(e).catch(e=>console.error(`could not remove the device token`,e))}function $m(e){Li(e);let t=Y(),n=t.machines.filter(t=>t.id!==e);X({machines:n,projects:t.projects.filter(t=>t.machine!==e),sessions:t.sessions.filter(t=>t.machine!==e),inactive:t.inactive.filter(t=>t.machine!==e),unseen:t.unseen.filter(t=>!t.startsWith(`${e} `)),...t.settingsMachine===e&&{settingsMachine:n.at(0)?.id??null},...t.selection?.machine===e&&{selection:null}}),lm()}function eh(){let e=Y(),t=e.machines.map(t=>({id:t.id,addresses:t.addresses,name:t.hostname,label:t.label,icon:t.icon,pairedAt:t.pairedAt,projects:e.projects.filter(e=>e.machine===t.id).map(e=>({id:e.id,path:e.path,name:e.name,logo:e.logo,hidden:e.hidden}))}));Lm(t),Xm(t)}var th=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}],nh=vp({theme:Ff().refine(e=>th.some(t=>t.id===e)).default(th[0].id),terminal:vp({font:vp({family:Ff().default(`FiraCode Nerd Font`),size:op().default(14),lineHeight:op().default(1.35),ligatures:q().default(!0)}).prefault({}),cursor:vp({style:Ep([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),padding:vp({top:op().default(4),right:op().default(4),bottom:op().default(0),left:op().default(4)}).prefault({}),scrollback:op().default(1e3),boldIsBright:q().default(!0),behavior:vp({modernizeShiftEnter:q().default(!0),pasteBrowserImages:q().default(!0),captureShortcuts:q().default(!0),bellFlash:q().default(!0),bellSound:q().default(!0),clickToMoveCursor:q().default(!0),optionAsMeta:Ep([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:q().default(!0),confirmCloseBusyTab:q().default(!0)}).prefault({})}).prefault({}),editor:vp({font:vp({family:Ff().default(`FiraCode Nerd Font`),size:op().default(15.3),lineHeight:op().default(1.8),ligatures:q().default(!0),features:Ff().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:vp({style:Ep([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),tabSize:op().default(2),wordWrap:q().default(!0),graph:q().default(!0)}).prefault({}),diff:vp({split:q().default(!1),wrap:q().default(!0),collapsed:q().default(!1)}).prefault({}),rewind:Ep([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:q().default(!1)}),rh=`prefs`,ih=nh.parse({});function ah(){let e=localStorage.getItem(rh);if(e===null)return structuredClone(ih);let t=nh.safeParse(JSON.parse(e));return t.success?t.data:(console.warn(`invalid stored prefs, using the defaults:\n${es(t.error)}`),structuredClone(ih))}function oh(e){localStorage.setItem(rh,JSON.stringify(e))}function sh(){let e=Y().prefs.theme,t=th.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function ch(){let e=mh(e=>e.prefs.theme),t=th.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function lh(){let e=sh(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}var uh={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},dh;function fh(e){dh=aa()(()=>e)}function ph(e){return dh.subscribe(e)}function Y(){return dh.getState()}function mh(e){return sa(dh,e)}function X(e){dh.setState(e)}function Z(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function hh(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function gh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function Q(e,t){X({machines:Y().machines.map(n=>n.id===e?{...n,...t}:n)})}function _h(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function vh(e){let t=e.selection;if(t!==null)return _h(e.machines,t.machine,t.sessionId)}function yh(e){return vh(e)?.running===!0}function bh(e){return e.sessionId===null?`new`:Vm(e.machine,e.sessionId)}function xh(e){X({draft:e})}function Sh(e){X({paletteOpen:e})}function Ch(e){X({editor:e})}function wh(e){X({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:gh(Y()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Th(e){X({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Y().settingsOpen&&{settingsMachine:gh(Y())}})}function Eh(e){X({prefs:e}),oh(e),lh()}function $(e){X({errors:[...Y().errors,i(e)]})}function Dh(){X({errors:[]})}function Oh(e){let t=new Map;function n(t,n){Y().machines.some(e=>e.id===t)&&e.apply(t,n)}async function r(r,a){let o=await e.save(r,a),s=t.get(r);s!==void 0&&(--s.writes,s.writes>0||(o===null?await i(r):n(r,o)))}async function i(r){let i=t.get(r)?.version;try{let a=await e.load(r),o=t.get(r);o!==void 0&&o.writes===0&&o.version===i&&n(r,a)}catch(e){$(e)}}return{update(n,i){e.set(n,i);let a=t.get(n)??{writes:0,version:0,timer:void 0};t.set(n,a),a.timer===void 0&&(a.writes+=1),a.version+=1,window.clearTimeout(a.timer),a.timer=window.setTimeout(()=>{a.timer=void 0,r(n,i)},300)},receive(e,r){(t.get(e)?.writes??0)===0&&n(e,r)}}}var kh=Oh({set:Fh,save:async(e,t)=>{try{let n=await M(e,`config.save`,t);return Q(e,{configError:null}),n}catch(t){return Q(e,{configError:i(t)}),null}},load:async e=>(await M(e,`config.get`,void 0)).config,apply:Fh}),Ah=Oh({set:(e,t)=>Q(e,{composer:t}),save:async(e,t)=>{try{return await M(e,`composer.save`,t)}catch(e){return $(e),null}},load:e=>M(e,`composer.get`,void 0),apply:Ih}),jh=kh.update,Mh=kh.receive,Nh=Ah.update,Ph=Ah.receive;function Fh(e,t){let n=Z(Y(),e).config;Q(e,{config:t}),n!==null&&ra(n.newThreads,t.newThreads)||Uh(e)}function Ih(e,t){let n=Z(Y(),e).composer;Q(e,{composer:t});let r=Y().selection;if(r===null||r.machine!==e)return;if(r.sessionId===null){n===null&&Uh(e);return}if(_h(Y().machines,e,r.sessionId)!==void 0)return;let i=Ea(bh(r))??zh(t,Y().settings.provider),a=i.provider!==Y().settings.provider||i.accountId!==Y().settings.accountId;X({settings:i}),a&&Kh()}var Lh=null,Rh={provider:`claude`,accountId:null,model:null,effort:null,mode:null,plan:!1};function zh(e,t){return e===null?{...Rh,provider:t}:{provider:t,...e[t]}}function Bh(e){if(e.config===null)return Rh;let t=e.config.newThreads;return{...zh(e.composer,t.provider),accountId:t.accountId,model:t.models[t.provider],effort:null}}function Vh(e){let t={...Y().settings,...e};X({settings:t});let n=Y().selection;if(n===null)return;n.sessionId!==null&&Da(bh(n),t);let r=Z(Y(),n.machine).composer;r!==null&&Nh(n.machine,{...r,provider:t.provider,[t.provider]:{accountId:t.accountId,model:t.model,effort:t.effort,mode:t.mode,plan:t.plan}}),e.accountId!==void 0&&Kh(),n.sessionId!==null&&_h(Y().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&M(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($)}function Hh(e,t){if(Q(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Y().selection?.machine!==e)return;let n=Y().settings,r=[...[...t.claudeAccounts,...t.codexAccounts].filter(e=>e.valid).map(e=>({provider:e.provider,accountId:e.id})),...t.openCode.available?[{provider:`opencode`,accountId:null}]:[]];if(r.some(e=>e.provider===n.provider&&e.accountId===n.accountId))return;let i=r.find(e=>e.provider===n.provider),a=Y().selection?.sessionId===null?r.at(0):void 0;if(i!==void 0)Vh({accountId:i.accountId});else if(a!==void 0){let t=Z(Y(),e);Vh({...zh(t.composer,a.provider),accountId:a.accountId,model:t.config===null?null:t.config.newThreads.models[a.provider],effort:null})}else n.accountId!==null&&Vh({accountId:null})}function Uh(e){let t=Y().selection;t?.machine===e&&t.sessionId===null&&(X({settings:Bh(Z(Y(),e))}),Wh(e))}function Wh(e){let t=Z(Y(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&Hh(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Kh()}async function Gh(e){try{Hh(e,await M(e,`accounts.list`,void 0))}catch(e){$(e)}}async function Kh(){let e=Y().selection;if(e===null)return;let{provider:t,accountId:n}=Y().settings;if(t!==`opencode`&&n===null)X({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if(Lh?.key!==r){let i=M(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){Lh?.result===i&&(Lh=null)}i.then(a,a),Lh={key:r,result:i}}let i=await Lh.result;if(Y().selection?.machine!==e.machine||Y().selection?.projectId!==e.projectId||Y().settings.provider!==t||Y().settings.accountId!==n)return;X({capabilities:i});let a=Y().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&Vh({effort:e});return}let o=i.models.find(e=>!e.hidden&&e.value===i.defaultModel)??i.models.find(e=>!e.hidden);if(o===void 0)return;Vh({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var qh=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{Um as $,Rr as $t,X as A,nm as At,Fm as B,ya as Bt,Q as C,im as Ct,wh as D,tm as Dt,Sh as E,$p as Et,ch as F,Ff as Ft,zm as G,M as Gt,Im as H,Da as Ht,ih as I,xa as It,Wm as J,Ri as Jt,eh as K,Ii as Kt,ah as L,Ta as Lt,mh as M,Sp as Mt,lh as N,Op as Nt,Th as O,cm as Ot,sh as P,_p as Pt,Hm as Q,ui as Qt,th as R,Ea as Rt,xh as S,am as St,$ as T,lm as Tt,Vm as U,ba as Ut,Jm as V,Sa as Vt,Km as W,ra as Wt,Qm as X,Vi as Xt,Zm as Y,Bi as Yt,Ym as Z,Pi as Zt,Z as _,bm as _t,Gh as a,ot as an,Sm as at,vh as b,sm as bt,Ph as c,de as cn,Cm as ct,_h as d,hm as dt,jr as en,Xm as et,fh as f,Em as ft,Y as g,vm as gt,bh as h,gm as ht,zh as i,Yt as in,Tm as it,Eh as j,q as jt,ph as k,em as kt,Mh as l,fm as lt,Dh as m,xm as mt,Vh as n,ar as nn,pm as nt,Kh as o,Re as on,ym as ot,gh as p,Om as pt,Bm as q,zi as qt,Rh as r,ir as rn,Dm as rt,Hh as s,Ae as sn,wm as st,qh as t,sr as tn,J as tt,jh as u,dm as ut,hh as v,_m as vt,Ch as w,rm as wt,yh as x,om as xt,uh as y,Qp as yt,Gm as z,Ca as zt};
57
+ 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);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function wd(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;wd(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Td=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ed=[`oneOf`,`anyOf`];function Dd(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Od(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Td.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Dd(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ia(n,r,e.length===1?e[0]:Od(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Dd(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function kd(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Td)if(t in e)return;let n=t.filter(e=>Ed.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Od(t);else{let e=n[0],i=Ed.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Od([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,yd(e,r))}function Ad(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)):yd(i,s),yd(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())wd(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])kd(e)}}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)}yd(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ia(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:Md(t,`input`,e.processors),output:Md(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function H(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 H(r.element,n);if(r.type===`set`)return H(r.valueType,n);if(r.type===`lazy`)return H(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`||r.type===`catch`)return H(r.innerType,n);if(r.type===`intersection`)return H(r.left,n)||H(r.right,n);if(r.type===`record`||r.type===`map`)return H(r.keyType,n)||H(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:H(r.in,n)||H(r.out,n);if(r.type===`object`){for(let e in r.shape)if(H(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(H(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(H(e,n))return!0;return!!(r.rest&&H(r.rest,n))}return!1}var jd=(e,t={})=>n=>{let r=bd({...n,processors:t});return V(e,r),Cd(r,e),Ad(r,e)},Md=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=bd({...i??{},target:a,io:t,processors:n});return V(e,o),Cd(o,e),Ad(o,e)},Nd=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Pd=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Fd=(e,t)=>{Nd(e,`minimum`,t),Pd(e,`maximum`,t)},Id=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ld=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Rd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},zd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Bd=(e,t)=>Nd(e,`minimum`,t.minimum),Vd=(e,t)=>Pd(e,`maximum`,t.maximum),Hd=e=>(t,n)=>{zd(t,n.format);let[r,i]=e[n.format];Nd(t,`minimum`,r),Pd(t,`maximum`,i)},Ud={greater_than:(e,t)=>Nd(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Pd(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Id(e,t.value),number_format:Hd(to),bigint_format:Hd(no),min_length:Bd,max_length:Vd,length_equals:(e,t)=>Fd(e,t.length),min_size:Bd,max_size:Vd,size_equals:(e,t)=>Fd(e,t.size),string_format:(e,t)=>{zd(e,t.format),t.pattern&&Ld(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Rd(e,t.mime)};function U(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ud[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Nd(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Nd(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Pd(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Pd(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Id(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Rd(t,i.mime);for(let e of i.patterns??[])Ld(t,e);return t}var Wd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Gd=new Map([[Zc,Ls],[$c,Rs]]),Kd=e=>Gd.get(e)??e,qd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=U(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Wd[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Kd);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}))])}},Jd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=U(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):xd(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Yd=(e,t,n,r)=>{n.type=`boolean`},Xd=(e,t,n,r)=>{n.not={}},Zd=(e,t,n,r)=>{let i=e._zod.def,a=Oa(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Qd=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(xd(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(xd(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},$d=(e,t,n,r)=>{xd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ef=(e,t,n,r)=>{xd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},tf=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=U(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=V(a.element,t,{...r,path:[...r.path,`items`]})};function nf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?nf(t.out):t.type===`catch`?nf(t.innerType):e._zod.optin}var rf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&xd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ia(i.properties,e,V(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?nf(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=V(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},af=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>V(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},of=(e,t,n,r)=>{let i=e._zod.def,a=V(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=V(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},sf=(e,t,n,r)=>{let i=e._zod.def,a=V(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`}]},cf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},lf=Symbol();function uf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(xd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),lf):JSON.parse(o)}var df=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=uf(i.defaultValue,e,t,n,r);o!==lf&&(n.default=o)},ff=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=uf(i.defaultValue,e,t,n,r);o!==lf&&(n._prefault=o)},pf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{xd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},mf=(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;V(o,t,r);let s=t.seen.get(e);s.ref=o},hf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},gf=(e,t,n,r)=>{let i=e._zod.def;V(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_f=new WeakSet([Object.prototype,Error.prototype]);function vf(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var W=I(`ZodError`,(e,t)=>{Yo.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);_f.has(n)||(_f.add(n),vf(n,`format`,e=>t=>Qo(e,t)),vf(n,`flatten`,e=>t=>Zo(e,t)),vf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Aa,2)}),vf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Aa,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),yf=ns(W),bf=rs(W),xf=is(W),Sf=os(W),Cf=fs(W),wf=ps(W),Tf=ms(W),Ef=hs(W),Df=gs(W),Of=_s(W),kf=vs(W),Af=ys(W);function jf(){L.localeError||Uo(du())}function Mf(){L.memoizer||Uo({memoizer:cu()})}var G=I(`ZodType`,(e,t)=>(jf(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(N(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 Qa(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xp(e,t))},superRefine(e,t){return this.check(Zp(e,t))},overwrite(e){return this.check(ld(e))},optional(){return Mp(this)},exactOptional(){return Pp(this)},nullable(){return Ip(this)},nullish(){return Mp(Ip(this))},nonoptional(e){return Hp(this,e)},array(){return hp(this)},or(e){return bp([this,e])},and(e){return wp(this,e)},transform(e){return Kp(this,Ap(e))},default(e){return Rp(this,e)},prefault(e){return Bp(this,e)},catch(e){return Wp(this,e)},pipe(e){return Kp(this,e)},readonly(){return Jp(this)},describe(e){let t=this.clone();return hu.add(t,{description:e}),t},meta(...e){if(e.length===0)return hu.get(this);let t=this.clone();return hu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Do(this,`~standard`,{...yc(this),jsonSchema:{input:Md(this,`input`),output:Md(this,`output`)}})},set"~standard"(e){Eo(this,`~standard`,e)},parse:function e(t,n){return yf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await bf(this,t,n,{callee:e})},safeParse(e,t){return xf(this,e,t)},async safeParseAsync(e,t){return Sf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Eo(this,`spa`,e)},validate(e,t){return ls(this,e,t)},validateAsync(e,t){return ds(this,e,t)},encode:function e(t,n){return Cf(this,t,n,{callee:e})},decode:function e(t,n){return wf(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Tf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ef(this,t,n,{callee:e})},safeEncode(e,t){return Df(this,e,t)},safeDecode(e,t){return Of(this,e,t)},async safeEncodeAsync(e,t){return kf(this,e,t)},async safeDecodeAsync(e,t){return Af(this,e,t)},toJSONSchema(e){return jd(this,{})(e)},get description(){return hu.get(this)?.description},get _def(){return this._zod.def}}),Nf=I(`_ZodString`,(e,t)=>{bc.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qd(e,t,n,r)},Oo({format:e=>U(e).format??null,minLength:e=>U(e).minimum??null,maxLength:e=>U(e).maximum??null},{regex(...e){return this.check(rd(...e))},includes(...e){return this.check(od(...e))},startsWith(...e){return this.check(sd(...e))},endsWith(...e){return this.check(cd(...e))},min(...e){return this.check(td(...e))},max(...e){return this.check(ed(...e))},length(...e){return this.check(nd(...e))},nonempty(...e){return this.check(td(1,...e))},lowercase(e){return this.check(id(e))},uppercase(e){return this.check(ad(e))},trim(){return this.check(dd())},normalize(...e){return this.check(ud(...e))},toLowerCase(){return this.check(fd())},toUpperCase(){return this.check(pd())},slugify(){return this.check(md())}})),Pf=I(`ZodString`,(e,t)=>{bc.init(e,t),Nf.init(e,t)},{email(e){return this.check(vu(Bf,e))},url(e){return this.check(wu(Uf,e))},jwt(e){return this.check(zu(ip,e))},emoji(e){return this.check(Tu(Wf,e))},guid(e){return this.check(yu(Vf,e))},uuid(e){return this.check(bu(Hf,e))},uuidv4(e){return this.check(xu(Hf,e))},uuidv6(e){return this.check(Su(Hf,e))},uuidv7(e){return this.check(Cu(Hf,e))},nanoid(e){return this.check(Eu(Gf,e))},cuid(e){return this.check(Du(Kf,e))},cuid2(e){return this.check(Ou(qf,e))},ulid(e){return this.check(ku(Jf,e))},base64(e){return this.check(Iu(tp,e))},base64url(e){return this.check(Lu(np,e))},xid(e){return this.check(Au(Yf,e))},ksuid(e){return this.check(ju(Xf,e))},ipv4(e){return this.check(Mu(Zf,e))},ipv6(e){return this.check(Nu(Qf,e))},cidrv4(e){return this.check(Pu($f,e))},cidrv6(e){return this.check(Fu(ep,e))},e164(e){return this.check(Ru(rp,e))},datetime(e){return this.check(Bu(If,e))},date(e){return this.check(Vu(Lf,e))},time(e){return this.check(Hu(Rf,e))},duration(e){return this.check(Uu(zf,e))}});function Ff(e){return _u(Pf,e)}var K=I(`ZodStringFormat`,(e,t)=>{B.init(e,t),Nf.init(e,t)}),If=I(`ZodISODateTime`,(e,t)=>{zc.init(e,t),K.init(e,t)}),Lf=I(`ZodISODate`,(e,t)=>{Bc.init(e,t),K.init(e,t)}),Rf=I(`ZodISOTime`,(e,t)=>{Vc.init(e,t),K.init(e,t)}),zf=I(`ZodISODuration`,(e,t)=>{Hc.init(e,t),K.init(e,t)}),Bf=I(`ZodEmail`,(e,t)=>{Cc.init(e,t),K.init(e,t)}),Vf=I(`ZodGUID`,(e,t)=>{xc.init(e,t),K.init(e,t)}),Hf=I(`ZodUUID`,(e,t)=>{Sc.init(e,t),K.init(e,t)}),Uf=I(`ZodURL`,(e,t)=>{jc.init(e,t),K.init(e,t)}),Wf=I(`ZodEmoji`,(e,t)=>{Mc.init(e,t),K.init(e,t)}),Gf=I(`ZodNanoID`,(e,t)=>{Nc.init(e,t),K.init(e,t)}),Kf=I(`ZodCUID`,(e,t)=>{Pc.init(e,t),K.init(e,t)}),qf=I(`ZodCUID2`,(e,t)=>{Fc.init(e,t),K.init(e,t)}),Jf=I(`ZodULID`,(e,t)=>{Ic.init(e,t),K.init(e,t)}),Yf=I(`ZodXID`,(e,t)=>{Lc.init(e,t),K.init(e,t)}),Xf=I(`ZodKSUID`,(e,t)=>{Rc.init(e,t),K.init(e,t)}),Zf=I(`ZodIPv4`,(e,t)=>{Uc.init(e,t),K.init(e,t)}),Qf=I(`ZodIPv6`,(e,t)=>{Kc.init(e,t),K.init(e,t)}),$f=I(`ZodCIDRv4`,(e,t)=>{qc.init(e,t),K.init(e,t)}),ep=I(`ZodCIDRv6`,(e,t)=>{Yc.init(e,t),K.init(e,t)}),tp=I(`ZodBase64`,(e,t)=>{Qc.init(e,t),K.init(e,t)}),np=I(`ZodBase64URL`,(e,t)=>{tl.init(e,t),K.init(e,t)}),rp=I(`ZodE164`,(e,t)=>{nl.init(e,t),K.init(e,t)}),ip=I(`ZodJWT`,(e,t)=>{il.init(e,t),K.init(e,t)}),ap=I(`ZodNumber`,(e,t)=>{al.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jd(e,t,n,r),e.isFinite=!0},Oo({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=U(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=U(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=U(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>U(e).format??null},{gt(e,t){return this.check(Zu(e,t))},gte(e,t){return this.check(Qu(e,t))},min(e,t){return this.check(Qu(e,t))},lt(e,t){return this.check(Yu(e,t))},lte(e,t){return this.check(Xu(e,t))},max(e,t){return this.check(Xu(e,t))},int(e){return this.check(cp(e))},safe(e){return this.check(cp(e))},positive(e){return this.check(Zu(0,e))},nonnegative(e){return this.check(Qu(0,e))},negative(e){return this.check(Yu(0,e))},nonpositive(e){return this.check(Xu(0,e))},multipleOf(e,t){return this.check($u(e,t))},step(e,t){return this.check($u(e,t))},finite(){return this}}));function op(e){return Wu(ap,e)}var sp=I(`ZodNumberFormat`,(e,t)=>{ol.init(e,t),ap.init(e,t)});function cp(e){return Gu(sp,e)}var lp=I(`ZodBoolean`,(e,t)=>{sl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yd(e,t,n,r)});function q(e){return Ku(lp,e)}var up=I(`ZodUnknown`,(e,t)=>{cl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function dp(){return qu(up)}var fp=I(`ZodNever`,(e,t)=>{ll.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xd(e,t,n,r)});function pp(e){return Ju(fp,e)}var mp=I(`ZodArray`,(e,t)=>{Mf(),pl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(e,t,n,r),e.element=t.element},{min(e,t){return this.check(td(e,t))},nonempty(e){return this.check(td(1,e))},max(e,t){return this.check(ed(e,t))},length(e,t){return this.check(nd(e,t))},unwrap(){return this.element}});function hp(e,t){return hd(mp,e,t)}var gp=I(`ZodObject`,(e,t)=>{Mf(),yl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r),Po(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ep(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(N(this._zod.def,{catchall:e}))},passthrough(){return this.clone(N(this._zod.def,{catchall:dp()}))},loose(){return this.clone(N(this._zod.def,{catchall:dp()}))},strict(){return this.clone(N(this._zod.def,{catchall:pp()}))},strip(){return this.clone(N(this._zod.def,{catchall:void 0}))},extend(e){return oo(this,e)},safeExtend(e){return co(this,e)},merge(e){return lo(this,e)},pick(e){return ro(this,e)},omit(e){return ao(this,e)},partial(...e){return uo(jp,this,e[0])},exactPartial(...e){return uo(Np,this,e[0],`exactPartial`)},required(...e){return fo(Vp,this,e[0])}});function _p(e,t){return new gp({type:`object`,shape:e??{},...P(t)})}function vp(e,t){return new gp({type:`object`,shape:e,catchall:pp(),...P(t)})}var yp=I(`ZodUnion`,(e,t)=>{xl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e.options=t.options});function bp(e,t){return new yp({type:`union`,options:e,...P(t)})}var xp=I(`ZodDiscriminatedUnion`,(e,t)=>{yp.init(e,t),Cl.init(e,t)});function Sp(e,t,n){return new xp({type:`union`,options:t,discriminator:e,...P(n)})}var Cp=I(`ZodIntersection`,(e,t)=>{wl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r)});function wp(e,t){return new Cp({type:`intersection`,left:e,right:t})}var Tp=I(`ZodEnum`,(e,t)=>{Dl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Tp({...t,checks:[],...P(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 Tp({...t,checks:[],...P(r),entries:i})}});function Ep(e,t){return new Tp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...P(t)})}var Dp=I(`ZodLiteral`,(e,t)=>{Ol.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Op(e,t){return new Dp({type:`literal`,values:Array.isArray(e)?e:[e],...P(t)})}var kp=I(`ZodTransform`,(e,t)=>{Mf(),kl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ho(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wo(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(wo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ap(e){return new kp({type:`transform`,transform:e})}var jp=I(`ZodOptional`,(e,t)=>{jl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mp(e){return new jp({type:`optional`,innerType:e})}var Np=I(`ZodExactOptional`,(e,t)=>{Ml.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new Np({type:`optional`,innerType:e})}var Fp=I(`ZodNullable`,(e,t)=>{Nl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Fp({type:`nullable`,innerType:e})}var Lp=I(`ZodDefault`,(e,t)=>{Pl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Rp(e,t){return new Lp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ya(t)}})}var zp=I(`ZodPrefault`,(e,t)=>{Il.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e,t){return new zp({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ya(t)}})}var Vp=I(`ZodNonOptional`,(e,t)=>{Ll.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hp(e,t){return new Vp({type:`nonoptional`,innerType:e,...P(t)})}var Up=I(`ZodCatch`,(e,t)=>{Bl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wp(e,t){return new Up({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Io(t)})}var Gp=I(`ZodPipe`,(e,t)=>{Vl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mf(e,t,n,r),e.in=t.in,e.out=t.out});function Kp(e,t){return new Gp({type:`pipe`,in:e,out:t})}var qp=I(`ZodReadonly`,(e,t)=>{Ul.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jp(e){return new qp({type:`readonly`,innerType:e})}var Yp=I(`ZodCustom`,(e,t)=>{Gl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r)});function Xp(e,t={}){return gd(Yp,e,t)}function Zp(e,t){return _d(e,t)}function Qp(){return J.parseLocation(J.history.location).search}function $p(){let e=/^\/terminal\/([^/]+)$/.exec(J.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Y().machines.some(e=>e.id===t)?t:null}function em(){let e=Lr({strict:!1,select:e=>e.machine??null});return _h(t=>t.machines.some(t=>t.id===e)?e:null)}function tm(){return Qp().project??`global`}function nm(){return Rr({strict:!1,select:e=>e.project??`global`})}function rm(e){let t=Qp();return t.machine===void 0||t.project===void 0||!e.includes(t.machine)?null:{machine:t.machine,projectId:t.project,sessionId:t.session??null}}function im(e){pm({...Qp(),...e},!0,J.history.location.state.layer)}function am(e,t){pm({...Qp(),...e},!1,t)}function om(e){let t=Y();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){im({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){im({panel:`browser`,browse:e});return}let n=vh(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);im({panel:`browser`,browse:`${n.path}/${e}`})}function sm(e,t){J.history.location.state.layer===e?J.history.back():t()}function cm(e,t){let n=(0,k.useEffectEvent)(t);(0,k.useEffect)(()=>{if(!e)return;let t,r=setTimeout(()=>{J.history.push(J.history.location.href);let e=J.history.location.state.__TSR_index,r=J.history.subscribe(()=>{J.history.location.state.__TSR_index<e&&n()});t=()=>{r(),J.history.location.state.__TSR_index===e&&J.history.back()}});return()=>{clearTimeout(r),t?.()}},[e])}var lm=`terminalProjects`;function um(){return JSON.parse(localStorage.getItem(lm)??`[]`)}function dm(){let e=Qp();if($p()!==null||e.machine===void 0||e.project===void 0)return;let t=`${e.machine} ${e.project}`,n=um().filter(e=>e!==t);localStorage.setItem(lm,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function fm(){let e=Y().selection;if(e===null){pm({project:$p()===null?void 0:Qp().project},!0,J.history.location.state.layer);return}let t={machine:e.machine,project:e.projectId,session:e.sessionId??void 0,bottom:um().includes(`${e.machine} ${e.projectId}`)?`terminal`:void 0};if($p()!==null){J.navigate({to:`/`,search:t,state:{layer:`chat`},resetScroll:!1});return}let n=Qp();n.machine===t.machine&&n.project===t.project&&(n.session===void 0||n.session===t.session)?im(t):am(t,`chat`)}function pm(e,t,n){let r=$p();r===null?J.navigate({to:`/`,search:e,replace:t,state:{layer:n},resetScroll:!1}):J.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t,state:{layer:n},resetScroll:!1})}function mm(e,t=null){let n=Z(Y(),e.machine),r=Y().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),X({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?r?.sessionId===null&&r.machine===e.machine?Y().settings:Wh(n):Ea(Ch(e))??Uh(n.composer,Y().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??n.composer?.provider??`claude`),context:null,paletteOpen:!1,unseen:Y().unseen.filter(t=>e.sessionId===null||t!==Wm(e.machine,e.sessionId))}),fm(),Jh(e.machine),e.sessionId!==null&&n.status===`online`&&hm(e.machine,e.projectId,e.sessionId,!0,t)}function hm(e,t,n,r,i){M(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Y().sessions.some(n=>n.machine===e&&n.id===t.id)||X({sessions:[...Y().sessions,{...t,machine:e}]})}).catch($)}function gm(){X({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),fm()}function _m(){let e=Y().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function vm(e,t){let n=$p();(n!==e||tm()!==t)&&(J.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null,state:{layer:`chat`},resetScroll:!1}),gm())}async function ym(e,t,n,r){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),X({sentAt:Date.now()}),await M(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t})}function bm(e){let t=Y().selection;t!==null&&t.sessionId!==null&&M(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function xm(e){let t=Y().selection;t!==null&&t.sessionId!==null&&M(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function Sm(){let e=Y().selection;e!==null&&e.sessionId!==null&&M(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function Cm(e,t,n){M(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function wm(e,t,n){let r=Y().selection;r!==null&&r.sessionId!==null&&M(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function Tm(e){let t=Y().selection;if(t!==null&&t.sessionId!==null)try{let n=await M(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});mm({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Em(){let e=Y().selection,t=Y().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await M(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Y().selection!==e||Y().before!==t)return;X({earlier:[...n.items,...Y().earlier],before:n.before})}catch(e){$(e)}}async function Dm(e,t){let n=Y().selection;if(n!==null&&n.sessionId!==null)try{let r=await M(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Y().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Y().items;X({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Om(e,t,n){let r=Y();function i(n){return n.machine===e&&n.id===t}let a=[...r.sessions,...r.inactive].find(i);if(a!==void 0){let e={...a,...n};X({sessions:r.sessions.some(i)?r.sessions.map(t=>i(t)?e:t):e.status===`inactive`?r.sessions:[...r.sessions,e],inactive:e.status===`inactive`?r.inactive.some(i)?r.inactive.map(t=>i(t)?e:t):[e,...r.inactive]:r.inactive.filter(e=>!i(e))})}try{await M(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function km(e){let t=Wm(e.machine,e.id);X({generatingTitles:[...Y().generatingTitles,t]});try{await M(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{X({generatingTitles:Y().generatingTitles.filter(e=>e!==t)})}}async function Am(e,t,n){let r=Y().selection;if(r?.machine===e&&r.sessionId===t){let i=Y().sessions.filter(r=>(r.status===`pinned`||r.status===`active`||r.status===`snoozed`)&&(r.machine!==e||r.id!==t)&&(n===null||r.machine===n.machine&&r.projectId===n.projectId)).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);mm(i===void 0?{...r,sessionId:null}:{machine:i.machine,projectId:i.projectId,sessionId:i.id})}await Om(e,t,{status:`inactive`})}async function jm(e,t){X({sessions:Y().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Y().inactive.filter(n=>n.machine!==e||n.id!==t)}),wa(Wm(e,t));let n=Y().selection;n?.machine===e&&n.sessionId===t&&mm({...n,sessionId:null});try{await M(e,`sessions.remove`,{id:t})}catch(e){$(e)}}var Mm=_p({machine:Ff().optional().catch(void 0),project:Ff().optional().catch(void 0),session:Ff().optional().catch(void 0),panel:Ep([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:Ff().optional().catch(void 0),bottom:Op(`terminal`).optional().catch(void 0),terminal:Ff().optional().catch(void 0)}),Nm=oi({validateSearch:Mm}),Pm=ii({getParentRoute:()=>Nm,path:`/`}),Fm=ii({getParentRoute:()=>Nm,path:`/terminal`,beforeLoad:()=>{let e=_m();throw st(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Im=ii({getParentRoute:()=>Nm,path:`/terminal/$machine`}),J=ci({routeTree:Nm.addChildren([Pm,Fm,Im]),disableGlobalCatchBoundary:!0,parseSearch:e=>Mm.parse(Object.fromEntries(new URLSearchParams(e))),stringifySearch:e=>{let t=new URLSearchParams;for(let n of Object.entries(e))n[1]!==void 0&&t.set(n[0],String(n[1]));let n=t.toString();return n===``?``:`?${n}`}}),Lm=`machines`,Rm=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function zm(){let e=localStorage.getItem(Lm);return e===null?[]:JSON.parse(e)}function Bm(e){localStorage.setItem(Lm,JSON.stringify(e))}async function Vm(e){if(!(`caches`in window))return;let t=e.map(e=>({id:e.id,addresses:e.addresses}));await(await caches.open(`offsite-worker`)).put(`/machines`,new Response(JSON.stringify(t)))}function Hm(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));J.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:Um(t).address,code:e.get(`code`)}}function Um(e){let t=e.trim(),n=new URL(/^[a-z]+:\/\//i.test(t)?t:`http://${t}`);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`Use an http:// or https:// address`);let r=new URLSearchParams(n.hash.slice(1)),i=r.get(`machine`);return{address:i===null?n.origin:Um(i).address,code:r.get(`code`)}}function Wm(e,t){return`${e} ${t}`}function Gm(e){return{id:e.id,addresses:e.addresses,via:null,status:`connecting`,name:e.label??e.name,hostname:e.name,label:e.label,icon:e.icon,pairedAt:e.pairedAt??null,config:null,composer:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function Km(e){return e.projects.map(t=>({...t,machine:e.id}))}function qm(){let e=zm(),t=Y().machines;for(let n of t)e.some(e=>e.id===n.id)||nh(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Y();X({machines:[...e.machines,Gm(n)],projects:[...e.projects,...Km(n)]}),Ii(n.id,n.addresses)}else Q(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(Q(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),eh(n.id))}let n=e.map(e=>e.id);X({machines:[...Y().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function Jm(e,t){let n=Y().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await Ym(n.id,t),n.id;let r=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);return t!==null&&await Si(r,await Xm(e,t)),X({machines:[...Y().machines,Gm({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),rh(),Ii(r,e),r}async function Ym(e,t){await Si(e,await Xm(Z(Y(),e).addresses,t)),Q(e,{pairedAt:Date.now()}),rh(),eh(e)}async function Xm(e,t){let n;for(let r of e){let e=await fetch(`${r}/api/pair`,{method:`POST`,headers:{authorization:`Bearer ${t}`}}).catch(e=>(n??=e,null));if(e!==null){if(!e.ok)throw Error(await e.text());return(await e.json()).token}}throw Error(`Could not reach the machine to pair: ${String(n)}`)}function Zm(e,t){let n=Z(Y(),e),r={...n,...t};Q(e,{...t,name:r.label??r.hostname}),rh(),r.addresses.join(` `)!==n.addresses.join(` `)&&eh(e)}function Qm(e){X({machines:[...Y().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),rh()}function $m(e){Vm(e).catch(e=>console.error(`could not share the machines with the service worker`,e))}function eh(e){Li(e),Q(e,{status:`connecting`,via:null}),Ii(e,Z(Y(),e).addresses)}function th(e){nh(e),rh(),Ci(e).catch(e=>console.error(`could not remove the device token`,e))}function nh(e){Li(e);let t=Y(),n=t.machines.filter(t=>t.id!==e);X({machines:n,projects:t.projects.filter(t=>t.machine!==e),sessions:t.sessions.filter(t=>t.machine!==e),inactive:t.inactive.filter(t=>t.machine!==e),unseen:t.unseen.filter(t=>!t.startsWith(`${e} `)),...t.settingsMachine===e&&{settingsMachine:n.at(0)?.id??null},...t.selection?.machine===e&&{selection:null}}),fm()}function rh(){let e=Y(),t=e.machines.map(t=>({id:t.id,addresses:t.addresses,name:t.hostname,label:t.label,icon:t.icon,pairedAt:t.pairedAt,projects:e.projects.filter(e=>e.machine===t.id).map(e=>({id:e.id,path:e.path,name:e.name,logo:e.logo,hidden:e.hidden}))}));Bm(t),$m(t)}var ih=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}],ah=vp({theme:Ff().refine(e=>ih.some(t=>t.id===e)).default(ih[0].id),terminal:vp({font:vp({family:Ff().default(`FiraCode Nerd Font`),size:op().default(14),lineHeight:op().default(1.35),ligatures:q().default(!0)}).prefault({}),cursor:vp({style:Ep([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),padding:vp({top:op().default(4),right:op().default(4),bottom:op().default(0),left:op().default(4)}).prefault({}),scrollback:op().default(1e3),boldIsBright:q().default(!0),behavior:vp({modernizeShiftEnter:q().default(!0),pasteBrowserImages:q().default(!0),captureShortcuts:q().default(!0),bellFlash:q().default(!0),bellSound:q().default(!0),clickToMoveCursor:q().default(!0),optionAsMeta:Ep([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:q().default(!0),confirmCloseBusyTab:q().default(!0)}).prefault({})}).prefault({}),editor:vp({font:vp({family:Ff().default(`FiraCode Nerd Font`),size:op().default(15.3),lineHeight:op().default(1.8),ligatures:q().default(!0),features:Ff().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:vp({style:Ep([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),tabSize:op().default(2),wordWrap:q().default(!0),graph:q().default(!0)}).prefault({}),diff:vp({split:q().default(!1),wrap:q().default(!0),collapsed:q().default(!1)}).prefault({}),rewind:Ep([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:q().default(!1)}),oh=`prefs`,sh=ah.parse({});function ch(){let e=localStorage.getItem(oh);if(e===null)return structuredClone(sh);let t=ah.safeParse(JSON.parse(e));return t.success?t.data:(console.warn(`invalid stored prefs, using the defaults:\n${es(t.error)}`),structuredClone(sh))}function lh(e){localStorage.setItem(oh,JSON.stringify(e))}function uh(){let e=Y().prefs.theme,t=ih.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function dh(){let e=_h(e=>e.prefs.theme),t=ih.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function fh(){let e=uh(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}var ph={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},mh;function hh(e){mh=aa()(()=>e)}function gh(e){return mh.subscribe(e)}function Y(){return mh.getState()}function _h(e){return sa(mh,e)}function X(e){mh.setState(e)}function Z(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function vh(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function yh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function Q(e,t){X({machines:Y().machines.map(n=>n.id===e?{...n,...t}:n)})}function bh(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function xh(e){let t=e.selection;if(t!==null)return bh(e.machines,t.machine,t.sessionId)}function Sh(e){return xh(e)?.running===!0}function Ch(e){return e.sessionId===null?`new`:Wm(e.machine,e.sessionId)}function wh(e){X({draft:e})}function Th(e){X({paletteOpen:e})}function Eh(e){X({editor:e})}function Dh(e){X({exporting:e})}function Oh(e){X({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:yh(Y()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function kh(e){X({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Y().settingsOpen&&{settingsMachine:yh(Y())}})}function Ah(e){X({prefs:e}),lh(e),fh()}function $(e){X({errors:[...Y().errors,i(e)]})}function jh(){X({errors:[]})}function Mh(e){let t=new Map;function n(t,n){Y().machines.some(e=>e.id===t)&&e.apply(t,n)}async function r(r,a){let o=await e.save(r,a),s=t.get(r);s!==void 0&&(--s.writes,s.writes>0||(o===null?await i(r):n(r,o)))}async function i(r){let i=t.get(r)?.version;try{let a=await e.load(r),o=t.get(r);o!==void 0&&o.writes===0&&o.version===i&&n(r,a)}catch(e){$(e)}}return{update(n,i){e.set(n,i);let a=t.get(n)??{writes:0,version:0,timer:void 0};t.set(n,a),a.timer===void 0&&(a.writes+=1),a.version+=1,window.clearTimeout(a.timer),a.timer=window.setTimeout(()=>{a.timer=void 0,r(n,i)},300)},receive(e,r){(t.get(e)?.writes??0)===0&&n(e,r)}}}var Nh=Mh({set:zh,save:async(e,t)=>{try{let n=await M(e,`config.save`,t);return Q(e,{configError:null}),n}catch(t){return Q(e,{configError:i(t)}),null}},load:async e=>(await M(e,`config.get`,void 0)).config,apply:zh}),Ph=Mh({set:(e,t)=>Q(e,{composer:t}),save:async(e,t)=>{try{return await M(e,`composer.save`,t)}catch(e){return $(e),null}},load:e=>M(e,`composer.get`,void 0),apply:Bh}),Fh=Nh.update,Ih=Nh.receive,Lh=Ph.update,Rh=Ph.receive;function zh(e,t){let n=Z(Y(),e).config;Q(e,{config:t}),n!==null&&ra(n.newThreads,t.newThreads)||qh(e)}function Bh(e,t){let n=Z(Y(),e).composer;Q(e,{composer:t});let r=Y().selection;if(r===null||r.machine!==e)return;if(r.sessionId===null){n===null&&qh(e);return}if(bh(Y().machines,e,r.sessionId)!==void 0)return;let i=Ea(Ch(r))??Uh(t,Y().settings.provider),a=i.provider!==Y().settings.provider||i.accountId!==Y().settings.accountId;X({settings:i}),a&&Xh()}var Vh=null,Hh={provider:`claude`,accountId:null,model:null,effort:null,mode:null,plan:!1};function Uh(e,t){return e===null?{...Hh,provider:t}:{provider:t,...e[t]}}function Wh(e){if(e.config===null)return Hh;let t=e.config.newThreads;return{...Uh(e.composer,t.provider),accountId:t.accountId,model:t.models[t.provider],effort:null}}function Gh(e){let t={...Y().settings,...e};X({settings:t});let n=Y().selection;if(n===null)return;n.sessionId!==null&&Da(Ch(n),t);let r=Z(Y(),n.machine).composer;r!==null&&Lh(n.machine,{...r,provider:t.provider,[t.provider]:{accountId:t.accountId,model:t.model,effort:t.effort,mode:t.mode,plan:t.plan}}),e.accountId!==void 0&&Xh(),n.sessionId!==null&&bh(Y().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&M(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($)}function Kh(e,t){if(Q(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Y().selection?.machine!==e)return;let n=Y().settings,r=[...[...t.claudeAccounts,...t.codexAccounts].filter(e=>e.valid).map(e=>({provider:e.provider,accountId:e.id})),...t.openCode.available?[{provider:`opencode`,accountId:null}]:[]];if(r.some(e=>e.provider===n.provider&&e.accountId===n.accountId))return;let i=r.find(e=>e.provider===n.provider),a=Y().selection?.sessionId===null?r.at(0):void 0;if(i!==void 0)Gh({accountId:i.accountId});else if(a!==void 0){let t=Z(Y(),e);Gh({...Uh(t.composer,a.provider),accountId:a.accountId,model:t.config===null?null:t.config.newThreads.models[a.provider],effort:null})}else n.accountId!==null&&Gh({accountId:null})}function qh(e){let t=Y().selection;t?.machine===e&&t.sessionId===null&&(X({settings:Wh(Z(Y(),e))}),Jh(e))}function Jh(e){let t=Z(Y(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&Kh(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Xh()}async function Yh(e){try{Kh(e,await M(e,`accounts.list`,void 0))}catch(e){$(e)}}async function Xh(){let e=Y().selection;if(e===null)return;let{provider:t,accountId:n}=Y().settings;if(t!==`opencode`&&n===null)X({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if(Vh?.key!==r){let i=M(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){Vh?.result===i&&(Vh=null)}i.then(a,a),Vh={key:r,result:i}}let i=await Vh.result;if(Y().selection?.machine!==e.machine||Y().selection?.projectId!==e.projectId||Y().settings.provider!==t||Y().settings.accountId!==n)return;X({capabilities:i});let a=Y().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&Gh({effort:e});return}let o=i.models.find(e=>!e.hidden&&e.value===i.defaultModel)??i.models.find(e=>!e.hidden);if(o===void 0)return;Gh({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var Zh=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{Gm as $,Pi as $t,gh as A,cm as At,Jm as B,Ea as Bt,Q as C,am as Ct,Th as D,fm as Dt,Dh as E,rm as Et,uh as F,Op as Ft,Ym as G,ba as Gt,Zm as H,ya as Ht,dh as I,_p as It,Um as J,Ii as Jt,Hm as K,ra as Kt,sh as L,Ff as Lt,Ah as M,nm as Mt,_h as N,q as Nt,Oh as O,$p as Ot,fh as P,Sp as Pt,Qm as Q,Vi as Qt,ch as R,xa as Rt,wh as S,om as St,$ as T,im as Tt,zm as U,Sa as Ut,Rm as V,Ca as Vt,Wm as W,Da as Wt,eh as X,Ri as Xt,qm as Y,zi as Yt,th as Z,Bi as Zt,Z as _,xm as _t,Yh as a,ir as an,Om as at,xh as b,Qp as bt,Rh as c,Re as cn,Dm as ct,bh as d,mm as dt,ui as en,Km as et,hh as f,vm as ft,Y as g,ym as gt,Ch as h,wm as ht,Uh as i,ar as in,Am as it,X as j,em as jt,kh as k,tm as kt,Ih as l,Ae as ln,Em as lt,jh as m,jm as mt,Gh as n,jr as nn,J as nt,Xh as o,Yt as on,Tm as ot,yh as p,km as pt,rh as q,M as qt,Hh as r,sr as rn,gm as rt,Kh as s,ot as sn,Sm as st,Zh as t,Rr as tn,$m as tt,Fh as u,de as un,hm as ut,vh as v,Cm as vt,Eh as w,dm as wt,Sh as x,sm as xt,ph as y,bm as yt,ih as z,Ta as zt};