offsite 0.0.95 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/client/dist/assets/{XIcon-Tc8nkaoT.js → XIcon-sNE7wlGT.js} +1 -1
- package/apps/client/dist/assets/{diff-panel-DTqI0r9W.js → diff-panel-D9sGyf1Y.js} +1 -1
- package/apps/client/dist/assets/{editor-dialog-Se2DP1E5.js → editor-dialog-De_ijtFY.js} +35 -35
- package/apps/client/dist/assets/{image-viewer-qKLCNUVK.js → image-viewer-DuyADV75.js} +1 -1
- package/apps/client/dist/assets/index-9ox1jth4.js +72 -0
- package/apps/client/dist/assets/index-dtN3QMc8.css +2 -0
- package/apps/client/dist/assets/{panel-close-button-ByrJIu34.js → panel-close-button-yIEA8ujQ.js} +1 -1
- package/apps/client/dist/assets/{preview-dialog-CnvAwgMU.js → preview-dialog-CPV2cjGd.js} +1 -1
- package/apps/client/dist/assets/{use-editor-shortcut-CGHT7fnL.js → use-editor-shortcut-BoixVvhO.js} +6 -6
- package/apps/client/dist/assets/{video-viewer-Ctc_XHXE.js → video-viewer-DbYvGHLh.js} +1 -1
- package/apps/client/dist/index.html +6 -6
- package/apps/client/dist/sw.js +1 -1
- package/apps/server/dist/main.mjs +71 -18
- package/apps/server/dist/main.mjs.map +1 -1
- package/apps/server/drizzle/20261108212949_last_efforts/migration.sql +6 -0
- package/apps/server/drizzle/20261108212949_last_efforts/snapshot.json +495 -0
- package/package.json +1 -1
- package/apps/client/dist/assets/index-B6yjBLio.js +0 -72
- package/apps/client/dist/assets/index-BFkBeASv.css +0 -2
|
@@ -64,4 +64,4 @@ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{l as n,r,u as i}from
|
|
|
64
64
|
|
|
65
65
|
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ja,c=!Go.jitless,l=c&&Ya.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?bl([],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 Cl(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=>!ho(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=>xo(e,r,Ko())))}),t)}var wl=B(`$ZodUnion`,(e,t)=>{H.init(e,t),z(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),z(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),z(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)))}),z(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=>Ia(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Cl(t,r,e,i)):Cl(o,r,e,i)}});function Tl(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 El=B(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,wl.init(e,t);let n=e._zod.parse;z(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)||Ra(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=za(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Pa(()=>Tl(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Ja(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)}}),Dl=B(`$ZodIntersection`,(e,t)=>{H.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])=>kl(e,t,n)):kl(e,i,a)}});function Ol(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Xa(e)&&Xa(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=Ol(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=Ol(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 kl(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=Ol(t.value,n.value);if(!c.valid){if(ho(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Al=B(`$ZodEnum`,(e,t)=>{H.init(e,t);let n=Aa(t.entries),r=new Set(n);e._zod.values=r,z(e,`pattern`,e=>{let t=Aa(e.def.entries).filter(e=>Qa.has(typeof e));return RegExp(t.length?`^(${t.map(e=>$a(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}}),jl=B(`$ZodLiteral`,(e,t)=>{H.init(e,t);let n=new Set(t.values);e._zod.values=n,z(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?$a(e):e?$a(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}}),Ml=B(`$ZodTransform`,(e,t)=>{H.init(e,t),e._zod.optin=`optional`,Go.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Wo(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 Uo;return n.value=i,n}});function Nl(e,t){return e.value=t.issues.length?void 0:t.value,e}var Pl=B(`$ZodOptional`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,z(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),z(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ia(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=>Nl(e,t)):Nl(e,r)}return t.innerType._zod.run(e,n)}}),Fl=B(`$ZodExactOptional`,(e,t)=>{Pl.init(e,t),z(e,`values`,e=>e.def.innerType._zod.values),z(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Il=B(`$ZodNullable`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin),z(e,`optout`,e=>e.def.innerType._zod.optout),z(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ia(t.source)}|null)$`):void 0}),z(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)}),Ll=B(`$ZodDefault`,(e,t)=>{H.init(e,t),e._zod.optin=`defaulted`,z(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=>Rl(e,t)):Rl(r,t)}});function Rl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var zl=B(`$ZodPrefault`,(e,t)=>{H.init(e,t),e._zod.optin=`defaulted`,z(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))}),Bl=B(`$ZodNonOptional`,(e,t)=>{H.init(e,t),z(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=>Vl(t,e)):Vl(i,e)}});function Vl(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 Hl(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>xo(e,r,Ko()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ul=B(`$ZodCatch`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),z(e,`optout`,e=>e.def.innerType._zod.optout),z(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=>Hl(e,r,t,n)):Hl(e,r,t,n)}}),Wl=B(`$ZodPipe`,(e,t)=>{H.init(e,t),z(e,`values`,e=>e.def.in._zod.values),z(e,`optin`,e=>e.def.in._zod.optin),z(e,`optout`,e=>e.def.out._zod.optout),z(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=>Gl(e,t.in,n)):Gl(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Gl(e,t.out,n)):Gl(r,t.out,n)}});function Gl(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 Kl=B(`$ZodReadonly`,(e,t)=>{H.init(e,t),z(e,`propValues`,e=>e.def.innerType._zod.propValues),z(e,`values`,e=>e.def.innerType._zod.values),z(e,`optin`,e=>e.def.innerType?._zod?.optin),z(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(ql):ql(r)}});function ql(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Jl=B(`$ZodCustom`,(e,t)=>{V.init(e,t),H.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=>Yl(t,n,r,e));Yl(i,n,r,e)}});function Yl(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(Eo(e))}}var Xl=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Zl=`~memo`,Ql=[];function $l(e){return typeof e==`object`&&!!e}function eu(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var tu=new WeakMap,nu=0,ru=1,iu=2;function au(e,t,n){let r=tu.get(e);if(r!==void 0)return r?iu:nu;if(t.has(e))return iu;t.add(e);let i=nu,a=e=>{if(i!==iu&&e?._zod){let r=au(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=nu;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?ru:o.value?._zod?au(o.value,t,n):nu;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=za(c);s(e?o(e,!0):ru),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?au(r,t,!1):ru);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),ou(e,i)}function ou(e,t){return t!==ru&&tu.set(e,t===iu),t}function su(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var cu,lu=[],uu={alloc(e,t,n){let r=cu;if(!r)return n;cu=void 0;let i={value:n,issues:null};return r.set(t.value,i),lu.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`&&fu(n,e.value))throw new Xl;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=au(e,new Set,!1);if(i===nu)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===iu||r?n=!0:r=!0}let l=s.value;if(!$l(l))return t(s,c);let u=c[Zl];u||(u={buckets:new WeakMap,backEdges:void 0},c[Zl]=u);let d;i===c?d=a:(d=su(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(...eu(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;cu=d;let p=lu.length,m=t(s,c);cu=void 0;let h=lu.length>p?lu.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?eu(e.issues):Ql),e)):(h&&(h.issues=m.issues.length?eu(m.issues):Ql),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function du(){return uu}function fu(e,t){let n=e[Zl]?.backEdges;return n!==void 0&&$l(t)&&n.has(t)}var pu=()=>{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(To(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${to(e.values[0])}`:`Invalid option: expected one of ${ja(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`:``}: ${ja(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 mu(){return{localeError:pu()}}var hu,gu=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 _u(){return new gu}(hu=globalThis).__zod_globalRegistry??(hu.__zod_globalRegistry=_u());var vu=globalThis.__zod_globalRegistry;function yu(e){return e.checks&&=[...e.checks],e}function bu(e,t){return new e(yu({type:`string`,...R(t)}))}function xu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...R(t)})}function Su(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...R(t)})}function Cu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...R(t)})}function wu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...R(t)})}function Tu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...R(t)})}function Eu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...R(t)})}function Du(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...R(t)})}function Ou(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...R(t)})}function ku(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...R(t)})}function Au(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...R(t)})}function ju(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...R(t)})}function Mu(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...R(t)})}function Nu(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...R(t)})}function Pu(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...R(t)})}function Fu(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...R(t)})}function Iu(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...R(t)})}function Lu(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...R(t)})}function Ru(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...R(t)})}function zu(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...R(t)})}function Bu(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...R(t)})}function Vu(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...R(t)})}function Hu(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...R(t)})}function Uu(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...R(t)})}function Wu(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...R(t)})}function Gu(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...R(t)})}function Ku(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...R(t)})}function qu(e,t){return new e(yu({type:`number`,checks:[],...R(t)}))}function Ju(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...R(t)})}function Yu(e,t){return new e({type:`boolean`,...R(t)})}function Xu(e){return new e({type:`unknown`})}function Zu(e,t){return new e({type:`never`,...R(t)})}function Qu(e,t){return new rc({check:`less_than`,...R(t),value:e,inclusive:!1})}function $u(e,t){return new rc({check:`less_than`,...R(t),value:e,inclusive:!0})}function ed(e,t){return new ic({check:`greater_than`,...R(t),value:e,inclusive:!1})}function td(e,t){return new ic({check:`greater_than`,...R(t),value:e,inclusive:!0})}function nd(e,t){return new ac({check:`multiple_of`,...R(t),value:e})}function rd(e,t){return new sc({check:`max_length`,...R(t),maximum:e})}function id(e,t){return new cc({check:`min_length`,...R(t),minimum:e})}function ad(e,t){return new lc({check:`length_equals`,...R(t),length:e})}function od(e,t){return new dc({check:`string_format`,format:`regex`,...R(t),pattern:e})}function sd(e){return new fc({check:`string_format`,format:`lowercase`,...R(e)})}function cd(e){return new pc({check:`string_format`,format:`uppercase`,...R(e)})}function ld(e,t){return new mc({check:`string_format`,format:`includes`,...R(t),includes:e})}function ud(e,t){return new hc({check:`string_format`,format:`starts_with`,...R(t),prefix:e})}function dd(e,t){return new gc({check:`string_format`,format:`ends_with`,...R(t),suffix:e})}function fd(e){return new _c({check:`overwrite`,tx:e})}function pd(e){return fd(t=>t.normalize(e))}function md(){return fd(e=>e.trim())}function hd(){return fd(e=>e.toLowerCase())}function gd(){return fd(e=>e.toUpperCase())}function _d(){return fd(e=>Ka(e))}function vd(e,t,n){return new e({type:`array`,element:t,...R(n)})}function yd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...R(n)})}function bd(e,t){let n=xd(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Eo(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(Eo(r))}},e(t.value,t)),t);return n}function xd(e,t){let n=new V({check:`custom`,...R(t)});return n._zod.check=e,n}function Sd(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ra(e,t,n[t]);return e}function Cd(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??vu,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 wd(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 W(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,W(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Sd(o.schema,c),t.io===`input`&&G(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 Td(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ed(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}/${Td(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+Td(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>
|
|
66
66
|
|
|
67
|
-
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 Dd(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;Dd(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 Od=new Set([`type`,`properties`,`required`,`additionalProperties`]),kd=[`oneOf`,`anyOf`];function Ad(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function jd(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Od.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]??Ad(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ra(n,r,e.length===1?e[0]:jd(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=Ad(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 Md(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Od)if(t in e)return;let n=t.filter(e=>kd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=jd(t);else{let e=n[0],i=kd.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=>jd([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Sd(e,r))}function Nd(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)):Sd(i,s),Sd(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())Dd(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)??[])Md(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)}Sd(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,Ra(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:Fd(t,`input`,e.processors),output:Fd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function G(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 G(r.element,n);if(r.type===`set`)return G(r.valueType,n);if(r.type===`lazy`)return G(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 G(r.innerType,n);if(r.type===`intersection`)return G(r.left,n)||G(r.right,n);if(r.type===`record`||r.type===`map`)return G(r.keyType,n)||G(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:G(r.in,n)||G(r.out,n);if(r.type===`object`){for(let e in r.shape)if(G(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(G(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(G(e,n))return!0;return!!(r.rest&&G(r.rest,n))}return!1}var Pd=(e,t={})=>n=>{let r=Cd({...n,processors:t});return W(e,r),Ed(r,e),Nd(r,e)},Fd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Cd({...i??{},target:a,io:t,processors:n});return W(e,o),Ed(o,e),Nd(o,e)},Id=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ld=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rd=(e,t)=>{Id(e,`minimum`,t),Ld(e,`maximum`,t)},zd=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bd=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Vd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ud=(e,t)=>Id(e,`minimum`,t.minimum),Wd=(e,t)=>Ld(e,`maximum`,t.maximum),Gd=e=>(t,n)=>{Hd(t,n.format);let[r,i]=e[n.format];Id(t,`minimum`,r),Ld(t,`maximum`,i)},Kd={greater_than:(e,t)=>Id(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ld(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zd(e,t.value),number_format:Gd(ro),bigint_format:Gd(io),min_length:Ud,max_length:Wd,length_equals:(e,t)=>Rd(e,t.length),min_size:Ud,max_size:Wd,size_equals:(e,t)=>Rd(e,t.size),string_format:(e,t)=>{Hd(e,t.format),t.pattern&&Bd(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)=>Vd(e,t.mime)};function qd(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kd[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Id(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Id(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ld(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ld(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zd(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vd(t,i.mime);for(let e of i.patterns??[])Bd(t,e);return t}var Jd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yd=new Map([[el,Bs],[nl,Vs]]),Xd=e=>Yd.get(e)??e,Zd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qd(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jd[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(Xd);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}))])}},Qd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qd(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)):wd(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}))])}},$d=(e,t,n,r)=>{n.type=`boolean`},ef=(e,t,n,r)=>{n.not={}},tf=(e,t,n,r)=>{let i=e._zod.def,a=Aa(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)},nf=(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(wd(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(wd(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}},rf=(e,t,n,r)=>{wd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},af=(e,t,n,r)=>{wd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},of=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qd(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=W(a.element,t,{...r,path:[...r.path,`items`]})};function sf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?sf(t.out):t.type===`catch`?sf(t.innerType):e._zod.optin}var cf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&wd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ra(i.properties,e,W(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`?sf(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=W(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},lf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>W(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},uf=(e,t,n,r)=>{let i=e._zod.def,a=W(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=W(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)},df=(e,t,n,r)=>{let i=e._zod.def,a=W(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`}]},ff=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pf=Symbol();function mf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(wd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),pf):JSON.parse(o)}var hf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n.default=o)},gf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n._prefault=o)},_f=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{wd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vf=(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;W(o,t,r);let s=t.seen.get(e);s.ref=o},yf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xf=new WeakSet([Object.prototype,Error.prototype]);function Sf(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 K=B(`ZodError`,(e,t)=>{Qo.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);xf.has(n)||(xf.add(n),Sf(n,`format`,e=>t=>ts(e,t)),Sf(n,`flatten`,e=>t=>es(e,t)),Sf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ma,2)}),Sf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ma,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cf=as(K),wf=os(K),Tf=ss(K),Ef=ls(K),Df=hs(K),Of=gs(K),kf=_s(K),Af=vs(K),jf=ys(K),Mf=bs(K),Nf=xs(K),Pf=Ss(K);function Ff(){Go.localeError||Ko(mu())}function If(){Go.memoizer||Ko({memoizer:du()})}var q=B(`ZodType`,(e,t)=>(Ff(),H.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(L(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 eo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(em(e,t))},superRefine(e,t){return this.check(tm(e,t))},overwrite(e){return this.check(fd(e))},optional(){return Ip(this)},exactOptional(){return Rp(this)},nullable(){return Bp(this)},nullish(){return Ip(Bp(this))},nonoptional(e){return Kp(this,e)},array(){return yp(this)},or(e){return wp([this,e])},and(e){return Op(this,e)},transform(e){return Xp(this,Pp(e))},default(e){return Hp(this,e)},prefault(e){return Wp(this,e)},catch(e){return Jp(this,e)},pipe(e){return Xp(this,e)},readonly(){return Qp(this)},describe(e){let t=this.clone();return vu.add(t,{description:e}),t},meta(...e){if(e.length===0)return vu.get(this);let t=this.clone();return vu.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 ko(this,`~standard`,{...Sc(this),jsonSchema:{input:Fd(this,`input`),output:Fd(this,`output`)}})},set"~standard"(e){Oo(this,`~standard`,e)},parse:function e(t,n){return Cf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wf(this,t,n,{callee:e})},safeParse(e,t){return Tf(this,e,t)},async safeParseAsync(e,t){return Ef(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Oo(this,`spa`,e)},validate(e,t){return fs(this,e,t)},validateAsync(e,t){return ms(this,e,t)},encode:function e(t,n){return Df(this,t,n,{callee:e})},decode:function e(t,n){return Of(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Af(this,t,n,{callee:e})},safeEncode(e,t){return jf(this,e,t)},safeDecode(e,t){return Mf(this,e,t)},async safeEncodeAsync(e,t){return Nf(this,e,t)},async safeDecodeAsync(e,t){return Pf(this,e,t)},toJSONSchema(e){return Pd(this,{})(e)},get description(){return vu.get(this)?.description},get _def(){return this._zod.def}}),Lf=B(`_ZodString`,(e,t)=>{Cc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r)},Ao({format:e=>qd(e).format??null,minLength:e=>qd(e).minimum??null,maxLength:e=>qd(e).maximum??null},{regex(...e){return this.check(od(...e))},includes(...e){return this.check(ld(...e))},startsWith(...e){return this.check(ud(...e))},endsWith(...e){return this.check(dd(...e))},min(...e){return this.check(id(...e))},max(...e){return this.check(rd(...e))},length(...e){return this.check(ad(...e))},nonempty(...e){return this.check(id(1,...e))},lowercase(e){return this.check(sd(e))},uppercase(e){return this.check(cd(e))},trim(){return this.check(md())},normalize(...e){return this.check(pd(...e))},toLowerCase(){return this.check(hd())},toUpperCase(){return this.check(gd())},slugify(){return this.check(_d())}})),Rf=B(`ZodString`,(e,t)=>{Cc.init(e,t),Lf.init(e,t)},{email(e){return this.check(xu(Wf,e))},url(e){return this.check(Du(qf,e))},jwt(e){return this.check(Hu(cp,e))},emoji(e){return this.check(Ou(Jf,e))},guid(e){return this.check(Su(Gf,e))},uuid(e){return this.check(Cu(Kf,e))},uuidv4(e){return this.check(wu(Kf,e))},uuidv6(e){return this.check(Tu(Kf,e))},uuidv7(e){return this.check(Eu(Kf,e))},nanoid(e){return this.check(ku(Yf,e))},cuid(e){return this.check(Au(Xf,e))},cuid2(e){return this.check(ju(Zf,e))},ulid(e){return this.check(Mu(Qf,e))},base64(e){return this.check(zu(ap,e))},base64url(e){return this.check(Bu(op,e))},xid(e){return this.check(Nu($f,e))},ksuid(e){return this.check(Pu(ep,e))},ipv4(e){return this.check(Fu(tp,e))},ipv6(e){return this.check(Iu(np,e))},cidrv4(e){return this.check(Lu(rp,e))},cidrv6(e){return this.check(Ru(ip,e))},e164(e){return this.check(Vu(sp,e))},datetime(e){return this.check(Uu(Bf,e))},date(e){return this.check(Wu(Vf,e))},time(e){return this.check(Gu(Hf,e))},duration(e){return this.check(Ku(Uf,e))}});function zf(e){return bu(Rf,e)}var J=B(`ZodStringFormat`,(e,t)=>{U.init(e,t),Lf.init(e,t)}),Bf=B(`ZodISODateTime`,(e,t)=>{Hc.init(e,t),J.init(e,t)}),Vf=B(`ZodISODate`,(e,t)=>{Uc.init(e,t),J.init(e,t)}),Hf=B(`ZodISOTime`,(e,t)=>{Wc.init(e,t),J.init(e,t)}),Uf=B(`ZodISODuration`,(e,t)=>{Gc.init(e,t),J.init(e,t)}),Wf=B(`ZodEmail`,(e,t)=>{Ec.init(e,t),J.init(e,t)}),Gf=B(`ZodGUID`,(e,t)=>{wc.init(e,t),J.init(e,t)}),Kf=B(`ZodUUID`,(e,t)=>{Tc.init(e,t),J.init(e,t)}),qf=B(`ZodURL`,(e,t)=>{Pc.init(e,t),J.init(e,t)}),Jf=B(`ZodEmoji`,(e,t)=>{Fc.init(e,t),J.init(e,t)}),Yf=B(`ZodNanoID`,(e,t)=>{Ic.init(e,t),J.init(e,t)}),Xf=B(`ZodCUID`,(e,t)=>{Lc.init(e,t),J.init(e,t)}),Zf=B(`ZodCUID2`,(e,t)=>{Rc.init(e,t),J.init(e,t)}),Qf=B(`ZodULID`,(e,t)=>{zc.init(e,t),J.init(e,t)}),$f=B(`ZodXID`,(e,t)=>{Bc.init(e,t),J.init(e,t)}),ep=B(`ZodKSUID`,(e,t)=>{Vc.init(e,t),J.init(e,t)}),tp=B(`ZodIPv4`,(e,t)=>{Kc.init(e,t),J.init(e,t)}),np=B(`ZodIPv6`,(e,t)=>{Yc.init(e,t),J.init(e,t)}),rp=B(`ZodCIDRv4`,(e,t)=>{Xc.init(e,t),J.init(e,t)}),ip=B(`ZodCIDRv6`,(e,t)=>{Qc.init(e,t),J.init(e,t)}),ap=B(`ZodBase64`,(e,t)=>{tl.init(e,t),J.init(e,t)}),op=B(`ZodBase64URL`,(e,t)=>{il.init(e,t),J.init(e,t)}),sp=B(`ZodE164`,(e,t)=>{al.init(e,t),J.init(e,t)}),cp=B(`ZodJWT`,(e,t)=>{sl.init(e,t),J.init(e,t)}),lp=B(`ZodNumber`,(e,t)=>{cl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r),e.isFinite=!0},Ao({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qd(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qd(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qd(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qd(e).format??null},{gt(e,t){return this.check(ed(e,t))},gte(e,t){return this.check(td(e,t))},min(e,t){return this.check(td(e,t))},lt(e,t){return this.check(Qu(e,t))},lte(e,t){return this.check($u(e,t))},max(e,t){return this.check($u(e,t))},int(e){return this.check(fp(e))},safe(e){return this.check(fp(e))},positive(e){return this.check(ed(0,e))},nonnegative(e){return this.check(td(0,e))},negative(e){return this.check(Qu(0,e))},nonpositive(e){return this.check($u(0,e))},multipleOf(e,t){return this.check(nd(e,t))},step(e,t){return this.check(nd(e,t))},finite(){return this}}));function up(e){return qu(lp,e)}var dp=B(`ZodNumberFormat`,(e,t)=>{ll.init(e,t),lp.init(e,t)});function fp(e){return Ju(dp,e)}var pp=B(`ZodBoolean`,(e,t)=>{ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r)});function Y(e){return Yu(pp,e)}var mp=B(`ZodUnknown`,(e,t)=>{dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hp(){return Xu(mp)}var gp=B(`ZodNever`,(e,t)=>{fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r)});function _p(e){return Zu(gp,e)}var vp=B(`ZodArray`,(e,t)=>{If(),gl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r),e.element=t.element},{min(e,t){return this.check(id(e,t))},nonempty(e){return this.check(id(1,e))},max(e,t){return this.check(rd(e,t))},length(e,t){return this.check(ad(e,t))},unwrap(){return this.element}});function yp(e,t){return vd(vp,e,t)}var bp=B(`ZodObject`,(e,t)=>{If(),Sl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),Io(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ap(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(L(this._zod.def,{catchall:e}))},passthrough(){return this.clone(L(this._zod.def,{catchall:hp()}))},loose(){return this.clone(L(this._zod.def,{catchall:hp()}))},strict(){return this.clone(L(this._zod.def,{catchall:_p()}))},strip(){return this.clone(L(this._zod.def,{catchall:void 0}))},extend(e){return co(this,e)},safeExtend(e){return uo(this,e)},merge(e){return fo(this,e)},pick(e){return ao(this,e)},omit(e){return so(this,e)},partial(...e){return po(Fp,this,e[0])},exactPartial(...e){return po(Lp,this,e[0],`exactPartial`)},required(...e){return mo(Gp,this,e[0])}});function xp(e,t){return new bp({type:`object`,shape:e??{},...R(t)})}function Sp(e,t){return new bp({type:`object`,shape:e,catchall:_p(),...R(t)})}var Cp=B(`ZodUnion`,(e,t)=>{wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lf(e,t,n,r),e.options=t.options});function wp(e,t){return new Cp({type:`union`,options:e,...R(t)})}var Tp=B(`ZodDiscriminatedUnion`,(e,t)=>{Cp.init(e,t),El.init(e,t)});function Ep(e,t,n){return new Tp({type:`union`,options:t,discriminator:e,...R(n)})}var Dp=B(`ZodIntersection`,(e,t)=>{Dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uf(e,t,n,r)});function Op(e,t){return new Dp({type:`intersection`,left:e,right:t})}var kp=B(`ZodEnum`,(e,t)=>{Al.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(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 kp({...t,checks:[],...R(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 kp({...t,checks:[],...R(r),entries:i})}});function Ap(e,t){return new kp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...R(t)})}var jp=B(`ZodLiteral`,(e,t)=>{jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nf(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 Mp(e,t){return new jp({type:`literal`,values:Array.isArray(e)?e:[e],...R(t)})}var Np=B(`ZodTransform`,(e,t)=>{If(),Ml.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Wo(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Eo(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(Eo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Pp(e){return new Np({type:`transform`,transform:e})}var Fp=B(`ZodOptional`,(e,t)=>{Pl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Fp({type:`optional`,innerType:e})}var Lp=B(`ZodExactOptional`,(e,t)=>{Fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rp(e){return new Lp({type:`optional`,innerType:e})}var zp=B(`ZodNullable`,(e,t)=>{Il.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e){return new zp({type:`nullable`,innerType:e})}var Vp=B(`ZodDefault`,(e,t)=>{Ll.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hp(e,t){return new Vp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Up=B(`ZodPrefault`,(e,t)=>{zl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wp(e,t){return new Up({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Gp=B(`ZodNonOptional`,(e,t)=>{Bl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kp(e,t){return new Gp({type:`nonoptional`,innerType:e,...R(t)})}var qp=B(`ZodCatch`,(e,t)=>{Ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_f(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Jp(e,t){return new qp({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ro(t)})}var Yp=B(`ZodPipe`,(e,t)=>{Wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vf(e,t,n,r),e.in=t.in,e.out=t.out});function Xp(e,t){return new Yp({type:`pipe`,in:e,out:t})}var Zp=B(`ZodReadonly`,(e,t)=>{Kl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qp(e){return new Zp({type:`readonly`,innerType:e})}var $p=B(`ZodCustom`,(e,t)=>{Jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r)});function em(e,t={}){return yd($p,e,t)}function tm(e,t){return bd(e,t)}var nm=`no-project`;function rm(){return X.parseLocation(X.history.location).search}function im(){let e=/^\/terminal\/([^/]+)$/.exec(X.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Z().machines.some(e=>e.id===t)?t:null}function am(){let e=sr({strict:!1,select:e=>e.machine??null});return Ph(t=>t.machines.some(t=>t.id===e)?e:null)}function om(){return rm().project??`global`}function sm(){return cr({strict:!1,select:e=>e.project??`global`})}function cm(e){let t=rm();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 lm(e){Tm({...rm(),...e},!0,X.history.location.state.layer)}function um(e,t){Tm({...rm(),...e},!1,t)}function dm(e){let t=Z();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){lm({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){lm({panel:`browser`,browse:e});return}let n=Ih(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);lm({panel:`browser`,browse:`${n.path}/${e}`})}var fm=[],pm=!1,mm=!1,hm=!1;function gm(){return X.history.location.state.guard===!0}function _m(){return hm}function vm(){pm||(fm.length>0&&!gm()?X.history.push(X.history.location.href,{guard:!0}):fm.length===0&&gm()&&(pm=!0,X.history.back()))}function ym(){mm=gm(),X.history.subscribe(({action:e})=>{let t=mm;mm=gm(),e.type===`PUSH`||e.type===`REPLACE`?hm=!1:(hm=t,hm&&pm?pm=!1:hm&&fm.at(-1)?.(),setTimeout(vm))}),setTimeout(vm)}function bm(e,t){let n=(0,j.useEffectEvent)(t);(0,j.useEffect)(()=>{if(!e)return;function t(){n()}return fm.push(t),setTimeout(vm),()=>{fm.splice(fm.indexOf(t),1),setTimeout(vm)}},[e])}var xm=`terminalProjects`;function Sm(){return JSON.parse(localStorage.getItem(xm)??`[]`)}function Cm(){let e=rm();if(im()!==null||e.machine===void 0||e.project===void 0||e.session===void 0)return;let t=`${e.machine} ${e.project}`,n=Sm().filter(e=>e!==t);localStorage.setItem(xm,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function wm(e=!1){let t=Z().selection;if(t===null){Tm({project:im()===null?void 0:rm().project},!0,X.history.location.state.layer);return}let n=rm(),r=n.machine===t.machine&&n.project===t.projectId&&n.session===void 0&&(t.sessionId===null||Z().loaded),i=Sm().includes(`${t.machine} ${t.projectId}`),a={machine:t.machine,project:t.projectId,session:t.sessionId??void 0,bottom:r?n.bottom:t.sessionId!==null&&i?`terminal`:void 0};if(im()!==null){X.navigate({to:`/`,search:a,replace:e||gm(),resetScroll:!1});return}let o=n.machine===a.machine&&n.project===a.project&&n.session===a.session,s=n.machine!==void 0&&n.session===void 0&&a.session===void 0;e||o||r||s?lm(a):um(a,void 0)}function Tm(e,t,n){let r=im(),i=gm(),a=t&&i?{layer:n,guard:i}:{layer:n};r===null?X.navigate({to:`/`,search:e,replace:t||i,state:a,resetScroll:!1}):X.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t||i,state:a,resetScroll:!1})}function Em(e,t=null,n=!1){let r=Fh(Z(),e.machine),i=Z().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),Q({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?i?.sessionId===null&&i.machine===e.machine?Z().settings:eg(r):Sa(Hh(e))??$h(r.lastUsed,Z().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??eg(r).provider),context:null,replacing:null,paletteOpen:!1,unseen:Z().unseen.filter(t=>e.sessionId===null||t!==ah(e.machine,e.sessionId))}),wm(n),ag(e.machine),e.sessionId!==null&&r.status===`online`&&Dm(e.machine,e.projectId,e.sessionId,!0,t)}function Dm(e,t,n,r,i){F(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Z().sessions.some(n=>n.machine===e&&n.id===t.id)||Q({sessions:[...Z().sessions,{...t,machine:e}]})}).catch($)}function Om(){Q({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),wm()}function km(){let e=Z().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function Am(e,t,n=!1){Em({machine:e,projectId:Ih(Z(),e,t)?.scratch===!0?nm:t,sessionId:null},null,n)}function jm(){let e=Z(),t=localStorage.getItem(`lastProject`),n=t===null?null:JSON.parse(t),r=e.machines.filter(e=>e.system?.scratchAvailable===!0);if(n!==null&&n.projectId===`no-project`&&r.some(e=>e.id===n.machine))return n;let i=(n===null?void 0:e.projects.find(e=>e.machine===n.machine&&e.id===n.projectId))??e.projects.find(e=>!e.scratch);return i===void 0?r.length>0?{machine:r[0].id,projectId:nm}:null:{machine:i.machine,projectId:i.id}}function Mm(e,t){let n=im();(n!==e||om()!==t)&&(X.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null||gm(),resetScroll:!1}),Om())}async function Nm(e,t,n,r,i){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),Q({sentAt:Date.now()}),await F(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t,status:i});let a=Z().replacing;n.sessionId===null&&a!==null&&a.machine===n.machine&&a.sessionId!==null&&(Q({replacing:null}),await Gm(a.machine,a.sessionId,a.projectId))}function Pm(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function Fm(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function Im(){let e=Z().selection;e!==null&&e.sessionId!==null&&F(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function Lm(e,t,n){F(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function Rm(e,t,n){let r=Z().selection;r!==null&&r.sessionId!==null&&F(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function zm(e){let t=Z().selection;if(t!==null&&t.sessionId!==null)try{let n=await F(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});Em({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Bm(){let e=Z().selection,t=Z().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await F(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Z().selection!==e||Z().before!==t)return;Q({earlier:[...n.items,...Z().earlier],before:n.before})}catch(e){$(e)}}async function Vm(e,t){let n=Z().selection;if(n!==null&&n.sessionId!==null)try{let r=await F(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Z().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Z().items;Q({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Hm(e,t,n){let r=Z();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};Q({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 F(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Um(e){let t=ah(e.machine,e.id);Q({generatingTitles:[...Z().generatingTitles,t]});try{await F(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{Q({generatingTitles:Z().generatingTitles.filter(e=>e!==t)})}}async function Wm(e,t,n){let r=Z().selection;if(r?.machine===e&&r.sessionId===t){let i=Z().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||n.projectId===`no-project`&&Ih(Z(),r.machine,r.projectId)?.scratch===!0))).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);i===void 0?Am(r.machine,r.projectId,!0):Em({machine:i.machine,projectId:i.projectId,sessionId:i.id},null,!0)}await Hm(e,t,{status:`inactive`})}async function Gm(e,t,n){Q({sessions:Z().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Z().inactive.filter(n=>n.machine!==e||n.id!==t)}),ba(ah(e,t));let r=Z().selection;r?.machine===e&&r.sessionId===t&&Am(e,r.projectId,!0);try{await F(e,`sessions.remove`,{id:t,projectId:n})}catch(e){$(e)}}var Km=xp({machine:zf().optional().catch(void 0),project:zf().optional().catch(void 0),session:zf().optional().catch(void 0),panel:Ap([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:zf().optional().catch(void 0),bottom:Mp(`terminal`).optional().catch(void 0),terminal:zf().optional().catch(void 0)}),qm=Ar({validateSearch:Km}),Jm=Or({getParentRoute:()=>qm,path:`/`}),Ym=Or({getParentRoute:()=>qm,path:`/terminal`,beforeLoad:()=>{let e=km();throw ke(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Xm=Or({getParentRoute:()=>qm,path:`/terminal/$machine`});if(window.history.state?.__TSR_index===void 0&&(location.pathname.startsWith(`/terminal`)||new URLSearchParams(location.search).has(`machine`))){let e=`${location.pathname}${location.search}${location.hash}`,t=Math.random().toString(36).slice(2),n=Math.random().toString(36).slice(2);window.history.replaceState({__TSR_index:0,__TSR_key:t,key:t},``,`/`),window.history.pushState({__TSR_index:1,__TSR_key:n,key:n},``,e)}var X=Mr({routeTree:qm.addChildren([Jm,Ym,Xm]),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}`}}),Zm=fi.withTag(`machines`),Qm=`machines`,$m=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function eh(){let e=localStorage.getItem(Qm);return e===null?[]:JSON.parse(e)}function th(e){localStorage.setItem(Qm,JSON.stringify(e))}async function nh(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 rh(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));X.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:ih(t).address,code:e.get(`code`)}}function ih(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:ih(i).address,code:r.get(`code`)}}function ah(e,t){return`${e} ${t}`}function oh(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,lastUsed:null,appIcon:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function sh(e){return e.projects.map(t=>({...t,machine:e.id}))}function ch(){let e=eh(),t=Z().machines;for(let n of t)e.some(e=>e.id===n.id)||_h(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Z();Q({machines:[...e.machines,oh(n)],projects:[...e.projects,...sh(n)]}),Ni(n.id,n.addresses)}else Rh(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(Rh(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),hh(n.id))}let n=e.map(e=>e.id);Q({machines:[...Z().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function lh(e,t){let n=Z().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await uh(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 ai(r,await dh(e,t)),Q({machines:[...Z().machines,oh({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),vh(),Ni(r,e),r}async function uh(e,t){await ai(e,await dh(Fh(Z(),e).addresses,t)),Rh(e,{pairedAt:Date.now()}),vh(),hh(e)}async function dh(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 fh(e,t){let n=Fh(Z(),e),r={...n,...t};Rh(e,{...t,name:r.label??r.hostname}),vh(),r.addresses.join(` `)!==n.addresses.join(` `)&&hh(e)}function ph(e){Q({machines:[...Z().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),vh()}function mh(e){nh(e).catch(e=>Zm.error(`could not share the machines with the service worker`,e))}function hh(e){Pi(e),Rh(e,{status:`connecting`,via:null}),Ni(e,Fh(Z(),e).addresses)}function gh(e){_h(e),vh(),oi(e).catch(e=>Zm.error(`could not remove the device token`,e))}function _h(e){Pi(e);let t=Z(),n=t.machines.filter(t=>t.id!==e);Q({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}}),wm()}function vh(){let e=Z(),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,scratch:e.scratch}))}));th(t),mh(t)}var yh=[{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`]}],bh=fi.withTag(`prefs`),xh=Sp({theme:zf().refine(e=>yh.some(t=>t.id===e)).default(yh[0].id),terminal:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(14),lineHeight:up().default(1.35),ligatures:Y().default(!0)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),padding:Sp({top:up().default(4),right:up().default(4),bottom:up().default(0),left:up().default(4)}).prefault({}),scrollback:up().default(1e3),boldIsBright:Y().default(!0),behavior:Sp({modernizeShiftEnter:Y().default(!0),pasteBrowserImages:Y().default(!0),captureShortcuts:Y().default(!0),bellFlash:Y().default(!0),bellSound:Y().default(!0),clickToMoveCursor:Y().default(!0),optionAsMeta:Ap([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:Y().default(!0),confirmCloseBusyTab:Y().default(!0)}).prefault({})}).prefault({}),editor:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(15.3),lineHeight:up().default(1.8),ligatures:Y().default(!0),features:zf().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),tabSize:up().default(2),wordWrap:Y().default(!0),graph:Y().default(!0)}).prefault({}),diff:Sp({split:Y().default(!1),wrap:Y().default(!0),collapsed:Y().default(!1)}).prefault({}),rewind:Ap([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:Y().default(!1),autoMoveToSnooze:Y().default(!1),dictateButton:Sp({desktop:Y().default(!1),mobile:Y().default(!0)}).prefault({}),toolbar:yp(Ap([`diff`,`terminal`,`tasks`,`browser`,`editor`])).default([`diff`,`terminal`,`editor`])}),Sh=`prefs`,Ch=xh.parse({});function wh(){let e=localStorage.getItem(Sh);if(e===null)return structuredClone(Ch);let t=xh.safeParse(JSON.parse(e));return t.success?t.data:(bh.warn(`invalid stored prefs, using the defaults:\n${rs(t.error)}`),structuredClone(Ch))}function Th(e){localStorage.setItem(Sh,JSON.stringify(e))}function Eh(){let e=Z().prefs.theme,t=yh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function Dh(){let e=Ph(e=>e.prefs.theme),t=yh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function Oh(){let e=Eh(),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 kh=fi.withTag(`ui`),Ah={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},jh;function Mh(e){jh=ea()(()=>e)}function Nh(e){return jh.subscribe(e)}function Z(){return jh.getState()}function Ph(e){return na(jh,e)}function Q(e){jh.setState(e)}function Fh(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function Ih(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function Lh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function Rh(e,t){Q({machines:Z().machines.map(n=>n.id===e?{...n,...t}:n)})}function zh(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function Bh(e){let t=e.selection;if(t!==null)return zh(e.machines,t.machine,t.sessionId)}function Vh(e){return Bh(e)?.running===!0}function Hh(e){return e.sessionId===null?`new`:ah(e.machine,e.sessionId)}function Uh(e){Q({draft:e})}function Wh(e){Q({paletteOpen:e})}function Gh(e){Q({editor:e})}function Kh(e){Q({exporting:e})}function qh(e){Q({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:Lh(Z()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Jh(e){Q({usageOpen:e,paletteOpen:!1})}function Yh(e){Q({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Z().settingsOpen&&{settingsMachine:Lh(Z())}})}function Xh(e){Q({prefs:e}),Th(e),Oh()}function $(e){kh.warn(`showing an error:`,e),Q({errors:[...Z().errors,r(e)]})}function Zh(){Q({errors:[]})}var Qh=null;function $h(e,t){let n=e?.find(e=>e.provider===t),r=t===`claude`?Yi:t===`codex`?Xi:null;return n===void 0?{provider:t,accountId:null,model:null,effort:null,mode:r,plan:!1}:{provider:t,accountId:n.accountId,model:n.model,effort:null,mode:r,plan:!1}}function eg(e){let t=Zi(e.lastUsed??[],e=>e.usedAt);return t===void 0?{provider:Ji,accountId:null,model:null,effort:null,mode:Yi,plan:!1}:$h(e.lastUsed,t.provider)}function tg(e,t,n,r){F(e,`lastUsed.save`,{provider:t,accountId:n,model:r}).catch($);let i=Z().machines.filter(t=>t.id!==e&&t.status===`online`);if(t===`opencode`){for(let e of i.filter(e=>e.openCode.available))F(e.id,`lastUsed.save`,{provider:t,accountId:null,model:r}).catch($);return}let a=Fh(Z(),e),o=(t===`claude`?a.claudeAccounts:a.codexAccounts).find(e=>e.id===n)?.identity;if(o!=null)for(let e of i){let n=(t===`claude`?e.claudeAccounts:e.codexAccounts).find(e=>e.enabled&&e.identity!==null&&e.identity.accountId===o.accountId&&e.identity.organizationId===o.organizationId);n!==void 0&&F(e.id,`lastUsed.save`,{provider:t,accountId:n.id,model:r}).catch($)}}function ng(e){let t={...Z().settings,...e};Q({settings:t});let n=Z().selection;n!==null&&(n.sessionId!==null&&Ca(Hh(n),t),e.accountId!==void 0&&sg(),n.sessionId!==null&&zh(Z().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&F(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($))}function rg(e,t){if(Rh(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Z().selection?.machine!==e)return;let n=Z().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=Z().selection?.sessionId===null?r.at(0):void 0;i===void 0?a===void 0?n.accountId!==null&&ng({accountId:null}):ng({...$h(Fh(Z(),e).lastUsed,a.provider),accountId:a.accountId}):ng({accountId:i.accountId})}function ig(e){let t=Z().selection;t?.machine===e&&t.sessionId===null&&(Q({settings:eg(Fh(Z(),e))}),ag(e))}function ag(e){let t=Fh(Z(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&rg(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),sg()}async function og(e){try{rg(e,await F(e,`accounts.list`,void 0))}catch(e){$(e)}}async function sg(){let e=Z().selection;if(e===null)return;let{provider:t,accountId:n}=Z().settings;if(t!==`opencode`&&n===null)Q({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if(Qh?.key!==r){let i=F(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){Qh?.result===i&&(Qh=null)}i.then(a,a),Qh={key:r,result:i}}let i=await Qh.result;if(Z().selection?.machine!==e.machine||Z().selection?.projectId!==e.projectId||Z().settings.provider!==t||Z().settings.accountId!==n)return;Q({capabilities:i});let a=Z().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&ng({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;ng({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var cg=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{sh as $,ga as $t,Q as A,im as At,$m as B,zf as Bt,$ as C,O as Cn,dm as Ct,Yh as D,cm as Dt,qh as E,lm as Et,Dh as F,nm as Ft,rh as G,Ta as Gt,eh as H,_a as Ht,Ch as I,Y as It,ch as J,ha as Jt,vh as K,Ea as Kt,wh as L,Ep as Lt,Ph as M,bm as Mt,Oh as N,am as Nt,Jh as O,ym as Ot,Eh as P,sm as Pt,oh as Q,Da as Qt,yh as R,Mp as Rt,Gh as S,Oe as Sn,_m as St,Wh as T,c as Tn,Cm as Tt,ah as U,xa as Ut,fh as V,ka as Vt,uh as W,Sa as Wt,gh as X,va as Xt,hh as Y,Oa as Yt,ph as Z,Ca as Zt,Ah as _,tr as _n,Am as _t,sg as a,Ii as an,zm as at,Uh as b,Dn as bn,Pm as bt,rg as c,Ri as cn,Vm as ct,Lh as d,mi as dn,Em as dt,wa as en,mh as et,Zh as f,Zr as fn,Mm as ft,Ih as g,cr as gn,Nm as gt,Fh as h,Pr as hn,Rm as ht,og as i,Ni as in,Hm as it,Xh as j,om as jt,Nh as k,wm as kt,zh as l,ji as ln,Bm as lt,Z as m,ti as mn,Gm as mt,ng as n,Ji as nn,Om as nt,ig as o,Fi as on,Im as ot,Hh as p,ei as pn,Um as pt,ih as q,ya as qt,$h as r,F as rn,Wm as rt,tg as s,Li as sn,jm as st,cg as t,Yi as tn,X as tt,Mh as u,fi as un,Dm as ut,Bh as v,An as vn,Fm as vt,Kh as w,D as wn,um as wt,Rh as x,_t as xn,rm as xt,Vh as y,On as yn,Lm as yt,lh as z,xp as zt};
|
|
67
|
+
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 Dd(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;Dd(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 Od=new Set([`type`,`properties`,`required`,`additionalProperties`]),kd=[`oneOf`,`anyOf`];function Ad(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function jd(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Od.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]??Ad(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ra(n,r,e.length===1?e[0]:jd(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=Ad(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 Md(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Od)if(t in e)return;let n=t.filter(e=>kd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=jd(t);else{let e=n[0],i=kd.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=>jd([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Sd(e,r))}function Nd(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)):Sd(i,s),Sd(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())Dd(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)??[])Md(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)}Sd(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,Ra(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:Fd(t,`input`,e.processors),output:Fd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function G(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 G(r.element,n);if(r.type===`set`)return G(r.valueType,n);if(r.type===`lazy`)return G(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 G(r.innerType,n);if(r.type===`intersection`)return G(r.left,n)||G(r.right,n);if(r.type===`record`||r.type===`map`)return G(r.keyType,n)||G(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:G(r.in,n)||G(r.out,n);if(r.type===`object`){for(let e in r.shape)if(G(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(G(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(G(e,n))return!0;return!!(r.rest&&G(r.rest,n))}return!1}var Pd=(e,t={})=>n=>{let r=Cd({...n,processors:t});return W(e,r),Ed(r,e),Nd(r,e)},Fd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Cd({...i??{},target:a,io:t,processors:n});return W(e,o),Ed(o,e),Nd(o,e)},Id=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ld=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rd=(e,t)=>{Id(e,`minimum`,t),Ld(e,`maximum`,t)},zd=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bd=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Vd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ud=(e,t)=>Id(e,`minimum`,t.minimum),Wd=(e,t)=>Ld(e,`maximum`,t.maximum),Gd=e=>(t,n)=>{Hd(t,n.format);let[r,i]=e[n.format];Id(t,`minimum`,r),Ld(t,`maximum`,i)},Kd={greater_than:(e,t)=>Id(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ld(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zd(e,t.value),number_format:Gd(ro),bigint_format:Gd(io),min_length:Ud,max_length:Wd,length_equals:(e,t)=>Rd(e,t.length),min_size:Ud,max_size:Wd,size_equals:(e,t)=>Rd(e,t.size),string_format:(e,t)=>{Hd(e,t.format),t.pattern&&Bd(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)=>Vd(e,t.mime)};function qd(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kd[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Id(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Id(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ld(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ld(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zd(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vd(t,i.mime);for(let e of i.patterns??[])Bd(t,e);return t}var Jd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yd=new Map([[el,Bs],[nl,Vs]]),Xd=e=>Yd.get(e)??e,Zd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qd(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jd[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(Xd);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}))])}},Qd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qd(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)):wd(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}))])}},$d=(e,t,n,r)=>{n.type=`boolean`},ef=(e,t,n,r)=>{n.not={}},tf=(e,t,n,r)=>{let i=e._zod.def,a=Aa(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)},nf=(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(wd(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(wd(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}},rf=(e,t,n,r)=>{wd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},af=(e,t,n,r)=>{wd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},of=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qd(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=W(a.element,t,{...r,path:[...r.path,`items`]})};function sf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?sf(t.out):t.type===`catch`?sf(t.innerType):e._zod.optin}var cf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&wd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ra(i.properties,e,W(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`?sf(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=W(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},lf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>W(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},uf=(e,t,n,r)=>{let i=e._zod.def,a=W(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=W(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)},df=(e,t,n,r)=>{let i=e._zod.def,a=W(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`}]},ff=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pf=Symbol();function mf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(wd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),pf):JSON.parse(o)}var hf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n.default=o)},gf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n._prefault=o)},_f=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{wd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vf=(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;W(o,t,r);let s=t.seen.get(e);s.ref=o},yf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xf=new WeakSet([Object.prototype,Error.prototype]);function Sf(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 K=B(`ZodError`,(e,t)=>{Qo.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);xf.has(n)||(xf.add(n),Sf(n,`format`,e=>t=>ts(e,t)),Sf(n,`flatten`,e=>t=>es(e,t)),Sf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ma,2)}),Sf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ma,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cf=as(K),wf=os(K),Tf=ss(K),Ef=ls(K),Df=hs(K),Of=gs(K),kf=_s(K),Af=vs(K),jf=ys(K),Mf=bs(K),Nf=xs(K),Pf=Ss(K);function Ff(){Go.localeError||Ko(mu())}function If(){Go.memoizer||Ko({memoizer:du()})}var q=B(`ZodType`,(e,t)=>(Ff(),H.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(L(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 eo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(em(e,t))},superRefine(e,t){return this.check(tm(e,t))},overwrite(e){return this.check(fd(e))},optional(){return Ip(this)},exactOptional(){return Rp(this)},nullable(){return Bp(this)},nullish(){return Ip(Bp(this))},nonoptional(e){return Kp(this,e)},array(){return yp(this)},or(e){return wp([this,e])},and(e){return Op(this,e)},transform(e){return Xp(this,Pp(e))},default(e){return Hp(this,e)},prefault(e){return Wp(this,e)},catch(e){return Jp(this,e)},pipe(e){return Xp(this,e)},readonly(){return Qp(this)},describe(e){let t=this.clone();return vu.add(t,{description:e}),t},meta(...e){if(e.length===0)return vu.get(this);let t=this.clone();return vu.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 ko(this,`~standard`,{...Sc(this),jsonSchema:{input:Fd(this,`input`),output:Fd(this,`output`)}})},set"~standard"(e){Oo(this,`~standard`,e)},parse:function e(t,n){return Cf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wf(this,t,n,{callee:e})},safeParse(e,t){return Tf(this,e,t)},async safeParseAsync(e,t){return Ef(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Oo(this,`spa`,e)},validate(e,t){return fs(this,e,t)},validateAsync(e,t){return ms(this,e,t)},encode:function e(t,n){return Df(this,t,n,{callee:e})},decode:function e(t,n){return Of(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Af(this,t,n,{callee:e})},safeEncode(e,t){return jf(this,e,t)},safeDecode(e,t){return Mf(this,e,t)},async safeEncodeAsync(e,t){return Nf(this,e,t)},async safeDecodeAsync(e,t){return Pf(this,e,t)},toJSONSchema(e){return Pd(this,{})(e)},get description(){return vu.get(this)?.description},get _def(){return this._zod.def}}),Lf=B(`_ZodString`,(e,t)=>{Cc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r)},Ao({format:e=>qd(e).format??null,minLength:e=>qd(e).minimum??null,maxLength:e=>qd(e).maximum??null},{regex(...e){return this.check(od(...e))},includes(...e){return this.check(ld(...e))},startsWith(...e){return this.check(ud(...e))},endsWith(...e){return this.check(dd(...e))},min(...e){return this.check(id(...e))},max(...e){return this.check(rd(...e))},length(...e){return this.check(ad(...e))},nonempty(...e){return this.check(id(1,...e))},lowercase(e){return this.check(sd(e))},uppercase(e){return this.check(cd(e))},trim(){return this.check(md())},normalize(...e){return this.check(pd(...e))},toLowerCase(){return this.check(hd())},toUpperCase(){return this.check(gd())},slugify(){return this.check(_d())}})),Rf=B(`ZodString`,(e,t)=>{Cc.init(e,t),Lf.init(e,t)},{email(e){return this.check(xu(Wf,e))},url(e){return this.check(Du(qf,e))},jwt(e){return this.check(Hu(cp,e))},emoji(e){return this.check(Ou(Jf,e))},guid(e){return this.check(Su(Gf,e))},uuid(e){return this.check(Cu(Kf,e))},uuidv4(e){return this.check(wu(Kf,e))},uuidv6(e){return this.check(Tu(Kf,e))},uuidv7(e){return this.check(Eu(Kf,e))},nanoid(e){return this.check(ku(Yf,e))},cuid(e){return this.check(Au(Xf,e))},cuid2(e){return this.check(ju(Zf,e))},ulid(e){return this.check(Mu(Qf,e))},base64(e){return this.check(zu(ap,e))},base64url(e){return this.check(Bu(op,e))},xid(e){return this.check(Nu($f,e))},ksuid(e){return this.check(Pu(ep,e))},ipv4(e){return this.check(Fu(tp,e))},ipv6(e){return this.check(Iu(np,e))},cidrv4(e){return this.check(Lu(rp,e))},cidrv6(e){return this.check(Ru(ip,e))},e164(e){return this.check(Vu(sp,e))},datetime(e){return this.check(Uu(Bf,e))},date(e){return this.check(Wu(Vf,e))},time(e){return this.check(Gu(Hf,e))},duration(e){return this.check(Ku(Uf,e))}});function zf(e){return bu(Rf,e)}var J=B(`ZodStringFormat`,(e,t)=>{U.init(e,t),Lf.init(e,t)}),Bf=B(`ZodISODateTime`,(e,t)=>{Hc.init(e,t),J.init(e,t)}),Vf=B(`ZodISODate`,(e,t)=>{Uc.init(e,t),J.init(e,t)}),Hf=B(`ZodISOTime`,(e,t)=>{Wc.init(e,t),J.init(e,t)}),Uf=B(`ZodISODuration`,(e,t)=>{Gc.init(e,t),J.init(e,t)}),Wf=B(`ZodEmail`,(e,t)=>{Ec.init(e,t),J.init(e,t)}),Gf=B(`ZodGUID`,(e,t)=>{wc.init(e,t),J.init(e,t)}),Kf=B(`ZodUUID`,(e,t)=>{Tc.init(e,t),J.init(e,t)}),qf=B(`ZodURL`,(e,t)=>{Pc.init(e,t),J.init(e,t)}),Jf=B(`ZodEmoji`,(e,t)=>{Fc.init(e,t),J.init(e,t)}),Yf=B(`ZodNanoID`,(e,t)=>{Ic.init(e,t),J.init(e,t)}),Xf=B(`ZodCUID`,(e,t)=>{Lc.init(e,t),J.init(e,t)}),Zf=B(`ZodCUID2`,(e,t)=>{Rc.init(e,t),J.init(e,t)}),Qf=B(`ZodULID`,(e,t)=>{zc.init(e,t),J.init(e,t)}),$f=B(`ZodXID`,(e,t)=>{Bc.init(e,t),J.init(e,t)}),ep=B(`ZodKSUID`,(e,t)=>{Vc.init(e,t),J.init(e,t)}),tp=B(`ZodIPv4`,(e,t)=>{Kc.init(e,t),J.init(e,t)}),np=B(`ZodIPv6`,(e,t)=>{Yc.init(e,t),J.init(e,t)}),rp=B(`ZodCIDRv4`,(e,t)=>{Xc.init(e,t),J.init(e,t)}),ip=B(`ZodCIDRv6`,(e,t)=>{Qc.init(e,t),J.init(e,t)}),ap=B(`ZodBase64`,(e,t)=>{tl.init(e,t),J.init(e,t)}),op=B(`ZodBase64URL`,(e,t)=>{il.init(e,t),J.init(e,t)}),sp=B(`ZodE164`,(e,t)=>{al.init(e,t),J.init(e,t)}),cp=B(`ZodJWT`,(e,t)=>{sl.init(e,t),J.init(e,t)}),lp=B(`ZodNumber`,(e,t)=>{cl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r),e.isFinite=!0},Ao({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qd(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qd(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qd(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qd(e).format??null},{gt(e,t){return this.check(ed(e,t))},gte(e,t){return this.check(td(e,t))},min(e,t){return this.check(td(e,t))},lt(e,t){return this.check(Qu(e,t))},lte(e,t){return this.check($u(e,t))},max(e,t){return this.check($u(e,t))},int(e){return this.check(fp(e))},safe(e){return this.check(fp(e))},positive(e){return this.check(ed(0,e))},nonnegative(e){return this.check(td(0,e))},negative(e){return this.check(Qu(0,e))},nonpositive(e){return this.check($u(0,e))},multipleOf(e,t){return this.check(nd(e,t))},step(e,t){return this.check(nd(e,t))},finite(){return this}}));function up(e){return qu(lp,e)}var dp=B(`ZodNumberFormat`,(e,t)=>{ll.init(e,t),lp.init(e,t)});function fp(e){return Ju(dp,e)}var pp=B(`ZodBoolean`,(e,t)=>{ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r)});function Y(e){return Yu(pp,e)}var mp=B(`ZodUnknown`,(e,t)=>{dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hp(){return Xu(mp)}var gp=B(`ZodNever`,(e,t)=>{fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r)});function _p(e){return Zu(gp,e)}var vp=B(`ZodArray`,(e,t)=>{If(),gl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r),e.element=t.element},{min(e,t){return this.check(id(e,t))},nonempty(e){return this.check(id(1,e))},max(e,t){return this.check(rd(e,t))},length(e,t){return this.check(ad(e,t))},unwrap(){return this.element}});function yp(e,t){return vd(vp,e,t)}var bp=B(`ZodObject`,(e,t)=>{If(),Sl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),Io(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ap(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(L(this._zod.def,{catchall:e}))},passthrough(){return this.clone(L(this._zod.def,{catchall:hp()}))},loose(){return this.clone(L(this._zod.def,{catchall:hp()}))},strict(){return this.clone(L(this._zod.def,{catchall:_p()}))},strip(){return this.clone(L(this._zod.def,{catchall:void 0}))},extend(e){return co(this,e)},safeExtend(e){return uo(this,e)},merge(e){return fo(this,e)},pick(e){return ao(this,e)},omit(e){return so(this,e)},partial(...e){return po(Fp,this,e[0])},exactPartial(...e){return po(Lp,this,e[0],`exactPartial`)},required(...e){return mo(Gp,this,e[0])}});function xp(e,t){return new bp({type:`object`,shape:e??{},...R(t)})}function Sp(e,t){return new bp({type:`object`,shape:e,catchall:_p(),...R(t)})}var Cp=B(`ZodUnion`,(e,t)=>{wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lf(e,t,n,r),e.options=t.options});function wp(e,t){return new Cp({type:`union`,options:e,...R(t)})}var Tp=B(`ZodDiscriminatedUnion`,(e,t)=>{Cp.init(e,t),El.init(e,t)});function Ep(e,t,n){return new Tp({type:`union`,options:t,discriminator:e,...R(n)})}var Dp=B(`ZodIntersection`,(e,t)=>{Dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uf(e,t,n,r)});function Op(e,t){return new Dp({type:`intersection`,left:e,right:t})}var kp=B(`ZodEnum`,(e,t)=>{Al.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(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 kp({...t,checks:[],...R(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 kp({...t,checks:[],...R(r),entries:i})}});function Ap(e,t){return new kp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...R(t)})}var jp=B(`ZodLiteral`,(e,t)=>{jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nf(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 Mp(e,t){return new jp({type:`literal`,values:Array.isArray(e)?e:[e],...R(t)})}var Np=B(`ZodTransform`,(e,t)=>{If(),Ml.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Wo(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Eo(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(Eo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Pp(e){return new Np({type:`transform`,transform:e})}var Fp=B(`ZodOptional`,(e,t)=>{Pl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Fp({type:`optional`,innerType:e})}var Lp=B(`ZodExactOptional`,(e,t)=>{Fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rp(e){return new Lp({type:`optional`,innerType:e})}var zp=B(`ZodNullable`,(e,t)=>{Il.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e){return new zp({type:`nullable`,innerType:e})}var Vp=B(`ZodDefault`,(e,t)=>{Ll.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hp(e,t){return new Vp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Up=B(`ZodPrefault`,(e,t)=>{zl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wp(e,t){return new Up({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Gp=B(`ZodNonOptional`,(e,t)=>{Bl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kp(e,t){return new Gp({type:`nonoptional`,innerType:e,...R(t)})}var qp=B(`ZodCatch`,(e,t)=>{Ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_f(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Jp(e,t){return new qp({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ro(t)})}var Yp=B(`ZodPipe`,(e,t)=>{Wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vf(e,t,n,r),e.in=t.in,e.out=t.out});function Xp(e,t){return new Yp({type:`pipe`,in:e,out:t})}var Zp=B(`ZodReadonly`,(e,t)=>{Kl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qp(e){return new Zp({type:`readonly`,innerType:e})}var $p=B(`ZodCustom`,(e,t)=>{Jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r)});function em(e,t={}){return yd($p,e,t)}function tm(e,t){return bd(e,t)}var nm=`no-project`;function rm(){return X.parseLocation(X.history.location).search}function im(){let e=/^\/terminal\/([^/]+)$/.exec(X.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Z().machines.some(e=>e.id===t)?t:null}function am(){let e=sr({strict:!1,select:e=>e.machine??null});return Fh(t=>t.machines.some(t=>t.id===e)?e:null)}function om(){return rm().project??`global`}function sm(){return cr({strict:!1,select:e=>e.project??`global`})}function cm(e){let t=rm();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 lm(e){Tm({...rm(),...e},!0,X.history.location.state.layer)}function um(e,t){Tm({...rm(),...e},!1,t)}function dm(e){let t=Z();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){lm({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){lm({panel:`browser`,browse:e});return}let n=Lh(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);lm({panel:`browser`,browse:`${n.path}/${e}`})}var fm=[],pm=!1,mm=!1,hm=!1;function gm(){return X.history.location.state.guard===!0}function _m(){return hm}function vm(){pm||(fm.length>0&&!gm()?X.history.push(X.history.location.href,{guard:!0}):fm.length===0&&gm()&&(pm=!0,X.history.back()))}function ym(){mm=gm(),X.history.subscribe(({action:e})=>{let t=mm;mm=gm(),e.type===`PUSH`||e.type===`REPLACE`?hm=!1:(hm=t,hm&&pm?pm=!1:hm&&fm.at(-1)?.(),setTimeout(vm))}),setTimeout(vm)}function bm(e,t){let n=(0,j.useEffectEvent)(t);(0,j.useEffect)(()=>{if(!e)return;function t(){n()}return fm.push(t),setTimeout(vm),()=>{fm.splice(fm.indexOf(t),1),setTimeout(vm)}},[e])}var xm=`terminalProjects`;function Sm(){return JSON.parse(localStorage.getItem(xm)??`[]`)}function Cm(){let e=rm();if(im()!==null||e.machine===void 0||e.project===void 0||e.session===void 0)return;let t=`${e.machine} ${e.project}`,n=Sm().filter(e=>e!==t);localStorage.setItem(xm,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function wm(e=!1){let t=Z().selection;if(t===null){Tm({project:im()===null?void 0:rm().project},!0,X.history.location.state.layer);return}let n=rm(),r=n.machine===t.machine&&n.project===t.projectId&&n.session===void 0&&(t.sessionId===null||Z().loaded),i=Sm().includes(`${t.machine} ${t.projectId}`),a={machine:t.machine,project:t.projectId,session:t.sessionId??void 0,bottom:r?n.bottom:t.sessionId!==null&&i?`terminal`:void 0};if(im()!==null){X.navigate({to:`/`,search:a,replace:e||gm(),resetScroll:!1});return}let o=n.machine===a.machine&&n.project===a.project&&n.session===a.session,s=n.machine!==void 0&&n.session===void 0&&a.session===void 0;e||o||r||s?lm(a):um(a,void 0)}function Tm(e,t,n){let r=im(),i=gm(),a=t&&i?{layer:n,guard:i}:{layer:n};r===null?X.navigate({to:`/`,search:e,replace:t||i,state:a,resetScroll:!1}):X.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t||i,state:a,resetScroll:!1})}function Em(e,t=null,n=!1){let r=Ih(Z(),e.machine),i=Z().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),Q({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?i?.sessionId===null&&i.machine===e.machine?Z().settings:rg(r):Sa(Uh(e))??ng(r,Z().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??rg(r).provider),context:null,replacing:null,paletteOpen:!1,unseen:Z().unseen.filter(t=>e.sessionId===null||t!==oh(e.machine,e.sessionId))}),wm(n),cg(e.machine),e.sessionId!==null&&r.status===`online`&&Dm(e.machine,e.projectId,e.sessionId,!0,t)}function Dm(e,t,n,r,i){F(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Z().sessions.some(n=>n.machine===e&&n.id===t.id)||Q({sessions:[...Z().sessions,{...t,machine:e}]})}).catch($)}function Om(){Q({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),wm()}function km(){let e=Z().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function Am(e,t,n=!1){Em({machine:e,projectId:Lh(Z(),e,t)?.scratch===!0?nm:t,sessionId:null},null,n)}function jm(){let e=Z(),t=localStorage.getItem(`lastProject`),n=t===null?null:JSON.parse(t),r=e.machines.filter(e=>e.system?.scratchAvailable===!0);if(n!==null&&n.projectId===`no-project`&&r.some(e=>e.id===n.machine))return n;let i=(n===null?void 0:e.projects.find(e=>e.machine===n.machine&&e.id===n.projectId))??e.projects.find(e=>!e.scratch);return i===void 0?r.length>0?{machine:r[0].id,projectId:nm}:null:{machine:i.machine,projectId:i.id}}function Mm(e,t){let n=im();(n!==e||om()!==t)&&(X.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null||gm(),resetScroll:!1}),Om())}async function Nm(e,t,n,r,i){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),Q({sentAt:Date.now()}),await F(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t,status:i});let a=Z().replacing;n.sessionId===null&&a!==null&&a.machine===n.machine&&a.sessionId!==null&&(Q({replacing:null}),await Km(a.machine,a.sessionId,a.projectId))}function Pm(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function Fm(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function Im(){let e=Z().selection;e!==null&&e.sessionId!==null&&F(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function Lm(e,t){F(e,`sessions.restart`,{sessionId:t}).catch($)}function Rm(e,t,n){F(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function zm(e,t,n){let r=Z().selection;r!==null&&r.sessionId!==null&&F(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function Bm(e){let t=Z().selection;if(t!==null&&t.sessionId!==null)try{let n=await F(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});Em({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Vm(){let e=Z().selection,t=Z().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await F(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Z().selection!==e||Z().before!==t)return;Q({earlier:[...n.items,...Z().earlier],before:n.before})}catch(e){$(e)}}async function Hm(e,t){let n=Z().selection;if(n!==null&&n.sessionId!==null)try{let r=await F(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Z().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Z().items;Q({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Um(e,t,n){let r=Z();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};Q({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 F(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Wm(e){let t=oh(e.machine,e.id);Q({generatingTitles:[...Z().generatingTitles,t]});try{await F(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{Q({generatingTitles:Z().generatingTitles.filter(e=>e!==t)})}}async function Gm(e,t,n){let r=Z().selection;if(r?.machine===e&&r.sessionId===t){let i=Z().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||n.projectId===`no-project`&&Lh(Z(),r.machine,r.projectId)?.scratch===!0))).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);i===void 0?Am(r.machine,r.projectId,!0):Em({machine:i.machine,projectId:i.projectId,sessionId:i.id},null,!0)}await Um(e,t,{status:`inactive`})}async function Km(e,t,n){Q({sessions:Z().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Z().inactive.filter(n=>n.machine!==e||n.id!==t)}),ba(oh(e,t));let r=Z().selection;r?.machine===e&&r.sessionId===t&&Am(e,r.projectId,!0);try{await F(e,`sessions.remove`,{id:t,projectId:n})}catch(e){$(e)}}var qm=xp({machine:zf().optional().catch(void 0),project:zf().optional().catch(void 0),session:zf().optional().catch(void 0),panel:Ap([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:zf().optional().catch(void 0),bottom:Mp(`terminal`).optional().catch(void 0),terminal:zf().optional().catch(void 0)}),Jm=Ar({validateSearch:qm}),Ym=Or({getParentRoute:()=>Jm,path:`/`}),Xm=Or({getParentRoute:()=>Jm,path:`/terminal`,beforeLoad:()=>{let e=km();throw ke(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Zm=Or({getParentRoute:()=>Jm,path:`/terminal/$machine`});if(window.history.state?.__TSR_index===void 0&&(location.pathname.startsWith(`/terminal`)||new URLSearchParams(location.search).has(`machine`))){let e=`${location.pathname}${location.search}${location.hash}`,t=Math.random().toString(36).slice(2),n=Math.random().toString(36).slice(2);window.history.replaceState({__TSR_index:0,__TSR_key:t,key:t},``,`/`),window.history.pushState({__TSR_index:1,__TSR_key:n,key:n},``,e)}var X=Mr({routeTree:Jm.addChildren([Ym,Xm,Zm]),disableGlobalCatchBoundary:!0,parseSearch:e=>qm.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}`}}),Qm=fi.withTag(`machines`),$m=`machines`,eh=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function th(){let e=localStorage.getItem($m);return e===null?[]:JSON.parse(e)}function nh(e){localStorage.setItem($m,JSON.stringify(e))}async function rh(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 ih(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));X.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:ah(t).address,code:e.get(`code`)}}function ah(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:ah(i).address,code:r.get(`code`)}}function oh(e,t){return`${e} ${t}`}function sh(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,lastUsed:null,lastEfforts:[],appIcon:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function ch(e){return e.projects.map(t=>({...t,machine:e.id}))}function lh(){let e=th(),t=Z().machines;for(let n of t)e.some(e=>e.id===n.id)||vh(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Z();Q({machines:[...e.machines,sh(n)],projects:[...e.projects,...ch(n)]}),Ni(n.id,n.addresses)}else zh(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(zh(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),gh(n.id))}let n=e.map(e=>e.id);Q({machines:[...Z().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function uh(e,t){let n=Z().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await dh(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 ai(r,await fh(e,t)),Q({machines:[...Z().machines,sh({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),yh(),Ni(r,e),r}async function dh(e,t){await ai(e,await fh(Ih(Z(),e).addresses,t)),zh(e,{pairedAt:Date.now()}),yh(),gh(e)}async function fh(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 ph(e,t){let n=Ih(Z(),e),r={...n,...t};zh(e,{...t,name:r.label??r.hostname}),yh(),r.addresses.join(` `)!==n.addresses.join(` `)&&gh(e)}function mh(e){Q({machines:[...Z().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),yh()}function hh(e){rh(e).catch(e=>Qm.error(`could not share the machines with the service worker`,e))}function gh(e){Pi(e),zh(e,{status:`connecting`,via:null}),Ni(e,Ih(Z(),e).addresses)}function _h(e){vh(e),yh(),oi(e).catch(e=>Qm.error(`could not remove the device token`,e))}function vh(e){Pi(e);let t=Z(),n=t.machines.filter(t=>t.id!==e);Q({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}}),wm()}function yh(){let e=Z(),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,scratch:e.scratch}))}));nh(t),hh(t)}var bh=[{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`]}],xh=fi.withTag(`prefs`),Sh=Sp({theme:zf().refine(e=>bh.some(t=>t.id===e)).default(bh[0].id),terminal:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(14),lineHeight:up().default(1.35),ligatures:Y().default(!0)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),padding:Sp({top:up().default(4),right:up().default(4),bottom:up().default(0),left:up().default(4)}).prefault({}),scrollback:up().default(1e3),boldIsBright:Y().default(!0),behavior:Sp({modernizeShiftEnter:Y().default(!0),pasteBrowserImages:Y().default(!0),captureShortcuts:Y().default(!0),bellFlash:Y().default(!0),bellSound:Y().default(!0),clickToMoveCursor:Y().default(!0),optionAsMeta:Ap([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:Y().default(!0),confirmCloseBusyTab:Y().default(!0)}).prefault({})}).prefault({}),editor:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(15.3),lineHeight:up().default(1.8),ligatures:Y().default(!0),features:zf().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),tabSize:up().default(2),wordWrap:Y().default(!0),graph:Y().default(!0)}).prefault({}),diff:Sp({split:Y().default(!1),wrap:Y().default(!0),collapsed:Y().default(!1)}).prefault({}),rewind:Ap([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:Y().default(!1),autoMoveToSnooze:Y().default(!1),dictateButton:xp({mobile:Y().default(!0)}).prefault({}),toolbar:yp(Ap([`diff`,`terminal`,`tasks`,`browser`,`editor`])).default([`diff`,`terminal`,`editor`])}),Ch=`prefs`,wh=Sh.parse({});function Th(){let e=localStorage.getItem(Ch);if(e===null)return structuredClone(wh);let t=Sh.safeParse(JSON.parse(e));return t.success?t.data:(xh.warn(`invalid stored prefs, using the defaults:\n${rs(t.error)}`),structuredClone(wh))}function Eh(e){localStorage.setItem(Ch,JSON.stringify(e))}function Dh(){let e=Z().prefs.theme,t=bh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function Oh(){let e=Fh(e=>e.prefs.theme),t=bh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function kh(){let e=Dh(),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 Ah=fi.withTag(`ui`),jh={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},Mh;function Nh(e){Mh=ea()(()=>e)}function Ph(e){return Mh.subscribe(e)}function Z(){return Mh.getState()}function Fh(e){return na(Mh,e)}function Q(e){Mh.setState(e)}function Ih(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function Lh(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function Rh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function zh(e,t){Q({machines:Z().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 Vh(e){let t=e.selection;if(t!==null)return Bh(e.machines,t.machine,t.sessionId)}function Hh(e){return Vh(e)?.running===!0}function Uh(e){return e.sessionId===null?`new`:oh(e.machine,e.sessionId)}function Wh(e){Q({draft:e})}function Gh(e){Q({paletteOpen:e})}function Kh(e){Q({editor:e})}function qh(e){Q({exporting:e})}function Jh(e){Q({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:Rh(Z()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Yh(e){Q({usageOpen:e,paletteOpen:!1})}function Xh(e){Q({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Z().settingsOpen&&{settingsMachine:Rh(Z())}})}function Zh(e){Q({prefs:e}),Eh(e),kh()}function $(e){Ah.warn(`showing an error:`,e),Q({errors:[...Z().errors,r(e)]})}function Qh(){Q({errors:[]})}var $h=null;function eg(e,t,n){return e.lastEfforts.find(e=>e.provider===t&&e.model===n)?.effort??null}function tg(e,t,n){for(let r of Z().machines)r.status===`online`&&F(r.id,`lastEffort.save`,{provider:e,model:t,effort:n}).catch($)}function ng(e,t){let n=e.lastUsed?.find(e=>e.provider===t),r=t===`claude`?Yi:t===`codex`?Xi:null;return n===void 0?{provider:t,accountId:null,model:null,effort:null,mode:r,plan:!1}:{provider:t,accountId:n.accountId,model:n.model,effort:eg(e,t,n.model),mode:r,plan:!1}}function rg(e){let t=Zi(e.lastUsed??[],e=>e.usedAt);return t===void 0?{provider:Ji,accountId:null,model:null,effort:null,mode:Yi,plan:!1}:ng(e,t.provider)}function ig(e,t,n,r){F(e,`lastUsed.save`,{provider:t,accountId:n,model:r}).catch($);let i=Z().machines.filter(t=>t.id!==e&&t.status===`online`);if(t===`opencode`){for(let e of i.filter(e=>e.openCode.available))F(e.id,`lastUsed.save`,{provider:t,accountId:null,model:r}).catch($);return}let a=Ih(Z(),e),o=(t===`claude`?a.claudeAccounts:a.codexAccounts).find(e=>e.id===n)?.identity;if(o!=null)for(let e of i){let n=(t===`claude`?e.claudeAccounts:e.codexAccounts).find(e=>e.enabled&&e.identity!==null&&e.identity.accountId===o.accountId&&e.identity.organizationId===o.organizationId);n!==void 0&&F(e.id,`lastUsed.save`,{provider:t,accountId:n.id,model:r}).catch($)}}function ag(e){let t={...Z().settings,...e};Q({settings:t});let n=Z().selection;n!==null&&(n.sessionId!==null&&Ca(Uh(n),t),e.accountId!==void 0&&ug(),n.sessionId!==null&&Bh(Z().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&F(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($))}function og(e,t){if(zh(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Z().selection?.machine!==e)return;let n=Z().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=Z().selection?.sessionId===null?r.at(0):void 0;i===void 0?a===void 0?n.accountId!==null&&ag({accountId:null}):ag({...ng(Ih(Z(),e),a.provider),accountId:a.accountId}):ag({accountId:i.accountId})}function sg(e){let t=Z().selection;t?.machine===e&&t.sessionId===null&&(Q({settings:rg(Ih(Z(),e))}),cg(e))}function cg(e){let t=Ih(Z(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&og(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),ug()}async function lg(e){try{og(e,await F(e,`accounts.list`,void 0))}catch(e){$(e)}}async function ug(){let e=Z().selection;if(e===null)return;let{provider:t,accountId:n}=Z().settings;if(t!==`opencode`&&n===null)Q({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if($h?.key!==r){let i=F(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){$h?.result===i&&($h=null)}i.then(a,a),$h={key:r,result:i}}let i=await $h.result;if(Z().selection?.machine!==e.machine||Z().selection?.projectId!==e.projectId||Z().settings.provider!==t||Z().settings.accountId!==n)return;Q({capabilities:i});let a=Z().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&ag({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;ag({model:o.value,effort:eg(Ih(Z(),e.machine),t,o.value)??o.effort})}catch(e){$(e)}}var dg=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{mh as $,va as $t,Yh as A,cm as At,bh as B,Ep as Bt,zh as C,Dn as Cn,Pm as Ct,Gh as D,D as Dn,um as Dt,qh as E,O as En,dm as Et,kh as F,bm as Ft,oh as G,_a as Gt,eh as H,xp as Ht,Dh as I,am as It,yh as J,Ta as Jt,dh as K,xa as Kt,Oh as L,sm as Lt,Q as M,wm as Mt,Zh as N,im as Nt,Jh as O,c as On,Cm as Ot,Fh as P,om as Pt,_h as Q,Oa as Qt,wh as R,nm as Rt,Wh as S,On as Sn,Rm as St,$ as T,Oe as Tn,_m as Tt,ph as U,zf as Ut,uh as V,Mp as Vt,th as W,ka as Wt,lh as X,ya as Xt,ah as Y,Ea as Yt,gh as Z,ha as Zt,Ih as _,ti as _n,zm as _t,lg as a,Ji as an,Gm as at,Vh as b,tr as bn,Am as bt,tg as c,Ii as cn,Im as ct,Bh as d,Ri as dn,Vm as dt,Ca as en,sh as et,Nh as f,ji as fn,Dm as ft,Z as g,ei as gn,Km as gt,Uh as h,Zr as hn,Wm as ht,ng as i,Yi as in,Om as it,Ph as j,ym as jt,Xh as k,lm as kt,ig as l,Fi as ln,jm as lt,Qh as m,mi as mn,Mm as mt,ag as n,ga as nn,hh as nt,ug as o,F as on,Um as ot,Rh as p,fi as pn,Em as pt,ih as q,Sa as qt,eg as r,wa as rn,X as rt,sg as s,Ni as sn,Bm as st,dg as t,Da as tn,ch as tt,og as u,Li as un,Hm as ut,Lh as v,Pr as vn,Lm as vt,Kh as w,_t as wn,rm as wt,Hh as x,An as xn,Fm as xt,jh as y,cr as yn,Nm as yt,Th as z,Y as zt};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{a as t,c as n,o as r,r as i,t as a}from"./panel-close-button-ByrJIu34.js";import{n as o,r as s,t as c}from"./TextWrapIcon-BRhMbXe9.js";import{t as l}from"./ChevronsDownUpIcon-BNVFd2te.js";import{a as u,t as d}from"./button-BnzxfmO3.js";import{An as f,Ft as p,G as m,Gn as h,N as g,P as _,W as v,Wn as y,at as b,cn as x,gt as S,ot as C,zt as w}from"./dist-Jliw2AH0.js";import{l as T,r as E,u as D}from"./utils-Cih_T9uV.js";import{F as O,M as k,j as A,m as j,rn as M}from"./XIcon-Tc8nkaoT.js";var N=[[`path`,{d:`M18.2505 10.5H19.6403C21.4918 10.5 22.0421 10.7655 21.9975 12.0838C21.9237 14.2674 20.939 16.8047 17 17.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M5.94627 20.6145C2.57185 18.02 2.07468 14.3401 2.00143 10.5001C1.96979 8.8413 2.45126 8.5 4.65919 8.5H15.3408C17.5487 8.5 18.0302 8.8413 17.9986 10.5001C17.9253 14.3401 17.4281 18.02 14.0537 20.6145C13.0934 21.3528 12.2831 21.5 10.9194 21.5H9.08064C7.71686 21.5 6.90658 21.3528 5.94627 20.6145Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M11.3089 2.5C10.7622 2.83861 10.0012 4 10.0012 5.5M7.53971 4C7.53971 4 7 4.5 7 5.5M14.0012 4C13.7279 4.1693 13.5 5 13.5 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],P=[[`path`,{d:`M3.89124 3.89124C5.28249 2.5 7.52166 2.5 12 2.5C16.4783 2.5 18.7175 2.5 20.1088 3.89124C21.5 5.28249 21.5 7.52166 21.5 12C21.5 16.4783 21.5 18.7175 20.1088 20.1088C18.7175 21.5 16.4783 21.5 12 21.5C7.52166 21.5 5.28249 21.5 3.89124 20.1088C2.5 18.7175 2.5 16.4783 2.5 12C2.5 7.52166 2.5 5.28249 3.89124 3.89124Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 2.5V21.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}]],F=[[`path`,{d:`M2.49219 15.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M2.49219 8.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2.49219 12C2.49219 7.52166 2.49219 5.28249 3.88343 3.89124C5.27467 2.5 7.51384 2.5 11.9922 2.5C16.4705 2.5 18.7097 2.5 20.1009 3.89124C21.4922 5.28249 21.4922 7.52166 21.4922 12C21.4922 16.4783 21.4922 18.7175 20.1009 20.1088C18.7097 21.5 16.4705 21.5 11.9922 21.5C7.51384 21.5 5.27467 21.5 3.88343 20.1088C2.49219 18.7175 2.49219 16.4783 2.49219 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}]],I=e(D(),1);function L(e){let t=(0,I.useRef)(e);return(0,I.useInsertionEffect)(()=>void(t.current=e)),(0,I.useCallback)((...e)=>t.current(...e),[])}var R=T(),z=(0,I.createContext)(void 0);function ee(){return(0,I.useContext)(z)}var B={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},V={display:`contents`};function H(){return null}function U({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:p=w}){let m=n?.(e),h=r?.(e),g=i?.(e),_=a?.(e);return(0,R.jsxs)(R.Fragment,{children:[m==null?(0,R.jsxs)(R.Fragment,{children:[h!=null&&(0,R.jsx)(`div`,{slot:`header-prefix`,children:h}),g!=null&&(0,R.jsx)(`div`,{slot:`header-filename-suffix`,children:g}),_!=null&&(0,R.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,R.jsx)(`div`,{slot:f,children:m}),o!=null&&l?.map((t,n)=>(0,R.jsx)(`div`,{slot:p(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=W(t,e);return(0,R.jsx)(`div`,{slot:n,style:V,children:c(t,d)},n)}),s!=null&&(0,R.jsx)(`div`,{slot:`gutter-utility-slot`,style:B,children:s(u)})]})}function W(e,t){let n=g(e,t);return n==null?void 0:_({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var G=(0,I.createContext)(void 0);function K(e,t){return typeof window>`u`&&t!=null?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,R.jsx)(R.Fragment,{children:e})}var q=(0,I.createContext)(void 0);function J(){return(0,I.useContext)(q)}function Y(){let[e]=(0,I.useState)(()=>{let e=0,t;return{getSnapshot:()=>e,subscribe(e){return t=e,()=>{t=void 0}},forceUpdate(){e++,t?.()}}});return(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),e.forceUpdate}function te(e,t){"use no memo";return e.current?.__getNextRenderData(t)}var ne=typeof window>`u`?I.useEffect:I.useLayoutEffect;function re({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:g,onEditComplete:_}){let y=J(),b=s!==void 0,S=(0,I.useContext)(G),C=ee(),[T,E]=(0,I.useState)(),D=L(e=>g?.(e)),O=g==null?void 0:D,k=(0,I.useRef)(null),A=L(r=>{let i=_?.(r)??`reject`;return i===`accept`&&(k.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),j=_==null?void 0:A,M=ie({acceptedCache:k,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),N=(0,I.useRef)(null),P=Y(),F=te(N,ae(k,M,o))??{fileDiff:M,lineAnnotations:o??h},R=(0,I.useRef)(null),z=(0,I.useRef)(null),B=L(()=>{if(C==null)throw Error(`FileDiff: EditContext is not attached`);return C(`file-diff`,i??{},a)}),V=L(e=>{if(e!=null){if(N.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);y==null?N.current=new m(Q({controlledSelection:b,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:O,onEditComplete:j,options:r}),f?void 0:S,P):N.current=new v(Q({controlledSelection:b,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:O,onEditComplete:j,options:r}),y,l,f?void 0:S,P),N.current.hydrate({fileDiff:M,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(N.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);z.current=null,N.current.cleanUp(),N.current=null,R.current=null}});ne(()=>{let{current:e}=N;if(e==null)return;let t=Q({controlledSelection:b,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:O,onEditComplete:j,options:r}),n=!x(e.options,t);if(e.setOptions(t),!p&&(z.current=null,R.current!=null)){let{current:e}=R;R.current=null,e()}let i=oe(M,o,k);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||R.current!=null)return;if(C==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{N.current===e&&R.current==null&&e.__canAttachEditor()&&(R.current=se(e,B),P())};if(e.__canAttachEditor()){z.current=null,a();return}let c=e.__prepareForEditing();if(c==null){z.current=null;return}if(z.current?.promise===c)return;let l={promise:c};z.current=l,c.then(()=>{z.current===l&&(a(),z.current=null)}).catch(e=>{z.current===l&&(z.current=null,E(e))})});let H=(0,I.useCallback)(()=>N.current?.getHoveredLine(),[]),U=(0,I.useCallback)(e=>N.current?.getAnnotationSlotName(e)??w(e),[]);if(T!=null)throw T;return{...F,ref:V,getHoveredLine:H,getAnnotationSlotName:U}}function ie({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,I.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(X(r,n,o.stale)||X(r,n,o.installed))return o.fileDiff;a.filePair=null}return b(r??null,n??null,i)},[e,t,r,n,i])}function X(e,t,n){return p(e??void 0,n.oldFile??void 0)&&p(t??void 0,n.newFile??void 0)}function ae(e,t,n){"use no memo";return Z(t,n,e.current)}function Z(e,t,n){return{fileDiff:n?.fileDiff!=null&&S(e,n.fileDiff.stale)?n.fileDiff.installed:e,lineAnnotations:n?.annotations!=null&&t===n.annotations.stale?n.annotations.installed:t}}function oe(e,t,n){let{current:r}=n,i=Z(e,t,r);return r==null||(r.fileDiff!=null&&!S(e,r.fileDiff.stale)&&(r.fileDiff=null),t!==r.annotations?.stale&&(r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null)),i}function Q({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return{...e,controlledSelection:t,renderCustomHeader:n?H:e?.renderCustomHeader,renderGutterUtility:r?H:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}}function se(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function ce({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1,onEditChange:v,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C,fileDiff:w,lineAnnotations:T}=re({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_,onEditChange:v,onEditComplete:b}),E=U({fileDiff:w,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,renderGutterUtility:h,lineAnnotations:T,getHoveredLine:S,getAnnotationSlotName:C});return(0,R.jsx)(y,{ref:x,className:s,style:c,children:K(E,l)})}var le=3e3,ue=`text-foreground hover:bg-accent aria-pressed:bg-accent inline-flex h-7 min-w-7 cursor-pointer items-center justify-center rounded-lg px-1.5 [&_svg]:opacity-80`,$=`text-muted-foreground hover:text-foreground aria-pressed:bg-background aria-pressed:text-foreground dark:aria-pressed:bg-input/72 inline-flex h-6 cursor-pointer items-center justify-center rounded-md px-2.5 aria-pressed:shadow-xs`;function de(e){let[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(0),v=(0,I.useRef)({patch:null,count:0}),y=k(e=>e.prefs.diff),b=O(),[x,S]=i(`diffFlipped`,[]);function w(e){A({...j().prefs,diff:{...y,...e}})}(0,I.useEffect)(()=>{let t=!0,n=!1;async function r(){if(!n){n=!0;try{let n=await M(e.machine,`git.diff`,{projectId:e.projectId});if(!t||(h(null),n===v.current.patch))return;v.current={patch:n,count:v.current.count+1},p(n.trim()===``?[]:C(n,`${e.projectId}:${v.current.count}`).flatMap(e=>e.files))}catch(e){t&&h(E(e))}finally{n=!1}}}function i(){document.hidden||r()}r();let a=window.setInterval(i,le);return window.addEventListener(`focus`,i),()=>{t=!1,window.clearInterval(a),window.removeEventListener(`focus`,i)}},[e.machine,e.projectId,e.running,g]);let T=f??[],D=n(T,e=>n(e.hunks,e=>e.additionLines)),L=n(T,e=>n(e.hunks,e=>e.deletionLines));return(0,R.jsxs)(`div`,{className:`bg-background flex h-full min-h-0 min-w-0 flex-col`,children:[(0,R.jsxs)(`div`,{className:`border-border/60 bg-background flex h-(--workspace-topbar-height) shrink-0 items-center justify-between gap-2 border-b pr-3 pl-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(a,{mobile:e.mobile,onClick:e.onClose}),(0,R.jsx)(`span`,{className:`text-foreground min-w-0 truncate text-xs font-medium`,children:`Uncommitted changes`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[T.length>0&&(0,R.jsxs)(`span`,{className:`text-2xs mr-1 inline-flex items-center gap-1 font-mono tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`text-diff-addition`,children:[`+`,D]}),(0,R.jsxs)(`span`,{className:`text-diff-deletion`,children:[`-`,L]})]}),(0,R.jsx)(d,{size:`icon-sm`,variant:`ghost`,title:`Refresh diff`,"aria-label":`Refresh diff`,onClick:()=>_(g+1),children:(0,R.jsx)(u,{icon:o,className:`size-4`})}),T.length>0&&(0,R.jsx)(d,{size:`icon-sm`,variant:`ghost`,title:y.collapsed?`Expand all files`:`Collapse all files`,onClick:()=>{S([]),w({collapsed:!y.collapsed})},children:(0,R.jsx)(u,{icon:y.collapsed?t:l,className:`size-4`})}),(0,R.jsxs)(`div`,{className:`bg-input/40 flex shrink-0 items-center rounded-lg p-0.5`,children:[(0,R.jsx)(`button`,{className:$,"aria-pressed":!y.split,"aria-label":`Stacked diff view`,onClick:()=>w({split:!1}),children:(0,R.jsx)(u,{icon:F,className:`size-3.5`})}),(0,R.jsx)(`button`,{className:$,"aria-pressed":y.split,"aria-label":`Split diff view`,onClick:()=>w({split:!0}),children:(0,R.jsx)(u,{icon:P,className:`size-3.5`})})]}),(0,R.jsx)(`button`,{className:ue,"aria-pressed":y.wrap,title:y.wrap?`Disable line wrapping`:`Enable line wrapping`,onClick:()=>w({wrap:!y.wrap}),children:(0,R.jsx)(u,{icon:c,className:`size-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`diff-render-surface min-h-0 flex-1 overflow-y-auto [--code-background:var(--background)]`,children:[m!==null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:m}),m===null&&f===null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:`Loading…`}),m===null&&f?.length===0&&(0,R.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,R.jsx)(u,{icon:N,className:`text-muted-foreground/40 size-8`}),(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No uncommitted changes`}),(0,R.jsx)(`p`,{className:`text-muted-foreground/50 text-xs italic`,children:`If it works, don’t touch it.`})]})]}),m===null&&T.map(e=>{let t=y.collapsed!==x.includes(e.name);function n(){S(x.includes(e.name)?x.filter(t=>t!==e.name):[...x,e.name])}return(0,R.jsx)(`div`,{onClick:e=>{e.nativeEvent.composedPath().some(e=>e instanceof Element&&e.hasAttribute(`data-title`))&&n()},children:(0,R.jsx)(ce,{fileDiff:e,options:{theme:b,themeType:`dark`,unsafeCSS:`:host,
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{a as t,c as n,o as r,r as i,t as a}from"./panel-close-button-yIEA8ujQ.js";import{n as o,r as s,t as c}from"./TextWrapIcon-BRhMbXe9.js";import{t as l}from"./ChevronsDownUpIcon-BNVFd2te.js";import{a as u,t as d}from"./button-BnzxfmO3.js";import{An as f,Ft as p,G as m,Gn as h,N as g,P as _,W as v,Wn as y,at as b,cn as x,gt as S,ot as C,zt as w}from"./dist-Jliw2AH0.js";import{l as T,r as E,u as D}from"./utils-Cih_T9uV.js";import{L as O,N as k,P as A,g as j,on as M}from"./XIcon-sNE7wlGT.js";var N=[[`path`,{d:`M18.2505 10.5H19.6403C21.4918 10.5 22.0421 10.7655 21.9975 12.0838C21.9237 14.2674 20.939 16.8047 17 17.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M5.94627 20.6145C2.57185 18.02 2.07468 14.3401 2.00143 10.5001C1.96979 8.8413 2.45126 8.5 4.65919 8.5H15.3408C17.5487 8.5 18.0302 8.8413 17.9986 10.5001C17.9253 14.3401 17.4281 18.02 14.0537 20.6145C13.0934 21.3528 12.2831 21.5 10.9194 21.5H9.08064C7.71686 21.5 6.90658 21.3528 5.94627 20.6145Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M11.3089 2.5C10.7622 2.83861 10.0012 4 10.0012 5.5M7.53971 4C7.53971 4 7 4.5 7 5.5M14.0012 4C13.7279 4.1693 13.5 5 13.5 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],P=[[`path`,{d:`M3.89124 3.89124C5.28249 2.5 7.52166 2.5 12 2.5C16.4783 2.5 18.7175 2.5 20.1088 3.89124C21.5 5.28249 21.5 7.52166 21.5 12C21.5 16.4783 21.5 18.7175 20.1088 20.1088C18.7175 21.5 16.4783 21.5 12 21.5C7.52166 21.5 5.28249 21.5 3.89124 20.1088C2.5 18.7175 2.5 16.4783 2.5 12C2.5 7.52166 2.5 5.28249 3.89124 3.89124Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 2.5V21.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}]],F=[[`path`,{d:`M2.49219 15.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M2.49219 8.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2.49219 12C2.49219 7.52166 2.49219 5.28249 3.88343 3.89124C5.27467 2.5 7.51384 2.5 11.9922 2.5C16.4705 2.5 18.7097 2.5 20.1009 3.89124C21.4922 5.28249 21.4922 7.52166 21.4922 12C21.4922 16.4783 21.4922 18.7175 20.1009 20.1088C18.7097 21.5 16.4705 21.5 11.9922 21.5C7.51384 21.5 5.27467 21.5 3.88343 20.1088C2.49219 18.7175 2.49219 16.4783 2.49219 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}]],I=e(D(),1);function L(e){let t=(0,I.useRef)(e);return(0,I.useInsertionEffect)(()=>void(t.current=e)),(0,I.useCallback)((...e)=>t.current(...e),[])}var R=T(),z=(0,I.createContext)(void 0);function ee(){return(0,I.useContext)(z)}var B={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},V={display:`contents`};function H(){return null}function U({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:p=w}){let m=n?.(e),h=r?.(e),g=i?.(e),_=a?.(e);return(0,R.jsxs)(R.Fragment,{children:[m==null?(0,R.jsxs)(R.Fragment,{children:[h!=null&&(0,R.jsx)(`div`,{slot:`header-prefix`,children:h}),g!=null&&(0,R.jsx)(`div`,{slot:`header-filename-suffix`,children:g}),_!=null&&(0,R.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,R.jsx)(`div`,{slot:f,children:m}),o!=null&&l?.map((t,n)=>(0,R.jsx)(`div`,{slot:p(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=W(t,e);return(0,R.jsx)(`div`,{slot:n,style:V,children:c(t,d)},n)}),s!=null&&(0,R.jsx)(`div`,{slot:`gutter-utility-slot`,style:B,children:s(u)})]})}function W(e,t){let n=g(e,t);return n==null?void 0:_({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var G=(0,I.createContext)(void 0);function K(e,t){return typeof window>`u`&&t!=null?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,R.jsx)(R.Fragment,{children:e})}var q=(0,I.createContext)(void 0);function J(){return(0,I.useContext)(q)}function Y(){let[e]=(0,I.useState)(()=>{let e=0,t;return{getSnapshot:()=>e,subscribe(e){return t=e,()=>{t=void 0}},forceUpdate(){e++,t?.()}}});return(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),e.forceUpdate}function te(e,t){"use no memo";return e.current?.__getNextRenderData(t)}var ne=typeof window>`u`?I.useEffect:I.useLayoutEffect;function re({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:g,onEditComplete:_}){let y=J(),b=s!==void 0,S=(0,I.useContext)(G),C=ee(),[T,E]=(0,I.useState)(),D=L(e=>g?.(e)),O=g==null?void 0:D,k=(0,I.useRef)(null),A=L(r=>{let i=_?.(r)??`reject`;return i===`accept`&&(k.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),j=_==null?void 0:A,M=ie({acceptedCache:k,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),N=(0,I.useRef)(null),P=Y(),F=te(N,ae(k,M,o))??{fileDiff:M,lineAnnotations:o??h},R=(0,I.useRef)(null),z=(0,I.useRef)(null),B=L(()=>{if(C==null)throw Error(`FileDiff: EditContext is not attached`);return C(`file-diff`,i??{},a)}),V=L(e=>{if(e!=null){if(N.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);y==null?N.current=new m(Q({controlledSelection:b,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:O,onEditComplete:j,options:r}),f?void 0:S,P):N.current=new v(Q({controlledSelection:b,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:O,onEditComplete:j,options:r}),y,l,f?void 0:S,P),N.current.hydrate({fileDiff:M,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(N.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);z.current=null,N.current.cleanUp(),N.current=null,R.current=null}});ne(()=>{let{current:e}=N;if(e==null)return;let t=Q({controlledSelection:b,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:O,onEditComplete:j,options:r}),n=!x(e.options,t);if(e.setOptions(t),!p&&(z.current=null,R.current!=null)){let{current:e}=R;R.current=null,e()}let i=oe(M,o,k);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||R.current!=null)return;if(C==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{N.current===e&&R.current==null&&e.__canAttachEditor()&&(R.current=se(e,B),P())};if(e.__canAttachEditor()){z.current=null,a();return}let c=e.__prepareForEditing();if(c==null){z.current=null;return}if(z.current?.promise===c)return;let l={promise:c};z.current=l,c.then(()=>{z.current===l&&(a(),z.current=null)}).catch(e=>{z.current===l&&(z.current=null,E(e))})});let H=(0,I.useCallback)(()=>N.current?.getHoveredLine(),[]),U=(0,I.useCallback)(e=>N.current?.getAnnotationSlotName(e)??w(e),[]);if(T!=null)throw T;return{...F,ref:V,getHoveredLine:H,getAnnotationSlotName:U}}function ie({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,I.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(X(r,n,o.stale)||X(r,n,o.installed))return o.fileDiff;a.filePair=null}return b(r??null,n??null,i)},[e,t,r,n,i])}function X(e,t,n){return p(e??void 0,n.oldFile??void 0)&&p(t??void 0,n.newFile??void 0)}function ae(e,t,n){"use no memo";return Z(t,n,e.current)}function Z(e,t,n){return{fileDiff:n?.fileDiff!=null&&S(e,n.fileDiff.stale)?n.fileDiff.installed:e,lineAnnotations:n?.annotations!=null&&t===n.annotations.stale?n.annotations.installed:t}}function oe(e,t,n){let{current:r}=n,i=Z(e,t,r);return r==null||(r.fileDiff!=null&&!S(e,r.fileDiff.stale)&&(r.fileDiff=null),t!==r.annotations?.stale&&(r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null)),i}function Q({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return{...e,controlledSelection:t,renderCustomHeader:n?H:e?.renderCustomHeader,renderGutterUtility:r?H:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}}function se(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function ce({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1,onEditChange:v,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C,fileDiff:w,lineAnnotations:T}=re({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_,onEditChange:v,onEditComplete:b}),E=U({fileDiff:w,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,renderGutterUtility:h,lineAnnotations:T,getHoveredLine:S,getAnnotationSlotName:C});return(0,R.jsx)(y,{ref:x,className:s,style:c,children:K(E,l)})}var le=3e3,ue=`text-foreground hover:bg-accent aria-pressed:bg-accent inline-flex h-7 min-w-7 cursor-pointer items-center justify-center rounded-lg px-1.5 [&_svg]:opacity-80`,$=`text-muted-foreground hover:text-foreground aria-pressed:bg-background aria-pressed:text-foreground dark:aria-pressed:bg-input/72 inline-flex h-6 cursor-pointer items-center justify-center rounded-md px-2.5 aria-pressed:shadow-xs`;function de(e){let[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(0),v=(0,I.useRef)({patch:null,count:0}),y=A(e=>e.prefs.diff),b=O(),[x,S]=i(`diffFlipped`,[]);function w(e){k({...j().prefs,diff:{...y,...e}})}(0,I.useEffect)(()=>{let t=!0,n=!1;async function r(){if(!n){n=!0;try{let n=await M(e.machine,`git.diff`,{projectId:e.projectId});if(!t||(h(null),n===v.current.patch))return;v.current={patch:n,count:v.current.count+1},p(n.trim()===``?[]:C(n,`${e.projectId}:${v.current.count}`).flatMap(e=>e.files))}catch(e){t&&h(E(e))}finally{n=!1}}}function i(){document.hidden||r()}r();let a=window.setInterval(i,le);return window.addEventListener(`focus`,i),()=>{t=!1,window.clearInterval(a),window.removeEventListener(`focus`,i)}},[e.machine,e.projectId,e.running,g]);let T=f??[],D=n(T,e=>n(e.hunks,e=>e.additionLines)),L=n(T,e=>n(e.hunks,e=>e.deletionLines));return(0,R.jsxs)(`div`,{className:`bg-background flex h-full min-h-0 min-w-0 flex-col`,children:[(0,R.jsxs)(`div`,{className:`border-border/60 bg-background flex h-(--workspace-topbar-height) shrink-0 items-center justify-between gap-2 border-b pr-3 pl-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(a,{mobile:e.mobile,onClick:e.onClose}),(0,R.jsx)(`span`,{className:`text-foreground min-w-0 truncate text-xs font-medium`,children:`Uncommitted changes`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[T.length>0&&(0,R.jsxs)(`span`,{className:`text-2xs mr-1 inline-flex items-center gap-1 font-mono tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`text-diff-addition`,children:[`+`,D]}),(0,R.jsxs)(`span`,{className:`text-diff-deletion`,children:[`-`,L]})]}),(0,R.jsx)(d,{size:`icon-sm`,variant:`ghost`,title:`Refresh diff`,"aria-label":`Refresh diff`,onClick:()=>_(g+1),children:(0,R.jsx)(u,{icon:o,className:`size-4`})}),T.length>0&&(0,R.jsx)(d,{size:`icon-sm`,variant:`ghost`,title:y.collapsed?`Expand all files`:`Collapse all files`,onClick:()=>{S([]),w({collapsed:!y.collapsed})},children:(0,R.jsx)(u,{icon:y.collapsed?t:l,className:`size-4`})}),(0,R.jsxs)(`div`,{className:`bg-input/40 flex shrink-0 items-center rounded-lg p-0.5`,children:[(0,R.jsx)(`button`,{className:$,"aria-pressed":!y.split,"aria-label":`Stacked diff view`,onClick:()=>w({split:!1}),children:(0,R.jsx)(u,{icon:F,className:`size-3.5`})}),(0,R.jsx)(`button`,{className:$,"aria-pressed":y.split,"aria-label":`Split diff view`,onClick:()=>w({split:!0}),children:(0,R.jsx)(u,{icon:P,className:`size-3.5`})})]}),(0,R.jsx)(`button`,{className:ue,"aria-pressed":y.wrap,title:y.wrap?`Disable line wrapping`:`Enable line wrapping`,onClick:()=>w({wrap:!y.wrap}),children:(0,R.jsx)(u,{icon:c,className:`size-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`diff-render-surface min-h-0 flex-1 overflow-y-auto [--code-background:var(--background)]`,children:[m!==null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:m}),m===null&&f===null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:`Loading…`}),m===null&&f?.length===0&&(0,R.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,R.jsx)(u,{icon:N,className:`text-muted-foreground/40 size-8`}),(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No uncommitted changes`}),(0,R.jsx)(`p`,{className:`text-muted-foreground/50 text-xs italic`,children:`If it works, don’t touch it.`})]})]}),m===null&&T.map(e=>{let t=y.collapsed!==x.includes(e.name);function n(){S(x.includes(e.name)?x.filter(t=>t!==e.name):[...x,e.name])}return(0,R.jsx)(`div`,{onClick:e=>{e.nativeEvent.composedPath().some(e=>e instanceof Element&&e.hasAttribute(`data-title`))&&n()},children:(0,R.jsx)(ce,{fileDiff:e,options:{theme:b,themeType:`dark`,unsafeCSS:`:host,
|
|
2
2
|
[data-diffs-header],
|
|
3
3
|
[data-diff],
|
|
4
4
|
[data-file],
|