local-operator-ui 0.41.0 → 0.41.1
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/out/main/index.js +0 -24
- package/out/renderer/assets/{_basePickBy--UFblcLV.js → _basePickBy-BP7Q8i4W.js} +1 -1
- package/out/renderer/assets/{_baseUniq-Ct7pRnI4.js → _baseUniq-D36dAcoY.js} +1 -1
- package/out/renderer/assets/{agent-details-page-Col1VcjS.js → agent-details-page-D3ljlPdf.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-CTPn6yGs.js → agent-hub-page-BMyIHnNM.js} +2 -2
- package/out/renderer/assets/{agents-page-CBWj1DTr.js → agents-page-mMqgQd2V.js} +3 -3
- package/out/renderer/assets/{arc-B-YNVaQW.js → arc-GVvow4so.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DCzmuMLj.js → architectureDiagram-IEHRJDOE-BjGwXAtH.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-f1GS2_U0.js → blockDiagram-JOT3LUYC-BTuigKlt.js} +1 -1
- package/out/renderer/assets/{book-open-Cb4F-cRs.js → book-open-C1uak1LZ.js} +1 -1
- package/out/renderer/assets/browser-page-B3mjDx8k.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-ghcPWp0R.js → browser-webauthn-prompt-CzYoJfO4.js} +1 -1
- package/out/renderer/assets/{building-2-C_YBTC7O.js → building-2-Bpz1qaDa.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-BlePs8Im.js → c4Diagram-VJAJSXHY-DK7eaKE8.js} +1 -1
- package/out/renderer/assets/channel-B05rL6In.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-Bse1IaHb.js → chunk-4BMEZGHF-DkQrsDhM.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CncpJ5It.js → chunk-A2AXSNBT-guh0INPR.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-37Z6jWz2.js → chunk-AEK57VVT-DvgIx6-r.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-BR9ZpBMV.js → chunk-D6G4REZN-FNdvnFYo.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-KrZ6g0pV.js → chunk-RZ5BOZE2-CgCQC9Mn.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-BUwRYMe9.js → chunk-XZIHB7SX-D1VRTTc4.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DpB8-8cT.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DpB8-8cT.js +1 -0
- package/out/renderer/assets/clone-BHHjv3HP.js +1 -0
- package/out/renderer/assets/{console-mirror-DPVG6sWK.js → console-mirror-DRkz3vUY.js} +1 -1
- package/out/renderer/assets/{consoleCapture-Coky9UhD.js → consoleCapture-BJfSUatx.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-C2vqs6ad.js → conversation-input-sync-CJU5GIzR.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-CGv1CEcm.js → dagre-OKDRZEBW-DeeYQh6O.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-u_zFGYu8.js → diagram-SSKATNLV-DD-xNxKH.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-Bme6bFvQ.js → diagram-VNBRO52H-YAoPlXaR.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-B-KkjVtc.js → erDiagram-Q7BY3M3F-OKzGXyMI.js} +1 -1
- package/out/renderer/assets/{error-boundary-DJSaJHcb.js → error-boundary-ZYkSCpZC.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CSZy2b_d.js → flowDiagram-4HSFHLVR-BG-3pPqS.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CpYOSVKU.js → ganttDiagram-APWFNJXF-CRyD5vsE.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-WOOSBsBb.js → gitGraphDiagram-7IBYFJ6S-aly2C__q.js} +1 -1
- package/out/renderer/assets/{graph-Du8nFp-Q.js → graph-CCWwMmhg.js} +1 -1
- package/out/renderer/assets/hash-BN0ECl3H.js +6 -0
- package/out/renderer/assets/{heart-CVGkdUzT.js → heart-tKYqMVIH.js} +1 -1
- package/out/renderer/assets/index-BDzV3bGH.js +57 -0
- package/out/renderer/assets/{index-fw54FEnm.js → index-BaNzqqGN.js} +1 -1
- package/out/renderer/assets/{index-D8L83jtw.js → index-CRjnV9wx.js} +199 -199
- package/out/renderer/assets/{index-AGCqaeOI.js → index-DaCf2W9T.js} +1 -1
- package/out/renderer/assets/index-ZovyVTxQ.css +1 -0
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-BprulvMk.js → infoDiagram-PH2N3AL5-BY536sF5.js} +1 -1
- package/out/renderer/assets/{installer-muZhWyyS.js → installer-Dw1P6j8q.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DfdLRQAF.js → journeyDiagram-U35MCT3I-DGvx__t6.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-R6IsuYWB.js → kanban-definition-NDS4AKOZ-CG2Lgkpw.js} +1 -1
- package/out/renderer/assets/{layout-05Xak_7z.js → layout-vpRrwE7T.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-Dpl33Kla.js → legacy-agents-page-D6Yma1Gm.js} +6 -6
- package/out/renderer/assets/library-page-B0gC-rRh.js +157 -0
- package/out/renderer/assets/{mermaid.core-BzKfajYZ.js → mermaid.core-COeGB8I0.js} +5 -5
- package/out/renderer/assets/{mesh-page-D6ZzFOeG.js → mesh-page-PabU05tN.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dn_l0i7j.js → mindmap-definition-ALO5MXBD-B0hkjZLY.js} +1 -1
- package/out/renderer/assets/{mini-BgJE9L7J.js → mini-Df5C4rpd.js} +1 -1
- package/out/renderer/assets/{notebook-pen-CtAKsfVm.js → notebook-pen-C3CwzwGA.js} +1 -1
- package/out/renderer/assets/{org-access-BHt55LAw.js → org-access-BacMtLkn.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CqFJQYmV.js → org-surface-gate-tkB025lu.js} +1 -1
- package/out/renderer/assets/{page-header-BlIvE-Ti.js → page-header-6mrV9W-E.js} +1 -1
- package/out/renderer/assets/{path-utils-CYBk4q7C.js → path-utils-Ct0VTUZS.js} +2 -2
- package/out/renderer/assets/{pieDiagram-IB7DONF6-_W_OzAAk.js → pieDiagram-IB7DONF6-DfFtQXU5.js} +1 -1
- package/out/renderer/assets/{projects-page-DtZ_g9gZ.js → projects-page-CoHTKLZH.js} +1 -1
- package/out/renderer/assets/{publication-validation-D7f3xAgF.js → publication-validation-B0Mf3mmP.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-FQ5Wvxqm.js → quadrantDiagram-7GDLP6J5-C4eDJWaK.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-BRufXucA.js → radar-MK3ICKWK-BEv1HS9Q.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-7i7blC-7.js → radient-auth-buttons-BX5vf982.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CHO8Cq1H.js → requirementDiagram-KVF5MWMF-B7f3qUcB.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-C4JDJOwX.js → sankeyDiagram-QLVOVGJD-xM7E-74l.js} +1 -1
- package/out/renderer/assets/{schedules-page-6tPgFgS_.js → schedules-page-5q7pvL1H.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BFf3HnKw.js → sequenceDiagram-X6HHIX6F-upwR02kU.js} +1 -1
- package/out/renderer/assets/{settings-page-CXOFCx8w.js → settings-page-DcnGr-GP.js} +9 -9
- package/out/renderer/assets/{smartart-crAq3DvJ.js → smartart-CYnMNs5u.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-BqFVSIKA.js → stateDiagram-DGXRK772-BqTri7Q-.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D8Sl1QhX.js +1 -0
- package/out/renderer/assets/team-bridge-page-vnNJdCi3.js +16 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cp3uYUSs.js → timeline-definition-BDJGKUSR-Bi2is17s.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-C_W8yx0C.js → use-download-agent-mutation-PHtokPlg.js} +2 -2
- package/out/renderer/assets/{use-session-snapshot-vFZD5qIO.js → use-session-snapshot-B5sxthdQ.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DFcICu1Q.js → xychartDiagram-VJFVF3MP-B0TrjzLJ.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-BfJd3-qS.js +0 -1
- package/out/renderer/assets/channel-BFAjMbH6.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CmW0Ezdi.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CmW0Ezdi.js +0 -1
- package/out/renderer/assets/clone-B_pc7cSP.js +0 -1
- package/out/renderer/assets/hash--PQTQMu2.js +0 -6
- package/out/renderer/assets/index-ALGblIL0.css +0 -1
- package/out/renderer/assets/index-BYeiLB51.js +0 -57
- package/out/renderer/assets/library-page-BNrffbLi.js +0 -157
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-aaVC-oiG.js +0 -1
- package/out/renderer/assets/team-bridge-page-BgjJrT3v.js +0 -26
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as na,r as b,t as le,j as Yu,D as Qu}from"./index-BYeiLB51.js";var ne;(function(e){e.assertEqual=s=>s;function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),a={};for(const l of i)a[l]=s[l];return e.objectValues(a)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},e.find=(s,i)=>{for(const a of s)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(ne||(ne={}));var fi;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(fi||(fi={}));const M=ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=e=>{switch(typeof e){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(e)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(e)?M.array:e===null?M.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?M.promise:typeof Map<"u"&&e instanceof Map?M.map:typeof Set<"u"&&e instanceof Set?M.set:typeof Date<"u"&&e instanceof Date?M.date:M.object;default:return M.unknown}},E=ne.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ju=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ze extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let l=r,c=0;for(;c<a.path.length;){const d=a.path[c];c===a.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(n(a))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}};return s(this),r}static assert(t){if(!(t instanceof Ze))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ze.create=e=>new Ze(e);const wn=(e,t)=>{let n;switch(e.code){case E.invalid_type:e.received===M.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case E.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ne.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:n=`Unrecognized key(s) in object: ${ne.joinValues(e.keys,", ")}`;break;case E.invalid_union:n="Invalid input";break;case E.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ne.joinValues(e.options)}`;break;case E.invalid_enum_value:n=`Invalid enum value. Expected ${ne.joinValues(e.options)}, received '${e.received}'`;break;case E.invalid_arguments:n="Invalid function arguments";break;case E.invalid_return_type:n="Invalid function return type";break;case E.invalid_date:n="Invalid date";break;case E.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ne.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case E.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case E.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case E.custom:n="Invalid input";break;case E.invalid_intersection_types:n="Intersection results could not be merged";break;case E.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case E.not_finite:n="Number must be finite";break;default:n=t.defaultError,ne.assertNever(e)}return{message:n}};let rc=wn;function Xu(e){rc=e}function Kr(){return rc}const Yr=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const c=r.filter(d=>!!d).slice().reverse();for(const d of c)l=d(a,{data:t,defaultError:l}).message;return{...s,path:i,message:l}},qu=[];function P(e,t){const n=Kr(),r=Yr({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===wn?void 0:wn].filter(s=>!!s)});e.common.issues.push(r)}class Ne{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return B;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return Ne.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return B;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const B=Object.freeze({status:"aborted"}),hn=e=>({status:"dirty",value:e}),$e=e=>({status:"valid",value:e}),pi=e=>e.status==="aborted",hi=e=>e.status==="dirty",Jt=e=>e.status==="valid",Qn=e=>typeof Promise<"u"&&e instanceof Promise;function Qr(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function sc(e,t,n,r,s){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var N;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(N||(N={}));var Bn,Gn;class mt{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ra=(e,t)=>{if(Jt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ze(e.common.issues);return this._error=n,this._error}}};function Y(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(a,l)=>{var c,d;const{message:u}=e;return a.code==="invalid_enum_value"?{message:u??l.defaultError}:typeof l.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:l.defaultError}:a.code!=="invalid_type"?{message:l.defaultError}:{message:(d=u??n)!==null&&d!==void 0?d:l.defaultError}},description:s}}class Q{get description(){return this._def.description}_getType(t){return wt(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:wt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ne,ctx:{common:t.parent.common,data:t.data,parsedType:wt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Qn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const s={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)},i=this._parseSync({data:t,path:s.path,parent:s});return ra(s,i)}"~validate"(t){var n,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:s});return Jt(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(n=i?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:s}).then(i=>Jt(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(Qn(s)?s:Promise.resolve(s));return ra(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const a=t(s),l=()=>i.addIssue({code:E.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(l(),!1)):a?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new lt({schema:this,typeName:F.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ht.create(this,this._def)}nullable(){return Lt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return at.create(this)}promise(){return kn.create(this,this._def)}or(t){return er.create([this,t],this._def)}and(t){return tr.create(this,t,this._def)}transform(t){return new lt({...Y(this._def),schema:this,typeName:F.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new or({...Y(this._def),innerType:this,defaultValue:n,typeName:F.ZodDefault})}brand(){return new qi({typeName:F.ZodBranded,type:this,...Y(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new ar({...Y(this._def),innerType:this,catchValue:n,typeName:F.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return vr.create(this,t)}readonly(){return lr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ef=/^c[^\s-]{8,}$/i,tf=/^[0-9a-z]+$/,nf=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rf=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,sf=/^[a-z0-9_-]{21}$/i,of=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,af=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,lf=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ms;const df=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,uf=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ff=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pf=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hf=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mf=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ic="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",gf=new RegExp(`^${ic}$`);function oc(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function yf(e){return new RegExp(`^${oc(e)}$`)}function ac(e){let t=`${ic}T${oc(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function vf(e,t){return!!((t==="v4"||!t)&&df.test(e)||(t==="v6"||!t)&&ff.test(e))}function _f(e,t){if(!of.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function bf(e,t){return!!((t==="v4"||!t)&&uf.test(e)||(t==="v6"||!t)&&pf.test(e))}class ot extends Q{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==M.string){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_type,expected:M.string,received:i.parsedType}),B}const r=new Ne;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,l=t.data.length<i.value;(a||l)&&(s=this._getOrReturnCtx(t,s),a?P(s,{code:E.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&P(s,{code:E.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")lf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"email",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ms||(Ms=new RegExp(cf,"u")),Ms.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"emoji",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")rf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"uuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")sf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"nanoid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")ef.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"cuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")tf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"cuid2",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")nf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"ulid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),P(s,{validation:"url",code:E.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"regex",code:E.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?ac(i).test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?gf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?yf(i).test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?af.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"duration",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?vf(t.data,i.version)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"ip",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?_f(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"jwt",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?bf(t.data,i.version)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"cidr",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?hf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"base64",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?mf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"base64url",code:E.invalid_string,message:i.message}),r.dirty()):ne.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:E.invalid_string,...N.errToObj(r)})}_addCheck(t){return new ot({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...N.errToObj(t)})}url(t){return this._addCheck({kind:"url",...N.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...N.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...N.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...N.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...N.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...N.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...N.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...N.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...N.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...N.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...N.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...N.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...N.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...N.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...N.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...N.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...N.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...N.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...N.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...N.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...N.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...N.errToObj(n)})}nonempty(t){return this.min(1,N.errToObj(t))}trim(){return new ot({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ot({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ot({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ot.create=e=>{var t;return new ot({checks:[],typeName:F.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Y(e)})};function wf(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=parseInt(e.toFixed(s).replace(".","")),a=parseInt(t.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class Mt extends Q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==M.number){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_type,expected:M.number,received:i.parsedType}),B}let r;const s=new Ne;for(const i of this._def.checks)i.kind==="int"?ne.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),P(r,{code:E.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?wf(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),P(r,{code:E.not_finite,message:i.message}),s.dirty()):ne.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,N.toString(n))}gt(t,n){return this.setLimit("min",t,!1,N.toString(n))}lte(t,n){return this.setLimit("max",t,!0,N.toString(n))}lt(t,n){return this.setLimit("max",t,!1,N.toString(n))}setLimit(t,n,r,s){return new Mt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:N.toString(s)}]})}_addCheck(t){return new Mt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:N.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:N.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:N.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ne.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Mt.create=e=>new Mt({checks:[],typeName:F.ZodNumber,coerce:e?.coerce||!1,...Y(e)});class Dt extends Q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==M.bigint)return this._getInvalidInput(t);let r;const s=new Ne;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):ne.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return P(n,{code:E.invalid_type,expected:M.bigint,received:n.parsedType}),B}gte(t,n){return this.setLimit("min",t,!0,N.toString(n))}gt(t,n){return this.setLimit("min",t,!1,N.toString(n))}lte(t,n){return this.setLimit("max",t,!0,N.toString(n))}lt(t,n){return this.setLimit("max",t,!1,N.toString(n))}setLimit(t,n,r,s){return new Dt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:N.toString(s)}]})}_addCheck(t){return new Dt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:N.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Dt.create=e=>{var t;return new Dt({checks:[],typeName:F.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Y(e)})};class Jn extends Q{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==M.boolean){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.boolean,received:r.parsedType}),B}return $e(t.data)}}Jn.create=e=>new Jn({typeName:F.ZodBoolean,coerce:e?.coerce||!1,...Y(e)});class Xt extends Q{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==M.date){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_type,expected:M.date,received:i.parsedType}),B}if(isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_date}),B}const r=new Ne;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):ne.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Xt({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:N.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:N.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Xt.create=e=>new Xt({checks:[],coerce:e?.coerce||!1,typeName:F.ZodDate,...Y(e)});class Jr extends Q{_parse(t){if(this._getType(t)!==M.symbol){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.symbol,received:r.parsedType}),B}return $e(t.data)}}Jr.create=e=>new Jr({typeName:F.ZodSymbol,...Y(e)});class Xn extends Q{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.undefined,received:r.parsedType}),B}return $e(t.data)}}Xn.create=e=>new Xn({typeName:F.ZodUndefined,...Y(e)});class qn extends Q{_parse(t){if(this._getType(t)!==M.null){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.null,received:r.parsedType}),B}return $e(t.data)}}qn.create=e=>new qn({typeName:F.ZodNull,...Y(e)});class Sn extends Q{constructor(){super(...arguments),this._any=!0}_parse(t){return $e(t.data)}}Sn.create=e=>new Sn({typeName:F.ZodAny,...Y(e)});class Vt extends Q{constructor(){super(...arguments),this._unknown=!0}_parse(t){return $e(t.data)}}Vt.create=e=>new Vt({typeName:F.ZodUnknown,...Y(e)});class St extends Q{_parse(t){const n=this._getOrReturnCtx(t);return P(n,{code:E.invalid_type,expected:M.never,received:n.parsedType}),B}}St.create=e=>new St({typeName:F.ZodNever,...Y(e)});class Xr extends Q{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.void,received:r.parsedType}),B}return $e(t.data)}}Xr.create=e=>new Xr({typeName:F.ZodVoid,...Y(e)});class at extends Q{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==M.array)return P(n,{code:E.invalid_type,expected:M.array,received:n.parsedType}),B;if(s.exactLength!==null){const a=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(a||l)&&(P(n,{code:a?E.too_big:E.too_small,minimum:l?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(P(n,{code:E.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(P(n,{code:E.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,l)=>s.type._parseAsync(new mt(n,a,n.path,l)))).then(a=>Ne.mergeArray(r,a));const i=[...n.data].map((a,l)=>s.type._parseSync(new mt(n,a,n.path,l)));return Ne.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new at({...this._def,minLength:{value:t,message:N.toString(n)}})}max(t,n){return new at({...this._def,maxLength:{value:t,message:N.toString(n)}})}length(t,n){return new at({...this._def,exactLength:{value:t,message:N.toString(n)}})}nonempty(t){return this.min(1,t)}}at.create=(e,t)=>new at({type:e,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...Y(t)});function un(e){if(e instanceof ve){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ht.create(un(r))}return new ve({...e._def,shape:()=>t})}else return e instanceof at?new at({...e._def,type:un(e.element)}):e instanceof ht?ht.create(un(e.unwrap())):e instanceof Lt?Lt.create(un(e.unwrap())):e instanceof gt?gt.create(e.items.map(t=>un(t))):e}class ve extends Q{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ne.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==M.object){const d=this._getOrReturnCtx(t);return P(d,{code:E.invalid_type,expected:M.object,received:d.parsedType}),B}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),l=[];if(!(this._def.catchall instanceof St&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||l.push(d);const c=[];for(const d of a){const u=i[d],f=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new mt(s,f,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof St){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of l)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")l.length>0&&(P(s,{code:E.unrecognized_keys,keys:l}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of l){const f=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new mt(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const f=await u.key,p=await u.value;d.push({key:f,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Ne.mergeObjectSync(r,d)):Ne.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return N.errToObj,new ve({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,i,a,l;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(l=N.errToObj(t).message)!==null&&l!==void 0?l:c}:{message:c}}}:{}})}strip(){return new ve({...this._def,unknownKeys:"strip"})}passthrough(){return new ve({...this._def,unknownKeys:"passthrough"})}extend(t){return new ve({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ve({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:F.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new ve({...this._def,catchall:t})}pick(t){const n={};return ne.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new ve({...this._def,shape:()=>n})}omit(t){const n={};return ne.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new ve({...this._def,shape:()=>n})}deepPartial(){return un(this)}partial(t){const n={};return ne.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}),new ve({...this._def,shape:()=>n})}required(t){const n={};return ne.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ht;)i=i._def.innerType;n[r]=i}}),new ve({...this._def,shape:()=>n})}keyof(){return lc(ne.objectKeys(this.shape))}}ve.create=(e,t)=>new ve({shape:()=>e,unknownKeys:"strip",catchall:St.create(),typeName:F.ZodObject,...Y(t)});ve.strictCreate=(e,t)=>new ve({shape:()=>e,unknownKeys:"strict",catchall:St.create(),typeName:F.ZodObject,...Y(t)});ve.lazycreate=(e,t)=>new ve({shape:e,unknownKeys:"strip",catchall:St.create(),typeName:F.ZodObject,...Y(t)});class er extends Q{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const a=i.map(l=>new Ze(l.ctx.common.issues));return P(n,{code:E.invalid_union,unionErrors:a}),B}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=a.map(c=>new Ze(c));return P(n,{code:E.invalid_union,unionErrors:l}),B}}get options(){return this._def.options}}er.create=(e,t)=>new er({options:e,typeName:F.ZodUnion,...Y(t)});const _t=e=>e instanceof rr?_t(e.schema):e instanceof lt?_t(e.innerType()):e instanceof sr?[e.value]:e instanceof Nt?e.options:e instanceof ir?ne.objectValues(e.enum):e instanceof or?_t(e._def.innerType):e instanceof Xn?[void 0]:e instanceof qn?[null]:e instanceof ht?[void 0,..._t(e.unwrap())]:e instanceof Lt?[null,..._t(e.unwrap())]:e instanceof qi||e instanceof lr?_t(e.unwrap()):e instanceof ar?_t(e._def.innerType):[];class us extends Q{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.object)return P(n,{code:E.invalid_type,expected:M.object,received:n.parsedType}),B;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(P(n,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),B)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const a=_t(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of a){if(s.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);s.set(l,i)}}return new us({typeName:F.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...Y(r)})}}function mi(e,t){const n=wt(e),r=wt(t);if(e===t)return{valid:!0,data:e};if(n===M.object&&r===M.object){const s=ne.objectKeys(t),i=ne.objectKeys(e).filter(l=>s.indexOf(l)!==-1),a={...e,...t};for(const l of i){const c=mi(e[l],t[l]);if(!c.valid)return{valid:!1};a[l]=c.data}return{valid:!0,data:a}}else if(n===M.array&&r===M.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const a=e[i],l=t[i],c=mi(a,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===M.date&&r===M.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class tr extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,a)=>{if(pi(i)||pi(a))return B;const l=mi(i.value,a.value);return l.valid?((hi(i)||hi(a))&&n.dirty(),{status:n.value,value:l.data}):(P(r,{code:E.invalid_intersection_types}),B)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}tr.create=(e,t,n)=>new tr({left:e,right:t,typeName:F.ZodIntersection,...Y(n)});class gt extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.array)return P(r,{code:E.invalid_type,expected:M.array,received:r.parsedType}),B;if(r.data.length<this._def.items.length)return P(r,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B;!this._def.rest&&r.data.length>this._def.items.length&&(P(r,{code:E.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new mt(r,a,r.path,l)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>Ne.mergeArray(n,a)):Ne.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new gt({...this._def,rest:t})}}gt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gt({items:e,typeName:F.ZodTuple,rest:null,...Y(t)})};class nr extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.object)return P(r,{code:E.invalid_type,expected:M.object,received:r.parsedType}),B;const s=[],i=this._def.keyType,a=this._def.valueType;for(const l in r.data)s.push({key:i._parse(new mt(r,l,r.path,l)),value:a._parse(new mt(r,r.data[l],r.path,l)),alwaysSet:l in r.data});return r.common.async?Ne.mergeObjectAsync(n,s):Ne.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Q?new nr({keyType:t,valueType:n,typeName:F.ZodRecord,...Y(r)}):new nr({keyType:ot.create(),valueType:t,typeName:F.ZodRecord,...Y(n)})}}class qr extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.map)return P(r,{code:E.invalid_type,expected:M.map,received:r.parsedType}),B;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([l,c],d)=>({key:s._parse(new mt(r,l,r.path,[d,"key"])),value:i._parse(new mt(r,c,r.path,[d,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of a){const d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return B;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),l.set(d.value,u.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of a){const d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return B;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),l.set(d.value,u.value)}return{status:n.value,value:l}}}}qr.create=(e,t,n)=>new qr({valueType:t,keyType:e,typeName:F.ZodMap,...Y(n)});class qt extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.set)return P(r,{code:E.invalid_type,expected:M.set,received:r.parsedType}),B;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(P(r,{code:E.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(P(r,{code:E.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function a(c){const d=new Set;for(const u of c){if(u.status==="aborted")return B;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}const l=[...r.data.values()].map((c,d)=>i._parse(new mt(r,c,r.path,d)));return r.common.async?Promise.all(l).then(c=>a(c)):a(l)}min(t,n){return new qt({...this._def,minSize:{value:t,message:N.toString(n)}})}max(t,n){return new qt({...this._def,maxSize:{value:t,message:N.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}qt.create=(e,t)=>new qt({valueType:e,minSize:null,maxSize:null,typeName:F.ZodSet,...Y(t)});class gn extends Q{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.function)return P(n,{code:E.invalid_type,expected:M.function,received:n.parsedType}),B;function r(l,c){return Yr({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Kr(),wn].filter(d=>!!d),issueData:{code:E.invalid_arguments,argumentsError:c}})}function s(l,c){return Yr({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Kr(),wn].filter(d=>!!d),issueData:{code:E.invalid_return_type,returnTypeError:c}})}const i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof kn){const l=this;return $e(async function(...c){const d=new Ze([]),u=await l._def.args.parseAsync(c,i).catch(h=>{throw d.addIssue(r(c,h)),d}),f=await Reflect.apply(a,this,u);return await l._def.returns._def.type.parseAsync(f,i).catch(h=>{throw d.addIssue(s(f,h)),d})})}else{const l=this;return $e(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new Ze([r(c,d.error)]);const u=Reflect.apply(a,this,d.data),f=l._def.returns.safeParse(u,i);if(!f.success)throw new Ze([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new gn({...this._def,args:gt.create(t).rest(Vt.create())})}returns(t){return new gn({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new gn({args:t||gt.create([]).rest(Vt.create()),returns:n||Vt.create(),typeName:F.ZodFunction,...Y(r)})}}class rr extends Q{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}rr.create=(e,t)=>new rr({getter:e,typeName:F.ZodLazy,...Y(t)});class sr extends Q{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return P(n,{received:n.data,code:E.invalid_literal,expected:this._def.value}),B}return{status:"valid",value:t.data}}get value(){return this._def.value}}sr.create=(e,t)=>new sr({value:e,typeName:F.ZodLiteral,...Y(t)});function lc(e,t){return new Nt({values:e,typeName:F.ZodEnum,...Y(t)})}class Nt extends Q{constructor(){super(...arguments),Bn.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return P(n,{expected:ne.joinValues(r),received:n.parsedType,code:E.invalid_type}),B}if(Qr(this,Bn)||sc(this,Bn,new Set(this._def.values)),!Qr(this,Bn).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return P(n,{received:n.data,code:E.invalid_enum_value,options:r}),B}return $e(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Nt.create(t,{...this._def,...n})}exclude(t,n=this._def){return Nt.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Bn=new WeakMap;Nt.create=lc;class ir extends Q{constructor(){super(...arguments),Gn.set(this,void 0)}_parse(t){const n=ne.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==M.string&&r.parsedType!==M.number){const s=ne.objectValues(n);return P(r,{expected:ne.joinValues(s),received:r.parsedType,code:E.invalid_type}),B}if(Qr(this,Gn)||sc(this,Gn,new Set(ne.getValidEnumValues(this._def.values))),!Qr(this,Gn).has(t.data)){const s=ne.objectValues(n);return P(r,{received:r.data,code:E.invalid_enum_value,options:s}),B}return $e(t.data)}get enum(){return this._def.values}}Gn=new WeakMap;ir.create=(e,t)=>new ir({values:e,typeName:F.ZodNativeEnum,...Y(t)});class kn extends Q{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.promise&&n.common.async===!1)return P(n,{code:E.invalid_type,expected:M.promise,received:n.parsedType}),B;const r=n.parsedType===M.promise?n.data:Promise.resolve(n.data);return $e(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}kn.create=(e,t)=>new kn({type:e,typeName:F.ZodPromise,...Y(t)});class lt extends Q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:a=>{P(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async l=>{if(n.value==="aborted")return B;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?B:c.status==="dirty"||n.value==="dirty"?hn(c.value):c});{if(n.value==="aborted")return B;const l=this._def.schema._parseSync({data:a,path:r.path,parent:r});return l.status==="aborted"?B:l.status==="dirty"||n.value==="dirty"?hn(l.value):l}}if(s.type==="refinement"){const a=l=>{const c=s.refinement(l,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?B:(l.status==="dirty"&&n.dirty(),a(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?B:(l.status==="dirty"&&n.dirty(),a(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Jt(a))return a;const l=s.transform(a.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Jt(a)?Promise.resolve(s.transform(a.value,i)).then(l=>({status:n.value,value:l})):a);ne.assertNever(s)}}lt.create=(e,t,n)=>new lt({schema:e,typeName:F.ZodEffects,effect:t,...Y(n)});lt.createWithPreprocess=(e,t,n)=>new lt({schema:t,effect:{type:"preprocess",transform:e},typeName:F.ZodEffects,...Y(n)});class ht extends Q{_parse(t){return this._getType(t)===M.undefined?$e(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ht.create=(e,t)=>new ht({innerType:e,typeName:F.ZodOptional,...Y(t)});class Lt extends Q{_parse(t){return this._getType(t)===M.null?$e(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Lt.create=(e,t)=>new Lt({innerType:e,typeName:F.ZodNullable,...Y(t)});class or extends Q{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===M.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}or.create=(e,t)=>new or({innerType:e,typeName:F.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Y(t)});class ar extends Q{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Qn(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ar.create=(e,t)=>new ar({innerType:e,typeName:F.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Y(t)});class es extends Q{_parse(t){if(this._getType(t)!==M.nan){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.nan,received:r.parsedType}),B}return{status:"valid",value:t.data}}}es.create=e=>new es({typeName:F.ZodNaN,...Y(e)});const Sf=Symbol("zod_brand");class qi extends Q{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class vr extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?B:i.status==="dirty"?(n.dirty(),hn(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?B:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new vr({in:t,out:n,typeName:F.ZodPipeline})}}class lr extends Q{_parse(t){const n=this._def.innerType._parse(t),r=s=>(Jt(s)&&(s.value=Object.freeze(s.value)),s);return Qn(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}lr.create=(e,t)=>new lr({innerType:e,typeName:F.ZodReadonly,...Y(t)});function sa(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function cc(e,t={},n){return e?Sn.create().superRefine((r,s)=>{var i,a;const l=e(r);if(l instanceof Promise)return l.then(c=>{var d,u;if(!c){const f=sa(t,r),p=(u=(d=f.fatal)!==null&&d!==void 0?d:n)!==null&&u!==void 0?u:!0;s.addIssue({code:"custom",...f,fatal:p})}});if(!l){const c=sa(t,r),d=(a=(i=c.fatal)!==null&&i!==void 0?i:n)!==null&&a!==void 0?a:!0;s.addIssue({code:"custom",...c,fatal:d})}}):Sn.create()}const kf={object:ve.lazycreate};var F;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(F||(F={}));const Rf=(e,t={message:`Input not instance of ${e.name}`})=>cc(n=>n instanceof e,t),dc=ot.create,uc=Mt.create,Ef=es.create,If=Dt.create,fc=Jn.create,xf=Xt.create,Tf=Jr.create,Cf=Xn.create,Af=qn.create,Of=Sn.create,Pf=Vt.create,jf=St.create,Mf=Xr.create,Df=at.create,Nf=ve.create,Lf=ve.strictCreate,$f=er.create,Uf=us.create,Ff=tr.create,Bf=gt.create,Gf=nr.create,Hf=qr.create,Wf=qt.create,zf=gn.create,Zf=rr.create,Vf=sr.create,Kf=Nt.create,Yf=ir.create,Qf=kn.create,ia=lt.create,Jf=ht.create,Xf=Lt.create,qf=lt.createWithPreprocess,ep=vr.create,tp=()=>dc().optional(),np=()=>uc().optional(),rp=()=>fc().optional(),sp={string:e=>ot.create({...e,coerce:!0}),number:e=>Mt.create({...e,coerce:!0}),boolean:e=>Jn.create({...e,coerce:!0}),bigint:e=>Dt.create({...e,coerce:!0}),date:e=>Xt.create({...e,coerce:!0})},ip=B;var o=Object.freeze({__proto__:null,defaultErrorMap:wn,setErrorMap:Xu,getErrorMap:Kr,makeIssue:Yr,EMPTY_PATH:qu,addIssueToContext:P,ParseStatus:Ne,INVALID:B,DIRTY:hn,OK:$e,isAborted:pi,isDirty:hi,isValid:Jt,isAsync:Qn,get util(){return ne},get objectUtil(){return fi},ZodParsedType:M,getParsedType:wt,ZodType:Q,datetimeRegex:ac,ZodString:ot,ZodNumber:Mt,ZodBigInt:Dt,ZodBoolean:Jn,ZodDate:Xt,ZodSymbol:Jr,ZodUndefined:Xn,ZodNull:qn,ZodAny:Sn,ZodUnknown:Vt,ZodNever:St,ZodVoid:Xr,ZodArray:at,ZodObject:ve,ZodUnion:er,ZodDiscriminatedUnion:us,ZodIntersection:tr,ZodTuple:gt,ZodRecord:nr,ZodMap:qr,ZodSet:qt,ZodFunction:gn,ZodLazy:rr,ZodLiteral:sr,ZodEnum:Nt,ZodNativeEnum:ir,ZodPromise:kn,ZodEffects:lt,ZodTransformer:lt,ZodOptional:ht,ZodNullable:Lt,ZodDefault:or,ZodCatch:ar,ZodNaN:es,BRAND:Sf,ZodBranded:qi,ZodPipeline:vr,ZodReadonly:lr,custom:cc,Schema:Q,ZodSchema:Q,late:kf,get ZodFirstPartyTypeKind(){return F},coerce:sp,any:Of,array:Df,bigint:If,boolean:fc,date:xf,discriminatedUnion:Uf,effect:ia,enum:Kf,function:zf,instanceof:Rf,intersection:Ff,lazy:Zf,literal:Vf,map:Hf,nan:Ef,nativeEnum:Yf,never:jf,null:Af,nullable:Xf,number:uc,object:Nf,oboolean:rp,onumber:np,optional:Jf,ostring:tp,pipeline:ep,preprocess:qf,promise:Qf,record:Gf,set:Wf,strictObject:Lf,string:dc,symbol:Tf,transformer:ia,tuple:Bf,undefined:Cf,union:$f,unknown:Pf,void:Mf,NEVER:ip,ZodIssueCode:E,quotelessJson:Ju,ZodError:Ze});const oa=o.enum(["app_start","sign_in","window_focus","surface_open"]),pc=o.object({id:o.string().min(1),state:o.enum(["active","paused","disabled"])}).passthrough(),op=o.object({tenant_id:o.string().min(1),tenant_name:o.string().optional(),eligible:o.boolean(),endpoint:pc.nullable()}).passthrough(),ap=o.object({code:o.string(),message:o.string(),details:o.record(o.unknown()).optional(),retry_after_seconds:o.number().optional()}).passthrough(),lp=o.object({code:o.string().min(1),count:o.number().int().nonnegative(),session:o.string().min(1).nullable().optional().catch(null)}).passthrough().nullable().optional().catch(null),$S=o.object({capability:o.number(),consent_account_guard:o.boolean().optional(),state:o.enum(["ready","signed_out","unavailable","update_required"]),account_id:o.string().nullable(),tenant_id:o.string().nullable(),surface_state:o.enum(["A","B","C","D","E","F","G"]).nullable(),visibility:o.object({settings:o.boolean(),inbox:o.boolean(),account_door:o.boolean(),onboarding:o.boolean()}),update_required:o.boolean(),local:o.object({enabled:o.boolean(),onboarding:o.string(),session:o.string()}),status:o.object({tenants:o.array(op)}).passthrough().nullable(),consent:o.object({version:o.string().min(1).max(128),text:o.string().min(1).refine(e=>new TextEncoder().encode(e).length<=2048,"Consent exceeds the served-text contract"),source:o.enum(["served","cached","embedded"])}).nullable(),error:ap.nullable(),state_note:o.string().nullable().optional(),read_only:o.boolean().optional(),delivery_hold:lp}).passthrough(),cp=o.object({version:o.string().min(1),consented_at:o.string().min(1),consented_via:o.enum(["dialog","settings"]),current:o.boolean()}).passthrough(),US=o.object({endpoint:pc.extend({tenant_id:o.string().min(1),label:o.string().optional(),consent:cp.nullable().optional(),created_at:o.string().optional(),updated_at:o.string().optional()}).nullable(),settings:o.object({tenant_id:o.string().min(1),eligible:o.boolean(),consent_version:o.string().optional(),consent_required:o.boolean()}).passthrough()}).passthrough(),dp=o.object({kind:o.enum(["endpoint","account"]).optional(),endpoint_id:o.string().min(1).optional(),account_id:o.string().min(1).optional()}).passthrough().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id").refine(e=>e.kind===void 0||(e.kind==="endpoint"?e.endpoint_id!==void 0:e.account_id!==void 0),"An allowlist target's kind must agree with the id it carries"),aa=o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:dp,id:o.string().optional()}).passthrough(),la=o.object({mode:o.enum(["class_default","listed_only"]),allow:o.number(),deny:o.number()}).passthrough(),FS=o.object({allowlist:o.object({tenant_id:o.string().min(1),entries:o.array(aa)}).passthrough(),view:o.object({tenant_id:o.string().nullable(),entries:o.array(aa),directions:o.object({send:la,receive:la}),class_default:o.literal("cos_cos"),cues:o.object({allow_entry_switches_direction_to_listed_only:o.boolean(),listed_only_affects:o.string(),removing_allow_does_not_stop_open_thread:o.boolean(),deny_stops_pair_both_directions:o.boolean()}).passthrough()}).passthrough()}).passthrough();function BS(e,t){if(!e||!t||e.account_id!==t||e.capability<1||e.state!=="ready"||e.update_required||e.surface_state!=="B"||!e.visibility.onboarding||!e.tenant_id)return null;const n=e.status?.tenants.filter(r=>r.tenant_id===e.tenant_id);return n?.length!==1||n[0].eligible!==!0||n[0].endpoint!==null?null:{accountId:t,tenantId:e.tenant_id}}function GS(e){const t=e?.consent;return t&&(t.source==="served"||t.source==="cached")?t:null}const gi=["aida","library","projects","agents","schedules","browser","team-bridge","agent-hub","mesh"],up=6*1024,fp=512;function ts(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const s=[];for(const i of n){if(s.length===fp)break;const l=new URLSearchParams({order_ids:i}).toString().length+1;if(r+l>up)break;e.append("order_ids",i),s.push(i),r+=l}return s}function pp(e,t,n){return ts(new URLSearchParams(n),t,e)}const k=o.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),Ar=o.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Or=o.string().min(1).max(32768),hp=/^[a-f0-9]{12}$/,L=o.string().regex(hp),Ds=o.string().regex(/^[a-f0-9]{12}$/),Ns=o.string().min(1).max(128),mp=o.string().min(1).max(4096),Ls=o.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),Pr=o.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),ca=o.string().regex(/^[a-f0-9]{32}$/),gp=/^(\/|[A-Za-z]:[\\/])/,$s=o.string().min(1).max(4096).regex(gp),da=/^[a-f0-9]{32}$/,te=o.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),ua=o.string().min(1).max(512).nullish(),cn=o.string().regex(/^[A-Za-z0-9_-]{1,128}$/),fa=o.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),Mn=o.string().regex(/^la_[0-9a-f]{16}$/),Dn=o.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/),pa=o.object({data_b64:o.string().min(1).max(1e6),mime_type:o.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),ha=2e5,ma=8,yp=256,vp=100,ga=16,_p=256,bp=100,wp=200,Sp=1e6,kp=o.enum(["auto","none","minimal","low","medium","high","xhigh","max"]),Oe=o.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),jr=o.object({kind:o.enum(["agent","team"]),name:Oe}).strict(),hc=o.enum(["claude","codex","omp"]),Rp=o.record(o.string(),o.array(o.string().min(1).max(512)).max(5e3)),ya={sources:o.array(hc).max(3).optional(),sessionIds:Rp.optional(),all:o.boolean().optional(),includeSubagents:o.boolean().optional(),includeClearedSegments:o.boolean().optional(),includeMemory:o.boolean().optional(),includeInstructions:o.boolean().optional(),maxSessions:o.number().int().min(1).max(5e3).optional()},Us=o.object({provider:o.string().min(1).max(128),model_id:o.string().min(1).max(512),reasoning_effort:o.string().min(1).max(64).nullable()}).strict(),va=o.object({kind:o.enum(["role","specialist"]).optional(),description:o.string().max(8e3).optional(),instructions:o.string().max(8e3).optional(),tools:o.array(o.string().min(1).max(128)).max(256).optional(),effort:o.string().max(64).optional(),delegate:o.boolean().optional(),action_class:o.enum(["reactive","proactive"]).optional()}).strict(),_a=o.object({name:o.string().min(1).max(64).optional(),description:o.string().max(8e3).optional(),manager:Oe.optional(),members:o.array(o.object({role:Oe,count:o.number().int().min(1).max(16),kind:o.enum(["agent","team"]),tier:o.enum(["lo","med","hi"]).nullable().optional(),effort:kp.nullable().optional()}).strict()).max(128).optional(),instructions:o.string().max(8e3).optional(),project:o.string().max(8e3).optional()}).strict(),Ep=o.record(o.array(o.string().max(1024)).max(100)),ba=o.enum(["minutes","hours","days"]);function Ip(e){return!/^\.+$/.test(e)}const HS=e=>Wr.safeParse(e).success,Wr=o.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(Ip),wa=o.enum(["str","int","float","bool","list","dict"]),Sa=o.string().max(16384),xp=2e3,ka=o.string().min(1).max(xp),Ra=o.string().min(1).max(64),Tp=o.string().min(1).max(64),Cp=o.string().min(1).max(64),Ea=o.object({is_active:o.boolean().nullish(),one_time:o.boolean().nullish(),start_time_utc:o.string().max(64).nullish(),end_time_utc:o.string().max(64).nullish()}).strict(),Ap=o.object({conversation_length:o.number().int().optional(),detail_length:o.number().int().optional(),max_learnings_history:o.number().int().optional(),hosting:o.string().max(256).optional(),model_name:o.string().max(1024).optional(),auto_save_conversation:o.boolean().optional()}).strict(),yi=128,Ia=2e3,xa=8e3,Ta=64,Ca=64,fs=e=>[...e].length,vi=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,Op=e=>e===9||e===10||e===11||e===12||e===13||e===133,Pp=e=>e<=31||e>=127&&e<=159,jp=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),Mp=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,Mr=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},mc=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&vi(t[n].codePointAt(0)??0);)n++;for(;r>n&&vi(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},Dp=e=>{let t="",n=!1;for(const r of e){if(vi(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function Np(e){const t=mc(e);if(!t)return"must not be empty";if(fs(t)>yi)return`must be at most ${yi} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(Mr(t,Mp))return"must not contain Unicode bidirectional override characters";if(Mr(t,Op))return"must not contain whitespace";if(Mr(t,Pp))return"must not contain control characters";if(Mr(t,jp))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function WS(e){return Dp(mc(e).normalize("NFKC").toLowerCase())}function Lp(e){return e.trim()?fs(e)>Ia?`must be at most ${Ia} characters`:null:"must not be empty"}function $p(e){return e.trim()?fs(e)>xa?`must be at most ${xa} characters`:null:"must not be empty"}function Up(e){if(e.length>Ca)return`must hold at most ${Ca} items`;for(const t of e)if(!t.trim()||fs(t)>Ta)return`must hold items of 1 to ${Ta} characters`;return null}const Fp=e=>Np(e)===null,Bp=o.string().refine(Fp,{message:"That is not a name the hub can publish."}),Gp=o.string().refine(e=>$p(e)===null,{message:"That instruction body cannot be published."}),Hp=o.string().refine(e=>Lp(e)===null,{message:"That description cannot be published."}),Wp=o.array(o.string()).refine(e=>Up(e)===null,{message:"That tool list cannot be published."}),Fs={requestId:te.optional(),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()},Aa=o.object({name:Bp,description:Hp,instructions:Gp,kind:o.enum(["role","specialist"]),when_to_use:o.string(),tools:Wp,effort:o.string(),delegate:o.boolean(),version:o.string(),categories:o.array(o.string()),tags:o.array(o.string())}).partial().strict(),zp=o.enum(["team","agent"]),Zp=o.string().min(1).max(64),Vp=o.string().min(1).max(256),gc=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Bs=o.string().regex(gc,{message:"Letters, digits, dot, underscore and dash; no spaces."}),Kp=["planning","active","qa","validation","done","paused","archived"],Oa=o.enum(Kp),Dr=o.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),Pa=o.array(o.string().min(1).max(24)).max(8),Tt=o.string().min(1).max(64),Yp=1e3,ja=240,Ma=80,Qp=256,Jp=100,Xp=200,qp=/^[a-z0-9][a-z0-9_-]{0,23}$/;function zS(e){return e?gc.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function ZS(e){return qp.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Nr=o.enum(["agent","team","skill"]),Da=o.enum(gi),eh=o.object({visible:o.array(Da).max(gi.length),more:o.array(Da).max(gi.length)}).strict(),th=o.discriminatedUnion("op",[o.object({op:o.literal("capabilities")}).strict(),o.object({op:o.literal("runtimes.list")}).strict(),o.object({op:o.literal("profiles.list")}).strict(),o.object({op:o.literal("profiles.get"),name:Oe}).strict(),o.object({op:o.literal("imports.sources")}).strict(),o.object({op:o.literal("imports.sessions"),source:hc,includeSubagents:o.boolean().optional()}).strict(),o.object({op:o.literal("imports.preview"),...ya}).strict(),o.object({op:o.literal("imports.start"),...ya}).strict(),o.object({op:o.literal("imports.status"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("imports.cancel"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("profiles.update"),name:Oe,requestId:te,fields:va,expectedDefinitionRevision:ua.optional()}).strict(),o.object({op:o.literal("profiles.install"),name:Oe,requestId:te}).strict(),o.object({op:o.literal("profiles.create"),name:Oe,requestId:te,fields:va.extend({description:o.string().max(8e3),instructions:o.string().min(1).max(8e3)})}).strict(),o.object({op:o.literal("hub.updates")}).strict(),o.object({op:o.literal("hub.skillPull"),requestId:te,hubId:k,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:k.nullable(),localAlias:Oe,subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.skillSubscribe"),requestId:te,hubId:k,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:k.nullable(),localAlias:Oe}).strict(),o.object({op:o.literal("hub.skillUnpull"),requestId:te,linkId:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("hub.skillPublish"),requestId:te,dryRun:o.boolean(),sourceSkill:Oe,localAlias:Oe,visibility:o.enum(["public","org"]),tenantId:k.nullable(),subscribe:o.boolean(),autoPush:o.boolean(),confirmPublicEgress:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("hub.links"),kind:o.enum(["agent","team","skill"]).optional()}).strict(),o.object({op:o.literal("hub.policy"),requestId:te,linkId:o.string().min(1).max(256),expectedPolicyRevision:o.string().min(1).max(256),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.check"),requestId:te,linkId:o.string().min(1).max(256).optional(),direction:o.enum(["pull","push"]).optional(),kind:Nr.optional(),name:Oe.optional()}).strict(),o.object({op:o.literal("hub.apply"),requestId:te,previewReceipt:o.string().min(1).max(4096).optional(),confirmApply:o.literal(!0).optional(),linkId:o.string().min(1).max(256).optional(),direction:o.literal("pull").optional(),kind:Nr.optional(),name:Oe.optional(),prefer:o.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:o.boolean().optional(),dryRun:o.boolean().optional(),resolveSource:o.literal(!0).optional(),hubSource:o.string().min(1).max(2048).optional(),visibility:o.enum(["public","org"]).optional(),tenantId:o.string().min(1).max(128).nullable().optional()}).strict(),o.object({op:o.literal("hub.applyAll"),requestId:te,kind:Nr.optional()}).strict(),o.object({op:o.literal("hub.retry"),requestId:te,linkId:o.string().min(1).max(256).optional(),direction:o.enum(["pull","push"]).optional(),kind:Nr.optional(),name:Oe.optional()}).strict(),o.object({op:o.literal("hub.push"),requestId:te,linkId:o.string().min(1).max(256),direction:o.literal("push"),dryRun:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("teams.list")}).strict(),o.object({op:o.literal("teams.get"),name:Oe}).strict(),o.object({op:o.literal("teams.effective"),name:Oe}).strict(),o.object({op:o.literal("teams.update"),name:Oe,requestId:te,fields:_a,expectedDefinitionRevision:ua.optional()}).strict(),o.object({op:o.literal("teams.create"),requestId:te,fields:_a.extend({name:o.string().min(1).max(64)})}).strict(),o.object({op:o.literal("sessions.list"),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional(),include_peers:o.boolean().optional(),scope_kind:zp.optional(),scope_name:Zp.optional(),cursor:Vp.optional(),with_counts:o.boolean().optional(),sort:o.literal("activity").optional()}).strict(),o.object({op:o.literal("delegated_cleanup_notice.ack")}).strict(),o.object({op:o.literal("sessions.search"),q:o.string().min(1).max(yp),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.archive"),sessionId:L,archived:o.boolean()}).strict(),o.object({op:o.literal("sessions.delete"),sessionId:L,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.create"),requestId:te,cwd:o.string().min(1).max(4096).optional(),target:jr.optional(),purpose:o.literal("agents-config").optional(),model:Us.optional(),draftId:L.optional(),peer:cn.optional()}).strict(),o.object({op:o.literal("sessions.preview"),requestId:te,cwd:o.string().min(1).max(4096),target:jr.optional(),model:Us.optional()}).strict(),o.object({op:o.literal("sessions.draft"),requestId:te,cwd:o.string().min(1).max(4096),target:jr.optional(),model:Us.optional()}).strict(),o.object({op:o.literal("sessions.get"),sessionId:L,journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.files"),sessionId:L,scope:o.enum(["family","self"]).optional(),kind:o.string().max(256).optional(),q:o.string().max(256).optional(),sort:o.enum(["recent","name","kind","modified","created","size"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(8192).optional()}).strict(),o.object({op:o.literal("sessions.files.materialise"),sessionId:L,fileId:o.string().regex(/^[a-f0-9]{16}$/)}).strict(),o.object({op:o.literal("sessions.history"),sessionId:L,beforeId:k.optional(),limit:o.number().int().min(1).max(500).optional(),openFrame:o.boolean().optional(),journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional(),sourceRead:o.enum(["metadata","payload"]).optional(),expectedJournalGeneration:o.string().min(1).max(128).optional()}).strict(),o.object({op:o.literal("sessions.checkpoints"),sessionId:L}).strict(),o.object({op:o.literal("sessions.checkpoints.warm"),sessionId:L,ids:o.array(k).max(ga).optional(),limit:o.number().int().min(1).max(ga).optional()}).strict(),o.object({op:o.literal("sessions.find"),sessionId:L,q:o.string().min(1).max(_p),limit:o.number().int().min(1).max(wp).optional()}).strict(),o.object({op:o.literal("subagents.transcript"),sessionId:L,childId:L,beforeId:k.optional(),limit:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("sessions.message"),sessionId:L,requestId:te,text:o.string().max(ha),images:o.array(pa).max(ma).optional(),mode:o.enum(["prompt","steer"]).optional(),inputMode:o.enum(["typed","dictated","mixed"]).optional(),inputPath:o.string().max(1024).optional()}).strict(),o.object({op:o.literal("sessions.command"),sessionId:L,requestId:te,command:o.string().regex(/^\/?[A-Za-z]+$/).max(64),args:o.string().max(ha).optional(),images:o.array(pa).max(ma).optional()}).strict(),o.object({op:o.literal("sessions.move"),sessionId:L,requestId:te,cwd:o.string().min(1).max(4096)}).strict(),o.object({op:o.literal("sessions.answer"),sessionId:L,epoch:k.optional(),requestId:k.optional(),value:o.string().max(32768).optional(),approved:o.boolean().optional(),questionIndex:o.number().int().min(0).optional(),askId:k.optional(),answers:o.record(o.string(),o.array(o.string().max(32768))).optional(),decline:o.boolean().optional(),revise:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.seen"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("attention.seen"),items:o.array(o.object({sessionId:L,completionToken:o.string().uuid()}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("sessions.notified"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("tags.list")}).strict(),o.object({op:o.literal("tags.replace"),tags:o.array(o.object({id:o.string().optional(),name:o.string()}).strict())}).strict(),o.object({op:o.literal("sessions.tags"),expected_revision:o.string().optional(),sessionId:L,tags:o.array(o.string()),primary:o.string().nullable()}).strict(),o.object({op:o.literal("sessions.pin"),sessionId:L,pinned:o.boolean()}).strict(),o.object({op:o.literal("sessions.watch"),sessionId:L,subscriptionId:o.string().regex(da),visible:o.boolean(),canNotify:o.boolean()}).strict(),o.object({op:o.literal("sessions.warm"),sessionId:L}).strict(),o.object({op:o.literal("sessions.interrupt"),sessionId:L,requestId:te}).strict(),o.object({op:o.literal("supplements.cancel"),sessionId:L,job:Ds,anchor:Ns}).strict(),o.object({op:o.literal("supplements.restart"),sessionId:L,job:Ds,anchor:Ns}).strict(),o.object({op:o.literal("supplements.steer"),sessionId:L,job:Ds,anchor:Ns,text:o.string().min(1).max(500)}).strict(),o.object({op:o.literal("sessions.variables.list"),sessionId:L}).strict(),o.object({op:o.literal("sessions.variables.create"),sessionId:L,key:Wr,value:Sa,type:wa}).strict(),o.object({op:o.literal("sessions.variables.update"),sessionId:L,key:Wr,value:Sa,type:wa}).strict(),o.object({op:o.literal("sessions.variables.delete"),sessionId:L,key:Wr}).strict(),o.object({op:o.literal("sessions.presence"),subscriptionId:o.string().regex(/^[a-f0-9]{1,64}$/),canNotify:o.boolean(),canNotifyKinds:o.array(o.enum(["complete","error"])).max(4),sessionId:o.string().regex(/^([a-f0-9]{12})?$/),window:o.object({exists:o.boolean(),focused:o.boolean(),visible:o.boolean(),minimized:o.boolean()}).strict()}).strict(),o.object({op:o.literal("legacy.models"),provider:o.string().max(128).optional(),sort:o.enum(["id","name","provider","recommended"]).optional(),direction:o.enum(["ascending","descending"]).optional()}).strict(),o.object({op:o.literal("legacy.models.providers")}).strict(),o.object({op:o.literal("auth.probe"),provider:k}).strict(),o.object({op:o.literal("legacy.agent.upload"),agentId:k}).strict(),o.object({op:o.literal("agent.publish"),agentId:k,document:Aa.optional(),...Fs,visibility:o.literal("org").optional(),tenantId:k.optional()}).strict(),o.object({op:o.literal("agent.republish"),agentId:k,hubAgentId:k,expectedRemoteRevision:o.string().min(1).max(512).optional(),document:Aa.optional(),...Fs,visibility:o.literal("org").optional(),tenantId:k.optional()}).strict(),o.object({op:o.literal("team.publish"),teamId:k,...Fs,visibility:o.literal("org").optional(),tenantId:k.optional()}).strict(),o.object({op:o.literal("team.pull"),teamId:k,tenantId:k.optional()}).strict(),o.object({op:o.literal("agent.nameAvailability"),name:o.string().min(1).max(yi)}).strict(),o.object({op:o.literal("legacy.agents.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional(),name:o.string().max(256).optional(),sort:o.string().max(64).optional(),direction:o.enum(["asc","desc"]).optional()}).strict(),o.object({op:o.literal("legacy.agent.get"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.history"),agentId:k,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("legacy.jobs.list"),agentId:k.optional(),status:o.string().max(64).optional()}).strict(),o.object({op:o.literal("legacy.job.get"),jobId:k}).strict(),o.object({op:o.literal("legacy.schedules.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedules.list"),agentId:k,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedule.create"),agentId:k,schedule:Ea.extend({prompt:o.string().max(64e3),interval:o.number().int().min(1),unit:ba})}).strict(),o.object({op:o.literal("legacy.schedule.get"),scheduleId:k}).strict(),o.object({op:o.literal("legacy.schedule.edit"),scheduleId:k,schedule:Ea.extend({prompt:o.string().max(64e3).nullish(),interval:o.number().int().min(1).nullish(),unit:ba.nullish()})}).strict(),o.object({op:o.literal("legacy.schedule.remove"),scheduleId:k}).strict(),o.object({op:o.literal("legacy.agent.create"),agent:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.update"),agentId:k,update:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.delete"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.conversation.clear"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.get"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.update"),agentId:k,systemPrompt:o.string().max(Sp)}).strict(),o.object({op:o.literal("legacy.agent.download"),agentId:k}).strict(),o.object({op:o.literal("legacy.job.cancel"),jobId:k}).strict(),o.object({op:o.literal("commands.list")}).strict(),o.object({op:o.literal("commands.entities"),sessionId:L,command:k,name:o.string().max(128).optional()}).strict(),o.object({op:o.literal("models.catalogue"),live:o.boolean().optional(),scope:o.enum(["usable","all"]).optional()}).strict(),o.object({op:o.literal("usage.get"),provider:k.optional(),live:o.boolean().optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("quota.notice"),provider:k.optional(),model:o.string().min(1).max(200).optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("analytics.get"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("analytics.models"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("info.get")}).strict(),o.object({op:o.literal("sessions.report"),sessionId:L,recentLimit:o.number().int().min(0).max(50).optional()}).strict(),o.object({op:o.literal("skills.list"),sessionId:L.optional(),cwd:mp.optional(),name:k.optional()}).strict(),o.object({op:o.literal("sessions.failovers"),sessionId:L}).strict(),o.object({op:o.literal("sessions.credential"),sessionId:L,action:o.enum(["list","store","forget"]),key:Ar.optional(),value:Or.optional(),confirmed:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.fork"),sessionId:L,requestId:te,message:o.string().max(2e5).optional(),boundary:o.enum(["next_safe","at_entry"]).optional(),entryId:o.string().max(128).optional(),autoTag:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.stop"),requestId:te,targets:o.array(L).min(1).max(100),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside"),sessionId:L,requestId:te,text:o.string().min(1).max(32768),asideId:te.optional(),subscriptionId:o.string().regex(da).optional()}).strict(),o.object({op:o.literal("sessions.adopt"),sessionId:L,requestId:te,asideId:te,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside.get"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("sessions.aside.close"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("wakes.list"),limit:o.number().int().min(1).max(500).optional(),includeDormant:o.boolean().optional()}).strict(),o.object({op:o.literal("wakes.create"),requestId:te,sessionId:L.optional(),cwd:o.string().min(1).max(4096).optional(),target:jr.optional(),message:ka,in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional(),title:o.string().min(1).max(200).optional()}).strict(),o.object({op:o.literal("wakes.edit"),sessionId:L,wakeId:Ra,message:ka.optional(),in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional()}).strict(),o.object({op:o.literal("wakes.remove"),sessionId:L,wakeId:Ra}).strict(),o.object({op:o.literal("monitors.cancel"),sessionId:L,monitorId:Tp}).strict(),o.object({op:o.literal("jobs.cancel"),sessionId:L,jobId:Cp}).strict(),o.object({op:o.literal("mcp.list"),sessionId:L}).strict(),o.object({op:o.literal("mcp.credentials.store"),sessionId:L,name:o.string().min(1).max(256),values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("mcp.control"),sessionId:L,control:o.object({action:o.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:Ls.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record(Pr).optional(),url:o.string().max(4096).optional(),headers:o.record(Pr).optional(),oauth:o.boolean().optional(),confirmed:o.boolean().optional(),operation_id:ca.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog"),cwd:$s.optional(),sessionId:L.optional()}).strict(),o.object({op:o.literal("mcp.catalog.control"),cwd:$s.optional(),control:o.object({action:o.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:Ls.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record(Pr).optional(),url:o.string().max(4096).optional(),headers:o.record(Pr).optional(),confirmed:o.boolean().optional(),operation_id:ca.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog.credentials"),header:o.string().min(1).max(128).optional(),cwd:$s.optional(),name:Ls,values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("radient.request"),control:o.object({operation:o.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list","org_skills.list","org_skill.get","signup.resend"]),request_id:te.optional(),tenant_id:k.optional(),account_id:k.optional(),agent_id:k.optional(),comment_id:k.optional(),team_id:k.optional(),skill_id:k.optional(),query:o.record(o.union([o.string().max(1024),o.number().int()])).optional(),payload:o.record(o.unknown()).optional(),confirmed:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("providers.list")}).strict(),o.object({op:o.literal("accounts.list")}).strict(),o.object({op:o.literal("accounts.remove"),accountId:o.number().int().positive(),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("tunnel.setup.read"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.plan"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.run"),credentialId:o.number().int().positive(),acceptMonthlyPrice:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("auth.start"),provider:k}).strict(),o.object({op:o.literal("auth.status"),id:k}).strict(),o.object({op:o.literal("auth.input"),id:k,promptId:k,value:Or}).strict(),o.object({op:o.literal("auth.cancel"),id:k}).strict(),o.object({op:o.literal("auth.key"),provider:k,value:Or}).strict(),o.object({op:o.literal("auth.logout"),provider:k}).strict(),o.object({op:o.literal("agent_messages.status"),boundary:oa}).strict(),o.object({op:o.literal("agent_messages.enable"),expected_account_id:k,tenant_id:k,state:o.literal("active"),consent_version:o.string().min(1).max(128),consented_via:o.literal("dialog")}).strict(),o.object({op:o.literal("agent_messages.settings"),tenant_id:k.optional()}).strict(),o.object({op:o.literal("agent_messages.settings.put"),expected_account_id:k,tenant_id:k.optional(),consent_version:o.string().min(1).max(128).optional(),consented_via:o.enum(["dialog","settings"]).optional(),label:o.string().min(1).max(128).optional(),state:o.enum(["active","paused","disabled"])}).strict(),o.object({op:o.literal("agent_messages.allowlist.get"),tenant_id:k.optional()}).strict(),o.object({op:o.literal("agent_messages.allowlist.put"),expected_account_id:k,tenant_id:k.optional(),entries:o.array(o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:o.object({endpoint_id:k.optional(),account_id:k.optional()}).strict().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id")}).strict()).max(200)}).strict(),o.object({op:o.literal("team_bridge.conversations.list"),scope:o.literal("account").optional(),tenant_id:k.optional(),limit:o.number().int().min(1).max(100).optional(),cursor:o.string().min(1).max(64).optional(),before:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.get"),conversation_id:k,tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.create"),tenant_id:k.optional(),kind:o.enum(["dm","group","channel"]),name:o.string().min(1).max(128).optional(),topic:o.string().min(1).max(512).optional(),visibility:o.enum(["private","tenant"]).optional(),agent_capable:o.boolean().optional(),members:o.array(o.object({account_id:k,kind:o.enum(["human","agent"]),endpoint_id:k.optional(),display_label:o.string().min(1).max(64)}).strict()).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.lifecycle"),conversation_id:k,action:o.enum(["archive","unarchive","join","leave"])}).strict(),o.object({op:o.literal("team_bridge.conversations.join"),conversation_id:k,tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.notify"),conversation_id:k,tenant_id:k.optional(),notify:o.enum(["all","mention","mute"])}).strict(),o.object({op:o.literal("team_bridge.conversations.members.add"),conversation_id:k,tenant_id:k.optional(),members:o.array(o.object({account_id:k,kind:o.enum(["human","agent"]),endpoint_id:k.optional(),display_label:o.string().min(1).max(64)}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.members.remove"),conversation_id:k,account_id:k}).strict(),o.object({op:o.literal("team_bridge.conversations.consent"),conversation_id:k,account_id:k,decision:o.enum(["accept","decline"]),consent_version:o.string().min(1).max(128),tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.messages.list"),conversation_id:k,tenant_id:k.optional(),limit:o.number().int().min(1).max(100).optional(),before_seq:o.number().int().nonnegative().optional(),endpoint_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.reactions.toggle"),conversation_id:k,message_id:k,tenant_id:k.optional(),emoji:o.string().min(1),active:o.boolean()}).strict(),o.object({op:o.literal("team_bridge.messages.send"),conversation_id:k,tenant_id:k.optional(),client_ref:k,body:o.string().min(1),agent_label:o.string().min(1).max(64).optional(),thread_root_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.messages.replies"),conversation_id:k,message_id:k,tenant_id:k.optional(),limit:o.number().int().min(1).max(100).optional(),after_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.read"),conversation_id:k,tenant_id:k.optional(),seq:o.number().int().nonnegative().optional(),muted:o.boolean().optional()}).strict(),o.object({op:o.literal("team_bridge.unread"),scope:o.literal("account").optional(),tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.directory"),tenant_id:k}).strict(),o.object({op:o.literal("team_bridge.status"),boundary:oa.optional()}).strict(),o.object({op:o.literal("settings.list")}).strict(),o.object({op:o.literal("settings.edit"),key:Ar,value:o.unknown().refine(e=>e!==void 0,"A setting value is required."),base:Ep.optional()}).strict(),o.object({op:o.literal("settings.reset"),key:Ar}).strict(),o.object({op:o.literal("tts.paths")}).strict(),o.object({op:o.literal("config.get")}).strict(),o.object({op:o.literal("config.update"),value:Ap}).strict(),o.object({op:o.literal("instructions.get")}).strict(),o.object({op:o.literal("instructions.update"),content:o.string().max(64e3)}).strict(),o.object({op:o.literal("credentials.list")}).strict(),o.object({op:o.literal("credentials.update"),key:Ar,value:Or}).strict(),o.object({op:o.literal("peers.list")}).strict(),o.object({op:o.literal("networks.list")}).strict(),o.object({op:o.literal("networks.invite"),networkId:cn,role:o.enum(["read","drive","admin"]),deviceId:cn.optional()}).strict(),o.object({op:o.literal("networks.member.remove"),networkId:cn,deviceId:cn,confirm:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("sessions.transfer"),sessionId:L,to:o.union([o.literal("local"),cn]),keep:o.boolean().optional(),waitS:o.number().min(0).max(300).optional(),requestId:te.optional()}).strict(),o.object({op:o.literal("approvals.list")}).strict(),o.object({op:o.literal("approvals.approve"),approvalId:fa}).strict(),o.object({op:o.literal("approvals.deny"),approvalId:fa}).strict(),o.object({op:o.literal("asks.list")}).strict(),o.object({op:o.literal("projects.list")}).strict(),o.object({op:o.literal("projects.get"),key:Tt}).strict(),o.object({op:o.literal("projects.create"),name:Bs,description:o.string().max(ja).optional(),status:Oa.optional(),tags:Pa.optional()}).strict(),o.object({op:o.literal("projects.update"),key:Tt,fields:o.object({name:Bs.optional(),title:o.string().max(80).optional(),owner:o.string().max(80).optional(),team:o.string().max(80).optional(),description:o.string().max(ja).optional(),status:Oa.optional(),progress:o.string().max(Yp).optional(),tags:Pa.optional(),start_date:Dr.optional(),target_date:Dr.optional(),completed_at:Dr.optional(),estimate:o.number().positive().max(1e3).optional(),estimate_unit:o.enum(["points","days"]).optional()}).strict(),force_done:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.delete"),key:Tt,confirmed_name:Bs}).strict(),o.object({op:o.literal("projects.link"),key:Tt,sessionId:L}).strict(),o.object({op:o.literal("projects.unlink"),key:Tt,sessionId:L}).strict(),o.object({op:o.literal("projects.milestone"),key:Tt,name:o.string().min(1).max(Ma),targetDate:Dr.optional(),completed:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.milestone.remove"),key:Tt,name:o.string().min(1).max(Ma)}).strict(),o.object({op:o.literal("projects.request_update"),key:Tt}).strict(),o.object({op:o.literal("projects.search"),q:o.string().min(1).max(Qp),limit:o.number().int().min(1).max(Xp).optional()}).strict(),o.object({op:o.literal("aida.status")}).strict(),o.object({op:o.literal("aida.control"),action:o.enum(["open","pause","resume","greet","status"])}).strict(),o.object({op:o.literal("code_requests.list"),sessionId:L}).strict(),o.object({op:o.literal("code_requests.refresh"),sessionId:L,keys:o.array(o.string().min(1).max(512)).max(256).optional(),force:o.boolean().optional()}).strict(),o.object({op:o.literal("static.sign"),route:o.enum(["images","videos","audio","html"]),path:o.string().min(1),ttlS:o.number().int().min(1).max(3600).optional()}).strict(),o.object({op:o.literal("library.list"),scope:o.enum(["final","all"]).optional(),q:o.string().max(512).optional(),category:o.string().min(1).max(64).optional(),kind:o.string().min(1).max(64).optional(),origin_group:o.enum(["generated","created","mentioned"]).optional(),origin:o.string().min(1).max(64).optional(),tag:o.string().min(1).max(128).optional(),tag_mode:o.enum(["all","any"]).optional(),highlighted:o.boolean().optional(),organized:o.boolean().optional(),favorite:o.boolean().optional(),session:o.string().min(1).max(12).optional(),session_id:o.string().min(1).max(512).optional(),sort:o.enum(["recent","name","kind","size","created","modified","organized"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(512).optional()}).strict(),o.object({op:o.literal("library.get"),id:Mn}).strict(),o.object({op:o.literal("library.update"),id:Mn,fields:o.object({name:o.string().max(200).optional(),description:o.string().max(2e3).optional(),favorite:o.boolean().optional(),locked:o.boolean().optional(),archived:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("library.tags")}).strict(),o.object({op:o.literal("library.tags.create"),name:o.string().trim().min(1).max(24),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.update"),id:Dn,name:o.string().trim().min(1).max(24).optional(),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.delete"),id:Dn}).strict(),o.object({op:o.literal("library.tags.merge"),id:Dn,into:Dn}).strict(),o.object({op:o.literal("library.tags.assign"),id:Mn,tags:o.array(Dn).max(64),primary:o.string().max(128).optional()}).strict(),o.object({op:o.literal("library.chat.link"),id:Mn,sessionId:L}).strict(),o.object({op:o.literal("library.chat.clear"),id:Mn}).strict(),o.object({op:o.literal("library.librarian"),action:o.enum(["status","open","pause","resume","run"]).optional()}).strict(),o.object({op:o.literal("sidebar_layout.get")}).strict(),o.object({op:o.literal("sidebar_layout.set"),layout:eh}).strict()]);th.superRefine((e,t)=>{if(e.op==="hub.skillPull"||e.op==="hub.skillSubscribe"||e.op==="hub.skillPublish"){if(e.visibility==="public"&&e.tenantId!==null||e.visibility==="org"&&!e.tenantId){t.addIssue({code:o.ZodIssueCode.custom,message:"A skill destination requires explicit paired scope",path:["tenantId"]});return}if(e.op==="hub.skillPublish"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"An initial skill publication requires its reviewed draft receipt",path:["previewReceipt"]});return}}if(e.op==="hub.check"||e.op==="hub.apply"||e.op==="hub.retry"){const n=e.linkId!==void 0,r=e.kind!==void 0||e.name!==void 0;if(n&&r||e.op!=="hub.check"&&!n&&(!e.kind||!e.name)||e.op==="hub.retry"&&n&&!e.direction||e.direction==="push"&&!n){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub action requires one unambiguous selector and an explicit retry direction",path:["linkId"]});return}}if(e.op==="hub.apply"&&(e.previewReceipt!==void 0||e.confirmApply!==void 0)&&(!e.linkId||e.dryRun||!e.previewReceipt||e.confirmApply!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"A viewed incoming application requires its scoped preview receipt and confirmation",path:["previewReceipt"]});return}if(e.op==="hub.apply"&&e.resolveSource===!0){const n=e.visibility==="public"&&e.tenantId===null||e.visibility==="org"&&typeof e.tenantId=="string"&&e.tenantId.length>0;if(!e.hubSource||!n||e.acknowledgeUnknownBaseline!==!0||e.linkId!==void 0||e.previewReceipt!==void 0||e.confirmApply!==void 0||e.prefer!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"Confirming a source requires its exact stated destination and the unknown-baseline acknowledgement, with no link, preview or preference",path:["hubSource"]});return}}if(e.op==="hub.push"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"A confirmed publication requires its reviewed preview receipt",path:["previewReceipt"]});return}if(e.op==="hub.policy"&&e.subscribe===void 0&&e.autoPush===void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub policy change must name subscribe or autoPush",path:["subscribe"]});return}if((e.op==="team_bridge.conversations.list"||e.op==="team_bridge.unread")&&e.scope==="account"&&e.tenant_id!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped read cannot name a tenant",path:["scope"]});return}if(e.op==="team_bridge.conversations.list"&&e.scope==="account"&&e.before!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped page uses cursor, not before",path:["before"]});return}if(e.op==="sessions.answer"){if(e.askId!==void 0){e.askId||t.addIssue({code:o.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.decline!==!0&&!e.answers?t.addIssue({code:o.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:o.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:o.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:o.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:o.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}if(!(e.op!=="agent.publish"&&e.op!=="agent.republish"&&e.op!=="team.publish")){if((e.subscribe!==void 0||e.autoPush!==void 0||e.confirmPublicEgress!==void 0)&&!e.requestId){t.addIssue({code:o.ZodIssueCode.custom,message:"Initial link policy needs a durable publication request ID",path:["requestId"]});return}e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:o.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})}});const Je={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},nh={runtimeUnreachable:"runtime_unreachable"},ps="runtime_busy",yc="runtime_retiring";o.object({data:o.object({aside_id:o.string().optional(),status:o.union([o.enum(["adopted","queued"]),o.string()]).optional()}).passthrough()}).passthrough();const VS="aside_adopt_refused",rh=["session_closed","open_tool_batch","turn_running"];function KS(e){if(typeof e!="object"||e===null)return;const t=e.reason;return rh.find(n=>n===t)}const eo={[Je.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[Je.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[Je.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[Je.transportFailed]:"The Local Operator server did not answer this request."},_i={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function hs(e){return e!==void 0&&Object.values(Je).includes(e)}function sh(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return Je.refused;if(t===503)return Je.planeClosed}}const YS=o.object({step:o.string(),blocked_on:o.string(),configured:o.boolean(),ready:o.boolean(),verified:o.boolean(),url:o.string().nullable(),credential_id:o.number().int().positive().nullable(),identity_label:o.string().nullable(),credential_choices:o.array(o.object({id:o.number().int().positive(),identity_label:o.string().nullable().optional()}).passthrough()).default([]),quote:o.object({monthly_price_usd:o.string().nullable(),positive_balance:o.boolean(),eligible:o.boolean(),account_valid:o.boolean()}).passthrough().nullable(),receipts:o.array(o.object({step:o.string(),ok:o.boolean(),text:o.string()})).default([]),remedy:o.object({kind:o.string(),text:o.string(),command:o.string().nullable().optional(),url:o.string().nullable().optional()}).nullable(),source:o.string(),in_progress:o.boolean().default(!1),progress:o.array(o.string()).default([]),active_credential_id:o.number().int().positive().nullable().default(null),billing_outcome:o.string().optional(),reservation_outcome:o.string().optional(),failure_stage:o.string().optional()}).passthrough(),QS=new Set(["setup_in_progress","setup_deadline","setup_unavailable","setup_intent_corrupt"]),ih=88e4,oh=11e5,ah=2e4,lh=9e4,ch=new Set(["analytics.get","analytics.models","sessions.report"]),dh=new Set(["usage.get"]),uh=new Set(["networks.list","peers.list"]),fh=new Set([...ch,...dh,...uh]),ph=90,hh=30,mh=300,gh=10,vc=15,yh=1e4;function vh(e){const n=e.to==="local"||e.keep?mh:hh,r=Math.max(0,e.waitS??0);return(ph+n+gh+vc)*1e3+r*1e3}const _h=18e4,bh=_h+15e3,wh=120,Sh=135e3,kh=93e4,_c=(wh+30+vc)*1e3,Rh=6e4,Eh=5*_c,Ih=new Set(["hub.apply","hub.retry","hub.push","hub.skillPublish","hub.skillPull","hub.skillSubscribe","hub.skillUnpull","hub.check","hub.applyAll"]);function xh(e){switch(e){case"hub.apply":case"hub.retry":case"hub.push":case"hub.skillPublish":case"hub.skillPull":case"hub.skillSubscribe":case"hub.skillUnpull":return _c;case"hub.check":return Rh;case"hub.applyAll":return Eh;default:return null}}function Th(e){if(typeof e!="string"&&e.op==="sessions.transfer")return vh(e)+yh;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return bh;if(t==="tunnel.setup.run")return kh;if(t==="tunnel.setup.plan")return Sh;const n=xh(t);return n!==null?n:fh.has(t)?lh:ah}const Ch=5e3;function bc(e){return Th(e)+Ch}const to="deadline_exceeded",wc="foreground_required",Sc="View these completions in the foreground before marking them read.",Ah=new Set(["capabilities","agent_messages.status","agent_messages.settings","agent_messages.allowlist.get","team_bridge.conversations.list","team_bridge.conversations.get","team_bridge.messages.list","team_bridge.messages.replies","team_bridge.unread","team_bridge.directory","team_bridge.status","accounts.list","analytics.get","analytics.models","approvals.list","commands.entities","commands.list","config.get","credentials.list","hub.updates","hub.links","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","quota.notice","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.files","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","teams.effective","teams.get","teams.list","tunnel.setup.plan","tunnel.setup.read","usage.get"]),Oh=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function Ph(e,t){const n=Math.round(t/1e3),r=to;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:Ih.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:Ah.has(e)?{code:r,message:Oh.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const JS=ih,XS=oh;o.object({state:o.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:o.string(),kind:o.enum(["balance","subscription","radient","none"]),model_free:o.boolean(),title:o.string(),body:o.string(),actions:o.array(o.object({id:o.enum(["open_url","resend_verification","refresh"]),label:o.string(),url:o.string().nullable().optional()})),resets_at_ms:o.number().int().nullable().optional(),checked_at_ms:o.number().int(),age_ms:o.number().int().nullable().optional(),source:o.enum(["cached","live"])});function jh(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function Na(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function Gs(e){return{...e.requestId?{request_id:e.requestId}:{},...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}}function Hs(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function La(e){return{sources:e.sources??null,session_ids:e.sessionIds??{},all:e.all??!1,include_subagents:e.includeSubagents??!1,include_cleared_segments:e.includeClearedSegments??!1,include_memory:e.includeMemory??!0,include_instructions:e.includeInstructions??!0,...e.maxSessions===void 0?{}:{max_sessions:e.maxSessions}}}function Lr(e){return e===void 0?"":`?tenant_id=${encodeURIComponent(e)}`}function Mh(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"imports.sources":return{path:"/v1/desktop/imports/sources",method:"GET"};case"imports.sessions":{const t=new URLSearchParams({source:e.source});return e.includeSubagents&&t.set("include_subagents","true"),{path:`/v1/desktop/imports/sessions?${t.toString()}`,method:"GET"}}case"imports.preview":return{path:"/v1/desktop/imports/preview",method:"POST",body:La(e)};case"imports.start":return{path:"/v1/desktop/imports/jobs",method:"POST",body:La(e)};case"imports.status":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"GET"};case"imports.cancel":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"DELETE"};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.skillPull":return{path:"/v1/desktop/hub/skills/pull",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.skillSubscribe":return{path:"/v1/desktop/hub/skills/subscribe",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias}};case"hub.skillUnpull":return{path:"/v1/desktop/hub/skills/unpull",method:"POST",body:{request_id:e.requestId,link_id:e.linkId}};case"hub.skillPublish":return{path:"/v1/desktop/hub/skills/publish",method:"POST",body:{request_id:e.requestId,dry_run:e.dryRun,source_skill:e.sourceSkill,local_alias:e.localAlias,visibility:e.visibility,tenant_id:e.tenantId,subscribe:e.subscribe,auto_push:e.autoPush,confirm_public_egress:e.confirmPublicEgress,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"hub.links":return{path:`/v1/desktop/hub/links${e.kind?`?kind=${e.kind}`:""}`,method:"GET"};case"hub.policy":return{path:`/v1/desktop/hub/links/${encodeURIComponent(e.linkId)}`,method:"PATCH",body:{request_id:e.requestId,expected_policy_revision:e.expectedPolicyRevision,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.linkId?{link_id:e.linkId}:{},...e.direction?{direction:e.direction}:{},...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmApply?{confirm_apply:!0}:{},...e.linkId?{link_id:e.linkId}:{},...e.direction?{direction:e.direction}:{},...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.resolveSource===!0?{resolve_source:!0,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId??null}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,...e.linkId?{link_id:e.linkId}:{},...e.direction?{direction:e.direction}:{},...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{}}};case"hub.push":return{path:"/v1/desktop/hub/updates/push",method:"POST",body:{request_id:e.requestId,link_id:e.linkId,direction:e.direction,dry_run:e.dryRun,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.effective":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}/effective`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),e.sort&&t.set("sort",e.sort),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??vp)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),ts(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.files":{const t=new URLSearchParams({limit:String(e.limit??200)});for(const n of["scope","kind","q","sort","order","cursor"]){const r=e[n];r!==void 0&&t.set(n,r)}return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files?${t}`,method:"GET"}}case"sessions.files.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/materialise`,method:"POST"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1")),e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),e.sourceRead==="metadata"?t.set("source_read","metadata"):e.sourceRead==="payload"&&e.expectedJournalGeneration&&t.set("source_read","payload"),e.expectedJournalGeneration&&t.set("expected_journal_generation",e.expectedJournalGeneration),ts(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??bp)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"tags.list":return{path:"/v1/desktop/tags",method:"GET"};case"tags.replace":return{path:"/v1/desktop/tags",method:"PUT",body:{tags:e.tags}};case"sessions.tags":return{path:`/v1/desktop/sessions/${e.sessionId}/tags`,method:"PUT",body:{tags:e.tags,primary:e.primary,...e.expected_revision===void 0?{}:{expected_revision:e.expected_revision}}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{Hs(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{},...Gs(e)}}}case"agent.republish":{Hs(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{},...Gs(e),...e.expectedRemoteRevision?{expected_remote_revision:e.expectedRemoteRevision}:{}}}}case"team.publish":{Hs(e);const t=new URLSearchParams;return e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId)),{path:`/v1/teams/${e.teamId}/publish${t.size?`?${t}`:""}`,method:"POST",body:Gs(e)}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...jh(e),message:e.message,...Na(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...Na(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,method:"GET"}}case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId,auto_tag:e.autoTag}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"tunnel.setup.read":return{path:e.credentialId===void 0?"/v1/desktop/tunnel/setup":`/v1/desktop/tunnel/setup?credential_id=${e.credentialId}`,method:"GET"};case"tunnel.setup.plan":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"plan",...e.credentialId!==void 0?{credential_id:e.credentialId}:{}}};case"tunnel.setup.run":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"run",credential_id:e.credentialId,...e.acceptMonthlyPrice!==void 0?{accept_monthly_price:e.acceptMonthlyPrice}:{}}};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"agent_messages.status":return{path:`/v1/desktop/team-bridge/status?boundary=${e.boundary}`,method:"GET"};case"agent_messages.enable":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,state:e.state,consent_version:e.consent_version,consented_via:e.consented_via}};case"agent_messages.settings":return{path:`/v1/desktop/team-bridge/settings${Lr(e.tenant_id)}`,method:"GET"};case"agent_messages.settings.put":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},...e.consent_version===void 0?{}:{consent_version:e.consent_version},...e.consented_via===void 0?{}:{consented_via:e.consented_via},...e.label===void 0?{}:{label:e.label},state:e.state}};case"agent_messages.allowlist.get":return{path:`/v1/desktop/team-bridge/allowlist${Lr(e.tenant_id)}`,method:"GET"};case"agent_messages.allowlist.put":return{path:"/v1/desktop/team-bridge/allowlist",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},entries:e.entries}};case"team_bridge.conversations.list":{const t=new URLSearchParams;return e.scope==="account"&&t.set("scope","account"),e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor),e.before&&t.set("before",e.before),{path:`/v1/desktop/team-bridge/conversations${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.conversations.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${Lr(e.tenant_id)}`,method:"GET"};case"team_bridge.conversations.create":return{path:"/v1/desktop/team-bridge/conversations",method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},kind:e.kind,...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agent_capable===void 0?{}:{agent_capable:e.agent_capable},members:e.members}};case"team_bridge.conversations.lifecycle":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/${e.action}`,method:"POST"};case"team_bridge.conversations.join":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/join`,method:"POST",...e.tenant_id?{body:{tenant_id:e.tenant_id}}:{}};case"team_bridge.conversations.notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.members.add":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members${n}`,method:"POST",body:e.members}}case"team_bridge.conversations.members.remove":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}`,method:"DELETE"};case"team_bridge.conversations.consent":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}/consent`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},decision:e.decision,consent_version:e.consent_version}};case"team_bridge.messages.list":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.endpoint_id&&t.set("endpoint_id",e.endpoint_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages${n}`,method:"GET"}}case"team_bridge.reactions.toggle":{const t=`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/reactions/${encodeURIComponent(e.emoji)}`;return e.active?{path:t,method:"PUT",body:e.tenant_id?{tenant_id:e.tenant_id}:{}}:{path:`${t}${Lr(e.tenant_id)}`,method:"DELETE"}}case"team_bridge.messages.send":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},client_ref:e.client_ref,body:e.body,...e.agent_label?{agent_label:e.agent_label}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.messages.replies":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq));const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/replies${n}`,method:"GET"}}case"team_bridge.read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.seq===void 0?{}:{seq:e.seq},...e.muted===void 0?{}:{muted:e.muted}}};case"team_bridge.unread":{const t=new URLSearchParams;return e.scope==="account"?t.set("scope","account"):e.tenant_id&&t.set("tenant_id",e.tenant_id),{path:`/v1/desktop/team-bridge/unread${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.directory":return{path:`/v1/desktop/team-bridge/directory?tenant_id=${encodeURIComponent(e.tenant_id)}`,method:"GET"};case"team_bridge.status":{const t=new URLSearchParams;return e.boundary&&t.set("boundary",e.boundary),{path:`/v1/desktop/team-bridge/status${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"library.list":{const t=new URLSearchParams;e.scope&&t.set("scope",e.scope),e.q&&t.set("q",e.q),e.category&&t.set("category",e.category),e.kind&&t.set("kind",e.kind),e.origin_group&&t.set("origin_group",e.origin_group),e.origin&&t.set("origin",e.origin),e.tag&&t.set("tag",e.tag),e.tag_mode&&t.set("tag_mode",e.tag_mode),e.highlighted!==void 0&&t.set("highlighted",e.highlighted?"1":"0"),e.organized!==void 0&&t.set("organized",e.organized?"1":"0"),e.favorite!==void 0&&t.set("favorite",e.favorite?"1":"0"),e.session&&t.set("session",e.session),e.session_id&&t.set("session_id",e.session_id),e.sort&&t.set("sort",e.sort),e.order&&t.set("order",e.order),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor);const n=t.toString();return{path:`/v1/desktop/library/assets${n?`?${n}`:""}`,method:"GET"}}case"library.get":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"GET"};case"library.update":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"PATCH",body:e.fields};case"library.tags":return{path:"/v1/desktop/library/tags",method:"GET"};case"library.tags.create":return{path:"/v1/desktop/library/tags",method:"POST",body:{name:e.name,...e.category!==void 0?{category:e.category}:{}}};case"library.tags.update":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"PATCH",body:{...e.name!==void 0?{name:e.name}:{},...e.category!==void 0?{category:e.category}:{}}};case"library.tags.delete":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"DELETE"};case"library.tags.merge":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}/merge`,method:"POST",body:{into:e.into}};case"library.tags.assign":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/tags`,method:"PUT",body:{tags:e.tags,...e.primary!==void 0?{primary:e.primary}:{}}};case"library.chat.link":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"PUT",body:{session_id:e.sessionId}};case"library.chat.clear":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"DELETE"};case"library.librarian":{const t=e.action??"status";return t==="status"?{path:"/v1/desktop/librarian",method:"GET"}:{path:"/v1/desktop/librarian",method:"POST",body:{op:t}}}case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields,...e.force_done===!0?{force_done:!0}:{}}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??Jp)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}};case"sidebar_layout.get":return{path:"/v1/desktop/sidebar-layout",method:"GET"};case"sidebar_layout.set":return{path:"/v1/desktop/sidebar-layout",method:"PUT",body:{layout:e.layout}}}}const qS=64,ek=64*1024*1024,tk="superseded_completion_token",nk="store_busy",Dh="session_is_remote",Nh="owner_build_behind";function rk(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function mn(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function Lh(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const sk=e=>typeof e?.goal_status=="string",ik=e=>(e?.goal??"").trim().length>0;function $h(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const Zn={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},$a={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},Uh={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},Fh={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},Bh={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},Gh={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function Ua(e){return e?e===Zn.notPaired?Fh:e===Zn.serverDown?Uh:e===Zn.frameBudget?Gh:$a:$a}const Fa=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const p=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(h=>h(t,p))}},s=()=>t,l={setState:r,getState:s,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,s,l);return l},Hh=e=>e?Fa(e):Fa,Wh=e=>e;function zh(e,t=Wh){const n=na.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return na.useDebugValue(n),n}const Ba=e=>{const t=Hh(e),n=r=>zh(t,r);return Object.assign(n,t),n},_r=e=>e?Ba(e):Ba;function kc(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const a=c=>c===null?null:JSON.parse(c,void 0),l=(i=n.getItem(s))!=null?i:null;return l instanceof Promise?l.then(a):a(l)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const bi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return bi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return bi(r)(n)}}}},Zh=(e,t)=>(n,r,s)=>{let i={storage:kc(()=>localStorage),partialize:m=>m,version:0,merge:(m,y)=>({...y,...m}),...t},a=!1;const l=new Set,c=new Set;let d=i.storage;if(!d)return e((...m)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...m)},r,s);const u=()=>{const m=i.partialize({...r()});return d.setItem(i.name,{state:m,version:i.version})},f=s.setState;s.setState=(m,y)=>{f(m,y),u()};const p=e((...m)=>{n(...m),u()},r,s);s.getInitialState=()=>p;let h;const g=()=>{var m,y;if(!d)return;a=!1,l.forEach(v=>{var I;return v((I=r())!=null?I:p)});const _=((y=i.onRehydrateStorage)==null?void 0:y.call(i,(m=r())!=null?m:p))||void 0;return bi(d.getItem.bind(d))(i.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==i.version){if(i.migrate){const I=i.migrate(v.state,v.version);return I instanceof Promise?I.then(C=>[!0,C]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var I;const[C,J]=v;if(h=i.merge(J,(I=r())!=null?I:p),n(h,!0),C)return u()}).then(()=>{_?.(h,void 0),h=r(),a=!0,c.forEach(v=>v(h))}).catch(v=>{_?.(void 0,v)})};return s.persist={setOptions:m=>{i={...i,...m},m.storage&&(d=m.storage)},clearStorage:()=>{d?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>a,onHydrate:m=>(l.add(m),()=>{l.delete(m)}),onFinishHydration:m=>(c.add(m),()=>{c.delete(m)})},i.skipHydration||g(),h||p},ms=Zh,Vh=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function Kh(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,s)=>typeof r=="number"&&Number.isFinite(r)?r:s;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const Rc=_r()(ms(e=>({notice:null,receive:t=>e(n=>Vh(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:kc(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));async function Ec(e){if(window.api?.desktop)try{return await Yh(window.api.desktop.request(e),e)}catch(n){throw n instanceof ye?n:tm(n)?new $t(Sc,wc):new ye(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new ye(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new ye(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function Yh(e,t){const n=bc(t);let r;return Promise.race([e,new Promise((s,i)=>{r=setTimeout(()=>{const a=Ph(t.op,n);i(new ye(null,a.message,void 0,a.code))},n)})]).finally(()=>clearTimeout(r))}const Qh="This server did not answer the request for its desktop controls.";class ye extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,s,i,a){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=s,this.retryAfterMs=i,this.detail=a}}class $t extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function no(e,t){return e instanceof ye||e instanceof $t?hs(e.code)?eo[e.code]:e.message:t}function Jh(e,t,n,r){return typeof r=="string"?r:n===_i.noCredential?Je.noCredential:n===_i.transportFailed?Je.transportFailed:sh(Mh(e).path,t)}async function xe(e){const t=await Ec(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new ye(t.status,r??Qh,void 0,Jh(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&Xh(n?.result),n?.result}function Xh(e){if(typeof e!="object"||e===null)return;const t=Kh(e.delegated_cleanup_notice);t&&Rc.getState().receive(t)}async function qh(){try{await xe({op:"delegated_cleanup_notice.ack"})}catch{}}async function ok(){Rc.getState().dismiss(),await qh()}function em(e){return e instanceof ye&&e.code===to}function ak(e){if(!(e instanceof ye))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===Nh:e.code===Dh}function lk(e){return e instanceof $t&&e.code===wc}function tm(e){return e instanceof Error&&e.message.includes(Sc)}async function ck(e){const t=await Ec(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function dk(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await xe({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function nm(e,t){const n=window.api?.desktop?.stream;if(n){const i=n.subscribe(e,t);return()=>i.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),ts(r,"/__desktop/stream",e.orderIds??[]));const s=new EventSource(`/__desktop/stream?${r}`);return s.onmessage=i=>{t({kind:"data",data:i.data})},s.onerror=()=>{s.readyState===EventSource.CLOSED&&(t({kind:"error",detail:Zn.ended}),s.close())},()=>{s.close(),t({kind:"end"})}}async function uk(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),s=r.headers.get("content-type")??"";if(!r.ok){let i="The media request failed.",a;if(s.includes("application/json"))try{const c=(await r.json())?.detail;if(typeof c=="string")i=c;else if(typeof c=="object"&&c!==null){const d=c;typeof d.text=="string"&&d.text.trim()?i=d.text:typeof d.message=="string"&&d.message.trim()&&(i=d.message),typeof d.code=="string"&&(a=d.code)}}catch{}return{status:r.status,kind:"error",detail:i,code:a!==void 0&&hs(a)?a:i===_i.noCredential?Je.noCredential:void 0}}return s.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:s||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function fk(e){return e.kind==="error"?hs(e.code)?new $t(eo[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const Nn=e=>{const t=e.id;return typeof t=="string"?t:typeof t=="number"?String(t):null};function rm(e,t){const n=new Set((t.removed??[]).map(String)),r=e.filter(a=>{const l=Nn(a);return l===null||!n.has(l)});for(const a of t.upserted??[]){const l=Nn(a);if(l===null){r.push(a);continue}const c=r.findIndex(d=>Nn(d)===l);c===-1?r.push(a):r[c]=a}if(!t.order)return r;const s=new Map;for(const a of r){const l=Nn(a);l!==null&&s.set(l,a)}const i=[];for(const a of t.order){const l=String(a),c=s.get(l);c&&(i.push(c),s.delete(l))}for(const a of r){const l=Nn(a);l!==null&&s.has(l)?(i.push(a),s.delete(l)):l===null&&i.push(a)}return i}const wi=e=>({revision:Ke(e),demand:e.orderDemand}),Kt=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Rn(e,t,n,r,s,i={}){let a=e;const l=t.journal_generation;if(t.reconcile===!0){const p=typeof l=="string"&&l.length>0?l:void 0;return a.orderNeedsReconcile&&a.orderWantedGeneration===p?a.journalMode?a:{...a,journalMode:!0}:{...a,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:p,orderDemand:p!==void 0?{generation:p}:{}}}if(typeof l!="string"||l.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&s&&a.orderNeedsReconcile&&a.orderDemand===s.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),l!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===l?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:l,orderDemand:{generation:l}};let c=a.journalMode?a:{...a,journalMode:!0};if(l!==a.journalGeneration&&(c={...a,journalMode:!0,journalGeneration:l,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand},i.peer===!0)){const p=(a.orderRevision??0)+1,h=new Map;for(const g of a.records){const m=g.sourceEntryId??(g.kind==="tool"||g.kind==="supplement"?null:g.id);typeof m=="string"&&m.length>0&&m.length<=128&&h.set(m,p)}c={...c,...h.size>0?{journalBodyOwed:h}:{},journalSourceVoid:void 0}}let d=c.journalPositions??new Map;const u=d,f=(p,h,g)=>{if(!Kt(g))return;const m=d.get(p);m&&m.seq>=g||(d===u&&(d=new Map(d)),d.set(p,{entryId:h,seq:g}))};for(const[p,h]of Object.entries(t.journal_ordinals??{}))f(p,p,h);for(const p of n)typeof p.id=="string"&&(f(p.id,p.id,p.journal_seq),p.role==="tool"&&typeof p.tool_call_id=="string"&&f(`tool:${p.tool_call_id}`,p.id,p.journal_seq),typeof p.anchor=="string"&&f(`supplement:${p.anchor}`,p.id,p.journal_seq));return d!==u&&(c={...c,journalPositions:d}),c}function ro(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const s=n,i=r;return t.tool_calls.forEach((a,l)=>{!a||typeof a.id!="string"||(n.get(a.id)!==t.id&&(n===s&&(n=new Map(n)),n.set(a.id,t.id)),r.get(a.id)!==l&&(r===i&&(r=new Map(r)),r.set(a.id,l)))}),n===s&&r===i?e:{...e,journalCallOwners:n,journalCallSlots:r}}function Ic(e,t){const n=new Set(e.map(i=>i.id));let r=!1,s;for(let i=0;i<e.length;i++){const a=e[i];if(a.kind==="user"&&a.provisional===!0){s=a;continue}!t(a)&&s&&(a.sourceAdmissionAnchor===void 0||!n.has(a.sourceAdmissionAnchor))&&(e[i]={...a,sourceAdmissionAnchor:s.id},r=!0),s=e[i]}return r}function xc(e,t,n,r,s){const i=[],a=new Set;let l=e,c;for(;l!==void 0;){if(s.has(l.id)){c=s.get(l.id);break}if(n(l)){c=r(l);break}if(l.kind==="user"&&l.provisional===!0||a.has(l.id))break;a.add(l.id),i.push(l.id),l=l.sourceAdmissionAnchor?t.get(l.sourceAdmissionAnchor):void 0}for(const d of i)s.set(d,c);return c}function Tc(e,t){const n=new Map;return r=>{if(!r)return;const s=t(r);if(s===void 0)return;const i=[],a=new Set;let l=r,c=!0;for(;l;){if(n.has(l.id)){c=n.get(l.id)===!0;break}if(a.has(l.id)||t(l)===void 0){c=!1;break}a.add(l.id),i.push(l.id),l=l.sourceAdmissionAnchor===void 0?void 0:e.get(l.sourceAdmissionAnchor)}for(const d of i)n.set(d,c);return c?s:void 0}}function ns(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const s=new Map;t.forEach((a,l)=>{if(a.kind!=="tool")return;const c=n.get(a.toolCallId);if(c===void 0||!r.has(a.toolCallId))return;const d=s.get(c);d?d.push(l):s.set(c,[l])});let i=t;for(const a of s.values()){if(a.length<2)continue;const l=a.map(c=>t[c]).sort((c,d)=>(r.get(c.toolCallId)??0)-(r.get(d.toolCallId)??0));l.every((c,d)=>c===t[a[d]])||(i===t&&(i=t.slice()),a.forEach((c,d)=>{i[c]=l[d]}))}return i}function Cc(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return sm(e,t);const n=e.journalGeneration,r=e.journalPositions;let s=!1;const i=t.map(h=>{let m=[r?.get(h.sourceEntryId??h.id),r?.get(h.id)].filter(v=>v!==void 0).sort((v,I)=>I.seq-v.seq)[0];if(h.journalGeneration===n&&Kt(h.journalSeq)&&(!m||h.journalSeq>m.seq)&&(m={entryId:h.sourceEntryId??h.id,seq:h.journalSeq}),!m||!n||!(h.kind==="user"&&(h.provisional===!0||h.local===!0))&&h.sourceEntryId===m.entryId&&h.journalSeq===m.seq&&h.journalGeneration===n)return h;s=!0;let _={...h,sourceEntryId:m.entryId,journalSeq:m.seq,journalGeneration:n};if(_.kind==="user"){const{provisional:v,local:I,...C}=_;_=C}return _});Ic(i,h=>h.journalGeneration===n&&Kt(h.journalSeq))&&(s=!0);const l=new Map,c=new Map(i.map(h=>[h.id,h])),d=Tc(c,h=>h!==void 0&&h.journalGeneration===n&&Kt(h.journalSeq)?h.journalSeq:void 0),u=h=>d(h)!==void 0,f=(h,g)=>{const m=d(h);if(h.kind==="user"&&h.provisional===!0&&m===void 0)return[1,0,0,0,g];const y=h.kind==="supplement"?h.anchor:h.kind==="tool"?e.journalCallOwners?.get(h.toolCallId)??e.argsByCall.get(h.toolCallId)?.anchorId:void 0,_=typeof y=="string"?d(c.get(y)):void 0,v=m===void 0?xc(h,c,u,d,l):void 0,I=_??m??v;return I===void 0?[1,0,0,0,g]:[0,I,_!==void 0?1:m!==void 0?0:2,m??Number.MAX_SAFE_INTEGER,g]},p=i.map((h,g)=>({record:h,index:g,rank:f(h,g)}));return p.sort((h,g)=>{for(let m=0;m<h.rank.length;m++){const y=h.rank[m]-g.rank[m];if(y)return y}return 0}),!s&&p.every((h,g)=>h.index===g)?ns(e,t):ns(e,p.map(h=>h.record))}function sm(e,t){const n=e.journalGeneration,r=e.journalPositions,s=new Map;for(const m of t){let _=[r?.get(m.sourceEntryId??m.id),r?.get(m.id)].filter(v=>v!==void 0).sort((v,I)=>I.seq-v.seq)[0];m.journalGeneration===n&&Kt(m.journalSeq)&&(!_||m.journalSeq>_.seq)&&(_={entryId:m.sourceEntryId??m.id,seq:m.journalSeq}),_&&s.set(m.id,_)}const i=m=>m===void 0?void 0:s.get(m.id)??r?.get(m.sourceEntryId??m.id)??r?.get(m.id);let a=!1;const l=t.slice();Ic(l,m=>m.journalGeneration===n&&Kt(m.journalSeq))&&(a=!0);const d=new Map,u=new Map(l.map(m=>[m.id,m])),f=Tc(u,m=>i(m)?.seq),p=m=>f(m)!==void 0,h=(m,y)=>{const _=f(m);if(m.kind==="user"&&m.provisional===!0&&_===void 0)return[1,0,0,0,y];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,I=typeof v=="string"?f(u.get(v)):void 0,C=_===void 0?xc(m,u,p,f,d):void 0,J=I??_??C;return J===void 0?[1,0,0,0,y]:[0,J,I!==void 0?1:_!==void 0?0:2,_??Number.MAX_SAFE_INTEGER,y]},g=l.map((m,y)=>({record:m,index:y,rank:h(m,y)}));return g.sort((m,y)=>{for(let _=0;_<m.rank.length;_++){const v=m.rank[_]-y.rank[_];if(v)return v}return 0}),!a&&g.every((m,y)=>m.index===y)?ns(e,t):ns(e,g.map(m=>m.record))}function ut(e){const t=e.records.filter(s=>s.kind==="user"&&s.provisional===!0),n=e.records.filter(s=>s.journalGeneration!==e.journalGeneration||!Kt(s.journalSeq)),r=[...t,...n].map(s=>s.sourceEntryId??(s.kind==="tool"||s.kind==="supplement"?null:s.id));if(r.push(...so(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let s=r.length-1;s>=0;s--){const i=r[s];typeof i=="string"&&e.journalSourceVoid.has(i)&&r.splice(s,1)}return[...new Set(r.filter(s=>typeof s=="string"&&s.length>0&&s.length<=128))]}function so(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const s=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof s=="string"&&s.length>0&&s.length<=128&&t.add(s)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Ac(e,t){const n=e.journalPositions;return ut(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Ke=e=>e.orderRevision??0;async function im(e){const t=new Map,n=l=>{let c=t.get(l);return c||(c=new Set,t.set(l,c)),c},r=(l,c)=>c==="payload"?so(l):c==="lookup"?Ac(l):ut(l);let s=e.getTranscript().journalGeneration,i=0,a=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const l=e.getTranscript(),c=wi(l),d=c.revision,u=e.sweep?.(l,n);if(u?.kind==="none")return{kind:"complete",transcript:l};const f=u?.kind??"authority",p=pp(r(l,f).filter(y=>!n(f).has(y)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),h=await e.read(p,f);if(!e.isCurrent()||Ke(e.getTranscript())!==d)return{kind:"stale"};if(e.commit(h,d,c),!e.isCurrent())return{kind:"stale"};const g=e.getTranscript(),m=e.page(h);if(m.journal_order_state==="ready"&&m.journal_generation===g.journalGeneration){m.journal_generation!==s&&(t.clear(),s=m.journal_generation);for(const v of p)n(f).add(v);if(g.orderNeedsReconcile){if(g.orderDemand===c.demand||i===1)return{kind:"waiting"};i++,t.clear();continue}if(f==="payload"){const v=(m.source_retry_ids??[]).filter(I=>typeof I=="string"&&I.length>0&&I.length<=128);if(v.length>0&&p.length>1&&a===0){a++;for(const I of v)n("payload").delete(I);continue}}const y=e.sweep?.(g,n);if(y?.kind==="none")return{kind:"complete",transcript:g};const _=y?.kind??"authority";if(r(g,_).some(v=>!n(_).has(v)))continue;return{kind:"complete",transcript:g}}if(!g.orderNeedsReconcile||g.orderDemand===c.demand||i===1)return{kind:"waiting"};i++,t.clear()}}function rt(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const s=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof s=="string"&&s?s:e.id}function Ws(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function Ga(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function pk(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const i of t){if(!i.settled||typeof i.run_key!="string"||i.run_key.length===0)continue;const a=Ws(i.action_count);if(a===null)continue;const l={actions:a,workedSeconds:Ga(i.worked_seconds),failed:Ws(i.failed_count)??0,complete:i.complete!==!1,openingUserId:typeof i.opening_user_id=="string"&&i.opening_user_id.length>0?i.opening_user_id:null,closingAnswerId:typeof i.closing_answer_id=="string"&&i.closing_answer_id.length>0?i.closing_answer_id:null,crossSessionActions:Ws(i.cross_session_action_count),crossSessionWorkedSeconds:Ga(i.cross_session_worked_seconds)};n.set(i.run_key,l),l.openingUserId!==null&&n.set(l.openingUserId,l),l.closingAnswerId!==null&&n.set(l.closingAnswerId,l)}if(n.size===0)return null;const r=new Set;for(const i of e.entries)r.add(rt(i));const s=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:s?rt(s):null}}}function om(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(i=>i.opening_user_id===n.id))return null;const s=Math.round((n.ts??0)*1e3);return s>0?{id:n.id,tsMs:s}:null}function am(e,t,n){const r=om(e),s=e?.entries;if(r===null||!s||s.length===0)return!1;const i=Math.round((s[s.length-1].ts??0)*1e3);if(!(i>r.tsMs))return!1;for(const[a,l]of t)if(!n.has(a)&&(l===null||!(l>r.tsMs)||!(l<i)))return!1;return!0}const io=new Set,en="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Oc=new RegExp(`[${en}]`),hk=new RegExp(`[${en}]+`),mk=new RegExp(`[${en}]+`,"g"),lm=new RegExp(`^[${en}]+|[${en}]+$`,"g"),cm=new RegExp(`^[${en}]+`),gk=new RegExp(`[^${en}]`);function Ot(e){return e.replace(lm,"")}function cr(e){return e.replace(cm,"")}function dm(e,t){return t===0||Oc.test(e[t-1])}function Pc(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&dm(e,n)&&t.push(n);return t}function oo(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
1
|
+
import{b as na,r as b,t as le,j as Yu,D as Qu}from"./index-BDzV3bGH.js";var ne;(function(e){e.assertEqual=s=>s;function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),a={};for(const l of i)a[l]=s[l];return e.objectValues(a)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},e.find=(s,i)=>{for(const a of s)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(ne||(ne={}));var fi;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(fi||(fi={}));const M=ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=e=>{switch(typeof e){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(e)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(e)?M.array:e===null?M.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?M.promise:typeof Map<"u"&&e instanceof Map?M.map:typeof Set<"u"&&e instanceof Set?M.set:typeof Date<"u"&&e instanceof Date?M.date:M.object;default:return M.unknown}},E=ne.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ju=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ze extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let l=r,c=0;for(;c<a.path.length;){const d=a.path[c];c===a.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(n(a))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}};return s(this),r}static assert(t){if(!(t instanceof Ze))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ze.create=e=>new Ze(e);const wn=(e,t)=>{let n;switch(e.code){case E.invalid_type:e.received===M.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case E.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ne.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:n=`Unrecognized key(s) in object: ${ne.joinValues(e.keys,", ")}`;break;case E.invalid_union:n="Invalid input";break;case E.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ne.joinValues(e.options)}`;break;case E.invalid_enum_value:n=`Invalid enum value. Expected ${ne.joinValues(e.options)}, received '${e.received}'`;break;case E.invalid_arguments:n="Invalid function arguments";break;case E.invalid_return_type:n="Invalid function return type";break;case E.invalid_date:n="Invalid date";break;case E.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ne.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case E.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case E.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case E.custom:n="Invalid input";break;case E.invalid_intersection_types:n="Intersection results could not be merged";break;case E.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case E.not_finite:n="Number must be finite";break;default:n=t.defaultError,ne.assertNever(e)}return{message:n}};let rc=wn;function Xu(e){rc=e}function Kr(){return rc}const Yr=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const c=r.filter(d=>!!d).slice().reverse();for(const d of c)l=d(a,{data:t,defaultError:l}).message;return{...s,path:i,message:l}},qu=[];function P(e,t){const n=Kr(),r=Yr({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===wn?void 0:wn].filter(s=>!!s)});e.common.issues.push(r)}class Ne{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return B;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return Ne.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return B;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const B=Object.freeze({status:"aborted"}),hn=e=>({status:"dirty",value:e}),$e=e=>({status:"valid",value:e}),pi=e=>e.status==="aborted",hi=e=>e.status==="dirty",Jt=e=>e.status==="valid",Qn=e=>typeof Promise<"u"&&e instanceof Promise;function Qr(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function sc(e,t,n,r,s){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var N;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(N||(N={}));var Bn,Gn;class mt{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ra=(e,t)=>{if(Jt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ze(e.common.issues);return this._error=n,this._error}}};function Y(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(a,l)=>{var c,d;const{message:u}=e;return a.code==="invalid_enum_value"?{message:u??l.defaultError}:typeof l.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:l.defaultError}:a.code!=="invalid_type"?{message:l.defaultError}:{message:(d=u??n)!==null&&d!==void 0?d:l.defaultError}},description:s}}class Q{get description(){return this._def.description}_getType(t){return wt(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:wt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ne,ctx:{common:t.parent.common,data:t.data,parsedType:wt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Qn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const s={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)},i=this._parseSync({data:t,path:s.path,parent:s});return ra(s,i)}"~validate"(t){var n,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:s});return Jt(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(n=i?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:s}).then(i=>Jt(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(Qn(s)?s:Promise.resolve(s));return ra(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const a=t(s),l=()=>i.addIssue({code:E.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(l(),!1)):a?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new lt({schema:this,typeName:F.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ht.create(this,this._def)}nullable(){return Lt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return at.create(this)}promise(){return kn.create(this,this._def)}or(t){return er.create([this,t],this._def)}and(t){return tr.create(this,t,this._def)}transform(t){return new lt({...Y(this._def),schema:this,typeName:F.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new or({...Y(this._def),innerType:this,defaultValue:n,typeName:F.ZodDefault})}brand(){return new qi({typeName:F.ZodBranded,type:this,...Y(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new ar({...Y(this._def),innerType:this,catchValue:n,typeName:F.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return vr.create(this,t)}readonly(){return lr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ef=/^c[^\s-]{8,}$/i,tf=/^[0-9a-z]+$/,nf=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rf=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,sf=/^[a-z0-9_-]{21}$/i,of=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,af=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,lf=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ms;const df=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,uf=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ff=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pf=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hf=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mf=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ic="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",gf=new RegExp(`^${ic}$`);function oc(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function yf(e){return new RegExp(`^${oc(e)}$`)}function ac(e){let t=`${ic}T${oc(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function vf(e,t){return!!((t==="v4"||!t)&&df.test(e)||(t==="v6"||!t)&&ff.test(e))}function _f(e,t){if(!of.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function bf(e,t){return!!((t==="v4"||!t)&&uf.test(e)||(t==="v6"||!t)&&pf.test(e))}class ot extends Q{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==M.string){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_type,expected:M.string,received:i.parsedType}),B}const r=new Ne;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,l=t.data.length<i.value;(a||l)&&(s=this._getOrReturnCtx(t,s),a?P(s,{code:E.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&P(s,{code:E.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")lf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"email",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ms||(Ms=new RegExp(cf,"u")),Ms.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"emoji",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")rf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"uuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")sf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"nanoid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")ef.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"cuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")tf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"cuid2",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")nf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"ulid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),P(s,{validation:"url",code:E.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"regex",code:E.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?ac(i).test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?gf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?yf(i).test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{code:E.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?af.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"duration",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?vf(t.data,i.version)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"ip",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?_f(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"jwt",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?bf(t.data,i.version)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"cidr",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?hf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"base64",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?mf.test(t.data)||(s=this._getOrReturnCtx(t,s),P(s,{validation:"base64url",code:E.invalid_string,message:i.message}),r.dirty()):ne.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:E.invalid_string,...N.errToObj(r)})}_addCheck(t){return new ot({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...N.errToObj(t)})}url(t){return this._addCheck({kind:"url",...N.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...N.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...N.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...N.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...N.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...N.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...N.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...N.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...N.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...N.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...N.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...N.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...N.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...N.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...N.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...N.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...N.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...N.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...N.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...N.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...N.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...N.errToObj(n)})}nonempty(t){return this.min(1,N.errToObj(t))}trim(){return new ot({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ot({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ot({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ot.create=e=>{var t;return new ot({checks:[],typeName:F.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Y(e)})};function wf(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=parseInt(e.toFixed(s).replace(".","")),a=parseInt(t.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class Mt extends Q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==M.number){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_type,expected:M.number,received:i.parsedType}),B}let r;const s=new Ne;for(const i of this._def.checks)i.kind==="int"?ne.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),P(r,{code:E.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?wf(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),P(r,{code:E.not_finite,message:i.message}),s.dirty()):ne.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,N.toString(n))}gt(t,n){return this.setLimit("min",t,!1,N.toString(n))}lte(t,n){return this.setLimit("max",t,!0,N.toString(n))}lt(t,n){return this.setLimit("max",t,!1,N.toString(n))}setLimit(t,n,r,s){return new Mt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:N.toString(s)}]})}_addCheck(t){return new Mt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:N.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:N.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:N.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ne.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Mt.create=e=>new Mt({checks:[],typeName:F.ZodNumber,coerce:e?.coerce||!1,...Y(e)});class Dt extends Q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==M.bigint)return this._getInvalidInput(t);let r;const s=new Ne;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),P(r,{code:E.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):ne.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return P(n,{code:E.invalid_type,expected:M.bigint,received:n.parsedType}),B}gte(t,n){return this.setLimit("min",t,!0,N.toString(n))}gt(t,n){return this.setLimit("min",t,!1,N.toString(n))}lte(t,n){return this.setLimit("max",t,!0,N.toString(n))}lt(t,n){return this.setLimit("max",t,!1,N.toString(n))}setLimit(t,n,r,s){return new Dt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:N.toString(s)}]})}_addCheck(t){return new Dt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:N.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Dt.create=e=>{var t;return new Dt({checks:[],typeName:F.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Y(e)})};class Jn extends Q{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==M.boolean){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.boolean,received:r.parsedType}),B}return $e(t.data)}}Jn.create=e=>new Jn({typeName:F.ZodBoolean,coerce:e?.coerce||!1,...Y(e)});class Xt extends Q{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==M.date){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_type,expected:M.date,received:i.parsedType}),B}if(isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return P(i,{code:E.invalid_date}),B}const r=new Ne;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),P(s,{code:E.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):ne.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Xt({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:N.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:N.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Xt.create=e=>new Xt({checks:[],coerce:e?.coerce||!1,typeName:F.ZodDate,...Y(e)});class Jr extends Q{_parse(t){if(this._getType(t)!==M.symbol){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.symbol,received:r.parsedType}),B}return $e(t.data)}}Jr.create=e=>new Jr({typeName:F.ZodSymbol,...Y(e)});class Xn extends Q{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.undefined,received:r.parsedType}),B}return $e(t.data)}}Xn.create=e=>new Xn({typeName:F.ZodUndefined,...Y(e)});class qn extends Q{_parse(t){if(this._getType(t)!==M.null){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.null,received:r.parsedType}),B}return $e(t.data)}}qn.create=e=>new qn({typeName:F.ZodNull,...Y(e)});class Sn extends Q{constructor(){super(...arguments),this._any=!0}_parse(t){return $e(t.data)}}Sn.create=e=>new Sn({typeName:F.ZodAny,...Y(e)});class Vt extends Q{constructor(){super(...arguments),this._unknown=!0}_parse(t){return $e(t.data)}}Vt.create=e=>new Vt({typeName:F.ZodUnknown,...Y(e)});class St extends Q{_parse(t){const n=this._getOrReturnCtx(t);return P(n,{code:E.invalid_type,expected:M.never,received:n.parsedType}),B}}St.create=e=>new St({typeName:F.ZodNever,...Y(e)});class Xr extends Q{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.void,received:r.parsedType}),B}return $e(t.data)}}Xr.create=e=>new Xr({typeName:F.ZodVoid,...Y(e)});class at extends Q{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==M.array)return P(n,{code:E.invalid_type,expected:M.array,received:n.parsedType}),B;if(s.exactLength!==null){const a=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(a||l)&&(P(n,{code:a?E.too_big:E.too_small,minimum:l?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(P(n,{code:E.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(P(n,{code:E.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,l)=>s.type._parseAsync(new mt(n,a,n.path,l)))).then(a=>Ne.mergeArray(r,a));const i=[...n.data].map((a,l)=>s.type._parseSync(new mt(n,a,n.path,l)));return Ne.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new at({...this._def,minLength:{value:t,message:N.toString(n)}})}max(t,n){return new at({...this._def,maxLength:{value:t,message:N.toString(n)}})}length(t,n){return new at({...this._def,exactLength:{value:t,message:N.toString(n)}})}nonempty(t){return this.min(1,t)}}at.create=(e,t)=>new at({type:e,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...Y(t)});function un(e){if(e instanceof ve){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ht.create(un(r))}return new ve({...e._def,shape:()=>t})}else return e instanceof at?new at({...e._def,type:un(e.element)}):e instanceof ht?ht.create(un(e.unwrap())):e instanceof Lt?Lt.create(un(e.unwrap())):e instanceof gt?gt.create(e.items.map(t=>un(t))):e}class ve extends Q{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ne.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==M.object){const d=this._getOrReturnCtx(t);return P(d,{code:E.invalid_type,expected:M.object,received:d.parsedType}),B}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),l=[];if(!(this._def.catchall instanceof St&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||l.push(d);const c=[];for(const d of a){const u=i[d],f=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new mt(s,f,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof St){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of l)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")l.length>0&&(P(s,{code:E.unrecognized_keys,keys:l}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of l){const f=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new mt(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const f=await u.key,p=await u.value;d.push({key:f,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Ne.mergeObjectSync(r,d)):Ne.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return N.errToObj,new ve({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,i,a,l;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(l=N.errToObj(t).message)!==null&&l!==void 0?l:c}:{message:c}}}:{}})}strip(){return new ve({...this._def,unknownKeys:"strip"})}passthrough(){return new ve({...this._def,unknownKeys:"passthrough"})}extend(t){return new ve({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ve({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:F.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new ve({...this._def,catchall:t})}pick(t){const n={};return ne.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new ve({...this._def,shape:()=>n})}omit(t){const n={};return ne.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new ve({...this._def,shape:()=>n})}deepPartial(){return un(this)}partial(t){const n={};return ne.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}),new ve({...this._def,shape:()=>n})}required(t){const n={};return ne.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ht;)i=i._def.innerType;n[r]=i}}),new ve({...this._def,shape:()=>n})}keyof(){return lc(ne.objectKeys(this.shape))}}ve.create=(e,t)=>new ve({shape:()=>e,unknownKeys:"strip",catchall:St.create(),typeName:F.ZodObject,...Y(t)});ve.strictCreate=(e,t)=>new ve({shape:()=>e,unknownKeys:"strict",catchall:St.create(),typeName:F.ZodObject,...Y(t)});ve.lazycreate=(e,t)=>new ve({shape:e,unknownKeys:"strip",catchall:St.create(),typeName:F.ZodObject,...Y(t)});class er extends Q{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const a=i.map(l=>new Ze(l.ctx.common.issues));return P(n,{code:E.invalid_union,unionErrors:a}),B}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=a.map(c=>new Ze(c));return P(n,{code:E.invalid_union,unionErrors:l}),B}}get options(){return this._def.options}}er.create=(e,t)=>new er({options:e,typeName:F.ZodUnion,...Y(t)});const _t=e=>e instanceof rr?_t(e.schema):e instanceof lt?_t(e.innerType()):e instanceof sr?[e.value]:e instanceof Nt?e.options:e instanceof ir?ne.objectValues(e.enum):e instanceof or?_t(e._def.innerType):e instanceof Xn?[void 0]:e instanceof qn?[null]:e instanceof ht?[void 0,..._t(e.unwrap())]:e instanceof Lt?[null,..._t(e.unwrap())]:e instanceof qi||e instanceof lr?_t(e.unwrap()):e instanceof ar?_t(e._def.innerType):[];class us extends Q{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.object)return P(n,{code:E.invalid_type,expected:M.object,received:n.parsedType}),B;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(P(n,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),B)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const a=_t(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of a){if(s.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);s.set(l,i)}}return new us({typeName:F.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...Y(r)})}}function mi(e,t){const n=wt(e),r=wt(t);if(e===t)return{valid:!0,data:e};if(n===M.object&&r===M.object){const s=ne.objectKeys(t),i=ne.objectKeys(e).filter(l=>s.indexOf(l)!==-1),a={...e,...t};for(const l of i){const c=mi(e[l],t[l]);if(!c.valid)return{valid:!1};a[l]=c.data}return{valid:!0,data:a}}else if(n===M.array&&r===M.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const a=e[i],l=t[i],c=mi(a,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===M.date&&r===M.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class tr extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,a)=>{if(pi(i)||pi(a))return B;const l=mi(i.value,a.value);return l.valid?((hi(i)||hi(a))&&n.dirty(),{status:n.value,value:l.data}):(P(r,{code:E.invalid_intersection_types}),B)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}tr.create=(e,t,n)=>new tr({left:e,right:t,typeName:F.ZodIntersection,...Y(n)});class gt extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.array)return P(r,{code:E.invalid_type,expected:M.array,received:r.parsedType}),B;if(r.data.length<this._def.items.length)return P(r,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B;!this._def.rest&&r.data.length>this._def.items.length&&(P(r,{code:E.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new mt(r,a,r.path,l)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>Ne.mergeArray(n,a)):Ne.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new gt({...this._def,rest:t})}}gt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gt({items:e,typeName:F.ZodTuple,rest:null,...Y(t)})};class nr extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.object)return P(r,{code:E.invalid_type,expected:M.object,received:r.parsedType}),B;const s=[],i=this._def.keyType,a=this._def.valueType;for(const l in r.data)s.push({key:i._parse(new mt(r,l,r.path,l)),value:a._parse(new mt(r,r.data[l],r.path,l)),alwaysSet:l in r.data});return r.common.async?Ne.mergeObjectAsync(n,s):Ne.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Q?new nr({keyType:t,valueType:n,typeName:F.ZodRecord,...Y(r)}):new nr({keyType:ot.create(),valueType:t,typeName:F.ZodRecord,...Y(n)})}}class qr extends Q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.map)return P(r,{code:E.invalid_type,expected:M.map,received:r.parsedType}),B;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([l,c],d)=>({key:s._parse(new mt(r,l,r.path,[d,"key"])),value:i._parse(new mt(r,c,r.path,[d,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of a){const d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return B;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),l.set(d.value,u.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of a){const d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return B;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),l.set(d.value,u.value)}return{status:n.value,value:l}}}}qr.create=(e,t,n)=>new qr({valueType:t,keyType:e,typeName:F.ZodMap,...Y(n)});class qt extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.set)return P(r,{code:E.invalid_type,expected:M.set,received:r.parsedType}),B;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(P(r,{code:E.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(P(r,{code:E.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function a(c){const d=new Set;for(const u of c){if(u.status==="aborted")return B;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}const l=[...r.data.values()].map((c,d)=>i._parse(new mt(r,c,r.path,d)));return r.common.async?Promise.all(l).then(c=>a(c)):a(l)}min(t,n){return new qt({...this._def,minSize:{value:t,message:N.toString(n)}})}max(t,n){return new qt({...this._def,maxSize:{value:t,message:N.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}qt.create=(e,t)=>new qt({valueType:e,minSize:null,maxSize:null,typeName:F.ZodSet,...Y(t)});class gn extends Q{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.function)return P(n,{code:E.invalid_type,expected:M.function,received:n.parsedType}),B;function r(l,c){return Yr({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Kr(),wn].filter(d=>!!d),issueData:{code:E.invalid_arguments,argumentsError:c}})}function s(l,c){return Yr({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Kr(),wn].filter(d=>!!d),issueData:{code:E.invalid_return_type,returnTypeError:c}})}const i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof kn){const l=this;return $e(async function(...c){const d=new Ze([]),u=await l._def.args.parseAsync(c,i).catch(h=>{throw d.addIssue(r(c,h)),d}),f=await Reflect.apply(a,this,u);return await l._def.returns._def.type.parseAsync(f,i).catch(h=>{throw d.addIssue(s(f,h)),d})})}else{const l=this;return $e(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new Ze([r(c,d.error)]);const u=Reflect.apply(a,this,d.data),f=l._def.returns.safeParse(u,i);if(!f.success)throw new Ze([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new gn({...this._def,args:gt.create(t).rest(Vt.create())})}returns(t){return new gn({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new gn({args:t||gt.create([]).rest(Vt.create()),returns:n||Vt.create(),typeName:F.ZodFunction,...Y(r)})}}class rr extends Q{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}rr.create=(e,t)=>new rr({getter:e,typeName:F.ZodLazy,...Y(t)});class sr extends Q{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return P(n,{received:n.data,code:E.invalid_literal,expected:this._def.value}),B}return{status:"valid",value:t.data}}get value(){return this._def.value}}sr.create=(e,t)=>new sr({value:e,typeName:F.ZodLiteral,...Y(t)});function lc(e,t){return new Nt({values:e,typeName:F.ZodEnum,...Y(t)})}class Nt extends Q{constructor(){super(...arguments),Bn.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return P(n,{expected:ne.joinValues(r),received:n.parsedType,code:E.invalid_type}),B}if(Qr(this,Bn)||sc(this,Bn,new Set(this._def.values)),!Qr(this,Bn).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return P(n,{received:n.data,code:E.invalid_enum_value,options:r}),B}return $e(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Nt.create(t,{...this._def,...n})}exclude(t,n=this._def){return Nt.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Bn=new WeakMap;Nt.create=lc;class ir extends Q{constructor(){super(...arguments),Gn.set(this,void 0)}_parse(t){const n=ne.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==M.string&&r.parsedType!==M.number){const s=ne.objectValues(n);return P(r,{expected:ne.joinValues(s),received:r.parsedType,code:E.invalid_type}),B}if(Qr(this,Gn)||sc(this,Gn,new Set(ne.getValidEnumValues(this._def.values))),!Qr(this,Gn).has(t.data)){const s=ne.objectValues(n);return P(r,{received:r.data,code:E.invalid_enum_value,options:s}),B}return $e(t.data)}get enum(){return this._def.values}}Gn=new WeakMap;ir.create=(e,t)=>new ir({values:e,typeName:F.ZodNativeEnum,...Y(t)});class kn extends Q{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.promise&&n.common.async===!1)return P(n,{code:E.invalid_type,expected:M.promise,received:n.parsedType}),B;const r=n.parsedType===M.promise?n.data:Promise.resolve(n.data);return $e(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}kn.create=(e,t)=>new kn({type:e,typeName:F.ZodPromise,...Y(t)});class lt extends Q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:a=>{P(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async l=>{if(n.value==="aborted")return B;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?B:c.status==="dirty"||n.value==="dirty"?hn(c.value):c});{if(n.value==="aborted")return B;const l=this._def.schema._parseSync({data:a,path:r.path,parent:r});return l.status==="aborted"?B:l.status==="dirty"||n.value==="dirty"?hn(l.value):l}}if(s.type==="refinement"){const a=l=>{const c=s.refinement(l,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?B:(l.status==="dirty"&&n.dirty(),a(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?B:(l.status==="dirty"&&n.dirty(),a(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Jt(a))return a;const l=s.transform(a.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Jt(a)?Promise.resolve(s.transform(a.value,i)).then(l=>({status:n.value,value:l})):a);ne.assertNever(s)}}lt.create=(e,t,n)=>new lt({schema:e,typeName:F.ZodEffects,effect:t,...Y(n)});lt.createWithPreprocess=(e,t,n)=>new lt({schema:t,effect:{type:"preprocess",transform:e},typeName:F.ZodEffects,...Y(n)});class ht extends Q{_parse(t){return this._getType(t)===M.undefined?$e(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ht.create=(e,t)=>new ht({innerType:e,typeName:F.ZodOptional,...Y(t)});class Lt extends Q{_parse(t){return this._getType(t)===M.null?$e(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Lt.create=(e,t)=>new Lt({innerType:e,typeName:F.ZodNullable,...Y(t)});class or extends Q{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===M.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}or.create=(e,t)=>new or({innerType:e,typeName:F.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Y(t)});class ar extends Q{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Qn(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ar.create=(e,t)=>new ar({innerType:e,typeName:F.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Y(t)});class es extends Q{_parse(t){if(this._getType(t)!==M.nan){const r=this._getOrReturnCtx(t);return P(r,{code:E.invalid_type,expected:M.nan,received:r.parsedType}),B}return{status:"valid",value:t.data}}}es.create=e=>new es({typeName:F.ZodNaN,...Y(e)});const Sf=Symbol("zod_brand");class qi extends Q{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class vr extends Q{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?B:i.status==="dirty"?(n.dirty(),hn(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?B:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new vr({in:t,out:n,typeName:F.ZodPipeline})}}class lr extends Q{_parse(t){const n=this._def.innerType._parse(t),r=s=>(Jt(s)&&(s.value=Object.freeze(s.value)),s);return Qn(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}lr.create=(e,t)=>new lr({innerType:e,typeName:F.ZodReadonly,...Y(t)});function sa(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function cc(e,t={},n){return e?Sn.create().superRefine((r,s)=>{var i,a;const l=e(r);if(l instanceof Promise)return l.then(c=>{var d,u;if(!c){const f=sa(t,r),p=(u=(d=f.fatal)!==null&&d!==void 0?d:n)!==null&&u!==void 0?u:!0;s.addIssue({code:"custom",...f,fatal:p})}});if(!l){const c=sa(t,r),d=(a=(i=c.fatal)!==null&&i!==void 0?i:n)!==null&&a!==void 0?a:!0;s.addIssue({code:"custom",...c,fatal:d})}}):Sn.create()}const kf={object:ve.lazycreate};var F;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(F||(F={}));const Rf=(e,t={message:`Input not instance of ${e.name}`})=>cc(n=>n instanceof e,t),dc=ot.create,uc=Mt.create,Ef=es.create,If=Dt.create,fc=Jn.create,xf=Xt.create,Tf=Jr.create,Cf=Xn.create,Af=qn.create,Of=Sn.create,Pf=Vt.create,jf=St.create,Mf=Xr.create,Df=at.create,Nf=ve.create,Lf=ve.strictCreate,$f=er.create,Uf=us.create,Ff=tr.create,Bf=gt.create,Gf=nr.create,Hf=qr.create,Wf=qt.create,zf=gn.create,Zf=rr.create,Vf=sr.create,Kf=Nt.create,Yf=ir.create,Qf=kn.create,ia=lt.create,Jf=ht.create,Xf=Lt.create,qf=lt.createWithPreprocess,ep=vr.create,tp=()=>dc().optional(),np=()=>uc().optional(),rp=()=>fc().optional(),sp={string:e=>ot.create({...e,coerce:!0}),number:e=>Mt.create({...e,coerce:!0}),boolean:e=>Jn.create({...e,coerce:!0}),bigint:e=>Dt.create({...e,coerce:!0}),date:e=>Xt.create({...e,coerce:!0})},ip=B;var o=Object.freeze({__proto__:null,defaultErrorMap:wn,setErrorMap:Xu,getErrorMap:Kr,makeIssue:Yr,EMPTY_PATH:qu,addIssueToContext:P,ParseStatus:Ne,INVALID:B,DIRTY:hn,OK:$e,isAborted:pi,isDirty:hi,isValid:Jt,isAsync:Qn,get util(){return ne},get objectUtil(){return fi},ZodParsedType:M,getParsedType:wt,ZodType:Q,datetimeRegex:ac,ZodString:ot,ZodNumber:Mt,ZodBigInt:Dt,ZodBoolean:Jn,ZodDate:Xt,ZodSymbol:Jr,ZodUndefined:Xn,ZodNull:qn,ZodAny:Sn,ZodUnknown:Vt,ZodNever:St,ZodVoid:Xr,ZodArray:at,ZodObject:ve,ZodUnion:er,ZodDiscriminatedUnion:us,ZodIntersection:tr,ZodTuple:gt,ZodRecord:nr,ZodMap:qr,ZodSet:qt,ZodFunction:gn,ZodLazy:rr,ZodLiteral:sr,ZodEnum:Nt,ZodNativeEnum:ir,ZodPromise:kn,ZodEffects:lt,ZodTransformer:lt,ZodOptional:ht,ZodNullable:Lt,ZodDefault:or,ZodCatch:ar,ZodNaN:es,BRAND:Sf,ZodBranded:qi,ZodPipeline:vr,ZodReadonly:lr,custom:cc,Schema:Q,ZodSchema:Q,late:kf,get ZodFirstPartyTypeKind(){return F},coerce:sp,any:Of,array:Df,bigint:If,boolean:fc,date:xf,discriminatedUnion:Uf,effect:ia,enum:Kf,function:zf,instanceof:Rf,intersection:Ff,lazy:Zf,literal:Vf,map:Hf,nan:Ef,nativeEnum:Yf,never:jf,null:Af,nullable:Xf,number:uc,object:Nf,oboolean:rp,onumber:np,optional:Jf,ostring:tp,pipeline:ep,preprocess:qf,promise:Qf,record:Gf,set:Wf,strictObject:Lf,string:dc,symbol:Tf,transformer:ia,tuple:Bf,undefined:Cf,union:$f,unknown:Pf,void:Mf,NEVER:ip,ZodIssueCode:E,quotelessJson:Ju,ZodError:Ze});const oa=o.enum(["app_start","sign_in","window_focus","surface_open"]),pc=o.object({id:o.string().min(1),state:o.enum(["active","paused","disabled"])}).passthrough(),op=o.object({tenant_id:o.string().min(1),tenant_name:o.string().optional(),eligible:o.boolean(),endpoint:pc.nullable()}).passthrough(),ap=o.object({code:o.string(),message:o.string(),details:o.record(o.unknown()).optional(),retry_after_seconds:o.number().optional()}).passthrough(),lp=o.object({code:o.string().min(1),count:o.number().int().nonnegative(),session:o.string().min(1).nullable().optional().catch(null)}).passthrough().nullable().optional().catch(null),$S=o.object({capability:o.number(),consent_account_guard:o.boolean().optional(),state:o.enum(["ready","signed_out","unavailable","update_required"]),account_id:o.string().nullable(),tenant_id:o.string().nullable(),surface_state:o.enum(["A","B","C","D","E","F","G"]).nullable(),visibility:o.object({settings:o.boolean(),inbox:o.boolean(),account_door:o.boolean(),onboarding:o.boolean()}),update_required:o.boolean(),local:o.object({enabled:o.boolean(),onboarding:o.string(),session:o.string()}),status:o.object({tenants:o.array(op)}).passthrough().nullable(),consent:o.object({version:o.string().min(1).max(128),text:o.string().min(1).refine(e=>new TextEncoder().encode(e).length<=2048,"Consent exceeds the served-text contract"),source:o.enum(["served","cached","embedded"])}).nullable(),error:ap.nullable(),state_note:o.string().nullable().optional(),read_only:o.boolean().optional(),delivery_hold:lp}).passthrough(),cp=o.object({version:o.string().min(1),consented_at:o.string().min(1),consented_via:o.enum(["dialog","settings"]),current:o.boolean()}).passthrough(),US=o.object({endpoint:pc.extend({tenant_id:o.string().min(1),label:o.string().optional(),consent:cp.nullable().optional(),created_at:o.string().optional(),updated_at:o.string().optional()}).nullable(),settings:o.object({tenant_id:o.string().min(1),eligible:o.boolean(),consent_version:o.string().optional(),consent_required:o.boolean()}).passthrough()}).passthrough(),dp=o.object({kind:o.enum(["endpoint","account"]).optional(),endpoint_id:o.string().min(1).optional(),account_id:o.string().min(1).optional()}).passthrough().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id").refine(e=>e.kind===void 0||(e.kind==="endpoint"?e.endpoint_id!==void 0:e.account_id!==void 0),"An allowlist target's kind must agree with the id it carries"),aa=o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:dp,id:o.string().optional()}).passthrough(),la=o.object({mode:o.enum(["class_default","listed_only"]),allow:o.number(),deny:o.number()}).passthrough(),FS=o.object({allowlist:o.object({tenant_id:o.string().min(1),entries:o.array(aa)}).passthrough(),view:o.object({tenant_id:o.string().nullable(),entries:o.array(aa),directions:o.object({send:la,receive:la}),class_default:o.literal("cos_cos"),cues:o.object({allow_entry_switches_direction_to_listed_only:o.boolean(),listed_only_affects:o.string(),removing_allow_does_not_stop_open_thread:o.boolean(),deny_stops_pair_both_directions:o.boolean()}).passthrough()}).passthrough()}).passthrough();function BS(e,t){if(!e||!t||e.account_id!==t||e.capability<1||e.state!=="ready"||e.update_required||e.surface_state!=="B"||!e.visibility.onboarding||!e.tenant_id)return null;const n=e.status?.tenants.filter(r=>r.tenant_id===e.tenant_id);return n?.length!==1||n[0].eligible!==!0||n[0].endpoint!==null?null:{accountId:t,tenantId:e.tenant_id}}function GS(e){const t=e?.consent;return t&&(t.source==="served"||t.source==="cached")?t:null}const gi=["aida","library","projects","agents","schedules","browser","team-bridge","agent-hub","mesh"],up=6*1024,fp=512;function ts(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const s=[];for(const i of n){if(s.length===fp)break;const l=new URLSearchParams({order_ids:i}).toString().length+1;if(r+l>up)break;e.append("order_ids",i),s.push(i),r+=l}return s}function pp(e,t,n){return ts(new URLSearchParams(n),t,e)}const k=o.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),Ar=o.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Or=o.string().min(1).max(32768),hp=/^[a-f0-9]{12}$/,L=o.string().regex(hp),Ds=o.string().regex(/^[a-f0-9]{12}$/),Ns=o.string().min(1).max(128),mp=o.string().min(1).max(4096),Ls=o.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),Pr=o.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),ca=o.string().regex(/^[a-f0-9]{32}$/),gp=/^(\/|[A-Za-z]:[\\/])/,$s=o.string().min(1).max(4096).regex(gp),da=/^[a-f0-9]{32}$/,te=o.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),ua=o.string().min(1).max(512).nullish(),cn=o.string().regex(/^[A-Za-z0-9_-]{1,128}$/),fa=o.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),Mn=o.string().regex(/^la_[0-9a-f]{16}$/),Dn=o.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/),pa=o.object({data_b64:o.string().min(1).max(1e6),mime_type:o.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),ha=2e5,ma=8,yp=256,vp=100,ga=16,_p=256,bp=100,wp=200,Sp=1e6,kp=o.enum(["auto","none","minimal","low","medium","high","xhigh","max"]),Oe=o.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),jr=o.object({kind:o.enum(["agent","team"]),name:Oe}).strict(),hc=o.enum(["claude","codex","omp"]),Rp=o.record(o.string(),o.array(o.string().min(1).max(512)).max(5e3)),ya={sources:o.array(hc).max(3).optional(),sessionIds:Rp.optional(),all:o.boolean().optional(),includeSubagents:o.boolean().optional(),includeClearedSegments:o.boolean().optional(),includeMemory:o.boolean().optional(),includeInstructions:o.boolean().optional(),maxSessions:o.number().int().min(1).max(5e3).optional()},Us=o.object({provider:o.string().min(1).max(128),model_id:o.string().min(1).max(512),reasoning_effort:o.string().min(1).max(64).nullable()}).strict(),va=o.object({kind:o.enum(["role","specialist"]).optional(),description:o.string().max(8e3).optional(),instructions:o.string().max(8e3).optional(),tools:o.array(o.string().min(1).max(128)).max(256).optional(),effort:o.string().max(64).optional(),delegate:o.boolean().optional(),action_class:o.enum(["reactive","proactive"]).optional()}).strict(),_a=o.object({name:o.string().min(1).max(64).optional(),description:o.string().max(8e3).optional(),manager:Oe.optional(),members:o.array(o.object({role:Oe,count:o.number().int().min(1).max(16),kind:o.enum(["agent","team"]),tier:o.enum(["lo","med","hi"]).nullable().optional(),effort:kp.nullable().optional()}).strict()).max(128).optional(),instructions:o.string().max(8e3).optional(),project:o.string().max(8e3).optional()}).strict(),Ep=o.record(o.array(o.string().max(1024)).max(100)),ba=o.enum(["minutes","hours","days"]);function Ip(e){return!/^\.+$/.test(e)}const HS=e=>Wr.safeParse(e).success,Wr=o.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(Ip),wa=o.enum(["str","int","float","bool","list","dict"]),Sa=o.string().max(16384),xp=2e3,ka=o.string().min(1).max(xp),Ra=o.string().min(1).max(64),Tp=o.string().min(1).max(64),Cp=o.string().min(1).max(64),Ea=o.object({is_active:o.boolean().nullish(),one_time:o.boolean().nullish(),start_time_utc:o.string().max(64).nullish(),end_time_utc:o.string().max(64).nullish()}).strict(),Ap=o.object({conversation_length:o.number().int().optional(),detail_length:o.number().int().optional(),max_learnings_history:o.number().int().optional(),hosting:o.string().max(256).optional(),model_name:o.string().max(1024).optional(),auto_save_conversation:o.boolean().optional()}).strict(),yi=128,Ia=2e3,xa=8e3,Ta=64,Ca=64,fs=e=>[...e].length,vi=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,Op=e=>e===9||e===10||e===11||e===12||e===13||e===133,Pp=e=>e<=31||e>=127&&e<=159,jp=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),Mp=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,Mr=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},mc=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&vi(t[n].codePointAt(0)??0);)n++;for(;r>n&&vi(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},Dp=e=>{let t="",n=!1;for(const r of e){if(vi(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function Np(e){const t=mc(e);if(!t)return"must not be empty";if(fs(t)>yi)return`must be at most ${yi} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(Mr(t,Mp))return"must not contain Unicode bidirectional override characters";if(Mr(t,Op))return"must not contain whitespace";if(Mr(t,Pp))return"must not contain control characters";if(Mr(t,jp))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function WS(e){return Dp(mc(e).normalize("NFKC").toLowerCase())}function Lp(e){return e.trim()?fs(e)>Ia?`must be at most ${Ia} characters`:null:"must not be empty"}function $p(e){return e.trim()?fs(e)>xa?`must be at most ${xa} characters`:null:"must not be empty"}function Up(e){if(e.length>Ca)return`must hold at most ${Ca} items`;for(const t of e)if(!t.trim()||fs(t)>Ta)return`must hold items of 1 to ${Ta} characters`;return null}const Fp=e=>Np(e)===null,Bp=o.string().refine(Fp,{message:"That is not a name the hub can publish."}),Gp=o.string().refine(e=>$p(e)===null,{message:"That instruction body cannot be published."}),Hp=o.string().refine(e=>Lp(e)===null,{message:"That description cannot be published."}),Wp=o.array(o.string()).refine(e=>Up(e)===null,{message:"That tool list cannot be published."}),Fs={requestId:te.optional(),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()},Aa=o.object({name:Bp,description:Hp,instructions:Gp,kind:o.enum(["role","specialist"]),when_to_use:o.string(),tools:Wp,effort:o.string(),delegate:o.boolean(),version:o.string(),categories:o.array(o.string()),tags:o.array(o.string())}).partial().strict(),zp=o.enum(["team","agent"]),Zp=o.string().min(1).max(64),Vp=o.string().min(1).max(256),gc=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Bs=o.string().regex(gc,{message:"Letters, digits, dot, underscore and dash; no spaces."}),Kp=["planning","active","qa","validation","done","paused","archived"],Oa=o.enum(Kp),Dr=o.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),Pa=o.array(o.string().min(1).max(24)).max(8),Tt=o.string().min(1).max(64),Yp=1e3,ja=240,Ma=80,Qp=256,Jp=100,Xp=200,qp=/^[a-z0-9][a-z0-9_-]{0,23}$/;function zS(e){return e?gc.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function ZS(e){return qp.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Nr=o.enum(["agent","team","skill"]),Da=o.enum(gi),eh=o.object({visible:o.array(Da).max(gi.length),more:o.array(Da).max(gi.length)}).strict(),th=o.discriminatedUnion("op",[o.object({op:o.literal("capabilities")}).strict(),o.object({op:o.literal("runtimes.list")}).strict(),o.object({op:o.literal("profiles.list")}).strict(),o.object({op:o.literal("profiles.get"),name:Oe}).strict(),o.object({op:o.literal("imports.sources")}).strict(),o.object({op:o.literal("imports.sessions"),source:hc,includeSubagents:o.boolean().optional()}).strict(),o.object({op:o.literal("imports.preview"),...ya}).strict(),o.object({op:o.literal("imports.start"),...ya}).strict(),o.object({op:o.literal("imports.status"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("imports.cancel"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("profiles.update"),name:Oe,requestId:te,fields:va,expectedDefinitionRevision:ua.optional()}).strict(),o.object({op:o.literal("profiles.install"),name:Oe,requestId:te}).strict(),o.object({op:o.literal("profiles.create"),name:Oe,requestId:te,fields:va.extend({description:o.string().max(8e3),instructions:o.string().min(1).max(8e3)})}).strict(),o.object({op:o.literal("hub.updates")}).strict(),o.object({op:o.literal("hub.skillPull"),requestId:te,hubId:k,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:k.nullable(),localAlias:Oe,subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.skillSubscribe"),requestId:te,hubId:k,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:k.nullable(),localAlias:Oe}).strict(),o.object({op:o.literal("hub.skillUnpull"),requestId:te,linkId:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("hub.skillPublish"),requestId:te,dryRun:o.boolean(),sourceSkill:Oe,localAlias:Oe,visibility:o.enum(["public","org"]),tenantId:k.nullable(),subscribe:o.boolean(),autoPush:o.boolean(),confirmPublicEgress:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("hub.links"),kind:o.enum(["agent","team","skill"]).optional()}).strict(),o.object({op:o.literal("hub.policy"),requestId:te,linkId:o.string().min(1).max(256),expectedPolicyRevision:o.string().min(1).max(256),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.check"),requestId:te,linkId:o.string().min(1).max(256).optional(),direction:o.enum(["pull","push"]).optional(),kind:Nr.optional(),name:Oe.optional()}).strict(),o.object({op:o.literal("hub.apply"),requestId:te,previewReceipt:o.string().min(1).max(4096).optional(),confirmApply:o.literal(!0).optional(),linkId:o.string().min(1).max(256).optional(),direction:o.literal("pull").optional(),kind:Nr.optional(),name:Oe.optional(),prefer:o.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:o.boolean().optional(),dryRun:o.boolean().optional(),resolveSource:o.literal(!0).optional(),hubSource:o.string().min(1).max(2048).optional(),visibility:o.enum(["public","org"]).optional(),tenantId:o.string().min(1).max(128).nullable().optional()}).strict(),o.object({op:o.literal("hub.applyAll"),requestId:te,kind:Nr.optional()}).strict(),o.object({op:o.literal("hub.retry"),requestId:te,linkId:o.string().min(1).max(256).optional(),direction:o.enum(["pull","push"]).optional(),kind:Nr.optional(),name:Oe.optional()}).strict(),o.object({op:o.literal("hub.push"),requestId:te,linkId:o.string().min(1).max(256),direction:o.literal("push"),dryRun:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("teams.list")}).strict(),o.object({op:o.literal("teams.get"),name:Oe}).strict(),o.object({op:o.literal("teams.effective"),name:Oe}).strict(),o.object({op:o.literal("teams.update"),name:Oe,requestId:te,fields:_a,expectedDefinitionRevision:ua.optional()}).strict(),o.object({op:o.literal("teams.create"),requestId:te,fields:_a.extend({name:o.string().min(1).max(64)})}).strict(),o.object({op:o.literal("sessions.list"),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional(),include_peers:o.boolean().optional(),scope_kind:zp.optional(),scope_name:Zp.optional(),cursor:Vp.optional(),with_counts:o.boolean().optional(),sort:o.literal("activity").optional()}).strict(),o.object({op:o.literal("delegated_cleanup_notice.ack")}).strict(),o.object({op:o.literal("sessions.search"),q:o.string().min(1).max(yp),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.archive"),sessionId:L,archived:o.boolean()}).strict(),o.object({op:o.literal("sessions.delete"),sessionId:L,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.create"),requestId:te,cwd:o.string().min(1).max(4096).optional(),target:jr.optional(),purpose:o.literal("agents-config").optional(),model:Us.optional(),draftId:L.optional(),peer:cn.optional()}).strict(),o.object({op:o.literal("sessions.preview"),requestId:te,cwd:o.string().min(1).max(4096),target:jr.optional(),model:Us.optional()}).strict(),o.object({op:o.literal("sessions.draft"),requestId:te,cwd:o.string().min(1).max(4096),target:jr.optional(),model:Us.optional()}).strict(),o.object({op:o.literal("sessions.get"),sessionId:L,journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.files"),sessionId:L,scope:o.enum(["family","self"]).optional(),kind:o.string().max(256).optional(),q:o.string().max(256).optional(),sort:o.enum(["recent","name","kind","modified","created","size"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(8192).optional()}).strict(),o.object({op:o.literal("sessions.files.materialise"),sessionId:L,fileId:o.string().regex(/^[a-f0-9]{16}$/)}).strict(),o.object({op:o.literal("sessions.history"),sessionId:L,beforeId:k.optional(),limit:o.number().int().min(1).max(500).optional(),openFrame:o.boolean().optional(),journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional(),sourceRead:o.enum(["metadata","payload"]).optional(),expectedJournalGeneration:o.string().min(1).max(128).optional()}).strict(),o.object({op:o.literal("sessions.checkpoints"),sessionId:L}).strict(),o.object({op:o.literal("sessions.checkpoints.warm"),sessionId:L,ids:o.array(k).max(ga).optional(),limit:o.number().int().min(1).max(ga).optional()}).strict(),o.object({op:o.literal("sessions.find"),sessionId:L,q:o.string().min(1).max(_p),limit:o.number().int().min(1).max(wp).optional()}).strict(),o.object({op:o.literal("subagents.transcript"),sessionId:L,childId:L,beforeId:k.optional(),limit:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("sessions.message"),sessionId:L,requestId:te,text:o.string().max(ha),images:o.array(pa).max(ma).optional(),mode:o.enum(["prompt","steer"]).optional(),inputMode:o.enum(["typed","dictated","mixed"]).optional(),inputPath:o.string().max(1024).optional()}).strict(),o.object({op:o.literal("sessions.command"),sessionId:L,requestId:te,command:o.string().regex(/^\/?[A-Za-z]+$/).max(64),args:o.string().max(ha).optional(),images:o.array(pa).max(ma).optional()}).strict(),o.object({op:o.literal("sessions.move"),sessionId:L,requestId:te,cwd:o.string().min(1).max(4096)}).strict(),o.object({op:o.literal("sessions.answer"),sessionId:L,epoch:k.optional(),requestId:k.optional(),value:o.string().max(32768).optional(),approved:o.boolean().optional(),questionIndex:o.number().int().min(0).optional(),askId:k.optional(),answers:o.record(o.string(),o.array(o.string().max(32768))).optional(),decline:o.boolean().optional(),revise:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.seen"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("attention.seen"),items:o.array(o.object({sessionId:L,completionToken:o.string().uuid()}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("sessions.notified"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("tags.list")}).strict(),o.object({op:o.literal("tags.replace"),tags:o.array(o.object({id:o.string().optional(),name:o.string()}).strict())}).strict(),o.object({op:o.literal("sessions.tags"),expected_revision:o.string().optional(),sessionId:L,tags:o.array(o.string()),primary:o.string().nullable()}).strict(),o.object({op:o.literal("sessions.pin"),sessionId:L,pinned:o.boolean()}).strict(),o.object({op:o.literal("sessions.watch"),sessionId:L,subscriptionId:o.string().regex(da),visible:o.boolean(),canNotify:o.boolean()}).strict(),o.object({op:o.literal("sessions.warm"),sessionId:L}).strict(),o.object({op:o.literal("sessions.interrupt"),sessionId:L,requestId:te}).strict(),o.object({op:o.literal("supplements.cancel"),sessionId:L,job:Ds,anchor:Ns}).strict(),o.object({op:o.literal("supplements.restart"),sessionId:L,job:Ds,anchor:Ns}).strict(),o.object({op:o.literal("supplements.steer"),sessionId:L,job:Ds,anchor:Ns,text:o.string().min(1).max(500)}).strict(),o.object({op:o.literal("sessions.variables.list"),sessionId:L}).strict(),o.object({op:o.literal("sessions.variables.create"),sessionId:L,key:Wr,value:Sa,type:wa}).strict(),o.object({op:o.literal("sessions.variables.update"),sessionId:L,key:Wr,value:Sa,type:wa}).strict(),o.object({op:o.literal("sessions.variables.delete"),sessionId:L,key:Wr}).strict(),o.object({op:o.literal("sessions.presence"),subscriptionId:o.string().regex(/^[a-f0-9]{1,64}$/),canNotify:o.boolean(),canNotifyKinds:o.array(o.enum(["complete","error"])).max(4),sessionId:o.string().regex(/^([a-f0-9]{12})?$/),window:o.object({exists:o.boolean(),focused:o.boolean(),visible:o.boolean(),minimized:o.boolean()}).strict()}).strict(),o.object({op:o.literal("legacy.models"),provider:o.string().max(128).optional(),sort:o.enum(["id","name","provider","recommended"]).optional(),direction:o.enum(["ascending","descending"]).optional()}).strict(),o.object({op:o.literal("legacy.models.providers")}).strict(),o.object({op:o.literal("auth.probe"),provider:k}).strict(),o.object({op:o.literal("legacy.agent.upload"),agentId:k}).strict(),o.object({op:o.literal("agent.publish"),agentId:k,document:Aa.optional(),...Fs,visibility:o.literal("org").optional(),tenantId:k.optional()}).strict(),o.object({op:o.literal("agent.republish"),agentId:k,hubAgentId:k,expectedRemoteRevision:o.string().min(1).max(512).optional(),document:Aa.optional(),...Fs,visibility:o.literal("org").optional(),tenantId:k.optional()}).strict(),o.object({op:o.literal("team.publish"),teamId:k,...Fs,visibility:o.literal("org").optional(),tenantId:k.optional()}).strict(),o.object({op:o.literal("team.pull"),teamId:k,tenantId:k.optional()}).strict(),o.object({op:o.literal("agent.nameAvailability"),name:o.string().min(1).max(yi)}).strict(),o.object({op:o.literal("legacy.agents.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional(),name:o.string().max(256).optional(),sort:o.string().max(64).optional(),direction:o.enum(["asc","desc"]).optional()}).strict(),o.object({op:o.literal("legacy.agent.get"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.history"),agentId:k,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("legacy.jobs.list"),agentId:k.optional(),status:o.string().max(64).optional()}).strict(),o.object({op:o.literal("legacy.job.get"),jobId:k}).strict(),o.object({op:o.literal("legacy.schedules.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedules.list"),agentId:k,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedule.create"),agentId:k,schedule:Ea.extend({prompt:o.string().max(64e3),interval:o.number().int().min(1),unit:ba})}).strict(),o.object({op:o.literal("legacy.schedule.get"),scheduleId:k}).strict(),o.object({op:o.literal("legacy.schedule.edit"),scheduleId:k,schedule:Ea.extend({prompt:o.string().max(64e3).nullish(),interval:o.number().int().min(1).nullish(),unit:ba.nullish()})}).strict(),o.object({op:o.literal("legacy.schedule.remove"),scheduleId:k}).strict(),o.object({op:o.literal("legacy.agent.create"),agent:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.update"),agentId:k,update:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.delete"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.conversation.clear"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.get"),agentId:k}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.update"),agentId:k,systemPrompt:o.string().max(Sp)}).strict(),o.object({op:o.literal("legacy.agent.download"),agentId:k}).strict(),o.object({op:o.literal("legacy.job.cancel"),jobId:k}).strict(),o.object({op:o.literal("commands.list")}).strict(),o.object({op:o.literal("commands.entities"),sessionId:L,command:k,name:o.string().max(128).optional()}).strict(),o.object({op:o.literal("models.catalogue"),live:o.boolean().optional(),scope:o.enum(["usable","all"]).optional()}).strict(),o.object({op:o.literal("usage.get"),provider:k.optional(),live:o.boolean().optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("quota.notice"),provider:k.optional(),model:o.string().min(1).max(200).optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("analytics.get"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("analytics.models"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("info.get")}).strict(),o.object({op:o.literal("sessions.report"),sessionId:L,recentLimit:o.number().int().min(0).max(50).optional()}).strict(),o.object({op:o.literal("skills.list"),sessionId:L.optional(),cwd:mp.optional(),name:k.optional()}).strict(),o.object({op:o.literal("sessions.failovers"),sessionId:L}).strict(),o.object({op:o.literal("sessions.credential"),sessionId:L,action:o.enum(["list","store","forget"]),key:Ar.optional(),value:Or.optional(),confirmed:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.fork"),sessionId:L,requestId:te,message:o.string().max(2e5).optional(),boundary:o.enum(["next_safe","at_entry"]).optional(),entryId:o.string().max(128).optional(),autoTag:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.stop"),requestId:te,targets:o.array(L).min(1).max(100),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside"),sessionId:L,requestId:te,text:o.string().min(1).max(32768),asideId:te.optional(),subscriptionId:o.string().regex(da).optional()}).strict(),o.object({op:o.literal("sessions.adopt"),sessionId:L,requestId:te,asideId:te,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside.get"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("sessions.aside.close"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("wakes.list"),limit:o.number().int().min(1).max(500).optional(),includeDormant:o.boolean().optional()}).strict(),o.object({op:o.literal("wakes.create"),requestId:te,sessionId:L.optional(),cwd:o.string().min(1).max(4096).optional(),target:jr.optional(),message:ka,in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional(),title:o.string().min(1).max(200).optional()}).strict(),o.object({op:o.literal("wakes.edit"),sessionId:L,wakeId:Ra,message:ka.optional(),in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional()}).strict(),o.object({op:o.literal("wakes.remove"),sessionId:L,wakeId:Ra}).strict(),o.object({op:o.literal("monitors.cancel"),sessionId:L,monitorId:Tp}).strict(),o.object({op:o.literal("jobs.cancel"),sessionId:L,jobId:Cp}).strict(),o.object({op:o.literal("mcp.list"),sessionId:L}).strict(),o.object({op:o.literal("mcp.credentials.store"),sessionId:L,name:o.string().min(1).max(256),values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("mcp.control"),sessionId:L,control:o.object({action:o.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:Ls.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record(Pr).optional(),url:o.string().max(4096).optional(),headers:o.record(Pr).optional(),oauth:o.boolean().optional(),confirmed:o.boolean().optional(),operation_id:ca.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog"),cwd:$s.optional(),sessionId:L.optional()}).strict(),o.object({op:o.literal("mcp.catalog.control"),cwd:$s.optional(),control:o.object({action:o.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:Ls.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record(Pr).optional(),url:o.string().max(4096).optional(),headers:o.record(Pr).optional(),confirmed:o.boolean().optional(),operation_id:ca.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog.credentials"),header:o.string().min(1).max(128).optional(),cwd:$s.optional(),name:Ls,values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("radient.request"),control:o.object({operation:o.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list","org_skills.list","org_skill.get","signup.resend"]),request_id:te.optional(),tenant_id:k.optional(),account_id:k.optional(),agent_id:k.optional(),comment_id:k.optional(),team_id:k.optional(),skill_id:k.optional(),query:o.record(o.union([o.string().max(1024),o.number().int()])).optional(),payload:o.record(o.unknown()).optional(),confirmed:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("providers.list")}).strict(),o.object({op:o.literal("accounts.list")}).strict(),o.object({op:o.literal("accounts.remove"),accountId:o.number().int().positive(),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("tunnel.setup.read"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.plan"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.run"),credentialId:o.number().int().positive(),acceptMonthlyPrice:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("auth.start"),provider:k}).strict(),o.object({op:o.literal("auth.status"),id:k}).strict(),o.object({op:o.literal("auth.input"),id:k,promptId:k,value:Or}).strict(),o.object({op:o.literal("auth.cancel"),id:k}).strict(),o.object({op:o.literal("auth.key"),provider:k,value:Or}).strict(),o.object({op:o.literal("auth.logout"),provider:k}).strict(),o.object({op:o.literal("agent_messages.status"),boundary:oa}).strict(),o.object({op:o.literal("agent_messages.enable"),expected_account_id:k,tenant_id:k,state:o.literal("active"),consent_version:o.string().min(1).max(128),consented_via:o.literal("dialog")}).strict(),o.object({op:o.literal("agent_messages.settings"),tenant_id:k.optional()}).strict(),o.object({op:o.literal("agent_messages.settings.put"),expected_account_id:k,tenant_id:k.optional(),consent_version:o.string().min(1).max(128).optional(),consented_via:o.enum(["dialog","settings"]).optional(),label:o.string().min(1).max(128).optional(),state:o.enum(["active","paused","disabled"])}).strict(),o.object({op:o.literal("agent_messages.allowlist.get"),tenant_id:k.optional()}).strict(),o.object({op:o.literal("agent_messages.allowlist.put"),expected_account_id:k,tenant_id:k.optional(),entries:o.array(o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:o.object({endpoint_id:k.optional(),account_id:k.optional()}).strict().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id")}).strict()).max(200)}).strict(),o.object({op:o.literal("team_bridge.conversations.list"),scope:o.literal("account").optional(),tenant_id:k.optional(),limit:o.number().int().min(1).max(100).optional(),cursor:o.string().min(1).max(64).optional(),before:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.get"),conversation_id:k,tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.create"),tenant_id:k.optional(),kind:o.enum(["dm","group","channel"]),name:o.string().min(1).max(128).optional(),topic:o.string().min(1).max(512).optional(),visibility:o.enum(["private","tenant"]).optional(),agent_capable:o.boolean().optional(),members:o.array(o.object({account_id:k,kind:o.enum(["human","agent"]),endpoint_id:k.optional(),display_label:o.string().min(1).max(64)}).strict()).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.lifecycle"),conversation_id:k,action:o.enum(["archive","unarchive","join","leave"])}).strict(),o.object({op:o.literal("team_bridge.conversations.join"),conversation_id:k,tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.notify"),conversation_id:k,tenant_id:k.optional(),notify:o.enum(["all","mention","mute"])}).strict(),o.object({op:o.literal("team_bridge.conversations.members.add"),conversation_id:k,tenant_id:k.optional(),members:o.array(o.object({account_id:k,kind:o.enum(["human","agent"]),endpoint_id:k.optional(),display_label:o.string().min(1).max(64)}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.members.remove"),conversation_id:k,account_id:k}).strict(),o.object({op:o.literal("team_bridge.conversations.consent"),conversation_id:k,account_id:k,decision:o.enum(["accept","decline"]),consent_version:o.string().min(1).max(128),tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.messages.list"),conversation_id:k,tenant_id:k.optional(),limit:o.number().int().min(1).max(100).optional(),before_seq:o.number().int().nonnegative().optional(),endpoint_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.reactions.toggle"),conversation_id:k,message_id:k,tenant_id:k.optional(),emoji:o.string().min(1),active:o.boolean()}).strict(),o.object({op:o.literal("team_bridge.messages.send"),conversation_id:k,tenant_id:k.optional(),client_ref:k,body:o.string().min(1),agent_label:o.string().min(1).max(64).optional(),thread_root_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.messages.replies"),conversation_id:k,message_id:k,tenant_id:k.optional(),limit:o.number().int().min(1).max(100).optional(),after_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.read"),conversation_id:k,tenant_id:k.optional(),seq:o.number().int().nonnegative().optional(),muted:o.boolean().optional()}).strict(),o.object({op:o.literal("team_bridge.unread"),scope:o.literal("account").optional(),tenant_id:k.optional()}).strict(),o.object({op:o.literal("team_bridge.directory"),tenant_id:k}).strict(),o.object({op:o.literal("team_bridge.status"),boundary:oa.optional()}).strict(),o.object({op:o.literal("settings.list")}).strict(),o.object({op:o.literal("settings.edit"),key:Ar,value:o.unknown().refine(e=>e!==void 0,"A setting value is required."),base:Ep.optional()}).strict(),o.object({op:o.literal("settings.reset"),key:Ar}).strict(),o.object({op:o.literal("tts.paths")}).strict(),o.object({op:o.literal("config.get")}).strict(),o.object({op:o.literal("config.update"),value:Ap}).strict(),o.object({op:o.literal("instructions.get")}).strict(),o.object({op:o.literal("instructions.update"),content:o.string().max(64e3)}).strict(),o.object({op:o.literal("credentials.list")}).strict(),o.object({op:o.literal("credentials.update"),key:Ar,value:Or}).strict(),o.object({op:o.literal("peers.list")}).strict(),o.object({op:o.literal("networks.list")}).strict(),o.object({op:o.literal("networks.invite"),networkId:cn,role:o.enum(["read","drive","admin"]),deviceId:cn.optional()}).strict(),o.object({op:o.literal("networks.member.remove"),networkId:cn,deviceId:cn,confirm:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("sessions.transfer"),sessionId:L,to:o.union([o.literal("local"),cn]),keep:o.boolean().optional(),waitS:o.number().min(0).max(300).optional(),requestId:te.optional()}).strict(),o.object({op:o.literal("approvals.list")}).strict(),o.object({op:o.literal("approvals.approve"),approvalId:fa}).strict(),o.object({op:o.literal("approvals.deny"),approvalId:fa}).strict(),o.object({op:o.literal("asks.list")}).strict(),o.object({op:o.literal("projects.list")}).strict(),o.object({op:o.literal("projects.get"),key:Tt}).strict(),o.object({op:o.literal("projects.create"),name:Bs,description:o.string().max(ja).optional(),status:Oa.optional(),tags:Pa.optional()}).strict(),o.object({op:o.literal("projects.update"),key:Tt,fields:o.object({name:Bs.optional(),title:o.string().max(80).optional(),owner:o.string().max(80).optional(),team:o.string().max(80).optional(),description:o.string().max(ja).optional(),status:Oa.optional(),progress:o.string().max(Yp).optional(),tags:Pa.optional(),start_date:Dr.optional(),target_date:Dr.optional(),completed_at:Dr.optional(),estimate:o.number().positive().max(1e3).optional(),estimate_unit:o.enum(["points","days"]).optional()}).strict(),force_done:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.delete"),key:Tt,confirmed_name:Bs}).strict(),o.object({op:o.literal("projects.link"),key:Tt,sessionId:L}).strict(),o.object({op:o.literal("projects.unlink"),key:Tt,sessionId:L}).strict(),o.object({op:o.literal("projects.milestone"),key:Tt,name:o.string().min(1).max(Ma),targetDate:Dr.optional(),completed:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.milestone.remove"),key:Tt,name:o.string().min(1).max(Ma)}).strict(),o.object({op:o.literal("projects.request_update"),key:Tt}).strict(),o.object({op:o.literal("projects.search"),q:o.string().min(1).max(Qp),limit:o.number().int().min(1).max(Xp).optional()}).strict(),o.object({op:o.literal("aida.status")}).strict(),o.object({op:o.literal("aida.control"),action:o.enum(["open","pause","resume","greet","status"])}).strict(),o.object({op:o.literal("code_requests.list"),sessionId:L}).strict(),o.object({op:o.literal("code_requests.refresh"),sessionId:L,keys:o.array(o.string().min(1).max(512)).max(256).optional(),force:o.boolean().optional()}).strict(),o.object({op:o.literal("static.sign"),route:o.enum(["images","videos","audio","html"]),path:o.string().min(1),ttlS:o.number().int().min(1).max(3600).optional()}).strict(),o.object({op:o.literal("library.list"),scope:o.enum(["final","all"]).optional(),q:o.string().max(512).optional(),category:o.string().min(1).max(64).optional(),kind:o.string().min(1).max(64).optional(),origin_group:o.enum(["generated","created","mentioned"]).optional(),origin:o.string().min(1).max(64).optional(),tag:o.string().min(1).max(128).optional(),tag_mode:o.enum(["all","any"]).optional(),highlighted:o.boolean().optional(),organized:o.boolean().optional(),favorite:o.boolean().optional(),session:o.string().min(1).max(12).optional(),session_id:o.string().min(1).max(512).optional(),sort:o.enum(["recent","name","kind","size","created","modified","organized"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(512).optional()}).strict(),o.object({op:o.literal("library.get"),id:Mn}).strict(),o.object({op:o.literal("library.update"),id:Mn,fields:o.object({name:o.string().max(200).optional(),description:o.string().max(2e3).optional(),favorite:o.boolean().optional(),locked:o.boolean().optional(),archived:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("library.tags")}).strict(),o.object({op:o.literal("library.tags.create"),name:o.string().trim().min(1).max(24),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.update"),id:Dn,name:o.string().trim().min(1).max(24).optional(),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.delete"),id:Dn}).strict(),o.object({op:o.literal("library.tags.merge"),id:Dn,into:Dn}).strict(),o.object({op:o.literal("library.tags.assign"),id:Mn,tags:o.array(Dn).max(64),primary:o.string().max(128).optional()}).strict(),o.object({op:o.literal("library.chat.link"),id:Mn,sessionId:L}).strict(),o.object({op:o.literal("library.chat.clear"),id:Mn}).strict(),o.object({op:o.literal("library.librarian"),action:o.enum(["status","open","pause","resume","run"]).optional()}).strict(),o.object({op:o.literal("sidebar_layout.get")}).strict(),o.object({op:o.literal("sidebar_layout.set"),layout:eh}).strict()]);th.superRefine((e,t)=>{if(e.op==="hub.skillPull"||e.op==="hub.skillSubscribe"||e.op==="hub.skillPublish"){if(e.visibility==="public"&&e.tenantId!==null||e.visibility==="org"&&!e.tenantId){t.addIssue({code:o.ZodIssueCode.custom,message:"A skill destination requires explicit paired scope",path:["tenantId"]});return}if(e.op==="hub.skillPublish"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"An initial skill publication requires its reviewed draft receipt",path:["previewReceipt"]});return}}if(e.op==="hub.check"||e.op==="hub.apply"||e.op==="hub.retry"){const n=e.linkId!==void 0,r=e.kind!==void 0||e.name!==void 0;if(n&&r||e.op!=="hub.check"&&!n&&(!e.kind||!e.name)||e.op==="hub.retry"&&n&&!e.direction||e.direction==="push"&&!n){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub action requires one unambiguous selector and an explicit retry direction",path:["linkId"]});return}}if(e.op==="hub.apply"&&(e.previewReceipt!==void 0||e.confirmApply!==void 0)&&(!e.linkId||e.dryRun||!e.previewReceipt||e.confirmApply!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"A viewed incoming application requires its scoped preview receipt and confirmation",path:["previewReceipt"]});return}if(e.op==="hub.apply"&&e.resolveSource===!0){const n=e.visibility==="public"&&e.tenantId===null||e.visibility==="org"&&typeof e.tenantId=="string"&&e.tenantId.length>0;if(!e.hubSource||!n||e.acknowledgeUnknownBaseline!==!0||e.linkId!==void 0||e.previewReceipt!==void 0||e.confirmApply!==void 0||e.prefer!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"Confirming a source requires its exact stated destination and the unknown-baseline acknowledgement, with no link, preview or preference",path:["hubSource"]});return}}if(e.op==="hub.push"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"A confirmed publication requires its reviewed preview receipt",path:["previewReceipt"]});return}if(e.op==="hub.policy"&&e.subscribe===void 0&&e.autoPush===void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub policy change must name subscribe or autoPush",path:["subscribe"]});return}if((e.op==="team_bridge.conversations.list"||e.op==="team_bridge.unread")&&e.scope==="account"&&e.tenant_id!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped read cannot name a tenant",path:["scope"]});return}if(e.op==="team_bridge.conversations.list"&&e.scope==="account"&&e.before!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped page uses cursor, not before",path:["before"]});return}if(e.op==="sessions.answer"){if(e.askId!==void 0){e.askId||t.addIssue({code:o.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.decline!==!0&&!e.answers?t.addIssue({code:o.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:o.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:o.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:o.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:o.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}if(!(e.op!=="agent.publish"&&e.op!=="agent.republish"&&e.op!=="team.publish")){if((e.subscribe!==void 0||e.autoPush!==void 0||e.confirmPublicEgress!==void 0)&&!e.requestId){t.addIssue({code:o.ZodIssueCode.custom,message:"Initial link policy needs a durable publication request ID",path:["requestId"]});return}e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:o.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})}});const Je={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},nh={runtimeUnreachable:"runtime_unreachable"},ps="runtime_busy",yc="runtime_retiring";o.object({data:o.object({aside_id:o.string().optional(),status:o.union([o.enum(["adopted","queued"]),o.string()]).optional()}).passthrough()}).passthrough();const VS="aside_adopt_refused",rh=["session_closed","open_tool_batch","turn_running"];function KS(e){if(typeof e!="object"||e===null)return;const t=e.reason;return rh.find(n=>n===t)}const eo={[Je.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[Je.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[Je.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[Je.transportFailed]:"The Local Operator server did not answer this request."},_i={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function hs(e){return e!==void 0&&Object.values(Je).includes(e)}function sh(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return Je.refused;if(t===503)return Je.planeClosed}}const YS=o.object({step:o.string(),blocked_on:o.string(),configured:o.boolean(),ready:o.boolean(),verified:o.boolean(),url:o.string().nullable(),credential_id:o.number().int().positive().nullable(),identity_label:o.string().nullable(),credential_choices:o.array(o.object({id:o.number().int().positive(),identity_label:o.string().nullable().optional()}).passthrough()).default([]),quote:o.object({monthly_price_usd:o.string().nullable(),positive_balance:o.boolean(),eligible:o.boolean(),account_valid:o.boolean()}).passthrough().nullable(),receipts:o.array(o.object({step:o.string(),ok:o.boolean(),text:o.string()})).default([]),remedy:o.object({kind:o.string(),text:o.string(),command:o.string().nullable().optional(),url:o.string().nullable().optional()}).nullable(),source:o.string(),in_progress:o.boolean().default(!1),progress:o.array(o.string()).default([]),active_credential_id:o.number().int().positive().nullable().default(null),billing_outcome:o.string().optional(),reservation_outcome:o.string().optional(),failure_stage:o.string().optional()}).passthrough(),QS=new Set(["setup_in_progress","setup_deadline","setup_unavailable","setup_intent_corrupt"]),ih=88e4,oh=11e5,ah=2e4,lh=9e4,ch=new Set(["analytics.get","analytics.models","sessions.report"]),dh=new Set(["usage.get"]),uh=new Set(["networks.list","peers.list"]),fh=new Set([...ch,...dh,...uh]),ph=90,hh=30,mh=300,gh=10,vc=15,yh=1e4;function vh(e){const n=e.to==="local"||e.keep?mh:hh,r=Math.max(0,e.waitS??0);return(ph+n+gh+vc)*1e3+r*1e3}const _h=18e4,bh=_h+15e3,wh=120,Sh=135e3,kh=93e4,_c=(wh+30+vc)*1e3,Rh=6e4,Eh=5*_c,Ih=new Set(["hub.apply","hub.retry","hub.push","hub.skillPublish","hub.skillPull","hub.skillSubscribe","hub.skillUnpull","hub.check","hub.applyAll"]);function xh(e){switch(e){case"hub.apply":case"hub.retry":case"hub.push":case"hub.skillPublish":case"hub.skillPull":case"hub.skillSubscribe":case"hub.skillUnpull":return _c;case"hub.check":return Rh;case"hub.applyAll":return Eh;default:return null}}function Th(e){if(typeof e!="string"&&e.op==="sessions.transfer")return vh(e)+yh;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return bh;if(t==="tunnel.setup.run")return kh;if(t==="tunnel.setup.plan")return Sh;const n=xh(t);return n!==null?n:fh.has(t)?lh:ah}const Ch=5e3;function bc(e){return Th(e)+Ch}const to="deadline_exceeded",wc="foreground_required",Sc="View these completions in the foreground before marking them read.",Ah=new Set(["capabilities","agent_messages.status","agent_messages.settings","agent_messages.allowlist.get","team_bridge.conversations.list","team_bridge.conversations.get","team_bridge.messages.list","team_bridge.messages.replies","team_bridge.unread","team_bridge.directory","team_bridge.status","accounts.list","analytics.get","analytics.models","approvals.list","commands.entities","commands.list","config.get","credentials.list","hub.updates","hub.links","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","quota.notice","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.files","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","teams.effective","teams.get","teams.list","tunnel.setup.plan","tunnel.setup.read","usage.get"]),Oh=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function Ph(e,t){const n=Math.round(t/1e3),r=to;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:Ih.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:Ah.has(e)?{code:r,message:Oh.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const JS=ih,XS=oh;o.object({state:o.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:o.string(),kind:o.enum(["balance","subscription","radient","none"]),model_free:o.boolean(),title:o.string(),body:o.string(),actions:o.array(o.object({id:o.enum(["open_url","resend_verification","refresh"]),label:o.string(),url:o.string().nullable().optional()})),resets_at_ms:o.number().int().nullable().optional(),checked_at_ms:o.number().int(),age_ms:o.number().int().nullable().optional(),source:o.enum(["cached","live"])});function jh(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function Na(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function Gs(e){return{...e.requestId?{request_id:e.requestId}:{},...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}}function Hs(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function La(e){return{sources:e.sources??null,session_ids:e.sessionIds??{},all:e.all??!1,include_subagents:e.includeSubagents??!1,include_cleared_segments:e.includeClearedSegments??!1,include_memory:e.includeMemory??!0,include_instructions:e.includeInstructions??!0,...e.maxSessions===void 0?{}:{max_sessions:e.maxSessions}}}function Lr(e){return e===void 0?"":`?tenant_id=${encodeURIComponent(e)}`}function Mh(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"imports.sources":return{path:"/v1/desktop/imports/sources",method:"GET"};case"imports.sessions":{const t=new URLSearchParams({source:e.source});return e.includeSubagents&&t.set("include_subagents","true"),{path:`/v1/desktop/imports/sessions?${t.toString()}`,method:"GET"}}case"imports.preview":return{path:"/v1/desktop/imports/preview",method:"POST",body:La(e)};case"imports.start":return{path:"/v1/desktop/imports/jobs",method:"POST",body:La(e)};case"imports.status":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"GET"};case"imports.cancel":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"DELETE"};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.skillPull":return{path:"/v1/desktop/hub/skills/pull",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.skillSubscribe":return{path:"/v1/desktop/hub/skills/subscribe",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias}};case"hub.skillUnpull":return{path:"/v1/desktop/hub/skills/unpull",method:"POST",body:{request_id:e.requestId,link_id:e.linkId}};case"hub.skillPublish":return{path:"/v1/desktop/hub/skills/publish",method:"POST",body:{request_id:e.requestId,dry_run:e.dryRun,source_skill:e.sourceSkill,local_alias:e.localAlias,visibility:e.visibility,tenant_id:e.tenantId,subscribe:e.subscribe,auto_push:e.autoPush,confirm_public_egress:e.confirmPublicEgress,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"hub.links":return{path:`/v1/desktop/hub/links${e.kind?`?kind=${e.kind}`:""}`,method:"GET"};case"hub.policy":return{path:`/v1/desktop/hub/links/${encodeURIComponent(e.linkId)}`,method:"PATCH",body:{request_id:e.requestId,expected_policy_revision:e.expectedPolicyRevision,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.linkId?{link_id:e.linkId}:{},...e.direction?{direction:e.direction}:{},...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmApply?{confirm_apply:!0}:{},...e.linkId?{link_id:e.linkId}:{},...e.direction?{direction:e.direction}:{},...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.resolveSource===!0?{resolve_source:!0,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId??null}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,...e.linkId?{link_id:e.linkId}:{},...e.direction?{direction:e.direction}:{},...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{}}};case"hub.push":return{path:"/v1/desktop/hub/updates/push",method:"POST",body:{request_id:e.requestId,link_id:e.linkId,direction:e.direction,dry_run:e.dryRun,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.effective":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}/effective`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),e.sort&&t.set("sort",e.sort),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??vp)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),ts(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.files":{const t=new URLSearchParams({limit:String(e.limit??200)});for(const n of["scope","kind","q","sort","order","cursor"]){const r=e[n];r!==void 0&&t.set(n,r)}return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files?${t}`,method:"GET"}}case"sessions.files.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/materialise`,method:"POST"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1")),e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),e.sourceRead==="metadata"?t.set("source_read","metadata"):e.sourceRead==="payload"&&e.expectedJournalGeneration&&t.set("source_read","payload"),e.expectedJournalGeneration&&t.set("expected_journal_generation",e.expectedJournalGeneration),ts(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??bp)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"tags.list":return{path:"/v1/desktop/tags",method:"GET"};case"tags.replace":return{path:"/v1/desktop/tags",method:"PUT",body:{tags:e.tags}};case"sessions.tags":return{path:`/v1/desktop/sessions/${e.sessionId}/tags`,method:"PUT",body:{tags:e.tags,primary:e.primary,...e.expected_revision===void 0?{}:{expected_revision:e.expected_revision}}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{Hs(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{},...Gs(e)}}}case"agent.republish":{Hs(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{},...Gs(e),...e.expectedRemoteRevision?{expected_remote_revision:e.expectedRemoteRevision}:{}}}}case"team.publish":{Hs(e);const t=new URLSearchParams;return e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId)),{path:`/v1/teams/${e.teamId}/publish${t.size?`?${t}`:""}`,method:"POST",body:Gs(e)}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...jh(e),message:e.message,...Na(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...Na(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,method:"GET"}}case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId,auto_tag:e.autoTag}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"tunnel.setup.read":return{path:e.credentialId===void 0?"/v1/desktop/tunnel/setup":`/v1/desktop/tunnel/setup?credential_id=${e.credentialId}`,method:"GET"};case"tunnel.setup.plan":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"plan",...e.credentialId!==void 0?{credential_id:e.credentialId}:{}}};case"tunnel.setup.run":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"run",credential_id:e.credentialId,...e.acceptMonthlyPrice!==void 0?{accept_monthly_price:e.acceptMonthlyPrice}:{}}};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"agent_messages.status":return{path:`/v1/desktop/team-bridge/status?boundary=${e.boundary}`,method:"GET"};case"agent_messages.enable":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,state:e.state,consent_version:e.consent_version,consented_via:e.consented_via}};case"agent_messages.settings":return{path:`/v1/desktop/team-bridge/settings${Lr(e.tenant_id)}`,method:"GET"};case"agent_messages.settings.put":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},...e.consent_version===void 0?{}:{consent_version:e.consent_version},...e.consented_via===void 0?{}:{consented_via:e.consented_via},...e.label===void 0?{}:{label:e.label},state:e.state}};case"agent_messages.allowlist.get":return{path:`/v1/desktop/team-bridge/allowlist${Lr(e.tenant_id)}`,method:"GET"};case"agent_messages.allowlist.put":return{path:"/v1/desktop/team-bridge/allowlist",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},entries:e.entries}};case"team_bridge.conversations.list":{const t=new URLSearchParams;return e.scope==="account"&&t.set("scope","account"),e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor),e.before&&t.set("before",e.before),{path:`/v1/desktop/team-bridge/conversations${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.conversations.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${Lr(e.tenant_id)}`,method:"GET"};case"team_bridge.conversations.create":return{path:"/v1/desktop/team-bridge/conversations",method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},kind:e.kind,...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agent_capable===void 0?{}:{agent_capable:e.agent_capable},members:e.members}};case"team_bridge.conversations.lifecycle":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/${e.action}`,method:"POST"};case"team_bridge.conversations.join":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/join`,method:"POST",...e.tenant_id?{body:{tenant_id:e.tenant_id}}:{}};case"team_bridge.conversations.notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.members.add":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members${n}`,method:"POST",body:e.members}}case"team_bridge.conversations.members.remove":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}`,method:"DELETE"};case"team_bridge.conversations.consent":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}/consent`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},decision:e.decision,consent_version:e.consent_version}};case"team_bridge.messages.list":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.endpoint_id&&t.set("endpoint_id",e.endpoint_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages${n}`,method:"GET"}}case"team_bridge.reactions.toggle":{const t=`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/reactions/${encodeURIComponent(e.emoji)}`;return e.active?{path:t,method:"PUT",body:e.tenant_id?{tenant_id:e.tenant_id}:{}}:{path:`${t}${Lr(e.tenant_id)}`,method:"DELETE"}}case"team_bridge.messages.send":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},client_ref:e.client_ref,body:e.body,...e.agent_label?{agent_label:e.agent_label}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.messages.replies":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq));const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/replies${n}`,method:"GET"}}case"team_bridge.read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.seq===void 0?{}:{seq:e.seq},...e.muted===void 0?{}:{muted:e.muted}}};case"team_bridge.unread":{const t=new URLSearchParams;return e.scope==="account"?t.set("scope","account"):e.tenant_id&&t.set("tenant_id",e.tenant_id),{path:`/v1/desktop/team-bridge/unread${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.directory":return{path:`/v1/desktop/team-bridge/directory?tenant_id=${encodeURIComponent(e.tenant_id)}`,method:"GET"};case"team_bridge.status":{const t=new URLSearchParams;return e.boundary&&t.set("boundary",e.boundary),{path:`/v1/desktop/team-bridge/status${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"library.list":{const t=new URLSearchParams;e.scope&&t.set("scope",e.scope),e.q&&t.set("q",e.q),e.category&&t.set("category",e.category),e.kind&&t.set("kind",e.kind),e.origin_group&&t.set("origin_group",e.origin_group),e.origin&&t.set("origin",e.origin),e.tag&&t.set("tag",e.tag),e.tag_mode&&t.set("tag_mode",e.tag_mode),e.highlighted!==void 0&&t.set("highlighted",e.highlighted?"1":"0"),e.organized!==void 0&&t.set("organized",e.organized?"1":"0"),e.favorite!==void 0&&t.set("favorite",e.favorite?"1":"0"),e.session&&t.set("session",e.session),e.session_id&&t.set("session_id",e.session_id),e.sort&&t.set("sort",e.sort),e.order&&t.set("order",e.order),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor);const n=t.toString();return{path:`/v1/desktop/library/assets${n?`?${n}`:""}`,method:"GET"}}case"library.get":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"GET"};case"library.update":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"PATCH",body:e.fields};case"library.tags":return{path:"/v1/desktop/library/tags",method:"GET"};case"library.tags.create":return{path:"/v1/desktop/library/tags",method:"POST",body:{name:e.name,...e.category!==void 0?{category:e.category}:{}}};case"library.tags.update":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"PATCH",body:{...e.name!==void 0?{name:e.name}:{},...e.category!==void 0?{category:e.category}:{}}};case"library.tags.delete":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"DELETE"};case"library.tags.merge":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}/merge`,method:"POST",body:{into:e.into}};case"library.tags.assign":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/tags`,method:"PUT",body:{tags:e.tags,...e.primary!==void 0?{primary:e.primary}:{}}};case"library.chat.link":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"PUT",body:{session_id:e.sessionId}};case"library.chat.clear":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"DELETE"};case"library.librarian":{const t=e.action??"status";return t==="status"?{path:"/v1/desktop/librarian",method:"GET"}:{path:"/v1/desktop/librarian",method:"POST",body:{op:t}}}case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields,...e.force_done===!0?{force_done:!0}:{}}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??Jp)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}};case"sidebar_layout.get":return{path:"/v1/desktop/sidebar-layout",method:"GET"};case"sidebar_layout.set":return{path:"/v1/desktop/sidebar-layout",method:"PUT",body:{layout:e.layout}}}}const qS=64,ek=64*1024*1024,tk="superseded_completion_token",nk="store_busy",Dh="session_is_remote",Nh="owner_build_behind";function rk(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function mn(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function Lh(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const sk=e=>typeof e?.goal_status=="string",ik=e=>(e?.goal??"").trim().length>0;function $h(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const Zn={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},$a={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},Uh={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},Fh={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},Bh={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},Gh={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function Ua(e){return e?e===Zn.notPaired?Fh:e===Zn.serverDown?Uh:e===Zn.frameBudget?Gh:$a:$a}const Fa=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const p=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(h=>h(t,p))}},s=()=>t,l={setState:r,getState:s,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,s,l);return l},Hh=e=>e?Fa(e):Fa,Wh=e=>e;function zh(e,t=Wh){const n=na.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return na.useDebugValue(n),n}const Ba=e=>{const t=Hh(e),n=r=>zh(t,r);return Object.assign(n,t),n},_r=e=>e?Ba(e):Ba;function kc(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const a=c=>c===null?null:JSON.parse(c,void 0),l=(i=n.getItem(s))!=null?i:null;return l instanceof Promise?l.then(a):a(l)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const bi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return bi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return bi(r)(n)}}}},Zh=(e,t)=>(n,r,s)=>{let i={storage:kc(()=>localStorage),partialize:m=>m,version:0,merge:(m,y)=>({...y,...m}),...t},a=!1;const l=new Set,c=new Set;let d=i.storage;if(!d)return e((...m)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...m)},r,s);const u=()=>{const m=i.partialize({...r()});return d.setItem(i.name,{state:m,version:i.version})},f=s.setState;s.setState=(m,y)=>{f(m,y),u()};const p=e((...m)=>{n(...m),u()},r,s);s.getInitialState=()=>p;let h;const g=()=>{var m,y;if(!d)return;a=!1,l.forEach(v=>{var I;return v((I=r())!=null?I:p)});const _=((y=i.onRehydrateStorage)==null?void 0:y.call(i,(m=r())!=null?m:p))||void 0;return bi(d.getItem.bind(d))(i.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==i.version){if(i.migrate){const I=i.migrate(v.state,v.version);return I instanceof Promise?I.then(C=>[!0,C]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var I;const[C,J]=v;if(h=i.merge(J,(I=r())!=null?I:p),n(h,!0),C)return u()}).then(()=>{_?.(h,void 0),h=r(),a=!0,c.forEach(v=>v(h))}).catch(v=>{_?.(void 0,v)})};return s.persist={setOptions:m=>{i={...i,...m},m.storage&&(d=m.storage)},clearStorage:()=>{d?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>a,onHydrate:m=>(l.add(m),()=>{l.delete(m)}),onFinishHydration:m=>(c.add(m),()=>{c.delete(m)})},i.skipHydration||g(),h||p},ms=Zh,Vh=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function Kh(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,s)=>typeof r=="number"&&Number.isFinite(r)?r:s;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const Rc=_r()(ms(e=>({notice:null,receive:t=>e(n=>Vh(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:kc(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));async function Ec(e){if(window.api?.desktop)try{return await Yh(window.api.desktop.request(e),e)}catch(n){throw n instanceof ye?n:tm(n)?new $t(Sc,wc):new ye(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new ye(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new ye(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function Yh(e,t){const n=bc(t);let r;return Promise.race([e,new Promise((s,i)=>{r=setTimeout(()=>{const a=Ph(t.op,n);i(new ye(null,a.message,void 0,a.code))},n)})]).finally(()=>clearTimeout(r))}const Qh="This server did not answer the request for its desktop controls.";class ye extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,s,i,a){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=s,this.retryAfterMs=i,this.detail=a}}class $t extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function no(e,t){return e instanceof ye||e instanceof $t?hs(e.code)?eo[e.code]:e.message:t}function Jh(e,t,n,r){return typeof r=="string"?r:n===_i.noCredential?Je.noCredential:n===_i.transportFailed?Je.transportFailed:sh(Mh(e).path,t)}async function xe(e){const t=await Ec(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new ye(t.status,r??Qh,void 0,Jh(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&Xh(n?.result),n?.result}function Xh(e){if(typeof e!="object"||e===null)return;const t=Kh(e.delegated_cleanup_notice);t&&Rc.getState().receive(t)}async function qh(){try{await xe({op:"delegated_cleanup_notice.ack"})}catch{}}async function ok(){Rc.getState().dismiss(),await qh()}function em(e){return e instanceof ye&&e.code===to}function ak(e){if(!(e instanceof ye))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===Nh:e.code===Dh}function lk(e){return e instanceof $t&&e.code===wc}function tm(e){return e instanceof Error&&e.message.includes(Sc)}async function ck(e){const t=await Ec(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function dk(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await xe({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function nm(e,t){const n=window.api?.desktop?.stream;if(n){const i=n.subscribe(e,t);return()=>i.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),ts(r,"/__desktop/stream",e.orderIds??[]));const s=new EventSource(`/__desktop/stream?${r}`);return s.onmessage=i=>{t({kind:"data",data:i.data})},s.onerror=()=>{s.readyState===EventSource.CLOSED&&(t({kind:"error",detail:Zn.ended}),s.close())},()=>{s.close(),t({kind:"end"})}}async function uk(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),s=r.headers.get("content-type")??"";if(!r.ok){let i="The media request failed.",a;if(s.includes("application/json"))try{const c=(await r.json())?.detail;if(typeof c=="string")i=c;else if(typeof c=="object"&&c!==null){const d=c;typeof d.text=="string"&&d.text.trim()?i=d.text:typeof d.message=="string"&&d.message.trim()&&(i=d.message),typeof d.code=="string"&&(a=d.code)}}catch{}return{status:r.status,kind:"error",detail:i,code:a!==void 0&&hs(a)?a:i===_i.noCredential?Je.noCredential:void 0}}return s.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:s||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function fk(e){return e.kind==="error"?hs(e.code)?new $t(eo[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const Nn=e=>{const t=e.id;return typeof t=="string"?t:typeof t=="number"?String(t):null};function rm(e,t){const n=new Set((t.removed??[]).map(String)),r=e.filter(a=>{const l=Nn(a);return l===null||!n.has(l)});for(const a of t.upserted??[]){const l=Nn(a);if(l===null){r.push(a);continue}const c=r.findIndex(d=>Nn(d)===l);c===-1?r.push(a):r[c]=a}if(!t.order)return r;const s=new Map;for(const a of r){const l=Nn(a);l!==null&&s.set(l,a)}const i=[];for(const a of t.order){const l=String(a),c=s.get(l);c&&(i.push(c),s.delete(l))}for(const a of r){const l=Nn(a);l!==null&&s.has(l)?(i.push(a),s.delete(l)):l===null&&i.push(a)}return i}const wi=e=>({revision:Ke(e),demand:e.orderDemand}),Kt=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Rn(e,t,n,r,s,i={}){let a=e;const l=t.journal_generation;if(t.reconcile===!0){const p=typeof l=="string"&&l.length>0?l:void 0;return a.orderNeedsReconcile&&a.orderWantedGeneration===p?a.journalMode?a:{...a,journalMode:!0}:{...a,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:p,orderDemand:p!==void 0?{generation:p}:{}}}if(typeof l!="string"||l.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&s&&a.orderNeedsReconcile&&a.orderDemand===s.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),l!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===l?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:l,orderDemand:{generation:l}};let c=a.journalMode?a:{...a,journalMode:!0};if(l!==a.journalGeneration&&(c={...a,journalMode:!0,journalGeneration:l,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand},i.peer===!0)){const p=(a.orderRevision??0)+1,h=new Map;for(const g of a.records){const m=g.sourceEntryId??(g.kind==="tool"||g.kind==="supplement"?null:g.id);typeof m=="string"&&m.length>0&&m.length<=128&&h.set(m,p)}c={...c,...h.size>0?{journalBodyOwed:h}:{},journalSourceVoid:void 0}}let d=c.journalPositions??new Map;const u=d,f=(p,h,g)=>{if(!Kt(g))return;const m=d.get(p);m&&m.seq>=g||(d===u&&(d=new Map(d)),d.set(p,{entryId:h,seq:g}))};for(const[p,h]of Object.entries(t.journal_ordinals??{}))f(p,p,h);for(const p of n)typeof p.id=="string"&&(f(p.id,p.id,p.journal_seq),p.role==="tool"&&typeof p.tool_call_id=="string"&&f(`tool:${p.tool_call_id}`,p.id,p.journal_seq),typeof p.anchor=="string"&&f(`supplement:${p.anchor}`,p.id,p.journal_seq));return d!==u&&(c={...c,journalPositions:d}),c}function ro(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const s=n,i=r;return t.tool_calls.forEach((a,l)=>{!a||typeof a.id!="string"||(n.get(a.id)!==t.id&&(n===s&&(n=new Map(n)),n.set(a.id,t.id)),r.get(a.id)!==l&&(r===i&&(r=new Map(r)),r.set(a.id,l)))}),n===s&&r===i?e:{...e,journalCallOwners:n,journalCallSlots:r}}function Ic(e,t){const n=new Set(e.map(i=>i.id));let r=!1,s;for(let i=0;i<e.length;i++){const a=e[i];if(a.kind==="user"&&a.provisional===!0){s=a;continue}!t(a)&&s&&(a.sourceAdmissionAnchor===void 0||!n.has(a.sourceAdmissionAnchor))&&(e[i]={...a,sourceAdmissionAnchor:s.id},r=!0),s=e[i]}return r}function xc(e,t,n,r,s){const i=[],a=new Set;let l=e,c;for(;l!==void 0;){if(s.has(l.id)){c=s.get(l.id);break}if(n(l)){c=r(l);break}if(l.kind==="user"&&l.provisional===!0||a.has(l.id))break;a.add(l.id),i.push(l.id),l=l.sourceAdmissionAnchor?t.get(l.sourceAdmissionAnchor):void 0}for(const d of i)s.set(d,c);return c}function Tc(e,t){const n=new Map;return r=>{if(!r)return;const s=t(r);if(s===void 0)return;const i=[],a=new Set;let l=r,c=!0;for(;l;){if(n.has(l.id)){c=n.get(l.id)===!0;break}if(a.has(l.id)||t(l)===void 0){c=!1;break}a.add(l.id),i.push(l.id),l=l.sourceAdmissionAnchor===void 0?void 0:e.get(l.sourceAdmissionAnchor)}for(const d of i)n.set(d,c);return c?s:void 0}}function ns(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const s=new Map;t.forEach((a,l)=>{if(a.kind!=="tool")return;const c=n.get(a.toolCallId);if(c===void 0||!r.has(a.toolCallId))return;const d=s.get(c);d?d.push(l):s.set(c,[l])});let i=t;for(const a of s.values()){if(a.length<2)continue;const l=a.map(c=>t[c]).sort((c,d)=>(r.get(c.toolCallId)??0)-(r.get(d.toolCallId)??0));l.every((c,d)=>c===t[a[d]])||(i===t&&(i=t.slice()),a.forEach((c,d)=>{i[c]=l[d]}))}return i}function Cc(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return sm(e,t);const n=e.journalGeneration,r=e.journalPositions;let s=!1;const i=t.map(h=>{let m=[r?.get(h.sourceEntryId??h.id),r?.get(h.id)].filter(v=>v!==void 0).sort((v,I)=>I.seq-v.seq)[0];if(h.journalGeneration===n&&Kt(h.journalSeq)&&(!m||h.journalSeq>m.seq)&&(m={entryId:h.sourceEntryId??h.id,seq:h.journalSeq}),!m||!n||!(h.kind==="user"&&(h.provisional===!0||h.local===!0))&&h.sourceEntryId===m.entryId&&h.journalSeq===m.seq&&h.journalGeneration===n)return h;s=!0;let _={...h,sourceEntryId:m.entryId,journalSeq:m.seq,journalGeneration:n};if(_.kind==="user"){const{provisional:v,local:I,...C}=_;_=C}return _});Ic(i,h=>h.journalGeneration===n&&Kt(h.journalSeq))&&(s=!0);const l=new Map,c=new Map(i.map(h=>[h.id,h])),d=Tc(c,h=>h!==void 0&&h.journalGeneration===n&&Kt(h.journalSeq)?h.journalSeq:void 0),u=h=>d(h)!==void 0,f=(h,g)=>{const m=d(h);if(h.kind==="user"&&h.provisional===!0&&m===void 0)return[1,0,0,0,g];const y=h.kind==="supplement"?h.anchor:h.kind==="tool"?e.journalCallOwners?.get(h.toolCallId)??e.argsByCall.get(h.toolCallId)?.anchorId:void 0,_=typeof y=="string"?d(c.get(y)):void 0,v=m===void 0?xc(h,c,u,d,l):void 0,I=_??m??v;return I===void 0?[1,0,0,0,g]:[0,I,_!==void 0?1:m!==void 0?0:2,m??Number.MAX_SAFE_INTEGER,g]},p=i.map((h,g)=>({record:h,index:g,rank:f(h,g)}));return p.sort((h,g)=>{for(let m=0;m<h.rank.length;m++){const y=h.rank[m]-g.rank[m];if(y)return y}return 0}),!s&&p.every((h,g)=>h.index===g)?ns(e,t):ns(e,p.map(h=>h.record))}function sm(e,t){const n=e.journalGeneration,r=e.journalPositions,s=new Map;for(const m of t){let _=[r?.get(m.sourceEntryId??m.id),r?.get(m.id)].filter(v=>v!==void 0).sort((v,I)=>I.seq-v.seq)[0];m.journalGeneration===n&&Kt(m.journalSeq)&&(!_||m.journalSeq>_.seq)&&(_={entryId:m.sourceEntryId??m.id,seq:m.journalSeq}),_&&s.set(m.id,_)}const i=m=>m===void 0?void 0:s.get(m.id)??r?.get(m.sourceEntryId??m.id)??r?.get(m.id);let a=!1;const l=t.slice();Ic(l,m=>m.journalGeneration===n&&Kt(m.journalSeq))&&(a=!0);const d=new Map,u=new Map(l.map(m=>[m.id,m])),f=Tc(u,m=>i(m)?.seq),p=m=>f(m)!==void 0,h=(m,y)=>{const _=f(m);if(m.kind==="user"&&m.provisional===!0&&_===void 0)return[1,0,0,0,y];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,I=typeof v=="string"?f(u.get(v)):void 0,C=_===void 0?xc(m,u,p,f,d):void 0,J=I??_??C;return J===void 0?[1,0,0,0,y]:[0,J,I!==void 0?1:_!==void 0?0:2,_??Number.MAX_SAFE_INTEGER,y]},g=l.map((m,y)=>({record:m,index:y,rank:h(m,y)}));return g.sort((m,y)=>{for(let _=0;_<m.rank.length;_++){const v=m.rank[_]-y.rank[_];if(v)return v}return 0}),!a&&g.every((m,y)=>m.index===y)?ns(e,t):ns(e,g.map(m=>m.record))}function ut(e){const t=e.records.filter(s=>s.kind==="user"&&s.provisional===!0),n=e.records.filter(s=>s.journalGeneration!==e.journalGeneration||!Kt(s.journalSeq)),r=[...t,...n].map(s=>s.sourceEntryId??(s.kind==="tool"||s.kind==="supplement"?null:s.id));if(r.push(...so(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let s=r.length-1;s>=0;s--){const i=r[s];typeof i=="string"&&e.journalSourceVoid.has(i)&&r.splice(s,1)}return[...new Set(r.filter(s=>typeof s=="string"&&s.length>0&&s.length<=128))]}function so(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const s=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof s=="string"&&s.length>0&&s.length<=128&&t.add(s)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Ac(e,t){const n=e.journalPositions;return ut(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Ke=e=>e.orderRevision??0;async function im(e){const t=new Map,n=l=>{let c=t.get(l);return c||(c=new Set,t.set(l,c)),c},r=(l,c)=>c==="payload"?so(l):c==="lookup"?Ac(l):ut(l);let s=e.getTranscript().journalGeneration,i=0,a=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const l=e.getTranscript(),c=wi(l),d=c.revision,u=e.sweep?.(l,n);if(u?.kind==="none")return{kind:"complete",transcript:l};const f=u?.kind??"authority",p=pp(r(l,f).filter(y=>!n(f).has(y)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),h=await e.read(p,f);if(!e.isCurrent()||Ke(e.getTranscript())!==d)return{kind:"stale"};if(e.commit(h,d,c),!e.isCurrent())return{kind:"stale"};const g=e.getTranscript(),m=e.page(h);if(m.journal_order_state==="ready"&&m.journal_generation===g.journalGeneration){m.journal_generation!==s&&(t.clear(),s=m.journal_generation);for(const v of p)n(f).add(v);if(g.orderNeedsReconcile){if(g.orderDemand===c.demand||i===1)return{kind:"waiting"};i++,t.clear();continue}if(f==="payload"){const v=(m.source_retry_ids??[]).filter(I=>typeof I=="string"&&I.length>0&&I.length<=128);if(v.length>0&&p.length>1&&a===0){a++;for(const I of v)n("payload").delete(I);continue}}const y=e.sweep?.(g,n);if(y?.kind==="none")return{kind:"complete",transcript:g};const _=y?.kind??"authority";if(r(g,_).some(v=>!n(_).has(v)))continue;return{kind:"complete",transcript:g}}if(!g.orderNeedsReconcile||g.orderDemand===c.demand||i===1)return{kind:"waiting"};i++,t.clear()}}function rt(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const s=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof s=="string"&&s?s:e.id}function Ws(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function Ga(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function pk(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const i of t){if(!i.settled||typeof i.run_key!="string"||i.run_key.length===0)continue;const a=Ws(i.action_count);if(a===null)continue;const l={actions:a,workedSeconds:Ga(i.worked_seconds),failed:Ws(i.failed_count)??0,complete:i.complete!==!1,openingUserId:typeof i.opening_user_id=="string"&&i.opening_user_id.length>0?i.opening_user_id:null,closingAnswerId:typeof i.closing_answer_id=="string"&&i.closing_answer_id.length>0?i.closing_answer_id:null,crossSessionActions:Ws(i.cross_session_action_count),crossSessionWorkedSeconds:Ga(i.cross_session_worked_seconds)};n.set(i.run_key,l),l.openingUserId!==null&&n.set(l.openingUserId,l),l.closingAnswerId!==null&&n.set(l.closingAnswerId,l)}if(n.size===0)return null;const r=new Set;for(const i of e.entries)r.add(rt(i));const s=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:s?rt(s):null}}}function om(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(i=>i.opening_user_id===n.id))return null;const s=Math.round((n.ts??0)*1e3);return s>0?{id:n.id,tsMs:s}:null}function am(e,t,n){const r=om(e),s=e?.entries;if(r===null||!s||s.length===0)return!1;const i=Math.round((s[s.length-1].ts??0)*1e3);if(!(i>r.tsMs))return!1;for(const[a,l]of t)if(!n.has(a)&&(l===null||!(l>r.tsMs)||!(l<i)))return!1;return!0}const io=new Set,en="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Oc=new RegExp(`[${en}]`),hk=new RegExp(`[${en}]+`),mk=new RegExp(`[${en}]+`,"g"),lm=new RegExp(`^[${en}]+|[${en}]+$`,"g"),cm=new RegExp(`^[${en}]+`),gk=new RegExp(`[^${en}]`);function Ot(e){return e.replace(lm,"")}function cr(e){return e.replace(cm,"")}function dm(e,t){return t===0||Oc.test(e[t-1])}function Pc(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&dm(e,n)&&t.push(n);return t}function oo(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
2
2
|
`,n-1)+1,s=e.indexOf(`
|
|
3
3
|
`,n),i=s===-1?e.length:s;let a=e.slice(r,i);return a.endsWith("\r")&&(a=a.slice(0,-1)),{line:a,lineStart:r,column:n-r}}function um(e,t){if(t.size===0)return null;for(const n of Pc(e)){const r=e.slice(n+1),s=r.indexOf(" ");if(s!==-1&&t.has(r.slice(0,s).toLowerCase()))return n}return null}function ao(e,t,n){const r=um(e,n);let s=null;for(const i of Pc(e)){if(i===r)return t>i?i:s;i<=t&&(s=i)}return s}function fm(e,t=null,n=io){const{line:r,lineStart:s,column:i}=oo(e,t),a=ao(r,i,n);if(a===null)return null;let l=a+1;for(;l<r.length&&!Oc.test(r[l]);)l++;return i>l?null:{start:s+a,query:r.slice(a+1,l),end:s+l}}function yk(e,t=null,n=io){const{line:r,lineStart:s,column:i}=oo(e,t),a=ao(r,i,n);return a===null?null:{start:s+a,end:s+r.length}}function pm(e,t,n=null,r=io){const{line:s,lineStart:i,column:a}=oo(e,n),l=r.size>0?r:new Set(t.map(h=>h.toLowerCase())),c=ao(s,a,l);if(c===null)return null;const d=s.slice(c+1),u=d.indexOf(" ");if(u===-1)return null;const f=d.slice(0,u);if(!t.some(h=>h.toLowerCase()===f.toLowerCase()))return null;const p=c+1+f.length;return a<=p?null:{value:d.slice(u+1),start:i+p+1,end:i+s.length,tokenStart:i+c}}function Ha(e,t){return Ot(e.slice(0,t))===""}function vk(e,t,n,r){const s=pm(e,r,t,n);if(s!==null&&Ha(e,s.tokenStart))return"argument";const i=fm(e,t,n);return i!==null&&Ha(e,i.start)?"command":null}function _k(e,t,n,r){let s=t,i=n;const a=l=>l>=0&&l<e.length&&`
|
|
4
4
|
`.includes(e[l]);return r===""?s>0&&a(s-1)?s-=1:a(i)&&(i+=1):s===0&&a(i)&&(i+=1),{text:`${e.slice(0,s)}${r}${e.slice(i)}`,caret:s+r.length}}const hm=/^\$([A-Za-z0-9][A-Za-z0-9._-]*)/,mm=/<skill name="([^"]*)" invocation="([^"]*)">/;function bk(e,t){const n=cr(e),r=hm.exec(n);if(!r)return null;const s=r[1];let i=t.includes(s)?s:void 0;if(i===void 0){const l=s.toLowerCase();i=t.find(c=>c.toLowerCase()===l)}if(i===void 0)return null;const a=Ot(n.slice(r[0].length));return{name:i,request:a,token:r[0],typed:Ot(n)}}function gm(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\n/g," ")}function ym(e){return e.replace(/ /g,`
|
|
@@ -55,4 +55,4 @@ ${e}`)}function Ni(e,t){return e.sessionId===t||e.key===t||e.key===`send:${t}`}f
|
|
|
55
55
|
* LICENSE.md file in the root directory of this source tree.
|
|
56
56
|
*
|
|
57
57
|
* @license MIT
|
|
58
|
-
*/function gr(){return gr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gr.apply(this,arguments)}const jo=b.createContext(null),Lw=b.createContext(null),rn=b.createContext(null),bs=b.createContext(null),Rt=b.createContext({outlet:null,matches:[],isDataRoute:!1}),vu=b.createContext(null);function $E(e,t){let{relative:n}=t===void 0?{}:t;In()||ke(!1);let{basename:r,navigator:s}=b.useContext(rn),{hash:i,pathname:a,search:l}=Fw(e,{relative:n}),c=a;return r!=="/"&&(c=a==="/"?r:jt([r,a])),s.createHref({pathname:c,search:l,hash:i})}function In(){return b.useContext(bs)!=null}function ws(){return In()||ke(!1),b.useContext(bs).location}function _u(e){b.useContext(rn).static||b.useLayoutEffect(e)}function $w(){let{isDataRoute:e}=b.useContext(Rt);return e?Xw():Uw()}function Uw(){In()||ke(!1);let e=b.useContext(jo),{basename:t,future:n,navigator:r}=b.useContext(rn),{matches:s}=b.useContext(Rt),{pathname:i}=ws(),a=JSON.stringify(Oo(s,n.v7_relativeSplatPath)),l=b.useRef(!1);return _u(()=>{l.current=!0}),b.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){r.go(d);return}let f=Po(d,JSON.parse(a),i,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:jt([t,f.pathname])),(u.replace?r.replace:r.push)(f,u.state,u)},[t,r,a,i,e])}function UE(){let{matches:e}=b.useContext(Rt),t=e[e.length-1];return t?t.params:{}}function Fw(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=b.useContext(rn),{matches:s}=b.useContext(Rt),{pathname:i}=ws(),a=JSON.stringify(Oo(s,r.v7_relativeSplatPath));return b.useMemo(()=>Po(e,JSON.parse(a),i,n==="path"),[e,a,i,n])}function Bw(e,t){return Gw(e,t)}function Gw(e,t,n,r){In()||ke(!1);let{navigator:s,static:i}=b.useContext(rn),{matches:a}=b.useContext(Rt),l=a[a.length-1],c=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=ws(),f;if(t){var p;let _=typeof t=="string"?nn(t):t;d==="/"||(p=_.pathname)!=null&&p.startsWith(d)||ke(!1),f=_}else f=u;let h=f.pathname||"/",g=h;if(d!=="/"){let _=d.replace(/^\//,"").split("/");g="/"+h.replace(/^\//,"").split("/").slice(_.length).join("/")}let m=hw(e,{pathname:g}),y=Vw(m&&m.map(_=>Object.assign({},_,{params:Object.assign({},c,_.params),pathname:jt([d,s.encodeLocation?s.encodeLocation(_.pathname).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?d:jt([d,s.encodeLocation?s.encodeLocation(_.pathnameBase).pathname:_.pathnameBase])})),a,n,r);return t&&y?b.createElement(bs.Provider,{value:{location:gr({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:At.Pop}},y):y}function Hw(){let e=Jw(),t=Dw(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},t),n?b.createElement("pre",{style:s},n):null,null)}const Ww=b.createElement(Hw,null);class zw extends b.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?b.createElement(Rt.Provider,{value:this.props.routeContext},b.createElement(vu.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Zw(e){let{routeContext:t,match:n,children:r}=e,s=b.useContext(jo);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(Rt.Provider,{value:t},r)}function Vw(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,l=(s=n)==null?void 0:s.errors;if(l!=null){let u=a.findIndex(f=>f.route.id&&l?.[f.route.id]!==void 0);u>=0||ke(!1),a=a.slice(0,Math.min(a.length,u+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let u=0;u<a.length;u++){let f=a[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(d=u),f.route.id){let{loaderData:p,errors:h}=n,g=f.route.loader&&p[f.route.id]===void 0&&(!h||h[f.route.id]===void 0);if(f.route.lazy||g){c=!0,d>=0?a=a.slice(0,d+1):a=[a[0]];break}}}return a.reduceRight((u,f,p)=>{let h,g=!1,m=null,y=null;n&&(h=l&&f.route.id?l[f.route.id]:void 0,m=f.route.errorElement||Ww,c&&(d<0&&p===0?(qw("route-fallback"),g=!0,y=null):d===p&&(g=!0,y=f.route.hydrateFallbackElement||null)));let _=t.concat(a.slice(0,p+1)),v=()=>{let I;return h?I=m:g?I=y:f.route.Component?I=b.createElement(f.route.Component,null):f.route.element?I=f.route.element:I=u,b.createElement(Zw,{match:f,routeContext:{outlet:u,matches:_,isDataRoute:n!=null},children:I})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?b.createElement(zw,{location:n.location,revalidation:n.revalidation,component:m,error:h,children:v(),routeContext:{outlet:null,matches:_,isDataRoute:!0}}):v()},null)}var bu=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(bu||{}),wu=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(wu||{});function Kw(e){let t=b.useContext(jo);return t||ke(!1),t}function Yw(e){let t=b.useContext(Lw);return t||ke(!1),t}function Qw(e){let t=b.useContext(Rt);return t||ke(!1),t}function Su(e){let t=Qw(),n=t.matches[t.matches.length-1];return n.route.id||ke(!1),n.route.id}function Jw(){var e;let t=b.useContext(vu),n=Yw(),r=Su();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Xw(){let{router:e}=Kw(bu.UseNavigateStable),t=Su(wu.UseNavigateStable),n=b.useRef(!1);return _u(()=>{n.current=!0}),b.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,gr({fromRouteId:t},i)))},[e,t])}const Kl={};function qw(e,t,n){Kl[e]||(Kl[e]=!0)}function FE(e,t){e?.v7_startTransition,e?.v7_relativeSplatPath}function BE(e){let{to:t,replace:n,state:r,relative:s}=e;In()||ke(!1);let{future:i,static:a}=b.useContext(rn),{matches:l}=b.useContext(Rt),{pathname:c}=ws(),d=$w(),u=Po(t,Oo(l,i.v7_relativeSplatPath),c,s==="path"),f=JSON.stringify(u);return b.useEffect(()=>d(JSON.parse(f),{replace:n,state:r,relative:s}),[d,f,s,n,r]),null}function e0(e){ke(!1)}function GE(e){let{basename:t="/",children:n=null,location:r,navigationType:s=At.Pop,navigator:i,static:a=!1,future:l}=e;In()&&ke(!1);let c=t.replace(/^\/*/,"/"),d=b.useMemo(()=>({basename:c,navigator:i,static:a,future:gr({v7_relativeSplatPath:!1},l)}),[c,l,i,a]);typeof r=="string"&&(r=nn(r));let{pathname:u="/",search:f="",hash:p="",state:h=null,key:g="default"}=r,m=b.useMemo(()=>{let y=gu(u,c);return y==null?null:{location:{pathname:y,search:f,hash:p,state:h,key:g},navigationType:s}},[c,u,f,p,h,g,s]);return m==null?null:b.createElement(rn.Provider,{value:d},b.createElement(bs.Provider,{children:n,value:m}))}function HE(e){let{children:t,location:n}=e;return Bw(zi(t),n)}new Promise(()=>{});function zi(e,t){t===void 0&&(t=[]);let n=[];return b.Children.forEach(e,(r,s)=>{if(!b.isValidElement(r))return;let i=[...t,s];if(r.type===b.Fragment){n.push.apply(n,zi(r.props.children,i));return}r.type!==e0&&ke(!1),!r.props.index||!r.props.children||ke(!1);let a={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=zi(r.props.children,i)),n.push(a)}),n}function WE(e){return e!=="detached"&&e!=="wedged"}function ku(e){return e!=="governed-elsewhere"&&e!=="pre-handshake"}function zE(e){if(!e)return{title:"Not connected to a Local Operator server.",detail:null,retry:!0};const t=e.addressSubstitution??null;if(t&&e.state!=="detached"&&e.state!=="wedged")return t.kind==="substituted"?{title:`Serving on ${t.serving}, not the address this app is configured for.`,detail:t.holder?`${t.holder}. The app uses ${t.serving} while that holds.${t.reclaim?` ${t.reclaim}`:""} It is back on ${t.configured} on its next launch or recovery.`:`The daemon this app is using was already running, so it did not start one. It looks for ${t.configured} again on its next launch or recovery.`,retry:!0}:{title:`Back on ${t.configured}, the address this app is configured for.`,detail:`It served on ${t.serving} while the configured address was held; it is on the address it was told to use again.`,retry:!1,dismiss:!0};const n=e.detail?.trim()?e.detail.trim():null,r=ku(e.pairing?.cause??null);switch(e.state){case"wedged":return{title:"A Local Operator server is running on this machine and this app is not attached to it.",detail:n,retry:r};case"detached":return e.reconnecting?{title:r?"Not connected to a Local Operator server. If one is still running, the app reconnects to it on its own.":"Not connected to a Local Operator server.",detail:n,retry:r}:{title:r?"The Local Operator server stopped. The app keeps looking for one and attaches to it when it appears.":"Not connected to a Local Operator server. The app keeps looking for one.",detail:n,retry:r};default:return null}}function t0(e){if(em(e))return"deadline";const t=e instanceof ye?e.status:null;return t===null||t===503?"unreachable":t===401||t===403?"unauthorized":t===404?"outdated":"unknown"}const Ru={unreachable:"",deadline:"",unauthorized:"",outdated:"Update the server and try again.",unknown:""},Zi={unreachable:"The Local Operator server is not answering.",deadline:"The Local Operator server did not answer in time.",unauthorized:"This app cannot authenticate to the running Local Operator server.",outdated:"The Local Operator server is older than this app expects.",unknown:""};function n0(e,t){const n=t0(t);return[e,Zi[n],Ru[n]].filter(Boolean).join(" ")}const Vi={successor:"The Local Operator server was replaced while this app was running. Pairing with the new one.","governed-elsewhere":"The Local Operator server on this machine is already managed by another program, so this app cannot use its settings, provider sign-in, slash commands or MCP management.","pre-handshake":"The Local Operator server on this machine is older than the pairing handshake this app uses, so this app cannot drive its controls. The server itself, and anything you run against it from the terminal, are unaffected.","credential-refused":"This app's credential for the running Local Operator server was refused, so provider sign-in, settings, slash commands and MCP management are unavailable.",unpaired:"This app is not paired with the running Local Operator server, so provider sign-in, settings, slash commands and MCP management are unavailable."},r0={successor:"This conversation cannot be read here until the app finishes pairing with the replacement server. Your chats are still on that server.","governed-elsewhere":"This conversation cannot be read here: the server's desktop controls belong to another program. Your chats are still on that server.","pre-handshake":"This conversation cannot be read here: that server is older than the pairing handshake this app uses. Your chats are still on that server.","credential-refused":"This conversation cannot be read here: the server refused this app's credential. Your chats are still on that server.",unpaired:"This conversation cannot be read here: the app is not paired with the running server. Your chats are still on that server."};function ZE(e,t){return e!=="unpaired"?null:r0[t??"unpaired"]}function VE(e,t){return e!=="unpaired"?null:Vi[t??"unpaired"]}function KE(e){const{kind:t,unpaired:n,answered:r,cause:s=null,servedByThisApp:i=!1}=e;return s==="pre-handshake"?i:s!==null||n?!1:r?i:t==="outdated"}function YE(e){const{kind:t,unpaired:n,missing:r,answered:s,cause:i=null}=e;if(i!==null)return Vi[i];if(!s){if(t==="unreachable")return`${Zi.unreachable} Provider sign-in, settings, slash commands and MCP management need it running.`;if(t==="unauthorized")return"This app cannot authenticate to the running Local Operator server, so provider sign-in, settings, slash commands and MCP management are unavailable.";if(t==="deadline")return`${Zi.deadline} Provider sign-in, settings, slash commands and MCP management need it answering.`;if(t==="outdated")return`The Local Operator server is older than this app expects, so provider sign-in, settings, slash commands and MCP management are off. ${Ru.outdated}`}return n?Vi.unpaired:s?`The Local Operator server is missing ${r.join(", ")} support. Update it to enable those surfaces.`:"Provider sign-in, settings, slash commands and MCP management are unavailable because the Local Operator server did not answer as expected."}const s0=["auth","settings","commands","catalogues","lifecycle","mcp","radient"];function QE(e,t=null){return t!==null||!e?!0:s0.filter(r=>(e.features?.[r]??0)<1).length>0||e.desktop_available!==!0}function i0(e,t){return t instanceof ye&&t.status===null?!1:e<1}function JE(e,t){return t instanceof ye&&t.status!==null&&t.status>=400&&t.status<500&&t.status!==408&&t.status!==425&&t.status!==429?!1:e<1}const o0={successor:"Your settings could not be loaded: the app is pairing with the server that replaced the one it was using.","governed-elsewhere":"Your settings could not be loaded: another program is managing this machine's Local Operator server, so this page cannot read or change them here.","pre-handshake":"Your settings could not be loaded: the server this app is talking to is older than the pairing handshake, so this page cannot read them from it.","credential-refused":"Your settings could not be loaded: the server refused this app's credential, so this page cannot read them from it.",unpaired:"Your settings could not be loaded: this app is not paired with the running server, so this page cannot read them from it."};function XE(e,t,n){return e===null?{sentence:n0(t,n),remedy:!0}:{sentence:o0[e],remedy:ku(e)}}const kr=260,Eu=220,Iu=320,Ki=56,a0=kr,l0=1024,xu=480,Tu=44,Cu=400,c0=560;function Au(e){return Math.max(0,Math.min(c0,e-xu))}function Yl(e){return Au(e)>=Cu?"docked":"overlay"}function qE({capacity:e,min:t,max:n,drawn:r}){const s=e>=t;return s?{resizable:s,value:Math.min(Math.max(r,t),e),minWidth:t,maxWidth:Math.min(n,e)}:{resizable:s,value:r,minWidth:r,maxWidth:r}}function d0(e,t=kr,n=Tu){return Yl(e-Ou(t)-n)==="overlay"&&Yl(e-Ki-n)==="docked"}function Ou(e){return Number.isNaN(e)?kr:Math.min(Iu,Math.max(Eu,e))}function eI(e,t,n,r=kr,s=!1,i=Tu){if(e>=l0){const l=!t&&s&&d0(e,r,i);return{mode:t||l?"strip":"docked",width:t||l?Ki:Ou(r),collapsed:t||l,sheetOpen:!1,resizable:!t&&!l}}return{mode:n?"overlay":"strip",width:n?a0:Ki,collapsed:!0,sheetOpen:n,resizable:!1}}function tI(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="b"}const nI=e=>e?"⌘B":"Ctrl+B",u0=()=>{const e=b.useContext(Co)??null,t=b.useMemo(()=>new Yb({defaultOptions:{queries:{enabled:!1,retry:!1}}}),[]);return b.useMemo(()=>e?{client:e,provided:!0}:{client:t,provided:!1},[e,t])},f0="data-canvas-shortcuts",p0=`[${f0}]`,h0=e=>Pu(e,p0),m0='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]',rI=e=>Pu(e,m0);function Pu(e,t){const n=e;return typeof n?.closest=="function"?n.closest(t)!==null:!1}const sI=e=>{if(!(e.metaKey||e.ctrlKey))return null;const t=e.key.toLowerCase();return t==="o"?"open-file":t==="n"&&h0(e.target)?"new-file":null},g0=["active","created"],iI={running:"Running",today:"Today",week:"This week",older:"Older"},y0=new Set(["waiting","busy","delegating","approval","answer","wedged"]);function Ss(e){return y0.has(e.status?.code??"")}const v0=new Set(["approval","answer"]);function _0(e){return v0.has(e.status?.code??"")}const b0=24*60*60*1e3,w0=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function Mo(e,t){const n=t==="created"?e.created_at:e.updated_at;return typeof n!="number"||!Number.isFinite(n)||n<=0?null:n*1e3}const S0="last_user_at";function k0(e){const t=e[S0],n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:e.created_at;return typeof n!="number"||!Number.isFinite(n)||n<=0?null:n*1e3}function R0(e,t,n){if(Ss(e))return"running";const r=Mo(e,n);if(r===null)return"older";const s=w0(t);return r>=s?"today":r>=s-6*b0?"week":"older"}function oI(e,t,n){const r={running:[],today:[],week:[],older:[]};for(const s of e)r[R0(s,t,n)].push(s);return r}function E0(e,t,n){const r=Mo(e,n);if(r===null)return"";const s=Math.floor(Math.max(0,t-r)/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const a=Math.floor(i/24);if(a<7)return`${a}d`;const l=Math.floor(a/7);return a<365?`${l}w`:`${Math.floor(a/365)}y`}function aI(e,t,n){const r=E0(e,t,n);if(!r)return"";const s=n==="created"?"created":"last active";if(r==="now")return`${s} just now`;const i={m:"minute",h:"hour",d:"day",w:"week",y:"year"},a=Number.parseInt(r,10),l=i[r.slice(-1)];return`${s} ${a} ${l}${a===1?"":"s"} ago`}const Yi=["pinned","running","today","week","older","agents","teams"];function lI(e){return e==="agents"||e==="teams"}const yr=8;function I0(e,t){if(!(t in e))return e;const n={...e};return delete n[t],n}function cI(e,t){return{...e,[t]:(e[t]??yr)+yr}}function dI(e,t,n,r,s){const i=!(e[n]??r);return{expanded:{...e,[n]:i},caps:!i&&!s?I0(t,n):t}}function uI(e,t,n,r){return(e||t!=="")&&(r>yr||n.trim()!=="")}const fI="Collapse, then reopen, to restore the compact list";function pI(e){return(e??yr)>yr}const hI=e=>`section-grown-hint-${e}`,x0=e=>e===1?"Show 1 more":`Show ${e} more`;function mI(e,t){return`${x0(e)} ${t}`}const pn={hidden:[],order:[...Yi],pins:[],groupBy:"section",tagsEnabled:!1,autoTagForks:!0,basis:"active",orderBy:"active-first",loads:0,pinnedAgents:[]},T0=10,$n=[25,50],C0=50,A0=500,O0=64;function bn(e){const t=Math.max(0,Math.floor(e));return t===0?T0:t<=$n.length?$n[t-1]:$n[$n.length-1]+(t-$n.length)*C0}function gI(e,t){const n=bn(e+1)-bn(e),r=Math.max(0,Math.min(n,t));return r===1?"Show 1 more chat":`Show ${r} more chats`}function yI(e,t,n){const r=bn(t+1)-bn(t),s=bn(t),i=Math.min(s+r,e.length);let a=0;for(let c=s;c<i;c+=1)Do(e[c])&&(a+=1);const l=Math.max(0,i-s-a);return l>0?l:Math.max(0,Math.min(r,n))}function Do(e){return Ss(e)}function P0(e){return _0(e)?0:Ss(e)?1:2}function j0(e,t){return Ss(e)?k0(e):Mo(e,t)}function M0(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:t-e}function vI(e,t,n){const r=e.map((s,i)=>({row:s,index:i,lane:t==="active-first"?P0(s):0,at:j0(s,n)}));return r.sort((s,i)=>s.lane-i.lane||M0(s.at,i.at)||s.index-i.index),r.map(s=>s.row)}function _I(e,t){const{limit:n,currentId:r,searching:s=!1}=t;if(s)return{rows:[...e],lifted:!1,remaining:0};const i=[];let a=Math.max(0,n);for(const d of e){if(a>0){i.push(d),a-=1;continue}Do(d)&&i.push(d)}const l=Math.max(0,e.length-i.length);if(!r)return{rows:i,lifted:!1,remaining:l};const c=e.find(d=>d.session_id===r)??null;return c===null||i.includes(c)?{rows:i,lifted:!1,remaining:l}:{rows:[c,...i],lifted:!0,remaining:l}}function bI(e,t){if(t.searching)return{rows:[...e],lifted:!1,hidden:0,held:e.length};const n=bn(t.loads),r=[];let s=n;for(const c of e){if(Do(c)){r.push(c);continue}s>0&&(r.push(c),s-=1)}const i=t.currentId,a=i==null?null:e.find(c=>c.session_id===i)??null,l=a!==null&&!r.includes(a);return{rows:l&&a!==null?[a,...r]:r,lifted:l,hidden:e.length-r.length-(l?1:0),held:e.length}}function wI(e){if(e.add<=0)return null;const t=e.add===1?"Show 1 more chat":`Show ${e.add} more chats`;if(e.drawn>=e.total)return{label:t,aria:t};const n=`${e.drawn} of ${e.total}`;return{label:`${t} · ${n}`,aria:`${t} · ${n} shown`}}const D0="mt-4",N0="mt-2";function SI(e){return e?D0:N0}function kI(e,t,n,r){return n?e.toLocaleLowerCase().includes(n.toLocaleLowerCase())||(r??"").toLocaleLowerCase().includes(n.toLocaleLowerCase())||t>0:!0}function RI(e,t){if(t==="section")return null;if(t==="flat")return[{key:"all",label:"",rows:[...e]}];const n=new Map;for(const i of e){const a=i.binding?.team||i.binding?.agent||"",l=a||"ungrouped",c=n.get(l)??{key:l,label:a||"Ungrouped",rows:[]};c.rows.push(i),n.set(l,c)}const r=[...n.values()],s=r.findIndex(i=>i.key==="ungrouped");return s>0&&r.push(...r.splice(s,1)),r}function L0(e,t){return!e.hidden.includes(t)}function ju(e){return e.order.filter(t=>L0(e,t))}function EI(e,t){const n=e.hidden.includes(t)?e.hidden.filter(r=>r!==t):[...e.hidden,t];return{...e,hidden:n}}function II(e,t,n){const r=ju(e),s=r.indexOf(t),i=r[s+n];if(s<0||i===void 0)return e;const a=e.order.indexOf(t),l=e.order.indexOf(i),c=[...e.order];return c[a]=i,c[l]=t,{...e,order:c}}const $0=["running","today","week","older"];function Ql(e){return $0.includes(e)}function xI(e,t,n,r){if(!Ql(t)||r&&!r(t))return!1;const s=ju(e),i=s.indexOf(t);if(i<0)return!1;const a=s[i+n];return a===void 0||!Ql(a)?!1:r?r(a):!0}const U0=["section","agent","flat"],F0=["active-first","recent"];function TI(e){if(typeof e!="object"||e===null)return pn;const t=e,n=new Set(Yi),r=[];if(Array.isArray(t.order))for(const p of t.order)typeof p=="string"&&n.has(p)&&(r.includes(p)||r.push(p));for(const p of Yi)r.includes(p)||r.push(p);const s=[];if(Array.isArray(t.hidden))for(const p of t.hidden)typeof p=="string"&&n.has(p)&&(s.includes(p)||s.push(p));const i=U0.includes(t.groupBy)?t.groupBy:pn.groupBy,a=g0.includes(t.basis)?t.basis:pn.basis,l=F0.includes(t.orderBy)?t.orderBy:pn.orderBy,c=typeof t.loads=="number"&&Number.isFinite(t.loads)&&t.loads>0?Math.min(A0,Math.floor(t.loads)):0,d=[];if(Array.isArray(t.pinnedAgents)){for(const p of t.pinnedAgents)if(typeof p=="string"&&p!==""&&!d.includes(p)){if(d.length>=O0)break;d.push(p)}}const u=[],f=new Set;if(Array.isArray(t.pins))for(const p of t.pins)typeof p=="string"&&p.length!==0&&(f.has(p)||(f.add(p),u.push(p)));return{hidden:s,order:r,groupBy:i,tagsEnabled:typeof t.tagsEnabled=="boolean"?t.tagsEnabled:!1,autoTagForks:typeof t.autoTagForks=="boolean"?t.autoTagForks:pn.autoTagForks,basis:a,orderBy:l,loads:c,pins:u,pinnedAgents:d}}const Mu={sort:"recent",order:"asc",group:!0,workingOpen:!1,closedSections:[],kinds:[]},B0=["recent","name","kind","modified","created","size"],G0=["images","video","audio","documents","spreadsheets","presentations","code","archives","other"];function No(e){const t=e&&typeof e=="object"?e:{};return{sort:B0.includes(t.sort??"")?t.sort:Mu.sort,order:t.order==="desc"?"desc":"asc",group:typeof t.group=="boolean"?t.group:!0,workingOpen:t.workingOpen===!0,closedSections:Array.isArray(t.closedSections)?[...new Set(t.closedSections.filter(n=>["Highlights","Images","Videos","Sounds","Documents","Spreadsheets","Other"].includes(n)))]:[],kinds:Array.isArray(t.kinds)?[...new Set(t.kinds.filter(n=>G0.includes(n)))]:[]}}function CI(e,t){const n=r=>{switch(t.sort){case"name":return r.row.name;case"kind":return`${r.row.kind}\0${r.row.name}`;case"modified":return r.modified;case"created":return r.created;case"size":return r.row.document.sizeBytes??null;default:return r.mentioned}};return[...e].sort((r,s)=>{const i=n(r),a=n(s);if(i===null||a===null)return i===a?0:i===null?1:-1;const l=typeof i=="string"&&typeof a=="string"?i.localeCompare(a,void 0,{numeric:!0}):Number(i)-Number(a);return(t.order==="asc"?l:-l)||r.mentioned-s.mentioned})}const H0=e=>{switch(e.row.kind){case"images":return"Images";case"video":return"Videos";case"audio":return"Sounds";case"spreadsheets":return"Spreadsheets";case"documents":case"presentations":case"code":return"Documents";default:return"Other"}};function AI(e,t,n,r){const s=e.filter(l=>l.highlighted),i=e.filter(l=>!l.highlighted),a=[];if(s.length&&a.push({id:"Highlights",label:"Highlights",items:s,open:n||!r.has("Highlights"),highlights:!0}),s.length&&i.length&&(a.push({id:"Working files",label:"Working files",items:[],open:t.workingOpen||n,highlights:!1}),!t.workingOpen&&!n))return a;if(!t.group)i.length&&a.push({id:"Files",label:"Files",items:i,open:!0,highlights:!1});else for(const l of["Images","Videos","Sounds","Documents","Spreadsheets","Other"]){const c=i.filter(d=>H0(d)===l);c.length&&a.push({id:l,label:l,items:c,open:n||!r.has(l),highlights:!1})}return a}const W0=32,OI=4;function PI(e,t,n){const r=[],s=new Map,i=Math.max(136,t-16),a=Math.max(1,Math.floor((i+4)/140));let l=0;const c=(d,u,f,p,h=1)=>{p.forEach((g,m)=>s.set(g.row.document.id,{band:r.length,column:m})),r.push({section:d,kind:u,height:f,top:l,items:p,cols:h}),l+=f};for(const d of e)if(c(d,"header",W0,[]),!!d.open)if(d.highlights)for(const u of d.items)c(d,"highlight",u.why?68:44,[u]);else if(n&&d.id==="Images"){const u=(i-4*(a-1))/a,f=Math.round((u-8)*3/4)+32;for(let p=0;p<d.items.length;p+=a)c(d,"tiles",f,d.items.slice(p,p+a),a)}else if(n&&d.id==="Videos")for(const u of d.items)c(d,"video",Math.min(Math.round((i-8)*9/16),280)+32,[u]);else if(n&&d.id==="Sounds")for(const u of d.items)c(d,"audio",80,[u]);else for(const u of d.items)c(d,"compact",36,[u]);return{bands:r,height:l,columns:a,positions:s}}function jI(e,t,n,r){const s=Math.max(600,n*.75);let i=0,a=e.bands.length;for(;i<a;){const d=i+a>>>1,u=e.bands[d];u.top+u.height<t-s?i=d+1:a=d}const l=new Set;for(let d=i;d<e.bands.length&&e.bands[d].top<=t+n+s;d++)l.add(d);const c=r?e.positions.get(r):null;return c&&l.add(c.band),[...l].sort((d,u)=>d-u)}function MI(e,t,n,r){const s=e.positions.get(t);if(!s)return null;const i=e.bands[s.band],a=e.bands.filter(u=>u.section.id===i.section.id&&u.items.length);if(n==="Home")return a[0]?.items[0]?.row.document.id??null;if(n==="End")return a.at(-1)?.items.at(-1)?.row.document.id??null;if(n==="ArrowLeft"||n==="ArrowRight")return i.items[s.column+(n==="ArrowLeft"?-1:1)]?.row.document.id??null;const l=n==="ArrowUp"||n==="PageUp"?-1:1,c=i.top+(n.startsWith("Page")?r*l:l);let d=s.band+l;for(;d>=0&&d<e.bands.length;d+=l){const u=e.bands[d];if(u.items.length&&!(n.startsWith("Page")&&(l>0?u.top<c:u.top>c)))return u.items[Math.min(s.column,u.items.length-1)].row.document.id}if(n.startsWith("Page")){const u=e.bands.filter(p=>p.items.length),f=l<0?u[0]:u.at(-1);return f?.items[l<0?0:f.items.length-1]?.row.document.id??null}return null}const z0="both",Du="by-turn",Qi=[{value:"by-turn",label:"By turn"},{value:"by-response",label:"By response"}];function DI(e){for(const t of Qi)if(e===t.value)return t.value;return Du}function NI(e){return Qi.find(t=>t.value===e)?.label??Qi[0].label}const LI="primary+alt+shift+space",Z0=/^f([1-9]|1[0-9]|2[0-4])$/;function V0(e){return Z0.test(e)}function K0(e,t){const n=Y0(e,t);return t==="mac"?n.join(""):n.join("+")}function Y0(e,t){const r=t==="mac"?{primary:"⌘",meta:"⌘",ctrl:"⌃",alt:"⌥",shift:"⇧"}:{primary:"Ctrl",meta:t==="win"?"Win":"Super",ctrl:"Ctrl",alt:"Alt",shift:"Shift"},s={space:"Space",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",up:"Up",down:"Down",left:"Left",right:"Right"};return e.split("+").map(i=>i.trim().toLowerCase()).filter(i=>i.length>0).map(i=>i in r?r[i]:i in s?s[i]:V0(i)||i.length===1?i.toUpperCase():i)}const ks=[{id:"panel.console",label:"Open console",category:"Panels",defaultChord:"primary+j",scope:"app"},{id:"panel.canvas",label:"Open canvas",category:"Panels",defaultChord:"primary+shift+c",scope:"app"},{id:"panel.run",label:"Open run details",category:"Panels",defaultChord:null,scope:"app"},{id:"panel.ask",label:"Open asks",category:"Panels",defaultChord:null,scope:"app"},{id:"panel.browser",label:"Open browser",category:"Panels",defaultChord:null,scope:"app"},{id:"panel.code",label:"Open code review",category:"Panels",defaultChord:null,scope:"app"}],Q0=new Map(ks.map(e=>[e.id,e])),J0=e=>Q0.get(e),X0=new Set(["primary+0","primary+r","primary+shift+r","primary+t","primary+shift+t","primary+l",...[1,2,3,4,5,6,7,8,9].map(e=>`primary+${e}`)]),Lo=new Map([["primary+p","Reserved: opens the command palette from anywhere."],["primary+shift+p","Reserved: opens the command palette on commands."],["primary+shift+s","Reserved: starts speech to text."],["primary+k","Reserved: opens the command palette on chats."],["primary+n","Reserved: starts a new chat."],["primary+b","Reserved: toggles the sidebar."],["primary+[","Reserved: goes back in the browser, or between chats outside it."],["primary+]","Reserved: goes forward in the browser, or between chats outside it."],["primary+f","Reserved: finds in the browser page, or searches the transcript outside it."],["primary+alt+up","Reserved: walks up the chat regions."],["primary+alt+down","Reserved: walks down the chat regions."],["primary+shift+a","Reserved: archives the focused conversation."],["primary+shift+l","Reserved: opens the focused conversation's tags."],["primary+s","Reserved: saves the canvas document."],["primary+o","Reserved: opens a file in the canvas."],["primary+shift+up","Reserved: moves the focused chat up the pinned order."],["primary+shift+down","Reserved: moves the focused chat down the pinned order."],["primary+c","Reserved: copy."],["primary+x","Reserved: cut."],["primary+v","Reserved: paste."],["primary+a","Reserved: select all."],["primary+z","Reserved: undo."],["primary+shift+z","Reserved: redo."],["primary+y","Reserved: redo on Windows and Linux."],["primary+r","Reserved: reloads the browser page."],["primary+shift+r","Reserved: reloads the browser page, ignoring the cache."],["primary+t","Reserved: opens a new browser tab."],["primary+shift+t","Reserved: reopens the last closed browser tab."],["primary+l","Reserved: focuses the browser address bar."],...[1,2,3,4,5,6,7,8,9].map(e=>[`primary+${e}`,e===9?"Reserved: switches to the last browser tab.":`Reserved: switches to browser tab ${e}.`]),["primary+0","Reserved: resets browser page zoom, or app zoom outside it."],["primary+plus","Reserved: zooms the browser page or app in."],["primary+=","Reserved: zooms the browser page or app in."],["primary+-","Reserved: zooms the browser page or app out."],["primary+q","Reserved: quits the app."],["primary+w","Reserved: closes the browser tab, or the window outside it."],["primary+m","Reserved: minimises the window."]]),q0=["primary","alt","shift"],eS={primary:"primary",meta:"primary",cmd:"primary",command:"primary",super:"primary",ctrl:"primary",control:"primary",alt:"alt",option:"alt",shift:"shift"},tS=new Set(["space","backspace","delete","insert","home","end","pageup","pagedown","up","down","left","right"]),nS=e=>tS.has(e)||/^[a-z0-9]$/.test(e);function $o(e){if(typeof e!="string")return null;const t=e.toLowerCase().split("+").map(i=>i.trim()).filter(i=>i.length>0);if(t.length===0)return null;const n=t[t.length-1];if(!nS(n))return null;const r=new Set;for(const i of t.slice(0,-1)){const a=eS[i];if(a===void 0)return null;r.add(a)}return[...q0.filter(i=>r.has(i)),n].join("+")}const Nu=e=>e.split("+").includes("primary");function Rs(e,t){const n=t?.[e];return n===null?null:typeof n=="string"&&!Lo.has(n)?n:J0(e)?.defaultChord??null}function $I(e){const t=new Map;for(const n of ks){const r=Rs(n.id,e);r!==null&&!t.has(r)&&t.set(r,n.id)}return t}const rS=e=>e==="mac"?"A shortcut needs ⌘ or Ctrl.":"A shortcut needs Ctrl.";function sS(e,t,n,r="linux"){const s=e===null?null:$o(e);if(s===null)return"That key cannot be bound.";if(!Nu(s))return rS(r);const i=Lo.get(s);if(i!==void 0)return i;for(const a of ks)if(a.id!==t&&Rs(a.id,n)===s)return`Already assigned to ${a.label}.`;return null}function iS(e){if(e===null||typeof e!="object"||Array.isArray(e))return{};const t=e,n=new Set,r={};for(const s of ks){const i=t[s.id];if(i===null){r[s.id]=null;continue}const a=typeof i=="string"?$o(i):null,l=a!==null&&X0.has(a),c=a!==null&&Nu(a)&&(l||!Lo.has(a)&&!n.has(a))?a:null;c!==null&&(r[s.id]=c);const d=Rs(s.id,r);d!==null&&n.add(d)}return r}function UI(e,t,n){const r=Rs(e,t);return r===null?null:Lu(r,n)}function Lu(e,t){return K0(e,t)}function FI(e,t){const n=e.split("+"),r=n[n.length-1],s=n.slice(0,-1).map(i=>i==="primary"?t==="mac"?"Meta":"Control":i==="shift"?"Shift":i==="alt"?"Alt":i);return{glyph:Lu(e,t),aria:[...s,r.length===1?r.toUpperCase():r].join("+")}}const Jl=64,Ji=["canvas","run","browser","console","code"],oS={canvas:"isCanvasOpen",run:"isRunPanelOpen",browser:"isBrowserPaneOpen",console:"isConsolePaneOpen",code:"isCodeReviewPaneOpen"};function $u(e){return typeof e=="string"&&Ji.includes(e)}function Uo(e){return e.startsWith("draft:")}function Rr(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r[0]===t)return r[1]}}function Fo(e){return e.length>Jl?e.slice(e.length-Jl):e}function Uu(e,t,n){return Fo([...e.filter(([r])=>r!==t),[t,n]])}function aS(e,t,n){return Rr(e,t)!==n?e:e.filter(([r])=>r!==t)}function lS(e,t){return Rr(e,t)===void 0?e:e.filter(([n])=>n!==t)}function cS(e,t,n){const r=Rr(e,t);return r===void 0?e:Fo([...e.filter(([s])=>s!==t&&s!==n),[n,r]])}const Xl=Object.freeze({isCanvasOpen:!1,isRunPanelOpen:!1,isBrowserPaneOpen:!1,isConsolePaneOpen:!1,isCodeReviewPaneOpen:!1});function ql(e,t,n){if(n||typeof t!="string")return Xl;const r=Rr(e,t);return r===void 0?Xl:{isCanvasOpen:r==="canvas",isRunPanelOpen:r==="run",isBrowserPaneOpen:r==="browser",isConsolePaneOpen:r==="console",isCodeReviewPaneOpen:r==="code"}}function dS(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!Array.isArray(n)||n.length!==2)continue;const[r,s]=n;typeof r!="string"||r===""||Uo(r)||$u(s)&&(t.delete(r),t.set(r,s))}return Fo([...t.entries()])}function BI(e){const t=new Set(Object.keys(e.forgotten));for(const[n,r]of Object.entries(e.archiveFacts))r?.archived===!0&&r.answered===!0&&t.add(n);return t}function ec(e){return oS[e]}const uS={canvas:"isCanvasOpen",run:"isRunPanelOpen",browser:"isBrowserPaneOpen",console:"isConsolePaneOpen",code:"isCodeReviewPaneOpen"},Er=e=>e.isCanvasOpen?"canvas":e.isRunPanelOpen?"run":e.isBrowserPaneOpen?"browser":e.isConsolePaneOpen?"console":e.isCodeReviewPaneOpen?"code":e.isAskDrawerOpen?"ask":null,Es=(e,t)=>e==="ask"?t.askDrawerScope==="fleet"||t.rightSlotRoute.mounted&&t.rightSlotRoute.session:t.rightSlotRoute.mounted,fS=e=>{const t=Er(e);return t===null||t==="ask"?null:uS[t]},Ct=e=>({isRunPanelOpen:e==="isRunPanelOpen",isCanvasOpen:e==="isCanvasOpen",isBrowserPaneOpen:e==="isBrowserPaneOpen",isConsolePaneOpen:e==="isConsolePaneOpen",isCodeReviewPaneOpen:e==="isCodeReviewPaneOpen",isAskDrawerOpen:e==="isAskDrawerOpen",askDrawerEvictedPane:null}),Gt=(e,t)=>{const n=e.rightSlotKey;return typeof n!="string"?{}:{rightSlotMemory:Uu(e.rightSlotMemory,n,t)}},Un=(e,t)=>{const n=e.rightSlotKey;if(typeof n!="string")return{};const r=aS(e.rightSlotMemory,n,t);return r===e.rightSlotMemory?{}:{rightSlotMemory:r}},pS=e=>{const t=e.rightSlotKey;if(typeof t!="string")return{};const n=lS(e.rightSlotMemory,t);return n===e.rightSlotMemory?{}:{rightSlotMemory:n}},hS=Object.freeze({mounted:!1,session:!1}),Fu=Object.freeze([]);function GI(e,t){const n=Er(t);if(n===null||!Es(n,t))return 0;let r;switch(n){case"canvas":case"ask":r=Math.max(Cu,t.rightSlotWidth||Fn);break;case"run":r=Math.max(nc,t.rightSlotWidth||Fn);break;case"browser":r=Math.max(vS,t.rightSlotWidth||Fn);break;case"console":r=Math.max(_S,t.rightSlotWidth||Fn);break;case"code":r=Math.max(nc,t.rightSlotWidth||Fn);break}return e<=0?r:n==="canvas"||n==="ask"?Math.min(r,Au(e)):Math.min(r,Math.max(0,e-xu))}function HI(e){const t=Er(e);return t!==null&&Es(t,e)}function WI(e){const t=Er(e);return t!==null&&Es(t,e)?t:null}function zI(e){const t=Er(e);return(t==="canvas"||t==="ask")&&Es(t,e)}const Fn=640,tc=kr,mS=20,gS=4,yS=20,nc=320,vS=480,_S=480,bS=5e3,ZI=(e,t)=>e.some(n=>n.surface===t),VI=(e,t=Date.now())=>e.some(n=>t-n.at<bS),wS=[],SS=4,kS=["chatMeasureWidth"],KI=_r()(ms((e,t)=>({finderFiles:Mu,setFinderFiles:n=>e({finderFiles:No({...t().finderFiles,...n})}),isCommandPaletteOpen:!1,commandPaletteQuery:"",isSidebarCollapsed:!1,sidebarOverflowExpanded:!1,showAgentReasoning:!1,transcriptDisplayMode:Du,themeName:Qu,rightSlotWidth:0,chatSidebarWidth:tc,chatSidebarRegions:z0,chatSidebarView:pn,chatSidebarListHeight:null,chatSidebarOrder:"entities-first",dismissedBuiltinOfferSignature:"",isCanvasOpen:!1,isRunPanelOpen:!1,isBrowserPaneOpen:!1,isConsolePaneOpen:!1,isCodeReviewPaneOpen:!1,rightSlotKey:void 0,rightSlotMemory:Fu,rightSlotLegacySeed:null,isAskDrawerOpen:!1,askDrawerScope:"session",askDrawerEvictedPane:null,askOpenIntent:null,rightSlotRoute:hS,consoleOpenIntent:null,consoleLiveSurface:null,runPanelReveal:null,codeReviewReveal:null,browserPaneScope:"conversation",consoleActiveSurface:null,consoleUnseen:wS,isCreateAgentDialogOpen:!1,mentionRecents:null,profileRecents:{agent:[],team:[]},conversationRecents:[],shortcutBindings:{},openCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!0})},closeCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!1})},openCommandPalette:()=>{e({isCommandPaletteOpen:!0})},closeCommandPalette:()=>{e({isCommandPaletteOpen:!1,commandPaletteQuery:""})},toggleCommandPalette:(n="")=>{e(r=>({isCommandPaletteOpen:!r.isCommandPaletteOpen,commandPaletteQuery:r.isCommandPaletteOpen?r.commandPaletteQuery:n}))},setCommandPaletteQuery:n=>{e({commandPaletteQuery:n})},toggleSidebar:()=>{e(n=>({isSidebarCollapsed:!n.isSidebarCollapsed}))},setSidebarOverflowExpanded:n=>{e({sidebarOverflowExpanded:n})},setSidebarCollapsed:n=>{e({isSidebarCollapsed:n})},setShowAgentReasoning:n=>{e({showAgentReasoning:n})},setTranscriptDisplayMode:n=>{e({transcriptDisplayMode:n})},setTheme:n=>{e({themeName:n})},setCanvasOpen:n=>{e(r=>n?{...Ct("isCanvasOpen"),...Gt(r,"canvas")}:{isCanvasOpen:!1,...Un(r,"canvas")})},setRunPanelOpen:n=>{e(r=>n?{...Ct("isRunPanelOpen"),...Gt(r,"run")}:{isRunPanelOpen:!1,...Un(r,"run")})},setBrowserPaneOpen:n=>{e(r=>n?{...Ct("isBrowserPaneOpen"),...Gt(r,"browser")}:{isBrowserPaneOpen:!1,...Un(r,"browser")})},setConsolePaneOpen:n=>{e(r=>n?{...Ct("isConsolePaneOpen"),...Gt(r,"console")}:{isConsolePaneOpen:!1,...Un(r,"console")})},setCodeReviewPaneOpen:n=>{e(r=>n?{...Ct("isCodeReviewPaneOpen"),...Gt(r,"code")}:{isCodeReviewPaneOpen:!1,...Un(r,"code")})},clearCodeReviewReveal:n=>{e(r=>r.codeReviewReveal?.nonce===n?{codeReviewReveal:null}:{})},revealCodeReviewPane:()=>{e(n=>({...Ct("isCodeReviewPaneOpen"),...Gt(n,"code"),codeReviewReveal:{nonce:(n.codeReviewReveal?.nonce??0)+1}}))},setAskDrawerOpen:(n,r,s)=>{e(i=>{const a=typeof i.rightSlotKey=="string";if(n)return{...Ct("isAskDrawerOpen"),askDrawerScope:r,askDrawerEvictedPane:a?null:fS(i),askOpenIntent:null};const l={isAskDrawerOpen:!1,askDrawerEvictedPane:null,askOpenIntent:null};return a?s?.dismissSlot?{...l,...pS(i)}:{...l,...ql(i.rightSlotMemory,i.rightSlotKey,!1)}:i.rightSlotKey===null?s?.dismissSlot?{...l,rightSlotLegacySeed:null}:l:s?.dismissSlot?{...l,rightSlotLegacySeed:null}:{...l,...i.askDrawerEvictedPane===null?null:{[i.askDrawerEvictedPane]:!0}}})},requestAskOpen:(n,r="menu")=>{e({askOpenIntent:{scope:n,via:r}})},clearAskOpenIntent:n=>{e(r=>r.askOpenIntent?.scope===n?{askOpenIntent:null}:{})},setConsoleActiveSurface:n=>{e({consoleActiveSurface:n})},requestConsoleOpen:n=>{e({consoleOpenIntent:n})},clearConsoleOpenIntent:n=>{e(r=>r.consoleOpenIntent===n?{consoleOpenIntent:null}:{})},setConsoleLiveSurface:(n,r)=>{e(s=>{if(n===null||r<=0)return s.consoleLiveSurface===null?{}:{consoleLiveSurface:null};const i=s.consoleLiveSurface;return i?.sessionId===n&&i.count===r?{}:{consoleLiveSurface:{sessionId:n,count:r}}})},markConsoleUnseen:(n,r)=>{e(s=>s.consoleUnseen.some(i=>i.surface===r)?{}:{consoleUnseen:[...s.consoleUnseen,{sessionId:n,surface:r,at:Date.now()}]})},clearConsoleUnseen:n=>{const r=Array.isArray(n)?n:[n];e(s=>{const i=s.consoleUnseen.filter(a=>!r.includes(a.surface));return i.length===s.consoleUnseen.length?{}:{consoleUnseen:i}})},setRightSlotWidth:n=>{e({rightSlotWidth:n})},restoreDefaultRightSlotWidth:()=>{e({rightSlotWidth:0})},bindRightSlotKey:(n,r)=>{e(s=>{let i=s.rightSlotMemory,a=s.rightSlotLegacySeed;const l=r?.admittedFrom;return typeof l=="string"&&typeof n=="string"&&(i=cS(i,l,n)),n===null||(Uo(n)?a=null:a!==null&&Rr(i,n)===void 0&&(i=Uu(i,n,a),a=null)),{rightSlotKey:n,rightSlotMemory:i,rightSlotLegacySeed:a,...ql(i,n,s.isAskDrawerOpen)}})},setRightSlotRoute:n=>{const r=t().rightSlotRoute;r.mounted===n.mounted&&r.session===n.session||e({rightSlotRoute:{...n}})},setShortcutBinding:(n,r)=>{if(r===null){e(i=>{const a={...i.shortcutBindings};return delete a[n],{shortcutBindings:a}});return}const s=$o(r);s!==null&&sS(s,n,t().shortcutBindings)===null&&e(i=>({shortcutBindings:{...i.shortcutBindings,[n]:s}}))},clearShortcutBinding:n=>{e(r=>({shortcutBindings:{...r.shortcutBindings,[n]:null}}))},setBrowserPaneScope:n=>{e({browserPaneScope:n})},revealRunPanelSection:n=>{e(r=>({...Ct("isRunPanelOpen"),...Gt(r,"run"),runPanelReveal:{section:n,nonce:(r.runPanelReveal?.nonce??0)+1}}))},clearRunPanelReveal:n=>{e(r=>r.runPanelReveal?.nonce===n?{runPanelReveal:null}:{})},setChatSidebarWidth:n=>{e({chatSidebarWidth:Math.min(Iu,Math.max(Eu,n))})},setChatSidebarRegions:n=>{e({chatSidebarRegions:n})},setChatSidebarListHeight:n=>{e({chatSidebarListHeight:n})},restoreDefaultChatSidebarListHeight:()=>{e({chatSidebarListHeight:null})},setChatSidebarOrder:n=>{e({chatSidebarOrder:n})},setChatSidebarView:n=>{e({chatSidebarView:n})},dismissBuiltinOffer:n=>{e({dismissedBuiltinOfferSignature:n})},restoreDefaultChatSidebarWidth:()=>{e({chatSidebarWidth:tc})},rememberMention:(n,r)=>{e(s=>{const i=s.mentionRecents,a=i?.cwd===n?i.paths:[],l=[r,...a.filter(c=>c!==r)].slice(0,mS);return{mentionRecents:{cwd:n,paths:l}}})},rememberProfile:(n,r)=>{e(s=>({profileRecents:{...s.profileRecents,[n]:RS(s.profileRecents[n]??[],r)}}))},rememberConversation:n=>{e(r=>{const s=xS(r.conversationRecents),i=ES(s,n);return i.length===s.length&&i.every((a,l)=>a===s[l])?r:{conversationRecents:i}})}}),{name:"ui-preferences-storage",version:SS,migrate:OS,partialize:TS,merge:AS}));function RS(e,t){return[t,...e.filter(n=>n!==t)].slice(0,gS)}function ES(e,t){return[t,...e.filter(n=>n!==t)].slice(0,yS)}const IS=[];function xS(e){return Array.isArray(e)?e:IS}function TS(e){const{runPanelReveal:t,codeReviewReveal:n,consoleOpenIntent:r,consoleLiveSurface:s,askOpenIntent:i,isAskDrawerOpen:a,askDrawerScope:l,askDrawerEvictedPane:c,rightSlotRoute:d,isCanvasOpen:u,isRunPanelOpen:f,isBrowserPaneOpen:p,isConsolePaneOpen:h,isCodeReviewPaneOpen:g,rightSlotKey:m,...y}=e;return{...y,rightSlotMemory:CS(e.rightSlotMemory)}}function CS(e){return(e??Fu).filter(([t])=>!Uo(t))}function AS(e,t){const n=e??{},{isCanvasOpen:r,isRunPanelOpen:s,isBrowserPaneOpen:i,isConsolePaneOpen:a,isCodeReviewPaneOpen:l,...c}=n;return{...t,...c,finderFiles:No(n.finderFiles),rightSlotKey:t.rightSlotKey,rightSlotMemory:dS(n.rightSlotMemory),rightSlotLegacySeed:$u(n.rightSlotLegacySeed)?n.rightSlotLegacySeed:null,shortcutBindings:iS(n.shortcutBindings)}}function OS(e,t){const n={...e??{}};if(t<1&&PS(n),t<2)for(const r of kS)delete n[r];if(t<3){let r=null;for(const s of Ji)if(n[ec(s)]===!0){r=s;break}r!==null&&(n.rightSlotLegacySeed=r);for(const s of Ji)delete n[ec(s)]}return t<4&&(n.finderFiles=No(n.finderFiles)),n}function PS(e){const t=[["canvasWidth",800],["runPanelWidth",420],["browserPanelWidth",640],["consolePanelWidth",796]];let n=0;for(const[r,s]of t){const i=e[r];if(typeof i=="number"&&i>0&&i!==s){n=i;break}}for(const[r]of t)delete e[r];e.rightSlotWidth=n}const Bu={settings:["desktop","settings"],capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"],catalogue:["desktop","models"],credentials:e=>["desktop","credentials",e]},jS=3e4,MS=15e3;function DS(e){return e?.desktop_available===!0}function YI(){const{client:e,provided:t}=u0();return fu({enabled:t,queryKey:Bu.capabilities,queryFn:async()=>{try{return await xe({op:"capabilities"})}catch(n){throw n instanceof Error?n:new Error(String(n))}},staleTime:6e4,retry:!1,refetchInterval:n=>DS(n.state.data)?jS:MS,refetchIntervalInBackground:!0},e)}function NS(e,t,n=1){return e?e.desktop_available?(e.features?.[t]??0)>=n?"enabled":"below-version":"unpaired":"unknown"}function QI(e,t,n=1){return NS(e,t,n)==="enabled"}function JI(e){return fu({queryKey:Bu.providers,queryFn:()=>xe({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:i0})}const Xi=e=>e.replace(/\\/g,"/"),XI=()=>window.location.hash?Xi(window.location.hash.substring(1)):Xi(window.location.pathname),qI=(e,t)=>{if(t!==null&&(e===t||e.startsWith(`${t}/`)||e.startsWith(`${t}\\`))){const r=e.substring(t.length);return r.startsWith("/")||r.startsWith("\\")||r===""?`~${r.replace(/\\/g,"/")}`:`~/${r.replace(/\\/g,"/")}`}return e==="~"?"~":e.replace(/\\/g,"/")},ex=(e,t)=>{if(e.length<=t)return e;const n=e.split("/"),r=n[n.length-1]??"";if(r.length+1>=t)return`…${r.slice(-39)}`;const s=n[0]==="~"||n[0]==="",i=s?n.slice(0,2):n.slice(0,1),a=n.slice(i.length),l=g=>{const m=t-g.length-(g?3:2);let y=[];for(let _=a.length-1;_>=0;_-=1){const v=[a[_],...y];if(v.join("/").length>m)break;y=v}return y},c=(g,m)=>g?`${g}/…/${m.join("/")}`:`…/${m.join("/")}`,d=i.join("/"),u=l(d);if(u.length>0)return u.length===a.length?e:c(d,u);const f=s?n[0]:"",p=l(f);if(p.length>0)return c(f,p);const h=t-(f?`${f}/…/`.length:2);return h>0?c(f,[r.slice(-h)]):"…"},tx=(e,t)=>Xi(e).includes(t);export{xS as $,KI as A,We as B,Y0 as C,ye as D,$w as E,UE as F,dE as G,Fd as H,iE as I,Bd as J,oE as K,cE as L,sE as M,lE as N,NS as O,xa as P,Qb as Q,aE as R,Ue as S,BE as T,Hd as U,XI as V,Yd as W,kE as X,RE as Y,ws as Z,rI as _,YI as a,W_ as a$,_r as a0,YR as a1,t0 as a2,Bu as a3,ms as a4,Fp as a5,JE as a6,uk as a7,Qp as a8,Jp as a9,lw as aA,iw as aB,ow as aC,Gl as aD,dw as aE,Hl as aF,cw as aG,aw as aH,tx as aI,FS as aJ,US as aK,$S as aL,BS as aM,hp as aN,st as aO,Yn as aP,Qh as aQ,WI as aR,UI as aS,Je as aT,ZR as aU,$t as aV,da as aW,to as aX,nh as aY,ps as aZ,yc as a_,ja as aa,ZS as ab,zS as ac,GS as ad,xR as ae,wR as af,kR as ag,RR as ah,Pd as ai,ks as aj,Rs as ak,Lu as al,sS as am,tg as an,pb as ao,XE as ap,Qi as aq,DI as ar,PE as as,Sb as at,wb as au,Sr as av,Pe as aw,ru as ax,ew as ay,rw as az,VE as b,mI as b$,rE as b0,X as b1,fn as b2,nE as b3,ji as b4,Mi as b5,eE as b6,tE as b7,QR as b8,JR as b9,lI as bA,EI as bB,II as bC,xI as bD,pE as bE,uE as bF,Qd as bG,OE as bH,TI as bI,vI as bJ,_I as bK,bn as bL,pn as bM,oI as bN,ju as bO,uI as bP,kI as bQ,yr as bR,SI as bS,RI as bT,gI as bU,yI as bV,Pl as bW,pI as bX,fI as bY,hI as bZ,x0 as b_,XR as ba,FI as bb,VI as bc,bS as bd,ZI as be,s0 as bf,QE as bg,YE as bh,KE as bi,Rc as bj,ok as bk,qS as bl,vb as bm,Ec as bn,Xi as bo,em as bp,yp as bq,jE as br,vp as bs,Mo as bt,nk as bu,Cl as bv,ak as bw,fb as bx,L0 as by,Ql as bz,QI as c,q_ as c$,cI as c0,bI as c1,wI as c2,E0 as c3,fE as c4,Ss as c5,aI as c6,EE as c7,iI as c8,dI as c9,_S as cA,Yl as cB,xu as cC,Sm as cD,vR as cE,_R as cF,xE as cG,IE as cH,TE as cI,AE as cJ,CE as cK,hk as cL,wr as cM,ku as cN,ZE as cO,Ro as cP,VR as cQ,TR as cR,Vd as cS,ob as cT,_s as cU,bE as cV,wE as cW,Am as cX,KR as cY,OR as cZ,T_ as c_,CI as ca,AI as cb,PI as cc,jI as cd,W0 as ce,OI as cf,MI as cg,HS as ch,sI as ci,qI as cj,ex as ck,NI as cl,zE as cm,Mv as cn,pk as co,HI as cp,hS as cq,GI as cr,qE as cs,Cu as ct,Au as cu,ik as cv,sk as cw,nc as cx,Fn as cy,vS as cz,xe as d,Av as d$,Zd as d0,J_ as d1,Tl as d2,hE as d3,h0 as d4,_E as d5,qR as d6,YS as d7,QS as d8,dk as d9,FE as dA,GE as dB,ck as dC,fk as dD,Ze as dE,db as dF,u0 as dG,kc as dH,zI as dI,eI as dJ,tI as dK,l0 as dL,Ki as dM,Tu as dN,Iu as dO,Eu as dP,JS as dQ,ha as dR,Mh as dS,XS as dT,Sp as dU,$R as dV,UR as dW,VS as dX,KS as dY,LR as dZ,jd as d_,o as da,$I as db,Ut as dc,Qt as dd,gi as de,nI as df,HE as dg,e0 as dh,Ou as di,Hb as dj,K0 as dk,NE as dl,Uo as dm,BI as dn,Ng as dp,$i as dq,pr as dr,Vb as ds,sw as dt,rn as du,gu as dv,$E as dw,Fw as dx,pu as dy,LE as dz,JI as e,$k as e$,ld as e0,Du as e1,Wc as e2,Lh as e3,ek as e4,bR as e5,SR as e6,AR as e7,CR as e8,ER as e9,dR as eA,ry as eB,Vs as eC,lR as eD,ay as eE,rR as eF,Kk as eG,tR as eH,pR as eI,Vk as eJ,nR as eK,iR as eL,mR as eM,hR as eN,sR as eO,Yk as eP,Qk as eQ,Jk as eR,Xk as eS,qk as eT,eR as eU,fR as eV,_p as eW,bp as eX,wp as eY,km as eZ,Dc as e_,mn as ea,rk as eb,lk as ec,tk as ed,Oc as ee,en as ef,Ot as eg,zk as eh,Zk as ei,Hk as ej,Gk as ek,Nk as el,zc as em,Fk as en,Ok as eo,Pk as ep,Mk as eq,gR as er,Dm as es,Bk as et,oy as eu,cR as ev,nd as ew,uR as ex,oR as ey,aR as ez,ME as f,Hc as f0,Fc as f1,Ik as f2,ga as f3,$o as f4,V0 as f5,Dk as f6,mg as f7,Uk as f8,Wk as f9,jR as fA,cr as fB,oo as fC,fm as fD,pm as fE,gp as fF,yk as fG,_k as fH,Ha as fI,gk as fJ,mk as fK,vk as fL,bc as fM,bk as fN,wk as fO,yE as fP,PR as fQ,NR as fR,MR as fS,DR as fT,mE as fU,gE as fV,Sk as fW,ma as fX,Lk as fa,vg as fb,Rk as fc,Gm as fd,xk as fe,Tk as ff,Ak as fg,Ck as fh,jk as fi,yR as fj,GR as fk,FR as fl,Hv as fm,WR as fn,BR as fo,HR as fp,zR as fq,kk as fr,Ek as fs,hs as ft,eo as fu,_i as fv,xp as fw,Yb as fx,IR as fy,Xs as fz,uw as g,DE as h,Ul as i,n0 as j,no as k,fu as l,Np as m,Lp as n,$p as o,WS as p,Up as q,i0 as r,LI as s,WE as t,qb as u,vE as v,Qe as w,SE as x,rb as y,tb as z};
|
|
58
|
+
*/function gr(){return gr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gr.apply(this,arguments)}const jo=b.createContext(null),Lw=b.createContext(null),rn=b.createContext(null),bs=b.createContext(null),Rt=b.createContext({outlet:null,matches:[],isDataRoute:!1}),vu=b.createContext(null);function $E(e,t){let{relative:n}=t===void 0?{}:t;In()||ke(!1);let{basename:r,navigator:s}=b.useContext(rn),{hash:i,pathname:a,search:l}=Fw(e,{relative:n}),c=a;return r!=="/"&&(c=a==="/"?r:jt([r,a])),s.createHref({pathname:c,search:l,hash:i})}function In(){return b.useContext(bs)!=null}function ws(){return In()||ke(!1),b.useContext(bs).location}function _u(e){b.useContext(rn).static||b.useLayoutEffect(e)}function $w(){let{isDataRoute:e}=b.useContext(Rt);return e?Xw():Uw()}function Uw(){In()||ke(!1);let e=b.useContext(jo),{basename:t,future:n,navigator:r}=b.useContext(rn),{matches:s}=b.useContext(Rt),{pathname:i}=ws(),a=JSON.stringify(Oo(s,n.v7_relativeSplatPath)),l=b.useRef(!1);return _u(()=>{l.current=!0}),b.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){r.go(d);return}let f=Po(d,JSON.parse(a),i,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:jt([t,f.pathname])),(u.replace?r.replace:r.push)(f,u.state,u)},[t,r,a,i,e])}function UE(){let{matches:e}=b.useContext(Rt),t=e[e.length-1];return t?t.params:{}}function Fw(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=b.useContext(rn),{matches:s}=b.useContext(Rt),{pathname:i}=ws(),a=JSON.stringify(Oo(s,r.v7_relativeSplatPath));return b.useMemo(()=>Po(e,JSON.parse(a),i,n==="path"),[e,a,i,n])}function Bw(e,t){return Gw(e,t)}function Gw(e,t,n,r){In()||ke(!1);let{navigator:s,static:i}=b.useContext(rn),{matches:a}=b.useContext(Rt),l=a[a.length-1],c=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=ws(),f;if(t){var p;let _=typeof t=="string"?nn(t):t;d==="/"||(p=_.pathname)!=null&&p.startsWith(d)||ke(!1),f=_}else f=u;let h=f.pathname||"/",g=h;if(d!=="/"){let _=d.replace(/^\//,"").split("/");g="/"+h.replace(/^\//,"").split("/").slice(_.length).join("/")}let m=hw(e,{pathname:g}),y=Vw(m&&m.map(_=>Object.assign({},_,{params:Object.assign({},c,_.params),pathname:jt([d,s.encodeLocation?s.encodeLocation(_.pathname).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?d:jt([d,s.encodeLocation?s.encodeLocation(_.pathnameBase).pathname:_.pathnameBase])})),a,n,r);return t&&y?b.createElement(bs.Provider,{value:{location:gr({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:At.Pop}},y):y}function Hw(){let e=Jw(),t=Dw(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},t),n?b.createElement("pre",{style:s},n):null,null)}const Ww=b.createElement(Hw,null);class zw extends b.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?b.createElement(Rt.Provider,{value:this.props.routeContext},b.createElement(vu.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Zw(e){let{routeContext:t,match:n,children:r}=e,s=b.useContext(jo);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(Rt.Provider,{value:t},r)}function Vw(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,l=(s=n)==null?void 0:s.errors;if(l!=null){let u=a.findIndex(f=>f.route.id&&l?.[f.route.id]!==void 0);u>=0||ke(!1),a=a.slice(0,Math.min(a.length,u+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let u=0;u<a.length;u++){let f=a[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(d=u),f.route.id){let{loaderData:p,errors:h}=n,g=f.route.loader&&p[f.route.id]===void 0&&(!h||h[f.route.id]===void 0);if(f.route.lazy||g){c=!0,d>=0?a=a.slice(0,d+1):a=[a[0]];break}}}return a.reduceRight((u,f,p)=>{let h,g=!1,m=null,y=null;n&&(h=l&&f.route.id?l[f.route.id]:void 0,m=f.route.errorElement||Ww,c&&(d<0&&p===0?(qw("route-fallback"),g=!0,y=null):d===p&&(g=!0,y=f.route.hydrateFallbackElement||null)));let _=t.concat(a.slice(0,p+1)),v=()=>{let I;return h?I=m:g?I=y:f.route.Component?I=b.createElement(f.route.Component,null):f.route.element?I=f.route.element:I=u,b.createElement(Zw,{match:f,routeContext:{outlet:u,matches:_,isDataRoute:n!=null},children:I})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?b.createElement(zw,{location:n.location,revalidation:n.revalidation,component:m,error:h,children:v(),routeContext:{outlet:null,matches:_,isDataRoute:!0}}):v()},null)}var bu=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(bu||{}),wu=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(wu||{});function Kw(e){let t=b.useContext(jo);return t||ke(!1),t}function Yw(e){let t=b.useContext(Lw);return t||ke(!1),t}function Qw(e){let t=b.useContext(Rt);return t||ke(!1),t}function Su(e){let t=Qw(),n=t.matches[t.matches.length-1];return n.route.id||ke(!1),n.route.id}function Jw(){var e;let t=b.useContext(vu),n=Yw(),r=Su();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Xw(){let{router:e}=Kw(bu.UseNavigateStable),t=Su(wu.UseNavigateStable),n=b.useRef(!1);return _u(()=>{n.current=!0}),b.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,gr({fromRouteId:t},i)))},[e,t])}const Kl={};function qw(e,t,n){Kl[e]||(Kl[e]=!0)}function FE(e,t){e?.v7_startTransition,e?.v7_relativeSplatPath}function BE(e){let{to:t,replace:n,state:r,relative:s}=e;In()||ke(!1);let{future:i,static:a}=b.useContext(rn),{matches:l}=b.useContext(Rt),{pathname:c}=ws(),d=$w(),u=Po(t,Oo(l,i.v7_relativeSplatPath),c,s==="path"),f=JSON.stringify(u);return b.useEffect(()=>d(JSON.parse(f),{replace:n,state:r,relative:s}),[d,f,s,n,r]),null}function e0(e){ke(!1)}function GE(e){let{basename:t="/",children:n=null,location:r,navigationType:s=At.Pop,navigator:i,static:a=!1,future:l}=e;In()&&ke(!1);let c=t.replace(/^\/*/,"/"),d=b.useMemo(()=>({basename:c,navigator:i,static:a,future:gr({v7_relativeSplatPath:!1},l)}),[c,l,i,a]);typeof r=="string"&&(r=nn(r));let{pathname:u="/",search:f="",hash:p="",state:h=null,key:g="default"}=r,m=b.useMemo(()=>{let y=gu(u,c);return y==null?null:{location:{pathname:y,search:f,hash:p,state:h,key:g},navigationType:s}},[c,u,f,p,h,g,s]);return m==null?null:b.createElement(rn.Provider,{value:d},b.createElement(bs.Provider,{children:n,value:m}))}function HE(e){let{children:t,location:n}=e;return Bw(zi(t),n)}new Promise(()=>{});function zi(e,t){t===void 0&&(t=[]);let n=[];return b.Children.forEach(e,(r,s)=>{if(!b.isValidElement(r))return;let i=[...t,s];if(r.type===b.Fragment){n.push.apply(n,zi(r.props.children,i));return}r.type!==e0&&ke(!1),!r.props.index||!r.props.children||ke(!1);let a={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=zi(r.props.children,i)),n.push(a)}),n}function WE(e){return e!=="detached"&&e!=="wedged"}function ku(e){return e!=="governed-elsewhere"&&e!=="pre-handshake"}function zE(e){if(!e)return{title:"Not connected to a Local Operator server.",detail:null,retry:!0};const t=e.addressSubstitution??null;if(t&&e.state!=="detached"&&e.state!=="wedged")return t.kind==="substituted"?{title:`Serving on ${t.serving}, not the address this app is configured for.`,detail:t.holder?`${t.holder}. The app uses ${t.serving} while that holds.${t.reclaim?` ${t.reclaim}`:""} It is back on ${t.configured} on its next launch or recovery.`:`The daemon this app is using was already running, so it did not start one. It looks for ${t.configured} again on its next launch or recovery.`,retry:!0}:{title:`Back on ${t.configured}, the address this app is configured for.`,detail:`It served on ${t.serving} while the configured address was held; it is on the address it was told to use again.`,retry:!1,dismiss:!0};const n=e.detail?.trim()?e.detail.trim():null,r=ku(e.pairing?.cause??null);switch(e.state){case"wedged":return{title:"A Local Operator server is running on this machine and this app is not attached to it.",detail:n,retry:r};case"detached":return e.reconnecting?{title:r?"Not connected to a Local Operator server. If one is still running, the app reconnects to it on its own.":"Not connected to a Local Operator server.",detail:n,retry:r}:{title:r?"The Local Operator server stopped. The app keeps looking for one and attaches to it when it appears.":"Not connected to a Local Operator server. The app keeps looking for one.",detail:n,retry:r};default:return null}}function t0(e){if(em(e))return"deadline";const t=e instanceof ye?e.status:null;return t===null||t===503?"unreachable":t===401||t===403?"unauthorized":t===404?"outdated":"unknown"}const Ru={unreachable:"",deadline:"",unauthorized:"",outdated:"Update the server and try again.",unknown:""},Zi={unreachable:"The Local Operator server is not answering.",deadline:"The Local Operator server did not answer in time.",unauthorized:"This app cannot authenticate to the running Local Operator server.",outdated:"The Local Operator server is older than this app expects.",unknown:""};function n0(e,t){const n=t0(t);return[e,Zi[n],Ru[n]].filter(Boolean).join(" ")}const Vi={successor:"The Local Operator server was replaced while this app was running. Pairing with the new one.","governed-elsewhere":"The Local Operator server on this machine is already managed by another program, so this app cannot use its settings, provider sign-in, slash commands or MCP management.","pre-handshake":"The Local Operator server on this machine is older than the pairing handshake this app uses, so this app cannot drive its controls. The server itself, and anything you run against it from the terminal, are unaffected.","credential-refused":"This app's credential for the running Local Operator server was refused, so provider sign-in, settings, slash commands and MCP management are unavailable.",unpaired:"This app is not paired with the running Local Operator server, so provider sign-in, settings, slash commands and MCP management are unavailable."},r0={successor:"This conversation cannot be read here until the app finishes pairing with the replacement server. Your chats are still on that server.","governed-elsewhere":"This conversation cannot be read here: the server's desktop controls belong to another program. Your chats are still on that server.","pre-handshake":"This conversation cannot be read here: that server is older than the pairing handshake this app uses. Your chats are still on that server.","credential-refused":"This conversation cannot be read here: the server refused this app's credential. Your chats are still on that server.",unpaired:"This conversation cannot be read here: the app is not paired with the running server. Your chats are still on that server."};function ZE(e,t){return e!=="unpaired"?null:r0[t??"unpaired"]}function VE(e,t){return e!=="unpaired"?null:Vi[t??"unpaired"]}function KE(e){const{kind:t,unpaired:n,answered:r,cause:s=null,servedByThisApp:i=!1}=e;return s==="pre-handshake"?i:s!==null||n?!1:r?i:t==="outdated"}function YE(e){const{kind:t,unpaired:n,missing:r,answered:s,cause:i=null}=e;if(i!==null)return Vi[i];if(!s){if(t==="unreachable")return`${Zi.unreachable} Provider sign-in, settings, slash commands and MCP management need it running.`;if(t==="unauthorized")return"This app cannot authenticate to the running Local Operator server, so provider sign-in, settings, slash commands and MCP management are unavailable.";if(t==="deadline")return`${Zi.deadline} Provider sign-in, settings, slash commands and MCP management need it answering.`;if(t==="outdated")return`The Local Operator server is older than this app expects, so provider sign-in, settings, slash commands and MCP management are off. ${Ru.outdated}`}return n?Vi.unpaired:s?`The Local Operator server is missing ${r.join(", ")} support. Update it to enable those surfaces.`:"Provider sign-in, settings, slash commands and MCP management are unavailable because the Local Operator server did not answer as expected."}const s0=["auth","settings","commands","catalogues","lifecycle","mcp","radient"];function QE(e,t=null){return t!==null||!e?!0:s0.filter(r=>(e.features?.[r]??0)<1).length>0||e.desktop_available!==!0}function i0(e,t){return t instanceof ye&&t.status===null?!1:e<1}function JE(e,t){return t instanceof ye&&t.status!==null&&t.status>=400&&t.status<500&&t.status!==408&&t.status!==425&&t.status!==429?!1:e<1}const o0={successor:"Your settings could not be loaded: the app is pairing with the server that replaced the one it was using.","governed-elsewhere":"Your settings could not be loaded: another program is managing this machine's Local Operator server, so this page cannot read or change them here.","pre-handshake":"Your settings could not be loaded: the server this app is talking to is older than the pairing handshake, so this page cannot read them from it.","credential-refused":"Your settings could not be loaded: the server refused this app's credential, so this page cannot read them from it.",unpaired:"Your settings could not be loaded: this app is not paired with the running server, so this page cannot read them from it."};function XE(e,t,n){return e===null?{sentence:n0(t,n),remedy:!0}:{sentence:o0[e],remedy:ku(e)}}const kr=260,Eu=220,Iu=320,Ki=56,a0=kr,l0=1024,xu=480,Tu=44,Cu=400,c0=560;function Au(e){return Math.max(0,Math.min(c0,e-xu))}function Yl(e){return Au(e)>=Cu?"docked":"overlay"}function qE({capacity:e,min:t,max:n,drawn:r}){const s=e>=t;return s?{resizable:s,value:Math.min(Math.max(r,t),e),minWidth:t,maxWidth:Math.min(n,e)}:{resizable:s,value:r,minWidth:r,maxWidth:r}}function d0(e,t=kr,n=Tu){return Yl(e-Ou(t)-n)==="overlay"&&Yl(e-Ki-n)==="docked"}function Ou(e){return Number.isNaN(e)?kr:Math.min(Iu,Math.max(Eu,e))}function eI(e,t,n,r=kr,s=!1,i=Tu){if(e>=l0){const l=!t&&s&&d0(e,r,i);return{mode:t||l?"strip":"docked",width:t||l?Ki:Ou(r),collapsed:t||l,sheetOpen:!1,resizable:!t&&!l}}return{mode:n?"overlay":"strip",width:n?a0:Ki,collapsed:!0,sheetOpen:n,resizable:!1}}function tI(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="b"}const nI=e=>e?"⌘B":"Ctrl+B",u0=()=>{const e=b.useContext(Co)??null,t=b.useMemo(()=>new Yb({defaultOptions:{queries:{enabled:!1,retry:!1}}}),[]);return b.useMemo(()=>e?{client:e,provided:!0}:{client:t,provided:!1},[e,t])},f0="data-canvas-shortcuts",p0=`[${f0}]`,h0=e=>Pu(e,p0),m0='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]',rI=e=>Pu(e,m0);function Pu(e,t){const n=e;return typeof n?.closest=="function"?n.closest(t)!==null:!1}const sI=e=>{if(!(e.metaKey||e.ctrlKey))return null;const t=e.key.toLowerCase();return t==="o"?"open-file":t==="n"&&h0(e.target)?"new-file":null},g0=["active","created"],iI={running:"Running",today:"Today",week:"This week",older:"Older"},y0=new Set(["waiting","busy","delegating","approval","answer","wedged"]);function Ss(e){return y0.has(e.status?.code??"")}const v0=new Set(["approval","answer"]);function _0(e){return v0.has(e.status?.code??"")}const b0=24*60*60*1e3,w0=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function Mo(e,t){const n=t==="created"?e.created_at:e.updated_at;return typeof n!="number"||!Number.isFinite(n)||n<=0?null:n*1e3}const S0="last_user_at";function k0(e){const t=e[S0],n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:e.created_at;return typeof n!="number"||!Number.isFinite(n)||n<=0?null:n*1e3}function R0(e,t,n){if(Ss(e))return"running";const r=Mo(e,n);if(r===null)return"older";const s=w0(t);return r>=s?"today":r>=s-6*b0?"week":"older"}function oI(e,t,n){const r={running:[],today:[],week:[],older:[]};for(const s of e)r[R0(s,t,n)].push(s);return r}function E0(e,t,n){const r=Mo(e,n);if(r===null)return"";const s=Math.floor(Math.max(0,t-r)/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const a=Math.floor(i/24);if(a<7)return`${a}d`;const l=Math.floor(a/7);return a<365?`${l}w`:`${Math.floor(a/365)}y`}function aI(e,t,n){const r=E0(e,t,n);if(!r)return"";const s=n==="created"?"created":"last active";if(r==="now")return`${s} just now`;const i={m:"minute",h:"hour",d:"day",w:"week",y:"year"},a=Number.parseInt(r,10),l=i[r.slice(-1)];return`${s} ${a} ${l}${a===1?"":"s"} ago`}const Yi=["pinned","running","today","week","older","agents","teams"];function lI(e){return e==="agents"||e==="teams"}const yr=8;function I0(e,t){if(!(t in e))return e;const n={...e};return delete n[t],n}function cI(e,t){return{...e,[t]:(e[t]??yr)+yr}}function dI(e,t,n,r,s){const i=!(e[n]??r);return{expanded:{...e,[n]:i},caps:!i&&!s?I0(t,n):t}}function uI(e,t,n,r){return(e||t!=="")&&(r>yr||n.trim()!=="")}const fI="Collapse, then reopen, to restore the compact list";function pI(e){return(e??yr)>yr}const hI=e=>`section-grown-hint-${e}`,x0=e=>e===1?"Show 1 more":`Show ${e} more`;function mI(e,t){return`${x0(e)} ${t}`}const pn={hidden:[],order:[...Yi],pins:[],groupBy:"section",tagsEnabled:!1,autoTagForks:!0,basis:"active",orderBy:"active-first",loads:0,pinnedAgents:[]},T0=10,$n=[25,50],C0=50,A0=500,O0=64;function bn(e){const t=Math.max(0,Math.floor(e));return t===0?T0:t<=$n.length?$n[t-1]:$n[$n.length-1]+(t-$n.length)*C0}function gI(e,t){const n=bn(e+1)-bn(e),r=Math.max(0,Math.min(n,t));return r===1?"Show 1 more chat":`Show ${r} more chats`}function yI(e,t,n){const r=bn(t+1)-bn(t),s=bn(t),i=Math.min(s+r,e.length);let a=0;for(let c=s;c<i;c+=1)Do(e[c])&&(a+=1);const l=Math.max(0,i-s-a);return l>0?l:Math.max(0,Math.min(r,n))}function Do(e){return Ss(e)}function P0(e){return _0(e)?0:Ss(e)?1:2}function j0(e,t){return Ss(e)?k0(e):Mo(e,t)}function M0(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:t-e}function vI(e,t,n){const r=e.map((s,i)=>({row:s,index:i,lane:t==="active-first"?P0(s):0,at:j0(s,n)}));return r.sort((s,i)=>s.lane-i.lane||M0(s.at,i.at)||s.index-i.index),r.map(s=>s.row)}function _I(e,t){const{limit:n,currentId:r,searching:s=!1}=t;if(s)return{rows:[...e],lifted:!1,remaining:0};const i=[];let a=Math.max(0,n);for(const d of e){if(a>0){i.push(d),a-=1;continue}Do(d)&&i.push(d)}const l=Math.max(0,e.length-i.length);if(!r)return{rows:i,lifted:!1,remaining:l};const c=e.find(d=>d.session_id===r)??null;return c===null||i.includes(c)?{rows:i,lifted:!1,remaining:l}:{rows:[c,...i],lifted:!0,remaining:l}}function bI(e,t){if(t.searching)return{rows:[...e],lifted:!1,hidden:0,held:e.length};const n=bn(t.loads),r=[];let s=n;for(const c of e){if(Do(c)){r.push(c);continue}s>0&&(r.push(c),s-=1)}const i=t.currentId,a=i==null?null:e.find(c=>c.session_id===i)??null,l=a!==null&&!r.includes(a);return{rows:l&&a!==null?[a,...r]:r,lifted:l,hidden:e.length-r.length-(l?1:0),held:e.length}}function wI(e){if(e.add<=0)return null;const t=e.add===1?"Show 1 more chat":`Show ${e.add} more chats`;if(e.drawn>=e.total)return{label:t,aria:t};const n=`${e.drawn} of ${e.total}`;return{label:`${t} · ${n}`,aria:`${t} · ${n} shown`}}const D0="mt-4",N0="mt-2";function SI(e){return e?D0:N0}function kI(e,t,n,r){return n?e.toLocaleLowerCase().includes(n.toLocaleLowerCase())||(r??"").toLocaleLowerCase().includes(n.toLocaleLowerCase())||t>0:!0}function RI(e,t){if(t==="section")return null;if(t==="flat")return[{key:"all",label:"",rows:[...e]}];const n=new Map;for(const i of e){const a=i.binding?.team||i.binding?.agent||"",l=a||"ungrouped",c=n.get(l)??{key:l,label:a||"Ungrouped",rows:[]};c.rows.push(i),n.set(l,c)}const r=[...n.values()],s=r.findIndex(i=>i.key==="ungrouped");return s>0&&r.push(...r.splice(s,1)),r}function L0(e,t){return!e.hidden.includes(t)}function ju(e){return e.order.filter(t=>L0(e,t))}function EI(e,t){const n=e.hidden.includes(t)?e.hidden.filter(r=>r!==t):[...e.hidden,t];return{...e,hidden:n}}function II(e,t,n){const r=ju(e),s=r.indexOf(t),i=r[s+n];if(s<0||i===void 0)return e;const a=e.order.indexOf(t),l=e.order.indexOf(i),c=[...e.order];return c[a]=i,c[l]=t,{...e,order:c}}const $0=["running","today","week","older"];function Ql(e){return $0.includes(e)}function xI(e,t,n,r){if(!Ql(t)||r&&!r(t))return!1;const s=ju(e),i=s.indexOf(t);if(i<0)return!1;const a=s[i+n];return a===void 0||!Ql(a)?!1:r?r(a):!0}const U0=["section","agent","flat"],F0=["active-first","recent"];function TI(e){if(typeof e!="object"||e===null)return pn;const t=e,n=new Set(Yi),r=[];if(Array.isArray(t.order))for(const p of t.order)typeof p=="string"&&n.has(p)&&(r.includes(p)||r.push(p));for(const p of Yi)r.includes(p)||r.push(p);const s=[];if(Array.isArray(t.hidden))for(const p of t.hidden)typeof p=="string"&&n.has(p)&&(s.includes(p)||s.push(p));const i=U0.includes(t.groupBy)?t.groupBy:pn.groupBy,a=g0.includes(t.basis)?t.basis:pn.basis,l=F0.includes(t.orderBy)?t.orderBy:pn.orderBy,c=typeof t.loads=="number"&&Number.isFinite(t.loads)&&t.loads>0?Math.min(A0,Math.floor(t.loads)):0,d=[];if(Array.isArray(t.pinnedAgents)){for(const p of t.pinnedAgents)if(typeof p=="string"&&p!==""&&!d.includes(p)){if(d.length>=O0)break;d.push(p)}}const u=[],f=new Set;if(Array.isArray(t.pins))for(const p of t.pins)typeof p=="string"&&p.length!==0&&(f.has(p)||(f.add(p),u.push(p)));return{hidden:s,order:r,groupBy:i,tagsEnabled:typeof t.tagsEnabled=="boolean"?t.tagsEnabled:!1,autoTagForks:typeof t.autoTagForks=="boolean"?t.autoTagForks:pn.autoTagForks,basis:a,orderBy:l,loads:c,pins:u,pinnedAgents:d}}const Mu={sort:"recent",order:"asc",group:!0,workingOpen:!1,closedSections:[],kinds:[]},B0=["recent","name","kind","modified","created","size"],G0=["images","video","audio","documents","spreadsheets","presentations","code","archives","other"];function No(e){const t=e&&typeof e=="object"?e:{};return{sort:B0.includes(t.sort??"")?t.sort:Mu.sort,order:t.order==="desc"?"desc":"asc",group:typeof t.group=="boolean"?t.group:!0,workingOpen:t.workingOpen===!0,closedSections:Array.isArray(t.closedSections)?[...new Set(t.closedSections.filter(n=>["Highlights","Images","Videos","Sounds","Documents","Spreadsheets","Other"].includes(n)))]:[],kinds:Array.isArray(t.kinds)?[...new Set(t.kinds.filter(n=>G0.includes(n)))]:[]}}function CI(e,t){const n=r=>{switch(t.sort){case"name":return r.row.name;case"kind":return`${r.row.kind}\0${r.row.name}`;case"modified":return r.modified;case"created":return r.created;case"size":return r.row.document.sizeBytes??null;default:return r.mentioned}};return[...e].sort((r,s)=>{const i=n(r),a=n(s);if(i===null||a===null)return i===a?0:i===null?1:-1;const l=typeof i=="string"&&typeof a=="string"?i.localeCompare(a,void 0,{numeric:!0}):Number(i)-Number(a);return(t.order==="asc"?l:-l)||r.mentioned-s.mentioned})}const H0=e=>{switch(e.row.kind){case"images":return"Images";case"video":return"Videos";case"audio":return"Sounds";case"spreadsheets":return"Spreadsheets";case"documents":case"presentations":case"code":return"Documents";default:return"Other"}};function AI(e,t,n,r){const s=e.filter(l=>l.highlighted),i=e.filter(l=>!l.highlighted),a=[];if(s.length&&a.push({id:"Highlights",label:"Highlights",items:s,open:n||!r.has("Highlights"),highlights:!0}),s.length&&i.length&&(a.push({id:"Working files",label:"Working files",items:[],open:t.workingOpen||n,highlights:!1}),!t.workingOpen&&!n))return a;if(!t.group)i.length&&a.push({id:"Files",label:"Files",items:i,open:!0,highlights:!1});else for(const l of["Images","Videos","Sounds","Documents","Spreadsheets","Other"]){const c=i.filter(d=>H0(d)===l);c.length&&a.push({id:l,label:l,items:c,open:n||!r.has(l),highlights:!1})}return a}const W0=32,OI=4;function PI(e,t,n){const r=[],s=new Map,i=Math.max(136,t-16),a=Math.max(1,Math.floor((i+4)/140));let l=0;const c=(d,u,f,p,h=1)=>{p.forEach((g,m)=>s.set(g.row.document.id,{band:r.length,column:m})),r.push({section:d,kind:u,height:f,top:l,items:p,cols:h}),l+=f};for(const d of e)if(c(d,"header",W0,[]),!!d.open)if(d.highlights)for(const u of d.items)c(d,"highlight",u.why?68:44,[u]);else if(n&&d.id==="Images"){const u=(i-4*(a-1))/a,f=Math.round((u-8)*3/4)+32;for(let p=0;p<d.items.length;p+=a)c(d,"tiles",f,d.items.slice(p,p+a),a)}else if(n&&d.id==="Videos")for(const u of d.items)c(d,"video",Math.min(Math.round((i-8)*9/16),280)+32,[u]);else if(n&&d.id==="Sounds")for(const u of d.items)c(d,"audio",80,[u]);else for(const u of d.items)c(d,"compact",36,[u]);return{bands:r,height:l,columns:a,positions:s}}function jI(e,t,n,r){const s=Math.max(600,n*.75);let i=0,a=e.bands.length;for(;i<a;){const d=i+a>>>1,u=e.bands[d];u.top+u.height<t-s?i=d+1:a=d}const l=new Set;for(let d=i;d<e.bands.length&&e.bands[d].top<=t+n+s;d++)l.add(d);const c=r?e.positions.get(r):null;return c&&l.add(c.band),[...l].sort((d,u)=>d-u)}function MI(e,t,n,r){const s=e.positions.get(t);if(!s)return null;const i=e.bands[s.band],a=e.bands.filter(u=>u.section.id===i.section.id&&u.items.length);if(n==="Home")return a[0]?.items[0]?.row.document.id??null;if(n==="End")return a.at(-1)?.items.at(-1)?.row.document.id??null;if(n==="ArrowLeft"||n==="ArrowRight")return i.items[s.column+(n==="ArrowLeft"?-1:1)]?.row.document.id??null;const l=n==="ArrowUp"||n==="PageUp"?-1:1,c=i.top+(n.startsWith("Page")?r*l:l);let d=s.band+l;for(;d>=0&&d<e.bands.length;d+=l){const u=e.bands[d];if(u.items.length&&!(n.startsWith("Page")&&(l>0?u.top<c:u.top>c)))return u.items[Math.min(s.column,u.items.length-1)].row.document.id}if(n.startsWith("Page")){const u=e.bands.filter(p=>p.items.length),f=l<0?u[0]:u.at(-1);return f?.items[l<0?0:f.items.length-1]?.row.document.id??null}return null}const z0="both",Du="by-turn",Qi=[{value:"by-turn",label:"By turn"},{value:"by-response",label:"By response"}];function DI(e){for(const t of Qi)if(e===t.value)return t.value;return Du}function NI(e){return Qi.find(t=>t.value===e)?.label??Qi[0].label}const LI="primary+alt+shift+space",Z0=/^f([1-9]|1[0-9]|2[0-4])$/;function V0(e){return Z0.test(e)}function K0(e,t){const n=Y0(e,t);return t==="mac"?n.join(""):n.join("+")}function Y0(e,t){const r=t==="mac"?{primary:"⌘",meta:"⌘",ctrl:"⌃",alt:"⌥",shift:"⇧"}:{primary:"Ctrl",meta:t==="win"?"Win":"Super",ctrl:"Ctrl",alt:"Alt",shift:"Shift"},s={space:"Space",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",up:"Up",down:"Down",left:"Left",right:"Right"};return e.split("+").map(i=>i.trim().toLowerCase()).filter(i=>i.length>0).map(i=>i in r?r[i]:i in s?s[i]:V0(i)||i.length===1?i.toUpperCase():i)}const ks=[{id:"panel.console",label:"Open console",category:"Panels",defaultChord:"primary+j",scope:"app"},{id:"panel.canvas",label:"Open canvas",category:"Panels",defaultChord:"primary+shift+c",scope:"app"},{id:"panel.run",label:"Open run details",category:"Panels",defaultChord:null,scope:"app"},{id:"panel.ask",label:"Open asks",category:"Panels",defaultChord:null,scope:"app"},{id:"panel.browser",label:"Open browser",category:"Panels",defaultChord:null,scope:"app"},{id:"panel.code",label:"Open code review",category:"Panels",defaultChord:null,scope:"app"}],Q0=new Map(ks.map(e=>[e.id,e])),J0=e=>Q0.get(e),X0=new Set(["primary+0","primary+r","primary+shift+r","primary+t","primary+shift+t","primary+l",...[1,2,3,4,5,6,7,8,9].map(e=>`primary+${e}`)]),Lo=new Map([["primary+p","Reserved: opens the command palette from anywhere."],["primary+shift+p","Reserved: opens the command palette on commands."],["primary+shift+s","Reserved: starts speech to text."],["primary+k","Reserved: opens the command palette on chats."],["primary+n","Reserved: starts a new chat."],["primary+b","Reserved: toggles the sidebar."],["primary+[","Reserved: goes back in the browser, or between chats outside it."],["primary+]","Reserved: goes forward in the browser, or between chats outside it."],["primary+f","Reserved: finds in the browser page, or searches the transcript outside it."],["primary+alt+up","Reserved: walks up the chat regions."],["primary+alt+down","Reserved: walks down the chat regions."],["primary+shift+a","Reserved: archives the focused conversation."],["primary+shift+l","Reserved: opens the focused conversation's tags."],["primary+s","Reserved: saves the canvas document."],["primary+o","Reserved: opens a file in the canvas."],["primary+shift+up","Reserved: moves the focused chat up the pinned order."],["primary+shift+down","Reserved: moves the focused chat down the pinned order."],["primary+c","Reserved: copy."],["primary+x","Reserved: cut."],["primary+v","Reserved: paste."],["primary+a","Reserved: select all."],["primary+z","Reserved: undo."],["primary+shift+z","Reserved: redo."],["primary+y","Reserved: redo on Windows and Linux."],["primary+r","Reserved: reloads the browser page."],["primary+shift+r","Reserved: reloads the browser page, ignoring the cache."],["primary+t","Reserved: opens a new browser tab."],["primary+shift+t","Reserved: reopens the last closed browser tab."],["primary+l","Reserved: focuses the browser address bar."],...[1,2,3,4,5,6,7,8,9].map(e=>[`primary+${e}`,e===9?"Reserved: switches to the last browser tab.":`Reserved: switches to browser tab ${e}.`]),["primary+0","Reserved: resets browser page zoom, or app zoom outside it."],["primary+plus","Reserved: zooms the browser page or app in."],["primary+=","Reserved: zooms the browser page or app in."],["primary+-","Reserved: zooms the browser page or app out."],["primary+q","Reserved: quits the app."],["primary+w","Reserved: closes the browser tab, or the window outside it."],["primary+m","Reserved: minimises the window."]]),q0=["primary","alt","shift"],eS={primary:"primary",meta:"primary",cmd:"primary",command:"primary",super:"primary",ctrl:"primary",control:"primary",alt:"alt",option:"alt",shift:"shift"},tS=new Set(["space","backspace","delete","insert","home","end","pageup","pagedown","up","down","left","right"]),nS=e=>tS.has(e)||/^[a-z0-9]$/.test(e);function $o(e){if(typeof e!="string")return null;const t=e.toLowerCase().split("+").map(i=>i.trim()).filter(i=>i.length>0);if(t.length===0)return null;const n=t[t.length-1];if(!nS(n))return null;const r=new Set;for(const i of t.slice(0,-1)){const a=eS[i];if(a===void 0)return null;r.add(a)}return[...q0.filter(i=>r.has(i)),n].join("+")}const Nu=e=>e.split("+").includes("primary");function Rs(e,t){const n=t?.[e];return n===null?null:typeof n=="string"&&!Lo.has(n)?n:J0(e)?.defaultChord??null}function $I(e){const t=new Map;for(const n of ks){const r=Rs(n.id,e);r!==null&&!t.has(r)&&t.set(r,n.id)}return t}const rS=e=>e==="mac"?"A shortcut needs ⌘ or Ctrl.":"A shortcut needs Ctrl.";function sS(e,t,n,r="linux"){const s=e===null?null:$o(e);if(s===null)return"That key cannot be bound.";if(!Nu(s))return rS(r);const i=Lo.get(s);if(i!==void 0)return i;for(const a of ks)if(a.id!==t&&Rs(a.id,n)===s)return`Already assigned to ${a.label}.`;return null}function iS(e){if(e===null||typeof e!="object"||Array.isArray(e))return{};const t=e,n=new Set,r={};for(const s of ks){const i=t[s.id];if(i===null){r[s.id]=null;continue}const a=typeof i=="string"?$o(i):null,l=a!==null&&X0.has(a),c=a!==null&&Nu(a)&&(l||!Lo.has(a)&&!n.has(a))?a:null;c!==null&&(r[s.id]=c);const d=Rs(s.id,r);d!==null&&n.add(d)}return r}function UI(e,t,n){const r=Rs(e,t);return r===null?null:Lu(r,n)}function Lu(e,t){return K0(e,t)}function FI(e,t){const n=e.split("+"),r=n[n.length-1],s=n.slice(0,-1).map(i=>i==="primary"?t==="mac"?"Meta":"Control":i==="shift"?"Shift":i==="alt"?"Alt":i);return{glyph:Lu(e,t),aria:[...s,r.length===1?r.toUpperCase():r].join("+")}}const Jl=64,Ji=["canvas","run","browser","console","code"],oS={canvas:"isCanvasOpen",run:"isRunPanelOpen",browser:"isBrowserPaneOpen",console:"isConsolePaneOpen",code:"isCodeReviewPaneOpen"};function $u(e){return typeof e=="string"&&Ji.includes(e)}function Uo(e){return e.startsWith("draft:")}function Rr(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r[0]===t)return r[1]}}function Fo(e){return e.length>Jl?e.slice(e.length-Jl):e}function Uu(e,t,n){return Fo([...e.filter(([r])=>r!==t),[t,n]])}function aS(e,t,n){return Rr(e,t)!==n?e:e.filter(([r])=>r!==t)}function lS(e,t){return Rr(e,t)===void 0?e:e.filter(([n])=>n!==t)}function cS(e,t,n){const r=Rr(e,t);return r===void 0?e:Fo([...e.filter(([s])=>s!==t&&s!==n),[n,r]])}const Xl=Object.freeze({isCanvasOpen:!1,isRunPanelOpen:!1,isBrowserPaneOpen:!1,isConsolePaneOpen:!1,isCodeReviewPaneOpen:!1});function ql(e,t,n){if(n||typeof t!="string")return Xl;const r=Rr(e,t);return r===void 0?Xl:{isCanvasOpen:r==="canvas",isRunPanelOpen:r==="run",isBrowserPaneOpen:r==="browser",isConsolePaneOpen:r==="console",isCodeReviewPaneOpen:r==="code"}}function dS(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!Array.isArray(n)||n.length!==2)continue;const[r,s]=n;typeof r!="string"||r===""||Uo(r)||$u(s)&&(t.delete(r),t.set(r,s))}return Fo([...t.entries()])}function BI(e){const t=new Set(Object.keys(e.forgotten));for(const[n,r]of Object.entries(e.archiveFacts))r?.archived===!0&&r.answered===!0&&t.add(n);return t}function ec(e){return oS[e]}const uS={canvas:"isCanvasOpen",run:"isRunPanelOpen",browser:"isBrowserPaneOpen",console:"isConsolePaneOpen",code:"isCodeReviewPaneOpen"},Er=e=>e.isCanvasOpen?"canvas":e.isRunPanelOpen?"run":e.isBrowserPaneOpen?"browser":e.isConsolePaneOpen?"console":e.isCodeReviewPaneOpen?"code":e.isAskDrawerOpen?"ask":null,Es=(e,t)=>e==="ask"?t.askDrawerScope==="fleet"||t.rightSlotRoute.mounted&&t.rightSlotRoute.session:t.rightSlotRoute.mounted,fS=e=>{const t=Er(e);return t===null||t==="ask"?null:uS[t]},Ct=e=>({isRunPanelOpen:e==="isRunPanelOpen",isCanvasOpen:e==="isCanvasOpen",isBrowserPaneOpen:e==="isBrowserPaneOpen",isConsolePaneOpen:e==="isConsolePaneOpen",isCodeReviewPaneOpen:e==="isCodeReviewPaneOpen",isAskDrawerOpen:e==="isAskDrawerOpen",askDrawerEvictedPane:null}),Gt=(e,t)=>{const n=e.rightSlotKey;return typeof n!="string"?{}:{rightSlotMemory:Uu(e.rightSlotMemory,n,t)}},Un=(e,t)=>{const n=e.rightSlotKey;if(typeof n!="string")return{};const r=aS(e.rightSlotMemory,n,t);return r===e.rightSlotMemory?{}:{rightSlotMemory:r}},pS=e=>{const t=e.rightSlotKey;if(typeof t!="string")return{};const n=lS(e.rightSlotMemory,t);return n===e.rightSlotMemory?{}:{rightSlotMemory:n}},hS=Object.freeze({mounted:!1,session:!1}),Fu=Object.freeze([]);function GI(e,t){const n=Er(t);if(n===null||!Es(n,t))return 0;let r;switch(n){case"canvas":case"ask":r=Math.max(Cu,t.rightSlotWidth||Fn);break;case"run":r=Math.max(nc,t.rightSlotWidth||Fn);break;case"browser":r=Math.max(vS,t.rightSlotWidth||Fn);break;case"console":r=Math.max(_S,t.rightSlotWidth||Fn);break;case"code":r=Math.max(nc,t.rightSlotWidth||Fn);break}return e<=0?r:n==="canvas"||n==="ask"?Math.min(r,Au(e)):Math.min(r,Math.max(0,e-xu))}function HI(e){const t=Er(e);return t!==null&&Es(t,e)}function WI(e){const t=Er(e);return t!==null&&Es(t,e)?t:null}function zI(e){const t=Er(e);return(t==="canvas"||t==="ask")&&Es(t,e)}const Fn=640,tc=kr,mS=20,gS=4,yS=20,nc=320,vS=480,_S=480,bS=5e3,ZI=(e,t)=>e.some(n=>n.surface===t),VI=(e,t=Date.now())=>e.some(n=>t-n.at<bS),wS=[],SS=4,kS=["chatMeasureWidth"],KI=_r()(ms((e,t)=>({finderFiles:Mu,setFinderFiles:n=>e({finderFiles:No({...t().finderFiles,...n})}),isCommandPaletteOpen:!1,commandPaletteQuery:"",isSidebarCollapsed:!1,sidebarOverflowExpanded:!1,showAgentReasoning:!1,transcriptDisplayMode:Du,themeName:Qu,rightSlotWidth:0,chatSidebarWidth:tc,chatSidebarRegions:z0,chatSidebarView:pn,chatSidebarListHeight:null,chatSidebarOrder:"entities-first",dismissedBuiltinOfferSignature:"",isCanvasOpen:!1,isRunPanelOpen:!1,isBrowserPaneOpen:!1,isConsolePaneOpen:!1,isCodeReviewPaneOpen:!1,rightSlotKey:void 0,rightSlotMemory:Fu,rightSlotLegacySeed:null,isAskDrawerOpen:!1,askDrawerScope:"session",askDrawerEvictedPane:null,askOpenIntent:null,rightSlotRoute:hS,consoleOpenIntent:null,consoleLiveSurface:null,runPanelReveal:null,codeReviewReveal:null,browserPaneScope:"conversation",consoleActiveSurface:null,consoleUnseen:wS,isCreateAgentDialogOpen:!1,mentionRecents:null,profileRecents:{agent:[],team:[]},conversationRecents:[],shortcutBindings:{},openCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!0})},closeCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!1})},openCommandPalette:()=>{e({isCommandPaletteOpen:!0})},closeCommandPalette:()=>{e({isCommandPaletteOpen:!1,commandPaletteQuery:""})},toggleCommandPalette:(n="")=>{e(r=>({isCommandPaletteOpen:!r.isCommandPaletteOpen,commandPaletteQuery:r.isCommandPaletteOpen?r.commandPaletteQuery:n}))},setCommandPaletteQuery:n=>{e({commandPaletteQuery:n})},toggleSidebar:()=>{e(n=>({isSidebarCollapsed:!n.isSidebarCollapsed}))},setSidebarOverflowExpanded:n=>{e({sidebarOverflowExpanded:n})},setSidebarCollapsed:n=>{e({isSidebarCollapsed:n})},setShowAgentReasoning:n=>{e({showAgentReasoning:n})},setTranscriptDisplayMode:n=>{e({transcriptDisplayMode:n})},setTheme:n=>{e({themeName:n})},setCanvasOpen:n=>{e(r=>n?{...Ct("isCanvasOpen"),...Gt(r,"canvas")}:{isCanvasOpen:!1,...Un(r,"canvas")})},setRunPanelOpen:n=>{e(r=>n?{...Ct("isRunPanelOpen"),...Gt(r,"run")}:{isRunPanelOpen:!1,...Un(r,"run")})},setBrowserPaneOpen:n=>{e(r=>n?{...Ct("isBrowserPaneOpen"),...Gt(r,"browser")}:{isBrowserPaneOpen:!1,...Un(r,"browser")})},setConsolePaneOpen:n=>{e(r=>n?{...Ct("isConsolePaneOpen"),...Gt(r,"console")}:{isConsolePaneOpen:!1,...Un(r,"console")})},setCodeReviewPaneOpen:n=>{e(r=>n?{...Ct("isCodeReviewPaneOpen"),...Gt(r,"code")}:{isCodeReviewPaneOpen:!1,...Un(r,"code")})},clearCodeReviewReveal:n=>{e(r=>r.codeReviewReveal?.nonce===n?{codeReviewReveal:null}:{})},revealCodeReviewPane:()=>{e(n=>({...Ct("isCodeReviewPaneOpen"),...Gt(n,"code"),codeReviewReveal:{nonce:(n.codeReviewReveal?.nonce??0)+1}}))},setAskDrawerOpen:(n,r,s)=>{e(i=>{const a=typeof i.rightSlotKey=="string";if(n)return{...Ct("isAskDrawerOpen"),askDrawerScope:r,askDrawerEvictedPane:a?null:fS(i),askOpenIntent:null};const l={isAskDrawerOpen:!1,askDrawerEvictedPane:null,askOpenIntent:null};return a?s?.dismissSlot?{...l,...pS(i)}:{...l,...ql(i.rightSlotMemory,i.rightSlotKey,!1)}:i.rightSlotKey===null?s?.dismissSlot?{...l,rightSlotLegacySeed:null}:l:s?.dismissSlot?{...l,rightSlotLegacySeed:null}:{...l,...i.askDrawerEvictedPane===null?null:{[i.askDrawerEvictedPane]:!0}}})},requestAskOpen:(n,r="menu")=>{e({askOpenIntent:{scope:n,via:r}})},clearAskOpenIntent:n=>{e(r=>r.askOpenIntent?.scope===n?{askOpenIntent:null}:{})},setConsoleActiveSurface:n=>{e({consoleActiveSurface:n})},requestConsoleOpen:n=>{e({consoleOpenIntent:n})},clearConsoleOpenIntent:n=>{e(r=>r.consoleOpenIntent===n?{consoleOpenIntent:null}:{})},setConsoleLiveSurface:(n,r)=>{e(s=>{if(n===null||r<=0)return s.consoleLiveSurface===null?{}:{consoleLiveSurface:null};const i=s.consoleLiveSurface;return i?.sessionId===n&&i.count===r?{}:{consoleLiveSurface:{sessionId:n,count:r}}})},markConsoleUnseen:(n,r)=>{e(s=>s.consoleUnseen.some(i=>i.surface===r)?{}:{consoleUnseen:[...s.consoleUnseen,{sessionId:n,surface:r,at:Date.now()}]})},clearConsoleUnseen:n=>{const r=Array.isArray(n)?n:[n];e(s=>{const i=s.consoleUnseen.filter(a=>!r.includes(a.surface));return i.length===s.consoleUnseen.length?{}:{consoleUnseen:i}})},setRightSlotWidth:n=>{e({rightSlotWidth:n})},restoreDefaultRightSlotWidth:()=>{e({rightSlotWidth:0})},bindRightSlotKey:(n,r)=>{e(s=>{let i=s.rightSlotMemory,a=s.rightSlotLegacySeed;const l=r?.admittedFrom;return typeof l=="string"&&typeof n=="string"&&(i=cS(i,l,n)),n===null||(Uo(n)?a=null:a!==null&&Rr(i,n)===void 0&&(i=Uu(i,n,a),a=null)),{rightSlotKey:n,rightSlotMemory:i,rightSlotLegacySeed:a,...ql(i,n,s.isAskDrawerOpen)}})},setRightSlotRoute:n=>{const r=t().rightSlotRoute;r.mounted===n.mounted&&r.session===n.session||e({rightSlotRoute:{...n}})},setShortcutBinding:(n,r)=>{if(r===null){e(i=>{const a={...i.shortcutBindings};return delete a[n],{shortcutBindings:a}});return}const s=$o(r);s!==null&&sS(s,n,t().shortcutBindings)===null&&e(i=>({shortcutBindings:{...i.shortcutBindings,[n]:s}}))},clearShortcutBinding:n=>{e(r=>({shortcutBindings:{...r.shortcutBindings,[n]:null}}))},setBrowserPaneScope:n=>{e({browserPaneScope:n})},revealRunPanelSection:n=>{e(r=>({...Ct("isRunPanelOpen"),...Gt(r,"run"),runPanelReveal:{section:n,nonce:(r.runPanelReveal?.nonce??0)+1}}))},clearRunPanelReveal:n=>{e(r=>r.runPanelReveal?.nonce===n?{runPanelReveal:null}:{})},setChatSidebarWidth:n=>{e({chatSidebarWidth:Math.min(Iu,Math.max(Eu,n))})},setChatSidebarRegions:n=>{e({chatSidebarRegions:n})},setChatSidebarListHeight:n=>{e({chatSidebarListHeight:n})},restoreDefaultChatSidebarListHeight:()=>{e({chatSidebarListHeight:null})},setChatSidebarOrder:n=>{e({chatSidebarOrder:n})},setChatSidebarView:n=>{e({chatSidebarView:n})},dismissBuiltinOffer:n=>{e({dismissedBuiltinOfferSignature:n})},restoreDefaultChatSidebarWidth:()=>{e({chatSidebarWidth:tc})},rememberMention:(n,r)=>{e(s=>{const i=s.mentionRecents,a=i?.cwd===n?i.paths:[],l=[r,...a.filter(c=>c!==r)].slice(0,mS);return{mentionRecents:{cwd:n,paths:l}}})},rememberProfile:(n,r)=>{e(s=>({profileRecents:{...s.profileRecents,[n]:RS(s.profileRecents[n]??[],r)}}))},rememberConversation:n=>{e(r=>{const s=xS(r.conversationRecents),i=ES(s,n);return i.length===s.length&&i.every((a,l)=>a===s[l])?r:{conversationRecents:i}})}}),{name:"ui-preferences-storage",version:SS,migrate:OS,partialize:TS,merge:AS}));function RS(e,t){return[t,...e.filter(n=>n!==t)].slice(0,gS)}function ES(e,t){return[t,...e.filter(n=>n!==t)].slice(0,yS)}const IS=[];function xS(e){return Array.isArray(e)?e:IS}function TS(e){const{runPanelReveal:t,codeReviewReveal:n,consoleOpenIntent:r,consoleLiveSurface:s,askOpenIntent:i,isAskDrawerOpen:a,askDrawerScope:l,askDrawerEvictedPane:c,rightSlotRoute:d,isCanvasOpen:u,isRunPanelOpen:f,isBrowserPaneOpen:p,isConsolePaneOpen:h,isCodeReviewPaneOpen:g,rightSlotKey:m,...y}=e;return{...y,rightSlotMemory:CS(e.rightSlotMemory)}}function CS(e){return(e??Fu).filter(([t])=>!Uo(t))}function AS(e,t){const n=e??{},{isCanvasOpen:r,isRunPanelOpen:s,isBrowserPaneOpen:i,isConsolePaneOpen:a,isCodeReviewPaneOpen:l,...c}=n;return{...t,...c,finderFiles:No(n.finderFiles),rightSlotKey:t.rightSlotKey,rightSlotMemory:dS(n.rightSlotMemory),rightSlotLegacySeed:$u(n.rightSlotLegacySeed)?n.rightSlotLegacySeed:null,shortcutBindings:iS(n.shortcutBindings)}}function OS(e,t){const n={...e??{}};if(t<1&&PS(n),t<2)for(const r of kS)delete n[r];if(t<3){let r=null;for(const s of Ji)if(n[ec(s)]===!0){r=s;break}r!==null&&(n.rightSlotLegacySeed=r);for(const s of Ji)delete n[ec(s)]}return t<4&&(n.finderFiles=No(n.finderFiles)),n}function PS(e){const t=[["canvasWidth",800],["runPanelWidth",420],["browserPanelWidth",640],["consolePanelWidth",796]];let n=0;for(const[r,s]of t){const i=e[r];if(typeof i=="number"&&i>0&&i!==s){n=i;break}}for(const[r]of t)delete e[r];e.rightSlotWidth=n}const Bu={settings:["desktop","settings"],capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"],catalogue:["desktop","models"],credentials:e=>["desktop","credentials",e]},jS=3e4,MS=15e3;function DS(e){return e?.desktop_available===!0}function YI(){const{client:e,provided:t}=u0();return fu({enabled:t,queryKey:Bu.capabilities,queryFn:async()=>{try{return await xe({op:"capabilities"})}catch(n){throw n instanceof Error?n:new Error(String(n))}},staleTime:6e4,retry:!1,refetchInterval:n=>DS(n.state.data)?jS:MS,refetchIntervalInBackground:!0},e)}function NS(e,t,n=1){return e?e.desktop_available?(e.features?.[t]??0)>=n?"enabled":"below-version":"unpaired":"unknown"}function QI(e,t,n=1){return NS(e,t,n)==="enabled"}function JI(e){return fu({queryKey:Bu.providers,queryFn:()=>xe({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:i0})}const Xi=e=>e.replace(/\\/g,"/"),XI=()=>window.location.hash?Xi(window.location.hash.substring(1)):Xi(window.location.pathname),qI=(e,t)=>{if(t!==null&&(e===t||e.startsWith(`${t}/`)||e.startsWith(`${t}\\`))){const r=e.substring(t.length);return r.startsWith("/")||r.startsWith("\\")||r===""?`~${r.replace(/\\/g,"/")}`:`~/${r.replace(/\\/g,"/")}`}return e==="~"?"~":e.replace(/\\/g,"/")},ex=(e,t)=>{if(e.length<=t)return e;const n=e.split("/"),r=n[n.length-1]??"";if(r.length+1>=t)return`…${r.slice(-39)}`;const s=n[0]==="~"||n[0]==="",i=s?n.slice(0,2):n.slice(0,1),a=n.slice(i.length),l=g=>{const m=t-g.length-(g?3:2);let y=[];for(let _=a.length-1;_>=0;_-=1){const v=[a[_],...y];if(v.join("/").length>m)break;y=v}return y},c=(g,m)=>g?`${g}/…/${m.join("/")}`:`…/${m.join("/")}`,d=i.join("/"),u=l(d);if(u.length>0)return u.length===a.length?e:c(d,u);const f=s?n[0]:"",p=l(f);if(p.length>0)return c(f,p);const h=t-(f?`${f}/…/`.length:2);return h>0?c(f,[r.slice(-h)]):"…"},tx=(e,t)=>Xi(e).includes(t);export{Bu as $,UE as A,dE as B,Fd as C,ye as D,iE as E,Bd as F,oE as G,cE as H,sE as I,lE as J,NS as K,XI as L,Yd as M,BE as N,kE as O,xa as P,RE as Q,aE as R,Ue as S,ws as T,Hd as U,rI as V,xS as W,_r as X,YR as Y,t0 as Z,ms as _,YI as a,W_ as a$,Fp as a0,Qb as a1,Ul as a2,DE as a3,ME as a4,uw as a5,JE as a6,uk as a7,Qp as a8,Jp as a9,lw as aA,iw as aB,ow as aC,Gl as aD,dw as aE,Hl as aF,cw as aG,aw as aH,tx as aI,FS as aJ,US as aK,$S as aL,BS as aM,hp as aN,st as aO,Yn as aP,Qh as aQ,WI as aR,UI as aS,Je as aT,ZR as aU,$t as aV,da as aW,to as aX,nh as aY,ps as aZ,yc as a_,ja as aa,ZS as ab,zS as ac,GS as ad,xR as ae,wR as af,kR as ag,RR as ah,Pd as ai,ks as aj,Rs as ak,Lu as al,sS as am,tg as an,pb as ao,XE as ap,Qi as aq,DI as ar,PE as as,Sb as at,wb as au,Sr as av,Pe as aw,ru as ax,ew as ay,rw as az,VE as b,mI as b$,rE as b0,X as b1,fn as b2,nE as b3,ji as b4,Mi as b5,eE as b6,tE as b7,QR as b8,JR as b9,lI as bA,EI as bB,II as bC,xI as bD,pE as bE,uE as bF,Qd as bG,OE as bH,TI as bI,vI as bJ,_I as bK,bn as bL,pn as bM,oI as bN,ju as bO,uI as bP,kI as bQ,yr as bR,SI as bS,RI as bT,gI as bU,yI as bV,Pl as bW,pI as bX,fI as bY,hI as bZ,x0 as b_,XR as ba,FI as bb,VI as bc,bS as bd,ZI as be,s0 as bf,QE as bg,YE as bh,KE as bi,Rc as bj,ok as bk,qS as bl,vb as bm,Ec as bn,Xi as bo,em as bp,yp as bq,jE as br,vp as bs,Mo as bt,nk as bu,Cl as bv,ak as bw,fb as bx,L0 as by,Ql as bz,QI as c,q_ as c$,cI as c0,bI as c1,wI as c2,E0 as c3,fE as c4,Ss as c5,aI as c6,EE as c7,iI as c8,dI as c9,_S as cA,Yl as cB,xu as cC,Sm as cD,vR as cE,_R as cF,xE as cG,IE as cH,TE as cI,AE as cJ,CE as cK,hk as cL,wr as cM,ku as cN,ZE as cO,Ro as cP,VR as cQ,TR as cR,Vd as cS,ob as cT,_s as cU,bE as cV,wE as cW,Am as cX,KR as cY,OR as cZ,T_ as c_,CI as ca,AI as cb,PI as cc,jI as cd,W0 as ce,OI as cf,MI as cg,HS as ch,sI as ci,qI as cj,ex as ck,NI as cl,zE as cm,Mv as cn,pk as co,HI as cp,hS as cq,GI as cr,qE as cs,Cu as ct,Au as cu,ik as cv,sk as cw,nc as cx,Fn as cy,vS as cz,xe as d,Av as d$,Zd as d0,J_ as d1,Tl as d2,hE as d3,h0 as d4,_E as d5,qR as d6,YS as d7,QS as d8,dk as d9,FE as dA,GE as dB,ck as dC,fk as dD,Ze as dE,db as dF,u0 as dG,kc as dH,zI as dI,eI as dJ,tI as dK,l0 as dL,Ki as dM,Tu as dN,Iu as dO,Eu as dP,JS as dQ,ha as dR,Mh as dS,XS as dT,Sp as dU,$R as dV,UR as dW,VS as dX,KS as dY,LR as dZ,jd as d_,o as da,$I as db,Ut as dc,Qt as dd,gi as de,nI as df,HE as dg,e0 as dh,Ou as di,Hb as dj,K0 as dk,NE as dl,Uo as dm,BI as dn,Ng as dp,$i as dq,pr as dr,Vb as ds,sw as dt,rn as du,gu as dv,$E as dw,Fw as dx,pu as dy,LE as dz,JI as e,$k as e$,ld as e0,Du as e1,Wc as e2,Lh as e3,ek as e4,bR as e5,SR as e6,AR as e7,CR as e8,ER as e9,dR as eA,ry as eB,Vs as eC,lR as eD,ay as eE,rR as eF,Kk as eG,tR as eH,pR as eI,Vk as eJ,nR as eK,iR as eL,mR as eM,hR as eN,sR as eO,Yk as eP,Qk as eQ,Jk as eR,Xk as eS,qk as eT,eR as eU,fR as eV,_p as eW,bp as eX,wp as eY,km as eZ,Dc as e_,mn as ea,rk as eb,lk as ec,tk as ed,Oc as ee,en as ef,Ot as eg,zk as eh,Zk as ei,Hk as ej,Gk as ek,Nk as el,zc as em,Fk as en,Ok as eo,Pk as ep,Mk as eq,gR as er,Dm as es,Bk as et,oy as eu,cR as ev,nd as ew,uR as ex,oR as ey,aR as ez,n0 as f,Hc as f0,Fc as f1,Ik as f2,ga as f3,$o as f4,V0 as f5,Dk as f6,mg as f7,Uk as f8,Wk as f9,jR as fA,cr as fB,oo as fC,fm as fD,pm as fE,gp as fF,yk as fG,_k as fH,Ha as fI,gk as fJ,mk as fK,vk as fL,bc as fM,bk as fN,wk as fO,yE as fP,PR as fQ,NR as fR,MR as fS,DR as fT,mE as fU,gE as fV,Sk as fW,ma as fX,Lk as fa,vg as fb,Rk as fc,Gm as fd,xk as fe,Tk as ff,Ak as fg,Ck as fh,jk as fi,yR as fj,GR as fk,FR as fl,Hv as fm,WR as fn,BR as fo,HR as fp,zR as fq,kk as fr,Ek as fs,hs as ft,eo as fu,_i as fv,xp as fw,Yb as fx,IR as fy,Xs as fz,no as g,fu as h,Np as i,Lp as j,$p as k,Up as l,LI as m,WE as n,vE as o,WS as p,Qe as q,i0 as r,SE as s,rb as t,qb as u,tb as v,KI as w,We as x,Y0 as y,$w as z};
|